RDK Documentation (Open Sourced RDK Components)
frameRate.cpp
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 
22 /**
23 * @defgroup devicesettings
24 * @{
25 * @defgroup ds
26 * @{
27 **/
28 
29 
30 #include "frameRate.hpp"
31 #include "illegalArgumentException.hpp"
32 #include "videoOutputPortConfig.hpp"
33 #include "dsTypes.h"
34 #include "dsUtl.h"
35 #include "dslogger.h"
36 
37 namespace {
38  const float _values[] = {
39  0, //unkown
40  24,
41  25,
42  30,
43  60,
44  23.98,
45  29.97,
46  50,
47  59.94,
48  };
49  const char * _names[] = {
50  "UnKnown", //unkown
51  "24",
52  "25",
53  "30",
54  "60",
55  "23.98",
56  "29.97",
57  "50",
58  "59.94",
59  };
60 
61  inline const bool isValid(int id) {
63  }
64 
65 }
66 
67 namespace device {
68 typedef int _SafetyCheck[(dsUTL_DIM(_values) == dsVIDEO_FRAMERATE_MAX) ? 1 : -1];
69 typedef int _SafetyCheck[(dsUTL_DIM(_names) == dsVIDEO_FRAMERATE_MAX) ? 1 : -1];
70 
81 
82 const FrameRate & FrameRate::getInstance(int id)
83 {
84  if (::isValid(id)) {
85  return VideoOutputPortConfig::getInstance().getFrameRate(id);
86  }
87  else {
88  throw IllegalArgumentException();
89  }
90 }
91 
92 FrameRate::FrameRate(int id)
93 {
94  if (::isValid(id)) {
95  _value = _values[id];
96  _name = std::string(_names[id]);
97  _id = id;
98  }
99  else {
100  throw IllegalArgumentException();
101  }
102 
103 }
104 
105 FrameRate::FrameRate(float value) : _value(value){
106  if (_value == 24.0) {
107  _id = dsVIDEO_FRAMERATE_24;
108  }
109  else if (_value == 24.0) {
110  _id = dsVIDEO_FRAMERATE_25;
111  }
112  else if (_value == 24.0) {
113  _id = dsVIDEO_FRAMERATE_30;
114  }
115  else if (_value == 24.0) {
116  _id = dsVIDEO_FRAMERATE_60;
117  }
118  else if (_value == 24.0) {
119  _id = dsVIDEO_FRAMERATE_60;
120  }
121  else if (_value == 24.0) {
123  }
124  else if (_value == 24.0) {
126  }
127  else if (_value == 24.0) {
128  _id = dsVIDEO_FRAMERATE_50;
129  }
130  else if (_value == 24.0) {
132  }
133  else {
134  throw IllegalArgumentException();
135  }
136 
137  _name = std::string(_names[_id]);
138 }
139 
140 
141 FrameRate::~FrameRate() {
142  // TODO Auto-generated destructor stub
143 }
144 
145 
146 
147 }
148 
149 
150 /** @} */
151 /** @} */
device::DSConstant::_id
int _id
Indicates the id of the instance inheriting this class.
Definition: dsConstant.hpp:57
dsVIDEO_FRAMERATE_25
@ dsVIDEO_FRAMERATE_25
Definition: dsTypes.h:505
dsVIDEO_FRAMERATE_UNKNOWN
@ dsVIDEO_FRAMERATE_UNKNOWN
Definition: dsTypes.h:503
dsVIDEO_FRAMERATE_60
@ dsVIDEO_FRAMERATE_60
Definition: dsTypes.h:507
dsVIDEO_FRAMERATE_23dot98
@ dsVIDEO_FRAMERATE_23dot98
Definition: dsTypes.h:508
dsVIDEO_FRAMERATE_30
@ dsVIDEO_FRAMERATE_30
Definition: dsTypes.h:506
device::FrameRate::_value
float _value
Indicates the supported frame rate value in fps.
Definition: frameRate.hpp:50
dsVideoPortFrameRate_isValid
#define dsVideoPortFrameRate_isValid(t)
Definition: dsTypes.h:518
dsVIDEO_FRAMERATE_59dot94
@ dsVIDEO_FRAMERATE_59dot94
Definition: dsTypes.h:511
dsTypes.h
Device Settings HAL types.
dsVIDEO_FRAMERATE_MAX
@ dsVIDEO_FRAMERATE_MAX
Definition: dsTypes.h:512
dsVIDEO_FRAMERATE_29dot97
@ dsVIDEO_FRAMERATE_29dot97
Definition: dsTypes.h:509
device::FrameRate::k29dot97
static const int k29dot97
Indicates video frame rate of 29.97 fps.
Definition: frameRate.hpp:58
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
dsUtl.h
Device Settings HAL utilities.
device::FrameRate::k50
static const int k50
Indicates video frame rate of 50 fps.
Definition: frameRate.hpp:59
device::FrameRate::k59dot94
static const int k59dot94
Indicates video frame rate of 59.94 fps.
Definition: frameRate.hpp:60
device::FrameRate::k24
static const int k24
Indicates video frame rate of 24 fps.
Definition: frameRate.hpp:53
device::FrameRate::k60
static const int k60
Indicates video frame rate of 60 fps.
Definition: frameRate.hpp:56
frameRate.hpp
This file defines FrameRate class to manage the video frame rate types.
dsVIDEO_FRAMERATE_50
@ dsVIDEO_FRAMERATE_50
Definition: dsTypes.h:510
device::FrameRate::kMax
static const int kMax
Indicates maximum number of frame rates supported.
Definition: frameRate.hpp:61
device::DSConstant::_name
std::string _name
Indicates the name string of the instance inheriting this class.
Definition: dsConstant.hpp:58
device::FrameRate::k23dot98
static const int k23dot98
Indicates video frame rate of 23.98 fps.
Definition: frameRate.hpp:57
dsVIDEO_FRAMERATE_24
@ dsVIDEO_FRAMERATE_24
Definition: dsTypes.h:504
device::FrameRate::kUnknown
static const int kUnknown
Indicates video frame rate of unknown type.
Definition: frameRate.hpp:52
dsUTL_DIM
#define dsUTL_DIM(arr)
Device Settings general Array dimension calculation inline definition.
Definition: dsUtl.h:85
device::FrameRate::k30
static const int k30
Indicates video frame rate of 30 fps.
Definition: frameRate.hpp:55
device::FrameRate::k25
static const int k25
Indicates video frame rate of 25 fps.
Definition: frameRate.hpp:54