Skip to content
This repository was archived by the owner on Jan 26, 2023. It is now read-only.
/ rdk-aamp Public archive

Commit c7d3338

Browse files
deepa_jacobjsubra057
deepa_jacob
authored andcommitted
RDK-29431 : Plugin calls added
Reason for change: Added MediaPlayer and Hdmiin plugin calls and event handler using direct jsonrpc method. Test Procedure: Pending testing Risks: Low Signed-off-by:[email protected] Change-Id: I2a09fa28d04bf5c779bd98a09217d4c4d1b538b0 AMLOGIC-588 : [CAD1.0][ATSC] scaling/placement incorrect when video not placed fullscreen Reason for change: MediaPlayer -> setVideoRectangle requires Screen width and height Screen size is retrived from RdkShell plugin and passed to mediplayer along with expected x,y,w,h of video window Test Procedure: atsc_test html app used to test scalling of videowindow from ATSC playback. Risks: Low Signed-off-by: shripad bankar <[email protected]> Change-Id: Ia1a6c0ca354fa313c2faf07dd8bc0e13eea684c5 AMLOGIC-588 : Separate plugin activation Reason for change: Seperate plugin activation from remote object creation. Test Procedure: Test OTA and hdmiin APIs Risks: Low Signed-off-by:[email protected] Change-Id: If3255a67c32fccbf018f274e4353142f275611fd RDK-29431 : Variable init fixes Reason for change: Added variable initialization fixes. Test Procedure: Test OTA video and events Risks: Low Signed-off-by:[email protected] Change-Id: Idd136733ef8d2129e389c844641369c82150f3b5 RDK-29431 : Event handler modified for OTA Reason for change: Event handler modified for OTA. PREPARED event sequence changed for OTA. Test Procedure: Test OTA video events Risks: Low Signed-off-by:[email protected] Change-Id: Ia89b5dce089223defa4c137142564cbbc4636583
1 parent b5e044c commit c7d3338

10 files changed

+966
-171
lines changed

CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ pkg_check_modules(LIBDASH REQUIRED libdash)
3737
pkg_check_modules(OPENSSL REQUIRED openssl)
3838
pkg_check_modules(LIBCJSON REQUIRED libcjson)
3939

