From 7cd64aa53042e1c82a8758f0a13128fdd9e51435 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Wed, 28 Feb 2024 02:22:42 -0500 Subject: [PATCH] PlayerInfo: syncup from metro version --- PlayerInfo/CMakeLists.txt | 37 ++++----- .../DeviceSettings/PlatformImplementation.cpp | 28 +++---- PlayerInfo/Dolby/DolbyOutput.cpp | 1 + .../GStreamer/PlatformImplementation.cpp | 2 +- PlayerInfo/PlayerInfo.conf.in | 6 +- PlayerInfo/PlayerInfo.cpp | 82 ++++++++++--------- PlayerInfo/PlayerInfo.h | 9 +- 7 files changed, 89 insertions(+), 76 deletions(-) diff --git a/PlayerInfo/CMakeLists.txt b/PlayerInfo/CMakeLists.txt index e2c0263ba8..2a1965a066 100644 --- a/PlayerInfo/CMakeLists.txt +++ b/PlayerInfo/CMakeLists.txt @@ -23,7 +23,6 @@ find_package(WPEFramework) project_version(1.0.0) -set(PLUGIN_NAME PlayerInfo) set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME}) message("Setup ${MODULE_NAME} v${PROJECT_VERSION}") @@ -81,30 +80,30 @@ if (GSTREAMER_FOUND) target_sources(${MODULE_NAME} PRIVATE GStreamer/PlatformImplementation.cpp) + endif () +endif () - if (DOLBY_SUPPORT) - target_sources(${MODULE_NAME} - PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/Dolby/DolbyOutput.cpp) +if (DOLBY_SUPPORT) + target_sources(${MODULE_NAME} + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Dolby/DolbyOutput.cpp) - target_include_directories(${MODULE_NAME} - PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/Dolby/include) + target_include_directories(${MODULE_NAME} + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Dolby/include) - target_compile_definitions(${MODULE_NAME} - PRIVATE - DOLBY_SUPPORT=1) + target_compile_definitions(${MODULE_NAME} + PRIVATE + DOLBY_SUPPORT=1) - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Dolby) + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Dolby) - target_link_libraries(${MODULE_NAME} - PRIVATE - PlayerInfoDolby) - endif() - endif () -endif () + target_link_libraries(${MODULE_NAME} + PRIVATE + PlayerInfoDolby) +endif() install(TARGETS ${MODULE_NAME} DESTINATION lib/${STORAGE_DIRECTORY}/plugins) -write_config(${PROJECT_NAME}) +write_config() diff --git a/PlayerInfo/DeviceSettings/PlatformImplementation.cpp b/PlayerInfo/DeviceSettings/PlatformImplementation.cpp index 282af9914c..813b878124 100644 --- a/PlayerInfo/DeviceSettings/PlatformImplementation.cpp +++ b/PlayerInfo/DeviceSettings/PlatformImplementation.cpp @@ -84,7 +84,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch for (const GList* padTemplatesIterator = padTemplates; padTemplatesIterator; padTemplatesIterator = padTemplatesIterator->next) { GstStaticPadTemplate* padTemplate = static_cast(padTemplatesIterator->data); - if (padTemplate->direction == GST_PAD_SRC) { + if (padTemplate && padTemplate->direction == GST_PAD_SRC) { MediaTypes mediaTypes{gst_static_pad_template_get_caps(padTemplate)}; if (GstUtils::GstRegistryGetElementForMediaType(decoderFactories.get(), std::move(mediaTypes))) { codecIteratorList.push_back(index.second); @@ -225,6 +225,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch uint32_t Register(Exchange::Dolby::IOutput::INotification* notification) override { + ASSERT(notification != nullptr); _adminLock.Lock(); // Make sure a sink is not registered multiple times. @@ -259,16 +260,16 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch static void AudioModeHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) { - if(PlayerInfoImplementation::_instance) + if (PlayerInfoImplementation::_instance) { dsAudioStereoMode_t amode = dsAUDIO_STEREO_UNKNOWN; Exchange::Dolby::IOutput::SoundModes mode = UNKNOWN; IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; amode = static_cast(eventData->data.Audioport.mode); if (amode == device::AudioStereoMode::kSurround) mode = SURROUND; - else if(amode == device::AudioStereoMode::kStereo) mode = STEREO; - else if(amode == device::AudioStereoMode::kMono) mode = MONO; - else if(amode == device::AudioStereoMode::kPassThru) mode = PASSTHRU; + else if (amode == device::AudioStereoMode::kStereo) mode = STEREO; + else if (amode == device::AudioStereoMode::kMono) mode = MONO; + else if (amode == device::AudioStereoMode::kPassThru) mode = PASSTHRU; else mode = UNKNOWN; PlayerInfoImplementation::_instance->audiomodeChanged(mode, true); } @@ -280,7 +281,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch std::list::const_iterator index = _observers.begin(); - while(index != _observers.end()) { + while (index != _observers.end()) { (*index)->AudioModeChanged(mode, enable); index++; } @@ -299,7 +300,6 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch return (Core::ERROR_GENERAL); } - uint32_t AtmosMetadata(bool& supported /* @out */) const override { dsATMOSCapability_t atmosCapability = dsAUDIO_ATMOS_NOTSUPPORTED; @@ -313,7 +313,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch for (size_t i = 0; i < aPorts.size(); i++) { device::AudioOutputPort &aPort = aPorts.at(i); - if(aPort.getName().find("HDMI_ARC") != std::string::npos) + if (aPort.getName().find("HDMI_ARC") != std::string::npos) { //the platform supports HDMI_ARC. Get the sound mode of the ARC port audioPort = "HDMI_ARC0"; @@ -336,7 +336,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch TRACE(Trace::Error, (_T("Exception during DeviceSetting library call. code = %d message = %s"), err.getCode(), err.what())); } - if(atmosCapability == dsAUDIO_ATMOS_ATMOSMETADATA) supported = true; + if (atmosCapability == dsAUDIO_ATMOS_ATMOSMETADATA) supported = true; return (Core::ERROR_NONE); } @@ -368,7 +368,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch audioPort = "SPDIF0"; } /* Does this device support HDMI_ARC output and is the port connected? If yes, then that the audio port whose sound mode we'll return */ - if(aPort.getName().find("HDMI_ARC") != std::string::npos && device::Host::getInstance().getAudioOutputPort("HDMI_ARC0").isConnected()) + if (aPort.getName().find("HDMI_ARC") != std::string::npos && device::Host::getInstance().getAudioOutputPort("HDMI_ARC0").isConnected()) { //the platform supports HDMI_ARC. Get the sound mode of the ARC port LOGINFO(" HDMI ARC port detected on platform"); @@ -383,13 +383,13 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch { soundmode = aPort.getStereoMode(); if (soundmode == device::AudioStereoMode::kSurround) mode = SURROUND; - else if(soundmode == device::AudioStereoMode::kStereo) mode = STEREO; - else if(soundmode == device::AudioStereoMode::kMono) mode = MONO; - else if(soundmode == device::AudioStereoMode::kPassThru) mode = PASSTHRU; + else if (soundmode == device::AudioStereoMode::kStereo) mode = STEREO; + else if (soundmode == device::AudioStereoMode::kMono) mode = MONO; + else if (soundmode == device::AudioStereoMode::kPassThru) mode = PASSTHRU; else mode = UNKNOWN; /* Auto mode applicable for HDMI Arc and SPDIF */ - if((aPort.getType().getId() == device::AudioOutputPortType::kARC || aPort.getType().getId() == device::AudioOutputPortType::kSPDIF) + if ((aPort.getType().getId() == device::AudioOutputPortType::kARC || aPort.getType().getId() == device::AudioOutputPortType::kSPDIF) && aPort.getStereoAuto()) { mode = SOUNDMODE_AUTO; diff --git a/PlayerInfo/Dolby/DolbyOutput.cpp b/PlayerInfo/Dolby/DolbyOutput.cpp index 17e2402a0e..fd8d9a5340 100644 --- a/PlayerInfo/Dolby/DolbyOutput.cpp +++ b/PlayerInfo/Dolby/DolbyOutput.cpp @@ -30,6 +30,7 @@ namespace WPEFramework public: uint32_t Register(Exchange::Dolby::IOutput::INotification* notification) override { + ASSERT(notification != nullptr); _adminLock.Lock(); // Make sure a sink is not registered multiple times. diff --git a/PlayerInfo/GStreamer/PlatformImplementation.cpp b/PlayerInfo/GStreamer/PlatformImplementation.cpp index 314ca4cf44..c65bd3c2c0 100644 --- a/PlayerInfo/GStreamer/PlatformImplementation.cpp +++ b/PlayerInfo/GStreamer/PlatformImplementation.cpp @@ -71,7 +71,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties { for (const GList* padTemplatesIterator = padTemplates; padTemplatesIterator; padTemplatesIterator = padTemplatesIterator->next) { GstStaticPadTemplate* padTemplate = static_cast(padTemplatesIterator->data); - if (padTemplate->direction == GST_PAD_SRC) { + if (padTemplate && padTemplate->direction == GST_PAD_SRC) { MediaTypes mediaTypes{gst_static_pad_template_get_caps(padTemplate)}; if (GstUtils::GstRegistryGetElementForMediaType(decoderFactories.get(), std::move(mediaTypes))) { codecIteratorList.push_back(index.second); diff --git a/PlayerInfo/PlayerInfo.conf.in b/PlayerInfo/PlayerInfo.conf.in index dfbabb8f33..a3b4334644 100644 --- a/PlayerInfo/PlayerInfo.conf.in +++ b/PlayerInfo/PlayerInfo.conf.in @@ -4,5 +4,9 @@ startuporder = "@PLUGIN_PLAYERINFO_STARTUPORDER@" configuration = JSON() rootobject = JSON() -rootobject.add("mode", "@PLUGIN_PLAYERINFO_MODE@") +if "@PLUGIN_IMPLEMENTATION_GSTREAMER@" == "ON": + rootobject.add("mode", "Local") +else: + rootobject.add("mode", "@PLUGIN_PLAYERINFO_MODE@") + configuration.add("root", rootobject) diff --git a/PlayerInfo/PlayerInfo.cpp b/PlayerInfo/PlayerInfo.cpp index aa2c4036d4..b26e6681f4 100644 --- a/PlayerInfo/PlayerInfo.cpp +++ b/PlayerInfo/PlayerInfo.cpp @@ -76,7 +76,7 @@ namespace Plugin { // The relevant JSONRPC endpoints will return ERROR_UNAVAILABLE, // if it hasn't been initialized. _dolbyOut = _player->QueryInterface(); - if(_dolbyOut == nullptr){ + if (_dolbyOut == nullptr) { SYSLOG(Logging::Startup, (_T("Dolby output switching service is unavailable."))); } else { _dolbyNotification.Initialize(_dolbyOut); @@ -93,56 +93,60 @@ namespace Plugin { message = _T("PlayerInfo could not be instantiated."); } - if(message.length() != 0){ +#ifndef USE_THUNDER_R4 + if (message.length() != 0) { Deinitialize(service); } +#endif + return message; } /* virtual */ void PlayerInfo::Deinitialize(PluginHost::IShell* service VARIABLE_IS_NOT_USED) { - ASSERT(service == _service); + if (_service != nullptr) { + ASSERT(service == _service); - _service->Unregister(&_notification); + _service->Unregister(&_notification); - if (_player != nullptr) { - if(_audioCodecs != nullptr && _videoCodecs != nullptr) { - Exchange::JPlayerProperties::Unregister(*this); - } - if (_audioCodecs != nullptr) { - _audioCodecs->Release(); - _audioCodecs = nullptr; - } - if (_videoCodecs != nullptr) { - _videoCodecs->Release(); - _videoCodecs = nullptr; - } - if (_dolbyOut != nullptr) { - _dolbyNotification.Deinitialize(); - Exchange::Dolby::JOutput::Unregister(*this); - _dolbyOut->Release(); - _dolbyOut = nullptr; - } + if (_player != nullptr) { + if (_audioCodecs != nullptr && _videoCodecs != nullptr) { + Exchange::JPlayerProperties::Unregister(*this); + } + if (_audioCodecs != nullptr) { + _audioCodecs->Release(); + _audioCodecs = nullptr; + } + if (_videoCodecs != nullptr) { + _videoCodecs->Release(); + _videoCodecs = nullptr; + } + if (_dolbyOut != nullptr) { + _dolbyNotification.Deinitialize(); + Exchange::Dolby::JOutput::Unregister(*this); + _dolbyOut->Release(); + _dolbyOut = nullptr; + } - RPC::IRemoteConnection* connection(_service->RemoteConnection(_connectionId)); - VARIABLE_IS_NOT_USED uint32_t result = _player->Release(); - _player = nullptr; - ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED); + RPC::IRemoteConnection* connection(_service->RemoteConnection(_connectionId)); + VARIABLE_IS_NOT_USED uint32_t result = _player->Release(); + _player = nullptr; + ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED); - // The connection can disappear in the meantime... - if (connection != nullptr) { - // But if it did not dissapear in the meantime, forcefully terminate it. Shoot to kill :-) - connection->Terminate(); - connection->Release(); + // The connection can disappear in the meantime... + if (connection != nullptr) { + // But if it did not dissapear in the meantime, forcefully terminate it. Shoot to kill :-) + connection->Terminate(); + connection->Release(); + } } - } - _service->Release(); - _service = nullptr; - _player = nullptr; + _service->Release(); + _service = nullptr; + _player = nullptr; - _connectionId = 0; - + _connectionId = 0; + } } /* virtual */ string PlayerInfo::Information() const @@ -191,14 +195,14 @@ namespace Plugin { Core::JSON::EnumType audioCodec; _audioCodecs->Reset(0); Exchange::IPlayerProperties::AudioCodec audio; - while(_audioCodecs->Next(audio) == true) { + while (_audioCodecs->Next(audio) == true) { playerInfo.Audio.Add(audioCodec = static_cast(audio)); } Core::JSON::EnumType videoCodec; Exchange::IPlayerProperties::VideoCodec video; _videoCodecs->Reset(0); - while(_videoCodecs->Next(video) == true) { + while (_videoCodecs->Next(video) == true) { playerInfo.Video.Add(videoCodec = static_cast(video)); } } diff --git a/PlayerInfo/PlayerInfo.h b/PlayerInfo/PlayerInfo.h index dc9921f2f3..75156e3cd2 100644 --- a/PlayerInfo/PlayerInfo.h +++ b/PlayerInfo/PlayerInfo.h @@ -43,13 +43,18 @@ namespace Plugin { ~Notification() override = default; public: - void Activated(RPC::IRemoteConnection*) override + void Activated(RPC::IRemoteConnection* /* connection */) override { } void Deactivated(RPC::IRemoteConnection* connection) override { _parent.Deactivated(connection); } +#ifdef USE_THUNDER_R4 + void Terminated(RPC::IRemoteConnection* /* connection */) override + { + } +#endif BEGIN_INTERFACE_MAP(Notification) INTERFACE_ENTRY(RPC::IRemoteConnection::INotification) @@ -88,7 +93,7 @@ namespace Plugin { _client = nullptr; } } - void AudioModeChanged(Exchange::Dolby::IOutput::SoundModes mode, bool enabled) override + void AudioModeChanged(const Exchange::Dolby::IOutput::SoundModes mode, bool enabled) override { Exchange::Dolby::JOutput::Event::AudioModeChanged(_parent, mode, enabled); }