RDK Documentation (Open Sourced RDK Components)
videoDFC.cpp
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @file videoDFC.cpp
22  * @brief This file contains implementation of VideoDFC class methods, support functions
23  * and variable assignments to manage the video decoder format conversions.
24  */
25 
26 
27 
28 
29 /**
30 * @defgroup devicesettings
31 * @{
32 * @defgroup ds
33 * @{
34 **/
35 
36 
37 #include "videoDFC.hpp"
38 #include "illegalArgumentException.hpp"
39 #include "videoDeviceConfig.hpp"
40 #include "dsTypes.h"
41 #include "dsUtl.h"
42 #include "dslogger.h"
43 #include <string.h>
44 
45 namespace {
46  const char *_names[] = {
47  "None",
48  "Full",
49  "Letterbox 16x9",
50  "Letterbox 14x9",
51  "CCO",
52  "PanScan",
53  "Letterbox 2.21 on 4x3",
54  "Letterbox 2.21 on 16x9",
55  "Platform",
56  "Zoom 16x9",
57  "Pillarbox 4x3",
58  "Widescreen 4x3",
59  };
60 
61  inline const bool isValid(int id) {
62  return dsVideoPortDFC_isValid(id);
63  }
64 
65 }
66 
67 namespace device {
68 typedef int _SafetyCheck[(dsUTL_DIM(_names) == dsVIDEO_ZOOM_MAX) ? 1 : -1];
69 
83 
84 
85 /**
86  * @fn VideoDFC::getInstance(int id)
87  * @brief This function gets an instance of VideoDFC against the id specified, only if the
88  * id passed is valid.
89  *
90  * @param[in] id Indicates the id for which the corresponding VideoDFC instance is required.
91  *
92  * @return Returns an instance of VideoDFC only if the specified id is valid else throws
93  * an IllegalArgumentException.
94  */
96 {
97  if (::isValid(id)) {
98  return VideoDeviceConfig::getInstance().getDFC(id);
99  }
100  else {
101  throw IllegalArgumentException();
102  }
103 }
104 
105 
106 /**
107  * @fn VideoDFC::getInstance(const std::string &name)
108  * @brief This function gets an instance of VideoDFC against the name specified, only if the
109  * name passed is valid.
110  *
111  * @param[in] name Indicates the name of the instance required.
112  *
113  * @return Returns an instance of VideoDFC only if the specified id is valid else throws
114  * an IllegalArgumentException.
115  */
116 const VideoDFC & VideoDFC::getInstance(const std::string &name)
117 {
118  for (size_t i = 0; i < dsUTL_DIM(_names); i++) {
119  if (name.compare(_names[i]) == 0) {
120  return VideoDFC::getInstance(i);
121  }
122  }
123 
124  throw IllegalArgumentException();
125 }
126 
127 
128 /**
129  * @fn VideoDFC::VideoDFC(int id)
130  * @brief This function is a parameterised constructor. It initializes the instance with
131  * the id provided and the name corresponding to the id. If the id passed is invalid then
132  * it throws an IllegalArgumentException.
133  *
134  * @param[in] id Indicates the id for the instance which is used to identify the video
135  * zoom type. For instance id indicates letterbox_16x9 and so on.
136  *
137  * @return None.
138  */
140 {
141  if (::isValid(id)) {
142  _id = id;
143  _name = std::string(_names[id]);
144  }
145  else {
146  throw IllegalArgumentException();
147  }
148 }
149 
150 
151 /**
152  * @fn VideoDFC::~VideoDFC()
153  * @brief This function is the default destructor for VideoDFC.
154  *
155  * @return None
156  */
158 {
159 }
160 
161 }
162 
163 
164 /** @} */
165 /** @} */
dsVIDEO_ZOOM_WIDE_4_3
@ dsVIDEO_ZOOM_WIDE_4_3
Definition: dsTypes.h:590
device::DSConstant::_id
int _id
Indicates the id of the instance inheriting this class.
Definition: dsConstant.hpp:57
dsVIDEO_ZOOM_UNKNOWN
@ dsVIDEO_ZOOM_UNKNOWN
Definition: dsTypes.h:578
device::VideoDFC::~VideoDFC
virtual ~VideoDFC()
This function is the default destructor for VideoDFC.
Definition: videoDFC.cpp:157
device::VideoDFC::kLetterBox_221x1ON4x3
static const int kLetterBox_221x1ON4x3
Indicates decoder format of type letter box 2:21:1 in a 4:3 video frame.
Definition: videoDFC.hpp:64
device::VideoDFC::VideoDFC
VideoDFC(int id)
This function is a parameterised constructor. It initializes the instance with the id provided and th...
Definition: videoDFC.cpp:139
dsVIDEO_ZOOM_CCO
@ dsVIDEO_ZOOM_CCO
Definition: dsTypes.h:583
dsTypes.h
Device Settings HAL types.
device::VideoDFC::kZoom_16x9
static const int kZoom_16x9
Indicates decoder format of type 16:9 zoom.
Definition: videoDFC.hpp:70
device::VideoDFC::kWideScreen_4x3
static const int kWideScreen_4x3
Indicates decoder format of type 4:3 wide.
Definition: videoDFC.hpp:74
dsVIDEO_ZOOM_16_9_ZOOM
@ dsVIDEO_ZOOM_16_9_ZOOM
Definition: dsTypes.h:588
device::VideoDFC::kPanScan
static const int kPanScan
Indicates decoder format of type pan and scan.
Definition: videoDFC.hpp:62
device::DSConstant::isValid
static bool isValid(int min, int max, int val)
This function checks if the given value lies between min and max values provided.
Definition: dsConstant.hpp:72
dsVIDEO_ZOOM_NONE
@ dsVIDEO_ZOOM_NONE
Definition: dsTypes.h:579
dsUtl.h
Device Settings HAL utilities.
device::VideoDFC::kPlatform
static const int kPlatform
Indicates decoding format conversion will be managed by the platform.
Definition: videoDFC.hpp:68
device::VideoDFC::getInstance
static const VideoDFC & getInstance(int id)
This function gets an instance of VideoDFC against the id specified, only if the id passed is valid.
Definition: videoDFC.cpp:95
device::VideoDFC
This class extends DSConstant to manage the video Decoder Format Conversion.
Definition: videoDFC.hpp:50
dsVIDEO_ZOOM_PAN_SCAN
@ dsVIDEO_ZOOM_PAN_SCAN
Definition: dsTypes.h:584
device::DSConstant::_name
std::string _name
Indicates the name string of the instance inheriting this class.
Definition: dsConstant.hpp:58
dsVIDEO_ZOOM_LB_14_9
@ dsVIDEO_ZOOM_LB_14_9
Definition: dsTypes.h:582
device::VideoDFC::kPillarBox_4x3
static const int kPillarBox_4x3
Indicates decoder format of type pillar box 4:3.
Definition: videoDFC.hpp:72
device::VideoDFC::kLetterBox_221x1ON16x9
static const int kLetterBox_221x1ON16x9
Indicates decoder format of type letter box 2:21:1 in a 16:9 video frame.
Definition: videoDFC.hpp:66
dsVIDEO_ZOOM_LB_2_21_1_ON_16_9
@ dsVIDEO_ZOOM_LB_2_21_1_ON_16_9
Definition: dsTypes.h:586
device::VideoDFC::kUnknown
static const int kUnknown
Indicates decoder format of type unknown.
Definition: videoDFC.hpp:53
dsVIDEO_ZOOM_LB_2_21_1_ON_4_3
@ dsVIDEO_ZOOM_LB_2_21_1_ON_4_3
Definition: dsTypes.h:585
device::VideoDFC::kLetterBox_16x9
static const int kLetterBox_16x9
Indicates decoder format of type letter box with 16:9 aspect ratio.
Definition: videoDFC.hpp:57
device::VideoDFC::kFull
static const int kFull
Indicates decoder format of type full.
Definition: videoDFC.hpp:55
dsVideoPortDFC_isValid
#define dsVideoPortDFC_isValid(t)
Definition: dsTypes.h:597
device::VideoDFC::kCCO
static const int kCCO
Indicates center cut out decoder format.
Definition: videoDFC.hpp:60
dsVIDEO_ZOOM_PILLARBOX_4_3
@ dsVIDEO_ZOOM_PILLARBOX_4_3
Definition: dsTypes.h:589
dsVIDEO_ZOOM_PLATFORM
@ dsVIDEO_ZOOM_PLATFORM
Definition: dsTypes.h:587
dsVIDEO_ZOOM_FULL
@ dsVIDEO_ZOOM_FULL
Definition: dsTypes.h:580
dsVIDEO_ZOOM_LB_16_9
@ dsVIDEO_ZOOM_LB_16_9
Definition: dsTypes.h:581
device::IllegalArgumentException
This class extends Exception class to manage the expections caused due to illegal arguments.
Definition: illegalArgumentException.hpp:51
device::VideoDFC::kNone
static const int kNone
Indicates decoder format of type none.
Definition: videoDFC.hpp:54
dsUTL_DIM
#define dsUTL_DIM(arr)
Device Settings general Array dimension calculation inline definition.
Definition: dsUtl.h:85
dsVIDEO_ZOOM_MAX
@ dsVIDEO_ZOOM_MAX
Definition: dsTypes.h:591
videoDFC.hpp
This file defines VideoDFC class for managing video decoder format conversion types.
device::VideoDFC::kLetterBox_14x9
static const int kLetterBox_14x9
Indicates decoder format of type letter box with 14:9 aspect ratio.
Definition: videoDFC.hpp:58