RDK Documentation (Open Sourced RDK Components)
Components_HDMI.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 Components_HDMI.cpp
22  * @brief This source file contains the APIs of TR069 Components HDMI.
23  */
24 
25 /**
26 * @defgroup tr69hostif
27 * @{
28 * @defgroup hostif
29 * @{
30 **/
31 
32 
33 #include "hostIf_main.h"
34 #include "videoOutputPort.hpp"
35 #include "illegalArgumentException.hpp"
36 #include "exception.hpp"
37 #include "Components_HDMI.h"
39 #include "safec_lib.h"
40 
41 #define DEV_NAME "HDMI"
42 #define BASE_NAME "Device.Services.STBService.1.Components.HDMI"
43 #define UPDATE_FORMAT_STRING "%s.%d.%s"
44 
45 
46 #define STATUS_STRING "Status"
47 #define ENABLE_STRING "Enable"
48 #define RES_MODE_STRING "ResolutionMode"
49 #define RES_VAL_STRING "ResolutionValue"
50 #define NAME_STRING "Name"
51 #define ENABLED_STRING "Enabled"
52 #define DISABLED_STRING "Disabled"
53 
54 
55 static EnumStringMapper dsVideoPixelResolutionMapper[] =
56 {
57  { dsVIDEO_PIXELRES_720x480, "720x480"},
58  { dsVIDEO_PIXELRES_720x576, "720x576"},
59  { dsVIDEO_PIXELRES_1280x720, "1280x720"},
60  { dsVIDEO_PIXELRES_1920x1080, "1920x1080"},
61  { dsVIDEO_PIXELRES_3840x2160, "3840x2160"}
62 };
63 
64 static EnumStringMapper dsVideoFrameRateMapper[] =
65 {
66  {dsVIDEO_FRAMERATE_24, "24"},
67  {dsVIDEO_FRAMERATE_25, "25"},
68  {dsVIDEO_FRAMERATE_30, "30"},
69  {dsVIDEO_FRAMERATE_60, "60"},
70  {dsVIDEO_FRAMERATE_23dot98, "23.98"},
71  {dsVIDEO_FRAMERATE_29dot97, "29.97"},
72  {dsVIDEO_FRAMERATE_50, "50"},
73  {dsVIDEO_FRAMERATE_59dot94, "59.94"}
74 };
75 
76 char hostIf_STBServiceHDMI::dsHDMIResolutionMode[10] = HDMI_RESOLUTION_MODE_MANUAL;
77 GHashTable* hostIf_STBServiceHDMI::ifHash = NULL;
78 GMutex* hostIf_STBServiceHDMI::m_mutex = NULL;
79 
80 /** Description: Counts the number of HDMI
81  * interfaces present in the device.
82  *
83  * Get all the current interfaces in the system and
84  * count "STBService" interface from the list.
85  *
86  * Return: Count value or '0' if error
87  *
88  */
89 
91 {
92  hostIf_STBServiceHDMI* pRet = NULL;
93 
94  if(ifHash)
95  {
96  pRet = (hostIf_STBServiceHDMI *)g_hash_table_lookup(ifHash,(gpointer) dev_id);
97  }
98  else
99  {
100  ifHash = g_hash_table_new(NULL,NULL);
101  }
102 
103  if(!pRet)
104  {
105  try
106  {
107  std::string strVideoPort = device::Host::getInstance().getDefaultVideoPortName();
108  std::string videoPortName = strVideoPort.substr(0, strVideoPort.size()-1);
109  pRet = new hostIf_STBServiceHDMI(dev_id, device::Host::getInstance().getVideoOutputPort(videoPortName.append(int_to_string(dev_id-1))));
110  g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
111  }
112  catch (const device::IllegalArgumentException &e)
113  {
114  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught device::IllegalArgumentException, not able create STB service %s Interface instance %d..\n", DEV_NAME, dev_id);
115  }
116  catch (const int &e)
117  {
118  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught exception, not able create STB service %s Interface instance %d..\n", DEV_NAME, dev_id);
119  }
120  catch (const dsError_t &e)
121  {
122  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"Caught dsError_t %d, not able create STB service %s Interface instance %d..\n", e, DEV_NAME, dev_id);
123  }
124  catch (const device::Exception &e)
125  {
126  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught device::Exception %d \"%s\", not able create STB service %s Interface instance %d..\n", e.getCode(), e.getMessage().c_str(), DEV_NAME, dev_id);
127  }
128  }
129  return pRet;
130 }
131 
132 GList* hostIf_STBServiceHDMI::getAllInstances()
133 {
134  if(ifHash)
135  return g_hash_table_get_keys(ifHash);
136  return NULL;
137 }
138 
139 void hostIf_STBServiceHDMI::closeInstance(hostIf_STBServiceHDMI *pDev)
140 {
141  if(pDev)
142  {
143  g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
144  delete pDev;
145  }
146 }
147 
148 void hostIf_STBServiceHDMI::closeAllInstances()
149 {
150  if(ifHash)
151  {
152  GList* tmp_list = g_hash_table_get_values (ifHash);
153 
154  while(tmp_list)
155  {
156  hostIf_STBServiceHDMI* pDev = (hostIf_STBServiceHDMI *)tmp_list->data;
157  tmp_list = tmp_list->next;
158  closeInstance(pDev);
159  }
160  }
161 }
162 
163 void hostIf_STBServiceHDMI::getLock()
164 {
165  if(!m_mutex)
166  {
167  m_mutex = g_mutex_new();
168  }
169  g_mutex_lock(m_mutex);
170 }
171 
172 void hostIf_STBServiceHDMI::releaseLock()
173 {
174  g_mutex_unlock(m_mutex);
175 }
176 
177 /**
178  * @brief Class Constructor of the class hostIf_STBServiceHDMI.
179  *
180  * It will initialize the device id and video output port.
181  *
182  * @param[in] devid Identification number of the device.
183  * @param[in] port Video output port number.
184  */
185 hostIf_STBServiceHDMI::hostIf_STBServiceHDMI(int devid, device::VideoOutputPort& port) : dev_id(devid), vPort(port)
186 {
187  errno_t rc = -1;
188  backupEnable = false;
189  rc=strcpy_s(backupStatus,sizeof(backupStatus), " ");
190  if(rc!=EOK)
191  {
192  ERR_CHK(rc);
193  }
194  rc=strcpy_s(backupResolutionValue,sizeof(backupResolutionValue)," ");
195  if(rc!=EOK)
196  {
197  ERR_CHK(rc);
198  }
199  rc=strcpy_s(backupName,sizeof(backupName)," ");
200  if(rc!=EOK)
201  {
202  ERR_CHK(rc);
203  }
204 
205  bCalledEnable = false;
206  bCalledStatus = false;
207  bCalledResolutionValue = false;
208  bCalledName = false;
209 
210  displayDevice = new hostIf_STBServiceDisplayDevice(devid, vPort);
211 }
212 
213 hostIf_STBServiceHDMI::~hostIf_STBServiceHDMI() {
214 
215  delete displayDevice;
216 }
217 /**
218  * @brief This function set the HDMI interface updates such as Status, Enable,
219  * ResolutionMode, ResolutionValue etc in a connected HDMI port.
220  *
221  * @param[in] paramName HDMI service name string.
222  * @param[in] stMsgData HostIf Message Request param contains the HDMI attribute value.
223  *
224  * @return Returns an Integer value.
225  * @retval 0 If successfully set the hostIf HDMI interface attribute.
226  * @retval -1 If Not able to set the hostIf HDMI interface attribute.
227  * @retval -2 If Not handle the hostIf HDMI interface attribute.
228  * @ingroup TR69_HOSTIF_STBSERVICES_HDMI_API
229  */
230 int hostIf_STBServiceHDMI::handleSetMsg(const char *paramName, HOSTIF_MsgData_t *stMsgData)
231 {
232  int ret = NOT_HANDLED;
233  if(strcasecmp(paramName, RES_MODE_STRING) == 0)
234  {
235  ret = setHDMIResolutionMode(stMsgData->paramValue);
236  }
237  else if(strcasecmp(paramName, RES_VAL_STRING) == 0)
238  {
239  if(0 == strcasecmp(getHDMIResolutionMode(), HDMI_RESOLUTION_MODE_MANUAL))
240  {
241  ret = setResolution(stMsgData);
242  }
243  else
244  {
245  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Setting the ResolutionValue has no effect because the ResolutionMode is \"Auto\".\n");
246  ret = NOK;
247  }
248  }
249  else if(strcasecmp(paramName, ENABLE_STRING) == 0)
250  {
251  ret = setEnableVideoPort(stMsgData);
252  }
253 
254  return ret;
255 }
256 
257 /**
258  * @brief This function get the HDMI interface updates such as Status, Enable,
259  * ResolutionMode, ResolutionValue etc in a connected HDMI port.
260  *
261  * @param[in] paramName HDMI service name string.
262  * @param[in] stMsgData HostIf Message Request param contains the HDMI attribute value.
263  *
264  * @return Returns an Integer value.
265  * @retval 0 If successfully get the host IF HDMI interface attribute.
266  * @retval -1 If Not able to get the host IF HDMI interface attribute.
267  * @retval -2 If Not handle the host IF HDMI interface attribute.
268  * @ingroup TR69_HOSTIF_STBSERVICES_HDMI_API
269  */
270 int hostIf_STBServiceHDMI::handleGetMsg(const char *paramName, HOSTIF_MsgData_t *stMsgData)
271 {
272  int ret = NOT_HANDLED;
273  if(strcasecmp(paramName, ENABLE_STRING) == 0)
274  {
275  ret = getEnable(stMsgData);
276  }
277  else if(strcasecmp(paramName, STATUS_STRING) == 0)
278  {
279  ret = getStatus(stMsgData);
280  }
281  else if(strcasecmp(paramName, NAME_STRING) == 0)
282  {
283  ret = getName(stMsgData);
284  }
285  else if(strcasecmp(paramName, RES_MODE_STRING) == 0)
286  {
287  strncpy(stMsgData->paramValue,getHDMIResolutionMode(), sizeof(stMsgData->paramValue) -1); //CID:136490 - Buffer size warning
288  stMsgData->paramValue [sizeof(stMsgData->paramValue) -1] = '\0';
289  stMsgData->paramtype=hostIf_StringType;
290  stMsgData->paramLen = strlen(stMsgData->paramValue);
291  ret = OK;
292  }
293  else if(strcasecmp(paramName, RES_VAL_STRING) == 0)
294  {
295  ret = getResolutionValue(stMsgData);
296  }
297  else if(strncasecmp(paramName, DISPLAYDEVICE_OBJECT_NAME, strlen(DISPLAYDEVICE_OBJECT_NAME)) == 0)
298  {
299  ret = displayDevice->handleGetMsg(paramName+strlen(DISPLAYDEVICE_OBJECT_NAME), stMsgData);
300  }
301  return ret;
302 }
303 
304 /**
305  * @brief This function updates the HDMI interface updates such as Status, Enable,
306  * ResolutionMode, ResolutionValue etc in a connected HDMI port.
307  *
308  * @param[in] mUpdateCallback Callback function pointer to updated the host IF HDMI interface.
309  * @ingroup TR69_HOSTIF_STBSERVICES_HDMI_API
310  */
311 void hostIf_STBServiceHDMI::doUpdates(updateCallback mUpdateCallback)
312 {
313  displayDevice->doUpdates(BASE_NAME, mUpdateCallback);
314  HOSTIF_MsgData_t msgData;
315  bool bChanged;
316  char tmp_buff[PARAM_LEN];
317 
318  memset(&msgData,0,sizeof(msgData));
319  memset(tmp_buff,0,PARAM_LEN);
320  bChanged = false;
321  msgData.instanceNum=dev_id;
322  getResolutionValue(&msgData,&bChanged);
323  if(bChanged)
324  {
325  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, RES_VAL_STRING);
326  if(mUpdateCallback)
327  {
328  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
329  }
330  }
331  memset(&msgData,0,sizeof(msgData));
332  memset(tmp_buff,0,PARAM_LEN);
333  bChanged = false;
334  msgData.instanceNum=dev_id;
335  getEnable(&msgData,&bChanged);
336  if(bChanged)
337  {
338  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, ENABLE_STRING);
339  if(mUpdateCallback)
340  {
341  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
342  }
343  }
344  memset(&msgData,0,sizeof(msgData));
345  memset(tmp_buff,0,PARAM_LEN);
346  bChanged = false;
347  msgData.instanceNum=dev_id;
348  getStatus(&msgData,&bChanged);
349  if(bChanged)
350  {
351  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, STATUS_STRING);
352  if(mUpdateCallback)
353  {
354  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
355  }
356  }
357  memset(&msgData,0,sizeof(msgData));
358  memset(tmp_buff,0,PARAM_LEN);
359  bChanged = false;
360  msgData.instanceNum=dev_id;
361  getName(&msgData,&bChanged);
362  if(bChanged)
363  {
364  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, NAME_STRING);
365  if(mUpdateCallback)
366  {
367  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
368  }
369  }
370 }
371 
372 /************************************************************
373  * Description : Set HDMI Resolution value to Device Setting
374  * Precondition : HDMI Display should be connected to STB
375  * Input : stMsgData->paramValue -> resolution string [ example: "1920x1080p/24Hz" ]
376 
377  * Return : OK -> Success
378  NOK -> Failure
379 ************************************************************/
380 
381 int hostIf_STBServiceHDMI::setResolution(const HOSTIF_MsgData_t *stMsgData)
382 {
383  try {
384  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] (): Value: %s \n",__FUNCTION__, stMsgData->paramValue);
385 
386  char inResolution[MAX_RESOLUTION_LENGTH] = {'\0'};
387  char *bufPtr = NULL, *hzPtr = NULL, *interlacedPtr = NULL;
388  char *pixelName = NULL, *frameRateName = NULL;
389  bool isInterlaced = true;
390 
391  strncpy(inResolution, stMsgData->paramValue, sizeof(inResolution)-1);
392  inResolution[sizeof(inResolution)-1] = '\0';
393  hzPtr = strcasestr(inResolution, (char*)"Hz");
394 
395  if (NULL == hzPtr)
396  {
397  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] (): Missing Hz value in Resolution\n",__FUNCTION__);
398  return NOK;
399  }
400  else
401  {
402  strncpy(hzPtr, "Hz", 3); //CID:136580 - Buffer size
403  }
404 
405  interlacedPtr = strcasestr(inResolution, (char*)"p");
406  if(interlacedPtr)
407  {
408  isInterlaced = false;
409  *interlacedPtr = 'p';
410  }
411  else
412  {
413  interlacedPtr = strcasestr(inResolution, (char*)"i");
414  if(interlacedPtr)
415  {
416  isInterlaced = true;
417  *interlacedPtr = 'i';
418  }
419  }
420 
421  bufPtr = inResolution;
422 
423  if(interlacedPtr)
424  {
425  if(isInterlaced)
426  {
427  pixelName = strsep (&bufPtr, "i");
428  }
429  else
430  {
431  pixelName = strsep (&bufPtr, "p");
432  }
433  bufPtr++; // For "/"
434  }
435  else
436  {
437  pixelName = strsep (&bufPtr, "/");
438  }
439 
440  frameRateName = strsep (&bufPtr, "Hz");
441 
442  if (!pixelName || !frameRateName)
443  {
444  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Null Pointers caught \n",__FUNCTION__);
445  return NOK;
446  }
447 
448  static int pixelResolArrSize = sizeof( dsVideoPixelResolutionMapper ) / sizeof( EnumStringMapper );
449  int pixelId = getEnumFromString(dsVideoPixelResolutionMapper, pixelResolArrSize, pixelName);
450  if ((pixelId<dsVIDEO_PIXELRES_720x480) || (pixelId>dsVIDEO_PIXELRES_3840x2160))
451  {
452  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Error in PixelResolution value: %s\n",__FUNCTION__, pixelName);
453  return NOK;
454  }
455 
456  static int frameRateArrSize = sizeof( dsVideoFrameRateMapper ) / sizeof( EnumStringMapper );
457  int frameRateId = getEnumFromString(dsVideoFrameRateMapper, frameRateArrSize, frameRateName);
458  if ((frameRateId<dsVIDEO_FRAMERATE_24) || (frameRateId>dsVIDEO_FRAMERATE_59dot94))
459  {
460  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Error in FrameRate value: %s\n",__FUNCTION__, frameRateName);
461  return NOK;
462  }
463 
464  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] pixelId = %d frameRateId = %d interlaced = %s\n", __FUNCTION__, pixelId, frameRateId, isInterlaced?"true":"false");
465  size_t numResolutions = dsUTL_DIM(kResolutions);
466  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] (): numResolutions = %d\n",__FUNCTION__, numResolutions);
467  for (size_t i = 0; i < numResolutions; i++) {
468  dsVideoPortResolution_t *resolution = &kResolutions[i];
469  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] pixelId = %d frameRateId = %d interlaced = %s\n", __FUNCTION__, resolution->pixelResolution, resolution->frameRate, resolution->interlaced?"true":"false");
470  if ( (resolution->pixelResolution == pixelId) &&
471  (resolution->frameRate == frameRateId) &&
472  (interlacedPtr?(resolution->interlaced == isInterlaced):true) )
473  {
474  vPort.setResolution(kResolutions[i].name);
475  return OK;
476  }
477  }
478 
479  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] (): Out of range values entered\n",__FUNCTION__);
480  }
481  catch (const std::exception e) {
482  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
483  }
484 
485  return NOK;
486 }
487 
488 /************************************************************
489  * Description : Get HDMI Resolution value from Device Setting
490  * Precondition : HDMI Display should be connected to STB
491  * Input : stMsgData for result return.
492  pChanged
493 
494  * Return : OK -> Success
495  NOK -> Failure
496  stMsgData->paramValue -> resolution string [ example: "1920x1080p/24Hz" ]
497 ************************************************************/
498 
499 int hostIf_STBServiceHDMI::getResolutionValue(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
500 {
501  try {
502  if(vPort.getResolution().getPixelResolution().getName().c_str() && vPort.getResolution().getFrameRate().getName().c_str())
503  {
504  snprintf(stMsgData->paramValue, PARAM_LEN, "%s%s/%sHz",
505  vPort.getResolution().getPixelResolution().getName().c_str(),
506  vPort.getResolution().isInterlaced()?"i":"p",
507  vPort.getResolution().getFrameRate().getName().c_str());
508 
509  if(bCalledResolutionValue && pChanged && strcmp(backupResolutionValue, stMsgData->paramValue))
510  {
511  *pChanged = true;
512  }
513  bCalledResolutionValue = true;
514  strncpy(backupResolutionValue, stMsgData->paramValue, _BUF_LEN_16-1);
515  backupResolutionValue[_BUF_LEN_16-1] = '\0';
516  }
517  stMsgData->paramtype = hostIf_StringType;
518  stMsgData->paramLen = strlen(stMsgData->paramValue);
519  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] getHDMIResolution(): Value: %s\n",__FUNCTION__, stMsgData->paramValue);
520  }
521  catch (const std::exception e) {
522  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
523  return NOK;
524  }
525 
526  return OK;
527 }
528 
529 /************************************************************
530  * Description : Set HDMI to Enable / Disable in Device Setting
531  * Precondition : HDMI Display should be connected to STB
532  * Input : stMsgData->paramValue -> 1 : Enable
533  -> 0 : Disable
534 
535  * Return : OK -> Success
536  NOK -> Failure
537 ************************************************************/
538 
539 int hostIf_STBServiceHDMI::setEnableVideoPort(const HOSTIF_MsgData_t *stMsgData)
540 {
541  try {
542  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] In setEnableVideoPort(): Value: %s \n",__FUNCTION__, stMsgData->paramValue);
543  if (true == vPort.isDisplayConnected())
544  {
545  if(get_boolean(stMsgData->paramValue))
546  vPort.enable();
547  else
548  vPort.disable();
549  }
550  else {
551  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] HDMI Display is NOT connected\r\n",__FUNCTION__);
552  return NOK;
553  }
554  }
555  catch (const std::exception e) {
556  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
557  return NOK;
558  }
559 
560  return OK;
561 }
562 
563 /************************************************************
564  * Description : Get HDMI Enable / Disable status
565  * Precondition : HDMI Display should be connected to STB
566  * Input : stMsgData for result return.
567  pChanged
568 
569  * Return : OK -> Success
570  NOK -> Failure
571  stMsgData->palue -> 1 : Enabled
572  0 : Disabled
573 
574 ************************************************************/
575 
576 int hostIf_STBServiceHDMI::getEnable(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
577 {
578  try {
579  if (true == vPort.isDisplayConnected())
580  {
581  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] In getHDMIEnable(): vPort.isEnabled(): %d \n",__FUNCTION__, vPort.isEnabled());
582  if (vPort.isEnabled())
583  put_boolean(stMsgData->paramValue,true);
584  else
585  put_boolean(stMsgData->paramValue,false);
586 
587  stMsgData->paramtype = hostIf_BooleanType;
588  stMsgData->paramLen = sizeof(bool);
589  }
590  else {
591  memset(stMsgData->paramValue, '\0', sizeof (stMsgData->paramValue));
592  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] HDMI Display is NOT connected\r\n",__FUNCTION__);
593  }
594  if(bCalledEnable && pChanged && (backupEnable != get_boolean(stMsgData->paramValue)))
595  {
596  *pChanged = true;
597  }
598  bCalledEnable = true;
599  backupEnable = get_boolean(stMsgData->paramValue);
600 
601  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] In getHDMIEnable(): Value: %s \n",__FUNCTION__, stMsgData->paramValue);
602  }
603  catch (const std::exception e) {
604  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
605  return NOK;
606  }
607 
608  return OK;
609 }
610 
611 /************************************************************
612  * Description : get HDMI port status
613  * Precondition : None
614  * Input : stMsgData for result return.
615  pChanged
616 
617  * Return : OK -> Success
618  NOK -> Failure
619  stMsgData->paramValue -> "Enabled" | "Disabled"
620 ************************************************************/
621 
622 int hostIf_STBServiceHDMI::getStatus(HOSTIF_MsgData_t *stMsgData, bool *pChanged)
623 {
624  int ret = getEnable(stMsgData);
625  if(ret == OK)
626  {
627  if(get_boolean(stMsgData->paramValue))
628  {
629  strncpy(stMsgData->paramValue, ENABLED_STRING, PARAM_LEN);
630  }
631  else
632  {
633  strncpy(stMsgData->paramValue, DISABLED_STRING, PARAM_LEN);
634  }
635  stMsgData->paramValue[PARAM_LEN-1] = '\0';
636  stMsgData->paramtype=hostIf_StringType;
637  stMsgData->paramLen = strlen(stMsgData->paramValue);
638  if(bCalledStatus && pChanged && strcmp(backupStatus, stMsgData->paramValue))
639  {
640  *pChanged = true;
641  }
642  bCalledStatus = true;
643  strncpy(backupStatus, stMsgData->paramValue, _BUF_LEN_16-1);
644  backupStatus[_BUF_LEN_16-1] = '\0';
645  }
646  return ret;
647 }
648 
649 
650 /************************************************************
651  * Description : get HDMI port human readable name
652  * Precondition : None
653  * Input : stMsgData for result return.
654  pChanged
655 
656  * Return : OK -> Success
657  NOK -> Failure
658  stMsgData->paramValue -> name string
659 ************************************************************/
660 
661 int hostIf_STBServiceHDMI::getName(HOSTIF_MsgData_t *stMsgData, bool *pChanged)
662 {
663  snprintf(stMsgData->paramValue, PARAM_LEN, "HDMI%d",stMsgData->instanceNum-1);
664  if(bCalledName && pChanged && strcmp(backupName, stMsgData->paramValue))
665  {
666  *pChanged = true;
667  }
668  bCalledName = true;
669  strncpy(backupName, stMsgData->paramValue, _BUF_LEN_256-1);
670  backupName[_BUF_LEN_256-1] = '\0';
671  stMsgData->paramtype = hostIf_StringType;
672  stMsgData->paramLen = strlen(stMsgData->paramValue);
673  return OK;
674 }
675 
676 /************************************************************
677  * Description : Set HDMI resolution mode
678  * Precondition : None
679  * Input : value ["Auto" or "Manual"]
680 
681  * Return : OK -> Success
682  NOK -> Failure
683 ************************************************************/
684 
685 int hostIf_STBServiceHDMI::setHDMIResolutionMode(const char* value)
686 {
687  if((0 != strcasecmp(value, HDMI_RESOLUTION_MODE_AUTO)) &&
688  (0 != strcasecmp(value, HDMI_RESOLUTION_MODE_MANUAL)))
689  {
690  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s]Failed to set HDMI ResolutionMode [%s]. Expected input values: [Auto|Manual] \n", __FUNCTION__, value);
691  return NOK;
692  }
693 
694  strncpy(dsHDMIResolutionMode,value, sizeof(dsHDMIResolutionMode));
695  dsHDMIResolutionMode[sizeof(dsHDMIResolutionMode)-1] = '\0';
696  if(0 == strcasecmp(value, HDMI_RESOLUTION_MODE_AUTO))
697  {
698  HOSTIF_MsgData_t msgData;
699  strncpy(msgData.paramValue,HDMI_RESOLUTION_VALUE_DEFAULT, PARAM_LEN);
700  msgData.paramValue[PARAM_LEN-1] = '\0';
701  msgData.instanceNum = dev_id; //Use tr69 protocol 1 based indexing
702  setResolution(&msgData);
703  }
704  return OK;
705 }
706 
707 const char* hostIf_STBServiceHDMI::getHDMIResolutionMode()
708 {
709  return dsHDMIResolutionMode;
710 }
711 
712 
713 
714 /** @} */
715 /** @} */
dsVIDEO_FRAMERATE_25
@ dsVIDEO_FRAMERATE_25
Definition: dsTypes.h:505
_HostIf_MsgData_t::instanceNum
short instanceNum
Definition: hostIf_tr69ReqHandler.h:176
hostIf_STBServiceHDMI::doUpdates
void doUpdates(updateCallback mUpdateCallback)
This function updates the HDMI interface updates such as Status, Enable, ResolutionMode,...
Definition: Components_HDMI.cpp:311
hostIf_STBServiceDisplayDevice::doUpdates
void doUpdates(const char *baseName, updateCallback mUpdateCallback)
This function updates the hostIf display device interface attribute value such as Status,...
Definition: Components_DisplayDevice.cpp:200
dsVIDEO_FRAMERATE_60
@ dsVIDEO_FRAMERATE_60
Definition: dsTypes.h:507
dsVIDEO_FRAMERATE_23dot98
@ dsVIDEO_FRAMERATE_23dot98
Definition: dsTypes.h:508
hostIf_STBServiceHDMI
This class provides the TR-069 components HDMI information.
Definition: Components_HDMI.h:89
dsVIDEO_FRAMERATE_30
@ dsVIDEO_FRAMERATE_30
Definition: dsTypes.h:506
Components_DisplayDevice.h
The header file provides components display device information APIs.
device::VideoResolution::getFrameRate
const FrameRate & getFrameRate() const
This API is used to get the frame rate of the given video output port.
Definition: videoResolution.cpp:172
dsVIDEO_PIXELRES_720x576
@ dsVIDEO_PIXELRES_720x576
Definition: dsTypes.h:460
device::VideoOutputPort::isEnabled
bool isEnabled() const
This API is used to check whether this Video output port is enabled or not.
Definition: videoOutputPort.cpp:398
Components_HDMI.h
The header file provides capabilities HDMI information APIs.
dsVIDEO_FRAMERATE_59dot94
@ dsVIDEO_FRAMERATE_59dot94
Definition: dsTypes.h:511
device::VideoOutputPort::isDisplayConnected
bool isDisplayConnected() const
This API is used to Check if the port is currently connected to any display device.
Definition: videoOutputPort.cpp:381
device::VideoOutputPort
Class extending enumerable to implement the videoooutputport interface.
Definition: videoOutputPort.hpp:59
hostIf_STBServiceDisplayDevice
This class provides the TR-069 components display device information.
Definition: Components_DisplayDevice.h:89
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
dsVIDEO_PIXELRES_1280x720
@ dsVIDEO_PIXELRES_1280x720
Definition: dsTypes.h:461
hostIf_STBServiceHDMI::handleSetMsg
int handleSetMsg(const char *paramName, HOSTIF_MsgData_t *stMsgData)
This function set the HDMI interface updates such as Status, Enable, ResolutionMode,...
Definition: Components_HDMI.cpp:230
_dsVideoPortResolution_t::pixelResolution
dsVideoResolution_t pixelResolution
Definition: dsTypes.h:644
dsVIDEO_FRAMERATE_29dot97
@ dsVIDEO_FRAMERATE_29dot97
Definition: dsTypes.h:509
put_boolean
void put_boolean(char *ptr, bool val)
This function converts the input data to Boolean type.
Definition: hostIf_utils.cpp:191
hostIf_main.h
hostIf_main API.
device::VideoResolution::isInterlaced
bool isInterlaced() const
This API is used to check the video is interlaced or not.
Definition: videoResolution.cpp:185
device::VideoOutputPort::getResolution
const VideoResolution & getResolution()
This API is used to get the current video resolution output from the video output port....
Definition: videoOutputPort.cpp:293
_HostIf_MsgData_t::paramtype
HostIf_ParamType_t paramtype
Definition: hostIf_tr69ReqHandler.h:177
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
dsVIDEO_FRAMERATE_50
@ dsVIDEO_FRAMERATE_50
Definition: dsTypes.h:510
device::VideoResolution::getPixelResolution
const PixelResolution & getPixelResolution() const
This API is used to get the pixel format of the given video output port.
Definition: videoResolution.cpp:134
device::Exception::getCode
virtual int getCode() const
This function is used to get the error code of the exception.
Definition: exception.hpp:104
hostIf_STBServiceHDMI::handleGetMsg
int handleGetMsg(const char *paramName, HOSTIF_MsgData_t *stMsgData)
This function get the HDMI interface updates such as Status, Enable, ResolutionMode,...
Definition: Components_HDMI.cpp:270
dsVIDEO_PIXELRES_720x480
@ dsVIDEO_PIXELRES_720x480
Definition: dsTypes.h:459
device::DSConstant::getName
virtual const std::string & getName() const
This function is used to the get the data member name.
Definition: dsConstant.hpp:141
videoOutputPort.hpp
It contains class and structure refrenced by the videooutputport.cpp file.
_dsVideoPortResolution_t
Structure that defines video port resolution settings of output video device.
Definition: dsTypes.h:642
device::Exception
This class handles exceptions occurring in DS module.
Definition: exception.hpp:52
_HostIf_MsgData_t::paramValue
char paramValue[(4 *1024)]
Definition: hostIf_tr69ReqHandler.h:172
hostIf_STBServiceHDMI::getInstance
static hostIf_STBServiceHDMI * getInstance(int dev_id)
Definition: Components_HDMI.cpp:90
hostIf_STBServiceDisplayDevice::handleGetMsg
int handleGetMsg(const char *paramName, HOSTIF_MsgData_t *stMsgData)
This function get the display device interface attribute value such as Status, EDID,...
Definition: Components_DisplayDevice.cpp:132
device::Host::getInstance
static Host & getInstance(void)
This API is used to get a reference to the single instance of the Host object.
Definition: host.cpp:88
EnumStringMapper
Definition: hostIf_utils.h:73
device::VideoOutputPort::setResolution
void setResolution(const std::string &resolution, bool persist=true, bool isIgnoreEdid=false)
This API is used to set the output resolution of the port by ID or its Name. The specified resolution...
Definition: videoOutputPort.cpp:457
device::VideoOutputPort::enable
void enable()
This API is used to enable the video output port.
Definition: videoOutputPort.cpp:552
device::Exception::getMessage
virtual const std::string & getMessage() const
This function is used to get the message string of the exception.
Definition: exception.hpp:93
dsVIDEO_FRAMERATE_24
@ dsVIDEO_FRAMERATE_24
Definition: dsTypes.h:504
device::IllegalArgumentException
This class extends Exception class to manage the expections caused due to illegal arguments.
Definition: illegalArgumentException.hpp:51
_dsVideoPortResolution_t::frameRate
dsVideoFrameRate_t frameRate
Definition: dsTypes.h:647
dsVIDEO_PIXELRES_1920x1080
@ dsVIDEO_PIXELRES_1920x1080
Definition: dsTypes.h:462
hostIf_STBServiceHDMI::hostIf_STBServiceHDMI
hostIf_STBServiceHDMI(int devid, device::VideoOutputPort &port)
Class Constructor of the class hostIf_STBServiceHDMI.
Definition: Components_HDMI.cpp:185
dsUTL_DIM
#define dsUTL_DIM(arr)
Device Settings general Array dimension calculation inline definition.
Definition: dsUtl.h:85
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84
IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED
@ IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED
Definition: hostIf_tr69ReqHandler.h:189
_HostIf_MsgData_t::paramLen
short paramLen
Definition: hostIf_tr69ReqHandler.h:175
device::VideoOutputPort::disable
void disable()
This API is used to disable the Audio output port.
Definition: videoOutputPort.cpp:567
_dsVideoPortResolution_t::interlaced
bool interlaced
Definition: dsTypes.h:648
dsVIDEO_PIXELRES_3840x2160
@ dsVIDEO_PIXELRES_3840x2160
Definition: dsTypes.h:464