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 m_configuration
.Clear();
57 // set the initial configuration
58 SetConfiguration(configuration
);
61 CCECClient::~CCECClient(void)
63 // unregister the client
64 if (m_processor
&& IsRegistered())
65 m_processor
->UnregisterClient(this);
68 bool CCECClient::IsInitialised(void)
70 CLockObject
lock(m_mutex
);
71 return m_bInitialised
&& m_processor
;
74 void CCECClient::SetInitialised(bool bSetTo
)
76 CLockObject
lock(m_mutex
);
77 m_bInitialised
= bSetTo
;
80 bool CCECClient::IsRegistered(void)
82 CLockObject
lock(m_mutex
);
83 return m_bRegistered
&& m_processor
;
86 void CCECClient::SetRegistered(bool bSetTo
)
88 CLockObject
lock(m_mutex
);
89 m_bRegistered
= bSetTo
;
92 bool CCECClient::OnRegister(void)
94 // return false if already initialised
98 // get all device we control
100 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
102 // return false when no devices were found
105 LIB_CEC
->AddLog(CEC_LOG_WARNING
, "cannot find the primary device (logical address %x)", GetPrimaryLogicalAdddress());
109 // mark as initialised
110 SetInitialised(true);
112 // configure all devices
113 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
115 // only set our OSD name for the primary device
116 if ((*it
)->GetLogicalAddress() == GetPrimaryLogicalAdddress())
117 (*it
)->SetOSDName(m_configuration
.strDeviceName
);
119 // set the default menu language for devices we control
120 (*it
)->SetMenuLanguage(m_configuration
.strDeviceLanguage
);
123 // set the physical address
124 SetPhysicalAddress(m_configuration
);
126 // make the primary device the active source if the option is set
127 if (m_configuration
.bActivateSource
== 1)
128 GetPrimaryDevice()->ActivateSource(500);
133 bool CCECClient::SetHDMIPort(const cec_logical_address iBaseDevice
, const uint8_t iPort
, bool bForce
/* = false */)
137 // limit the HDMI port range to 1-15
138 if (iPort
< CEC_MIN_HDMI_PORTNUMBER
||
139 iPort
> CEC_MAX_HDMI_PORTNUMBER
)
142 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, "setting HDMI port to %d on device %s (%d)", iPort
, ToString(iBaseDevice
), (int)iBaseDevice
);
144 // update the configuration
146 CLockObject
lock(m_mutex
);
147 m_configuration
.baseDevice
= iBaseDevice
;
148 m_configuration
.iHDMIPort
= iPort
;
151 // don't continue if the connection isn't opened
152 if (!m_processor
->CECInitialised() && !bForce
)
155 // get the PA of the base device
156 uint16_t iPhysicalAddress(CEC_INVALID_PHYSICAL_ADDRESS
);
157 CCECBusDevice
*baseDevice
= m_processor
->GetDevice(iBaseDevice
);
159 iPhysicalAddress
= baseDevice
->GetPhysicalAddress(GetPrimaryLogicalAdddress());
161 // add our port number
162 if (iPhysicalAddress
<= CEC_MAX_PHYSICAL_ADDRESS
)
164 if (iPhysicalAddress
== 0)
165 iPhysicalAddress
+= 0x1000 * iPort
;
166 else if (iPhysicalAddress
% 0x1000 == 0)
167 iPhysicalAddress
+= 0x100 * iPort
;
168 else if (iPhysicalAddress
% 0x100 == 0)
169 iPhysicalAddress
+= 0x10 * iPort
;
170 else if (iPhysicalAddress
% 0x10 == 0)
171 iPhysicalAddress
+= iPort
;
176 // set the default address when something went wrong
179 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
);
180 iPhysicalAddress
= CEC_DEFAULT_PHYSICAL_ADDRESS
;
183 // and set the address
184 SetDevicePhysicalAddress(iPhysicalAddress
);
186 ConfigurationChanged(m_configuration
);
191 void CCECClient::ResetPhysicalAddress(void)
193 SetPhysicalAddress(m_configuration
);
196 void CCECClient::SetPhysicalAddress(const libcec_configuration
&configuration
)
200 // override the physical address from configuration.iPhysicalAddress if it's set
201 if (!bPASet
&& CLibCEC::IsValidPhysicalAddress(configuration
.iPhysicalAddress
))
202 bPASet
= SetPhysicalAddress(configuration
.iPhysicalAddress
);
204 // try to autodetect the address
205 if (!bPASet
&& m_processor
->CECInitialised())
207 bPASet
= AutodetectPhysicalAddress();
208 m_configuration
.bAutodetectAddress
= bPASet
? 1 : 0;
211 // use the base device + hdmi port settings
213 bPASet
= SetHDMIPort(configuration
.baseDevice
, configuration
.iHDMIPort
);
215 // reset to defaults if something went wrong
218 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - resetting HDMI port and base device to defaults", __FUNCTION__
);
219 m_configuration
.baseDevice
= CECDEVICE_UNKNOWN
;
220 m_configuration
.iHDMIPort
= CEC_HDMI_PORTNUMBER_NONE
;
224 bool CCECClient::SetPhysicalAddress(const uint16_t iPhysicalAddress
)
226 // update the configuration
228 CLockObject
lock(m_mutex
);
229 if (m_configuration
.iPhysicalAddress
== iPhysicalAddress
)
231 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "physical address unchanged (%04X)", iPhysicalAddress
);
236 m_configuration
.iPhysicalAddress
= iPhysicalAddress
;
237 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "setting physical address to '%04X'", iPhysicalAddress
);
241 // persist the new configuration
242 m_processor
->PersistConfiguration(m_configuration
);
244 // set the physical address for each device
245 SetDevicePhysicalAddress(iPhysicalAddress
);
247 // and send back the updated configuration
248 ConfigurationChanged(m_configuration
);
253 void CCECClient::SetSupportedDeviceTypes(void)
255 cec_device_type_list types
;
258 // get the command handler for the tv
259 CCECCommandHandler
*tvHandler
= m_processor
->GetTV()->GetHandler();
263 // check all device types
264 for (uint8_t iPtr
= 0; iPtr
< 5; iPtr
++)
266 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_RESERVED
)
269 // get the supported device type. the handler will replace types it doesn't support by one it does support
270 cec_device_type type
= tvHandler
->GetReplacementDeviceType(m_configuration
.deviceTypes
.types
[iPtr
]);
271 if (!types
.IsSet(type
))
274 m_processor
->GetTV()->MarkHandlerReady();
276 // set the new type list
277 m_configuration
.deviceTypes
= types
;
280 bool CCECClient::AllocateLogicalAddresses(void)
282 // reset all previous LAs that were set
283 m_configuration
.logicalAddresses
.Clear();
285 // get the supported device types from the command handler of the TV
286 SetSupportedDeviceTypes();
288 // display an error if no device types are set
289 if (m_configuration
.deviceTypes
.IsEmpty())
291 LIB_CEC
->AddLog(CEC_LOG_ERROR
, "no device types given");
295 // check each entry of the list
296 for (uint8_t iPtr
= 0; iPtr
< 5; iPtr
++)
298 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_RESERVED
)
301 // find an LA for this type
302 cec_logical_address
address(CECDEVICE_UNKNOWN
);
303 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_RECORDING_DEVICE
)
304 address
= AllocateLogicalAddressRecordingDevice();
305 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_TUNER
)
306 address
= AllocateLogicalAddressTuner();
307 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_PLAYBACK_DEVICE
)
308 address
= AllocateLogicalAddressPlaybackDevice();
309 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_AUDIO_SYSTEM
)
310 address
= AllocateLogicalAddressAudioSystem();
312 // display an error if no LA could be allocated
313 if (address
== CECDEVICE_UNKNOWN
)
315 LIB_CEC
->AddLog(CEC_LOG_ERROR
, "%s - failed to allocate device '%d', type '%s'", __FUNCTION__
, iPtr
, ToString(m_configuration
.deviceTypes
.types
[iPtr
]));
319 // display the registered LA
320 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - device '%d', type '%s', LA '%X'", __FUNCTION__
, iPtr
, ToString(m_configuration
.deviceTypes
.types
[iPtr
]), address
);
321 m_configuration
.logicalAddresses
.Set(address
);
327 cec_logical_address
CCECClient::AllocateLogicalAddressRecordingDevice(void)
329 cec_logical_address
retVal(CECDEVICE_UNKNOWN
);
331 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'recording device'");
332 if (m_processor
->TryLogicalAddress(CECDEVICE_RECORDINGDEVICE1
))
333 retVal
= CECDEVICE_RECORDINGDEVICE1
;
334 else if (m_processor
->TryLogicalAddress(CECDEVICE_RECORDINGDEVICE2
))
335 retVal
= CECDEVICE_RECORDINGDEVICE2
;
336 else if (m_processor
->TryLogicalAddress(CECDEVICE_RECORDINGDEVICE3
))
337 retVal
= CECDEVICE_RECORDINGDEVICE3
;
342 cec_logical_address
CCECClient::AllocateLogicalAddressTuner(void)
344 cec_logical_address
retVal(CECDEVICE_UNKNOWN
);
346 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'tuner'");
347 if (m_processor
->TryLogicalAddress(CECDEVICE_TUNER1
))
348 retVal
= CECDEVICE_TUNER1
;
349 else if (m_processor
->TryLogicalAddress(CECDEVICE_TUNER2
))
350 retVal
= CECDEVICE_TUNER2
;
351 else if (m_processor
->TryLogicalAddress(CECDEVICE_TUNER3
))
352 retVal
= CECDEVICE_TUNER3
;
353 else if (m_processor
->TryLogicalAddress(CECDEVICE_TUNER4
))
354 retVal
= CECDEVICE_TUNER4
;
359 cec_logical_address
CCECClient::AllocateLogicalAddressPlaybackDevice(void)
361 cec_logical_address
retVal(CECDEVICE_UNKNOWN
);
363 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'playback device'");
364 if (m_processor
->TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE1
))
365 retVal
= CECDEVICE_PLAYBACKDEVICE1
;
366 else if (m_processor
->TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE2
))
367 retVal
= CECDEVICE_PLAYBACKDEVICE2
;
368 else if (m_processor
->TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE3
))
369 retVal
= CECDEVICE_PLAYBACKDEVICE3
;
374 cec_logical_address
CCECClient::AllocateLogicalAddressAudioSystem(void)
376 cec_logical_address
retVal(CECDEVICE_UNKNOWN
);
378 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'audiosystem'");
379 if (m_processor
->TryLogicalAddress(CECDEVICE_AUDIOSYSTEM
))
380 retVal
= CECDEVICE_AUDIOSYSTEM
;
385 CCECBusDevice
*CCECClient::GetDeviceByType(const cec_device_type type
) const
387 // get all devices that match our logical addresses
388 CECDEVICEVEC devices
;
389 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
391 // filter the type we need
392 CCECDeviceMap::FilterType(type
, devices
);
394 return devices
.empty() ?
399 bool CCECClient::ChangeDeviceType(const cec_device_type from
, const cec_device_type to
)
401 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, "changing device type '%s' into '%s'", ToString(from
), ToString(to
));
403 CLockObject
lock(m_mutex
);
405 // get the previous device that was allocated
406 CCECBusDevice
*previousDevice
= GetDeviceByType(from
);
410 // change the type in the device type list
411 bool bChanged(false);
412 for (uint8_t iPtr
= 0; iPtr
< 5; iPtr
++)
414 if (m_configuration
.deviceTypes
.types
[iPtr
] == CEC_DEVICE_TYPE_RESERVED
)
417 if (m_configuration
.deviceTypes
.types
[iPtr
] == from
)
420 m_configuration
.deviceTypes
.types
[iPtr
] = to
;
422 else if (m_configuration
.deviceTypes
.types
[iPtr
] == to
&& bChanged
)
424 // ensure that dupes are removed
425 m_configuration
.deviceTypes
.types
[iPtr
] = CEC_DEVICE_TYPE_RESERVED
;
429 // re-register the client to set the new ackmask
430 if (!m_processor
->RegisterClient(this))
436 bool CCECClient::SetLogicalAddress(const cec_logical_address iLogicalAddress
)
438 CLockObject
lock(m_mutex
);
439 if (GetPrimaryLogicalAdddress() != iLogicalAddress
)
442 CLockObject
lock(m_mutex
);
443 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, "<< setting primary logical address to %1x", iLogicalAddress
);
444 m_configuration
.logicalAddresses
.primary
= iLogicalAddress
;
445 m_configuration
.logicalAddresses
.Set(iLogicalAddress
);
447 return m_processor
->RegisterClient(this);
453 bool CCECClient::Transmit(const cec_command
&data
)
455 return m_processor
? m_processor
->Transmit(data
) : false;
458 bool CCECClient::SendPowerOnDevices(const cec_logical_address address
/* = CECDEVICE_TV */)
460 // if the broadcast address if set as destination and the client version >=1.5.0, read the wakeDevices setting
461 if (address
== CECDEVICE_BROADCAST
&& m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_0
)
463 CECDEVICEVEC devices
;
464 m_processor
->GetDevices()->GetWakeDevices(m_configuration
, devices
);
465 return m_processor
->PowerOnDevices(GetPrimaryLogicalAdddress(), devices
);
468 return m_processor
->PowerOnDevice(GetPrimaryLogicalAdddress(), address
);
471 bool CCECClient::SendStandbyDevices(const cec_logical_address address
/* = CECDEVICE_BROADCAST */)
473 // if the broadcast address if set as destination and the client version >=1.5.0, read the standbyDevices setting
474 if (address
== CECDEVICE_BROADCAST
&& m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_0
)
476 CECDEVICEVEC devices
;
477 m_processor
->GetDevices()->GetPowerOffDevices(m_configuration
, devices
);
478 return m_processor
->StandbyDevices(GetPrimaryLogicalAdddress(), devices
);
481 return m_processor
->StandbyDevice(GetPrimaryLogicalAdddress(), address
);
484 bool CCECClient::SendSetActiveSource(const cec_device_type type
/* = CEC_DEVICE_TYPE_RESERVED */)
486 // get the devices that are controlled by us
487 CECDEVICEVEC devices
;
488 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
490 // filter out the device that matches the given type
491 if (type
!= CEC_DEVICE_TYPE_RESERVED
)
492 CCECDeviceMap::FilterType(type
, devices
);
494 // no devices left, re-fetch the list of devices that are controlled by us
496 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
498 if (!devices
.empty())
500 // get the first device from the list
501 CCECBusDevice
*device
= *devices
.begin();
504 if (!m_processor
->CECInitialised())
505 device
->MarkAsActiveSource();
506 else if (device
->HasValidPhysicalAddress())
507 return device
->ActivateSource();
513 CCECPlaybackDevice
*CCECClient::GetPlaybackDevice(void)
515 CCECPlaybackDevice
*device(NULL
);
516 CECDEVICEVEC devices
;
518 // get the playback devices
519 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
520 CCECDeviceMap::FilterType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE
, devices
);
522 // no matches, get the recording devices
525 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
526 CCECDeviceMap::FilterType(CEC_DEVICE_TYPE_RECORDING_DEVICE
, devices
);
529 // get the first device that matches, and cast it to CCECPlaybackDevice
530 if (!devices
.empty())
531 device
= (*devices
.begin())->AsPlaybackDevice();
536 cec_logical_address
CCECClient::GetPrimaryLogicalAdddress(void)
538 CLockObject
lock(m_mutex
);
539 return m_configuration
.logicalAddresses
.primary
;
542 CCECBusDevice
*CCECClient::GetPrimaryDevice(void)
544 return m_processor
->GetDevice(GetPrimaryLogicalAdddress());
547 bool CCECClient::SendSetDeckControlMode(const cec_deck_control_mode mode
, bool bSendUpdate
/* = true */)
549 // find a playback device that we control
550 CCECPlaybackDevice
*device
= GetPlaybackDevice();
553 // and set the deck control mode if there is a match
554 device
->SetDeckControlMode(mode
);
556 return device
->TransmitDeckStatus(CECDEVICE_TV
);
564 bool CCECClient::SendSetDeckInfo(const cec_deck_info info
, bool bSendUpdate
/* = true */)
566 // find a playback device that we control
567 CCECPlaybackDevice
*device
= GetPlaybackDevice();
570 // and set the deck status if there is a match
571 device
->SetDeckStatus(info
);
573 return device
->AsPlaybackDevice()->TransmitDeckStatus(CECDEVICE_TV
);
581 bool CCECClient::SendSetMenuState(const cec_menu_state state
, bool bSendUpdate
/* = true */)
583 CECDEVICEVEC devices
;
585 // set the menu state for all devices that are controlled by us
586 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
587 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
589 (*it
)->SetMenuState(state
);
591 (*it
)->TransmitMenuState(CECDEVICE_TV
);
597 bool CCECClient::SendSetInactiveView(void)
599 CECDEVICEVEC devices
;
601 // mark all devices that are controlled by us as inactive source
602 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
603 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
605 if ((*it
)->IsActiveSource())
607 (*it
)->MarkAsInactiveSource();
608 return (*it
)->TransmitInactiveSource();
615 bool CCECClient::SendSetOSDString(const cec_logical_address iLogicalAddress
, const cec_display_control duration
, const char *strMessage
)
617 CCECBusDevice
*primary
= GetPrimaryDevice();
619 return primary
->TransmitOSDString(iLogicalAddress
, duration
, strMessage
);
624 cec_version
CCECClient::GetDeviceCecVersion(const cec_logical_address iAddress
)
626 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
628 return device
->GetCecVersion(GetPrimaryLogicalAdddress());
629 return CEC_VERSION_UNKNOWN
;
632 bool CCECClient::GetDeviceMenuLanguage(const cec_logical_address iAddress
, cec_menu_language
&language
)
634 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
637 language
= device
->GetMenuLanguage(GetPrimaryLogicalAdddress());
638 return (strcmp(language
.language
, "???") != 0);
643 cec_osd_name
CCECClient::GetDeviceOSDName(const cec_logical_address iAddress
)
646 retVal
.device
= iAddress
;
649 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
652 CStdString strOSDName
= device
->GetOSDName(GetPrimaryLogicalAdddress());
653 snprintf(retVal
.name
, sizeof(retVal
.name
), "%s", strOSDName
.c_str());
654 retVal
.device
= iAddress
;
660 uint16_t CCECClient::GetDevicePhysicalAddress(const cec_logical_address iAddress
)
662 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
664 return device
->GetPhysicalAddress(GetPrimaryLogicalAdddress());
665 return CEC_INVALID_PHYSICAL_ADDRESS
;
668 cec_power_status
CCECClient::GetDevicePowerStatus(const cec_logical_address iAddress
)
670 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
672 return device
->GetPowerStatus(GetPrimaryLogicalAdddress());
673 return CEC_POWER_STATUS_UNKNOWN
;
676 uint64_t CCECClient::GetDeviceVendorId(const cec_logical_address iAddress
)
678 CCECBusDevice
*device
= m_processor
->GetDevice(iAddress
);
680 return device
->GetVendorId(GetPrimaryLogicalAdddress());
681 return CEC_VENDOR_UNKNOWN
;
684 uint8_t CCECClient::SendVolumeUp(bool bSendRelease
/* = true */)
686 CCECBusDevice
*device
= GetPrimaryDevice();
687 CCECAudioSystem
*audio
= m_processor
->GetAudioSystem();
689 return device
&& audio
&& audio
->IsPresent() ?
690 audio
->VolumeUp(device
->GetLogicalAddress(), bSendRelease
) :
691 (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
694 uint8_t CCECClient::SendVolumeDown(bool bSendRelease
/* = true */)
696 CCECBusDevice
*device
= GetPrimaryDevice();
697 CCECAudioSystem
*audio
= m_processor
->GetAudioSystem();
699 return device
&& audio
&& audio
->IsPresent() ?
700 audio
->VolumeDown(device
->GetLogicalAddress(), bSendRelease
) :
701 (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
704 uint8_t CCECClient::SendMuteAudio(void)
706 CCECBusDevice
*device
= GetPrimaryDevice();
707 CCECAudioSystem
*audio
= m_processor
->GetAudioSystem();
709 return device
&& audio
&& audio
->IsPresent() ?
710 audio
->MuteAudio(device
->GetLogicalAddress()) :
711 (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
714 bool CCECClient::SendKeypress(const cec_logical_address iDestination
, const cec_user_control_code key
, bool bWait
/* = true */)
716 CCECBusDevice
*dest
= m_processor
->GetDevice(iDestination
);
719 dest
->TransmitKeypress(GetPrimaryLogicalAdddress(), key
, bWait
) :
723 bool CCECClient::SendKeyRelease(const cec_logical_address iDestination
, bool bWait
/* = true */)
725 CCECBusDevice
*dest
= m_processor
->GetDevice(iDestination
);
728 dest
->TransmitKeyRelease(GetPrimaryLogicalAdddress(), bWait
) :
732 bool CCECClient::GetCurrentConfiguration(libcec_configuration
&configuration
)
734 CLockObject
lock(m_mutex
);
736 // client version 1.5.0
737 snprintf(configuration
.strDeviceName
, 13, "%s", m_configuration
.strDeviceName
);
738 configuration
.deviceTypes
= m_configuration
.deviceTypes
;
739 configuration
.bAutodetectAddress
= m_configuration
.bAutodetectAddress
;
740 configuration
.iPhysicalAddress
= m_configuration
.iPhysicalAddress
;
741 configuration
.baseDevice
= m_configuration
.baseDevice
;
742 configuration
.iHDMIPort
= m_configuration
.iHDMIPort
;
743 configuration
.clientVersion
= m_configuration
.clientVersion
;
744 configuration
.serverVersion
= m_configuration
.serverVersion
;
745 configuration
.tvVendor
= m_configuration
.tvVendor
;
747 configuration
.bGetSettingsFromROM
= m_configuration
.bGetSettingsFromROM
;
748 configuration
.bUseTVMenuLanguage
= m_configuration
.bUseTVMenuLanguage
;
749 configuration
.bActivateSource
= m_configuration
.bActivateSource
;
750 configuration
.wakeDevices
= m_configuration
.wakeDevices
;
751 configuration
.powerOffDevices
= m_configuration
.powerOffDevices
;
752 configuration
.bPowerOffScreensaver
= m_configuration
.bPowerOffScreensaver
;
753 configuration
.bPowerOffOnStandby
= m_configuration
.bPowerOffOnStandby
;
755 // client version 1.5.1
756 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_1
)
757 configuration
.bSendInactiveSource
= m_configuration
.bSendInactiveSource
;
759 // client version 1.5.3
760 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_3
)
761 configuration
.logicalAddresses
= m_configuration
.logicalAddresses
;
763 // client version 1.6.0
764 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_0
)
766 configuration
.iFirmwareVersion
= m_configuration
.iFirmwareVersion
;
767 configuration
.bPowerOffDevicesOnStandby
= m_configuration
.bPowerOffDevicesOnStandby
;
768 configuration
.bShutdownOnStandby
= m_configuration
.bShutdownOnStandby
;
771 // client version 1.6.2
772 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_2
)
774 memcpy(configuration
.strDeviceLanguage
, m_configuration
.strDeviceLanguage
, 3);
775 configuration
.iFirmwareBuildDate
= m_configuration
.iFirmwareBuildDate
;
778 // client version 1.6.3
779 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_3
)
781 configuration
.bMonitorOnly
= m_configuration
.bMonitorOnly
;
787 bool CCECClient::SetConfiguration(const libcec_configuration
&configuration
)
789 bool bIsRunning(m_processor
&& m_processor
->CECInitialised());
790 CCECBusDevice
*primary
= bIsRunning
? GetPrimaryDevice() : NULL
;
791 uint16_t iPA
= primary
? primary
->GetCurrentPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS
;
793 // update the callbacks
794 if (configuration
.callbacks
)
795 EnableCallbacks(configuration
.callbackParam
, configuration
.callbacks
);
797 // update the client version
798 SetClientVersion((cec_client_version
)configuration
.clientVersion
);
800 // update the OSD name
801 CStdString
strOSDName(configuration
.strDeviceName
);
802 SetOSDName(strOSDName
);
804 // update the TV vendor override
805 SetTVVendorOverride((cec_vendor_id
)configuration
.tvVendor
);
809 CLockObject
lock(m_mutex
);
810 m_configuration
.bUseTVMenuLanguage
= configuration
.bUseTVMenuLanguage
;
811 m_configuration
.bActivateSource
= configuration
.bActivateSource
;
812 m_configuration
.bGetSettingsFromROM
= configuration
.bGetSettingsFromROM
;
813 m_configuration
.wakeDevices
= configuration
.wakeDevices
;
814 m_configuration
.powerOffDevices
= configuration
.powerOffDevices
;
815 m_configuration
.bPowerOffScreensaver
= configuration
.bPowerOffScreensaver
;
816 m_configuration
.bPowerOffOnStandby
= configuration
.bPowerOffOnStandby
;
818 // client version 1.5.1
819 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_1
)
820 m_configuration
.bSendInactiveSource
= configuration
.bSendInactiveSource
;
822 // client version 1.6.0
823 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_0
)
825 m_configuration
.bPowerOffDevicesOnStandby
= configuration
.bPowerOffDevicesOnStandby
;
826 m_configuration
.bShutdownOnStandby
= configuration
.bShutdownOnStandby
;
829 // client version 1.6.2
830 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_2
)
832 memcpy(m_configuration
.strDeviceLanguage
, configuration
.strDeviceLanguage
, 3);
835 // client version 1.6.3
836 if (configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_3
)
838 m_configuration
.bMonitorOnly
= configuration
.bMonitorOnly
;
841 // ensure that there is at least 1 device type set
842 if (m_configuration
.deviceTypes
.IsEmpty())
843 m_configuration
.deviceTypes
.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE
);
846 bool bNeedReinit(false);
849 if (SetDeviceTypes(configuration
.deviceTypes
))
851 // the device type changed. just copy the rest, and re-register
853 CLockObject
lock(m_mutex
);
854 m_configuration
.iPhysicalAddress
= configuration
.iPhysicalAddress
;
855 m_configuration
.baseDevice
= configuration
.baseDevice
;
856 m_configuration
.iHDMIPort
= configuration
.iHDMIPort
;
862 // set the physical address
863 SetPhysicalAddress(configuration
);
866 m_processor
->PersistConfiguration(m_configuration
);
869 primary
= GetPrimaryDevice();
871 if (bNeedReinit
|| !primary
|| primary
->GetCurrentPhysicalAddress() != iPA
)
873 // PA or device type changed
874 m_processor
->RegisterClient(this);
876 else if (primary
&& configuration
.bActivateSource
== 1 && bIsRunning
&& !primary
->IsActiveSource())
878 // activate the source if we're not already the active source
879 primary
->ActivateSource();
885 void CCECClient::AddCommand(const cec_command
&command
)
887 // don't forward the standby opcode more than once every 10 seconds
888 if (command
.opcode
== CEC_OPCODE_STANDBY
)
890 CLockObject
lock(m_mutex
);
891 if (m_iPreventForwardingPowerOffCommand
!= 0 &&
892 m_iPreventForwardingPowerOffCommand
> GetTimeMs())
895 m_iPreventForwardingPowerOffCommand
= GetTimeMs() + CEC_FORWARD_STANDBY_MIN_INTERVAL
;
898 if (command
.destination
== CECDEVICE_BROADCAST
|| GetLogicalAddresses().IsSet(command
.destination
))
900 CLockObject
lock(m_mutex
);
902 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
);
904 if (m_configuration
.callbacks
&& m_configuration
.callbacks
->CBCecCommand
)
905 m_configuration
.callbacks
->CBCecCommand(m_configuration
.callbackParam
, command
);
906 else if (!m_commandBuffer
.Push(command
))
907 LIB_CEC
->AddLog(CEC_LOG_WARNING
, "command buffer is full");
911 int CCECClient::MenuStateChanged(const cec_menu_state newState
)
913 CLockObject
lock(m_mutex
);
915 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, ">> %s: %s", ToString(CEC_OPCODE_MENU_REQUEST
), ToString(newState
));
917 if (m_configuration
.callbacks
&&
918 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_2
&&
919 m_configuration
.callbacks
->CBCecMenuStateChanged
)
920 return m_configuration
.callbacks
->CBCecMenuStateChanged(m_configuration
.callbackParam
, newState
);
925 void CCECClient::SourceActivated(const cec_logical_address logicalAddress
)
927 CLockObject
lock(m_mutex
);
929 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, ">> source activated: %s (%x)", ToString(logicalAddress
), logicalAddress
);
931 if (m_configuration
.callbacks
&&
932 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_7_1
&&
933 m_configuration
.callbacks
->CBCecSourceActivated
)
934 m_configuration
.callbacks
->CBCecSourceActivated(m_configuration
.callbackParam
, logicalAddress
, 1);
937 void CCECClient::SourceDeactivated(const cec_logical_address logicalAddress
)
939 CLockObject
lock(m_mutex
);
941 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, ">> source deactivated: %s (%x)", ToString(logicalAddress
), logicalAddress
);
943 if (m_configuration
.callbacks
&&
944 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_7_1
&&
945 m_configuration
.callbacks
->CBCecSourceActivated
)
946 m_configuration
.callbacks
->CBCecSourceActivated(m_configuration
.callbackParam
, logicalAddress
, 0);
949 void CCECClient::Alert(const libcec_alert type
, const libcec_parameter
¶m
)
951 CLockObject
lock(m_mutex
);
953 if (m_configuration
.callbacks
&&
954 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_6_0
&&
955 m_configuration
.callbacks
->CBCecAlert
)
956 m_configuration
.callbacks
->CBCecAlert(m_configuration
.callbackParam
, type
, param
);
959 void CCECClient::AddLog(const cec_log_message
&message
)
961 CLockObject
lock(m_logMutex
);
962 if (m_configuration
.callbacks
&& m_configuration
.callbacks
->CBCecLogMessage
)
963 m_configuration
.callbacks
->CBCecLogMessage(m_configuration
.callbackParam
, message
);
965 m_logBuffer
.Push(message
);
968 void CCECClient::AddKey(void)
970 CLockObject
lock(m_mutex
);
972 if (m_iCurrentButton
!= CEC_USER_CONTROL_CODE_UNKNOWN
)
976 key
.duration
= (unsigned int) (GetTimeMs() - m_buttontime
);
977 key
.keycode
= m_iCurrentButton
;
978 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "key released: %1x", key
.keycode
);
980 if (m_configuration
.callbacks
&& m_configuration
.callbacks
->CBCecKeyPress
)
981 m_configuration
.callbacks
->CBCecKeyPress(m_configuration
.callbackParam
, key
);
983 m_keyBuffer
.Push(key
);
984 m_iCurrentButton
= CEC_USER_CONTROL_CODE_UNKNOWN
;
990 void CCECClient::AddKey(const cec_keypress
&key
)
992 CLockObject
lock(m_mutex
);
994 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "key pressed: %1x", key
.keycode
);
996 if (m_configuration
.callbacks
&& m_configuration
.callbacks
->CBCecKeyPress
)
997 m_configuration
.callbacks
->CBCecKeyPress(m_configuration
.callbackParam
, key
);
999 m_keyBuffer
.Push(key
);
1001 m_iCurrentButton
= key
.duration
> 0 ? CEC_USER_CONTROL_CODE_UNKNOWN
: key
.keycode
;
1002 m_buttontime
= key
.duration
> 0 ? 0 : GetTimeMs();
1005 void CCECClient::SetCurrentButton(const cec_user_control_code iButtonCode
)
1007 // push a keypress to the buffer with 0 duration and another with the duration set when released
1010 key
.keycode
= iButtonCode
;
1015 void CCECClient::CheckKeypressTimeout(void)
1017 if (m_iCurrentButton
!= CEC_USER_CONTROL_CODE_UNKNOWN
&& GetTimeMs() - m_buttontime
> CEC_BUTTON_TIMEOUT
)
1020 m_iCurrentButton
= CEC_USER_CONTROL_CODE_UNKNOWN
;
1024 void CCECClient::ConfigurationChanged(const libcec_configuration
&config
)
1026 CLockObject
lock(m_mutex
);
1028 if (m_configuration
.callbacks
&&
1029 m_configuration
.clientVersion
>= CEC_CLIENT_VERSION_1_5_0
&&
1030 m_configuration
.callbacks
->CBCecConfigurationChanged
&&
1031 m_processor
->CECInitialised())
1032 m_configuration
.callbacks
->CBCecConfigurationChanged(m_configuration
.callbackParam
, config
);
1035 bool CCECClient::EnableCallbacks(void *cbParam
, ICECCallbacks
*callbacks
)
1037 CLockObject
lock(m_mutex
);
1038 m_configuration
.callbackParam
= cbParam
;
1039 m_configuration
.callbacks
= callbacks
;
1043 bool CCECClient::PingAdapter(void)
1045 return m_processor
? m_processor
->PingAdapter() : false;
1048 bool CCECClient::GetNextLogMessage(cec_log_message
*message
)
1050 return (m_logBuffer
.Pop(*message
));
1053 bool CCECClient::GetNextKeypress(cec_keypress
*key
)
1055 return m_keyBuffer
.Pop(*key
);
1058 bool CCECClient::GetNextCommand(cec_command
*command
)
1060 return m_commandBuffer
.Pop(*command
);
1063 CStdString
CCECClient::GetConnectionInfo(void)
1066 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
);
1067 if (m_configuration
.iFirmwareBuildDate
!= CEC_FW_BUILD_UNKNOWN
)
1069 time_t buildTime
= (time_t)m_configuration
.iFirmwareBuildDate
;
1070 strLog
.AppendFormat(", firmware build date: %s", asctime(gmtime(&buildTime
)));
1071 strLog
= strLog
.Left((int)strLog
.length() - 1); // strip \n added by asctime
1072 strLog
.append(" +0000");
1075 // log the addresses that are being used
1076 if (!m_configuration
.logicalAddresses
.IsEmpty())
1078 strLog
.append(", logical address(es) = ");
1079 CECDEVICEVEC devices
;
1080 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
1081 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
1082 strLog
.AppendFormat("%s (%X) ", (*it
)->GetLogicalAddressName(), (*it
)->GetLogicalAddress());
1085 if (!CLibCEC::IsValidPhysicalAddress(m_configuration
.iPhysicalAddress
))
1086 strLog
.AppendFormat(", base device: %s (%X), HDMI port number: %d", ToString(m_configuration
.baseDevice
), m_configuration
.baseDevice
, m_configuration
.iHDMIPort
);
1088 strLog
.AppendFormat(", physical address: %04x", m_configuration
.iPhysicalAddress
);
1093 void CCECClient::SetTVVendorOverride(const cec_vendor_id id
)
1096 CLockObject
lock(m_mutex
);
1097 m_configuration
.tvVendor
= id
;
1100 if (id
!= CEC_VENDOR_UNKNOWN
)
1102 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - vendor id '%s'", __FUNCTION__
, ToString(id
));
1104 CCECBusDevice
*tv
= m_processor
? m_processor
->GetTV() : NULL
;
1106 tv
->SetVendorId((uint64_t)id
);
1110 cec_vendor_id
CCECClient::GetTVVendorOverride(void)
1112 CLockObject
lock(m_mutex
);
1113 return (cec_vendor_id
)m_configuration
.tvVendor
;
1116 void CCECClient::SetOSDName(const CStdString
&strDeviceName
)
1119 CLockObject
lock(m_mutex
);
1120 snprintf(m_configuration
.strDeviceName
, 13, "%s", strDeviceName
.c_str());
1123 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - using OSD name '%s'", __FUNCTION__
, strDeviceName
.c_str());
1125 CCECBusDevice
*primary
= GetPrimaryDevice();
1126 if (primary
&& !primary
->GetCurrentOSDName().Equals(strDeviceName
))
1128 primary
->SetOSDName(strDeviceName
);
1129 if (m_processor
&& m_processor
->CECInitialised())
1130 primary
->TransmitOSDName(CECDEVICE_TV
);
1134 CStdString
CCECClient::GetOSDName(void)
1136 CLockObject
lock(m_mutex
);
1137 CStdString
strOSDName(m_configuration
.strDeviceName
);
1141 void CCECClient::SetWakeDevices(const cec_logical_addresses
&addresses
)
1143 CLockObject
lock(m_mutex
);
1144 m_configuration
.wakeDevices
= addresses
;
1147 cec_logical_addresses
CCECClient::GetWakeDevices(void)
1149 CLockObject
lock(m_mutex
);
1150 return m_configuration
.wakeDevices
;
1153 bool CCECClient::AutodetectPhysicalAddress(void)
1155 bool bPhysicalAutodetected(false);
1156 uint16_t iPhysicalAddress
= m_processor
? m_processor
->GetDetectedPhysicalAddress() : CEC_INVALID_PHYSICAL_ADDRESS
;
1158 if (CLibCEC::IsValidPhysicalAddress(iPhysicalAddress
))
1160 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - autodetected physical address '%04X'", __FUNCTION__
, iPhysicalAddress
);
1162 CLockObject
lock(m_mutex
);
1163 m_configuration
.iPhysicalAddress
= iPhysicalAddress
;
1164 m_configuration
.iHDMIPort
= CEC_HDMI_PORTNUMBER_NONE
;
1165 m_configuration
.baseDevice
= CECDEVICE_UNKNOWN
;
1166 bPhysicalAutodetected
= true;
1169 SetDevicePhysicalAddress(iPhysicalAddress
);
1171 return bPhysicalAutodetected
;
1174 void CCECClient::SetClientVersion(const cec_client_version version
)
1176 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - using client version '%s'", __FUNCTION__
, ToString(version
));
1178 CLockObject
lock(m_mutex
);
1179 m_configuration
.clientVersion
= (uint32_t)version
;
1182 cec_client_version
CCECClient::GetClientVersion(void)
1184 CLockObject
lock(m_mutex
);
1185 return (cec_client_version
)m_configuration
.clientVersion
;
1188 bool CCECClient::SetDeviceTypes(const cec_device_type_list
&deviceTypes
)
1190 bool bNeedReinit(false);
1193 CLockObject
lock(m_mutex
);
1194 bNeedReinit
= m_processor
&& m_processor
->CECInitialised() &&
1195 (m_configuration
.deviceTypes
!= deviceTypes
);
1196 m_configuration
.deviceTypes
= deviceTypes
;
1200 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - using primary device type '%s'", __FUNCTION__
, ToString(deviceTypes
[0]));
1205 cec_device_type_list
CCECClient::GetDeviceTypes(void)
1207 cec_device_type_list retVal
;
1208 CLockObject
lock(m_mutex
);
1209 retVal
= m_configuration
.deviceTypes
;
1213 bool CCECClient::SetDevicePhysicalAddress(const uint16_t iPhysicalAddress
)
1215 if (!CLibCEC::IsValidPhysicalAddress(iPhysicalAddress
))
1217 LIB_CEC
->AddLog(CEC_LOG_DEBUG
, "%s - not setting invalid physical address %04x", __FUNCTION__
, iPhysicalAddress
);
1221 // reconfigure all devices
1222 cec_logical_address
reactivateSource(CECDEVICE_UNKNOWN
);
1223 CECDEVICEVEC devices
;
1224 m_processor
->GetDevices()->GetByLogicalAddresses(devices
, m_configuration
.logicalAddresses
);
1225 for (CECDEVICEVEC::iterator it
= devices
.begin(); it
!= devices
.end(); it
++)
1227 // if this device was the active source, reactivate it afterwards
1228 if ((*it
)->IsActiveSource())
1229 reactivateSource
= (*it
)->GetLogicalAddress();
1231 // mark the device as inactive source
1232 if (IsInitialised())
1233 (*it
)->MarkAsInactiveSource();
1235 // set the new physical address
1236 (*it
)->SetPhysicalAddress(iPhysicalAddress
);
1239 if (IsInitialised())
1240 (*it
)->TransmitPhysicalAddress();
1243 // reactivate the previous active source
1244 if (reactivateSource
!= CECDEVICE_UNKNOWN
&&
1245 m_processor
->CECInitialised() &&
1248 CCECBusDevice
*device
= m_processor
->GetDevice(reactivateSource
);
1250 device
->ActivateSource();
1256 bool CCECClient::SwitchMonitoring(bool bEnable
)
1258 LIB_CEC
->AddLog(CEC_LOG_NOTICE
, "== %s monitoring mode ==", bEnable
? "enabling" : "disabling");
1263 return m_processor
->UnregisterClient(this);
1266 m_configuration
.bMonitorOnly
= false;
1267 return m_processor
->RegisterClient(this);
1274 bool CCECClient::PollDevice(const cec_logical_address iAddress
)
1276 // try to find the primary device
1277 CCECBusDevice
*primary
= GetPrimaryDevice();
1278 // poll the destination, with the primary as source
1280 return primary
->TransmitPoll(iAddress
);
1282 return m_processor
? m_processor
->PollDevice(iAddress
) : false;
1285 cec_logical_addresses
CCECClient::GetActiveDevices(void)
1287 CECDEVICEVEC activeDevices
;
1289 m_processor
->GetDevices()->GetActive(activeDevices
);
1290 return CCECDeviceMap::ToLogicalAddresses(activeDevices
);
1293 bool CCECClient::IsActiveDevice(const cec_logical_address iAddress
)
1295 cec_logical_addresses activeDevices
= GetActiveDevices();
1296 return activeDevices
.IsSet(iAddress
);
1299 bool CCECClient::IsActiveDeviceType(const cec_device_type type
)
1301 CECDEVICEVEC activeDevices
;
1303 m_processor
->GetDevices()->GetActive(activeDevices
);
1304 CCECDeviceMap::FilterType(type
, activeDevices
);
1305 return !activeDevices
.empty();
1308 cec_logical_address
CCECClient::GetActiveSource(void)
1310 return m_processor
? m_processor
->GetActiveSource() : CECDEVICE_UNKNOWN
;
1313 bool CCECClient::IsActiveSource(const cec_logical_address iAddress
)
1315 return m_processor
? m_processor
->IsActiveSource(iAddress
) : false;
1318 bool CCECClient::SetStreamPath(const cec_logical_address iAddress
)
1320 uint16_t iPhysicalAddress
= GetDevicePhysicalAddress(iAddress
);
1321 if (iPhysicalAddress
!= CEC_INVALID_PHYSICAL_ADDRESS
)
1322 return SetStreamPath(iPhysicalAddress
);
1326 bool CCECClient::SetStreamPath(const uint16_t iPhysicalAddress
)
1328 return m_processor
? m_processor
->SetStreamPath(iPhysicalAddress
) : false;
1331 cec_logical_addresses
CCECClient::GetLogicalAddresses(void)
1333 cec_logical_addresses addresses
;
1334 CLockObject
lock(m_mutex
);
1335 addresses
= m_configuration
.logicalAddresses
;
1339 bool CCECClient::CanPersistConfiguration(void)
1341 return m_processor
? m_processor
->CanPersistConfiguration() : false;
1344 bool CCECClient::PersistConfiguration(const libcec_configuration
&configuration
)
1346 return m_processor
? m_processor
->PersistConfiguration(configuration
) : false;
1349 void CCECClient::RescanActiveDevices(void)
1352 m_processor
->RescanActiveDevices();
1355 bool CCECClient::IsLibCECActiveSource(void)
1357 bool bReturn(false);
1360 cec_logical_address activeSource
= m_processor
->GetActiveSource();
1361 CCECBusDevice
*device
= m_processor
->GetDevice(activeSource
);
1363 bReturn
= device
->IsHandledByLibCEC();