RDK Documentation (Open Sourced RDK Components)
testGetAudioConfig.cpp
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 // TODO: Include your class to test here.
21 
22 
23 /**
24 * @defgroup devicesettings
25 * @{
26 * @defgroup test
27 * @{
28 **/
29 
30 
31 #define BOOST_TEST_MODULE GetAudioConfig
32 #define BOOST_TEST_MAIN
33 #include "boost/test/included/unit_test.hpp"
34 #include <iostream>
35 
36 #include "videoOutputPort.hpp"
37 #include "host.hpp"
38 #include "videoOutputPortConfig.hpp"
39 #include "videoResolution.hpp"
40 #include "audioOutputPort.hpp"
41 #include "audioEncoding.hpp"
42 #include "audioCompression.hpp"
43 #include "audioStereoMode.hpp"
44 #include "audioOutputPortType.hpp"
45 
46 
47 #include "dsUtl.h"
48 #include "dsError.h"
49 #include "dsVideoPort.h"
50 #include "list.hpp"
51 
52 #undef _DS_VIDEOOUTPUTPORTSETTINGS_H
53 #include "dsVideoPortSettings.h"
54 #undef _DS_VIDEORESOLUTIONSETTINGS_H
55 #include "dsVideoResolutionSettings.h"
56 
57 BOOST_AUTO_TEST_CASE(test_AudioOutputPort_get_Methods)
58 {
59  /*
60  * The following code demonstrate how to get the complete audio configuration information for SM.
61  * All audio ports connected to existing Video Ports are traversed.
62  *
63  * Please note current SM only requires information for HDMI port, alghough such requirment is not
64  * indicated in SM's request message.
65  *
66  * Basic relationship:
67  * A host has a list of VideoOutputPorts.
68  * A VideoOutPort has a AudioOutputPort.
69  * A AudioOutPort has
70  * 1) a set of properties (db, mute, level etc) and
71  * 2) A list of supported AudioEncodings.
72  * 3) A list of supported AudioCompressions.
73  * 4) A list of supported AUdioStereoModes.
74  *
75  * Input From SM: None.
76  * Output to SM: Audio Port configurations for all audio port instances.
77  */
78  try {
80  BOOST_CHECK(vPorts.size() != 0);
81  for (int i = 0; i < vPorts.size(); i++) {
82  device::AudioOutputPort &aPort = vPorts.at(i).getAudioOutputPort();
83 
84  aPort.getCompression();
85  aPort.getEncoding();
86  aPort.getStereoMode();
87  aPort.getGain();
88  aPort.getDB();
89  aPort.getMaxDB();
90  aPort.getMinDB();
91  aPort.getOptimalLevel();
92  aPort.isLoopThru();
93  aPort.isMuted();
94 
95  {
97  BOOST_CHECK(aCompressions.size() != 0);
98  for (size_t j = 0; j < aCompressions.size(); j++) {
99  std::cout << "Compressions supported = " << aCompressions.at(j).toString() << " FOR " << aPort.getType().getName() << std::endl;
100  }
101  }
102 
103  {
105  BOOST_CHECK(aEncodings.size() != 0);
106  for (size_t j = 0; j < aEncodings.size(); j++) {
107  std::cout << "Encodings supported = " << aEncodings.at(j).toString() << " FOR " << aPort.getType().getName() << std::endl;
108  }
109  }
110 
111  {
112  const device::List<device::AudioStereoMode> & aStereoModes = aPort.getSupportedStereoModes();
113  BOOST_CHECK(aStereoModes.size() != 0);
114  for (size_t j = 0; j < aStereoModes.size(); j++) {
115  std::cout << "fSTereoModes supported = " << aStereoModes.at(j).toString() << " FOR " << aPort.getType().getName() << std::endl;
116  }
117  }
118 
119  }
120  }
121  catch(...) {
122  BOOST_CHECK(0);
123  }
124 }
125 
126 BOOST_AUTO_TEST_CASE(testDummy)
127 {
128  BOOST_CHECK(1 == 1);
129 }
130 
131 
132 /** @} */
133 /** @} */
device::AudioOutputPort::getDB
float getDB() const
This API will get the current Decibel value for the given Audio port.
Definition: audioOutputPort.cpp:408
device::AudioOutputPort::getSupportedStereoModes
const List< AudioStereoMode > getSupportedStereoModes() const
Definition: audioOutputPort.cpp:248
device::AudioOutputPort::getSupportedCompressions
const List< AudioCompression > getSupportedCompressions() const
This API is used to get the list of audio compressions supported by the port.
Definition: audioOutputPort.cpp:236
device::AudioOutputPort::getGain
float getGain() const
This API will get the current Gain for the given audio output port.
Definition: audioOutputPort.cpp:386
device::AudioOutputPort::getEncoding
const AudioEncoding & getEncoding() const
This API is used to get the current encoding of the output port.
Definition: audioOutputPort.cpp:260
device::Host::getVideoOutputPorts
List< VideoOutputPort > getVideoOutputPorts()
This API is used to get the list of the video output ports supported on the device....
Definition: host.cpp:285
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::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
dsVideoPort.h
dsError.h
Device Settings HAL error codes.
device::AudioOutputPort::getType
const AudioOutputPortType & getType() const
This API is used to get the type of the audio output port. The type of audio output port represent th...
Definition: audioOutputPort.cpp:212
device::List::size
size_t size()
This function gets the size of the container.
Definition: list.hpp:118
dsUtl.h
Device Settings HAL utilities.
device::AudioOutputPort
Class extending Enumerable to implement the audiooutputport interface.
Definition: audioOutputPort.hpp:60
audioStereoMode.hpp
This file defines AudioStereoMode class for managing audio mode types.
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
videoResolution.hpp
It contains class and structure refrenced by the videoResolution.cpp file.
device::AudioOutputPort::isMuted
bool isMuted() const
This API is used to check whether the audio is muted or not.
Definition: audioOutputPort.cpp:530
device::DSConstant::getName
virtual const std::string & getName() const
This function is used to the get the data member name.
Definition: dsConstant.hpp:141
videoOutputPort.hpp
It contains class and structure refrenced by the videooutputport.cpp file.
device::VideoOutputPort::getAudioOutputPort
AudioOutputPort & getAudioOutputPort()
This API is used to get the audio output port connected to the video output port. This connection is ...
Definition: videoOutputPort.cpp:280
device::DSConstant::toString
virtual const std::string & toString() const
This function is used to the get the data member name in string format.
Definition: dsConstant.hpp:152
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::AudioOutputPort::getSupportedEncodings
const List< AudioEncoding > getSupportedEncodings() const
This API is used to get the list of audio encodings supported by the port.
Definition: audioOutputPort.cpp:224
device::List< device::VideoOutputPort >
audioOutputPortType.hpp
It contain variables,stuctures,class and functions referenced by audiooutputportType code.
audioOutputPort.hpp
It contain variables,stuctures,class and functions referenced by audiooutputport code.
device::AudioOutputPort::getCompression
int getCompression() const
This API is used to get the current compression of the output port.
Definition: audioOutputPort.cpp:871
audioCompression.hpp
This file defines AudioCompression class for managing audio compression levels.
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
audioEncoding.hpp
This file defines AudioEncoding class for managing audio encoding types.