Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions HdcpProfile/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${NAMESPACE}Protocols::${
endif (USE_THUNDER_R4)

find_package(DS)
find_package(IARMBus)
find_package(CEC)

if (RDK_SERVICE_L2_TEST)
Expand All @@ -82,14 +81,13 @@ if (RDK_SERVICE_L2_TEST)
endif()


target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${IARMBUS_INCLUDE_DIRS})
target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${DS_INCLUDE_DIRS})
target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ../helpers)


set_source_files_properties(HdcpProfile.cpp PROPERTIES COMPILE_FLAGS "-fexceptions")

target_link_libraries(${PLUGIN_IMPLEMENTATION} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${IARMBUS_LIBRARIES} ${DS_LIBRARIES})
target_link_libraries(${PLUGIN_IMPLEMENTATION} PUBLIC ${NAMESPACE}Plugins::${NAMESPACE}Plugins ${DS_LIBRARIES})

install(TARGETS ${PLUGIN_IMPLEMENTATION}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)
Expand Down
84 changes: 26 additions & 58 deletions HdcpProfile/HdcpProfileImplementation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in HdcpProfile/HdcpProfileImplementation.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'HdcpProfile/HdcpProfileImplementation.cpp' (Match: rdkcentral/rdkservices/1, 346 lines, url: https://github.com/rdkcentral/rdkservices/archive/GRT_v1.tar.gz, file: HdcpProfile/HdcpProfile.cpp)
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
Expand All @@ -23,14 +23,9 @@

#include "videoOutputPort.hpp"
#include "videoOutputPortConfig.hpp"
#include "dsMgr.h"
#include "manager.hpp"
#include "host.hpp"

#include "UtilsJsonRpc.h"
#include "UtilsIarm.h"

#include "UtilsSynchroIarm.hpp"

#define HDMI_HOT_PLUG_EVENT_CONNECTED 0
#define HDMI_HOT_PLUG_EVENT_DISCONNECTED 1
Expand Down Expand Up @@ -61,14 +56,15 @@
HdcpProfileImplementation::~HdcpProfileImplementation()
{
LOGINFO("Call HdcpProfileImplementation destructor\n");
device::Host::getInstance().UnRegister(baseInterface<device::Host::IVideoOutputPortEvents>());
device::Host::getInstance().UnRegister(baseInterface<device::Host::IDisplayDeviceEvents>());
if (_powerManagerPlugin) {
_powerManagerPlugin.Reset();
}
if(_service != nullptr)
{
_service->Release();
}
DeinitializeIARM();
HdcpProfileImplementation::_instance = nullptr;
mShell = nullptr;
}
Expand All @@ -82,26 +78,7 @@
.createInterface();
}

void HdcpProfileImplementation::InitializeIARM()
{
Utils::IARM::init();

IARM_Result_t res;
IARM_CHECK( Utils::Synchro::RegisterLockedIarmEventHandler<HdcpProfileImplementation>(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, dsHdmiEventHandler) );
IARM_CHECK( Utils::Synchro::RegisterLockedIarmEventHandler<HdcpProfileImplementation>(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDCP_STATUS, dsHdmiEventHandler) );
}

void HdcpProfileImplementation::DeinitializeIARM()
{
if (Utils::IARM::isConnected())
{
IARM_Result_t res;
IARM_CHECK( Utils::Synchro::RemoveLockedEventHandler<HdcpProfileImplementation>(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, dsHdmiEventHandler) );
IARM_CHECK( Utils::Synchro::RemoveLockedEventHandler<HdcpProfileImplementation>(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDCP_STATUS, dsHdmiEventHandler) );
}
}

void HdcpProfileImplementation::onHdmiOutputHotPlug(int connectStatus)
void HdcpProfileImplementation::onHdmiOutputHotPlug(dsDisplayEvent_t connectStatus)
{
if (HDMI_HOT_PLUG_EVENT_CONNECTED == connectStatus)
{
Expand Down Expand Up @@ -137,49 +114,39 @@
status.hdcpReason);
}

void HdcpProfileImplementation::onHdmiOutputHDCPStatusEvent(int hdcpStatus)
void HdcpProfileImplementation::onHdmiOutputHDCPStatusEvent(dsHdcpStatus_t hdcpStatus)
{
LOGINFO("hdcpStatus[%d]",hdcpStatus);
onHdcpProfileDisplayConnectionChanged();
}

void HdcpProfileImplementation::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
void HdcpProfileImplementation::OnDisplayHDMIHotPlug(dsDisplayEvent_t displayEvent)
{
LOGINFO("Received OnDisplayHDMIHotPlug event data:%d \r\n", displayEvent);
HdcpProfileImplementation::_instance->onHdmiOutputHotPlug(displayEvent);
}

