RDK Documentation (Open Sourced RDK Components)
host.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 
22 /**
23 * @defgroup devicesettings
24 * @{
25 * @defgroup ds
26 * @{
27 **/
28 
29 
30 #include <iostream>
31 #include <algorithm>
32 #include <string.h>
33 #include "iarmProxy.hpp"
34 #include "audioOutputPortConfig.hpp"
35 #include "videoOutputPortConfig.hpp"
36 #include "list.hpp"
37 #include "host.hpp"
38 #include "videoDeviceConfig.hpp"
39 #include "dsVideoPort.h"
40 #include "dsVideoDevice.h"
41 #include "dsAudio.h"
42 #include "dsDisplay.h"
43 #include "dslogger.h"
44 #include "dsHost.h"
45 #include "dsTypes.h"
47 #include "hostEDID.hpp"
48 
49 /**
50  * @file host.cpp
51  * @brief The host module is the central module of the Device Settings module.
52  * Each devices establishes one and only one host instance that represents the entire host device.
53  */
54 using namespace std;
55 
56 namespace device
57 {
58 
59  const int Host::kPowerOn = dsPOWER_ON;
60  const int Host::kPowerOff = dsPOWER_OFF;
61  const int Host::kPowerStandby = dsPOWER_STANDBY;
62 
63 
64  Host::Host()
65  {
66  // TODO Auto-generated destructor stub
67  }
68 
69  Host::~Host() {
70  if (true)
71  {
72  IARMProxy::getInstance().UnRegisterPowerEventHandler();
73  }
74  }
75 
76 
77 /**
78  * @addtogroup dssettingshostapi
79  * @{
80  */
81 
82 /**
83  * @fn Host& Host::getInstance()
84  * @brief This API is used to get a reference to the single instance of the Host object.
85  *
86  * @return reference to Host singleton instance
87  */
88  Host& Host::getInstance()
89  {
90  static Host instance; // instance is in thread-safe now.
91  static bool isFirstTime = true;
92  try {
93  if (isFirstTime) {
94  isFirstTime = false;
95  }
96  else {
97  }
98  }
99  catch (...) {
100  cout << "Host Exception Thrown ...!\n";
101  }
102  return instance;
103  }
104 
105 
106 /**
107  * @fn void Host::addPowerModeListener(PowerModeChangeListener *l)
108  * @brief This API is used to register listeners for Power Mode change event.
109  * The listener object is created by application and should be released by the application once the listener is removed.
110  * Listeners will be notified with the new mode via the listener's powerModeChanged() callback.
111  *
112  * @param[in] PowerModeChangeListener Pointer to Power Mode change listener
113  *
114  * @return None
115  */
116  void Host::addPowerModeListener(PowerModeChangeListener *l)
117  {
118  std::list < PowerModeChangeListener* > ::iterator it;
119 
120  it = find (powerEvntListeners.begin(),powerEvntListeners.end(), l);
121  if (it == powerEvntListeners.end())
122  {
123  powerEvntListeners.push_back (l);
124  cout << "Added Power Mode listener...!\n";
125  }
126  else
127  {
128  cout << "Already register for Power Mode Change\n";
129  }
130  return ;
131  }
132 
133 
134 /**
135  * @fn void Host::removePowerModeChangeListener(PowerModeChangeListener *l)
136  * @brief This API is used to remove a listener from Power Mode change listener list.
137  *
138  * @param[in]PowerModeChangeListener The listener to remove.
139  *
140  * @return None
141  */
142  void Host::removePowerModeChangeListener(PowerModeChangeListener *l)
143  {
144  std::list < PowerModeChangeListener* > ::iterator it ;
145  it = find (powerEvntListeners.begin(),powerEvntListeners.end(), l);
146  if (it == powerEvntListeners.end())
147  {
148  cout << "Not Registered for Power Mode change yet...!\n";
149  }
150  else
151  {
152  powerEvntListeners.erase (it);
153  cout << "Removed from Power Mode listener group..!\n";
154  }
155  return;
156  }
157 
158 
159 /**
160  * @fn void Host::addDisplayConnectionListener (DisplayConnectionChangeListener *l)
161  * @brief This API is used to register listeners for Display connection change event.
162  * The listener will be notified if Display device is connected/disconnected from the video output port.
163  * The notification only carries the state change of the connection.
164  * It does not carry any other system state change that may have been triggered by the connection.
165  * The application is responsible to query the various parts of system to detect any such change.
166  * For example, when a TV device is replaced, the application shall query the video output port again upon the connection
167  * for the new resolution supported by the TV.
168  * The listener object is created by application and should be released by the application once the listener is removed.
169  *
170  * @param[in] DisplayConnectionChangeListener Pointer to Display connection change listener
171  *
172  * @return None
173  */
174  void Host::addDisplayConnectionListener (DisplayConnectionChangeListener *l)
175  {
176  std::list < DisplayConnectionChangeListener* > ::iterator it;
177 
178  it = find (dispEvntListeners.begin(), dispEvntListeners.end(), l);
179  if (it == dispEvntListeners.end())
180  {
181  dispEvntListeners.push_back (l);
182  cout << "Added Display listener...!\n";
183  }
184  else
185  {
186  cout << "Already registered to the Display listener\n";
187  }
188  return ;
189  }
190 
191 
192 /**
193  * @fn void Host::removeDisplayConnectionListener (DisplayConnectionChangeListener *l)
194  * @brief This API is used to remove listeners from the Display connection change event list.
195  *
196  * @param[in] DisplayConnectionChangeListener The listener to remove
197  *
198  * @return None
199  */
200  void Host::removeDisplayConnectionListener (DisplayConnectionChangeListener *l)
201  {
202  std::list < DisplayConnectionChangeListener* > ::iterator it ;
203  it = find (dispEvntListeners.begin(), dispEvntListeners.end(), l);
204  if (it == dispEvntListeners.end())
205  {
206  cout << "Not Registered to Display Listener yet...!\n";
207  }
208  else
209  {
210  dispEvntListeners.erase (it);
211  cout << "Removed from the Display listener...!\n";
212  }
213  return;
214  }
215 
216 
217 /**
218  * @fn void Host::notifyPowerChange (const int mode)
219  * @brief This function is used to get the current power state.
220  *
221  * @param[in] mode Power mode of the decoder.
222  * @return None.
223  */
224  void Host::notifyPowerChange (const int mode)
225  {
226  std::list < PowerModeChangeListener* > ::iterator it;
227  for ( it = powerEvntListeners.begin() ; it != powerEvntListeners.end(); it++ )
228  {
229  (*it)->powerModeChanged (mode);
230  }
231  }
232 
233  void Host::notifyDisplayConnectionChange (int portHandle, bool newConnectionStatus)
234  {
235  std::list < DisplayConnectionChangeListener* > ::iterator it;
236  for ( it = dispEvntListeners.begin() ; it != dispEvntListeners.end(); it++ )
237  {
238  (*it)->displayConnectionChanged(getVideoOutputPort(portHandle), newConnectionStatus);
239  getVideoOutputPort(portHandle).setDisplayConnected(newConnectionStatus);
240  }
241  }
242 
243 
244 /**
245  * @fn bool Host::setPowerMode(int mode)
246  * @brief This API is used to change the power mode of the device.
247  * This function will set the power mode to active or standby and turn off all the ouput ports.
248  * The accepted modes are defined as constants in host module: Host::kPowerOn, Host::kPowerOff, Host::kPowerStandby.
249  * Upon the return of this API, the power mode listeners will be notified of the new power mode.
250  * This function is currently not supported.
251  *
252  * @param[in] mode New Power Mode.
253  *
254  * @return None
255  */
256  bool Host::setPowerMode(int mode)
257  {
259  }
260 
261 
262 /**
263  * @fn int Host::getPowerMode()
264  * @brief This API is used to get the current power mode of the device.
265  * This function is currently not supported.
266  *
267  * @return Current power mode
268  */
269  int Host::getPowerMode()
270  {
272  }
273 
274 
275 /**
276  * @fn List<VideoOutputPort> Host::getVideoOutputPorts()
277  * @brief This API is used to get the list of the video output ports supported on the device.
278  * A complete list of ports that are physically present on the platform will be returned, regardless the state of each port.
279  * If no Video Output Port is available on the device, an empty List will be returned.
280  *
281  * @param None
282  *
283  * @return A list of videooutputport instances
284  */
285  List<VideoOutputPort> Host::getVideoOutputPorts()
286  {
287  List<VideoOutputPort> rPorts;
288 
289  List<VideoOutputPortType> vTypes = VideoOutputPortConfig::getInstance().getSupportedTypes();
290  for (size_t i = 0; i < vTypes.size(); i++) {
291  List<VideoOutputPort> vPorts = vTypes.at(i).getPorts();
292  for (size_t j = 0; j < vPorts.size(); j++) {
293  rPorts.push_back(vPorts.at(j));
294  }
295  }
296 
297  return rPorts;
298  }
299 
300 
301 /**
302  * @fn List<AudioOutputPort> Host::getAudioOutputPorts()
303  * @brief This API is used to get the list of the audio output ports supported on the device.
304  * A complete list of ports that are physically present on the platform will be returned, regardless the state of each port.
305  * If no Audio Output Port is available on the device, an empty List will be returned.
306  *
307  * @return A list of audiooutputport instances
308  */
309  List<AudioOutputPort> Host::getAudioOutputPorts()
310  {
311  List<AudioOutputPort> rPorts;
312 
313  List<AudioOutputPortType> aTypes = AudioOutputPortConfig::getInstance().getSupportedTypes();
314  for (size_t i = 0; i < aTypes.size(); i++) {
315  List<AudioOutputPort> aPorts = aTypes.at(i).getPorts();
316  for (size_t j = 0; j < aPorts.size(); j++) {
317  rPorts.push_back(aPorts.at(j));
318  }
319  }
320  return rPorts;
321  }
322 
323 
324 /**
325  * @fn List<VideoDevice> Host::getVideoDevices()
326  * @brief This API is used to get the list of the video devices (i.e. Decoders) supported on the device.
327  * If no Video Device is available on the device, an empty List will be returned.
328  *
329  * @return A list of videodevice instances
330  */
331  List<VideoDevice> Host::getVideoDevices()
332  {
333  return VideoDeviceConfig::getInstance().getDevices();
334  }
335 
336 
337 /**
338  * @fn VideoOutputPort &Host::getVideoOutputPort(const std::string &name)
339  * @brief This API is used to get the reference to the video output port by its name.
340  * The name of the port must match one of those returned by Host::getVideoOutputPorts.
341  * Application shall not develop code that depends on the actual naming conventions of the video output port.
342  * Such code as Host::getVideoOutputPort("HDMI0") is discouraged as the name of the left-most
343  * HDMI output port may not necessarily be "HDMI0" from all implementations.
344  * IllegalArgumentException will be thrown if the "name" does not match any of the ports.
345  *
346  * @param[in] name Name of the port
347  *
348  * @return Reference to its object
349  */
350  VideoOutputPort &Host::getVideoOutputPort(const std::string &name)
351  {
352  return VideoOutputPortConfig::getInstance().getPort(name);
353  }
354 
355 
356 /**
357  * @fn VideoOutputPort &Host::getVideoOutputPort(int id)
358  * @brief This API is used to get a reference to the video output port by its id.
359  * The name of the port must match one of those returned by Host::getVideoOutputPorts.
360  * Application shall not develop code that depends on the actual naming conventions of the video output port.
361  * Such code as Host::getVideoOutputPort("HDMI0") is discouraged as the name of the left-most
362  * HDMI output port may not necessarily be "HDMI0" from all implementations.
363  * IllegalArgumentException will be thrown if the "name" does not match any of the ports.
364  *
365  * @param[in] id port id
366  *
367  * @return Reference to its object
368  */
369  VideoOutputPort &Host::getVideoOutputPort(int id)
370  {
371  return VideoOutputPortConfig::getInstance().getPort(id);
372  }
373 
374 
375 /**
376  * @fn AudioOutputPort &Host::getAudioOutputPort(const std::string &name)
377  * @brief This API is used to get the reference to the audio output port by its name.
378  * The name of the port must match one of those returned by Host::getAudioOutputPorts.
379  * Application shall not develop code that depends on the actual naming conventions of the Audio output port.
380  * Such code as Host::getAudioOutputPort("SPDIF0") is discouraged as the name of the left-most
381  * SPDIF output port may not necessarily be "SPDIF0" from all implementations.
382  * IllegalArgumentException will be thrown if the "name" does not match any of the ports.
383  *
384  * @param[in] name Name of the port
385  *
386  * @return Reference to its object
387  */
388  AudioOutputPort &Host::getAudioOutputPort(const std::string &name)
389  {
390  return AudioOutputPortConfig::getInstance().getPort(name);
391  }
392 
393 
394 /**
395  * @fn AudioOutputPort &Host::getAudioOutputPort(int id)
396  * @brief This API is used to get a reference to the Audio output port by its id.
397  * The name of the port must match one of those returned by Host::getAudioOutputPorts.
398  * Application shall not develop code that depends on the actual naming conventions of the Audio output port.
399  * Such code as Host::getAudioOutputPort("SPDIF0") is discouraged as the name of the left-most
400  * SPDIF output port may not necessarily be "SPDIF0" from all implementations.
401  * IllegalArgumentException will be thrown if the "name" does not match any of the ports.
402  *
403  * @param[in] id port id
404  *
405  * @return Reference to its object
406  */
407  AudioOutputPort &Host::getAudioOutputPort(int id)
408  {
409  return AudioOutputPortConfig::getInstance().getPort(id);
410  }
411 
412 
413 /**
414  * @fn Host::getPreferredSleepMode()
415  * @brief This API is used to gets the Preferred sleep Mode and implements the low power mode for RDK platform.
416  * dsGetPreferredSleepMode(&mode) function returns preferred sleep mode which is persisted.
417  *
418  * @param None
419  *
420  * @return A list of sleepmode instances
421  */
422  SleepMode Host::getPreferredSleepMode()
423  {
425  dsError_t ret = dsGetPreferredSleepMode(&mode);
426  if (ret == dsERR_NONE) {
427  return SleepMode::getInstance(mode);
428  }
429  else {
430  printf("Host::getPreferredSleepMode failed IPC, returning default LIGHT_SLEEP\r\n");
431  return SleepMode::getInstance(dsHOST_SLEEP_MODE_LIGHT);
432  }
433  }
434 
435 
436 /**
437  * @fn Host::setPreferredSleepMode(const SleepMode mode)
438  * @brief This API is used to set the Preferred sleep Mode and implements the low power mode for RDK platform.
439  *
440  * @param[in] mode sleep mode that is expected to be persisted
441  *
442  * @return ID value of the sleepmode instance
443  */
444  int Host::setPreferredSleepMode(const SleepMode mode)
445  {
446  return dsSetPreferredSleepMode((dsSleepMode_t)mode.getId());
447  }
448 
449 
450 /**
451  * @fn List<SleepMode> Host::getAvailableSleepModes()
452  * @brief This function is used to get the available sleep modes.
453  *
454  * @return A list of sleepmode instance
455  */
456  List<SleepMode> Host::getAvailableSleepModes()
457  {
458  SleepMode mode = SleepMode::getInstance(1);
459  return mode.getSleepModes();
460  }
461 
462 
463 /**
464  * @fn Host::getCPUTemperature()
465  * @brief This API gets CPU temperature.
466  *
467  * @return CPU temperature in default float value
468  * @retval temperature Indicates CPU temerature in centigrade.
469  */
470  float Host::getCPUTemperature()
471  {
472  float temperature = 45.0;
473  dsGetCPUTemperature(&temperature);
474  return temperature;
475  }
476 
477  /**
478  * @fn Host::getVersion()
479  * @brief Get DS HAL API Version
480  *
481  * @return Returns 4 byte Versionnumber
482  * @retval In 4 byte VersionNumber, Two Most significant Bytes are Major number
483  * and Two Least Significant Bytes are minor number.
484  */
485  uint32_t Host::getVersion(void)
486  {
487  uint32_t versionNumber;
488  dsGetVersion(&versionNumber);
489  return versionNumber;
490  }
491 
492  /**
493  * @fn Host::SetVersion()
494  * @brief Allows the application to set the runtime version of the dsHAL
495  *
496  * @param[out] New 4 Bytes versionNumber of DS HAL
497  * @return None.
498  */
499  void Host::setVersion(uint32_t versionNumber)
500  {
501  dsSetVersion(versionNumber);
502  }
503 
504 /**
505  * @fn void Host::getHostEDID(std::vector<uint8_t> &edid) const
506  * @brief This function is used to get the EDID information of the host device.
507  *
508  * @param[out] edid EDID info of the device.
509  * @return None.
510  */
511  void Host::getHostEDID(std::vector<uint8_t> &edid) const
512  {
513  printf("Host::getHostEDID \r\n");
514  dsError_t ret = dsERR_NONE;
515  int length = 0;
516  unsigned char edidBytes[EDID_MAX_DATA_SIZE];
517 
518  const char* exceptionstr = "";
519 
520  ret = dsGetHostEDID( edidBytes, &length);
521 
522  printf("Host::getHostEDID has ret %d\r\n", ret);
523  if (ret == dsERR_NONE) {
524  edid.clear();
525  edid.insert(edid.begin(), edidBytes, edidBytes + length);
526  } else {
527  exceptionstr = "getHostEDID failed";
528  }
529 
530  if (ret != dsERR_NONE) {
531  throw Exception(ret, exceptionstr);
532  }
533  }
534 
535 /**
536  * @fn Host::getSocIDFromSDK()
537  * @brief This API to get the SOC ID.
538  * dsGetSocIDFromSDK() function returns the SOC ID in string format.
539  *
540  * @param None
541  *
542  * @return Device ID
543  */
544  std::string Host::getSocIDFromSDK()
545  {
546  char socID[1024];
547  dsGetSocIDFromSDK(socID);
548  return std::string(socID);
549  }
550 
551  /**
552  * Host::getCurrentAudioFormat(dsAudioFormat_t &audioFormat)
553  * @brief
554  *
555  * @param[in/out] Audio format of currently playing content
556  *
557  * @return None
558  */
559  void Host::getCurrentAudioFormat(dsAudioFormat_t &audioFormat)
560  {
561  dsError_t ret = dsERR_NONE;
562  dsAudioFormat_t aFormat;
563 
564  ret = dsGetAudioFormat(NULL, &aFormat);
565 
566  if (ret == dsERR_NONE)
567  {
568  audioFormat = aFormat;
569  }
570  else
571  {
572  throw Exception(ret);
573  }
574  }
575 
576 
577  /**
578  * Host::getSinkDeviceAtmosCapability(dsATMOSCapability_t & atmosCapability)
579  * @brief
580  *
581  * @param[in/out] Sink device ATMOS capability
582  *
583  * @return None
584  */
585  void Host::getSinkDeviceAtmosCapability(dsATMOSCapability_t & atmosCapability)
586  {
587  dsError_t ret = dsERR_NONE;
588  dsATMOSCapability_t capability;
589 
590  //TV panel sink device is panel itsel so audio port is passed as NULL
591  ret = dsGetSinkDeviceAtmosCapability(NULL, &capability);
592 
593  if (ret == dsERR_NONE)
594  {
595  atmosCapability = capability;
596  }
597  else
598  {
599  throw Exception(ret);
600  }
601  }
602 
603  void Host::setAudioAtmosOutputMode(bool enable)
604  {
605  dsError_t ret = dsERR_NONE;
606  //TV panel sink device is panel itsel so audio port is passed as NULL
607  ret = dsSetAudioAtmosOutputMode(NULL,enable);
608  if (ret != dsERR_NONE)
609  {
610  throw Exception(ret);
611  }
612  }
613 
614 
615  /**
616  * @fn Host::setAssociatedAudioMixing(const bool mixing)
617  * @brief This API is used to enable/disable Associated Audio Mixing.
618  *
619  * If return is not equal to dsERR_NONE, it will throw the ret to IllegalArgumentException Handler and
620  * it will pass the message as "No message for this exception" with the value of "dsERR_INVALID_PARAM" from dsError type.
621  *
622  * @param[in] mixing enable/disable Associated Audio Mixing.
623  *
624  * @return None
625  */
626  void Host::setAssociatedAudioMixing(const bool mixing)
627  {
628  dsError_t ret = dsERR_NONE;
629  if ( (ret = dsSetAssociatedAudioMixing(NULL, mixing)) == dsERR_NONE) {
630  }
631  else
632  {
633  throw Exception(ret);
634  }
635  }
636 
637 
638  /**
639  * @fn void Host::getAssociatedAudioMixing(bool *mixing)
640  * @brief This API is used to get status of Associated Audio Mixing
641  *
642  * @return Current status of Associated Audio Mixing
643  */
644  void Host::getAssociatedAudioMixing(bool *mixing)
645  {
646  dsError_t ret = dsERR_NONE;
647  bool _mixing = false;
648 
649  if(mixing == NULL) {
650  ret = dsERR_INVALID_PARAM;
651  throw Exception(ret);
652  }
653 
654  if ( (ret = dsGetAssociatedAudioMixing(NULL, &_mixing)) == dsERR_NONE)
655  {
656  *mixing = _mixing;
657  }
658  else
659  {
660  throw Exception(ret);
661  }
662  }
663 
664 
665  /**
666  * @fn Host::setFaderControl(const int mixerBalance)
667  * @brief This API is used to set the mixerbalance betweeen main and associated audio
668  *
669  * If return is not equal to dsERR_NONE, it will throw the ret to IllegalArgumentException Handler and
670  * it will pass the message as "No message for this exception" with the value of "dsERR_INVALID_PARAM" from dsError type.
671  *
672  * @param[in] New mixerbalance betweeen main and associated audio.
673  *
674  * @return None
675  */
676  void Host::setFaderControl(const int mixerBalance)
677  {
678  dsError_t ret = dsERR_NONE;
679  ret = dsSetFaderControl(NULL, mixerBalance);
680  if (ret != dsERR_NONE) {
681  throw Exception(ret);
682  }
683  }
684 
685 
686  /**
687  * @fn void Host::getFaderControl(int *mixerBalance)
688  * @brief This API is used to get the mixerbalance betweeen main and associated audio
689  *
690  * @return Current mixerbalance betweeen main and associated audio
691  */
692  void Host::getFaderControl(int *mixerBalance)
693  {
694  dsError_t ret = dsERR_NONE;
695  int _mixerBalance = 0;
696 
697  if(mixerBalance == NULL) {
698  ret = dsERR_INVALID_PARAM;
699  throw Exception(ret);
700  }
701 
702  ret = dsGetFaderControl(NULL, &_mixerBalance);
703  if (ret == dsERR_NONE)
704  {
705  *mixerBalance = _mixerBalance;
706  }
707  else
708  {
709  throw Exception(ret);
710  }
711  }
712 
713 
714  /**
715  * @fn Host::setPrimaryLanguage(const std::string pLang)
716  * @brief This API is used to set Primary language
717  *
718  * If return is not equal to dsERR_NONE, it will throw the ret to IllegalArgumentException Handler and
719  * it will pass the message as "No message for this exception" with the value of "dsERR_INVALID_PARAM" from dsError type.
720  *
721  * @param[string] Primary language to be set
722  *
723  * @return None
724  */
725  void Host::setPrimaryLanguage(const std::string pLang)
726  {
727  dsError_t ret = dsERR_NONE;
728  if ( (ret = dsSetPrimaryLanguage(NULL, pLang.c_str())) == dsERR_NONE) {
729  }
730  else
731  {
732  throw Exception(ret);
733  }
734  }
735 
736 
737  /**
738  * @fn void Host::getPrimaryLanguage(std::string pLang)
739  * @brief This API is used to get the current Primary language
740  *
741  * If return is not equal to dsERR_NONE, it will throw the ret to IllegalArgumentException Handler and
742  * it will pass the message as "No message for this exception" with the value of "dsERR_INVALID_PARAM" from dsError type.
743  *
744  * @return[string] Primary language
745  */
746  void Host::getPrimaryLanguage(std::string &pLang)
747  {
748  dsError_t ret = dsERR_NONE;
749  char _pLang[MAX_LANGUAGE_LEN] = {0};
750  if ( (ret = dsGetPrimaryLanguage(NULL, _pLang)) == dsERR_NONE)
751  {
752  pLang.assign(_pLang);
753  }
754  else
755  {
756  throw Exception(ret);
757  }
758  }
759 
760 
761  /**
762  * @fn Host::setSecondaryLanguage(const std::string sLang)
763  * @brief This API is used to set Secondary language
764  *
765  * If return is not equal to dsERR_NONE, it will throw the ret to IllegalArgumentException Handler and
766  * it will pass the message as "No message for this exception" with the value of "dsERR_INVALID_PARAM" from dsError type.
767  *
768  * @param[string] Secondary language to be set
769  *
770  * @return None
771  */
772  void Host::setSecondaryLanguage(const std::string sLang)
773  {
774  dsError_t ret = dsERR_NONE;
775  if ( (ret = dsSetSecondaryLanguage(NULL, sLang.c_str())) == dsERR_NONE) {
776  }
777  else
778  {
779  throw Exception(ret);
780  }
781  }
782 
783 
784  /**
785  * @fn void Host::getSecondaryLanguage(std::string &sLang)
786  * @brief This API is used to get the current AC4 Secondary language
787  *
788  * If return is not equal to dsERR_NONE, it will throw the ret to IllegalArgumentException Handler and
789  * it will pass the message as "No message for this exception" with the value of "dsERR_INVALID_PARAM" from dsError type.
790  *
791  * @return[string] AC4 Secondary language
792  */
793  void Host::getSecondaryLanguage(std::string &sLang)
794  {
795  dsError_t ret = dsERR_NONE;
796  char _sLang[MAX_LANGUAGE_LEN] = {0};
797  if ( (ret = dsGetSecondaryLanguage(NULL, _sLang)) == dsERR_NONE)
798  {
799  sLang.assign(_sLang);
800  }
801  else
802  {
803  throw Exception(ret);
804  }
805  }
806 
807  bool Host::isHDMIOutPortPresent()
808  {
809  bool isHDMIOutPort = false;
810 
811  List<AudioOutputPortType> aTypes = AudioOutputPortConfig::getInstance().getSupportedTypes();
812  for (size_t i = 0; i < aTypes.size(); i++) {
813  List<AudioOutputPort> aPorts = aTypes.at(i).getPorts();
814  for (size_t j = 0; j < aPorts.size(); j++) {
815  string portName = aPorts.at(j).getName();
816  if (portName.find("HDMI0") != string::npos) {
817  isHDMIOutPort = true;
818  break;
819  }
820  }
821  if (isHDMIOutPort) {
822  break;
823  }
824  }
825 
826  return isHDMIOutPort;
827  }
828 
829  std::string Host::getDefaultVideoPortName()
830  {
831  std::string strDefaultVideoPortName = "HDMI0";
832  bool isDefaultPortfound = false;
833  List<VideoOutputPortType> vTypes = VideoOutputPortConfig::getInstance().getSupportedTypes();
834  for (size_t i = 0; i < vTypes.size(); i++) {
835  List<VideoOutputPort> vPorts = vTypes.at(i).getPorts();
836  for (size_t j = 0; j < vPorts.size(); j++) {
837  string portName = vPorts.at(j).getName();
838  /*By default assign first port as default port*/
839  if (0==i && 0==j) {
840  strDefaultVideoPortName.assign (portName);
841  }
842  /*If HDMI0 present assign HDMI0 as default video port*/
843  if (portName.find("HDMI0") != string::npos) {
844  strDefaultVideoPortName.assign (portName);
845  isDefaultPortfound = true;
846  break;
847  }
848  /*If INTERNAL0 present assign INTERNAL0 as default video port*/
849  if (portName.find("INTERNAL0") != string::npos) {
850  strDefaultVideoPortName.assign (portName);
851  isDefaultPortfound = true;
852  break;
853  }
854  }
855  if (isDefaultPortfound) {
856  break;
857  }
858  }
859 
860  return strDefaultVideoPortName;
861  }
862 
863  std::string Host::getDefaultAudioPortName()
864  {
865  std::string strDefaultAudioPortName = "HDMI0";
866  bool isDefaultPortfound = false;
867  List<AudioOutputPortType> aTypes = AudioOutputPortConfig::getInstance().getSupportedTypes();
868  for (size_t i = 0; i < aTypes.size(); i++) {
869  List<AudioOutputPort> aPorts = aTypes.at(i).getPorts();
870  for (size_t j = 0; j < aPorts.size(); j++) {
871  string portName = aPorts.at(j).getName();
872  /*By default assign first port as default port*/
873  if (0==i && 0==j) {
874  strDefaultAudioPortName.assign (portName);
875  }
876  /*If HDMI0/SPEAKER0 present assign it as default video port*/
877  if (portName.find("HDMI0") != string::npos || portName.find("SPEAKER0") != string::npos) {
878  strDefaultAudioPortName.assign (portName);
879  isDefaultPortfound = true;
880  break;
881  }
882  }
883  if (isDefaultPortfound) {
884  break;
885  }
886  }
887 
888  return strDefaultAudioPortName;
889  }
890 
891 }
892 
893 
894 /** @} */
895 
896 /** @} */
897 /** @} */
dsPOWER_OFF
@ dsPOWER_OFF
Definition: dsTypes.h:929
dsGetVersion
dsError_t dsGetVersion(uint32_t *versionNumber)
Get DS HAL API Version.
Definition: dsHost.cpp:114
dsSetAssociatedAudioMixing
dsError_t dsSetAssociatedAudioMixing(intptr_t handle, bool mixing)
Enable/Disable Associated Audio Mixing.
Definition: dsAudio.c:1248
dsGetCPUTemperature
dsError_t dsGetCPUTemperature(float *cpuTemperature)
This function gets the CPU temperature in centrigade.
Definition: dsHost.cpp:88
device::List
This class is implemented using templates and it is used to maintain a container with the list of sup...
Definition: list.hpp:51
dsSleepMode_t
enum _dsSleepMode_t dsSleepMode_t
device::VideoOutputPort
Class extending enumerable to implement the videoooutputport interface.
Definition: videoOutputPort.hpp:59
dsTypes.h
Device Settings HAL types.
dsPOWER_STANDBY
@ dsPOWER_STANDBY
Definition: dsTypes.h:928
dsVideoPort.h
dsGetPrimaryLanguage
dsError_t dsGetPrimaryLanguage(intptr_t handle, char *pLang)
To get AC4 Primary language.
Definition: dsAudio.c:1371
device::List::size
size_t size()
This function gets the size of the container.
Definition: list.hpp:118
device::AudioOutputPort
Class extending Enumerable to implement the audiooutputport interface.
Definition: audioOutputPort.hpp:60
dsGetFaderControl
dsError_t dsGetFaderControl(intptr_t handle, int *mixerbalance)
To get the mixerbalance betweeen main and associated audio.
Definition: dsAudio.c:1314
dsERR_NONE
@ dsERR_NONE
Definition: dsError.h:85
dsGetAudioFormat
dsError_t dsGetAudioFormat(intptr_t handle, dsAudioFormat_t *audioFormat)
Get the current audio format.
Definition: dsAudio.c:121
dsVideoDevice.h
dsSetVersion
dsError_t dsSetVersion(uint32_t versionNumber)
Allows the application to set the runtime version of the dsHAL.
Definition: dsHost.cpp:139
dsSetPrimaryLanguage
dsError_t dsSetPrimaryLanguage(intptr_t handle, const char *pLang)
To set AC4 Primary language.
Definition: dsAudio.c:1342
device::PowerModeChangeListener
Definition: powerModeChangeListener.hpp:36
dsGetSecondaryLanguage
dsError_t dsGetSecondaryLanguage(intptr_t handle, char *sLang)
To get AC4 Secondary language.
Definition: dsAudio.c:1428
dsDisplay.h
device::DisplayConnectionChangeListener
Definition: displayConnectionChangeListener.hpp:38
device::SleepMode
This class extends DSConstant to implement SleepMode. It is used to manage the sleep modes for device...
Definition: sleepMode.hpp:51
dsGetSinkDeviceAtmosCapability
dsError_t dsGetSinkDeviceAtmosCapability(intptr_t handle, dsATMOSCapability_t *capability)
Get the sink device ATMOS capability.
Definition: dsAudio.c:1640
device::UnsupportedOperationException
This class extends Exception class to manage unsupported operations in devicesettings.
Definition: unsupportedOperationException.hpp:50
dsGetAssociatedAudioMixing
dsError_t dsGetAssociatedAudioMixing(intptr_t handle, bool *mixing)
To get the Associated Audio Mixing status - enabled/disabled.
Definition: dsAudio.c:1267
device::Exception
This class handles exceptions occurring in DS module.
Definition: exception.hpp:52
dsSetAudioAtmosOutputMode
dsError_t dsSetAudioAtmosOutputMode(intptr_t handle, bool enable)
Set the audio ATMOS outout mode.
Definition: dsAudio.c:1619
dsAudio.h
dsSetSecondaryLanguage
dsError_t dsSetSecondaryLanguage(intptr_t handle, const char *sLang)
To set AC4 Secondary language.
Definition: dsAudio.c:1399
device::Host
Class to implement the Host interface.
Definition: host.hpp:60
dsHOST_SLEEP_MODE_LIGHT
@ dsHOST_SLEEP_MODE_LIGHT
Definition: dsTypes.h:921
device::List::push_back
void push_back(const T &x)
This is a template function used to push/store the ID of an instance x into the container.
Definition: list.hpp:108
dsGetPreferredSleepMode
dsError_t dsGetPreferredSleepMode(dsSleepMode_t *pMode)
This function returns the preferred sleep mode which is persisted.
Definition: dsHost.cpp:63
dsSetPreferredSleepMode
dsError_t dsSetPreferredSleepMode(dsSleepMode_t mode)
This function sets the preferred sleep mode which needs to be persisted.
Definition: dsHost.cpp:43
dsAudioFormat_t
enum _dsAudioFormat_t dsAudioFormat_t
dsGetSocIDFromSDK
dsError_t dsGetSocIDFromSDK(char *socID)
This function returns SOC ID.
Definition: dsHost.cpp:162
dsERR_INVALID_PARAM
@ dsERR_INVALID_PARAM
Definition: dsError.h:87
unsupportedOperationException.hpp
This file defines UnsupportedOperationException class.
dsError_t
dsError_t
Device Settings API Error return codes.
Definition: dsError.h:84
dsPOWER_ON
@ dsPOWER_ON
Definition: dsTypes.h:927
dsGetHostEDID
dsError_t dsGetHostEDID(unsigned char *edid, int *length)
This function is used to get the host EDID and length.
Definition: dsHost.cpp:191
dsSetFaderControl
dsError_t dsSetFaderControl(intptr_t handle, int mixerbalance)
To set the mixerbalance betweeen main and associated audio.
Definition: dsAudio.c:1294