RDK Documentation (Open Sourced RDK Components)
testSetAudioConfig.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 SetAudioConfig
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 #include "audioEncoding.hpp"
46 #include "audioCompression.hpp"
47 #include "audioStereoMode.hpp"
48 
49 
50 #include "dsUtl.h"
51 #include "dsError.h"
52 #include "dsVideoPort.h"
53 
54 #undef _DS_VIDEOOUTPUTPORTSETTINGS_H
55 #include "dsVideoPortSettings.h"
56 #undef _DS_VIDEORESOLUTIONSETTINGS_H
57 #include "dsVideoResolutionSettings.h"
58 
59 BOOST_AUTO_TEST_CASE(test_AudioOutputPort_set_Methods)
60 {
61  /*
62  * The following code demonstrate how to get the complete audio configuration information for SM.
63  * All audio ports connected to existing Video Ports are traversed.
64  *
65  * Please note current SM only requires information for HDMI port, alghough such requirment is not
66  * indicated in SM's request message.
67  *
68  * Basic relationship:
69  * A host has a list of VideoOutputPorts.
70  * A VideoOutPort has a AudioOutputPort.
71  * A AudioOutPort has
72  * 1) a set of properties (db, mute, level etc) and
73  * 2) A list of supported AudioEncodings.
74  * 3) A list of supported AudioCompressions.
75  * 4) A list of supported AUdioStereoModes.
76  *
77  * Input From SM:
78  * 1) A Video Port Name (such as "HDMI0", "Component0" etc..) whose connected Audio Port is the target port.
79  * 2) A Property of the target port to set.
80  * 3) SM is responsible to convert the proerty value from string to corresponding types.
81  *
82  * Output to SM: Void (or exception thrown upon error).
83  */
84  try {
85  /* convert the video port Name to the corresponding port object */
87  device::Host::getInstance().getVideoOutputPort(std::string("HDMI0"));
89  if (true) { /* These are dummy values */
90  /* You can set the following 3 values using integer constants or use string names*/
94  aPort.setEncoding(std::string("AC3"));
95  aPort.setCompression(std::string("MEDIUM"));
96  aPort.setStereoMode(std::string("SURROUND"));
97 
98  aPort.setDB(1.0);
99  aPort.setLevel(2.0);
100  aPort.setLoopThru(false);
101  aPort.setMuted(false);
102  }
103  }
104  catch(...) {
105  BOOST_CHECK(0);
106  }
107 }
108 
109 BOOST_AUTO_TEST_CASE(SetAudioConfig_InvalidNames)
110 {
111  /*
112  * Output to SM: Void (or exception thrown upon error).
113  */
114  try {
115  /* convert the video port Name to the corresponding port object */
117  device::Host::getInstance().getVideoOutputPort(std::string("BadPort"));
118  BOOST_CHECK(0);
119  }
120  catch(...) {
121  BOOST_CHECK(1);
122  }
123 
124  try {
125  /* convert the video port Name to the corresponding port object */
127  device::Host::getInstance().getVideoOutputPort(std::string("HDMI0"));
129  aPort.setEncoding(device::AudioEncoding::getInstance("BadName").getId());
130  BOOST_CHECK(0);
131  }
132  catch(...) {
133  BOOST_CHECK(1);
134  }
135 
136  try {
137  /* convert the video port Name to the corresponding port object */
139  device::Host::getInstance().getVideoOutputPort(std::string("HDMI0"));
141  aPort.setCompression(device::AudioCompression::getInstance("BadName").getId());
142  BOOST_CHECK(0);
143  }
144  catch(...) {
145  BOOST_CHECK(1);
146  }
147 
148  try {
149  /* convert the video port Name to the corresponding port object */
151  device::Host::getInstance().getVideoOutputPort(std::string("HDMI0"));
153  aPort.setStereoMode(device::AudioStereoMode::getInstance("BadName").getId());
154  BOOST_CHECK(0);
155  }
156  catch(...) {
157  BOOST_CHECK(1);
158  }
159 
160 
161 }
162 BOOST_AUTO_TEST_CASE(testDummy)
163 {
164  BOOST_CHECK(1 == 1);
165 }
166 
167 
168 /** @} */
169 /** @} */
device::AudioEncoding::getInstance
static const AudioEncoding & getInstance(int id)
This function gets an AudioEncoding instance against the id parameter, only if the id passed is valid...
Definition: audioEncoding.cpp:82
device::VideoOutputPort
Class extending enumerable to implement the videoooutputport interface.
Definition: videoOutputPort.hpp:59
device::AudioStereoMode::kSurround
static const int kSurround
Indicates audio mode of type surround.
Definition: audioStereoMode.hpp:57
dsVideoPort.h
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
dsError.h
Device Settings HAL error codes.
device::AudioCompression::getInstance
static const AudioCompression & getInstance(int id)
This function gets an instance of AudioCompression against the specified id, only if the id passed is...
Definition: audioCompression.cpp:79
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::AudioStereoMode::getInstance
static const AudioStereoMode & getInstance(int id)
This function gets an instance of AudioStereoMode against the specified id, only if the id passed is ...
Definition: audioStereoMode.cpp:84
videoResolution.hpp
It contains class and structure refrenced by the videoResolution.cpp file.
device::AudioCompression::kMedium
static const int kMedium
Indicates medium audio compression.
Definition: audioCompression.hpp:54
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
device::AudioEncoding::kAC3
static const int kAC3
Value indicating AC3 digital audio encoding format.
Definition: audioEncoding.hpp:57
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::Host::getVideoOutputPort
VideoOutputPort & getVideoOutputPort(const std::string &name)
This API is used to get the reference to the video output port by its name. The name of the port must...
Definition: host.cpp:350
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
audioOutputPortType.hpp
It contain variables,stuctures,class and functions referenced by audiooutputportType code.
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
audioOutputPort.hpp
It contain variables,stuctures,class and functions referenced by audiooutputport code.
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::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
audioCompression.hpp
This file defines AudioCompression class for managing audio compression levels.
audioEncoding.hpp
This file defines AudioEncoding class for managing audio encoding types.