@@ -175,12 +175,12 @@ namespace Plugin {
175
175
int hdmiin_hotplug_port = eventData->data .hdmi_in_connect .port ;
176
176
int hdmiin_hotplug_conn = eventData->data .hdmi_in_connect .isPortConnected ;
177
177
LOGWARN (" Received IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG event data:%d" , hdmiin_hotplug_port);
178
- AVInputImplementation::_instance->AVInputHotplug (hdmiin_hotplug_port, hdmiin_hotplug_conn ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, HDMI );
178
+ AVInputImplementation::_instance->AVInputHotplug (hdmiin_hotplug_port, hdmiin_hotplug_conn ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, INPUT_TYPE_INT_HDMI );
179
179
} else if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG == eventId) {
180
180
int compositein_hotplug_port = eventData->data .composite_in_connect .port ;
181
181
int compositein_hotplug_conn = eventData->data .composite_in_connect .isPortConnected ;
182
182
LOGWARN (" Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG event data:%d" , compositein_hotplug_port);
183
- AVInputImplementation::_instance->AVInputHotplug (compositein_hotplug_port, compositein_hotplug_conn ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, COMPOSITE );
183
+ AVInputImplementation::_instance->AVInputHotplug (compositein_hotplug_port, compositein_hotplug_conn ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, INPUT_TYPE_INT_COMPOSITE );
184
184
}
185
185
}
186
186
@@ -193,12 +193,12 @@ namespace Plugin {
193
193
int hdmi_in_port = eventData->data .hdmi_in_sig_status .port ;
194
194
int hdmi_in_signal_status = eventData->data .hdmi_in_sig_status .status ;
195
195
LOGWARN (" Received IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS event port: %d, signal status: %d" , hdmi_in_port, hdmi_in_signal_status);
196
- AVInputImplementation::_instance->AVInputSignalChange (hdmi_in_port, hdmi_in_signal_status, HDMI );
196
+ AVInputImplementation::_instance->AVInputSignalChange (hdmi_in_port, hdmi_in_signal_status, INPUT_TYPE_INT_HDMI );
197
197
} else if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS == eventId) {
198
198
int composite_in_port = eventData->data .composite_in_sig_status .port ;
199
199
int composite_in_signal_status = eventData->data .composite_in_sig_status .status ;
200
200
LOGWARN (" Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS event port: %d, signal status: %d" , composite_in_port, composite_in_signal_status);
201
- AVInputImplementation::_instance->AVInputSignalChange (composite_in_port, composite_in_signal_status, COMPOSITE );
201
+ AVInputImplementation::_instance->AVInputSignalChange (composite_in_port, composite_in_signal_status, INPUT_TYPE_INT_COMPOSITE );
202
202
}
203
203
}
204
204
@@ -211,12 +211,12 @@ namespace Plugin {
211
211
int hdmi_in_port = eventData->data .hdmi_in_status .port ;
212
212
bool hdmi_in_status = eventData->data .hdmi_in_status .isPresented ;
213
213
LOGWARN (" Received IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS event port: %d, started: %d" , hdmi_in_port, hdmi_in_status);
214
- AVInputImplementation::_instance->AVInputStatusChange (hdmi_in_port, hdmi_in_status, HDMI );
214
+ AVInputImplementation::_instance->AVInputStatusChange (hdmi_in_port, hdmi_in_status, INPUT_TYPE_INT_HDMI );
215
215
} else if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS == eventId) {
216
216
int composite_in_port = eventData->data .composite_in_status .port ;
217
217
bool composite_in_status = eventData->data .composite_in_status .isPresented ;
218
218
LOGWARN (" Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS event port: %d, started: %d" , composite_in_port, composite_in_status);
219
- AVInputImplementation::_instance->AVInputStatusChange (composite_in_port, composite_in_status, COMPOSITE );
219
+ AVInputImplementation::_instance->AVInputStatusChange (composite_in_port, composite_in_status, INPUT_TYPE_INT_COMPOSITE );
220
220
}
221
221
}
222
222
@@ -233,7 +233,7 @@ namespace Plugin {
233
233
resolution.interlaced = eventData->data .hdmi_in_video_mode .resolution .interlaced ;
234
234
resolution.frameRate = eventData->data .hdmi_in_video_mode .resolution .frameRate ;
235
235
LOGWARN (" Received IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE event port: %d, pixelResolution: %d, interlaced : %d, frameRate: %d \n " , hdmi_in_port, resolution.pixelResolution , resolution.interlaced , resolution.frameRate );
236
- AVInputImplementation::_instance->AVInputVideoModeUpdate (hdmi_in_port, resolution, HDMI );
236
+ AVInputImplementation::_instance->AVInputVideoModeUpdate (hdmi_in_port, resolution, INPUT_TYPE_INT_HDMI );
237
237
} else if (IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE == eventId) {
238
238
IARM_Bus_DSMgr_EventData_t* eventData = (IARM_Bus_DSMgr_EventData_t*)data;
239
239
int composite_in_port = eventData->data .composite_in_video_mode .port ;
@@ -242,7 +242,7 @@ namespace Plugin {
242
242
resolution.interlaced = eventData->data .composite_in_video_mode .resolution .interlaced ;
243
243
resolution.frameRate = eventData->data .composite_in_video_mode .resolution .frameRate ;
244
244
LOGWARN (" Received IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_VIDEO_MODE_UPDATE event port: %d, pixelResolution: %d, interlaced : %d, frameRate: %d \n " , composite_in_port, resolution.pixelResolution , resolution.interlaced , resolution.frameRate );
245
- AVInputImplementation::_instance->AVInputVideoModeUpdate (composite_in_port, resolution, COMPOSITE );
245
+ AVInputImplementation::_instance->AVInputVideoModeUpdate (composite_in_port, resolution, INPUT_TYPE_INT_COMPOSITE );
246
246
}
247
247
}
248
248
@@ -567,17 +567,21 @@ namespace Plugin {
567
567
}
568
568
569
569
try {
570
- if (strcmp (typeOfInput.c_str (), INPUT_TYPE_HDMI) == 0 ) {
571
- device::HdmiInput::getInstance ().selectPort (id, requestAudioMix, plane, topMost);
572
- } else if (strcmp (typeOfInput.c_str (), INPUT_TYPE_COMPOSITE) == 0 ) {
573
- device::CompositeInput::getInstance ().selectPort (id);
574
- } else {
575
- LOGWARN (" Invalid input type passed to StartInput" );
576
- successResult.success = false ;
577
- return Core::ERROR_GENERAL;
570
+ switch (AVInputUtils::getTypeOfInput (typeOfInput)) {
571
+ case INPUT_TYPE_INT_HDMI: {
572
+ device::HdmiInput::getInstance ().selectPort (id, requestAudioMix, plane, topMost);
573
+ break ;
574
+ }
575
+ case INPUT_TYPE_INT_COMPOSITE: {
576
+ device::CompositeInput::getInstance ().selectPort (id);
577
+ }
578
+ default : {
579
+ LOGWARN (" Invalid input type passed to StartInput" );
580
+ successResult.success = false ;
581
+ return Core::ERROR_GENERAL;
582
+ }
578
583
}
579
- } catch (const device::Exception& err) {
580
- LOG_DEVICE_EXCEPTION1 (std::to_string (id));
584
+ } catch (...) {
581
585
successResult.success = false ;
582
586
return Core::ERROR_GENERAL;
583
587
}
@@ -598,14 +602,20 @@ namespace Plugin {
598
602
device::Host::getInstance ().setAudioMixerLevels (dsAUDIO_INPUT_SYSTEM, DEFAULT_INPUT_VOL_LEVEL);
599
603
isAudioBalanceSet = false ;
600
604
}
601
- if (strcmp (typeOfInput.c_str (), INPUT_TYPE_HDMI) == 0 ) {
602
- device::HdmiInput::getInstance ().selectPort (-1 );
603
- } else if (strcmp (typeOfInput.c_str (), INPUT_TYPE_COMPOSITE) == 0 ) {
604
- device::CompositeInput::getInstance ().selectPort (-1 );
605
- } else {
606
- LOGWARN (" Invalid input type passed to StopInput" );
607
- successResult.success = false ;
608
- ret = Core::ERROR_GENERAL;
605
+
606
+ switch (AVInputUtils::getTypeOfInput (typeOfInput)) {
607
+ case INPUT_TYPE_INT_HDMI: {
608
+ device::HdmiInput::getInstance ().selectPort (-1 );
609
+ break ;
610
+ }
611
+ case INPUT_TYPE_INT_COMPOSITE: {
612
+ device::CompositeInput::getInstance ().selectPort (-1 );
613
+ }
614
+ default : {
615
+ LOGWARN (" Invalid input type passed to StopInput" );
616
+ successResult.success = false ;
617
+ return Core::ERROR_GENERAL;
618
+ }
609
619
}
610
620
} catch (const device::Exception& err) {
611
621
LOGWARN (" AVInputImplementation::StopInput Failed" );
@@ -619,12 +629,20 @@ namespace Plugin {
619
629
Core::hresult AVInputImplementation::SetVideoRectangle (const uint16_t x, const uint16_t y, const uint16_t w, const uint16_t h, const string& typeOfInput, SuccessResult& successResult)
620
630
{
621
631
try {
622
- if (strcmp (typeOfInput.c_str (), INPUT_TYPE_HDMI) == 0 ) {
623
- device::HdmiInput::getInstance ().scaleVideo (x, y, w, h);
624
- } else {
625
- device::CompositeInput::getInstance ().scaleVideo (x, y, w, h);
632
+ switch (AVInputUtils::getTypeOfInput (typeOfInput)) {
633
+ case INPUT_TYPE_INT_HDMI: {
634
+ device::HdmiInput::getInstance ().scaleVideo (x, y, w, h);
635
+ break ;
636
+ }
637
+ case INPUT_TYPE_INT_COMPOSITE: {
638
+ device::CompositeInput::getInstance ().scaleVideo (x, y, w, h);
639
+ }
640
+ default : {
641
+ successResult.success = false ;
642
+ return Core::ERROR_GENERAL;
643
+ }
626
644
}
627
- } catch ( const device::Exception& err ) {
645
+ } catch (... ) {
628
646
successResult.success = false ;
629
647
return Core::ERROR_GENERAL;
630
648
}
@@ -639,14 +657,20 @@ namespace Plugin {
639
657
bool isHdmi = true ;
640
658
641
659
try {
642
- if (strcmp (typeOfInput.c_str (), INPUT_TYPE_HDMI) == 0 ) {
643
- num = device::HdmiInput::getInstance ().getNumberOfInputs ();
644
- } else if (strcmp (typeOfInput.c_str (), INPUT_TYPE_COMPOSITE) == 0 ) {
645
- num = device::CompositeInput::getInstance ().getNumberOfInputs ();
646
- isHdmi = false ;
647
- } else {
648
- LOGERR (" getInputDevices: Invalid input type" );
649
- return Core::ERROR_GENERAL;
660
+ switch (AVInputUtils::getTypeOfInput (typeOfInput)) {
661
+ case INPUT_TYPE_INT_HDMI: {
662
+ num = device::HdmiInput::getInstance ().getNumberOfInputs ();
663
+ break ;
664
+ }
665
+ case INPUT_TYPE_INT_COMPOSITE: {
666
+ num = device::CompositeInput::getInstance ().getNumberOfInputs ();
667
+ isHdmi = false ;
668
+ }
669
+ default : {
670
+ LOGERR (" getInputDevices: Invalid input type" );
671
+ successResult.success = false ;
672
+ return Core::ERROR_GENERAL;
673
+ }
650
674
}
651
675
652
676
if (num > 0 ) {
@@ -683,15 +707,25 @@ namespace Plugin {
683
707
std::list<WPEFramework::Exchange::IAVInput::InputDevice> inputDeviceList;
684
708
success = false ;
685
709
686
- if (strcmp (typeOfInput.c_str (), INPUT_TYPE_ALL) == 0 ) {
687
- result = getInputDevices (INPUT_TYPE_HDMI, inputDeviceList);
688
- if (result == Core::ERROR_NONE) {
689
- result = getInputDevices (INPUT_TYPE_COMPOSITE, inputDeviceList);
710
+ try {
711
+ switch (AVInputUtils::getTypeOfInput (typeOfInput)) {
712
+ case INPUT_TYPE_INT_ALL: {
713
+ result = getInputDevices (INPUT_TYPE_HDMI, inputDeviceList);
714
+ if (result == Core::ERROR_NONE) {
715
+ result = getInputDevices (INPUT_TYPE_COMPOSITE, inputDeviceList);
716
+ }
717
+ break ;
718
+ }
719
+ case INPUT_TYPE_INT_HDMI:
720
+ case INPUT_TYPE_INT_COMPOSITE: {
721
+ result = getInputDevices (typeOfInput, inputDeviceList);
722
+ }
723
+ default : {
724
+ LOGERR (" GetInputDevices: Invalid input type" );
725
+ return Core::ERROR_GENERAL;
726
+ }
690
727
}
691
- } else if ((strcmp (typeOfInput.c_str (), INPUT_TYPE_HDMI) == 0 ) || (strcmp (typeOfInput.c_str (), INPUT_TYPE_COMPOSITE) == 0 )) {
692
- result = getInputDevices (typeOfInput, inputDeviceList);
693
- } else {
694
- LOGERR (" GetInputDevices: Invalid input type" );
728
+ } catch (...) {
695
729
return Core::ERROR_GENERAL;
696
730
}
697
731
@@ -742,6 +776,11 @@ namespace Plugin {
742
776
// convert to base64
743
777
uint16_t size = min (edidVec.size (), (size_t )numeric_limits<uint16_t >::max ());
744
778
779
+ if (0 == size) {
780
+ success = false ;
781
+ return Core::ERROR_GENERAL;
782
+ }
783
+
745
784
LOGWARN (" AVInputImplementation::readEDID size:%d edidVec.size:%zu" , size, edidVec.size ());
746
785
if (edidVec.size () > (size_t )numeric_limits<uint16_t >::max ()) {
747
786
LOGERR (" Size too large to use ToString base64 wpe api" );
@@ -774,19 +813,12 @@ namespace Plugin {
774
813
bool success;
775
814
776
815
string typeOfInput;
777
- switch (type) {
778
- case HDMI:
779
- typeOfInput = INPUT_TYPE_HDMI;
780
- break ;
781
- case COMPOSITE:
782
- typeOfInput = INPUT_TYPE_COMPOSITE;
783
- break ;
784
- case ALL:
785
- typeOfInput = INPUT_TYPE_ALL;
786
- break ;
787
- default :
788
- LOGERR (" AVInputHotplug: Invalid input type" );
789
- return ;
816
+
817
+ try {
818
+ typeOfInput = AVInputUtils::getTypeOfInput (type);
819
+ } catch (...) {
820
+ LOGERR (" AVInputHotplug: Invalid input type" );
821
+ return ;
790
822
}
791
823
792
824
Core::hresult result = GetInputDevices (typeOfInput, devices, success);
@@ -814,7 +846,7 @@ namespace Plugin {
814
846
string signalStatusStr;
815
847
816
848
std::stringstream locator;
817
- if (type == HDMI ) {
849
+ if (type == INPUT_TYPE_INT_HDMI ) {
818
850
locator << " hdmiin://localhost/deviceid/" << port;
819
851
} else {
820
852
locator << " cvbsin://localhost/deviceid/" << port;
@@ -862,9 +894,9 @@ namespace Plugin {
862
894
863
895
std::stringstream locator;
864
896
865
- if (type == HDMI ) {
897
+ if (type == INPUT_TYPE_INT_HDMI ) {
866
898
locator << " hdmiin://localhost/deviceid/" << port;
867
- } else if (type == COMPOSITE ) {
899
+ } else if (type == INPUT_TYPE_INT_COMPOSITE ) {
868
900
locator << " cvbsin://localhost/deviceid/" << port;
869
901
}
870
902
@@ -893,7 +925,7 @@ namespace Plugin {
893
925
894
926
LOGWARN (" AVInputVideoModeUpdate [%d]" , port);
895
927
896
- if (type == HDMI ) {
928
+ if (type == INPUT_TYPE_INT_HDMI ) {
897
929
locator << " hdmiin://localhost/deviceid/" << port;
898
930
899
931
switch (resolution.pixelResolution ) {
@@ -936,7 +968,7 @@ namespace Plugin {
936
968
937
969
progressive = (!resolution.interlaced );
938
970
939
- } else if (type == COMPOSITE ) {
971
+ } else if (type == INPUT_TYPE_INT_COMPOSITE ) {
940
972
locator << " cvbsin://localhost/deviceid/" << port;
941
973
942
974
switch (resolution.pixelResolution ) {
0 commit comments