2828#define API_VERSION_NUMBER_MINOR 7
2929#define API_VERSION_NUMBER_PATCH 1
3030
31+ #define AV_HOT_PLUG_EVENT_CONNECTED 0
32+ #define AV_HOT_PLUG_EVENT_DISCONNECTED 1
33+
3134// Explicitly implementing getInputDevices method instead of autogenerating via IAVInput.h
3235// because it requires optional parameters which are not supported in Thunder 4.x. This can
3336// be refactored after migrating to 5.x.
@@ -56,6 +59,9 @@ namespace Plugin {
5659 , _connectionId(0 )
5760 , _avInput(nullptr )
5861 , _avInputNotification(this )
62+ // <pca>
63+ , _registeredDsEventHandlers(false )
64+ // </pca>
5965 {
6066 Register<JsonObject, JsonObject>(_T (AVINPUT_METHOD_GET_INPUT_DEVICES), &AVInput::getInputDevicesWrapper, this );
6167 SYSLOG (Logging::Startup, (_T (" AVInput Constructor" )));
@@ -94,6 +100,22 @@ namespace Plugin {
94100 _avInput->RegisterGameFeatureStatusUpdateNotification (_avInputNotification.baseInterface <Exchange::IAVInput::IGameFeatureStatusUpdateNotification>());
95101 _avInput->RegisterAviContentTypeUpdateNotification (_avInputNotification.baseInterface <Exchange::IAVInput::IAviContentTypeUpdateNotification>());
96102
103+ // <pca>
104+ try {
105+ device::Manager::Initialize ();
106+ LOGINFO (" device::Manager::Initialize success" );
107+ if (!_registeredDsEventHandlers) {
108+ _registeredDsEventHandlers = true ;
109+ device::Host::getInstance ().Register (baseInterface<device::Host::IHdmiInEvents>(), " WPE::AVInputHdmi" );
110+ device::Host::getInstance ().Register (baseInterface<device::Host::ICompositeInEvents>(), " WPE::AVInputComp" );
111+ }
112+ }
113+ catch (const device::Exception& err) {
114+ LOGINFO (" AVInput: Initialization failed due to device::manager::Initialize()" );
115+ LOG_DEVICE_EXCEPTION0 ();
116+ }
117+ // </pca>
118+
97119 // Invoking Plugin API register to wpeframework
98120 Exchange::JAVInput::Register (*this , _avInput);
99121 } else {
@@ -110,6 +132,20 @@ namespace Plugin {
110132
111133 SYSLOG (Logging::Shutdown, (string (_T (" AVInput::Deinitialize" ))));
112134
135+ // <pca>
136+ device::Host::getInstance ().UnRegister (baseInterface<device::Host::IHdmiInEvents>());
137+ device::Host::getInstance ().UnRegister (baseInterface<device::Host::ICompositeInEvents>());
138+ _registeredDsEventHandlers = false ;
139+ try {
140+ device::Manager::DeInitialize ();
141+ LOGINFO (" device::Manager::DeInitialize success" );
142+ }
143+ catch (const device::Exception& err) {
144+ LOGINFO (" device::Manager::DeInitialize failed due to device::Manager::DeInitialize()" );
145+ LOG_DEVICE_EXCEPTION0 ();
146+ }
147+ // </pca>
148+
113149 // Make sure the Activated and Deactivated are no longer called before we start cleaning up.
114150 _service->Unregister (&_avInputNotification);
115151
@@ -262,133 +298,133 @@ namespace Plugin {
262298 }
263299
264300 // <pca>
265- // / * HDMIInEventsNotification*/
266-
267- // void AVInput::Notification ::OnHdmiInAVIContentType(dsHdmiInPort_t port, dsAviContentType_t aviContentType)
268- // {
269- // LOGINFO("Received OnHdmiInAVIContentType callback, port: %d, Content Type: %d", port, aviContentType);
270-
271- // if(AVInput ::_instance) {
272- // AVInput ::_instance->hdmiInputAviContentTypeChange(port, aviContentType);
273- // }
274- // }
275-
276- // void AVInput::Notification ::OnHdmiInEventHotPlug(dsHdmiInPort_t port, bool isConnected)
277- // {
278- // LOGINFO("Received OnHdmiInEventHotPlug callback, port: %d, isConnected: %s", port, isConnected ? "true" : "false");
279-
280- // if(AVInput ::_instance) {
281- // AVInput ::_instance->AVInputHotplug(port,isConnected ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, HDMI );
282- // }
283- // }
284-
285- // void AVInput::Notification ::OnHdmiInEventSignalStatus(dsHdmiInPort_t port, dsHdmiInSignalStatus_t signalStatus)
286- // {
287- // LOGINFO("Received OnHdmiInEventSignalStatus callback, port: %d, signalStatus: %d",port, signalStatus);
288-
289- // if(AVInput ::_instance) {
290- // AVInput ::_instance->AVInputSignalChange(port, signalStatus, HDMI );
291- // }
292- // }
293-
294- // void AVInput::Notification ::OnHdmiInEventStatus(dsHdmiInPort_t activePort, bool isPresented)
295- // {
296- // LOGINFO("Received OnHdmiInEventStatus callback, port: %d, isPresented: %s",activePort, isPresented ? "true" : "false");
297-
298- // if (AVInput ::_instance) {
299- // AVInput ::_instance->AVInputStatusChange(activePort, isPresented, HDMI );
300- // }
301- // }
302-
303- // void AVInput::Notification ::OnHdmiInVideoModeUpdate(dsHdmiInPort_t port, const dsVideoPortResolution_t& videoPortResolution)
304- // {
305- // LOGINFO("Received OnHdmiInVideoModeUpdate callback, port: %d, pixelResolution: %d, interlaced: %d, frameRate: %d",
306- // port,
307- // videoPortResolution.pixelResolution,
308- // videoPortResolution.interlaced,
309- // videoPortResolution.frameRate);
310-
311- // if (AVInput ::_instance) {
312- // AVInput ::_instance->AVInputVideoModeUpdate(port, videoPortResolution, HDMI );
313- // }
314- // }
315-
316- // void AVInput::Notification ::OnHdmiInAllmStatus(dsHdmiInPort_t port, bool allmStatus)
317- // {
318- // LOGINFO("Received OnHdmiInAllmStatus callback, port: %d, ALLM Mode: %s",
319- // port, allmStatus ? "true" : "false");
320-
321- // if (AVInput ::_instance) {
322- // AVInput ::_instance->AVInputALLMChange(port, allmStatus);
323- // }
324- // }
325-
326- // void AVInput::Notification ::OnHdmiInVRRStatus(dsHdmiInPort_t port, dsVRRType_t vrrType)
327- // {
328- // LOGINFO("Received OnHdmiInVRRStatus callback, port: %d, VRR Type: %d",
329- // port, vrrType);
330-
331- // if (!AVInput ::_instance)
332- // return;
333-
334- // // Handle transitions
335- // if (dsVRR_NONE == vrrType) {
336- // if (AVInput ::_instance->m_currentVrrType != dsVRR_NONE) {
337- // AVInput ::_instance->AVInputVRRChange(port,AVInput ::_instance->m_currentVrrType,false);
338- // }
339- // } else {
340- // if (AVInput ::_instance->m_currentVrrType != dsVRR_NONE) {
341- // AVInput ::_instance->AVInputVRRChange(port,AVInput ::_instance->m_currentVrrType,false);
342- // }
343- // AVInput ::_instance->AVInputVRRChange(port,vrrType,true);
344- // }
345-
346- // AVInput ::_instance->m_currentVrrType = vrrType;
347- // }
348-
349-
350- // / *CompositeInEventsNotification*/
351-
352- // void AVInput::Notification ::OnCompositeInHotPlug(dsCompositeInPort_t port, bool isConnected)
353- // {
354- // LOGINFO("Received OnCompositeInHotPlug callback, port: %d, isConnected: %s",port, isConnected ? "true" : "false");
355-
356- // if(AVInput ::_instance) {
357- // AVInput ::_instance->AVInputHotplug(port,isConnected ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED,COMPOSITE );
358- // }
359- // }
360-
361- // void AVInput::Notification ::OnCompositeInSignalStatus(dsCompositeInPort_t port, dsCompInSignalStatus_t signalStatus)
362- // {
363- // LOGINFO("Received OnCompositeInSignalStatus callback, port: %d, signalStatus: %d",port, signalStatus);
364-
365- // if(AVInput ::_instance) {
366- // AVInput ::_instance->AVInputSignalChange(port, signalStatus, COMPOSITE );
367- // }
368- // }
369-
370- // void AVInput::Notification ::OnCompositeInStatus(dsCompositeInPort_t activePort, bool isPresented)
371- // {
372- // LOGINFO("Received OnCompositeInStatus callback, port: %d, isPresented: %s",
373- // activePort, isPresented ? "true" : "false");
374-
375- // if (AVInput ::_instance) {
376- // AVInput ::_instance->AVInputStatusChange(activePort, isPresented, COMPOSITE );
377- // }
378- // }
379-
380- // void AVInput::Notification ::OnCompositeInVideoModeUpdate(dsCompositeInPort_t activePort, dsVideoPortResolution_t videoResolution)
381- // {
382- // LOGINFO("Received OnCompositeInVideoModeUpdate callback, port: %d, pixelResolution: %d, interlaced: %d, frameRate: %d",
383- // activePort,
384- // videoResolution.pixelResolution,
385- // videoResolution.interlaced,
386- // videoResolution.frameRate);
387-
388- // if (AVInput ::_instance) {
389- // AVInput ::_instance->AVInputVideoModeUpdate(activePort, videoResolution, COMPOSITE );
390- // }
391- // }
301+ /* HDMIInEventsNotification*/
302+
303+ void AVInput::OnHdmiInAVIContentType (dsHdmiInPort_t port, dsAviContentType_t aviContentType)
304+ {
305+ LOGINFO (" Received OnHdmiInAVIContentType callback, port: %d, Content Type: %d" , port, aviContentType);
306+
307+ if (AVInputImplementation ::_instance) {
308+ AVInputImplementation ::_instance->hdmiInputAviContentTypeChange (port, aviContentType);
309+ }
310+ }
311+
312+ void AVInput::OnHdmiInEventHotPlug (dsHdmiInPort_t port, bool isConnected)
313+ {
314+ LOGINFO (" Received OnHdmiInEventHotPlug callback, port: %d, isConnected: %s" , port, isConnected ? " true" : " false" );
315+
316+ if (AVInputImplementation ::_instance) {
317+ AVInputImplementation ::_instance->AVInputHotplug (port,isConnected ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, INPUT_TYPE_INT_HDMI );
318+ }
319+ }
320+
321+ void AVInput::OnHdmiInEventSignalStatus (dsHdmiInPort_t port, dsHdmiInSignalStatus_t signalStatus)
322+ {
323+ LOGINFO (" Received OnHdmiInEventSignalStatus callback, port: %d, signalStatus: %d" ,port, signalStatus);
324+
325+ if (AVInputImplementation ::_instance) {
326+ AVInputImplementation ::_instance->AVInputSignalChange (port, signalStatus, INPUT_TYPE_INT_HDMI );
327+ }
328+ }
329+
330+ void AVInput::OnHdmiInEventStatus (dsHdmiInPort_t activePort, bool isPresented)
331+ {
332+ LOGINFO (" Received OnHdmiInEventStatus callback, port: %d, isPresented: %s" ,activePort, isPresented ? " true" : " false" );
333+
334+ if (AVInputImplementation ::_instance) {
335+ AVInputImplementation ::_instance->AVInputStatusChange (activePort, isPresented, INPUT_TYPE_INT_HDMI );
336+ }
337+ }
338+
339+ void AVInput::OnHdmiInVideoModeUpdate (dsHdmiInPort_t port, const dsVideoPortResolution_t& videoPortResolution)
340+ {
341+ LOGINFO (" Received OnHdmiInVideoModeUpdate callback, port: %d, pixelResolution: %d, interlaced: %d, frameRate: %d" ,
342+ port,
343+ videoPortResolution.pixelResolution ,
344+ videoPortResolution.interlaced ,
345+ videoPortResolution.frameRate );
346+
347+ if (AVInputImplementation ::_instance) {
348+ AVInputImplementation ::_instance->AVInputVideoModeUpdate (port, videoPortResolution, INPUT_TYPE_INT_HDMI );
349+ }
350+ }
351+
352+ void AVInput::OnHdmiInAllmStatus (dsHdmiInPort_t port, bool allmStatus)
353+ {
354+ LOGINFO (" Received OnHdmiInAllmStatus callback, port: %d, ALLM Mode: %s" ,
355+ port, allmStatus ? " true" : " false" );
356+
357+ if (AVInputImplementation ::_instance) {
358+ AVInputImplementation ::_instance->AVInputALLMChange (port, allmStatus);
359+ }
360+ }
361+
362+ void AVInput::OnHdmiInVRRStatus (dsHdmiInPort_t port, dsVRRType_t vrrType)
363+ {
364+ LOGINFO (" Received OnHdmiInVRRStatus callback, port: %d, VRR Type: %d" ,
365+ port, vrrType);
366+
367+ if (!AVInputImplementation ::_instance)
368+ return ;
369+
370+ // Handle transitions
371+ if (dsVRR_NONE == vrrType) {
372+ if (AVInputImplementation ::_instance->m_currentVrrType != dsVRR_NONE) {
373+ AVInputImplementation ::_instance->AVInputVRRChange (port,AVInputImplementation ::_instance->m_currentVrrType ,false );
374+ }
375+ } else {
376+ if (AVInputImplementation ::_instance->m_currentVrrType != dsVRR_NONE) {
377+ AVInputImplementation ::_instance->AVInputVRRChange (port,AVInputImplementation ::_instance->m_currentVrrType ,false );
378+ }
379+ AVInputImplementation ::_instance->AVInputVRRChange (port,vrrType,true );
380+ }
381+
382+ AVInputImplementation ::_instance->m_currentVrrType = vrrType;
383+ }
384+
385+
386+ /* CompositeInEventsNotification*/
387+
388+ void AVInput::OnCompositeInHotPlug (dsCompositeInPort_t port, bool isConnected)
389+ {
390+ LOGINFO (" Received OnCompositeInHotPlug callback, port: %d, isConnected: %s" ,port, isConnected ? " true" : " false" );
391+
392+ if (AVInputImplementation ::_instance) {
393+ AVInputImplementation ::_instance->AVInputHotplug (port,isConnected ? AV_HOT_PLUG_EVENT_CONNECTED : AV_HOT_PLUG_EVENT_DISCONNECTED, INPUT_TYPE_INT_COMPOSITE );
394+ }
395+ }
396+
397+ void AVInput::OnCompositeInSignalStatus (dsCompositeInPort_t port, dsCompInSignalStatus_t signalStatus)
398+ {
399+ LOGINFO (" Received OnCompositeInSignalStatus callback, port: %d, signalStatus: %d" ,port, signalStatus);
400+
401+ if (AVInputImplementation ::_instance) {
402+ AVInputImplementation ::_instance->AVInputSignalChange (port, signalStatus, INPUT_TYPE_INT_COMPOSITE );
403+ }
404+ }
405+
406+ void AVInput::OnCompositeInStatus (dsCompositeInPort_t activePort, bool isPresented)
407+ {
408+ LOGINFO (" Received OnCompositeInStatus callback, port: %d, isPresented: %s" ,
409+ activePort, isPresented ? " true" : " false" );
410+
411+ if (AVInputImplementation ::_instance) {
412+ AVInputImplementation ::_instance->AVInputStatusChange (activePort, isPresented, INPUT_TYPE_INT_COMPOSITE );
413+ }
414+ }
415+
416+ void AVInput::OnCompositeInVideoModeUpdate (dsCompositeInPort_t activePort, dsVideoPortResolution_t videoResolution)
417+ {
418+ LOGINFO (" Received OnCompositeInVideoModeUpdate callback, port: %d, pixelResolution: %d, interlaced: %d, frameRate: %d" ,
419+ activePort,
420+ videoResolution.pixelResolution ,
421+ videoResolution.interlaced ,
422+ videoResolution.frameRate );
423+
424+ if (AVInputImplementation ::_instance) {
425+ AVInputImplementation ::_instance->AVInputVideoModeUpdate (activePort, videoResolution, INPUT_TYPE_INT_COMPOSITE );
426+ }
427+ }
392428 // </pca>
393429} // namespace Plugin
394430} // namespace WPEFramework
0 commit comments