Skip to content

Commit

Permalink
PlayerInfo: syncup from metro version
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Mar 15, 2024
1 parent 422b785 commit 7cd64aa
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 76 deletions.
37 changes: 18 additions & 19 deletions PlayerInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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()
28 changes: 14 additions & 14 deletions PlayerInfo/DeviceSettings/PlatformImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch
for (const GList* padTemplatesIterator = padTemplates; padTemplatesIterator; padTemplatesIterator = padTemplatesIterator->next) {
GstStaticPadTemplate* padTemplate = static_cast<GstStaticPadTemplate*>(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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<dsAudioStereoMode_t>(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);
}
Expand All @@ -280,7 +281,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties, public Exch

std::list<Exchange::Dolby::IOutput::INotification*>::const_iterator index = _observers.begin();

while(index != _observers.end()) {
while (index != _observers.end()) {
(*index)->AudioModeChanged(mode, enable);
index++;
}
Expand All @@ -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;
Expand All @@ -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";
Expand All @@ -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);
}

Expand Down Expand Up @@ -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");
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions PlayerInfo/Dolby/DolbyOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion PlayerInfo/GStreamer/PlatformImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PlayerInfoImplementation : public Exchange::IPlayerProperties {
for (const GList* padTemplatesIterator = padTemplates; padTemplatesIterator; padTemplatesIterator = padTemplatesIterator->next) {
GstStaticPadTemplate* padTemplate = static_cast<GstStaticPadTemplate*>(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);
Expand Down
6 changes: 5 additions & 1 deletion PlayerInfo/PlayerInfo.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
82 changes: 43 additions & 39 deletions PlayerInfo/PlayerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace Plugin {
// The relevant JSONRPC endpoints will return ERROR_UNAVAILABLE,
// if it hasn't been initialized.
_dolbyOut = _player->QueryInterface<Exchange::Dolby::IOutput>();
if(_dolbyOut == nullptr){
if (_dolbyOut == nullptr) {
SYSLOG(Logging::Startup, (_T("Dolby output switching service is unavailable.")));
} else {
_dolbyNotification.Initialize(_dolbyOut);
Expand All @@ -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
Expand Down Expand Up @@ -191,14 +195,14 @@ namespace Plugin {
Core::JSON::EnumType<JsonData::PlayerInfo::CodecsData::AudiocodecsType> audioCodec;
_audioCodecs->Reset(0);
Exchange::IPlayerProperties::AudioCodec audio;
while(_audioCodecs->Next(audio) == true) {
while (_audioCodecs->Next(audio) == true) {
playerInfo.Audio.Add(audioCodec = static_cast<JsonData::PlayerInfo::CodecsData::AudiocodecsType>(audio));
}

Core::JSON::EnumType<JsonData::PlayerInfo::CodecsData::VideocodecsType> videoCodec;
Exchange::IPlayerProperties::VideoCodec video;
_videoCodecs->Reset(0);
while(_videoCodecs->Next(video) == true) {
while (_videoCodecs->Next(video) == true) {
playerInfo.Video.Add(videoCodec = static_cast<JsonData::PlayerInfo::CodecsData::VideocodecsType>(video));
}
}
Expand Down
9 changes: 7 additions & 2 deletions PlayerInfo/PlayerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 7cd64aa

Please sign in to comment.