37
37
#include " UtilssyncPersistFile.h"
38
38
#include " UtilsSearchRDKProfile.h"
39
39
40
- #define HDMICECSOURCE_METHOD_SET_ENABLED " setEnabled"
41
- #define HDMICECSOURCE_METHOD_GET_ENABLED " getEnabled"
42
- #define HDMICECSOURCE_METHOD_OTP_SET_ENABLED " setOTPEnabled"
43
- #define HDMICECSOURCE_METHOD_OTP_GET_ENABLED " getOTPEnabled"
44
- #define HDMICECSOURCE_METHOD_SET_OSD_NAME " setOSDName"
45
- #define HDMICECSOURCE_METHOD_GET_OSD_NAME " getOSDName"
46
- #define HDMICECSOURCE_METHOD_SET_VENDOR_ID " setVendorId"
47
- #define HDMICECSOURCE_METHOD_GET_VENDOR_ID " getVendorId"
48
- #define HDMICECSOURCE_METHOD_PERFORM_OTP_ACTION " performOTPAction"
49
- #define HDMICECSOURCE_METHOD_SEND_STANDBY_MESSAGE " sendStandbyMessage"
50
- #define HDMICECSOURCE_METHOD_GET_ACTIVE_SOURCE_STATUS " getActiveSourceStatus"
51
40
#define HDMICECSOURCE_METHOD_SEND_KEY_PRESS " sendKeyPressEvent"
52
41
#define HDMICEC_EVENT_ON_DEVICES_CHANGED " onDevicesChanged"
53
42
#define HDMICEC_EVENT_ON_HDMI_HOT_PLUG " onHdmiHotPlug"
@@ -116,13 +105,9 @@ namespace WPEFramework
116
105
static int libcecInitStatus = 0 ;
117
106
118
107
HdmiCecSource::HdmiCecSource ()
119
- : PluginHost::JSONRPC(),cecEnableStatus(false ),smConnection(nullptr ), m_sendKeyEventThreadRun(false )
120
- , _pwrMgrNotification(*this )
121
- , _registeredEventHandlers(false )
108
+ : PluginHost::JSONRPC(),
122
109
{
123
110
LOGWARN (" ctor" );
124
- _engine = Core::ProxyType<RPC::InvokeServerType<1 , 0 , 4 >>::Create ();
125
- _communicatorClient = Core::ProxyType<RPC::CommunicatorClient>::Create (Core::NodeId (" /tmp/communicator" ), Core::ProxyType<Core::IIPCServer>(_engine));
126
111
}
127
112
128
113
HdmiCecSource::~HdmiCecSource ()
@@ -134,8 +119,6 @@ namespace WPEFramework
134
119
{
135
120
LOGWARN (" Initlaizing CEC_2" );
136
121
uint32_t res = Core::ERROR_GENERAL;
137
- PowerState pwrStateCur = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
138
- PowerState pwrStatePrev = WPEFramework::Exchange::IPowerManager::POWER_STATE_UNKNOWN;
139
122
140
123
profileType = searchRdkProfile ();
141
124
@@ -147,98 +130,21 @@ namespace WPEFramework
147
130
148
131
string msg;
149
132
HdmiCecSource::_instance = this ;
150
- smConnection = NULL ;
151
- cecEnableStatus = false ;
152
133
_hdmiCecSource = _service->Root <Exchange::IHdmiCecSource>(_connectionId, 5000 , _T (" HdmiCecSourceImplementation" ));
153
134
154
135
if (nullptr != _hdmiCecSource)
155
- {
136
+ {
137
+ _hdmiCecSource->Configure ();
156
138
_hdmiCecSource->Register (&_hdmiCecSourceNotification);
157
- }
158
- else
159
- {
139
+ msg = " HdmiCecSource plugin is available" ;
140
+ LOGINFO (" HdmiCecSource plugin is available. Successfully activated HdmiCecSource Plugin" );
141
+ }
142
+ else
143
+ {
160
144
msg = " HdmiCecSource plugin is not available" ;
161
- LOGERR (" HdmiCecSource plugin is not available. Failed to activate HdmiCecSource Plugin" );
145
+ LOGINFO (" HdmiCecSource plugin is not available. Failed to activate HdmiCecSource Plugin" );
162
146
return msg;
163
- }
164
- Register (HDMICECSOURCE_METHOD_SET_ENABLED, &HdmiCecSource::setEnabledWrapper, this );
165
- Register (HDMICECSOURCE_METHOD_GET_ENABLED, &HdmiCecSource::getEnabledWrapper, this );
166
- Register (HDMICECSOURCE_METHOD_OTP_SET_ENABLED, &HdmiCecSource::setOTPEnabledWrapper, this );
167
- Register (HDMICECSOURCE_METHOD_OTP_GET_ENABLED, &HdmiCecSource::getOTPEnabledWrapper, this );
168
- Register (HDMICECSOURCE_METHOD_SET_OSD_NAME, &HdmiCecSource::setOSDNameWrapper, this );
169
- Register (HDMICECSOURCE_METHOD_GET_OSD_NAME, &HdmiCecSource::getOSDNameWrapper, this );
170
- Register (HDMICECSOURCE_METHOD_SET_VENDOR_ID, &HdmiCecSource::setVendorIdWrapper, this );
171
- Register (HDMICECSOURCE_METHOD_GET_VENDOR_ID, &HdmiCecSource::getVendorIdWrapper, this );
172
- Register (HDMICECSOURCE_METHOD_PERFORM_OTP_ACTION, &HdmiCecSource::performOTPActionWrapper, this );
173
- Register (HDMICECSOURCE_METHOD_SEND_STANDBY_MESSAGE, &HdmiCecSource::sendStandbyMessageWrapper, this );
174
- Register (HDMICECSOURCE_METHOD_GET_ACTIVE_SOURCE_STATUS, &HdmiCecSource::getActiveSourceStatusWrapper, this );
175
- Register (HDMICECSOURCE_METHOD_SEND_KEY_PRESS,&HdmiCecSource::sendRemoteKeyPressWrapper,this );
176
- Register (" getDeviceList" , &HdmiCecSource::getDeviceList, this );
177
- if (Utils::IARM::init ()) {
178
-
179
-
180
- // Initialize cecEnableStatus to false in ctor
181
- cecEnableStatus = false ;
182
-
183
- logicalAddressDeviceType = " None" ;
184
- logicalAddress = 0xFF ;
185
-
186
- // CEC plugin functionalities will only work if CECmgr is available. If plugin Initialize failure upper layer will call dtor directly.
187
- InitializeIARM ();
188
- InitializePowerManager ();
189
-
190
- // load persistence setting
191
- loadSettings ();
192
-
193
- try
194
- {
195
- // TODO(MROLLINS) this is probably per process so we either need to be running in our own process or be carefull no other plugin is calling it
196
- device::Manager::Initialize ();
197
- std::string strVideoPort = device::Host::getInstance ().getDefaultVideoPortName ();
198
- device::VideoOutputPort vPort = device::Host::getInstance ().getVideoOutputPort (strVideoPort.c_str ());
199
- if (vPort.isDisplayConnected ())
200
- {
201
- std::vector<uint8_t > edidVec;
202
- vPort.getDisplay ().getEDIDBytes (edidVec);
203
- // Set LG vendor id if connected with LG TV
204
- if (edidVec.at (8 ) == 0x1E && edidVec.at (9 ) == 0x6D )
205
- {
206
- isLGTvConnected = true ;
207
- }
208
- LOGINFO (" manufacturer byte from edid :%x: %x isLGTvConnected :%d" ,edidVec.at (8 ),edidVec.at (9 ),isLGTvConnected);
209
- }
210
- }
211
- catch (...)
212
- {
213
- LOGWARN (" Exception in getting edid info .\r\n " );
214
- }
215
-
216
- // get power state:
217
- ASSERT (_powerManagerPlugin);
218
- if (_powerManagerPlugin){
219
- res = _powerManagerPlugin->GetPowerState (pwrStateCur, pwrStatePrev);
220
- if (Core::ERROR_NONE == res)
221
- {
222
- powerState = (pwrStateCur == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON)?0 :1 ;
223
- LOGINFO (" Current state is PowerManagerPlugin: (%d) powerState :%d \n " ,pwrStateCur,powerState);
224
- }
225
- }
226
-
227
- if (cecSettingEnabled)
228
- {
229
- try
230
- {
231
- CECEnable ();
232
- }
233
- catch (...)
234
- {
235
- LOGWARN (" Exception while enabling CEC settings .\r\n " );
236
- }
237
- }
238
- } else {
239
- msg = " IARM bus is not available" ;
240
- LOGERR (" IARM bus is not available. Failed to activate HdmiCecSource Plugin" );
241
- }
147
+ }
242
148
243
149
// On success return empty, to indicate there is no error text.
244
150
return msg;
@@ -280,7 +186,6 @@ namespace WPEFramework
280
186
isDeviceActiveSource = false ;
281
187
HdmiCecSource::_instance->sendActiveSourceEvent ();
282
188
HdmiCecSource::_instance = nullptr ;
283
- smConnection = NULL ;
284
189
285
190
DeinitializeIARM ();
286
191
}
@@ -322,179 +227,5 @@ namespace WPEFramework
322
227
sendNotify (HDMICEC_EVENT_ON_STANDBY_MSG_RECEIVED, params);
323
228
}
324
229
325
- uint32_t HdmiCecSource::setEnabledWrapper (const JsonObject& parameters, JsonObject& response)
326
- {
327
- LOGINFOMETHOD ();
328
-
329
- bool enabled = false ;
330
-
331
- if (parameters.HasLabel (" enabled" ))
332
- {
333
- getBoolParameter (" enabled" , enabled);
334
- }
335
- else
336
- {
337
- returnResponse (false );
338
- }
339
-
340
- HdmiCecSource::_hdmiCecSource->SetEnabled (enabled,true );
341
- returnResponse (true );
342
- }
343
-
344
- uint32_t HdmiCecSource::getEnabledWrapper (const JsonObject& parameters, JsonObject& response)
345
- {
346
- bool enabled;
347
- HdmiCecSource::_hdmiCecSource->GetEnabled (&enabled);
348
- response[" enabled" ] = enabled;
349
- returnResponse (true );
350
- }
351
- uint32_t HdmiCecSource::setOTPEnabledWrapper (const JsonObject& parameters, JsonObject& response)
352
- {
353
- LOGINFOMETHOD ();
354
-
355
- bool enabled = false ;
356
-
357
- if (parameters.HasLabel (" enabled" ))
358
- {
359
- getBoolParameter (" enabled" , enabled);
360
- }
361
- else
362
- {
363
- returnResponse (false );
364
- }
365
-
366
- HdmiCecSource::_hdmiCecSource->SetOTPEnabled (enabled);
367
- returnResponse (true );
368
- }
369
-
370
- uint32_t HdmiCecSource::getOTPEnabledWrapper (const JsonObject& parameters, JsonObject& response)
371
- {
372
- bool enabled;
373
- HdmiCecSource::_hdmiCecSource->GetOTPEnabled (&enabled);
374
- response[" enabled" ] = enabled;
375
- returnResponse (true );
376
- }
377
-
378
- uint32_t HdmiCecSource::setOSDNameWrapper (const JsonObject& parameters, JsonObject& response)
379
- {
380
- LOGINFOMETHOD ();
381
-
382
- if (parameters.HasLabel (" name" ))
383
- {
384
- std::string osd = parameters[" name" ].String ();
385
- LOGINFO (" setOSDNameWrapper osdName: %s" ,osd.c_str ());
386
- HdmiCecSource::_hdmiCecSource->SetOSDName (osd);
387
- }
388
- else
389
- {
390
- returnResponse (false );
391
- }
392
- returnResponse (true );
393
- }
394
-
395
- uint32_t HdmiCecSource::getOSDNameWrapper (const JsonObject& parameters, JsonObject& response)
396
- {
397
- std::string osdName;
398
- HdmiCecSource::_hdmiCecSource->GetOSDName (&osdName);
399
- response[" name" ] = osdName;
400
- LOGINFO (" getOSDNameWrapper osdName : %s \n " ,osdName.c_str ());
401
- returnResponse (true );
402
- }
403
-
404
- uint32_t HdmiCecSource::setVendorIdWrapper (const JsonObject& parameters, JsonObject& response)
405
- {
406
- LOGINFOMETHOD ();
407
-
408
- if (parameters.HasLabel (" vendorid" ))
409
- {
410
- std::string id = parameters[" vendorid" ].String ();
411
-
412
- LOGINFO (" setVendorIdWrapper vendorId: %s" ,id.c_str ());
413
- HdmiCecSource::_hdmiCecSource->SetVendorId (id);
414
- }
415
- else
416
- {
417
- returnResponse (false );
418
- }
419
- returnResponse (true );
420
- }
421
-
422
- uint32_t HdmiCecSource::getVendorIdWrapper (const JsonObject& parameters, JsonObject& response)
423
- {
424
- std::string vendorId;
425
- HdmiCecSource::_hdmiCecSource->GetVendorId (&vendorId);
426
- response[" vendorid" ] = vendorId.toString ();
427
- returnResponse (true );
428
- }
429
-
430
-
431
- uint32_t HdmiCecSource::performOTPActionWrapper (const JsonObject& parameters, JsonObject& response)
432
- {
433
- if (HdmiCecSource::_hdmiCecSource->PerformOTPAction () == Core::ERROR_NONE)
434
- {
435
- returnResponse (true );
436
- }
437
- else
438
- {
439
- returnResponse (false );
440
- }
441
- }
442
-
443
- uint32_t HdmiCecSource::sendStandbyMessageWrapper (const JsonObject& parameters, JsonObject& response)
444
- {
445
- if (HdmiCecSource::_hdmiCecSource->SendStandbyMessage () == Core::ERROR_NONE)
446
- {
447
- returnResponse (true );
448
- }
449
- else
450
- {
451
- returnResponse (false );
452
- }
453
- }
454
-
455
-
456
- uint32_t HdmiCecSource::sendRemoteKeyPressWrapper (const JsonObject& parameters, JsonObject& response)
457
- {
458
- returnIfParamNotFound (parameters, " logicalAddress" );
459
- returnIfParamNotFound (parameters, " keyCode" );
460
- string logicalAddress = parameters[" logicalAddress" ].String ();
461
- string keyCode = parameters[" keyCode" ].String ();
462
- HdmiCecSource::_hdmiCecSource->sendRemoteKeyPress (logicalAddress, keyCode);
463
-
464
- }
465
-
466
- uint32_t HdmiCecSource::GetActiveSourceStatusWrapper (const JsonObject& parameters, JsonObject& response)
467
- {
468
- bool isActiveSource;
469
- HdmiCecSource::_hdmiCecSource->GetActiveSourceStatus (&isActiveSource);
470
- response[" isActiveSource" ] = isActiveSource;
471
- returnResponse (true );
472
- }
473
-
474
- uint32_t HdmiCecSource::getDeviceList (const JsonObject& parameters, JsonObject& response)
475
- {
476
- Exchange::IHdmiCecSource::IHdmiCecSourceDeviceListIterator* devices = nullptr ;
477
- uint32_t result = HdmiCecSource::_hdmiCecSource->getDeviceList (devices);
478
- if (result == Core::ERROR_NONE && devices != nullptr )
479
- {
480
- JsonArray deviceArray;
481
- while (devices->Next ())
482
- {
483
- Exchange::HdmiCecSourceDevices device;
484
- devices->Current (device);
485
-
486
- JsonObject deviceJson;
487
- deviceJson[" logicalAddress" ] = device.logicalAddress ;
488
- deviceJson[" osdName" ] = device.osdName ;
489
- deviceJson[" vendorID" ] = device.vendorID ;
490
-
491
- deviceArray.Add (deviceJson);
492
- }
493
- response[" devices" ] = deviceArray;
494
- devices->Release ();
495
- }
496
- returnResponse (result);
497
- }
498
-
499
230
} // namespace Plugin
500
231
} // namespace WPEFramework
0 commit comments