2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
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.
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.
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.
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
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/
33 #include "CECClient.h"
34 #include "CECProcessor.h"
36 #include "CECTypeUtils.h"
37 #include "devices/CECPlaybackDevice.h"
38 #include "devices/CECAudioSystem.h"
39 #include "devices/CECTV.h"
40 #include "implementations/CECCommandHandler.h"
43 using namespace PLATFORM
;
45 #define LIB_CEC m_processor->GetLib()
46 #define ToString(x) CCECTypeUtils::ToString(x)
48 CCECClient::CCECClient(CCECProcessor
*processor
, const libcec_configuration
&configuration
) :
49 m_processor(processor
),
50 m_bInitialised(false),
52 m_iCurrentButton(CEC_USER_CONTROL_CODE_UNKNOWN
),
54 m_iPreventForwardingPowerOffCommand(0)
56 // set the initial configuration
57 SetConfiguration(configuration
);
60 CCECClient::~CCECClient(void)
62 // unregister the client
63 if (m_processor
&& IsRegistered())
64 m_processor
->UnregisterClient(this);
67 bool CCECClient::IsInitialised(void)
69 CLockObject
lock(m_mutex
);
70 return m_bInitialised
&& m_processor
;
73 void CCECClient::SetInitialised(bool bSetTo
)
75 CLockObject
lock(m_mutex
);
76 m_bInitialised
= bSetTo
;
79 bool CCECClient::IsRegistered(void)
81 CLockObject
lock(m_mutex
);
82 return m_bRegistered
&& m_processor
;
85 void CCECClient::SetRegistered(bool bSetTo
)
87 CLockObject
lock(m_mutex
);
88 m_bRegistered
= bSetTo
;
91 bool CCECClient::OnRegister(void)
93 // return false if already initialised
97 // get all device we control
99 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
101 // return false when no devices were found
104 LIB_CEC
->AddLog(CEC_LOG_WARNING
, "cannot find the primary device (logical address %x)", GetPrimaryLogicalAdddress());
108 // mark as initialised
109 SetInitialised(true);
111 // configure all devices
112 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
114 // only set our OSD name for the primary device
115 if ((*it
)->GetLogicalAddress() == GetPrimaryLogicalAdddress())
116 (*it
)->SetOSDName(m_configuration
.strDeviceName
);
118 // set the default menu language for devices we control
119 (*it
)->SetMenuLanguage(m_configuration
.strDeviceLanguage
);
122 // set the physical address
123 SetPhysicalAddress(m_configuration
);
125 // make the primary device the active source if the option is set
126 if (m_configuration
.bActivateSource
== 1)
127 GetPrimaryDevice()->ActivateSource();
132 bool CCECClient::SetHDMIPort(const cec_logical_address iBaseDevice
, const uint8_t iPort
, bool bForce
/* = false */)
136 // limit the HDMI port range to 1-15
137 if (iPort
< CEC_MIN_HDMI_PORTNUMBER
||
138 iPort
> CEC_MAX_HDMI_PORTNUMBER
)
141 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "setting HDMI port to %d on device %s (%d)", iPort
, ToString(iBaseDevice
), (int)iBaseDevice
);
143 // update the configuration
145 CLockObject
lock(m_mutex
);
146 m_configuration
.baseDevice
= iBaseDevice
;
147 m_configuration
.iHDMIPort
= iPort
;
150 // don't continue if the connection isn't opened
151 if (!m_processor
->CECInitialised() && !bForce
)
154 // get the PA of the base device
155 uint16_t iPhysicalAddress(CEC_INVALID_PHYSICAL_ADDRESS
);
156 CCECBusDevice
*baseDevice
= m_processor
->GetDevice(iBaseDevice
);
158 iPhysicalAddress
= baseDevice
->GetPhysicalAddress(GetPrimaryLogicalAdddress());
160 // add our port number
161 if (iPhysicalAddress
<= CEC_MAX_PHYSICAL_ADDRESS
)
163 if (iPhysicalAddress
== 0)
164 iPhysicalAddress
+= 0x1000 * iPort
;
165 else if (iPhysicalAddress
% 0x1000 == 0)
166 iPhysicalAddress
+= 0x100 * iPort
;
167 else if (iPhysicalAddress
% 0x100 == 0)
168 iPhysicalAddress
+= 0x10 * iPort
;
169 else if (iPhysicalAddress
% 0x10 == 0)
170 iPhysicalAddress
+= iPort
;
175 // set the default address when something went wrong
178 LIB_CEC
->AddLog(CEC_LOG_WARNING
, "failed to set the physical address to %04X, setting it to the default value %04X", iPhysicalAddress
, CEC_DEFAULT_PHYSICAL_ADDRESS
);
179 iPhysicalAddress
= CEC_DEFAULT_PHYSICAL_ADDRESS
;
182 // and set the address
183 SetDevicePhysicalAddress(iPhysicalAddress
);
185 ConfigurationChanged(m_configuration
);
190 void CCECClient::ResetPhysicalAddress(void)
192 SetPhysicalAddress(m_configuration
);
195 void CCECClient::SetPhysicalAddress(const libcec_configuration
&configuration
)
199 // override the physical address from configuration.iPhysicalAddress if it's set
200 if (!bPASet
&& CLibCEC::IsValidPhysicalAddress(configuration
.iPhysicalAddress
))
201 bPASet
= SetPhysicalAddress(configuration
.iPhysicalAddress
);
203 // try to autodetect the address
204 if (!bPASet
&& m_processor
->CECInitialised())
206 bPASet
= AutodetectPhysicalAddress();
207 m_configuration
.bAutodetectAddress
= bPASet
? 1 : 0;
210 // use the base device + hdmi port settings
212 bPASet
= SetHDMIPort(configuration
.baseDevice
, configuration
.iHDMIPort
);
214 // reset to defaults if something went wrong
217 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - resetting HDMI port and base device to defaults", __FUNCTION__
);
218 m_configuration
.baseDevice
= CECDEVICE_UNKNOWN
;
219 m_configuration
.iHDMIPort
= CEC_HDMI_PORTNUMBER_NONE
;
223 bool CCECClient::SetPhysicalAddress(const uint16_t iPhysicalAddress
)
225 // update the configuration
227 CLockObject
lock(m_mutex
);
228 if (m_configuration
.iPhysicalAddress
== iPhysicalAddress
)
230 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "physical address unchanged (%04X)", iPhysicalAddress
);
235 m_configuration
.iPhysicalAddress
= iPhysicalAddress
;
236 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "setting physical address to '%04X'", iPhysicalAddress
);
240 // persist the new configuration
241 m_processor
->PersistConfiguration(m_configuration
);
243 // set the physical address for each device
244 SetDevicePhysicalAddress(iPhysicalAddress
);
246 // and send back the updated configuration
247 ConfigurationChanged(m_configuration
);
252 void CCECClient::SetSupportedDeviceTypes(void)
254 cec_device_type_list types
;
257 // get the command handler for the tv
258 CCECCommandHandler
*tvHandler
= m_processor
->GetTV()->GetHandler();
262 // check all device types
263 for (uint8_t iPtr
= 0; iPtr
< 5; iPtr
++)
265 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_RESERVED
)
268 // get the supported device type. the handler will replace types it doesn't support by one it does support
269 cec_device_type type
= tvHandler
->GetReplacementDeviceType(m_configuration
.deviceTypes
.types
[iPtr
]);
270 if (!types
.IsSet(type
))
273 m_processor
->GetTV()->MarkHandlerReady();
275 // set the new type list
276 m_configuration
.deviceTypes
= types
;
279 bool CCECClient::AllocateLogicalAddresses(void)
281 // reset all previous LAs that were set
282 m_configuration
.logicalAddresses
.Clear();
284 // get the supported device types from the command handler of the TV
285 SetSupportedDeviceTypes();
287 // display an error if no device types are set
288 if (m_configuration
.deviceTypes
.IsEmpty())
290 LIB_CEC
->AddLog(CEC_LOG_ERROR
, "no device types given");
294 // check each entry of the list
295 for (uint8_t iPtr
= 0; iPtr
< 5; iPtr
++)
297 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_RESERVED
)
300 // find an LA for this type
301 cec_logical_address
address(CECDEVICE_UNKNOWN
);
302 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_RECORDING_DEVICE
)
303 address
= AllocateLogicalAddressRecordingDevice();
304 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_TUNER
)
305 address
= AllocateLogicalAddressTuner();
306 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_PLAYBACK_DEVICE
)
307 address
= AllocateLogicalAddressPlaybackDevice();
308 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_AUDIO_SYSTEM
)
309 address
= AllocateLogicalAddressAudioSystem();
311 // display an error if no LA could be allocated
312 if (address
== CECDEVICE_UNKNOWN
)
314 LIB_CEC
->AddLog(CEC_LOG_ERROR
, "%s - failed to allocate device '%d', type '%s'", __FUNCTION__
, iPtr
, ToString(m_configuration
.deviceTypes
.types
[iPtr
]));
318 // display the registered LA
319 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - device '%d', type '%s', LA '%X'", __FUNCTION__
, iPtr
, ToString(m_configuration
.deviceTypes
.types
[iPtr
]), address
);
320 m_configuration
.logicalAddresses
.Set(address
);
326 cec_logical_address
CCECClient::AllocateLogicalAddressRecordingDevice(void)
328 cec_logical_address
retVal(CECDEVICE_UNKNOWN
);
330 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'recording device'");
331 if (m_processor
->TryLogicalAddress(CECDEVICE_RECORDINGDEVICE1
))
332 retVal
= CECDEVICE_RECORDINGDEVICE1
;
333 else if (m_processor
->TryLogicalAddress(CECDEVICE_RECORDINGDEVICE2
))
334 retVal
= CECDEVICE_RECORDINGDEVICE2
;
335 else if (m_processor
->TryLogicalAddress(CECDEVICE_RECORDINGDEVICE3
))
336 retVal
= CECDEVICE_RECORDINGDEVICE3
;
341 cec_logical_address
CCECClient::AllocateLogicalAddressTuner(void)
343 cec_logical_address
retVal(CECDEVICE_UNKNOWN
);
345 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'tuner'");
346 if (m_processor
->TryLogicalAddress(CECDEVICE_TUNER1
))
347 retVal
= CECDEVICE_TUNER1
;
348 else if (m_processor
->TryLogicalAddress(CECDEVICE_TUNER2
))
349 retVal
= CECDEVICE_TUNER2
;
350 else if (m_processor
->TryLogicalAddress(CECDEVICE_TUNER3
))
351 retVal
= CECDEVICE_TUNER3
;
352 else if (m_processor
->TryLogicalAddress(CECDEVICE_TUNER4
))
353 retVal
= CECDEVICE_TUNER4
;
358 cec_logical_address
CCECClient::AllocateLogicalAddressPlaybackDevice(void)
360 cec_logical_address
retVal(CECDEVICE_UNKNOWN
);
362 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'playback device'");
363 if (m_processor
->TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE1
))
364 retVal
= CECDEVICE_PLAYBACKDEVICE1
;
365 else if (m_processor
->TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE2
))
366 retVal
= CECDEVICE_PLAYBACKDEVICE2
;
367 else if (m_processor
->TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE3
))
368 retVal
= CECDEVICE_PLAYBACKDEVICE3
;
373 cec_logical_address
CCECClient::AllocateLogicalAddressAudioSystem(void)
375 cec_logical_address
retVal(CECDEVICE_UNKNOWN
);
377 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'audiosystem'");
378 if (m_processor
->TryLogicalAddress(CECDEVICE_AUDIOSYSTEM
))
379 retVal
= CECDEVICE_AUDIOSYSTEM
;
384 CCECBusDevice
*CCECClient::GetDeviceByType(const cec_device_type type
) const
386 // get all devices that match our logical addresses
387 CECDEVICEVEC devices
;
388 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
390 // filter the type we need
391 CCECDeviceMap::FilterType(type
, devices
);
393 return devices
.empty() ?
398 bool CCECClient::ChangeDeviceType(const cec_device_type from
, const cec_device_type to
)
400 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, "changing device type '%s' into '%s'", ToString(from
), ToString(to
));
402 CLockObject
lock(m_mutex
);
404 // get the previous device that was allocated
405 CCECBusDevice
*previousDevice
= GetDeviceByType(from
);
409 // change the type in the device type list
410 bool bChanged(false);
411 for (uint8_t iPtr
= 0; iPtr
< 5; iPtr
++)
413 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_RESERVED
)
416 if (m_configuration
.deviceTypes
.types
[iPtr
] == from
)
419 m_configuration
.deviceTypes
.types
[iPtr
] = to
;
421 else if (m_configuration
.deviceTypes
.types
[iPtr
] == to
&& bChanged
)
423 // ensure that dupes are removed
424 m_configuration
.deviceTypes
.types
[iPtr
] = CEC_DEVICE_TYPE_RESERVED
;
428 // re-register the client to set the new ackmask
429 if (!m_processor
->RegisterClient(this))
435 bool CCECClient::SetLogicalAddress(const cec_logical_address iLogicalAddress
)
437 CLockObject
lock(m_mutex
);
438 if (GetPrimaryLogicalAdddress() != iLogicalAddress
)
441 CLockObject
lock(m_mutex
);
442 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, "<< setting primary logical address to %1x", iLogicalAddress
);
443 m_configuration
.logicalAddresses
.primary
= iLogicalAddress
;
444 m_configuration
.logicalAddresses
.Set(iLogicalAddress
);
446 return m_processor
->RegisterClient(this);
452 bool CCECClient::Transmit(const cec_command
&data
)
454 return m_processor
? m_processor
->Transmit(data
) : false;
457 bool CCECClient::SendPowerOnDevices(const cec_logical_address address
/* = CECDEVICE_TV */)
459 // if the broadcast address if set as destination and the client version >=1.5.0, read the wakeDevices setting
460 if (address
== CECDEVICE_BROADCAST
&& m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_0
)
462 CECDEVICEVEC devices
;
463 m_processor
->GetDevices()->GetWakeDevices(m_configuration
, devices
);
464 return m_processor
->PowerOnDevices(GetPrimaryLogicalAdddress(), devices
);
467 return m_processor
->PowerOnDevice(GetPrimaryLogicalAdddress(), address
);
470 bool CCECClient::SendStandbyDevices(const cec_logical_address address
/* = CECDEVICE_BROADCAST */)
472 // if the broadcast address if set as destination and the client version >=1.5.0, read the standbyDevices setting
473 if (address
== CECDEVICE_BROADCAST
&& m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_0
)
475 CECDEVICEVEC devices
;
476 m_processor
->GetDevices()->GetPowerOffDevices(m_configuration
, devices
);
477 return m_processor
->StandbyDevices(GetPrimaryLogicalAdddress(), devices
);
480 return m_processor
->StandbyDevice(GetPrimaryLogicalAdddress(), address
);
483 bool CCECClient::SendSetActiveSource(const cec_device_type type
/* = CEC_DEVICE_TYPE_RESERVED */)
485 // get the devices that are controlled by us
486 CECDEVICEVEC devices
;
487 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
489 // filter out the device that matches the given type
490 if (type
!= CEC_DEVICE_TYPE_RESERVED
)
491 CCECDeviceMap::FilterType(type
, devices
);
493 // no devices left, re-fetch the list of devices that are controlled by us
495 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
497 if (!devices
.empty())
499 // get the first device from the list
500 CCECBusDevice
*device
= *devices
.begin();
503 if (!m_processor
->CECInitialised())
504 device
->MarkAsActiveSource();
505 else if (device
->HasValidPhysicalAddress())
506 return device
->ActivateSource();
512 CCECPlaybackDevice
*CCECClient::GetPlaybackDevice(void)
514 CCECPlaybackDevice
*device(NULL
);
515 CECDEVICEVEC devices
;
517 // get the playback devices
518 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
519 CCECDeviceMap::FilterType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE
, devices
);
521 // no matches, get the recording devices
524 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
525 CCECDeviceMap::FilterType(CEC_DEVICE_TYPE_RECORDING_DEVICE
, devices
);
528 // get the first device that matches, and cast it to CCECPlaybackDevice
529 if (!devices
.empty())
530 device
= (*devices
.begin())->AsPlaybackDevice();
535 cec_logical_address
CCECClient::GetPrimaryLogicalAdddress(void)
537 CLockObject
lock(m_mutex
);
538 return m_configuration
.logicalAddresses
.primary
;
541 CCECBusDevice
*CCECClient::GetPrimaryDevice(void)
543 return m_processor
->GetDevice(GetPrimaryLogicalAdddress());
546 bool CCECClient::SendSetDeckControlMode(const cec_deck_control_mode mode
, bool bSendUpdate
/* = true */)
548 // find a playback device that we control
549 CCECPlaybackDevice
*device
= GetPlaybackDevice();
552 // and set the deck control mode if there is a match
553 device
->SetDeckControlMode(mode
);
555 return device
->TransmitDeckStatus(CECDEVICE_TV
);
563 bool CCECClient::SendSetDeckInfo(const cec_deck_info info
, bool bSendUpdate
/* = true */)
565 // find a playback device that we control
566 CCECPlaybackDevice
*device
= GetPlaybackDevice();
569 // and set the deck status if there is a match
570 device
->SetDeckStatus(info
);
572 return device
->AsPlaybackDevice()->TransmitDeckStatus(CECDEVICE_TV
);
580 bool CCECClient::SendSetMenuState(const cec_menu_state state
, bool bSendUpdate
/* = true */)
582 CECDEVICEVEC devices
;
584 // set the menu state for all devices that are controlled by us
585 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
586 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
588 (*it
)->SetMenuState(state
);
590 (*it
)->TransmitMenuState(CECDEVICE_TV
);
596 bool CCECClient::SendSetInactiveView(void)
598 CECDEVICEVEC devices
;
600 // mark all devices that are controlled by us as inactive source
601 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
602 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
604 if ((*it
)->IsActiveSource())
606 (*it
)->MarkAsInactiveSource();
607 return (*it
)->TransmitInactiveSource();
614 bool CCECClient::SendSetOSDString(const cec_logical_address iLogicalAddress
, const cec_display_control duration
, const char *strMessage
)
616 CCECBusDevice
*primary
= GetPrimaryDevice();
618 return primary
->TransmitOSDString(iLogicalAddress
, duration
, strMessage
);
623 cec_version
CCECClient::GetDeviceCecVersion(const cec_logical_address iAddress
)
625 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
627 return device
->GetCecVersion(GetPrimaryLogicalAdddress());
628 return CEC_VERSION_UNKNOWN
;
631 bool CCECClient::GetDeviceMenuLanguage(const cec_logical_address iAddress
, cec_menu_language
&language
)
633 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
636 language
= device
->GetMenuLanguage(GetPrimaryLogicalAdddress());
637 return (strcmp(language
.language
, "???") != 0);
642 cec_osd_name
CCECClient::GetDeviceOSDName(const cec_logical_address iAddress
)
645 retVal
.device
= iAddress
;
648 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
651 CStdString strOSDName
= device
->GetOSDName(GetPrimaryLogicalAdddress());
652 snprintf(retVal
.name
, sizeof(retVal
.name
), "%s", strOSDName
.c_str());
653 retVal
.device
= iAddress
;
659 uint16_t CCECClient::GetDevicePhysicalAddress(const cec_logical_address iAddress
)
661 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
663 return device
->GetPhysicalAddress(GetPrimaryLogicalAdddress());
664 return CEC_INVALID_PHYSICAL_ADDRESS
;
667 cec_power_status
CCECClient::GetDevicePowerStatus(const cec_logical_address iAddress
)
669 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
671 return device
->GetPowerStatus(GetPrimaryLogicalAdddress());
672 return CEC_POWER_STATUS_UNKNOWN
;
675 uint64_t CCECClient::GetDeviceVendorId(const cec_logical_address iAddress
)
677 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
679 return device
->GetVendorId(GetPrimaryLogicalAdddress());
680 return CEC_VENDOR_UNKNOWN
;
683 uint8_t CCECClient::SendVolumeUp(bool bSendRelease
/* = true */)
685 CCECBusDevice
*device
= GetPrimaryDevice();
686 CCECAudioSystem
*audio
= m_processor
->GetAudioSystem();
688 return device
&& audio
&& audio
->IsPresent() ?
689 audio
->VolumeUp(device
->GetLogicalAddress(), bSendRelease
) :
690 (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
693 uint8_t CCECClient::SendVolumeDown(bool bSendRelease
/* = true */)
695 CCECBusDevice
*device
= GetPrimaryDevice();
696 CCECAudioSystem
*audio
= m_processor
->GetAudioSystem();
698 return device
&& audio
&& audio
->IsPresent() ?
699 audio
->VolumeDown(device
->GetLogicalAddress(), bSendRelease
) :
700 (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
703 uint8_t CCECClient::SendMuteAudio(void)
705 CCECBusDevice
*device
= GetPrimaryDevice();
706 CCECAudioSystem
*audio
= m_processor
->GetAudioSystem();
708 return device
&& audio
&& audio
->IsPresent() ?
709 audio
->MuteAudio(device
->GetLogicalAddress()) :
710 (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
713 bool CCECClient::SendKeypress(const cec_logical_address iDestination
, const cec_user_control_code key
, bool bWait
/* = true */)
715 CCECBusDevice
*dest
= m_processor
->GetDevice(iDestination
);
718 dest
->TransmitKeypress(GetPrimaryLogicalAdddress(), key
, bWait
) :
722 bool CCECClient::SendKeyRelease(const cec_logical_address iDestination
, bool bWait
/* = true */)
724 CCECBusDevice
*dest
= m_processor
->GetDevice(iDestination
);
727 dest
->TransmitKeyRelease(GetPrimaryLogicalAdddress(), bWait
) :
731 bool CCECClient::GetCurrentConfiguration(libcec_configuration
&configuration
)
733 CLockObject
lock(m_mutex
);
735 // client version 1.5.0
736 snprintf(configuration
.strDeviceName
, 13, "%s", m_configuration
.strDeviceName
);
737 configuration
.deviceTypes
= m_configuration
.deviceTypes
;
738 configuration
.bAutodetectAddress
= m_configuration
.bAutodetectAddress
;
739 configuration
.iPhysicalAddress
= m_configuration
.iPhysicalAddress
;
740 configuration
.baseDevice
= m_configuration
.baseDevice
;
741 configuration
.iHDMIPort
= m_configuration
.iHDMIPort
;
742 configuration
.clientVersion
= m_configuration
.clientVersion
;
743 configuration
.serverVersion
= m_configuration
.serverVersion
;
744 configuration
.tvVendor
= m_configuration
.tvVendor
;
746 configuration
.bGetSettingsFromROM
= m_configuration
.bGetSettingsFromROM
;
747 configuration
.bUseTVMenuLanguage
= m_configuration
.bUseTVMenuLanguage
;
748 configuration
.bActivateSource
= m_configuration
.bActivateSource
;
749 configuration
.wakeDevices
= m_configuration
.wakeDevices
;
750 configuration
.powerOffDevices
= m_configuration
.powerOffDevices
;
751 configuration
.bPowerOffScreensaver
= m_configuration
.bPowerOffScreensaver
;
752 configuration
.bPowerOffOnStandby
= m_configuration
.bPowerOffOnStandby
;
754 // client version 1.5.1
755 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_1
)
756 configuration
.bSendInactiveSource
= m_configuration
.bSendInactiveSource
;
758 // client version 1.5.3
759 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_3
)
760 configuration
.logicalAddresses
= m_configuration
.logicalAddresses
;
762 // client version 1.6.0
763 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_0
)
765 configuration
.iFirmwareVersion
= m_configuration
.iFirmwareVersion
;
766 configuration
.bPowerOffDevicesOnStandby
= m_configuration
.bPowerOffDevicesOnStandby
;
767 configuration
.bShutdownOnStandby
= m_configuration
.bShutdownOnStandby
;
770 // client version 1.6.2
771 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_2
)
773 memcpy(configuration
.strDeviceLanguage
, m_configuration
.strDeviceLanguage
, 3);
774 configuration
.iFirmwareBuildDate
= m_configuration
.iFirmwareBuildDate
;
777 // client version 1.6.3
778 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_3
)
780 configuration
.bMonitorOnly
= m_configuration
.bMonitorOnly
;
786 bool CCECClient::SetConfiguration(const libcec_configuration
&configuration
)
788 bool bIsRunning(m_processor
&& m_processor
->CECInitialised());
789 CCECBusDevice
*primary
= bIsRunning
? GetPrimaryDevice() : NULL
;
790 uint16_t iPA
= primary
? primary
->GetCurrentPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS
;
792 // update the callbacks
793 if (configuration
.callbacks
)
794 EnableCallbacks(configuration
.callbackParam
, configuration
.callbacks
);
796 // update the client version
797 SetClientVersion((cec_client_version
)configuration
.clientVersion
);
799 // update the OSD name
800 CStdString
strOSDName(configuration
.strDeviceName
);
801 SetOSDName(strOSDName
);
803 // update the TV vendor override
804 SetTVVendorOverride((cec_vendor_id
)configuration
.tvVendor
);
808 CLockObject
lock(m_mutex
);
809 m_configuration
.bUseTVMenuLanguage
= configuration
.bUseTVMenuLanguage
;
810 m_configuration
.bActivateSource
= configuration
.bActivateSource
;
811 m_configuration
.bGetSettingsFromROM
= configuration
.bGetSettingsFromROM
;
812 m_configuration
.wakeDevices
= configuration
.wakeDevices
;
813 m_configuration
.powerOffDevices
= configuration
.powerOffDevices
;
814 m_configuration
.bPowerOffScreensaver
= configuration
.bPowerOffScreensaver
;
815 m_configuration
.bPowerOffOnStandby
= configuration
.bPowerOffOnStandby
;
817 // client version 1.5.1
818 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_1
)
819 m_configuration
.bSendInactiveSource
= configuration
.bSendInactiveSource
;
821 // client version 1.6.0
822 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_0
)
824 m_configuration
.bPowerOffDevicesOnStandby
= configuration
.bPowerOffDevicesOnStandby
;
825 m_configuration
.bShutdownOnStandby
= configuration
.bShutdownOnStandby
;
828 // client version 1.6.2
829 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_2
)
831 memcpy(m_configuration
.strDeviceLanguage
, configuration
.strDeviceLanguage
, 3);
834 // client version 1.6.3
835 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_3
)
837 m_configuration
.bMonitorOnly
= configuration
.bMonitorOnly
;
840 // ensure that there is at least 1 device type set
841 if (m_configuration
.deviceTypes
.IsEmpty())
842 m_configuration
.deviceTypes
.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE
);
845 bool bNeedReinit(false);
848 if (SetDeviceTypes(configuration
.deviceTypes
))
850 // the device type changed. just copy the rest, and re-register
852 CLockObject
lock(m_mutex
);
853 m_configuration
.iPhysicalAddress
= configuration
.iPhysicalAddress
;
854 m_configuration
.baseDevice
= configuration
.baseDevice
;
855 m_configuration
.iHDMIPort
= configuration
.iHDMIPort
;
861 // set the physical address
862 SetPhysicalAddress(configuration
);
865 m_processor
->PersistConfiguration(m_configuration
);
868 primary
= GetPrimaryDevice();
870 if (bNeedReinit
|| !primary
|| primary
->GetCurrentPhysicalAddress() != iPA
)
872 // PA or device type changed
873 m_processor
->RegisterClient(this);
875 else if (primary
&& configuration
.bActivateSource
== 1 && bIsRunning
&& !primary
->IsActiveSource())
877 // activate the source if we're not already the active source
878 primary
->ActivateSource();
884 void CCECClient::AddCommand(const cec_command
&command
)
886 // don't forward the standby opcode more than once every 10 seconds
887 if (command
.opcode
== CEC_OPCODE_STANDBY
)
889 CLockObject
lock(m_mutex
);
890 if (m_iPreventForwardingPowerOffCommand
!= 0 &&
891 m_iPreventForwardingPowerOffCommand
> GetTimeMs())
894 m_iPreventForwardingPowerOffCommand
= GetTimeMs() + CEC_FORWARD_STANDBY_MIN_INTERVAL
;
897 if (command
.destination
== CECDEVICE_BROADCAST
|| GetLogicalAddresses().IsSet(command
.destination
))
899 CLockObject
lock(m_mutex
);
901 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, ">> %s (%X) -> %s (%X): %s (%2X)", ToString(command
.initiator
), command
.initiator
, ToString(command
.destination
), command
.destination
, ToString(command
.opcode
), command
.opcode
);
903 if (m_configuration
.callbacks
&& m_configuration
.callbacks
->CBCecCommand
)
904 m_configuration
.callbacks
->CBCecCommand(m_configuration
.callbackParam
, command
);
905 else if (!m_commandBuffer
.Push(command
))
906 LIB_CEC
->AddLog(CEC_LOG_WARNING
, "command buffer is full");
910 int CCECClient::MenuStateChanged(const cec_menu_state newState
)
912 CLockObject
lock(m_mutex
);
914 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, ">> %s: %s", ToString(CEC_OPCODE_MENU_REQUEST
), ToString(newState
));
916 if (m_configuration
.callbacks
&&
917 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_2
&&
918 m_configuration
.callbacks
->CBCecMenuStateChanged
)
919 return m_configuration
.callbacks
->CBCecMenuStateChanged(m_configuration
.callbackParam
, newState
);
924 void CCECClient::SourceActivated(const cec_logical_address logicalAddress
)
926 CLockObject
lock(m_mutex
);
928 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, ">> source activated: %s (%x)", ToString(logicalAddress
), logicalAddress
);
930 if (m_configuration
.callbacks
&&
931 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_7_1
&&
932 m_configuration
.callbacks
->CBCecSourceActivated
)
933 m_configuration
.callbacks
->CBCecSourceActivated(m_configuration
.callbackParam
, logicalAddress
, 1);
936 void CCECClient::SourceDeactivated(const cec_logical_address logicalAddress
)
938 CLockObject
lock(m_mutex
);
940 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, ">> source deactivated: %s (%x)", ToString(logicalAddress
), logicalAddress
);
942 if (m_configuration
.callbacks
&&
943 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_7_1
&&
944 m_configuration
.callbacks
->CBCecSourceActivated
)
945 m_configuration
.callbacks
->CBCecSourceActivated(m_configuration
.callbackParam
, logicalAddress
, 0);
948 void CCECClient::Alert(const libcec_alert type
, const libcec_parameter
¶m
)
950 CLockObject
lock(m_mutex
);
952 if (m_configuration
.callbacks
&&
953 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_0
&&
954 m_configuration
.callbacks
->CBCecAlert
)
955 m_configuration
.callbacks
->CBCecAlert(m_configuration
.callbackParam
, type
, param
);
958 void CCECClient::AddLog(const cec_log_message
&message
)
960 CLockObject
lock(m_logMutex
);
961 if (m_configuration
.callbacks
&& m_configuration
.callbacks
->CBCecLogMessage
)
962 m_configuration
.callbacks
->CBCecLogMessage(m_configuration
.callbackParam
, message
);
964 m_logBuffer
.Push(message
);
967 void CCECClient::AddKey(void)
969 CLockObject
lock(m_mutex
);
971 if (m_iCurrentButton
!= CEC_USER_CONTROL_CODE_UNKNOWN
)
975 key
.duration
= (unsigned int) (GetTimeMs() - m_buttontime
);
976 key
.keycode
= m_iCurrentButton
;
977 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "key released: %1x", key
.keycode
);
979 if (m_configuration
.callbacks
&& m_configuration
.callbacks
->CBCecKeyPress
)
980 m_configuration
.callbacks
->CBCecKeyPress(m_configuration
.callbackParam
, key
);
982 m_keyBuffer
.Push(key
);
983 m_iCurrentButton
= CEC_USER_CONTROL_CODE_UNKNOWN
;
989 void CCECClient::AddKey(const cec_keypress
&key
)
991 CLockObject
lock(m_mutex
);
993 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "key pressed: %1x", key
.keycode
);
995 if (m_configuration
.callbacks
&& m_configuration
.callbacks
->CBCecKeyPress
)
996 m_configuration
.callbacks
->CBCecKeyPress(m_configuration
.callbackParam
, key
);
998 m_keyBuffer
.Push(key
);
1000 m_iCurrentButton
= key
.duration
> 0 ? CEC_USER_CONTROL_CODE_UNKNOWN
: key
.keycode
;
1001 m_buttontime
= key
.duration
> 0 ? 0 : GetTimeMs();
1004 void CCECClient::SetCurrentButton(const cec_user_control_code iButtonCode
)
1006 // push a keypress to the buffer with 0 duration and another with the duration set when released
1009 key
.keycode
= iButtonCode
;
1014 void CCECClient::CheckKeypressTimeout(void)
1016 if (m_iCurrentButton
!= CEC_USER_CONTROL_CODE_UNKNOWN
&& GetTimeMs() - m_buttontime
> CEC_BUTTON_TIMEOUT
)
1019 m_iCurrentButton
= CEC_USER_CONTROL_CODE_UNKNOWN
;
1023 void CCECClient::ConfigurationChanged(const libcec_configuration
&config
)
1025 CLockObject
lock(m_mutex
);
1027 if (m_configuration
.callbacks
&&
1028 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_0
&&
1029 m_configuration
.callbacks
->CBCecConfigurationChanged
&&
1030 m_processor
->CECInitialised())
1031 m_configuration
.callbacks
->CBCecConfigurationChanged(m_configuration
.callbackParam
, config
);
1034 bool CCECClient::EnableCallbacks(void *cbParam
, ICECCallbacks
*callbacks
)
1036 CLockObject
lock(m_mutex
);
1037 m_configuration
.callbackParam
= cbParam
;
1038 m_configuration
.callbacks
= callbacks
;
1042 bool CCECClient::PingAdapter(void)
1044 return m_processor
? m_processor
->PingAdapter() : false;
1047 bool CCECClient::GetNextLogMessage(cec_log_message
*message
)
1049 return (m_logBuffer
.Pop(*message
));
1052 bool CCECClient::GetNextKeypress(cec_keypress
*key
)
1054 return m_keyBuffer
.Pop(*key
);
1057 bool CCECClient::GetNextCommand(cec_command
*command
)
1059 return m_commandBuffer
.Pop(*command
);
1062 CStdString
CCECClient::GetConnectionInfo(void)
1065 strLog
.Format("libCEC version = %s, client version = %s, firmware version = %d", ToString((cec_server_version
)m_configuration
.serverVersion
), ToString((cec_client_version
)m_configuration
.clientVersion
), m_configuration
.iFirmwareVersion
);
1066 if (m_configuration
.iFirmwareBuildDate
!= CEC_FW_BUILD_UNKNOWN
)
1068 time_t buildTime
= (time_t)m_configuration
.iFirmwareBuildDate
;
1069 strLog
.AppendFormat(", firmware build date: %s", asctime(gmtime(&buildTime
)));
1070 strLog
= strLog
.Left((int)strLog
.length() - 1); // strip \n added by asctime
1071 strLog
.append(" +0000");
1074 // log the addresses that are being used
1075 if (!m_configuration
.logicalAddresses
.IsEmpty())
1077 strLog
.append(", logical address(es) = ");
1078 CECDEVICEVEC devices
;
1079 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
1080 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
1081 strLog
.AppendFormat("%s (%X) ", (*it
)->GetLogicalAddressName(), (*it
)->GetLogicalAddress());
1084 if (!CLibCEC::IsValidPhysicalAddress(m_configuration
.iPhysicalAddress
))
1085 strLog
.AppendFormat(", base device: %s (%X), HDMI port number: %d", ToString(m_configuration
.baseDevice
), m_configuration
.baseDevice
, m_configuration
.iHDMIPort
);
1087 strLog
.AppendFormat(", physical address: %04x", m_configuration
.iPhysicalAddress
);
1092 void CCECClient::SetTVVendorOverride(const cec_vendor_id id
)
1095 CLockObject
lock(m_mutex
);
1096 m_configuration
.tvVendor
= id
;
1099 if (id
!= CEC_VENDOR_UNKNOWN
)
1101 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - vendor id '%s'", __FUNCTION__
, ToString(id
));
1103 CCECBusDevice
*tv
= m_processor
? m_processor
->GetTV() : NULL
;
1105 tv
->SetVendorId((uint64_t)id
);
1109 cec_vendor_id
CCECClient::GetTVVendorOverride(void)
1111 CLockObject
lock(m_mutex
);
1112 return (cec_vendor_id
)m_configuration
.tvVendor
;
1115 void CCECClient::SetOSDName(const CStdString
&strDeviceName
)
1118 CLockObject
lock(m_mutex
);
1119 snprintf(m_configuration
.strDeviceName
, 13, "%s", strDeviceName
.c_str());
1122 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - using OSD name '%s'", __FUNCTION__
, strDeviceName
.c_str());
1124 CCECBusDevice
*primary
= GetPrimaryDevice();
1125 if (primary
&& !primary
->GetCurrentOSDName().Equals(strDeviceName
))
1127 primary
->SetOSDName(strDeviceName
);
1128 if (m_processor
&& m_processor
->CECInitialised())
1129 primary
->TransmitOSDName(CECDEVICE_TV
);
1133 CStdString
CCECClient::GetOSDName(void)
1135 CLockObject
lock(m_mutex
);
1136 CStdString
strOSDName(m_configuration
.strDeviceName
);
1140 void CCECClient::SetWakeDevices(const cec_logical_addresses
&addresses
)
1142 CLockObject
lock(m_mutex
);
1143 m_configuration
.wakeDevices
= addresses
;
1146 cec_logical_addresses
CCECClient::GetWakeDevices(void)
1148 CLockObject
lock(m_mutex
);
1149 return m_configuration
.wakeDevices
;
1152 bool CCECClient::AutodetectPhysicalAddress(void)
1154 bool bPhysicalAutodetected(false);
1155 uint16_t iPhysicalAddress
= m_processor
? m_processor
->GetDetectedPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS
;
1157 if (CLibCEC::IsValidPhysicalAddress(iPhysicalAddress
))
1159 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - autodetected physical address '%04X'", __FUNCTION__
, iPhysicalAddress
);
1161 CLockObject
lock(m_mutex
);
1162 m_configuration
.iPhysicalAddress
= iPhysicalAddress
;
1163 m_configuration
.iHDMIPort
= CEC_HDMI_PORTNUMBER_NONE
;
1164 m_configuration
.baseDevice
= CECDEVICE_UNKNOWN
;
1165 bPhysicalAutodetected
= true;
1168 SetDevicePhysicalAddress(iPhysicalAddress
);
1170 return bPhysicalAutodetected
;
1173 void CCECClient::SetClientVersion(const cec_client_version version
)
1175 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - using client version '%s'", __FUNCTION__
, ToString(version
));
1177 CLockObject
lock(m_mutex
);
1178 m_configuration
.clientVersion
= (uint32_t)version
;
1181 cec_client_version
CCECClient::GetClientVersion(void)
1183 CLockObject
lock(m_mutex
);
1184 return (cec_client_version
)m_configuration
.clientVersion
;
1187 bool CCECClient::SetDeviceTypes(const cec_device_type_list
&deviceTypes
)
1189 bool bNeedReinit(false);
1192 CLockObject
lock(m_mutex
);
1193 bNeedReinit
= m_processor
&& m_processor
->CECInitialised() &&
1194 (m_configuration
.deviceTypes
!= deviceTypes
);
1195 m_configuration
.deviceTypes
= deviceTypes
;
1199 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - using primary device type '%s'", __FUNCTION__
, ToString(deviceTypes
[0]));
1204 cec_device_type_list
CCECClient::GetDeviceTypes(void)
1206 cec_device_type_list retVal
;
1207 CLockObject
lock(m_mutex
);
1208 retVal
= m_configuration
.deviceTypes
;
1212 bool CCECClient::SetDevicePhysicalAddress(const uint16_t iPhysicalAddress
)
1214 if (!CLibCEC::IsValidPhysicalAddress(iPhysicalAddress
))
1216 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - not setting invalid physical address %04x", __FUNCTION__
, iPhysicalAddress
);
1220 // reconfigure all devices
1221 cec_logical_address
reactivateSource(CECDEVICE_UNKNOWN
);
1222 CECDEVICEVEC devices
;
1223 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
1224 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
1226 // if this device was the active source, reactivate it afterwards
1227 if ((*it
)->IsActiveSource())
1228 reactivateSource
= (*it
)->GetLogicalAddress();
1230 // mark the device as inactive source
1231 if (IsInitialised())
1232 (*it
)->MarkAsInactiveSource();
1234 // set the new physical address
1235 (*it
)->SetPhysicalAddress(iPhysicalAddress
);
1238 if (IsInitialised())
1239 (*it
)->TransmitPhysicalAddress();
1242 // reactivate the previous active source
1243 if (reactivateSource
!= CECDEVICE_UNKNOWN
&&
1244 m_processor
->CECInitialised() &&
1247 CCECBusDevice
*device
= m_processor
->GetDevice(reactivateSource
);
1249 device
->ActivateSource();
1255 bool CCECClient::SwitchMonitoring(bool bEnable
)
1257 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, "== %s monitoring mode ==", bEnable
? "enabling" : "disabling");
1262 return m_processor
->UnregisterClient(this);
1265 m_configuration
.bMonitorOnly
= false;
1266 return m_processor
->RegisterClient(this);
1273 bool CCECClient::PollDevice(const cec_logical_address iAddress
)
1275 // try to find the primary device
1276 CCECBusDevice
*primary
= GetPrimaryDevice();
1277 // poll the destination, with the primary as source
1279 return primary
->TransmitPoll(iAddress
);
1281 return m_processor
? m_processor
->PollDevice(iAddress
) : false;
1284 cec_logical_addresses
CCECClient::GetActiveDevices(void)
1286 CECDEVICEVEC activeDevices
;
1288 m_processor
->GetDevices()->GetActive(activeDevices
);
1289 return CCECDeviceMap::ToLogicalAddresses(activeDevices
);
1292 bool CCECClient::IsActiveDevice(const cec_logical_address iAddress
)
1294 cec_logical_addresses activeDevices
= GetActiveDevices();
1295 return activeDevices
.IsSet(iAddress
);
1298 bool CCECClient::IsActiveDeviceType(const cec_device_type type
)
1300 CECDEVICEVEC activeDevices
;
1302 m_processor
->GetDevices()->GetActive(activeDevices
);
1303 CCECDeviceMap::FilterType(type
, activeDevices
);
1304 return !activeDevices
.empty();
1307 cec_logical_address
CCECClient::GetActiveSource(void)
1309 return m_processor
? m_processor
->GetActiveSource() : CECDEVICE_UNKNOWN
;
1312 bool CCECClient::IsActiveSource(const cec_logical_address iAddress
)
1314 return m_processor
? m_processor
->IsActiveSource(iAddress
) : false;
1317 bool CCECClient::SetStreamPath(const cec_logical_address iAddress
)
1319 uint16_t iPhysicalAddress
= GetDevicePhysicalAddress(iAddress
);
1320 if (iPhysicalAddress
!= CEC_INVALID_PHYSICAL_ADDRESS
)
1321 return SetStreamPath(iPhysicalAddress
);
1325 bool CCECClient::SetStreamPath(const uint16_t iPhysicalAddress
)
1327 return m_processor
? m_processor
->SetStreamPath(iPhysicalAddress
) : false;
1330 cec_logical_addresses
CCECClient::GetLogicalAddresses(void)
1332 cec_logical_addresses addresses
;
1333 CLockObject
lock(m_mutex
);
1334 addresses
= m_configuration
.logicalAddresses
;
1338 bool CCECClient::CanPersistConfiguration(void)
1340 return m_processor
? m_processor
->CanPersistConfiguration() : false;
1343 bool CCECClient::PersistConfiguration(const libcec_configuration
&configuration
)
1345 return m_processor
? m_processor
->PersistConfiguration(configuration
) : false;
1348 void CCECClient::RescanActiveDevices(void)
1351 m_processor
->RescanActiveDevices();
1354 bool CCECClient::IsLibCECActiveSource(void)
1356 bool bReturn(false);
1359 cec_logical_address activeSource
= m_processor
->GetActiveSource();
1360 CCECBusDevice
*device
= m_processor
->GetDevice(activeSource
);
1362 bReturn
= device
->IsHandledByLibCEC();