34 #include "illegalArgumentException.hpp"
35 #include "exception.hpp"
37 #include "safec_lib.h"
39 #define DEV_NAME "SPDIF"
40 #define BASE_NAME "Device.Services.STBService.1.Components.SPDIF"
41 #define UPDATE_FORMAT_STRING "%s.%d.%s"
43 #define ENABLE_STRING "Enable"
44 #define STATUS_STRING "Status"
45 #define ALIAS_STRING "Alias"
46 #define NAME_STRING "Name"
47 #define FORCEPCM_STRING "ForcePCM"
48 #define PASSTHROUGH_STRING "Passthrough"
49 #define AUDIODELAY_STRING "AudioDelay"
51 #define ENABLED_STRING "Enabled"
52 #define DISABLED_STRING "Disabled"
54 GHashTable * hostIf_STBServiceSPDIF::ifHash = NULL;
55 GMutex * hostIf_STBServiceSPDIF::m_mutex = NULL;
67 ifHash = g_hash_table_new(NULL,NULL);
75 g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
79 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught device::IllegalArgumentException, not able create STB service %s Interface instance %d..\n", DEV_NAME, dev_id);
83 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"Caught exception, not able create STB service %s Interface instance %d..\n", DEV_NAME, dev_id);
87 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);
91 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);
97 GList* hostIf_STBServiceSPDIF::getAllInstances()
100 return g_hash_table_get_keys(ifHash);
108 g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
113 void hostIf_STBServiceSPDIF::closeAllInstances()
117 GList* tmp_list = g_hash_table_get_values (ifHash);
122 tmp_list = tmp_list->next;
128 void hostIf_STBServiceSPDIF::getLock()
132 m_mutex = g_mutex_new();
134 g_mutex_lock(m_mutex);
137 void hostIf_STBServiceSPDIF::releaseLock()
139 g_mutex_unlock(m_mutex);
152 backupEnable =
false;
154 rc=strcpy_s(backupStatus,
sizeof(backupStatus),
" ");
159 backupForcePCM =
false;
160 backupPassthrough =
false;
161 backupAudioDelay = 0;
163 bCalledEnable =
false;
164 bCalledStatus =
false;
165 bCalledAlias =
false;
167 bCalledForcePCM =
false;
168 bCalledPassthrough =
false;
169 bCalledAudioDelay =
false;
189 int ret = NOT_HANDLED;
190 if (strcasecmp(paramName, FORCEPCM_STRING) == 0)
192 ret = setForcePCM(stMsgData);
212 int ret = NOT_HANDLED;
213 if (strcasecmp(paramName, ENABLE_STRING) == 0)
215 ret = getEnable(stMsgData);
217 else if (strcasecmp(paramName, STATUS_STRING) == 0)
219 ret = getStatus(stMsgData);
221 else if (strcasecmp(paramName, ALIAS_STRING) == 0)
223 ret = getAlias(stMsgData);
225 else if (strcasecmp(paramName, NAME_STRING) == 0)
227 ret = getName(stMsgData);
229 else if (strcasecmp(paramName, FORCEPCM_STRING) == 0)
231 ret = getForcePCM(stMsgData);
233 else if (strcasecmp(paramName, PASSTHROUGH_STRING) == 0)
235 ret = getPassthrough(stMsgData);
237 else if (strcasecmp(paramName, AUDIODELAY_STRING) == 0)
239 ret = getAudioDelay(stMsgData);
256 char tmp_buff[PARAM_LEN];
258 memset(&msgData,0,
sizeof(msgData));
259 memset(tmp_buff,0,PARAM_LEN);
262 getEnable(&msgData,&bChanged);
265 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, ENABLE_STRING);
272 memset(&msgData,0,
sizeof(msgData));
273 memset(tmp_buff,0,PARAM_LEN);
276 getStatus(&msgData,&bChanged);
279 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, STATUS_STRING);
286 memset(&msgData,0,
sizeof(msgData));
287 memset(tmp_buff,0,PARAM_LEN);
290 getAlias(&msgData,&bChanged);
293 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, ALIAS_STRING);
300 memset(&msgData,0,
sizeof(msgData));
301 memset(tmp_buff,0,PARAM_LEN);
304 getName(&msgData,&bChanged);
307 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, NAME_STRING);
314 memset(&msgData,0,
sizeof(msgData));
315 memset(tmp_buff,0,PARAM_LEN);
318 getForcePCM(&msgData,&bChanged);
321 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, FORCEPCM_STRING);
328 memset(&msgData,0,
sizeof(msgData));
329 memset(tmp_buff,0,PARAM_LEN);
332 getPassthrough(&msgData,&bChanged);
335 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, PASSTHROUGH_STRING);
342 memset(&msgData,0,
sizeof(msgData));
343 memset(tmp_buff,0,PARAM_LEN);
346 getAudioDelay(&msgData,&bChanged);
349 snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, AUDIODELAY_STRING);
357 int hostIf_STBServiceSPDIF::getNumberOfInstances(
HOSTIF_MsgData_t *stMsgData)
361 for (
int i = 0; i < aPorts.
size() ; i++)
363 if (strcasestr(aPorts.at(i).
getName().c_str(),
"spdif"))
367 stMsgData->
paramtype = hostIf_UnsignedIntType;
368 stMsgData->
paramLen =
sizeof(
unsigned int);
385 int ret = NOT_HANDLED;
399 int ret = NOT_HANDLED;
424 catch (
const std::exception e)
426 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception: %s\r\n",__FUNCTION__, e.what());
432 int hostIf_STBServiceSPDIF::getEnable(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
434 int ret = NOT_HANDLED;
448 int hostIf_STBServiceSPDIF::getStatus(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
451 strncpy(stMsgData->
paramValue, ENABLED_STRING, PARAM_LEN);
453 stMsgData->
paramtype = hostIf_StringType;
454 stMsgData->
paramLen = strlen(ENABLED_STRING);
455 if(bCalledStatus && pChanged && strcmp(backupStatus, stMsgData->
paramValue))
459 bCalledStatus =
true;
460 strncpy(backupStatus, stMsgData->
paramValue, _BUF_LEN_16-1);
461 backupStatus[_BUF_LEN_16-1] =
'\0';
475 int hostIf_STBServiceSPDIF::getAlias(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
477 int ret = NOT_HANDLED;
491 int hostIf_STBServiceSPDIF::getName(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
493 int ret = NOT_HANDLED;
508 int hostIf_STBServiceSPDIF::getForcePCM(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
522 stMsgData->
paramtype = hostIf_BooleanType;
524 if(bCalledForcePCM && pChanged && (backupForcePCM != get_boolean(stMsgData->
paramValue)))
528 bCalledForcePCM =
true;
529 backupForcePCM = get_boolean(stMsgData->
paramValue);
531 catch (
const std::exception e)
533 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception: %s\r\n",__FUNCTION__, e.what());
550 int hostIf_STBServiceSPDIF::getPassthrough(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
565 stMsgData->
paramtype = hostIf_BooleanType;
567 if(bCalledPassthrough && pChanged && (backupPassthrough != get_boolean(stMsgData->
paramValue)))
571 bCalledPassthrough =
true;
572 backupPassthrough = get_boolean(stMsgData->
paramValue);
574 catch (
const std::exception e)
576 RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,
"[%s] Exception: %s\r\n",__FUNCTION__, e.what());
592 int hostIf_STBServiceSPDIF::getAudioDelay(
HOSTIF_MsgData_t *stMsgData,
bool *pChanged)
594 int ret = NOT_HANDLED;