void HdcpProfileImplementation::OnHDCPStatusChange(dsHdcpStatus_t hdcpStatus)
{
uint32_t res = Core::ERROR_GENERAL;
PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;

if(!HdcpProfileImplementation::_instance)
return;

if (IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG == eventId)
{
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
int hdmi_hotplug_event = eventData->data.hdmi_hpd.event;
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event data:%d \r\n", hdmi_hotplug_event);

HdcpProfileImplementation::_instance->onHdmiOutputHotPlug(hdmi_hotplug_event);
}
else if (IARM_BUS_DSMGR_EVENT_HDCP_STATUS == eventId)
{
ASSERT (_powerManagerPlugin);
if (_powerManagerPlugin){
res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev);
if (Core::ERROR_NONE != res)
{
LOGWARN("Failed to Invoke RPC method: GetPowerState");
}
else
{
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
int hdcpStatus = eventData->data.hdmi_hdcp.hdcpStatus;
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDCP_STATUS event data:%d param.curState: %d \r\n", hdcpStatus,pwrStateCur);
HdcpProfileImplementation::_instance->onHdmiOutputHDCPStatusEvent(hdcpStatus);
}

ASSERT (_powerManagerPlugin);
if (_powerManagerPlugin){
res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev);
if (Core::ERROR_NONE != res)
{
LOGWARN("Failed to Invoke RPC method: GetPowerState");
}
else
{
LOGINFO("Received OnHDCPStatusChange event data:%d param.curState: %d \r\n", hdcpStatus,pwrStateCur);
HdcpProfileImplementation::_instance->onHdmiOutputHDCPStatusEvent(hdcpStatus);
}
}
}

/**
* Register a notification callback
*/
Expand Down Expand Up @@ -243,7 +210,8 @@
_service = service;
_service->AddRef();
ASSERT(service != nullptr);
InitializeIARM();
device::Host::getInstance().Register(baseInterface<device::Host::IVideoOutputPortEvents>(),"WPE::HdcpProfile");
device::Host::getInstance().Register(baseInterface<device::Host::IDisplayDeviceEvents>(),"WPE::HdcpProfile");
InitializePowerManager(service);
return result;
}
Expand Down
29 changes: 18 additions & 11 deletions HdcpProfile/HdcpProfileImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,27 @@
#include <core/core.h>
#include <mutex>
#include <vector>
#include "libIBus.h"

#include "host.hpp"

#include "PowerManagerInterface.h"

namespace WPEFramework
{
namespace Plugin
{

class HdcpProfileImplementation : public Exchange::IHdcpProfile, public Exchange::IConfiguration
class HdcpProfileImplementation : public Exchange::IHdcpProfile, public Exchange::IConfiguration, public device::Host::IVideoOutputPortEvents, public device::Host::IDisplayDeviceEvents
// , public Exchange::IConfiguration
{
public:
// We do not allow this plugin to be copied !!
HdcpProfileImplementation();
~HdcpProfileImplementation() override;


virtual void OnDisplayHDMIHotPlug(dsDisplayEvent_t displayEvent) override;
virtual void OnHDCPStatusChange(dsHdcpStatus_t hdcpStatus) override;

static HdcpProfileImplementation *instance(HdcpProfileImplementation *HdcpProfileImpl = nullptr);

// We do not allow this plugin to be copied !!
Expand Down Expand Up @@ -110,18 +113,22 @@


public:
template <typename T>
T* baseInterface()
{
static_assert(std::is_base_of<T, HdcpProfileImplementation>(), "base type mismatch");
return static_cast<T*>(this);
}

Core::hresult Register(Exchange::IHdcpProfile::INotification *notification) override;
Core::hresult Unregister(Exchange::IHdcpProfile::INotification *notification) override;

Core::hresult GetHDCPStatus(HDCPStatus& hdcpstatus,bool& success) override;
Core::hresult GetSettopHDCPSupport(string& supportedHDCPVersion,bool& isHDCPSupported,bool& success) override;
bool GetHDCPStatusInternal(HDCPStatus& hdcpstatus);
void InitializePowerManager(PluginHost::IShell *service);
void InitializeIARM();
void DeinitializeIARM();
static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
void onHdmiOutputHotPlug(int connectStatus);
void onHdmiOutputHDCPStatusEvent(int);
void onHdmiOutputHotPlug(dsDisplayEvent_t connectStatus);
void onHdmiOutputHDCPStatusEvent(dsHdcpStatus_t);
void logHdcpStatus (const char *trigger, HDCPStatus& status);
void onHdcpProfileDisplayConnectionChanged();
static PowerManagerInterfaceRef _powerManagerPlugin;
Expand All @@ -143,4 +150,4 @@
};

} // namespace Plugin
} // namespace WPEFramework
} // namespace WPEFramework
Loading