40+
if (CMAKE_WPEFRAMEWORK_REQUIRED)
41+
message("CMAKE_WPEFRAMEWORK_REQUIRED set")
42+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
43+
find_package(WPEFramework REQUIRED)
44+
if (WPEFRAMEWORK_FOUND)
45+
message("WPEFRAMEWORK_FOUND = ${WPEFRAMEWORK_FOUND}")
46+
include_directories(${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${WPEFRAMEWORK_INCLUDE_DIRS})
47+
else()
48+
message(FATAL_ERROR "WPEFrameworkProtocols not found")
49+
endif()
50+
endif()
51+
4052
if(CMAKE_QT5WEBKIT_JSBINDINGS)
4153
message("CMAKE_QT5WEBKIT_JSBINDINGS set, require Qt5WebKit")
4254
pkg_check_modules(Qt5WebKit REQUIRED Qt5WebKit)
@@ -118,6 +130,9 @@ set(LIBAAMP_SOURCES iso639map.cpp
118130
isobmff/isobmffprocessor.cpp
119131
drm/helper/AampDrmHelper.cpp
120132
)
133+
if (CMAKE_WPEFRAMEWORK_REQUIRED)
134+
set(LIBAAMP_SOURCES ${LIBAAMP_SOURCES} ThunderAccess.cpp)
135+
endif()
121136

122137
if(CMAKE_CONTENT_METADATA_IPDVR_ENABLED)
123138
message("CMAKE_CONTENT_METADATA_IPDVR_ENABLED set")
@@ -403,6 +418,10 @@ endif()
403418
message("LIB_AAMP_DEPENDS is ${LIBAAMP_DEPENDS}")
404419

405420
target_link_libraries(aamp ${LIBAAMP_DEPENDS})
421+
if (CMAKE_WPEFRAMEWORK_REQUIRED)
422+
set(LIBAAMP_DEFINES "${LIBAAMP_DEFINES} -DUSE_CPP_THUNDER_PLUGIN_ACCESS")
423+
target_link_libraries(aamp ${WPEFRAMEWORK_LIBRARIES})
424+
endif()
406425
target_link_libraries(aamp-cli aamp ${AAMP_CLI_LD_FLAGS})
407426

408427
set_target_properties(aamp PROPERTIES COMPILE_FLAGS "${LIBAAMP_DEFINES} ${OS_CXX_FLAGS}")

ThunderAccess.cpp

+220
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
/*
2+
* If not stated otherwise in this file or this component's license file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2018 RDK Management
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
/**
21+
* @file ThunderAccess.cpp
22+
* @brief wrapper class for accessing thunder plugins
23+
*/
24+
#include "priv_aamp.h"
25+
#include <core/core.h>
26+
#include <websocket/websocket.h>
27+
#include <securityagent/SecurityTokenUtil.h>
28+
#include <ThunderAccess.h>
29+
30+
using namespace std;
31+
using namespace WPEFramework;
32+
33+
#define SERVER_DETAILS "127.0.0.1:9998"
34+
#define MAX_LENGTH 1024
35+
36+
/**
37+
* @brief ThunderAccessAAMP constructor
38+
* @note Security tocken accusition, controller object creation
39+
* @param NA
40+
* @retval NA
41+
* @retval NA
42+
*/
43+
ThunderAccessAAMP::ThunderAccessAAMP(std::string callsign)
44+
: remoteObject(NULL),
45+
controllerObject(NULL),
46+
query(""),
47+
pluginCallsign(callsign)
48+
{
49+
AAMPLOG_INFO( "[ThunderAccessAAMP]Inside %s ", __FUNCTION__ );
50+
51+
int ret = 0;
52+
uint32_t status = Core::ERROR_NONE;
53+
unsigned char buffer[MAX_LENGTH] = {0};
54+
55+
Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS)));
56+
57+
ret = GetSecurityToken(MAX_LENGTH,buffer);
58+
if(ret > 0){
59+
AAMPLOG_INFO( "[ThunderAccessAAMP] %s : GetSecurityToken success", __FUNCTION__ );
60+
}
61+
else{
62+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : GetSecurityToken failed", __FUNCTION__ );
63+
}
64+
65+
if (NULL == controllerObject) {
66+
string sToken = (char*)buffer;
67+
query = "token=" + sToken;
68+
69+
/*Passing empty string instead of Controller callsign.This is assumed as controller plugin.*/
70+
//controllerObject = new JSONRPC::LinkType<Core::JSON::IElement>(_T(""), _T(""), false, query);
71+
/*To Do: Need to switch to above line once auth token is required*/
72+
controllerObject = new JSONRPC::LinkType<Core::JSON::IElement>(_T(""));
73+
if (NULL == controllerObject) {
74+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : Controller object creation failed", __FUNCTION__ );
75+
} else {
76+
AAMPLOG_INFO( "[ThunderAccessAAMP] %s : Controller object creation success", __FUNCTION__ );
77+
}
78+
}
79+
80+
//remoteObject = new JSONRPC::LinkType<Core::JSON::IElement>(_T(pluginCallsign), _T(""), false, query);
81+
/*To Do: Need to switch to above line once auth token is required*/
82+
remoteObject = new JSONRPC::LinkType<Core::JSON::IElement>(_T(pluginCallsign), _T(""));
83+
if (NULL == remoteObject) {
84+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : %s Client initialization failed", __FUNCTION__, pluginCallsign.c_str());
85+
ret = false;
86+
} else {
87+
AAMPLOG_INFO( "[ThunderAccessAAMP] %s : %s Client initialization success", __FUNCTION__, pluginCallsign.c_str());
88+
}
89+
}
90+
91+
/**
92+
* @brief ThunderAccessAAMP destructor
93+
* @note clean up
94+
* @param NA
95+
* @retval NA
96+
* @retval NA
97+
*/
98+
ThunderAccessAAMP::~ThunderAccessAAMP()
99+
{
100+
if(NULL != controllerObject)
101+
{
102+
delete controllerObject;
103+
controllerObject = NULL;
104+
}
105+
if(NULL != remoteObject)
106+
{
107+
delete remoteObject;
108+
remoteObject = NULL;
109+
}
110+
}
111+
112+
/**
113+
* @brief ActivatePlugin
114+
* @note Plugin activation and Remote object creation
115+
* @param Plugin Callsign
116+
* @retval true on success
117+
* @retval false on failure
118+
*/
119+
bool ThunderAccessAAMP::ActivatePlugin()
120+
{
121+
bool ret = true;
122+
JsonObject result;
123+
JsonObject controlParam;
124+
std::string response;
125+
126+
if (NULL != controllerObject) {
127+
controlParam["callsign"] = pluginCallsign;
128+
if (Core::ERROR_NONE == controllerObject->Invoke<JsonObject, JsonObject>(1000, _T("activate"), controlParam, result)){
129+
result.ToString(response);
130+
AAMPLOG_INFO( "[ThunderAccessAAMP] %s plugin Activated. Response : %s ", pluginCallsign.c_str(), response.c_str());
131+
}
132+
} else {
133+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : Controller Object NULL ", __FUNCTION__);
134+
ret = false;
135+
}
136+
137+
return ret;
138+
}
139+
140+
/**
141+
* @brief subscribeEvent
142+
* @note Subscribe event data for the specific plugin
143+
* @param Event name, Event handler
144+
* @retval true on success
145+
* @retval false on failure
146+
*/
147+
/*To Do: Only JSON Object can be used as parameter now*/
148+
bool ThunderAccessAAMP::SubscribeEvent (string eventName, std::function<void(const WPEFramework::Core::JSON::VariantContainer&)> functionHandler)
149+
{
150+
bool ret = true;
151+
if (NULL != remoteObject) {
152+
if (remoteObject->Subscribe<JsonObject>(1000, _T(eventName), functionHandler) == Core::ERROR_NONE) {
153+
AAMPLOG_INFO( "[ThunderAccessAAMP] %s : Subscribed to : %s", __FUNCTION__, eventName.c_str());
154+
} else {
155+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : Failed to Subscribe notification handler for : %s", __FUNCTION__, eventName.c_str());
156+
}
157+
} else {
158+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : remoteObject not created for the plugin!", __FUNCTION__ );
159+
ret = false;
160+
}
161+
return ret;
162+
}
163+
164+
/**
165+
* @brief unSubscribeEvent
166+
* @note unSubscribe event data for the specific plugin
167+
* @param Event name
168+
* @retval true on success
169+
* @retval false on failure
170+
*/
171+
/*To Do: Only JSON Object can be used as parameter now*/
172+
bool ThunderAccessAAMP::UnSubscribeEvent (string eventName)
173+
{
174+
bool ret = true;
175+
if (NULL != remoteObject) {
176+
remoteObject->Unsubscribe(1000, _T(eventName));
177+
AAMPLOG_INFO( "[ThunderAccessAAMP] %s : UnSubscribed : %s event", __FUNCTION__, eventName.c_str());
178+
} else {
179+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : remoteObject not created for the plugin!", __FUNCTION__ );
180+
ret = false;
181+
}
182+
return ret;
183+
}
184+
185+
/**
186+
* @brief invokeJSONRPC
187+
* @note Invoke JSONRPC call for the plugin
188+
* @param Plugin method, reference to input pram and result
189+
* @retval true on success
190+
* @retval false on failure
191+
*/
192+
bool ThunderAccessAAMP::InvokeJSONRPC(std::string method, const JsonObject &param, JsonObject &result)
193+
{
194+
bool ret = true;
195+
std::string response;
196+
if(NULL == remoteObject)
197+
{
198+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : client not initialized! ", __FUNCTION__ );
199+
return false;
200+
}
201+
if (Core::ERROR_NONE == remoteObject->Invoke<JsonObject, JsonObject>(1000, _T(method), param, result))
202+
{
203+
if (result["success"].Boolean()) {
204+
result.ToString(response);
205+
AAMPLOG_INFO( "[ThunderAccessAAMP] %s success! Response : %s", method.c_str() , response.c_str());
206+
}
207+
else
208+
{
209+
result.ToString(response);
210+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s call failed! Response : %s", method.c_str() , response.c_str());
211+
ret = false;
212+
}
213+
}
214+
else
215+
{
216+
AAMPLOG_WARN( "[ThunderAccessAAMP] %s : invoke failed! ", method.c_str());
217+
ret = false;
218+
}
219+
return ret;
220+
}

