RDK Documentation (Open Sourced RDK Components)
pixelResolution.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 pixelResolution.cpp
22  * @brief This file contains implementation of PixelResolution class methods,
23  * support functions and variable assignments to manage the video resolutions.
24  */
25 
26 
27 
28 /**
29 * @defgroup devicesettings
30 * @{
31 * @defgroup ds
32 * @{
33 **/
34 
35 
36 #include "dsTypes.h"
37 #include "dsUtl.h"
38 #include "pixelResolution.hpp"
39 #include "illegalArgumentException.hpp"
40 #include "videoOutputPortConfig.hpp"
41 #include "dslogger.h"
42 
43 namespace {
44  const char *_names[] = {
45  "720x480",
46  "720x576",
47  "1280x720",
48  "1920x1080",
49 
50  "3840x2160",
51  "4096x2160",
52 
53  };
54 
55  inline const bool isValid(int id) {
57  }
58 }
59 
60 
61 namespace device {
62 typedef int _SafetyCheck[(dsUTL_DIM(_names) == dsVIDEO_PIXELRES_MAX) ? 1 : -1];
63 
68 
71 
73 
74 
75 /**
76  * @fn PixelResolution::getInstance(int id)
77  * @brief This function gets the instance of PixelResolution against the specified id,
78  * only if the id passed is valid.
79  *
80  * @param[in] id Indicates the id against which the PixelResolution instance is required.
81  *
82  * @return Returns an instance of PixelResolution if the specified id is valid else
83  * throws an IllegalArgumentException.
84  */
86 {
87  if (::isValid(id)) {
88  return VideoOutputPortConfig::getInstance().getPixelResolution(id);
89  }
90  else {
92  }
93 }
94 
95 
96 /**
97  * @fn PixelResolution::PixelResolution(int id)
98  * @brief This function is a parameterised constructor for PixelResolution. It
99  * initializes the instance with the specified id and the name corresponding
100  * to it. If the id passed is invalid then it throws an IllegalArgumentException.
101  *
102  * @param[in] id Indicates the id for the instance with is used to identify
103  * the pixel resolution type.
104  *
105  * @return None
106  */
108 {
109  if (::isValid(id)) {
110  _id = id;
111  _name = std::string(_names[id]);
112  }
113  else {
114  throw IllegalArgumentException();
115  }
116 }
117 
118 
119 /**
120  * @fn PixelResolution::~PixelResolution()
121  * @brief This function is the default destructor for PixelResolution.
122  *
123  * @return None
124  */
126 {
127 }
128 
129 }
130 
131 
132 /** @} */
133 /** @} */
device::DSConstant::_id
int _id
Indicates the id of the instance inheriting this class.
Definition: dsConstant.hpp:57
device::PixelResolution::kMax
static const int kMax
Indicates the maximum number of video resolutions supported.
Definition: pixelResolution.hpp:63
dsVIDEO_PIXELRES_720x576
@ dsVIDEO_PIXELRES_720x576
Definition: dsTypes.h:460
device::PixelResolution::k1280x720
static const int k1280x720
Indicates 1280x720 video resolution.
Definition: pixelResolution.hpp:57
device::PixelResolution
This class extends DSConstant to manages the pixel resolution of the video.
Definition: pixelResolution.hpp:51
dsTypes.h
Device Settings HAL types.
dsVIDEO_PIXELRES_1280x720
@ dsVIDEO_PIXELRES_1280x720
Definition: dsTypes.h:461
device::PixelResolution::getInstance
static const PixelResolution & getInstance(int id)
This function gets the instance of PixelResolution against the specified id, only if the id passed is...
Definition: pixelResolution.cpp:85
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
device::PixelResolution::k3840x2160
static const int k3840x2160
Indicates 3840x2160 video resolution.
Definition: pixelResolution.hpp:60
dsUtl.h
Device Settings HAL utilities.
device::PixelResolution::k1920x1080
static const int k1920x1080
Indicates 1920x1080 video resolution.
Definition: pixelResolution.hpp:58
device::DSConstant::_name
std::string _name
Indicates the name string of the instance inheriting this class.
Definition: dsConstant.hpp:58
device::PixelResolution::k720x480
static const int k720x480
Indicates 720x480 video resolution.
Definition: pixelResolution.hpp:55
dsVideoPortPixelResolution_isValid
#define dsVideoPortPixelResolution_isValid(t)
Definition: dsTypes.h:497
dsVIDEO_PIXELRES_720x480
@ dsVIDEO_PIXELRES_720x480
Definition: dsTypes.h:459
device::PixelResolution::k4096x2160
static const int k4096x2160
Indicates 4096x2160 video resolution.
Definition: pixelResolution.hpp:61
dsVIDEO_PIXELRES_MAX
@ dsVIDEO_PIXELRES_MAX
Definition: dsTypes.h:467
device::IllegalArgumentException
This class extends Exception class to manage the expections caused due to illegal arguments.
Definition: illegalArgumentException.hpp:51
device::PixelResolution::k720x576
static const int k720x576
Indicates 720x576 video resolution.
Definition: pixelResolution.hpp:56
device::PixelResolution::~PixelResolution
virtual ~PixelResolution()
This function is the default destructor for PixelResolution.
Definition: pixelResolution.cpp:125
dsVIDEO_PIXELRES_1920x1080
@ dsVIDEO_PIXELRES_1920x1080
Definition: dsTypes.h:462
device::PixelResolution::PixelResolution
PixelResolution(int id)
This function is a parameterised constructor for PixelResolution. It initializes the instance with th...
Definition: pixelResolution.cpp:107
dsVIDEO_PIXELRES_4096x2160
@ dsVIDEO_PIXELRES_4096x2160
Definition: dsTypes.h:465
dsUTL_DIM
#define dsUTL_DIM(arr)
Device Settings general Array dimension calculation inline definition.
Definition: dsUtl.h:85
pixelResolution.hpp
This file defines PixelResolution class for managing video resolution types.
dsVIDEO_PIXELRES_3840x2160
@ dsVIDEO_PIXELRES_3840x2160
Definition: dsTypes.h:464