31 #include "videoOutputPortConfig.hpp"
32 #include "audioOutputPortConfig.hpp"
33 #include "illegalArgumentException.hpp"
34 #include "dsVideoPortSettings.h"
35 #include "dsVideoResolutionSettings.h"
40 #include "illegalArgumentException.hpp"
55 static VideoResolution* defaultVideoResolution;
56 static std::mutex gSupportedResolutionsMutex;
57 VideoOutputPortConfig::VideoOutputPortConfig() {
59 defaultVideoResolution =
new VideoResolution(
70 VideoOutputPortConfig::~VideoOutputPortConfig() {
72 delete defaultVideoResolution;
75 VideoOutputPortConfig & VideoOutputPortConfig::getInstance() {
76 static VideoOutputPortConfig _singleton;
80 const PixelResolution &VideoOutputPortConfig::getPixelResolution(
int id)
const
82 return _vPixelResolutions.at(
id);
85 const AspectRatio &VideoOutputPortConfig::getAspectRatio(
int id)
const
87 return _vAspectRatios.at(
id);
90 const StereoScopicMode &VideoOutputPortConfig::getSSMode(
int id)
const
92 return _vStereoScopieModes.at(
id);
95 const VideoResolution &VideoOutputPortConfig::getVideoResolution (
int id)
const
97 {std::lock_guard<std::mutex> lock(gSupportedResolutionsMutex);
98 if (
id < _supportedResolutions.size()){
99 return _supportedResolutions.at(
id);
102 cout<<
"returns default resolution 720p"<<endl;
104 return *defaultVideoResolution;
109 const FrameRate &VideoOutputPortConfig::getFrameRate(
int id)
const
111 return _vFrameRates.at(
id);
114 VideoOutputPortType &VideoOutputPortConfig::getPortType(
int id)
116 return _vPortTypes.at(
id);
119 VideoOutputPort &VideoOutputPortConfig::getPort(
int id)
121 return _vPorts.at(
id);
124 VideoOutputPort &VideoOutputPortConfig::getPort(
const std::string & name)
126 for (
size_t i = 0; i < _vPorts.size(); i++) {
127 if (name.compare(_vPorts.at(i).getName()) == 0) {
128 return _vPorts.at(i);
132 throw IllegalArgumentException();
135 List<VideoOutputPort> VideoOutputPortConfig::getPorts()
137 List <VideoOutputPort> rPorts;
139 for (
size_t i = 0; i < _vPorts.size(); i++) {
140 rPorts.push_back(_vPorts.at(i));
146 List<VideoOutputPortType> VideoOutputPortConfig::getSupportedTypes()
148 List<VideoOutputPortType> supportedTypes;
149 for (std::vector<VideoOutputPortType>::const_iterator it = _vPortTypes.begin(); it != _vPortTypes.end(); it++) {
150 if (it->isEnabled()) {
151 supportedTypes.push_back(*it);
155 return supportedTypes;
158 List<VideoResolution> VideoOutputPortConfig::getSupportedResolutions(
bool isIgnoreEdid)
160 List<VideoResolution> supportedResolutions;
161 std::vector<VideoResolution> tmpsupportedResolutions;
162 int isDynamicList = 0;
164 intptr_t _handle = 0;
165 bool force_disable_4K =
true;
167 printf (
"\nResOverride VideoOutputPortConfig::getSupportedResolutions isIgnoreEdid:%d\n", isIgnoreEdid);
177 memset(&edid, 0,
sizeof(edid));
184 cout <<
" dsGetEDID failed so setting edid.numOfSupportedResolution to 0"<< endl;
194 tmpsupportedResolutions.push_back(
197 std::string(resolution->
name),
208 cout <<
"VideoOutputPortConfig::getSupportedResolutions Thrown. Exception..."<<endl;
212 if (0 == isDynamicList )
214 size_t numResolutions =
dsUTL_DIM(kResolutions);
215 for (
size_t i = 0; i < numResolutions; i++)
218 tmpsupportedResolutions.push_back(
221 std::string(resolution->
name),
231 dsGetForceDisable4KSupport(_handle, &force_disable_4K);
235 cout<<
"Failed to get status of forceDisable4K!"<<endl;
237 for (std::vector<VideoResolution>::iterator it = tmpsupportedResolutions.begin(); it != tmpsupportedResolutions.end(); it++) {
238 if (it->isEnabled()) {
239 if((
true == force_disable_4K) && (((it->getName() ==
"2160p60") || (it->getName() ==
"2160p30"))))
243 supportedResolutions.push_back(*it);
247 for (std::vector<VideoResolution>::iterator it = tmpsupportedResolutions.begin(); it != tmpsupportedResolutions.end(); it++) {
248 supportedResolutions.push_back(*it);
251 {std::lock_guard<std::mutex> lock(gSupportedResolutionsMutex);
252 cout<<
"_supportedResolutions cache updated"<<endl;
253 _supportedResolutions.clear ();
254 for (VideoResolution resolution : tmpsupportedResolutions){
255 _supportedResolutions.push_back(resolution);
258 return supportedResolutions;
263 void VideoOutputPortConfig::load()
270 _vPixelResolutions.push_back(PixelResolution(i));
273 _vAspectRatios.push_back(AspectRatio(i));
276 _vStereoScopieModes.push_back(StereoScopicMode(i));
279 _vFrameRates.push_back(FrameRate((
int)i));
283 _vPortTypes.push_back(VideoOutputPortType((
int)i));
289 size_t numResolutions =
dsUTL_DIM(kResolutions);
290 for (
size_t i = 0; i < numResolutions; i++) {
292 {std::lock_guard<std::mutex> lock(gSupportedResolutionsMutex);
293 _supportedResolutions.push_back(
296 std::string(resolution->
name),
310 for (
size_t i = 0; i <
dsUTL_DIM(kConfigs); i++)
313 VideoOutputPortType &vPortType = VideoOutputPortType::getInstance(typeCfg->
typeId);
321 for (
size_t i = 0; i <
dsUTL_DIM(kPorts); i++) {
326 AudioOutputPortType::getInstance(kPorts[i].connectedAOP.type).getPort(kPorts[i].connectedAOP.index).getId(),
329 _vPortTypes.at(port->
id.
type).addPort(_vPorts.at(i));
335 cout <<
"VIdeo Outport Exception Thrown. ..."<<endl;
340 void VideoOutputPortConfig::release()
343 _vPixelResolutions.clear();
344 _vAspectRatios.clear();
345 _vStereoScopieModes.clear();
346 _vFrameRates.clear();
348 {std::lock_guard<std::mutex> lock(gSupportedResolutionsMutex);
349 _supportedResolutions.clear();