RDK Documentation (Open Sourced RDK Components)
dsVideoDevice.c
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 rpc
26 * @{
27 **/
28 
29 
30 #include "dsVideoDevice.h"
31 #include "dsclientlogger.h"
32 #include <sys/types.h>
33 #include <stdint.h>
34 #include <string.h>
35 #include "dsError.h"
36 #include "dsUtl.h"
37 #include "dsRpc.h"
38 #include "dsMgr.h"
39 #include "iarmUtil.h"
40 #include "libIBus.h"
41 #include "libIARM.h"
42 #include "dsTypes.h"
43 
44 #include "safec_lib.h"
45 
47 {
48  printf("<<<<< VID is initialized in Multi-App Mode >>>>>>>>\r\n");
49 
50  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
51 
52  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
53  (char *)IARM_BUS_DSMGR_API_dsVideoDeviceInit,
54  NULL,
55  0);
56 
57  if (IARM_RESULT_SUCCESS == rpcRet)
58  {
59  return dsERR_NONE;
60  }
61  return dsERR_GENERAL;
62 }
63 
64 dsError_t dsGetVideoDevice(int index, intptr_t *handle)
65 {
66  _DEBUG_ENTER();
67  _RETURN_IF_ERROR((handle) != NULL, dsERR_INVALID_PARAM);
68 
70  param.index = index;
71  param.handle = NULL;
72 
73  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
74 
75  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
76  (char *)IARM_BUS_DSMGR_API_dsGetVideoDevice,
77  (void *)&param,
78  sizeof(param));
79 
80  if (IARM_RESULT_SUCCESS == rpcRet)
81  {
82  *handle =param.handle;
83  return dsERR_NONE;
84  }
85 
86  return dsERR_GENERAL ;
87 }
88 
89 dsError_t dsSetDFC(intptr_t handle, dsVideoZoom_t dfc)
90 {
91  _DEBUG_ENTER();
92 
94  param.handle = handle;
95  param.dfc = dfc;
96 
97  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
98 
99 
100 
101  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
102  (char *)IARM_BUS_DSMGR_API_dsSetDFC,
103  (void *)&param,
104  sizeof(param));
105 
106  if (IARM_RESULT_SUCCESS == rpcRet)
107  {
108  return dsERR_NONE;
109  }
110 
111  return dsERR_GENERAL ;
112 
113 }
114 
115 
116 
117 dsError_t dsGetDFC(intptr_t handle, dsVideoZoom_t *dfc)
118 {
119  _DEBUG_ENTER();
120 
122  param.handle = handle;
123  param.dfc = dsVIDEO_ZOOM_NONE;
124 
125  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
126 
127  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
128  (char *)IARM_BUS_DSMGR_API_dsGetDFC,
129  (void *)&param,
130  sizeof(param));
131 
132  if (IARM_RESULT_SUCCESS == rpcRet)
133  {
134  *dfc = param.dfc;
135  return dsERR_NONE;
136  }
137 
138  return dsERR_GENERAL ;
139 
140 }
141 
142 
143 
145 {
146  _DEBUG_ENTER();
147 
148  IARM_Result_t rpcRet = IARM_RESULT_SUCCESS;
149  rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
150  (char *)IARM_BUS_DSMGR_API_dsVideoDeviceTerm,
151  NULL,
152  0);
153 
154  if (IARM_RESULT_SUCCESS == rpcRet)
155  {
156  return dsERR_NONE;
157  }
158 
159  return dsERR_GENERAL ;
160 }
161 
162 dsError_t dsGetHDRCapabilities(intptr_t handle, int *capabilities)
163 {
164  _DEBUG_ENTER();
165 
167  param.handle = handle;
168 
169  IARM_Result_t rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
170  (char *) IARM_BUS_DSMGR_API_dsGetHDRCapabilities,
171  (void *) &param,
172  sizeof(param));
173 
174  if (IARM_RESULT_SUCCESS == rpcRet)
175  {
176  *capabilities = param.capabilities;
177  return param.result;
178  }
179 
180  return dsERR_GENERAL ;
181 }
182 
183 dsError_t dsGetSupportedVideoCodingFormats(intptr_t handle, unsigned int * supported_formats)
184 {
185  _DEBUG_ENTER();
186 
188  param.handle = handle;
189 
190  IARM_Result_t rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
191  (char *) IARM_BUS_DSMGR_API_dsGetSupportedVideoCodingFormats,
192  (void *) &param,
193  sizeof(param));
194 
195  if (IARM_RESULT_SUCCESS == rpcRet)
196  {
197  *supported_formats = param.supported_formats;
198  return param.result;
199  }
200  return dsERR_GENERAL;
201 }
202 
203 dsError_t dsGetVideoCodecInfo(intptr_t handle, dsVideoCodingFormat_t format, dsVideoCodecInfo_t* info)
204 {
205  _DEBUG_ENTER();
206 
208  memset(&param, 0, sizeof(param));
209  param.handle = handle;
210  param.format = format;
211  info->num_entries = 0;
212 
213  IARM_Result_t rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
214  (char *) IARM_BUS_DSMGR_API_dsGetVideoCodecInfo,
215  (void *) &param,
216  sizeof(param));
217 
218  if (IARM_RESULT_SUCCESS == rpcRet)
219  {
220  *info = param.info;
221  return param.result;
222  }
223  return dsERR_GENERAL;
224 }
225 
226 dsError_t dsForceDisableHDRSupport(intptr_t handle, bool disable)
227 {
228  _DEBUG_ENTER();
229 
231  memset(&param, 0, sizeof(param));
232  param.handle = handle;
233  param.disable = disable;
234 
235  IARM_Result_t rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
236  (char *) IARM_BUS_DSMGR_API_dsSetForceDisableHDR,
237  (void *) &param,
238  sizeof(param));
239 
240  if (IARM_RESULT_SUCCESS == rpcRet)
241  {
242  return param.result;
243  }
244 
245  return dsERR_GENERAL ;
246 }
247 
248 dsError_t dsGetFRFMode(intptr_t handle, int *frfmode)
249 {
250  dsFRFParam_t param = {0};
251  param.handle = handle;
252 
253  IARM_Result_t rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
254  (char *) IARM_BUS_DSMGR_API_dsGetFRFMode,
255  (void *) &param,
256  sizeof(param));
257 
258  if (IARM_RESULT_SUCCESS == rpcRet)
259  {
260  *frfmode = param.frfmode;
261  return dsERR_NONE;
262  }
263  return dsERR_GENERAL ;
264 }
265 
266 dsError_t dsSetFRFMode(intptr_t handle, int frfmode)
267 {
268  dsFRFParam_t param = {0};
269  param.handle = handle;
270  param.frfmode = frfmode;
271 
272  IARM_Result_t rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
273  (char *) IARM_BUS_DSMGR_API_dsSetFRFMode,
274  (void *) &param,
275  sizeof(param));
276 
277  if (IARM_RESULT_SUCCESS == rpcRet)
278  {
279  return dsERR_NONE;
280  }
281 
282  return dsERR_GENERAL ;
283 }
284 
285 dsError_t dsSetDisplayframerate(intptr_t handle, char *framerate)
286 {
287  dsFramerateParam_t param = {0};
288  param.handle = handle;
289  errno_t rc = -1;
290  rc = strcpy_s(param.framerate ,sizeof(param.framerate), framerate);
291  if(rc!=EOK)
292  {
293  ERR_CHK(rc);
294  }
295  IARM_Result_t rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
296  (char *) IARM_BUS_DSMGR_API_dsSetDisplayframerate,
297  (void *) &param,
298  sizeof(param));
299 
300  if (IARM_RESULT_SUCCESS == rpcRet)
301  {
302  return dsERR_NONE;
303  }
304  return dsERR_GENERAL ;
305 }
306 
307 dsError_t dsGetCurrentDisplayframerate(intptr_t handle, char *framerate)
308 {
309  errno_t rc = -1;
310  dsFramerateParam_t param ={0};
311  param.handle = handle;
312 
313  IARM_Result_t rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME,
314  (char *) IARM_BUS_DSMGR_API_dsGetCurrentDisframerate,
315  (void *) &param,
316  sizeof(param));
317 
318  if (IARM_RESULT_SUCCESS == rpcRet)
319  {
320  errno_t rc = -1;
321  rc = strcpy_s(framerate ,sizeof(param.framerate), param.framerate);
322  if(rc!=EOK)
323  {
324  ERR_CHK(rc);
325  }
326  return dsERR_NONE;
327  }
328  return dsERR_GENERAL ;
329 }
330 
331 /** @} */
332 /** @} */
dsGetSupportedVideoCodingFormats
dsError_t dsGetSupportedVideoCodingFormats(intptr_t handle, unsigned int *supported_formats)
To find the Video formats supported by the SoC.
Definition: dsVideoDevice.c:183
dsSetDFC
dsError_t dsSetDFC(intptr_t handle, dsVideoZoom_t dfc)
This function is used to set the screen zoom mode (decoder format conversion). This function sets the...
Definition: dsVideoDevice.c:89
dsVideoDeviceInit
dsError_t dsVideoDeviceInit()
This function initialize all the video devices in the system.
Definition: dsVideoDevice.c:46
dsGetVideoCodecInfoParam_t
Definition: dsRpc.h:822
dsGetSupportedVideoCodingFormatsParam_t
Definition: dsRpc.h:815
IARM_Bus_Call
IARM_Result_t IARM_Bus_Call(const char *ownerName, const char *methodName, void *arg, size_t argLen)
This API is used to Invoke RPC method by its application name and method name.
Definition: iarm_bus.c:57
dsTypes.h
Device Settings HAL types.
_dsVideoDeviceGetHandleParam_t
Definition: dsRpc.h:581
dsGetHDRCapabilities
dsError_t dsGetHDRCapabilities(intptr_t handle, int *capabilities)
To find the HDR capabilities of SoC.
Definition: dsVideoDevice.c:162
dsVideoDeviceTerm
dsError_t dsVideoDeviceTerm(void)
This function deinitialize all the video devices in the system. It reset any data structures used wit...
Definition: dsVideoDevice.c:144
dsError.h
Device Settings HAL error codes.
dsVIDEO_ZOOM_NONE
@ dsVIDEO_ZOOM_NONE
Definition: dsTypes.h:579
dsUtl.h
Device Settings HAL utilities.
dsERR_GENERAL
@ dsERR_GENERAL
Definition: dsError.h:86
dsGetVideoCodecInfo
dsError_t dsGetVideoCodecInfo(intptr_t handle, dsVideoCodingFormat_t format, dsVideoCodecInfo_t *info)
This API is used to get the video codec information.
Definition: dsVideoDevice.c:203
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
_dsVideoDeviceSetDFCParam_t
Definition: dsRpc.h:586
libIBus.h
RDK IARM-Bus API Declarations.
dsVideoDevice.h
dsFRFParam_t
Definition: dsRpc.h:954
dsVideoZoom_t
enum _dsVideoZoom_t dsVideoZoom_t
_dsGetHDRCapabilitiesParam_t
Definition: dsRpc.h:774
dsGetDFC
dsError_t dsGetDFC(intptr_t handle, dsVideoZoom_t *dfc)
This function is used to get the screen zoom mode (decoder format conversion). This function Gets the...
Definition: dsVideoDevice.c:117
dsForceDisableHDRParam_t
Definition: dsRpc.h:830
dsVideoCodecInfo_t
Definition: dsTypes.h:1111
dsGetVideoDevice
dsError_t dsGetVideoDevice(int index, intptr_t *handle)
This function gets the handle for the video device requested.
Definition: dsVideoDevice.c:64
dsFramerateParam_t
Definition: dsRpc.h:960
dsERR_INVALID_PARAM
@ dsERR_INVALID_PARAM
Definition: dsError.h:87
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84