RDK Documentation (Open Sourced RDK Components)
Components_AudioOutput.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_AudioOutput.cpp
22  * @brief This source file contains the APIs of TR069 Components AudioOutput.
23  */
24 
25 
26 /**
27 * @defgroup tr69hostif
28 * @{
29 * @defgroup hostif
30 * @{
31 **/
32 
33 
34 #include "hostIf_main.h"
35 #include "dsTypes.h"
36 #include "illegalArgumentException.hpp"
37 #include "exception.hpp"
38 #include "Components_AudioOutput.h"
39 #include "safec_lib.h"
40 
41 #define DEV_NAME "AudioOutput"
42 #define BASE_NAME "Device.Services.STBService.1.Components.AudioOutput"
43 #define UPDATE_FORMAT_STRING "%s.%d.%s"
44 
45 #define STATUS_STRING "Status"
46 #define ENABLED_STRING "Enabled"
47 #define ENABLE_STRING "Enable"
48 #define CANCELMUTE_STRING "CancelMute"
49 #define AUDIOFORMAT_STRING "AudioFormat"
50 #define NAME_STRING "Name"
51 #define AUDIOLEVEL_STRING "AudioLevel"
52 #define COMCAST_AUDIOOPTIMALLEVEL_STRING "X_COMCAST-COM_AudioOptimalLevel"
53 #define COMCAST_MINAUDIODB_STRING "X_COMCAST-COM_MinAudioDB"
54 #define COMCAST_MAXAUDIODB_STRING "X_COMCAST-COM_MaxAudioDB"
55 #define COMCAST_AUDIODB_STRING "X_COMCAST-COM_AudioDB"
56 #define COMCAST_AUDIOSTEREOMODE_STRING "X_COMCAST-COM_AudioStereoMode"
57 #define COMCAST_AUDIOLOOPTHRU_STRING "X_COMCAST-COM_AudioLoopThru"
58 #define COMCAST_AUDIOENCODING_STRING "X_COMCAST-COM_AudioEncoding"
59 #define COMCAST_AUDIOCOMPRESSION_STRING "X_COMCAST-COM_AudioCompression"
60 #define COMCAST_AUDIOGAIN_STRING "X_COMCAST-COM_AudioGain"
61 #define COMCAST_DIALOGENHANCEMENT_STRING "X_COMCAST-COM_DialogEnhancement"
62 
63 
64 GHashTable * hostIf_STBServiceAudioInterface::ifHash = NULL;
65 GMutex * hostIf_STBServiceAudioInterface::m_mutex = NULL;
66 
67 hostIf_STBServiceAudioInterface* hostIf_STBServiceAudioInterface::getInstance(int dev_id)
68 {
70 
71  if(ifHash)
72  {
73  pRet = (hostIf_STBServiceAudioInterface *)g_hash_table_lookup(ifHash,(gpointer) dev_id);
74  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s:%d]: dev_id=[%d]; pRet=0x%08X\n", __FILE__, __FUNCTION__, __LINE__, dev_id, pRet);
75  }
76  else
77  {
78  ifHash = g_hash_table_new(NULL,NULL);
79  }
80 
81  if(!pRet)
82  {
83  try
84  {
86  pRet = new hostIf_STBServiceAudioInterface(dev_id, aPorts.at(dev_id-1));
87  g_hash_table_insert(ifHash, (gpointer)dev_id, pRet);
88  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s:%d]: AudioLevel[%d]=%f\n", __FILE__, __FUNCTION__, __LINE__, dev_id, pRet->aPort.getLevel());
89  }
90  catch (const device::IllegalArgumentException &e)
91  {
92  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught device::IllegalArgumentException, not able create STB service %s Interface instance %d..\n", DEV_NAME, dev_id);
93  }
94  catch (const int &e)
95  {
96  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught exception, not able create STB service %s Interface instance %d..\n", DEV_NAME, dev_id);
97  }
98  catch (const dsError_t &e)
99  {
100  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"Caught dsError_t %d, not able create STB service %s Interface instance %d..\n", e, DEV_NAME, dev_id);
101  }
102  catch (const device::Exception &e)
103  {
104  RDK_LOG(RDK_LOG_ERROR,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);
105  }
106  }
107  return pRet;
108 }
109 
110 GList* hostIf_STBServiceAudioInterface::getAllInstances()
111 {
112  if(ifHash)
113  return g_hash_table_get_keys(ifHash);
114  return NULL;
115 }
116 
117 void hostIf_STBServiceAudioInterface::closeInstance(hostIf_STBServiceAudioInterface *pDev)
118 {
119  if(pDev)
120  {
121  g_hash_table_remove(ifHash, (gconstpointer)pDev->dev_id);
122  delete pDev;
123  }
124 }
125 
126 void hostIf_STBServiceAudioInterface::closeAllInstances()
127 {
128  if(ifHash)
129  {
130  GList* tmp_list = g_hash_table_get_values (ifHash);
131 
132  while(tmp_list)
133  {
135  tmp_list = tmp_list->next;
136  closeInstance(pDev);
137  }
138  }
139 }
140 
141 void hostIf_STBServiceAudioInterface::getLock()
142 {
143  if(!m_mutex)
144  {
145  m_mutex = g_mutex_new();
146  }
147  g_mutex_lock(m_mutex);
148 }
149 
150 void hostIf_STBServiceAudioInterface::releaseLock()
151 {
152  g_mutex_unlock(m_mutex);
153 }
154 
155 /**
156  * @brief Class Constructor of the class hostIf_STBServiceAudioInterface.
157  *
158  * It will initialize the device id and audio output port.
159  *
160  * @param[in] devid Identification number of the device.
161  * @param[in] port Audio output port number.
162  */
164 {
165  errno_t rc = -1;
166  rc=strcpy_s(backupStatus,sizeof(backupStatus), " ");
167  if(rc!=EOK)
168  {
169  ERR_CHK(rc);
170  }
171  backupCancelMute = false;
172  rc=strcpy_s(backupAudioStereoMode,sizeof(backupAudioStereoMode)," ");
173  if(rc!=EOK)
174  {
175  ERR_CHK(rc);
176  }
177  backupAudioLevel=0;
178  rc=strcpy_s(backupAudioDB,sizeof(backupAudioDB)," ");
179  if(rc!=EOK)
180  {
181  ERR_CHK(rc);
182  }
183  rc=strcpy_s(backupAudioLoopThru,sizeof(backupAudioLoopThru)," ");
184  if(rc!=EOK)
185  {
186  ERR_CHK(rc);
187  }
188  backupAudioCompression=0;
189  rc=strcpy_s(backupAudioEncoding,sizeof(backupAudioEncoding)," ");
190  if(rc!=EOK)
191  {
192  ERR_CHK(rc);
193  }
194  rc=strcpy_s(backupAudioGain,sizeof(backupAudioGain)," ");
195  if(rc!=EOK)
196  {
197  ERR_CHK(rc);
198  }
199  rc=strcpy_s(backupMinAudioDB,sizeof(backupMinAudioDB)," ");
200  if(rc!=EOK)
201  {
202  ERR_CHK(rc);
203  }
204  rc=strcpy_s(backupMaxAudioDB,sizeof(backupMaxAudioDB)," ");
205  if(rc!=EOK)
206  {
207  ERR_CHK(rc);
208  }
209  rc=strcpy_s(backupAudioOptimalLevel,sizeof(backupAudioOptimalLevel)," ");
210  if(rc!=EOK)
211  {
212  ERR_CHK(rc);
213  }
214  backupDialogEnhancement=0;
215  bCalledStatus = false;
216  bCalledCancelMute = false;
217  bCalledAudioStereoMode = false;
218  bCalledAudioLevel = false;
219  bCalledAudioDB = false;
220  bCalledAudioLoopThru = false;
221  bCalledAudioCompression = false;
222  bCalledAudioEncoding = false;
223  bCalledAudioGain = false;
224  bCalledMinAudioDB = false;
225  bCalledMaxAudioDB = false;
226  bCalledAudioOptimalLevel = false;
227  bCalledDialogEnhancement = false;
228 }
229 
230 /**
231  * @brief This function set the audio interface such as mute status, audio encoding, audio level,
232  * Minimum dB(decibel) and Maximum dB(decibel) that can be supported on audio port, Stereo mode used
233  * in a given audio port etc..
234  *
235  * @param[in] pSetting Audio service name string.
236  * @param[in] stMsgData HostIf Message Request param contains the audio attribute value.
237  *
238  * @return Returns an Integer value.
239  * @retval 0 If successfully set the hostIf audio interface attribute.
240  * @retval -1 If Not able to set the hostIf audio interface attribute.
241  * @ingroup TR69_HOSTIF_STBSERVICES_AUDIOOUTPUT_API
242  */
244 {
245  int ret = NOT_HANDLED;
246  if (strcasecmp(pSetting, CANCELMUTE_STRING) == 0)
247  {
248  ret = setCancelMute(stMsgData);
249  }
250  else if (strcasecmp(pSetting, AUDIOLEVEL_STRING) == 0)
251  {
252  ret = setAudioLevel(stMsgData);
253  }
254  else if (strcasecmp(pSetting, COMCAST_AUDIODB_STRING) == 0)
255  {
256  ret = setX_COMCAST_COM_AudioDB(stMsgData);
257  }
258  else if (strcasecmp(pSetting, COMCAST_AUDIOSTEREOMODE_STRING) == 0)
259  {
260  ret = setX_COMCAST_COM_AudioStereoMode(stMsgData);
261  }
262  else if (strcasecmp(pSetting, COMCAST_AUDIOLOOPTHRU_STRING) == 0)
263  {
264  ret = setX_COMCAST_COM_AudioLoopThru(stMsgData);
265  }
266  else if (strcasecmp(pSetting, COMCAST_AUDIOENCODING_STRING) == 0)
267  {
268  ret = setAudioEncoding(stMsgData);
269  }
270  else if (strcasecmp(pSetting, COMCAST_AUDIOCOMPRESSION_STRING) == 0)
271  {
272  ret = setX_COMCAST_COM_AudioCompression(stMsgData);
273  }
274  else if (strcasecmp(pSetting, COMCAST_DIALOGENHANCEMENT_STRING) == 0)
275  {
276  ret = setX_COMCAST_COM_DialogEnhancement(stMsgData);
277  }
278  return ret;
279 }
280 
281 /**
282  * @brief This function get the audio interface attribute values such as mute status, audio encoding,
283  * audio level, Minimum dB(decibel) and Maximum dB(decibel) that can be supported on audio port, Stereo mode used
284  * in a given audio port etc..
285  *
286  * @param[in] paramName Audio service name string.
287  * @param[in] stMsgData Host IF Message Request param contains the audio attribute value.
288  *
289  * @return Returns an Integer value.
290  * @retval 0 If successfully get the hostIf audio interface attribute.
291  * @retval -1 If Not able to get the hostIf audio interface attribute.
292  * @retval -2 If Not handle the hostIf audio interface attribute.
293  * @ingroup TR69_HOSTIF_STBSERVICES_AUDIOOUTPUT_API
294  */
296 {
297  int ret = NOT_HANDLED;
298  if(strcasecmp(paramName, STATUS_STRING) == 0)
299  {
300  ret = getStatus(stMsgData);
301  }
302  else if(strcasecmp(paramName, ENABLE_STRING) == 0)
303  {
304  ret = getEnable(stMsgData);
305  }
306  else if(strcasecmp(paramName, CANCELMUTE_STRING) == 0)
307  {
308  ret = getCancelMute(stMsgData);
309  }
310  else if(strcasecmp(paramName, AUDIOFORMAT_STRING) == 0)
311  {
312  ret = getX_COMCAST_COM_AudioFormat(stMsgData);
313  }
314  else if(strcasecmp(paramName, NAME_STRING) == 0)
315  {
316  ret = getName(stMsgData);
317  }
318  else if(strcasecmp(paramName, AUDIOLEVEL_STRING) == 0)
319  {
320  ret = getAudioLevel(stMsgData);
321  }
322  else if(strcasecmp(paramName, COMCAST_AUDIOOPTIMALLEVEL_STRING) == 0)
323  {
324  ret = getX_COMCAST_COM_AudioOptimalLevel(stMsgData);
325  }
326  else if(strcasecmp(paramName, COMCAST_MINAUDIODB_STRING) == 0)
327  {
328  ret = getX_COMCAST_COM_MinAudioDB(stMsgData);
329  }
330  else if(strcasecmp(paramName, COMCAST_MAXAUDIODB_STRING) == 0)
331  {
332  ret = getX_COMCAST_COM_MaxAudioDB(stMsgData);
333  }
334  else if(strcasecmp(paramName, COMCAST_AUDIODB_STRING) == 0)
335  {
336  ret = getX_COMCAST_COM_AudioDB(stMsgData);
337  }
338  else if(strcasecmp(paramName,COMCAST_AUDIOSTEREOMODE_STRING) == 0)
339  {
340  ret = getX_COMCAST_COM_AudioStereoMode(stMsgData);
341  }
342  else if(strcasecmp(paramName, COMCAST_AUDIOLOOPTHRU_STRING) == 0)
343  {
344  ret = getX_COMCAST_COM_AudioLoopThru(stMsgData);
345  }
346  else if(strcasecmp(paramName, COMCAST_AUDIOENCODING_STRING) == 0)
347  {
348  ret = getX_COMCAST_COM_AudioEncoding(stMsgData);
349  }
350  else if(strcasecmp(paramName, COMCAST_AUDIOCOMPRESSION_STRING) == 0)
351  {
352  ret = getX_COMCAST_COM_AudioCompression(stMsgData);
353  }
354  else if(strcasecmp(paramName, COMCAST_AUDIOGAIN_STRING) == 0)
355  {
356  ret = getX_COMCAST_COM_AudioGain(stMsgData);
357  }
358  else if(strcasecmp(paramName, COMCAST_DIALOGENHANCEMENT_STRING) == 0)
359  {
360  ret = getX_COMCAST_COM_DialogEnhancement(stMsgData);
361  }
362  return ret;
363 }
364 
365 /**
366  * @brief This function updates the audio interface such as mute status, audio encoding, audio level,
367  * Minimum dB(decibel) and Maximum dB(decibel) that can be supported on audio port, Stereo mode used
368  * in a given audio port etc.. using callback mechanism.
369  *
370  * @param[in] mUpdateCallback Callback function which updates the hostIf audio interface.
371  * @ingroup TR69_HOSTIF_STBSERVICES_AUDIOOUTPUT_API
372  */
373 void hostIf_STBServiceAudioInterface::doUpdates(updateCallback mUpdateCallback)
374 {
375  HOSTIF_MsgData_t msgData;
376  bool bChanged;
377  char tmp_buff[PARAM_LEN];
378 
379  memset(&msgData,0,sizeof(msgData));
380  memset(tmp_buff,0,PARAM_LEN);
381  bChanged = false;
382  msgData.instanceNum=dev_id;
383  getCancelMute(&msgData,&bChanged);
384  if(bChanged)
385  {
386  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, CANCELMUTE_STRING);
387  if(mUpdateCallback)
388  {
389  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
390  }
391  }
392  memset(&msgData,0,sizeof(msgData));
393  memset(tmp_buff,0,PARAM_LEN);
394  bChanged = false;
395  msgData.instanceNum=dev_id;
396  getX_COMCAST_COM_AudioEncoding(&msgData,&bChanged);
397  if(bChanged)
398  {
399  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_AUDIOENCODING_STRING);
400  if(mUpdateCallback)
401  {
402  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
403  }
404  }
405  memset(&msgData,0,sizeof(msgData));
406  memset(tmp_buff,0,PARAM_LEN);
407  bChanged = false;
408  msgData.instanceNum=dev_id;
409  getAudioLevel(&msgData,&bChanged);
410  if(bChanged)
411  {
412  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, AUDIOLEVEL_STRING);
413  if(mUpdateCallback)
414  {
415  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
416  }
417  }
418  memset(&msgData,0,sizeof(msgData));
419  memset(tmp_buff,0,PARAM_LEN);
420  bChanged = false;
421  msgData.instanceNum=dev_id;
422  getX_COMCAST_COM_AudioOptimalLevel(&msgData,&bChanged);
423  if(bChanged)
424  {
425  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_AUDIOOPTIMALLEVEL_STRING);
426  if(mUpdateCallback)
427  {
428  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
429  }
430  }
431  memset(&msgData,0,sizeof(msgData));
432  memset(tmp_buff,0,PARAM_LEN);
433  bChanged = false;
434  msgData.instanceNum=dev_id;
435  getX_COMCAST_COM_MinAudioDB(&msgData,&bChanged);
436  if(bChanged)
437  {
438  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_MINAUDIODB_STRING);
439  if(mUpdateCallback)
440  {
441  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
442  }
443  }
444  memset(&msgData,0,sizeof(msgData));
445  memset(tmp_buff,0,PARAM_LEN);
446  bChanged = false;
447  msgData.instanceNum=dev_id;
448  getX_COMCAST_COM_MaxAudioDB(&msgData,&bChanged);
449  if(bChanged)
450  {
451  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_MAXAUDIODB_STRING);
452  if(mUpdateCallback)
453  {
454  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
455  }
456  }
457  memset(&msgData,0,sizeof(msgData));
458  memset(tmp_buff,0,PARAM_LEN);
459  bChanged = false;
460  msgData.instanceNum=dev_id;
461  getX_COMCAST_COM_AudioDB(&msgData,&bChanged);
462  if(bChanged)
463  {
464  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_AUDIODB_STRING);
465  if(mUpdateCallback)
466  {
467  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
468  }
469  }
470  memset(&msgData,0,sizeof(msgData));
471  memset(tmp_buff,0,PARAM_LEN);
472  bChanged = false;
473  msgData.instanceNum=dev_id;
474  getX_COMCAST_COM_AudioStereoMode(&msgData,&bChanged);
475  if(bChanged)
476  {
477  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_AUDIOSTEREOMODE_STRING);
478  if(mUpdateCallback)
479  {
480  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
481  }
482  }
483  memset(&msgData,0,sizeof(msgData));
484  memset(tmp_buff,0,PARAM_LEN);
485  bChanged = false;
486  msgData.instanceNum=dev_id;
487  getX_COMCAST_COM_AudioLoopThru(&msgData,&bChanged);
488  if(bChanged)
489  {
490  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_AUDIOLOOPTHRU_STRING);
491  if(mUpdateCallback)
492  {
493  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
494  }
495  }
496  memset(&msgData,0,sizeof(msgData));
497  memset(tmp_buff,0,PARAM_LEN);
498  bChanged = false;
499  msgData.instanceNum=dev_id;
500  getX_COMCAST_COM_AudioCompression(&msgData,&bChanged);
501  if(bChanged)
502  {
503  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_AUDIOCOMPRESSION_STRING);
504  if(mUpdateCallback)
505  {
506  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
507  }
508  }
509  memset(&msgData,0,sizeof(msgData));
510  memset(tmp_buff,0,PARAM_LEN);
511  bChanged = false;
512  msgData.instanceNum=dev_id;
513  getX_COMCAST_COM_AudioGain(&msgData,&bChanged);
514  if(bChanged)
515  {
516  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_AUDIOGAIN_STRING);
517  if(mUpdateCallback)
518  {
519  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
520  }
521  }
522  memset(&msgData,0,sizeof(msgData));
523  memset(tmp_buff,0,PARAM_LEN);
524  bChanged = false;
525  msgData.instanceNum=dev_id;
526  getX_COMCAST_COM_DialogEnhancement(&msgData,&bChanged);
527  if(bChanged)
528  {
529  snprintf(tmp_buff, PARAM_LEN, UPDATE_FORMAT_STRING, BASE_NAME, dev_id, COMCAST_DIALOGENHANCEMENT_STRING);
530  if(mUpdateCallback)
531  {
532  mUpdateCallback(IARM_BUS_TR69HOSTIFMGR_EVENT_VALUECHANGED,tmp_buff, msgData.paramValue, msgData.paramtype);
533  }
534  }
535 
536 }
537 
538 int hostIf_STBServiceAudioInterface::getNumberOfInstances(HOSTIF_MsgData_t *stMsgData)
539 {
541  put_int(stMsgData->paramValue, aPorts.size());
542  stMsgData->paramtype = hostIf_UnsignedIntType;
543  stMsgData->paramLen = sizeof(unsigned int);
544  return OK;
545 }
546 
547 /************************************************************
548  * Description : Get Audio Status
549  * Precondition : None
550  * Input : stMsgData for result return.
551  pChanged
552 
553  * Return : OK -> Success
554  NOK -> Failure
555  stMsgData->paramValue -> Disabled: Audio port diabled
556  -> Enabled: Audio port enabled
557  -> Muted: Audio port enabled and muted
558  -> Error: Error
559 ************************************************************/
560 
561 int hostIf_STBServiceAudioInterface::getStatus(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
562 {
563  //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
564  try {
565  const char* audioPortStatus = NULL;
566  bool isEnabled = aPort.isEnabled();
567  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] dev_id = %d, isEnabled = %s\n", __FUNCTION__, dev_id, isEnabled?"true":"false");
568  audioPortStatus = isEnabled? "Enabled" : "Disabled";
569  if(isEnabled)
570  {
571  bool isMute = aPort.isMuted();
572  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] dev_id = %d, isMute = %s\n", __FUNCTION__, dev_id, isMute?"true":"false");
573  audioPortStatus = isMute? "Muted" : "Enabled";
574  }
575 
576  strncpy(stMsgData->paramValue, audioPortStatus, PARAM_LEN);
577  stMsgData->paramValue[PARAM_LEN-1] = '\0';
578  stMsgData->paramtype = hostIf_StringType;
579  stMsgData->paramLen = strlen(stMsgData->paramValue);
580 
581  if(bCalledStatus && pChanged && strcmp(backupStatus, stMsgData->paramValue))
582  {
583  *pChanged = true;
584  }
585  bCalledStatus = true;
586  strncpy(backupStatus, stMsgData->paramValue, sizeof(backupStatus) -1);
587  backupStatus [sizeof(backupStatus) -1] = '\0';
588  //CID:44082 - OVERRUN
589  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] [Value: %s] \n", __FUNCTION__, stMsgData->paramValue);
590  }
591  catch (const std::exception e) {
592  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
593  return NOK;
594  }
595  //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
596  return OK;
597 }
598 
599 /************************************************************
600  * Description : Cancel Audio Mute
601  * Precondition : None
602  * Input : stMsgData->paramValue -> 1: cancels audio output mute status
603  -> 0: Setting it to false has no effect
604  * Return : OK -> Success
605  NOK -> Failure
606 ************************************************************/
607 
608 int hostIf_STBServiceAudioInterface::setCancelMute(const HOSTIF_MsgData_t *stMsgData)
609 {
610  bool toMute = get_boolean(stMsgData->paramValue);
611 
612  try {
613  aPort.setMuted(toMute);
614  }
615  catch (const std::exception e) {
616  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
617  return NOK;
618  }
619 
620  return OK;
621 }
622 
623 /************************************************************
624  * Description : Get Audio Mute Status
625  * Precondition : None
626  * Input : stMsgData for result return.
627  pChanged
628 
629  * Return : OK -> Success
630  NOK -> Failure
631  stMsgData->paramValue -> 1: Audio output set to mute
632  -> 0: Audio output not set to mute
633 ************************************************************/
634 
635 int hostIf_STBServiceAudioInterface::getCancelMute(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
636 {
637  //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
638  try {
639  bool getMute = 0;
640  getMute = aPort.isMuted();
641 
642  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] getMute = %d\n", __FUNCTION__, getMute);
643  put_boolean(stMsgData->paramValue,getMute);
644  stMsgData->paramtype=hostIf_BooleanType;
645  stMsgData->paramLen = sizeof(bool);
646  if(bCalledCancelMute && pChanged && (backupCancelMute != get_boolean(stMsgData->paramValue)))
647  {
648  *pChanged = true;
649  }
650  bCalledCancelMute = true;
651  backupCancelMute = get_boolean(stMsgData->paramValue);
652  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s()] [Value: %s] \n", __FUNCTION__, stMsgData->paramValue);
653  }
654  catch (const std::exception e) {
655  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
656  return NOK;
657  }
658  //RDK_LOG(RDK_LOG_TRACE1,LOG_TR69HOSTIF,"[%s:%s] Exiting..\n", __FUNCTION__, __FILE__);
659  return OK;
660 }
661 
662 /************************************************************
663  * Description : Get the enabled status for the audio port.
664  * Precondition : None
665  * Input : stMsgData for result return.
666 
667  * Return : OK -> Success
668  NOK -> Failure
669  stMsgData->paramValue -> true
670 ************************************************************/
671 
672 int hostIf_STBServiceAudioInterface::getEnable(HOSTIF_MsgData_t *stMsgData)
673 {
674  put_boolean(stMsgData->paramValue,true);
675  stMsgData->paramtype = hostIf_BooleanType;
676  stMsgData->paramLen = sizeof(bool);
677  return OK;
678 }
679 
680 /************************************************************
681  * Description : Get the human readable name for the audio device.
682  * Precondition : None
683  * Input : stMsgData for result return.
684 
685  * Return : OK -> Success
686  NOK -> Failure
687  stMsgData->paramValue -> name string
688 ************************************************************/
689 
690 int hostIf_STBServiceAudioInterface::getName(HOSTIF_MsgData_t *stMsgData)
691 {
692  try {
693  snprintf(stMsgData->paramValue, PARAM_LEN, "AudioOutputPort%s%d", aPort.getName().c_str(), dev_id);
694  stMsgData->paramtype = hostIf_StringType;
695  stMsgData->paramLen = strlen(stMsgData->paramValue);
696  }
697  catch (const std::exception e) {
698  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
699  return NOK;
700  }
701  return OK;
702 }
703 
704 /************************************************************
705  * Description : Set Stereo mode used in a given audio port
706  * Precondition : None
707  * Input : stMsgData->paramValue -> 0-3
708  -> 0: Unknown
709  -> 1: Mono
710  -> 2: Stereo
711  -> 3: Surround
712 
713  * Return : OK -> Success
714  NOK -> Failure
715 ************************************************************/
716 
717 int hostIf_STBServiceAudioInterface::setX_COMCAST_COM_AudioStereoMode(const HOSTIF_MsgData_t *stMsgData)
718 {
719  int mode = get_int(stMsgData->paramValue);
720 
721  try {
722  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Value: %s \n",__FUNCTION__, stMsgData->paramValue);
723  aPort.setStereoMode(mode);
724  }
725  catch (const std::exception e) {
726  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
727  return NOK;
728  }
729 
730  return OK;
731 }
732 
733 /************************************************************
734  * Description : Get Stereo mode used in a given audio port
735  * Precondition : None
736  * Input : stMsgData for result return.
737  pChanged
738 
739  * Return : OK -> Success
740  NOK -> Failure
741  stMsgData->paramValue -> 0: Unknown
742  -> 1: Mono
743  -> 2: Stereo
744  -> 3: Surround
745 ************************************************************/
746 
747 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_AudioStereoMode(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
748 {
749  try {
750  int stereoMode = 0;
751 
752  stereoMode = aPort.getStereoMode().getId();
753 
754  switch(stereoMode)
755  {
757  strncpy(stMsgData->paramValue, "Unknown", PARAM_LEN);
758  break;
759  case dsAUDIO_STEREO_MONO:
760  strncpy(stMsgData->paramValue, "Mono", PARAM_LEN);
761  break;
763  strncpy(stMsgData->paramValue, "Stereo", PARAM_LEN);
764  break;
766  strncpy(stMsgData->paramValue, "Surround", PARAM_LEN);
767  break;
769  strncpy(stMsgData->paramValue, "Expertmode", PARAM_LEN);
770  break;
771  default:
772  return NOK;
773  }
774  stMsgData->paramValue[PARAM_LEN-1] = '\0';
775  stMsgData->paramtype = hostIf_StringType;
776  stMsgData->paramLen = strlen(stMsgData->paramValue);
777  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Value:%s\n",__FUNCTION__, stMsgData->paramValue);
778  if(bCalledAudioStereoMode && pChanged && strcmp(backupAudioStereoMode, stMsgData->paramValue))
779  {
780  *pChanged = true;
781  }
782  bCalledAudioStereoMode = true;
783  strncpy(backupAudioStereoMode, stMsgData->paramValue, sizeof(backupAudioStereoMode) -1);
784  backupAudioStereoMode[sizeof(backupAudioStereoMode) -1] = '\0';
785  //CID:44081 - OVERRUN
786  }
787  catch (const std::exception e) {
788  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
789  return NOK;
790  }
791 
792  return OK;
793 }
794 
795 /************************************************************
796  * Description : Set Audio Encoding
797  * Precondition : None
798  * Input : stMsgData->paramValue -> 0-3
799  0: None
800  1: Display
801  2: PCM
802  3: AC3
803  * Return : OK -> Success
804  NOK -> Failure
805 ************************************************************/
806 
807 int hostIf_STBServiceAudioInterface::setAudioEncoding(const HOSTIF_MsgData_t *stMsgData)
808 {
809  int newEncoding = atoi((const char *)stMsgData->paramValue);
810  if ((newEncoding < device::AudioEncoding::kNone) || (newEncoding >= device::AudioEncoding::kMax))
811  {
812  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Invalid value to setAudioEncoding: %d\n",__FUNCTION__, newEncoding);
813  return NOK;
814  }
815 
816  try {
817  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] In setAudioEncoding(): Value: %s \n",__FUNCTION__, stMsgData->paramValue);
818  aPort.setEncoding(newEncoding);
819  }
820  catch (const std::exception e) {
821  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
822  return NOK;
823  }
824 
825  return OK;
826 }
827 
828 /************************************************************
829  * Description : Get Audio Encoding
830  * Precondition : None
831  * Input : stMsgData for result return.
832  pChanged
833 
834  * Return : OK -> Success
835  NOK -> Failure
836  stMsgData->paramValue -> the audio encoding
837  0: None
838  1: Display
839  2: PCM
840  3: AC3
841  4: Max
842 ************************************************************/
843 
844 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_AudioEncoding(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
845 {
846  try {
847  switch(aPort.getEncoding().getId())
848  {
849  case dsAUDIO_ENC_NONE:
850  strncpy(stMsgData->paramValue, "None", _BUF_LEN_16);
851  break;
852  case dsAUDIO_ENC_DISPLAY:
853  strncpy(stMsgData->paramValue, "Display", _BUF_LEN_16);
854  break;
855  case dsAUDIO_ENC_PCM:
856  strncpy(stMsgData->paramValue, "PCM", _BUF_LEN_16);
857  break;
858  case dsAUDIO_ENC_AC3:
859  strncpy(stMsgData->paramValue, "AC3", _BUF_LEN_16);
860  break;
861  default:
862  return NOK;
863  }
864  stMsgData->paramValue[_BUF_LEN_16-1] = '\0';
865  stMsgData->paramtype = hostIf_StringType;
866  stMsgData->paramLen = strlen(stMsgData->paramValue);
867  if(bCalledAudioEncoding && pChanged && strcmp(backupAudioEncoding, stMsgData->paramValue))
868  {
869  *pChanged = true;
870  }
871  bCalledAudioEncoding = true;
872  strncpy(backupAudioEncoding,stMsgData->paramValue, _BUF_LEN_16);
873  backupAudioEncoding[_BUF_LEN_16-1] = '\0';
874  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] stMsgData->paramValue [%s]\n",__FUNCTION__, stMsgData->paramValue);
875  }
876  catch (const std::exception e) {
877  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception: %s\r\n",__FUNCTION__, e.what());
878  return NOK;
879  }
880 
881  return OK;
882 }
883 
884 /************************************************************
885  * Description : Get Audio Format
886  * Precondition : None
887  * Input : stMsgData for result return.
888 
889 
890  * Return : OK -> Success
891  NOK -> Failure
892  stMsgData->paramValue -> The Audio Format
893  0: None
894  1: PCM
895  2: AC3
896  3: Max
897 ************************************************************/
898 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_AudioFormat(HOSTIF_MsgData_t *stMsgData)
899 {
900  try {
901  switch(aPort.getEncoding().getId())
902  {
903  case dsAUDIO_ENC_NONE:
904  strncpy(stMsgData->paramValue, "None", PARAM_LEN);
905  break;
906 
907  case dsAUDIO_ENC_DISPLAY:
908  /* Platform-selected digital audio encoding format. */
909  strncpy(stMsgData->paramValue, "Other", PARAM_LEN);
910  break;
911 
912  case dsAUDIO_ENC_PCM:
913  strncpy(stMsgData->paramValue, "PCM", PARAM_LEN);
914  break;
915 
916  case dsAUDIO_ENC_AC3:
917  strncpy(stMsgData->paramValue, "AC3", PARAM_LEN);
918  break;
919 
920  case dsAUDIO_ENC_EAC3:
921  strncpy(stMsgData->paramValue, "EAC3", PARAM_LEN);
922  break;
923 
924  default:
925  return NOK;
926  }
927 
928  stMsgData->paramValue[PARAM_LEN-1] = '\0';
929  stMsgData->paramtype = hostIf_StringType;
930  stMsgData->paramLen = strlen(stMsgData->paramValue);
931 
932  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] stMsgData->paramValue [%s]\n",__FUNCTION__, stMsgData->paramValue);
933  }
934  catch (const std::exception e) {
935  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception: %s\r\n",__FUNCTION__, e.what());
936  return NOK;
937  }
938 
939  return OK;
940 }
941 
942 
943 /************************************************************
944  * Description : Set Audio Compression
945  * Precondition : None
946  * Precondition : None
947  * Input : stMsgData->paramValue -> 0-10
948 
949  * Return : OK -> Success
950  NOK -> Failure
951 ************************************************************/
952 
953 int hostIf_STBServiceAudioInterface::setX_COMCAST_COM_AudioCompression(const HOSTIF_MsgData_t *stMsgData)
954 {
955  int newComp = get_int(stMsgData->paramValue);
956  if (newComp < 0 || newComp > 10)
957  {
958  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Failed due to Invalid value: %d\n",__FUNCTION__, newComp);
959  return NOK;
960  }
961 
962  try {
963  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Value: %s \n",__FUNCTION__, stMsgData->paramValue);
964  aPort.setCompression(newComp);
965  }
966  catch (const std::exception e) {
967  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
968  return NOK;
969  }
970 
971  return OK;
972 }
973 
974 /************************************************************
975  * Description : Get Audio Compression
976  * Precondition : None
977  * Input : stMsgData for result return.
978  pChanged
979 
980  * Return : OK -> Success
981  NOK -> Failure
982  stMsgData->paramValue -> the audio compression
983 ************************************************************/
984 
985 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_AudioCompression(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
986 {
987  try {
988  int compression = aPort.getCompression();
989 
990  put_int(stMsgData->paramValue, compression);
991  stMsgData->paramtype = hostIf_UnsignedIntType;
992  stMsgData->paramLen = sizeof(unsigned int);
993  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] \n",__FUNCTION__, stMsgData->paramValue);
994  if(bCalledAudioCompression && pChanged && (backupAudioCompression != get_int(stMsgData->paramValue)))
995  {
996  *pChanged = true;
997  }
998  bCalledAudioCompression = true;
999  backupAudioCompression = get_int(stMsgData->paramValue);
1000  }
1001  catch (const std::exception e) {
1002  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception: %s\r\n",__FUNCTION__, e.what());
1003  return NOK;
1004  }
1005 
1006  return OK;
1007 }
1008 
1009 /************************************************************
1010  * Description : Set Audio Level
1011  * Precondition : None
1012  * Input : stMsgData->paramValue -> 0-100
1013 
1014  * Return : OK -> Success
1015  NOK -> Failure
1016 ************************************************************/
1017 int hostIf_STBServiceAudioInterface::setAudioLevel(const HOSTIF_MsgData_t *stMsgData)
1018 {
1019 
1020  float newLevel = (float)get_int(stMsgData->paramValue);
1021  if (newLevel < 0.0 || newLevel > 100.0)
1022  {
1023  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Failed due to invalid value : %f\n",__FUNCTION__, newLevel);
1024  return NOK;
1025  }
1026 
1027  try {
1028  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s:%d]: Value=%f \n",__FUNCTION__, __FILE__, __LINE__, newLevel);
1029  aPort.setLevel(newLevel);
1030  }
1031  catch (const std::exception e) {
1032  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s:%s:%d]: Exception caught\r\n",__FUNCTION__, __FILE__, __LINE__);
1033  return NOK;
1034  }
1035 
1036  return OK;
1037 }
1038 
1039 
1040 /************************************************************
1041  * Description : Get Audio Level
1042  * Precondition : None
1043  * Input : stMsgData for result return.
1044  pChanged
1045 
1046  * Return : OK -> Success
1047  NOK -> Failure
1048  stMsgData->paramValue -> the audio level
1049 ************************************************************/
1050 
1051 int hostIf_STBServiceAudioInterface::getAudioLevel(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
1052 {
1053  try {
1054  float level = aPort.getLevel();
1055  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s:%s:%d]: getAudioLevel=%f, muted=%s, getOptimalLevel=%f, DB=[%f, %f]:%f, getGain=%f\n", __FUNCTION__, __FILE__, __LINE__, level, aPort.isMuted()?"Muted":"Not Muted", aPort.getOptimalLevel(), aPort.getMinDB(), aPort.getMaxDB(), aPort.getDB(), aPort.getGain());
1056  put_int(stMsgData->paramValue, (int)(level + 0.5));
1057  stMsgData->paramtype=hostIf_UnsignedIntType;
1058  stMsgData->paramLen = sizeof(unsigned int);
1059  if(bCalledAudioLevel && pChanged && (backupAudioLevel != get_int(stMsgData->paramValue)))
1060  {
1061  *pChanged = true;
1062  }
1063  bCalledAudioLevel = true;
1064  backupAudioLevel = get_int(stMsgData->paramValue);
1065  }
1066  catch (const std::exception e) {
1067  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception: %s\r\n",__FUNCTION__, e.what());
1068  return NOK;
1069  }
1070 
1071  return OK;
1072 }
1073 
1074 /************************************************************
1075  * Description : Set Audio DB
1076  * Precondition : None
1077  * Input : stMsgData->paramValue -> ???
1078 
1079  * Return : OK -> Success
1080  NOK -> Failure
1081 ************************************************************/
1082 int hostIf_STBServiceAudioInterface::setX_COMCAST_COM_AudioDB(const HOSTIF_MsgData_t *stMsgData)
1083 {
1084 
1085  float newDb = (float)get_int(stMsgData->paramValue);
1086 
1087  try {
1088  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] : Value: %s \n",__FUNCTION__, stMsgData->paramValue);
1089  aPort.setDB(newDb);
1090  }
1091  catch (const std::exception e) {
1092  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1093  return NOK;
1094  }
1095 
1096  return OK;
1097 }
1098 
1099 /************************************************************
1100  * Description : Get Audio DB
1101  * Precondition : None
1102  * Input : stMsgData for result return.
1103  pChanged
1104 
1105  * Return : OK -> Success
1106  NOK -> Failure
1107  stMsgData->paramValue -> the audio decibel (DB) level
1108 ************************************************************/
1109 
1110 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_AudioDB(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
1111 {
1112  try {
1113  float dbValue = 0.0;
1114  dbValue = aPort.getDB();
1115 
1116  snprintf(stMsgData->paramValue, PARAM_LEN, "%f", dbValue);
1117  stMsgData->paramtype = hostIf_StringType;
1118  stMsgData->paramLen = strlen(stMsgData->paramValue);
1119  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] \n",__FUNCTION__, stMsgData->paramValue);
1120  if(bCalledAudioDB && pChanged && strcmp(backupAudioDB, stMsgData->paramValue))
1121  {
1122  *pChanged = true;
1123  }
1124  bCalledAudioDB = true;
1125  strncpy(backupAudioDB, stMsgData->paramValue, sizeof(backupAudioDB) -1);
1126  backupAudioDB[sizeof(backupAudioDB) -1] = '\0';
1127  //CID:44080 - OVERRUN
1128  }
1129  catch (const std::exception e) {
1130  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1131  return NOK;
1132  }
1133 
1134  return OK;
1135 }
1136 
1137 /************************************************************
1138  * Description : Get Minimum DB that can be supported on audio port
1139  * Precondition : None
1140  * Input : stMsgData for result return.
1141  pChanged
1142 
1143  * Return : OK -> Success
1144  NOK -> Failure
1145  stMsgData->paramValue -> the audio decibel (DB) level
1146 ************************************************************/
1147 
1148 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_MinAudioDB(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
1149 {
1150  try {
1151  float minDbValue = 0.0;
1152  minDbValue = aPort.getMinDB();
1153 
1154  snprintf(stMsgData->paramValue, PARAM_LEN, "%f", minDbValue);
1155  stMsgData->paramtype = hostIf_StringType;
1156  stMsgData->paramLen = strlen(stMsgData->paramValue);
1157  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] \n",__FUNCTION__, stMsgData->paramValue);
1158  if(bCalledMinAudioDB && pChanged && strcmp(backupMinAudioDB, stMsgData->paramValue))
1159  {
1160  *pChanged = true;
1161  }
1162  bCalledMinAudioDB = true;
1163  strncpy(backupMinAudioDB, stMsgData->paramValue, _BUF_LEN_16-1);
1164  backupMinAudioDB[_BUF_LEN_16-1] = '\0';
1165  }
1166  catch (const std::exception e) {
1167  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1168  return NOK;
1169  }
1170 
1171  return OK;
1172 }
1173 
1174 /************************************************************
1175  * Description : Get Maximum DB that can be supported on audio port
1176  * Precondition : None
1177  * Input : stMsgData for result return.
1178  pChanged
1179 
1180  * Return : OK -> Success
1181  NOK -> Failure
1182  stMsgData->paramValue -> the audio decibel (DB) level
1183 ************************************************************/
1184 
1185 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_MaxAudioDB(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
1186 {
1187  try {
1188  float maxDbValue = 0.0;
1189  maxDbValue = aPort.getMaxDB();
1190 
1191  snprintf(stMsgData->paramValue, PARAM_LEN, "%f", maxDbValue);
1192  stMsgData->paramtype = hostIf_StringType;
1193  stMsgData->paramLen = strlen(stMsgData->paramValue);
1194  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] \n",__FUNCTION__, stMsgData->paramValue);
1195  if(bCalledMaxAudioDB && pChanged && strcmp(backupMaxAudioDB, stMsgData->paramValue))
1196  {
1197  *pChanged = true;
1198  }
1199  bCalledMaxAudioDB = true;
1200  strncpy(backupMaxAudioDB, stMsgData->paramValue, _BUF_LEN_16-1);
1201  backupMaxAudioDB[_BUF_LEN_16-1] = '\0';
1202  }
1203  catch (const std::exception e) {
1204  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1205  return NOK;
1206  }
1207 
1208  return OK;
1209 }
1210 
1211 /************************************************************
1212  * Description : Get Audio Gain
1213  * Precondition : None
1214  * Input : stMsgData for result return.
1215  pChanged
1216 
1217  * Return : OK -> Success
1218  NOK -> Failure
1219  stMsgData->paramValue -> the audio gain
1220 ************************************************************/
1221 
1222 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_AudioGain(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
1223 {
1224  try {
1225  float gainValue = 0.0;
1226  gainValue = aPort.getGain();
1227 
1228  snprintf(stMsgData->paramValue, PARAM_LEN, "%f", gainValue);
1229  stMsgData->paramtype = hostIf_StringType;
1230  stMsgData->paramLen = strlen(stMsgData->paramValue);
1231  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] \n",__FUNCTION__, stMsgData->paramValue);
1232  if(bCalledAudioGain && pChanged && strcmp(backupAudioGain, stMsgData->paramValue))
1233  {
1234  *pChanged = true;
1235  }
1236  bCalledAudioGain = true;
1237  strncpy(backupAudioGain,stMsgData->paramValue, _BUF_LEN_16-1);
1238  backupAudioGain[_BUF_LEN_16-1] = '\0';
1239  }
1240  catch (const std::exception e) {
1241  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1242  return NOK;
1243  }
1244 
1245  return OK;
1246 }
1247 
1248 /************************************************************
1249  * Description : Sets a given audio port for loopthru
1250  * Precondition : None
1251  * Input : stMsgData->paramValue -> 1: Set audio port for loopthru
1252  -> 0: Unset audio port for loopthru
1253  * Return : OK -> Success
1254  NOK -> Failure
1255 ************************************************************/
1256 
1257 int hostIf_STBServiceAudioInterface::setX_COMCAST_COM_AudioLoopThru(const HOSTIF_MsgData_t *stMsgData)
1258 {
1259  bool loopThru = get_boolean(stMsgData->paramValue);
1260 
1261  try {
1262  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Value: %s \n",__FUNCTION__, stMsgData->paramValue);
1263  aPort.setLoopThru(loopThru);
1264  }
1265  catch (const std::exception e) {
1266  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1267  return NOK;
1268  }
1269 
1270  return OK;
1271 }
1272 
1273 /************************************************************
1274  * Description : Informs if a given audio port is set for loopthru
1275  * Precondition : None
1276  * Input : stMsgData for result return.
1277  pChanged
1278 
1279  * Return : OK -> Success
1280  NOK -> Failure
1281  stMsgData->paramValue -> 1 : audio port set for loopthru
1282  0 : audio port not set for loopthru
1283 
1284 ************************************************************/
1285 
1286 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_AudioLoopThru(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
1287 {
1288  try {
1289  bool isLoopThru = 0;
1290  isLoopThru = aPort.isLoopThru();
1291 
1292  snprintf(stMsgData->paramValue, PARAM_LEN, "%d", isLoopThru);
1293  stMsgData->paramtype = hostIf_StringType;
1294  stMsgData->paramLen = strlen(stMsgData->paramValue);
1295  if(bCalledAudioLoopThru && pChanged && strcmp(backupAudioLoopThru, stMsgData->paramValue))
1296  {
1297  *pChanged = true;
1298  }
1299  bCalledAudioLoopThru = true;
1300  strncpy(backupAudioLoopThru, stMsgData->paramValue, sizeof(backupAudioLoopThru) -1);
1301  backupAudioLoopThru[sizeof(backupAudioLoopThru) -1] = '\0';
1302  //CID:44083 - OVERRUN
1303  }
1304  catch (const std::exception e) {
1305  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1306  return NOK;
1307  }
1308 
1309  return OK;
1310 }
1311 
1312 /************************************************************
1313  * Description : Get Audio Optimal audio level
1314  * Precondition : None
1315  * Input : stMsgData for result return.
1316  pChanged
1317 
1318  * Return : OK -> Success
1319  NOK -> Failure
1320  stMsgData->paramValue -> the audio level
1321 ************************************************************/
1322 
1323 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_AudioOptimalLevel(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
1324 {
1325  try {
1326  float optimalLevel = 0.0;
1327  optimalLevel = aPort.getOptimalLevel();
1328 
1329  snprintf(stMsgData->paramValue, PARAM_LEN, "%f", optimalLevel);
1330  stMsgData->paramtype = hostIf_StringType;
1331  stMsgData->paramLen = strlen(stMsgData->paramValue);
1332  if(bCalledAudioOptimalLevel && pChanged && strcmp(backupAudioOptimalLevel, stMsgData->paramValue))
1333  {
1334  *pChanged = true;
1335  }
1336  bCalledAudioOptimalLevel = true;
1337  strncpy(backupAudioOptimalLevel, stMsgData->paramValue, _BUF_LEN_16-1);
1338  backupAudioOptimalLevel[_BUF_LEN_16-1] = '\0';
1339  }
1340  catch (const std::exception e) {
1341  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1342  return NOK;
1343  }
1344 
1345  return OK;
1346 }
1347 
1348 /************************************************************
1349  * Description : Set Dialog Enhancement Level
1350  * Precondition : None
1351  * Precondition : None
1352  * Input : stMsgData->paramValue -> 0-16
1353 
1354  * Return : OK -> Success
1355  NOK -> Failure
1356 ************************************************************/
1357 
1358 int hostIf_STBServiceAudioInterface::setX_COMCAST_COM_DialogEnhancement(const HOSTIF_MsgData_t *stMsgData)
1359 {
1360  int newLevel = get_int(stMsgData->paramValue);
1361 
1362  if (newLevel < 0 || newLevel > 16)
1363  {
1364  RDK_LOG(RDK_LOG_ERROR,LOG_TR69HOSTIF,"[%s] Failed due to invalid value : %d\n",__FUNCTION__, newLevel);
1365  return NOK;
1366  }
1367 
1368  try {
1369  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] Value: %s \n",__FUNCTION__, stMsgData->paramValue);
1370  aPort.setDialogEnhancement(newLevel);
1371  }
1372  catch (const std::exception e) {
1373  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1374  return NOK;
1375  }
1376 
1377  return OK;
1378 }
1379 
1380 /************************************************************
1381  * Description : Get Dialog Enhancement Level
1382  * Precondition : None
1383  * Input : stMsgData for result return.
1384  pChanged
1385 
1386  * Return : OK -> Success
1387  NOK -> Failure
1388  stMsgData->paramValue -> the dialog enhancement level
1389 ************************************************************/
1390 
1391 int hostIf_STBServiceAudioInterface::getX_COMCAST_COM_DialogEnhancement(HOSTIF_MsgData_t *stMsgData,bool *pChanged)
1392 {
1393  try {
1394  int enhancementLevel = 0;
1395  enhancementLevel = aPort.getDialogEnhancement();
1396 
1397  put_int(stMsgData->paramValue, enhancementLevel);
1398  stMsgData->paramtype = hostIf_UnsignedIntType;
1399  stMsgData->paramLen = sizeof(unsigned int);
1400  RDK_LOG(RDK_LOG_DEBUG,LOG_TR69HOSTIF,"[%s] \n",__FUNCTION__, stMsgData->paramValue);
1401  if(bCalledDialogEnhancement && pChanged && (backupDialogEnhancement != get_int(stMsgData->paramValue)))
1402  {
1403  *pChanged = true;
1404  }
1405  bCalledDialogEnhancement = true;
1406  backupDialogEnhancement = get_int(stMsgData->paramValue);
1407  }
1408  catch (const std::exception e) {
1409  RDK_LOG(RDK_LOG_WARN,LOG_TR69HOSTIF,"[%s] Exception\r\n",__FUNCTION__);
1410  return NOK;
1411  }
1412 
1413  return OK;
1414 }
1415 
1416 /** @} */
1417 /** @} */
device::AudioOutputPort::isEnabled
bool isEnabled() const
This API is used to check whether the audio is enabled or not.
Definition: audioOutputPort.cpp:549
device::AudioOutputPort::getDialogEnhancement
int getDialogEnhancement() const
This API is used to get the current auto mode.
Definition: audioOutputPort.cpp:891
_HostIf_MsgData_t::instanceNum
short instanceNum
Definition: hostIf_tr69ReqHandler.h:176
device::AudioOutputPort::getDB
float getDB() const
This API will get the current Decibel value for the given Audio port.
Definition: audioOutputPort.cpp:408
hostIf_STBServiceAudioInterface::handleSetMsg
int handleSetMsg(const char *paramName, HOSTIF_MsgData_t *stMsgData)
This function set the audio interface such as mute status, audio encoding, audio level,...
Definition: Components_AudioOutput.cpp:243
device::AudioOutputPort::setDialogEnhancement
void setDialogEnhancement(const int level)
This API is used to set the compression mode in a given audio port.
Definition: audioOutputPort.cpp:669
device::AudioOutputPort::getGain
float getGain() const
This API will get the current Gain for the given audio output port.
Definition: audioOutputPort.cpp:386
device::AudioEncoding::kMax
static const int kMax
Indicates the maximum encoding formats supported.
Definition: audioEncoding.hpp:58
device::AudioOutputPort::getEncoding
const AudioEncoding & getEncoding() const
This API is used to get the current encoding of the output port.
Definition: audioOutputPort.cpp:260
dsTypes.h
Device Settings HAL types.
device::AudioOutputPort::getOptimalLevel
float getOptimalLevel() const
This API is used to get the current optimal level value for audio output port.
Definition: audioOutputPort.cpp:444
device::AudioOutputPort::getStereoMode
const AudioStereoMode & getStereoMode(bool usePersist=false)
This API is used to get the current stereo mode of the output port.
Definition: audioOutputPort.cpp:273
device::AudioEncoding::kNone
static const int kNone
Value indicating encoding type None.
Definition: audioEncoding.hpp:54
device::AudioOutputPort::getLevel
float getLevel() const
This API is used to get the current audio level for the given audio output port.
Definition: audioOutputPort.cpp:492
_HostIf_MsgData_t
Definition: hostIf_tr69ReqHandler.h:170
device::AudioOutputPort::isLoopThru
bool isLoopThru() const
This API is used to check whether the given audio port is configured for loop thro'.
Definition: audioOutputPort.cpp:514
dsAUDIO_STEREO_STEREO
@ dsAUDIO_STEREO_STEREO
Definition: dsTypes.h:376
device::AudioOutputPort::getName
const std::string & getName() const
This API gets the name of the AudioOutputPort. The AudioOutputPort names can be IDLR,...
Definition: audioOutputPort.hpp:105
device::Host::getAudioOutputPorts
List< AudioOutputPort > getAudioOutputPorts()
This API is used to get the list of the audio output ports supported on the device....
Definition: host.cpp:309
device::AudioOutputPort::setLevel
void setLevel(const float level)
This API is used to set the audio level to be used in a given audio port.
Definition: audioOutputPort.cpp:1771
Components_AudioOutput.h
The header file provides capabilities audio output information APIs.
dsAUDIO_ENC_NONE
@ dsAUDIO_ENC_NONE
Definition: dsTypes.h:184
dsAUDIO_ENC_EAC3
@ dsAUDIO_ENC_EAC3
Definition: dsTypes.h:188
put_boolean
void put_boolean(char *ptr, bool val)
This function converts the input data to Boolean type.
Definition: hostIf_utils.cpp:191
device::List::size
size_t size()
This function gets the size of the container.
Definition: list.hpp:118
hostIf_main.h
hostIf_main API.
dsAUDIO_ENC_PCM
@ dsAUDIO_ENC_PCM
Definition: dsTypes.h:186
device::AudioOutputPort
Class extending Enumerable to implement the audiooutputport interface.
Definition: audioOutputPort.hpp:60
dsAUDIO_STEREO_SURROUND
@ dsAUDIO_STEREO_SURROUND
Definition: dsTypes.h:377
device::AudioOutputPort::getMinDB
float getMinDB() const
This API is used to get the current minimum decibel that Audio output port can support.
Definition: audioOutputPort.cpp:432
_HostIf_MsgData_t::paramtype
HostIf_ParamType_t paramtype
Definition: hostIf_tr69ReqHandler.h:177
RDK_LOG
#define RDK_LOG
Definition: rdk_debug.h:258
hostIf_STBServiceAudioInterface::handleGetMsg
int handleGetMsg(const char *paramName, HOSTIF_MsgData_t *stMsgData)
This function get the audio interface attribute values such as mute status, audio encoding,...
Definition: Components_AudioOutput.cpp:295
device::AudioOutputPort::isMuted
bool isMuted() const
This API is used to check whether the audio is muted or not.
Definition: audioOutputPort.cpp:530
device::Exception::getCode
virtual int getCode() const
This function is used to get the error code of the exception.
Definition: exception.hpp:104
device::AudioOutputPort::setMuted
void setMuted(const bool mute)
This API is used to mute/unmute the audio. It throws an IllegalArgumentException if audio could not b...
Definition: audioOutputPort.cpp:1839
device::AudioOutputPort::setEncoding
void setEncoding(const int encoding)
This API is used to set the Encoding method in a given audio port.
Definition: audioOutputPort.cpp:608
device::AudioOutputPort::setLoopThru
void setLoopThru(const bool loopThru)
This API is used to set the audio port to do loop thro.
Definition: audioOutputPort.cpp:1822
dsAUDIO_STEREO_PASSTHRU
@ dsAUDIO_STEREO_PASSTHRU
Definition: dsTypes.h:378
hostIf_STBServiceAudioInterface
This class provides the TR069 components audio output information.
Definition: Components_AudioOutput.h:112
hostIf_STBServiceAudioInterface::hostIf_STBServiceAudioInterface
hostIf_STBServiceAudioInterface(int dev_id, device::AudioOutputPort &port)
Class Constructor of the class hostIf_STBServiceAudioInterface.
Definition: Components_AudioOutput.cpp:163
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
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
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
dsAUDIO_ENC_AC3
@ dsAUDIO_ENC_AC3
Definition: dsTypes.h:187
dsAUDIO_STEREO_UNKNOWN
@ dsAUDIO_STEREO_UNKNOWN
Definition: dsTypes.h:374
device::List< device::AudioOutputPort >
hostIf_STBServiceAudioInterface::doUpdates
void doUpdates(updateCallback mUpdateCallback)
This function updates the audio interface such as mute status, audio encoding, audio level,...
Definition: Components_AudioOutput.cpp:373
dsAUDIO_ENC_DISPLAY
@ dsAUDIO_ENC_DISPLAY
Definition: dsTypes.h:185
device::AudioOutputPort::setCompression
void setCompression(const int compression)
This API is used to set the compression mode in a given audio port.
Definition: audioOutputPort.cpp:648
device::IllegalArgumentException
This class extends Exception class to manage the expections caused due to illegal arguments.
Definition: illegalArgumentException.hpp:51
device::AudioOutputPort::setStereoMode
void setStereoMode(const int mode, const bool toPersist=true)
This API is used to set the stereo mode to be used in a given audio port.If toPersist is true,...
Definition: audioOutputPort.cpp:1412
device::AudioOutputPort::getCompression
int getCompression() const
This API is used to get the current compression of the output port.
Definition: audioOutputPort.cpp:871
put_int
void put_int(char *ptr, int val)
This function converts the input data to integer type.
Definition: hostIf_utils.cpp:152
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
device::AudioOutputPort::setDB
void setDB(const float db)
This API is used to set the audio DB value to be used in a given audio port.
Definition: audioOutputPort.cpp:1719
dsAUDIO_STEREO_MONO
@ dsAUDIO_STEREO_MONO
Definition: dsTypes.h:375
_HostIf_MsgData_t::paramLen
short paramLen
Definition: hostIf_tr69ReqHandler.h:175
device::AudioOutputPort::getMaxDB
float getMaxDB() const
This API is used to get the current Maximum decibel that Audio output port can support.
Definition: audioOutputPort.cpp:420
device::DSConstant::getId
virtual int getId() const
This function is used to get the id.
Definition: dsConstant.hpp:130