Skip to content

Commit a70eda8

Browse files
RDKEMW-6166: Update HDCP Profile with libds client library notifications
1 parent 1ea0522 commit a70eda8

File tree

2 files changed

+40
-64
lines changed

2 files changed

+40
-64
lines changed

HdcpProfile/HdcpProfileImplementation.cpp

Lines changed: 24 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@
2525
#include "videoOutputPortConfig.hpp"
2626
#include "dsMgr.h"
2727
#include "manager.hpp"
28-
#include "host.hpp"
2928

3029
#include "UtilsJsonRpc.h"
31-
#include "UtilsIarm.h"
32-
33-
#include "UtilsSynchroIarm.hpp"
3430

3531
#define HDMI_HOT_PLUG_EVENT_CONNECTED 0
3632
#define HDMI_HOT_PLUG_EVENT_DISCONNECTED 1
@@ -61,14 +57,15 @@
6157
HdcpProfileImplementation::~HdcpProfileImplementation()
6258
{
6359
LOGINFO("Call HdcpProfileImplementation destructor\n");
60+
device::Host::getInstance().UnRegister(baseInterface<device::Host::IVideoOutputPortEvents>());
61+
device::Host::getInstance().UnRegister(baseInterface<device::Host::IDisplayDeviceEvents>());
6462
if (_powerManagerPlugin) {
6563
_powerManagerPlugin.Reset();
6664
}
6765
if(_service != nullptr)
6866
{
6967
_service->Release();
7068
}
71-
DeinitializeIARM();
7269
HdcpProfileImplementation::_instance = nullptr;
7370
mShell = nullptr;
7471
}
@@ -82,25 +79,6 @@
8279
.createInterface();
8380
}
8481

85-
void HdcpProfileImplementation::InitializeIARM()
86-
{
87-
Utils::IARM::init();
88-
89-
IARM_Result_t res;
90-
IARM_CHECK( Utils::Synchro::RegisterLockedIarmEventHandler<HdcpProfileImplementation>(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, dsHdmiEventHandler) );
91-
IARM_CHECK( Utils::Synchro::RegisterLockedIarmEventHandler<HdcpProfileImplementation>(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDCP_STATUS, dsHdmiEventHandler) );
92-
}
93-
94-
void HdcpProfileImplementation::DeinitializeIARM()
95-
{
96-
if (Utils::IARM::isConnected())
97-
{
98-
IARM_Result_t res;
99-
IARM_CHECK( Utils::Synchro::RemoveLockedEventHandler<HdcpProfileImplementation>(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, dsHdmiEventHandler) );
100-
IARM_CHECK( Utils::Synchro::RemoveLockedEventHandler<HdcpProfileImplementation>(IARM_BUS_DSMGR_NAME,IARM_BUS_DSMGR_EVENT_HDCP_STATUS, dsHdmiEventHandler) );
101-
}
102-
}
103-
10482
void HdcpProfileImplementation::onHdmiOutputHotPlug(int connectStatus)
10583
{
10684
if (HDMI_HOT_PLUG_EVENT_CONNECTED == connectStatus)
@@ -143,43 +121,33 @@
143121
onHdcpProfileDisplayConnectionChanged();
144122
}
145123

