31 #include "AampUtils.h"
34 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
36 #include <core/core.h>
37 #include <websocket/websocket.h>
40 using namespace WPEFramework;
42 #define RDKSHELL_CALLSIGN "org.rdk.RDKShell.1"
44 #define UHD_4K_WIDTH 3840
45 #define UHD_4K_HEIGHT 2160
54 AAMPLOG_WARN(
"%s Function not implemented",mName.c_str());
62 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
77 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
78 ,thunderAccessObj(callSign, logObj),
79 thunderRDKShellObj(RDKSHELL_CALLSIGN, logObj)
82 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
83 AAMPLOG_WARN(
"%s Constructor",mName.c_str());
84 thunderAccessObj.ActivatePlugin();
93 AAMPLOG_WARN(
"%s destructor",mName.c_str());
94 for (
auto const& evtName : mRegisteredEvents) {
95 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
96 thunderAccessObj.UnSubscribeEvent(_T(evtName));
99 mRegisteredEvents.clear();
107 AAMPLOG_WARN(
"%s Function not implemented",mName.c_str());
115 AAMPLOG_WARN(
"%s method:%s port:%d",mName.c_str(),methodName.c_str(),port);
117 videoInputPort = port;
118 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
121 param[
"portId"] = videoInputPort;
122 thunderAccessObj.InvokeJSONRPC(methodName, param, result);
131 if( videoInputPort>=0 )
133 AAMPLOG_WARN(
"%s method:%s",mName.c_str(),methodName.c_str());
135 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
138 thunderAccessObj.InvokeJSONRPC(methodName, param, result);
150 AAMPLOG_WARN(
"%s Function not implemented",mName.c_str());
154 bool StreamAbstractionAAMP_VIDEOIN::GetScreenResolution(
int & screenWidth,
int & screenHeight)
156 #ifndef USE_CPP_THUNDER_PLUGIN_ACCESS
161 bool bRetVal =
false;
163 if( thunderRDKShellObj.InvokeJSONRPC(
"getScreenResolution", param, result) )
165 screenWidth = result[
"w"].Number();
166 screenHeight = result[
"h"].Number();
167 AAMPLOG_INFO(
"%s screenWidth:%d screenHeight:%d ",mName.c_str(),screenWidth, screenHeight);
179 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
181 int screenHeight = 0;
182 float width_ratio = 1.0, height_ratio = 1.0;
183 if(GetScreenResolution(screenWidth,screenHeight))
186 if((0 != screenWidth) && (0 != screenHeight))
188 width_ratio = UHD_4K_WIDTH / screenWidth;
189 height_ratio = UHD_4K_HEIGHT / screenHeight;
195 param[
"x"] = (int) (x * width_ratio);
196 param[
"y"] = (int) (y * height_ratio);
197 param[
"w"] = (int) (w * width_ratio);
198 param[
"h"] = (int) (h * height_ratio);
199 AAMPLOG_WARN(
"%s x:%d y:%d w:%d h:%d w-ratio:%f h-ratio:%f",mName.c_str(),x,y,w,h,width_ratio,height_ratio);
200 thunderAccessObj.InvokeJSONRPC(
"setVideoRectangle", param, result);
209 AAMPLOG_WARN(
"%s Function not implemented",mName.c_str());
218 AAMPLOG_WARN(
"%s ",mName.c_str());
229 AAMPLOG_WARN(
"%s ",mName.c_str());
238 AAMPLOG_WARN(
"%s ",mName.c_str());
247 AAMPLOG_WARN(
"%s ",mName.c_str());
256 AAMPLOG_WARN(
"%s ",mName.c_str());
265 AAMPLOG_WARN(
"%s ",mName.c_str());
274 AAMPLOG_WARN(
"%s ",mName.c_str());
283 AAMPLOG_WARN(
"%s ",mName.c_str());
292 AAMPLOG_WARN(
"%s ",mName.c_str());
301 AAMPLOG_WARN(
"%s ",mName.c_str());
302 return std::vector<long>();
310 AAMPLOG_WARN(
"%s ",mName.c_str());
319 AAMPLOG_WARN(
"%s ",mName.c_str());
320 return std::vector<long>();
328 AAMPLOG_WARN(
"%s ",mName.c_str());
336 AAMPLOG_WARN(
"%s ",mName.c_str());
341 #ifdef USE_CPP_THUNDER_PLUGIN_ACCESS
346 void StreamAbstractionAAMP_VIDEOIN::RegisterEvent (
string eventName, std::function<
void(
const WPEFramework::Core::JSON::VariantContainer&)> functionHandler)
349 bSubscribed = thunderAccessObj.SubscribeEvent(_T(eventName), functionHandler);
352 mRegisteredEvents.push_back(eventName);
359 void StreamAbstractionAAMP_VIDEOIN::RegisterAllEvents ()
361 std::function<void(
const WPEFramework::Core::JSON::VariantContainer&)> inputStatusChangedMethod = std::bind(&StreamAbstractionAAMP_VIDEOIN::OnInputStatusChanged,
this, std::placeholders::_1);
363 RegisterEvent(
"onInputStatusChanged",inputStatusChangedMethod);
365 std::function<void(
const WPEFramework::Core::JSON::VariantContainer&)> signalChangedMethod = std::bind(&StreamAbstractionAAMP_VIDEOIN::OnSignalChanged,
this, std::placeholders::_1);
367 RegisterEvent(
"onSignalChanged",signalChangedMethod);
374 void StreamAbstractionAAMP_VIDEOIN::OnInputStatusChanged(
const JsonObject& parameters)
377 parameters.ToString(message);
378 AAMPLOG_WARN(
"%s",message.c_str());
380 std::string strStatus = parameters[
"status"].String();
382 if(0 == strStatus.compare(
"started"))
392 else if(0 == strStatus.compare(
"stopped"))
401 void StreamAbstractionAAMP_VIDEOIN::OnSignalChanged (
const JsonObject& parameters)
404 parameters.ToString(message);
405 AAMPLOG_WARN(
"%s",message.c_str());
407 std::string strReason;
408 std::string strStatus = parameters[
"signalStatus"].String();
410 if(0 == strStatus.compare(
"noSignal"))
412 strReason =
"NO_SIGNAL";
414 else if (0 == strStatus.compare(
"unstableSignal"))
416 strReason =
"UNSTABLE_SIGNAL";
418 else if (0 == strStatus.compare(
"notSupportedSignal"))
420 strReason =
"NOT_SUPPORTED_SIGNAL";
422 else if (0 == strStatus.compare(
"stableSignal"))
430 if(!strReason.empty())
432 AAMPLOG_WARN(
"GENERATING BLOCKED EVNET :%s",strReason.c_str());