removed deprecated methods and fields
[deb_libcec.git] / src / lib / LibCEC.cpp
CommitLineData
2abe74eb
LOK
1/*
2 * This file is part of the libCEC(R) library.
3 *
b492c10e 4 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
2abe74eb
LOK
5 * libCEC(R) is an original work, containing original code.
6 *
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
8 *
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 *
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
26 *
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
31 */
32
2b44051c 33#include "env.h"
2abe74eb
LOK
34#include "LibCEC.h"
35
2b44051c
LOK
36#include "adapter/AdapterFactory.h"
37#include "adapter/AdapterCommunication.h"
2abe74eb 38#include "CECProcessor.h"
0d800fe5 39#include "CECTypeUtils.h"
004b8382 40#include "devices/CECAudioSystem.h"
0f23c85c 41#include "devices/CECBusDevice.h"
004b8382
LOK
42#include "devices/CECPlaybackDevice.h"
43#include "devices/CECTV.h"
ba65909d
LOK
44#include "platform/util/timeutils.h"
45#include "platform/util/StdString.h"
c9d15485 46#include "platform/util/util.h"
2abe74eb 47
004b8382
LOK
48#include "CECClient.h"
49
2abe74eb
LOK
50using namespace std;
51using namespace CEC;
f00ff009 52using namespace PLATFORM;
2abe74eb 53
c9d15485 54//TODO replace deprecated constructor in 2.0
c30acafa
LOK
55CLibCEC::CLibCEC(const char *UNUSED(strDeviceName), cec_device_type_list UNUSED(types), uint16_t UNUSED(iPhysicalAddress) /* = 0 */) :
56 m_iStartTime(GetTimeMs()),
57 m_client(NULL)
58{
59 m_cec = new CCECProcessor(this);
60}
61
c9d15485 62//TODO replace deprecated constructor in 2.0
c30acafa
LOK
63CLibCEC::CLibCEC(libcec_configuration *UNUSED(configuration)) :
64 m_iStartTime(GetTimeMs()),
65 m_client(NULL)
caca2d81 66{
004b8382 67 m_cec = new CCECProcessor(this);
f8513317
LOK
68}
69
2abe74eb
LOK
70CLibCEC::~CLibCEC(void)
71{
c0152c09
LOK
72 // unregister all clients client
73 UnregisterClients();
74
75 // delete the adapter connection
c9d15485 76 DELETE_AND_NULL(m_cec);
2abe74eb
LOK
77}
78
b32ffd87 79bool CLibCEC::Open(const char *strPort, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
2abe74eb 80{
c0152c09 81 if (!m_cec || !strPort)
99aeafb9
LOK
82 return false;
83
c0152c09 84 // open a new connection
b32ffd87 85 if (!m_cec->Start(strPort, CEC_SERIAL_DEFAULT_BAUDRATE, iTimeoutMs))
2abe74eb
LOK
86 {
87 AddLog(CEC_LOG_ERROR, "could not start CEC communications");
88 return false;
89 }
90
c0152c09 91 // register all clients
004b8382
LOK
92 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
93 {
94 if (!m_cec->RegisterClient(*it))
95 {
96 AddLog(CEC_LOG_ERROR, "failed to register a CEC client");
97 return false;
98 }
99 }
100
2abe74eb
LOK
101 return true;
102}
103
104void CLibCEC::Close(void)
105{
af205cf4
LOK
106 if (!m_cec)
107 return;
108
c0152c09 109 // unregister all clients
af205cf4 110 m_cec->UnregisterClients();
c0152c09
LOK
111
112 // close the connection
af205cf4 113 m_cec->Close();
fa4798bd
LOK
114}
115
25701fa6 116int8_t CLibCEC::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */)
2abe74eb 117{
2b44051c 118 return CAdapterFactory(this).FindAdapters(deviceList, iBufSize, strDevicePath);
2abe74eb
LOK
119}
120
2abe74eb
LOK
121bool CLibCEC::StartBootloader(void)
122{
1113cb7d 123 return m_cec ? m_cec->StartBootloader() : false;
2abe74eb
LOK
124}
125
c0152c09 126bool CLibCEC::PingAdapter(void)
2abe74eb 127{
c0152c09 128 return m_client ? m_client->PingAdapter() : false;
2abe74eb
LOK
129}
130
c0152c09 131bool CLibCEC::EnableCallbacks(void *cbParam, ICECCallbacks *callbacks)
a9232a79 132{
c0152c09 133 return m_client ? m_client->EnableCallbacks(cbParam, callbacks) : false;
a9232a79
LOK
134}
135
c0152c09 136bool CLibCEC::GetCurrentConfiguration(libcec_configuration *configuration)
2abe74eb 137{
c0152c09 138 return m_client ? m_client->GetCurrentConfiguration(*configuration) : false;
2abe74eb
LOK
139}
140
c0152c09 141bool CLibCEC::SetConfiguration(const libcec_configuration *configuration)
28fa6c97 142{
c0152c09 143 return m_client ? m_client->SetConfiguration(*configuration) : false;
28fa6c97
LOK
144}
145
004b8382 146bool CLibCEC::CanPersistConfiguration(void)
1969b140 147{
c0152c09 148 return m_client ? m_client->CanPersistConfiguration() : false;
1969b140
LOK
149}
150
004b8382 151bool CLibCEC::PersistConfiguration(libcec_configuration *configuration)
8b7e5ff6 152{
c0152c09 153 return m_client ? m_client->PersistConfiguration(*configuration) : false;
8b7e5ff6
LOK
154}
155
004b8382 156void CLibCEC::RescanActiveDevices(void)
6a1c0009 157{
c0152c09
LOK
158 if (m_client)
159 m_client->RescanActiveDevices();
44c74256
LOK
160}
161
c0152c09 162bool CLibCEC::IsLibCECActiveSource(void)
eab72c40 163{
c0152c09 164 return m_client ? m_client->IsLibCECActiveSource() : false;
eab72c40
LOK
165}
166
004b8382 167bool CLibCEC::Transmit(const cec_command &data)
b4b1b49b 168{
2b44051c 169 return m_client ? m_client->Transmit(data, false) : false;
b4b1b49b
LOK
170}
171
004b8382 172bool CLibCEC::SetLogicalAddress(cec_logical_address iLogicalAddress)
b4b1b49b 173{
004b8382 174 return m_client ? m_client->SetLogicalAddress(iLogicalAddress) : false;
b4b1b49b
LOK
175}
176
004b8382 177bool CLibCEC::SetPhysicalAddress(uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
e55f3f70 178{
004b8382 179 return m_client ? m_client->SetPhysicalAddress(iPhysicalAddress) : false;
e55f3f70 180}
44c74256 181
004b8382 182bool CLibCEC::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort /* = CEC_DEFAULT_HDMI_PORT */)
57f45e6c 183{
004b8382 184 return m_client ? m_client->SetHDMIPort(iBaseDevice, iPort) : false;
57f45e6c
LOK
185}
186
004b8382 187bool CLibCEC::PowerOnDevices(cec_logical_address address /* = CECDEVICE_TV */)
6d858ba4 188{
004b8382 189 return m_client ? m_client->SendPowerOnDevices(address) : false;
6d858ba4
LOK
190}
191
004b8382 192bool CLibCEC::StandbyDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
6d858ba4 193{
004b8382 194 return m_client ? m_client->SendStandbyDevices(address) : false;
6d858ba4
LOK
195}
196
004b8382 197bool CLibCEC::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */)
6d858ba4 198{
004b8382 199 return m_client ? m_client->SendSetActiveSource(type) : false;
6d858ba4
LOK
200}
201
004b8382 202bool CLibCEC::SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate /* = true */)
04e637f9 203{
004b8382 204 return m_client ? m_client->SendSetDeckControlMode(mode, bSendUpdate) : false;
04e637f9
LOK
205}
206
004b8382 207bool CLibCEC::SetDeckInfo(cec_deck_info info, bool bSendUpdate /* = true */)
04e637f9 208{
004b8382 209 return m_client ? m_client->SendSetDeckInfo(info, bSendUpdate) : false;
04e637f9
LOK
210}
211
004b8382 212bool CLibCEC::SetInactiveView(void)
04e637f9 213{
004b8382 214 return m_client ? m_client->SendSetInactiveView() : false;
04e637f9
LOK
215}
216
004b8382 217bool CLibCEC::SetMenuState(cec_menu_state state, bool bSendUpdate /* = true */)
a33794d8 218{
004b8382 219 return m_client ? m_client->SendSetMenuState(state, bSendUpdate) : false;
a33794d8
LOK
220}
221
004b8382 222bool CLibCEC::SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage)
a33794d8 223{
004b8382 224 return m_client ? m_client->SendSetOSDString(iLogicalAddress, duration, strMessage) : false;
a33794d8
LOK
225}
226
c0152c09
LOK
227bool CLibCEC::SwitchMonitoring(bool bEnable)
228{
229 return m_client ? m_client->SwitchMonitoring(bEnable) : false;
230}
231
004b8382 232cec_version CLibCEC::GetDeviceCecVersion(cec_logical_address iAddress)
ed21be2a 233{
004b8382 234 return m_client ? m_client->GetDeviceCecVersion(iAddress) : CEC_VERSION_UNKNOWN;
ed21be2a
LOK
235}
236
004b8382 237bool CLibCEC::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language)
2abe74eb 238{
c0152c09 239 return m_client ? m_client->GetDeviceMenuLanguage(iAddress, *language) : false;
2abe74eb
LOK
240}
241
004b8382 242uint64_t CLibCEC::GetDeviceVendorId(cec_logical_address iAddress)
95ba7a09 243{
004b8382 244 return m_client ? m_client->GetDeviceVendorId(iAddress) : (uint64_t)CEC_VENDOR_UNKNOWN;
02e7043e
LOK
245}
246
004b8382 247uint16_t CLibCEC::GetDevicePhysicalAddress(cec_logical_address iAddress)
32403cc3 248{
004b8382 249 return m_client ? m_client->GetDevicePhysicalAddress(iAddress) : CEC_INVALID_PHYSICAL_ADDRESS;
32403cc3
LOK
250}
251
004b8382 252cec_power_status CLibCEC::GetDevicePowerStatus(cec_logical_address iAddress)
02e7043e 253{
004b8382 254 return m_client ? m_client->GetDevicePowerStatus(iAddress) : CEC_POWER_STATUS_UNKNOWN;
95ba7a09
LOK
255}
256
c0152c09
LOK
257bool CLibCEC::PollDevice(cec_logical_address iAddress)
258{
259 return m_client ? m_client->PollDevice(iAddress) : false;
260}
261
262cec_logical_addresses CLibCEC::GetActiveDevices(void)
263{
264 cec_logical_addresses addresses;
265 addresses.Clear();
266 if (m_client)
267 addresses = m_client->GetActiveDevices();
268 return addresses;
269}
270
271bool CLibCEC::IsActiveDevice(cec_logical_address iAddress)
272{
273 return m_client ? m_client->IsActiveDevice(iAddress) : false;
274}
275
276bool CLibCEC::IsActiveDeviceType(cec_device_type type)
277{
278 return m_client ? m_client->IsActiveDeviceType(type) : false;
279}
280
004b8382 281uint8_t CLibCEC::VolumeUp(bool bSendRelease /* = true */)
2abe74eb 282{
004b8382 283 return m_client ? m_client->SendVolumeUp(bSendRelease) : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
2abe74eb
LOK
284}
285
004b8382 286uint8_t CLibCEC::VolumeDown(bool bSendRelease /* = true */)
2abe74eb 287{
004b8382 288 return m_client ? m_client->SendVolumeDown(bSendRelease) : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
2abe74eb
LOK
289}
290
004b8382 291uint8_t CLibCEC::MuteAudio(bool UNUSED(bSendRelease) /* = true */)
b1c47f9d 292{
004b8382 293 return m_client ? m_client->SendMuteAudio() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
b1c47f9d
LOK
294}
295
004b8382 296bool CLibCEC::SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = true */)
2abe74eb 297{
004b8382 298 return m_client ? m_client->SendKeypress(iDestination, key, bWait) : false;
2abe74eb
LOK
299}
300
004b8382 301bool CLibCEC::SendKeyRelease(cec_logical_address iDestination, bool bWait /* = true */)
e1804a4e 302{
004b8382 303 return m_client ? m_client->SendKeyRelease(iDestination, bWait) : false;
e1804a4e
LOK
304}
305
004b8382 306cec_osd_name CLibCEC::GetDeviceOSDName(cec_logical_address iAddress)
f42d3e0f 307{
004b8382 308 cec_osd_name retVal;
20505741
LOK
309 retVal.device = CECDEVICE_UNKNOWN;
310 memset(retVal.name, 0, 14);
311
004b8382
LOK
312 if (m_client)
313 retVal = m_client->GetDeviceOSDName(iAddress);
314 return retVal;
f42d3e0f
LOK
315}
316
c0152c09
LOK
317cec_logical_address CLibCEC::GetActiveSource(void)
318{
319 return m_client ? m_client->GetActiveSource() : CECDEVICE_UNKNOWN;
320}
321
322bool CLibCEC::IsActiveSource(cec_logical_address iAddress)
323{
324 return m_client ? m_client->IsActiveSource(iAddress) : false;
325}
326bool CLibCEC::SetStreamPath(cec_logical_address iAddress)
327{
328 return m_client ? m_client->SetStreamPath(iAddress) : false;
329}
330
331bool CLibCEC::SetStreamPath(uint16_t iPhysicalAddress)
332{
333 return m_client ? m_client->SetStreamPath(iPhysicalAddress) : false;
334}
335
004b8382 336cec_logical_addresses CLibCEC::GetLogicalAddresses(void)
f42d3e0f 337{
004b8382 338 cec_logical_addresses addresses;
c30acafa 339 addresses.Clear();
c0152c09
LOK
340 if (m_client)
341 m_client->GetLogicalAddresses();
004b8382 342 return addresses;
f42d3e0f
LOK
343}
344
004b8382 345cec_device_type CLibCEC::GetType(cec_logical_address address)
f8513317 346{
0d800fe5 347 return CCECTypeUtils::GetType(address);
f8513317
LOK
348}
349
004b8382 350uint16_t CLibCEC::GetMaskForType(cec_logical_address address)
caca2d81 351{
0d800fe5 352 return CCECTypeUtils::GetMaskForType(address);
caca2d81
LOK
353}
354
004b8382 355uint16_t CLibCEC::GetMaskForType(cec_device_type type)
a2198e5e 356{
0d800fe5 357 return CCECTypeUtils::GetMaskForType(type);
004b8382 358}
08d80226 359
004b8382
LOK
360bool CLibCEC::IsValidPhysicalAddress(uint16_t iPhysicalAddress)
361{
362 return iPhysicalAddress >= CEC_MIN_PHYSICAL_ADDRESS &&
363 iPhysicalAddress <= CEC_MAX_PHYSICAL_ADDRESS;
a2198e5e
LOK
364}
365
004b8382 366const char *CLibCEC::ToString(const cec_device_type type)
25701fa6 367{
0d800fe5 368 return CCECTypeUtils::ToString(type);
25701fa6 369}
03ae897d
LOK
370
371const char *CLibCEC::ToString(const cec_menu_state state)
372{
0d800fe5 373 return CCECTypeUtils::ToString(state);
03ae897d
LOK
374}
375
376const char *CLibCEC::ToString(const cec_version version)
377{
0d800fe5 378 return CCECTypeUtils::ToString(version);
03ae897d
LOK
379}
380
381const char *CLibCEC::ToString(const cec_power_status status)
382{
0d800fe5 383 return CCECTypeUtils::ToString(status);
03ae897d
LOK
384}
385
386const char *CLibCEC::ToString(const cec_logical_address address)
387{
0d800fe5 388 return CCECTypeUtils::ToString(address);
03ae897d
LOK
389}
390
391const char *CLibCEC::ToString(const cec_deck_control_mode mode)
392{
0d800fe5 393 return CCECTypeUtils::ToString(mode);
03ae897d
LOK
394}
395
396const char *CLibCEC::ToString(const cec_deck_info status)
397{
0d800fe5 398 return CCECTypeUtils::ToString(status);
03ae897d
LOK
399}
400
401const char *CLibCEC::ToString(const cec_opcode opcode)
402{
0d800fe5 403 return CCECTypeUtils::ToString(opcode);
03ae897d
LOK
404}
405
406const char *CLibCEC::ToString(const cec_system_audio_status mode)
407{
0d800fe5 408 return CCECTypeUtils::ToString(mode);
03ae897d
LOK
409}
410
0d800fe5 411const char *CLibCEC::ToString(const cec_audio_status status)
03ae897d 412{
0d800fe5 413 return CCECTypeUtils::ToString(status);
03ae897d
LOK
414}
415
416const char *CLibCEC::ToString(const cec_vendor_id vendor)
417{
0d800fe5 418 return CCECTypeUtils::ToString(vendor);
03ae897d 419}
caca2d81
LOK
420
421const char *CLibCEC::ToString(const cec_client_version version)
422{
0d800fe5 423 return CCECTypeUtils::ToString(version);
caca2d81 424}
d40928b5 425
3efda01a
LOK
426const char *CLibCEC::ToString(const cec_server_version version)
427{
0d800fe5 428 return CCECTypeUtils::ToString(version);
3efda01a
LOK
429}
430
004b8382 431void CLibCEC::CheckKeypressTimeout(void)
a75e3a5a 432{
004b8382
LOK
433 // check all clients
434 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
435 (*it)->CheckKeypressTimeout();
a75e3a5a
LOK
436}
437
004b8382 438void CLibCEC::AddLog(const cec_log_level level, const char *strFormat, ...)
d40928b5 439{
004b8382
LOK
440 CStdString strLog;
441
c0152c09 442 // format the message
004b8382
LOK
443 va_list argList;
444 va_start(argList, strFormat);
445 strLog.FormatV(strFormat, argList);
446 va_end(argList);
447
448 cec_log_message message;
449 message.level = level;
450 message.time = GetTimeMs() - m_iStartTime;
451 snprintf(message.message, sizeof(message.message), "%s", strLog.c_str());
452
453 // send the message to all clients
454 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
455 (*it)->AddLog(message);
224ea877
LOK
456}
457
5d19989f
LOK
458void CLibCEC::AddCommand(const cec_command &command)
459{
460 // send the command to all clients
461 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
462 (*it)->AddCommand(command);
463}
464
004b8382 465void CLibCEC::Alert(const libcec_alert type, const libcec_parameter &param)
30b4aac0 466{
004b8382
LOK
467 // send the alert to all clients
468 for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
469 (*it)->Alert(type, param);
30b4aac0
LOK
470}
471
c0152c09 472CCECClient *CLibCEC::RegisterClient(libcec_configuration &configuration)
3efda01a 473{
004b8382
LOK
474 if (!m_cec)
475 return NULL;
476
c0152c09 477 // create a new client instance
004b8382
LOK
478 CCECClient *newClient = new CCECClient(m_cec, configuration);
479 if (!newClient)
480 return NULL;
004b8382 481 m_clients.push_back(newClient);
c0152c09
LOK
482
483 // if the default client isn't set, set it
004b8382
LOK
484 if (!m_client)
485 m_client = newClient;
486
c0152c09 487 // register the new client
0b8c7eab 488 if (m_cec->CECInitialised())
004b8382
LOK
489 m_cec->RegisterClient(newClient);
490
99aeafb9 491 return newClient;
3efda01a 492}
c9549d35 493
004b8382 494void CLibCEC::UnregisterClients(void)
c9549d35 495{
c0152c09
LOK
496 if (m_cec)
497 m_cec->UnregisterClients();
498
004b8382 499 m_clients.clear();
c0152c09 500
c9d15485 501 DELETE_AND_NULL(m_client);
c9549d35 502}
9878069e 503
004b8382 504void * CECInitialise(libcec_configuration *configuration)
9878069e 505{
004b8382
LOK
506 if (!configuration)
507 return NULL;
508
c0152c09 509 // create a new libCEC instance
c30acafa 510 CLibCEC *lib = new CLibCEC(NULL);
c0152c09
LOK
511
512 // register a new client
99aeafb9 513 CCECClient *client(NULL);
c0152c09
LOK
514 if (lib && configuration)
515 client = lib->RegisterClient(*configuration);
99aeafb9 516
c0152c09 517 // update the current configuration
99aeafb9 518 if (client)
c0152c09 519 client->GetCurrentConfiguration(*configuration);
99aeafb9
LOK
520
521 // ensure that the correct server version is set
522 configuration->serverVersion = LIBCEC_VERSION_CURRENT;
004b8382
LOK
523
524 return static_cast< void* > (lib);
9878069e 525}
209b7a5c 526
38f1fbcc 527void * CECInit(const char *strDeviceName, CEC::cec_device_type_list types)
209b7a5c 528{
38f1fbcc 529 libcec_configuration configuration; configuration.Clear();
004b8382
LOK
530
531 // client version < 1.5.0
532 snprintf(configuration.strDeviceName, 13, "%s", strDeviceName);
533 configuration.deviceTypes = types;
aa169fd7 534 configuration.iPhysicalAddress = CEC_INVALID_PHYSICAL_ADDRESS;
004b8382
LOK
535
536 if (configuration.deviceTypes.IsEmpty())
537 configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
538
539 return CECInitialise(&configuration);
209b7a5c
LOK
540}
541
004b8382 542bool CECStartBootloader(void)
209b7a5c 543{
004b8382
LOK
544 bool bReturn(false);
545 cec_adapter deviceList[1];
2b44051c 546 if (CAdapterFactory(NULL).FindAdapters(deviceList, 1, 0) > 0)
209b7a5c 547 {
2b44051c
LOK
548 CAdapterFactory factory(NULL);
549 IAdapterCommunication *comm = factory.GetInstance(deviceList[0].comm);
550 if (comm)
209b7a5c 551 {
2b44051c
LOK
552 CTimeout timeout(CEC_DEFAULT_CONNECT_TIMEOUT);
553 while (timeout.TimeLeft() > 0 &&
554 (bReturn = comm->Open(timeout.TimeLeft() / CEC_CONNECT_TRIES, true)) == false)
555 {
556 comm->Close();
557 CEvent::Sleep(500);
558 }
559 if (comm->IsOpen())
560 bReturn = comm->StartBootloader();
561
562 delete comm;
209b7a5c 563 }
209b7a5c 564 }
004b8382
LOK
565
566 return bReturn;
567}
568
569void CECDestroy(CEC::ICECAdapter *instance)
570{
c9d15485 571 DELETE_AND_NULL(instance);
209b7a5c 572}
f80cd208 573
b32ffd87 574bool CLibCEC::GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs /* = CEC_DEFAULT_CONNECT_TIMEOUT */)
f80cd208
LOK
575{
576 if (m_cec->IsRunning())
577 return false;
004b8382 578
f80cd208 579 return m_cec->GetDeviceInformation(strPort, config, iTimeoutMs);
a75e3a5a 580}
c30acafa 581
2b44051c
LOK
582const char *CLibCEC::GetLibInfo(void)
583{
584#ifndef LIB_INFO
585#ifdef _WIN32
586#define FEATURES "'P8 USB' 'P8 USB detect'"
587#ifdef _WIN64
588#define HOST_TYPE "Windows (x64)"
589#else
590#define HOST_TYPE "Windows (x86)"
591#endif
592#else
593#define HOST_TYPE "unknown"
594#define FEATURES "unknown"
595#endif
596
597 return "host: " HOST_TYPE ", features: " FEATURES ", compiled: " __DATE__;
598#else
599 return LIB_INFO;
600#endif
601}
602
603const char *CLibCEC::ToString(const cec_user_control_code key)
604{
605 return CCECTypeUtils::ToString(key);
606}
607
608void CLibCEC::InitVideoStandalone(void)
609{
610 CAdapterFactory::InitVideoStandalone();
611}
612
2d418322
LOK
613const char *CLibCEC::ToString(const cec_adapter_type type)
614{
615 return CCECTypeUtils::ToString(type);
616}