146-
void HdcpProfileImplementation::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
124+
void HdcpProfileImplementation::OnDisplayHDMIHotPlug(dsDisplayEvent_t displayEvent)
125+
{
126+
LOGINFO("Received OnDisplayHDMIHotPlug event data:%d \r\n", displayEvent);
127+
HdcpProfileImplementation::_instance->onHdmiOutputHotPlug(static_cast<int>(displayEvent));
128+
}
129+
130+
void HdcpProfileImplementation::OnHDCPStatusChange(dsHdcpStatus_t hdcpStatus)
147131
{
148132
uint32_t res = Core::ERROR_GENERAL;
149133
PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
150134
PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
151-
152-
if(!HdcpProfileImplementation::_instance)
153-
return;
154-
155-
if (IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG == eventId)
156-
{
157-
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
158-
int hdmi_hotplug_event = eventData->data.hdmi_hpd.event;
159-
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event data:%d \r\n", hdmi_hotplug_event);
160-
161-
HdcpProfileImplementation::_instance->onHdmiOutputHotPlug(hdmi_hotplug_event);
162-
}
163-
else if (IARM_BUS_DSMGR_EVENT_HDCP_STATUS == eventId)
164-
{
165-
ASSERT (_powerManagerPlugin);
166-
if (_powerManagerPlugin){
167-
res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev);
168-
if (Core::ERROR_NONE != res)
169-
{
170-
LOGWARN("Failed to Invoke RPC method: GetPowerState");
171-
}
172-
else
173-
{
174-
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
175-
int hdcpStatus = eventData->data.hdmi_hdcp.hdcpStatus;
176-
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDCP_STATUS event data:%d param.curState: %d \r\n", hdcpStatus,pwrStateCur);
177-
HdcpProfileImplementation::_instance->onHdmiOutputHDCPStatusEvent(hdcpStatus);
178-
}
135+
136+
ASSERT (_powerManagerPlugin);
137+
if (_powerManagerPlugin){
138+
res = _powerManagerPlugin->GetPowerState(pwrStateCur, pwrStatePrev);
139+
if (Core::ERROR_NONE != res)
140+
{
141+
LOGWARN("Failed to Invoke RPC method: GetPowerState");
142+
}
143+
else
144+
{
145+
LOGINFO("Received OnHDCPStatusChange event data:%d param.curState: %d \r\n", hdcpStatus,pwrStateCur);
146+
HdcpProfileImplementation::_instance->onHdmiOutputHDCPStatusEvent(static_cast<int>(hdcpStatus));
179147
}
180148
}
181149
}
182-
150+
183151
/**
184152
* Register a notification callback
185153
*/
@@ -243,7 +211,8 @@
243211
_service = service;
244212
_service->AddRef();
245213
ASSERT(service != nullptr);
246-
InitializeIARM();
214+
device::Host::getInstance().Register(baseInterface<device::Host::IVideoOutputPortEvents>(),"WPE[HdcpProfile]");
215+
device::Host::getInstance().Register(baseInterface<device::Host::IDisplayDeviceEvents>(),"WPE[HdcpProfile]");
247216
InitializePowerManager(service);
248217
return result;
249218
}

HdcpProfile/HdcpProfileImplementation.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,27 @@
2929
#include <core/core.h>
3030
#include <mutex>
3131
#include <vector>
32-
33-
#include "libIBus.h"
34-
32+
33+
#include "host.hpp"
34+
3535
#include "PowerManagerInterface.h"
3636

3737
namespace WPEFramework
3838
{
3939
namespace Plugin
4040
{
4141

42-
class HdcpProfileImplementation : public Exchange::IHdcpProfile, public Exchange::IConfiguration
42+
class HdcpProfileImplementation : public Exchange::IHdcpProfile, public Exchange::IConfiguration, public device::Host::IVideoOutputPortEvents, public device::Host::IDisplayDeviceEvents
4343
// , public Exchange::IConfiguration
4444
{
4545
public:
4646
// We do not allow this plugin to be copied !!
4747
HdcpProfileImplementation();
4848
~HdcpProfileImplementation() override;
49-
49+
50+
virtual void OnDisplayHDMIHotPlug(dsDisplayEvent_t displayEvent) override;
51+
virtual void OnHDCPStatusChange(dsHdcpStatus_t hdcpStatus) override;
52+
5053
static HdcpProfileImplementation *instance(HdcpProfileImplementation *HdcpProfileImpl = nullptr);
5154

5255
// We do not allow this plugin to be copied !!
@@ -110,16 +113,20 @@
110113

111114

112115
public:
116+
template <typename T>
117+
T* baseInterface()
118+
{
119+
static_assert(std::is_base_of<T, HdcpProfileImplementation>(), "base type mismatch");
120+
return static_cast<T*>(this);
121+
}
122+
113123
Core::hresult Register(Exchange::IHdcpProfile::INotification *notification) override;
114124
Core::hresult Unregister(Exchange::IHdcpProfile::INotification *notification) override;
115125

116126
Core::hresult GetHDCPStatus(HDCPStatus& hdcpstatus,bool& success) override;
117127
Core::hresult GetSettopHDCPSupport(string& supportedHDCPVersion,bool& isHDCPSupported,bool& success) override;
118128
bool GetHDCPStatusInternal(HDCPStatus& hdcpstatus);
119129
void InitializePowerManager(PluginHost::IShell *service);
120-
void InitializeIARM();
121-
void DeinitializeIARM();
122-
static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
123130
void onHdmiOutputHotPlug(int connectStatus);
124131
void onHdmiOutputHDCPStatusEvent(int);
125132
void logHdcpStatus (const char *trigger, HDCPStatus& status);
@@ -143,4 +150,4 @@
143150
};
144151

145152
} // namespace Plugin
146-
} // namespace WPEFramework
153+
} // namespace WPEFramework

0 commit comments

Comments
 (0)