34 #include "illegalArgumentException.hpp"
35 #include "exception.hpp"
37 #include "safec_lib.h"
39 #define DEV_NAME "VideoOutput"
40 #define BASE_NAME "Device.Services.STBService.1.Components.VideoOutput"
41 #define UPDATE_FORMAT_STRING "%s.%d.%s"
43 #define STATUS_STRING "Status"
44 #define ENABLE_STRING "Enable"
45 #define DISPLAY_FORMAT_STRING "DisplayFormat"
46 #define VIDEO_FORMAT_STRING "VideoFormat"
47 #define AR_BEHAVIOR_STRING "AspectRatioBehaviour"
48 #define HDCP_STRING "HDCP"
49 #define DISPLAY_NAME_STRING "Name"
50 #define ENABLED_STRING "Enabled"
51 #define DISABLED_STRING "Disabled"
53 GHashTable * hostIf_STBServiceVideoOutput::ifHash = NULL;
54 GMutex * hostIf_STBServiceVideoOutput::m_mutex = NULL;
66 ifHash = g_hash_table_new(NULL,NULL);
74 std::string videoPortName = strVideoPort.substr(0, strVideoPort.size()-1);
76 g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
80 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught device::IllegalArgumentException, not able create STB service %s Interface instance %d..\n", DEV_NAME, dev_id);
84 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception, not able create STB service %s Interface instance %d..\n", DEV_NAME, dev_id);
88 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);
92 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);
98 GList* hostIf_STBServiceVideoOutput::getAllInstances()
101 return g_hash_table_get_keys(ifHash);
109 g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
114 void hostIf_STBServiceVideoOutput::closeAllInstances()
118 GList* tmp_list = g_hash_table_get_values (ifHash);
123 tmp_list = tmp_list->next;
129 void hostIf_STBServiceVideoOutput::getLock()
133 m_mutex = g_mutex_new();
135 g_mutex_lock(m_mutex);
138 void hostIf_STBServiceVideoOutput::releaseLock()
140 g_mutex_unlock(m_mutex);
154 rc=strcpy_s(backupAspectRatioBehaviour,
sizeof(backupAspectRatioBehaviour),
" ");
159 rc=strcpy_s(backupDisplayFormat,
sizeof(backupDisplayFormat),
" ");
164 rc=strcpy_s(backupDisplayName,
sizeof(backupDisplayName),
" ");
169 rc=strcpy_s(backupVideoFormat,
sizeof(backupVideoFormat),
" ");
175 rc=strcpy_s(backupVideoOutputStatus,
sizeof(backupVideoOutputStatus),
" ");
181 bCalledAspectRatioBehaviour =
false;
182 bCalledDisplayFormat =
false;
183 bCalledDisplayName =
false;
184 bCalledVideoFormat =
false;
186 bCalledVideoOutputStatus =
false;
206 int ret = NOT_HANDLED;
226 int ret = NOT_HANDLED;
227 if(strcasecmp(paramName, STATUS_STRING) == 0)
229 ret = getStatus(stMsgData);
231 else if(strcasecmp(paramName, ENABLE_STRING) == 0)
234 stMsgData->
paramtype = hostIf_BooleanType;
238 else if(strcasecmp(paramName, DISPLAY_FORMAT_STRING) == 0)
240 ret = getDisplayFormat(stMsgData);
242 else if(strcasecmp(paramName, VIDEO_FORMAT_STRING) == 0)
244 ret = getVideoFormat(stMsgData);
246 else if(strcasecmp(paramName, AR_BEHAVIOR_STRING) == 0)
248 ret = getAspectRatioBehaviour(stMsgData);
250 else if(strcasecmp(paramName, HDCP_STRING) == 0)
252 ret = getHDCP(stMsgData);
254 else if(strcasecmp(paramName, DISPLAY_NAME_STRING) == 0)
256 ret = getName(stMsgData);
274 char tmp_buff[PARAM_LEN];
276 memset(&msgData,0,
sizeof(msgData));
277 memset(tmp_buff,0,PARAM_LEN);
280 getStatus(&msgData,&bChanged);
283 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, STATUS_STRING);
289 memset(&msgData,0,
sizeof(msgData));
290 memset(tmp_buff,0,PARAM_LEN);
293 getDisplayFormat(&msgData,&bChanged);
296 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, DISPLAY_FORMAT_STRING);
302 memset(&msgData,0,
sizeof(msgData));
303 memset(tmp_buff,0,PARAM_LEN);
306 getName(&msgData,&bChanged);
309 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, DISPLAY_NAME_STRING);
315 memset(&msgData,0,
sizeof(msgData));
316 memset(tmp_buff,0,PARAM_LEN);
319 getVideoFormat(&msgData,&bChanged);
322 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, VIDEO_FORMAT_STRING);
328 memset(&msgData,0,
sizeof(msgData));
329 memset(tmp_buff,0,PARAM_LEN);
332 getAspectRatioBehaviour(&msgData,&bChanged);
335 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, AR_BEHAVIOR_STRING);
341 memset(&msgData,0,
sizeof(msgData));
342 memset(tmp_buff,0,PARAM_LEN);
345 getHDCP(&msgData,&bChanged);
348 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, HDCP_STRING);
370 int hostIf_STBServiceVideoOutput::getStatus(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
385 strncpy(stMsgData->
paramValue, ENABLED_STRING, PARAM_LEN);
387 strncpy(stMsgData->
paramValue, DISABLED_STRING, PARAM_LEN);
393 RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,
"[%s] HDMI Display is NOT connected\r\n",__FUNCTION__);
394 strncpy(stMsgData->
paramValue, DISABLED_STRING, PARAM_LEN);
397 stMsgData->
paramtype = hostIf_StringType;
399 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] HDCP Status is [%s]\r\n",__FUNCTION__,stMsgData->
paramValue);
400 if(bCalledVideoOutputStatus && pChanged && strcmp(backupVideoOutputStatus, stMsgData->
paramValue))
404 bCalledVideoOutputStatus =
true;
405 strncpy(backupVideoOutputStatus,stMsgData->
paramValue,_BUF_LEN_16-1);
406 backupVideoOutputStatus[_BUF_LEN_16-1] =
'\0';
408 catch (
const std::exception e) {
409 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
427 int hostIf_STBServiceVideoOutput::getAspectRatioBehaviour(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
433 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] : Value: %s \n",__FUNCTION__, stMsgData->
paramValue);
435 stMsgData->
paramtype = hostIf_StringType;
437 if(bCalledAspectRatioBehaviour && pChanged && strncmp(backupAspectRatioBehaviour,stMsgData->
paramValue,_BUF_LEN_16-1))
441 bCalledAspectRatioBehaviour =
true;
442 strncpy(backupAspectRatioBehaviour,stMsgData->
paramValue,_BUF_LEN_16-1);
443 backupAspectRatioBehaviour[_BUF_LEN_16-1] =
'\0';
445 catch (
const std::exception e) {
446 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
467 int hostIf_STBServiceVideoOutput::getVideoFormat(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
471 snprintf(stMsgData->
paramValue, PARAM_LEN,
"%s",
"HDMI");
472 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] : Value: %s \n",__FUNCTION__, stMsgData->
paramValue);
473 stMsgData->
paramtype = hostIf_StringType;
475 if(bCalledVideoFormat && pChanged && strcmp(backupVideoFormat, stMsgData->
paramValue))
479 bCalledVideoFormat =
true;
480 strncpy(backupVideoFormat,stMsgData->
paramValue,_BUF_LEN_16-1);
481 backupVideoFormat[_BUF_LEN_16-1] =
'\0';
483 catch (
const std::exception e) {
484 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
504 int hostIf_STBServiceVideoOutput::getDisplayFormat(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
508 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] : Value: %s \n",__FUNCTION__, stMsgData->
paramValue);
509 stMsgData->
paramtype = hostIf_StringType;
511 if(bCalledDisplayFormat && pChanged && strcmp(backupDisplayFormat, stMsgData->
paramValue))
515 bCalledDisplayFormat =
true;
516 strncpy(backupDisplayFormat,stMsgData->
paramValue,_BUF_LEN_16-1);
517 backupDisplayFormat[_BUF_LEN_16-1] =
'\0';
519 catch (
const std::exception e) {
520 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
539 int hostIf_STBServiceVideoOutput::getName(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
543 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] : Value: %s \n",__FUNCTION__, stMsgData->
paramValue);
544 stMsgData->
paramtype = hostIf_StringType;
546 if(bCalledDisplayName && pChanged && strcmp(backupDisplayName, stMsgData->
paramValue))
550 bCalledDisplayName =
true;
551 strncpy(backupDisplayName,stMsgData->
paramValue,_BUF_LEN_16-1);
552 backupDisplayName[_BUF_LEN_16-1] =
'\0';
554 catch (
const std::exception e) {
555 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);
572 int hostIf_STBServiceVideoOutput::getHDCP(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
575 bool isHDCPSupported =
false;
579 hdpcStatus = vPort.getHDCPStatus();
585 stMsgData->
paramtype = hostIf_BooleanType;
587 RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,
"[%s] Value: %s \n",__FUNCTION__, stMsgData->
paramValue);
588 if(bCalledHDCP && pChanged && (backupHDCP != get_boolean(stMsgData->
paramValue)))
593 backupHDCP = get_boolean(stMsgData->
paramValue);
595 catch (
const std::exception e) {
596 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception\r\n",__FUNCTION__);