RDK Documentation (Open Sourced RDK Components)
compositeIn.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  * If not stated otherwise in this file or this component's Licenses.txt file the
21  * following copyright and licenses apply:
22  *
23  * Copyright ARRIS Enterprises, Inc. 2015.
24  *
25  * Licensed under the Apache License, Version 2.0 (the "License");
26  * you may not use this file except in compliance with the License.
27  * You may obtain a copy of the License at
28  *
29  * http://www.apache.org/licenses/LICENSE-2.0
30  *
31  * Unless required by applicable law or agreed to in writing, software
32  * distributed under the License is distributed on an "AS IS" BASIS,
33  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34  * See the License for the specific language governing permissions and
35  * limitations under
36 */
37 
38 
39 /**
40  * @file compositeIn.cpp
41  * @brief Configuration of COMPOSITE Input
42  */
43 
44 /**
45 * @defgroup devicesettings
46 * @{
47 * @defgroup ds
48 * @{
49 **/
50 
51 
52 #include <iostream>
53 #include <sstream>
54 #include <string>
55 #include <string.h>
56 #include "compositeIn.hpp"
57 #include "illegalArgumentException.hpp"
58 #include "host.hpp"
59 
60 #include "dslogger.h"
61 #include "dsError.h"
62 #include "dsTypes.h"
63 #include "dsCompositeIn.h"
64 #include "dsUtl.h"
65 
66 
67 namespace device
68 {
69 
70 
71 /**
72  * @fn CompositeInput::CompositeInput()
73  * @brief default constructor
74  *
75  * @param None
76  *
77  * @return None
78  * @callergraph
79  */
81 {
83 }
84 
85 /**
86  * @fn CompositeInput::~CompositeInput()
87  * @brief destructor
88  *
89  * @param None
90  *
91  * @return None
92  * @callergraph
93  */
95 {
97 }
98 
99 /**
100  * @fn CompositeInput::getInstance()
101  * @brief This API is used to get the instance of the COMPOSITE Input
102  *
103  * @param None
104  *
105  * @return Reference to the instance of COMPOSITE Input class instance
106  * @callergraph
107  */
109 {
110  static CompositeInput _singleton;
111  return _singleton;
112 }
113 
114 /**
115  * @fn CompositeInput::getNumberOfInputs()
116  * @brief This API is used to get the number of COMPOSITE Input ports on the set-top
117  *
118  * @param[in] None
119  *
120  * @return number of COMPOSITE Inputs
121  * @callergraph
122  */
124 {
125  uint8_t numCompositeInputs;
126  dsError_t eError = dsCompositeInGetNumberOfInputs (&numCompositeInputs);
127 
128  // Throw an exception if there was an error
129  if (dsERR_NONE != eError)
130  {
131  throw Exception(eError);
132  }
133 
134  return (numCompositeInputs);
135 }
136 
137 /**
138  * @fn CompositeInput::isPresented()
139  * @brief This API is used to specify if COMPOSITE Input is being
140  * presented via COMPOSITE Out
141  *
142  * @param[in] None
143  *
144  * @return true if COMPOSITE Input is being presetned.
145  * @callergraph
146  */
148 {
149  dsCompositeInStatus_t Status;
150  dsError_t eError = dsCompositeInGetStatus (&Status);
151 
152  // Throw an exception if there was an error
153  if (dsERR_NONE != eError)
154  {
155  throw Exception(eError);
156  }
157  return (Status.isPresented);
158 }
159 
160 /**
161  * @fn CompositeInput::isActivePort()
162  * @brief This API is used to specify if the provided COMPOSITE Input port is
163  * active (i.e. communicating with the set-top)
164  *
165  * @param[in] COMPOSITE Input port
166  *
167  * @return true if the provided COMPOSITE Input port is active.
168  * @callergraph
169  */
170 bool CompositeInput::isActivePort(int8_t Port) const
171 {
172  dsCompositeInStatus_t Status;
173  dsError_t eError = dsCompositeInGetStatus (&Status);
174 
175  // Throw an exception if there was an error
176  if (dsERR_NONE != eError)
177  {
178  throw Exception(eError);
179  }
180  return (Status.activePort == Port);
181 }
182 
183 /**
184  * @fn CompositeInput::getActivePort()
185  * @brief This API is used to specify the active (i.e. communicating with
186  * the set-top) COMPOSITE Input port
187  *
188  * @param[in] None
189  *
190  * @return the COMPOSITE Input port which is currently active.
191  * @callergraph
192  */
194 {
195  dsCompositeInStatus_t Status;
196  dsError_t eError = dsCompositeInGetStatus (&Status);
197 
198  // Throw an exception if there was an error
199  if (dsERR_NONE != eError)
200  {
201  throw Exception(eError);
202  }
203  return (Status.activePort);
204 }
205 
206 /**
207  * @fn CompositeInput::isPortConnected()
208  * @brief This API is used to specify if the prvided COMPOSITE Input port is
209  * connected (i.e. COMPOSITE Input devie is plugged into the set-top).
210  *
211  * @param[in] COMPOSITE Input port
212  *
213  * @return true if the COMPOSITE Input port is connected
214  * @callergraph
215  */
216 bool CompositeInput::isPortConnected(int8_t Port) const
217 {
218  dsCompositeInStatus_t Status;
219  dsError_t eError = dsCompositeInGetStatus (&Status);
220 
221  // Throw an exception if there was an error
222  if (dsERR_NONE != eError)
223  {
224  throw Exception(eError);
225  }
226  return (Status.isPortConnected[Port]);
227 }
228 
229 /**
230  * @fn CompositeInput::selectPort()
231  * @brief This API is used to select the COMPOSITE In port to be presented
232  *
233  * @param[in] int8_t Port : -1 for No COMPOSITE Input port to be presented
234  * 0..n for COMPOSITE Input port (n) to be presented
235  *
236  * @return None
237  * @callergraph
238  */
239 void CompositeInput::selectPort (int8_t Port) const
240 {
241  dsError_t eError = dsCompositeInSelectPort ((dsCompositeInPort_t)Port);
242 
243  // Throw an exception if there was an error
244  if (dsERR_NONE != eError)
245  {
246  throw Exception(eError);
247  }
248 }
249 
250 /**
251  * @fn CompositeInput::scaleVideo()
252  * @brief This API is used to scale the COMPOSITE In video
253  *
254  * @param[in] int32_t x : x coordinate for the video
255  * @param[in] int32_t y : y coordinate for the video
256  * @param[in] int32_t width : width of the video
257  * @param[in] int32_t height : height of the video
258  *
259  * @return None
260  * @callergraph
261  */
262 void CompositeInput::scaleVideo (int32_t x, int32_t y, int32_t width, int32_t height) const
263 {
264  dsError_t eError = dsCompositeInScaleVideo (x, y, width, height);
265 
266  // Throw an exception if there was an error
267  if (dsERR_NONE != eError)
268  {
269  throw Exception(eError);
270  }
271 }
272 
273 }
274 
275 
276 /** @} */
277 /** @} */
dsCompositeInGetNumberOfInputs
dsError_t dsCompositeInGetNumberOfInputs(uint8_t *pNumberOfInputs)
Get the number of COMPOSITE Input ports on the set-top.
Definition: dsCompositeIn.c:100
dsCompositeInGetStatus
dsError_t dsCompositeInGetStatus(dsCompositeInStatus_t *pStatus)
Get the COMPOSITE Input Status.
Definition: dsCompositeIn.c:127
device::CompositeInput::~CompositeInput
virtual ~CompositeInput()
destructor
Definition: compositeIn.cpp:94
device::CompositeInput::isActivePort
bool isActivePort(int8_t Port) const
This API is used to specify if the provided COMPOSITE Input port is active (i.e. communicating with t...
Definition: compositeIn.cpp:170
dsCompositeInScaleVideo
dsError_t dsCompositeInScaleVideo(int32_t x, int32_t y, int32_t width, int32_t height)
Scale the COMPOSITE In video This function is used to scale the COMPOSITE In video.
Definition: dsCompositeIn.c:178
dsTypes.h
Device Settings HAL types.
_dsCompositeInStatus_t::activePort
dsCompositeInPort_t activePort
Definition: dsTypes.h:1080
dsCompositeInInit
dsError_t dsCompositeInInit(void)
Initialize the underlying COMPOSITE Input sub-system.
Definition: dsCompositeIn.c:58
device::CompositeInput::getNumberOfInputs
uint8_t getNumberOfInputs() const
This API is used to get the number of COMPOSITE Input ports on the set-top.
Definition: compositeIn.cpp:123
dsCompositeInTerm
dsError_t dsCompositeInTerm(void)
Terminate the underlying COMPOSITE Input sub-system.
Definition: dsCompositeIn.c:79
dsError.h
Device Settings HAL error codes.
_dsCompositeInStatus_t::isPortConnected
bool isPortConnected[dsCOMPOSITE_IN_PORT_MAX]
Definition: dsTypes.h:1079
dsUtl.h
Device Settings HAL utilities.
compositeIn.hpp
Structures and classes for COMPOSITE Input are defined here.
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
dsCompositeInSelectPort
dsError_t dsCompositeInSelectPort(dsCompositeInPort_t Port)
Select the COMPOSITE Input port to be presented.
Definition: dsCompositeIn.c:154
_dsCompositeInStatus_t
Definition: dsTypes.h:1076
device::CompositeInput::isPortConnected
bool isPortConnected(int8_t Port) const
This API is used to specify if the prvided COMPOSITE Input port is connected (i.e....
Definition: compositeIn.cpp:216
device::Exception
This class handles exceptions occurring in DS module.
Definition: exception.hpp:52
device::CompositeInput::selectPort
void selectPort(int8_t Port) const
This API is used to select the COMPOSITE In port to be presented.
Definition: compositeIn.cpp:239
device::CompositeInput::CompositeInput
CompositeInput()
default constructor
Definition: compositeIn.cpp:80
device::CompositeInput
This class manages COMPOSITE Input.
Definition: compositeIn.hpp:69
dsCompositeIn.h
Device Settings HAL COMPOSITE Input Public API. This API defines the HAL for the Device Settings COMP...
_dsCompositeInStatus_t::isPresented
bool isPresented
Definition: dsTypes.h:1078
device::CompositeInput::getInstance
static CompositeInput & getInstance()
This API is used to get the instance of the COMPOSITE Input.
Definition: compositeIn.cpp:108
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84
device::CompositeInput::scaleVideo
void scaleVideo(int32_t x, int32_t y, int32_t width, int32_t height) const
This API is used to scale the COMPOSITE In video.
Definition: compositeIn.cpp:262
device::CompositeInput::getActivePort
int8_t getActivePort() const
This API is used to specify the active (i.e. communicating with the set-top) COMPOSITE Input port.
Definition: compositeIn.cpp:193
device::CompositeInput::isPresented
bool isPresented() const
This API is used to specify if COMPOSITE Input is being presented via COMPOSITE Out.
Definition: compositeIn.cpp:147