ThunderAccess.h

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* If not stated otherwise in this file or this component's license file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2018 RDK Management
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
/**
21+
* @file ThunderAccess.h
22+
* @brief shim for dispatching UVE HDMI input playback
23+
*/
24+
25+
#ifndef THUNDERACCESS_H_
26+
#define THUNDERACCESS_H_
27+
28+
#include <core/core.h>
29+
#include <websocket/websocket.h>
30+
31+
using namespace std;
32+
using namespace WPEFramework;
33+
34+
/**
35+
* @class ThunderAccessAAMP
36+
* @brief Support Thunder Plugin Access from AAMP
37+
*/
38+
class ThunderAccessAAMP
39+
{
40+
public:
41+
ThunderAccessAAMP(std::string callsign);
42+
~ThunderAccessAAMP();
43+
44+
bool ActivatePlugin();
45+
bool InvokeJSONRPC(std::string method, const JsonObject &param, JsonObject &result);
46+
bool SubscribeEvent (string eventName, std::function<void(const WPEFramework::Core::JSON::VariantContainer&)> functionHandler);
47+
bool UnSubscribeEvent (string eventName);
48+
49+
private:
50+
/*The Remote object connected to specific Plugin*/
51+
JSONRPC::LinkType<Core::JSON::IElement> *remoteObject;
52+
/*The Remote object connected to controller Plugin*/
53+
JSONRPC::LinkType<Core::JSON::IElement> *controllerObject;
54+
/*For Authentication token*/
55+
string query;
56+
std::string pluginCallsign;
57+
};
58+
#endif // THUNDERACCESS_H_

0 commit comments

Comments
 (0)