2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011 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 "CECBusDevice.h"
34 #include "../CECProcessor.h"
35 #include "../implementations/ANCommandHandler.h"
36 #include "../implementations/CECCommandHandler.h"
37 #include "../implementations/SLCommandHandler.h"
38 #include "../implementations/VLCommandHandler.h"
39 #include "../platform/timeutils.h"
43 #define ToString(p) m_processor->ToString(p)
45 CCECBusDevice::CCECBusDevice(CCECProcessor
*processor
, cec_logical_address iLogicalAddress
, uint16_t iPhysicalAddress
) :
46 m_type(CEC_DEVICE_TYPE_RESERVED
),
47 m_iPhysicalAddress(iPhysicalAddress
),
49 m_iLogicalAddress(iLogicalAddress
),
50 m_powerStatus(CEC_POWER_STATUS_UNKNOWN
),
51 m_processor(processor
),
52 m_vendor(CEC_VENDOR_UNKNOWN
),
53 m_menuState(CEC_MENU_STATE_ACTIVATED
),
54 m_bActiveSource(false),
55 m_iLastCommandSent(0),
57 m_cecVersion(CEC_VERSION_UNKNOWN
),
58 m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN
)
60 m_handler
= new CCECCommandHandler(this);
62 for (unsigned int iPtr
= 0; iPtr
< 4; iPtr
++)
63 m_menuLanguage
.language
[iPtr
] = '?';
64 m_menuLanguage
.language
[3] = 0;
65 m_menuLanguage
.device
= iLogicalAddress
;
67 m_strDeviceName
= ToString(m_iLogicalAddress
);
70 CCECBusDevice::~CCECBusDevice(void)
75 void CCECBusDevice::AddLog(cec_log_level level
, const CStdString
&strMessage
)
77 m_processor
->AddLog(level
, strMessage
);
80 bool CCECBusDevice::HandleCommand(const cec_command
&command
)
83 CLockObject
lock(&m_writeMutex
);
84 m_iLastActive
= GetTimeMs();
87 m_handler
->HandleCommand(command
);
90 CLockObject
lock(&m_writeMutex
);
91 if (m_deviceStatus
!= CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC
)
93 if (m_deviceStatus
!= CEC_DEVICE_STATUS_PRESENT
)
96 strLog
.Format("device %s (%x) status changed to present after command %s", GetLogicalAddressName(), (uint8_t)GetLogicalAddress(), ToString(command
.opcode
));
97 AddLog(CEC_LOG_DEBUG
, strLog
);
99 m_deviceStatus
= CEC_DEVICE_STATUS_PRESENT
;
105 bool CCECBusDevice::PowerOn(void)
108 strLog
.Format("<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress
);
109 AddLog(CEC_LOG_DEBUG
, strLog
.c_str());
111 if (m_handler
->TransmitPowerOn(GetMyLogicalAddress(), m_iLogicalAddress
))
114 CLockObject
lock(&m_mutex
);
115 m_powerStatus
= CEC_POWER_STATUS_UNKNOWN
;
117 cec_power_status status
= GetPowerStatus();
118 if (status
== CEC_POWER_STATUS_STANDBY
|| status
== CEC_POWER_STATUS_UNKNOWN
)
120 SendKeypress(CEC_USER_CONTROL_CODE_POWER
);
121 return SendKeyRelease();
129 bool CCECBusDevice::Standby(void)
132 strLog
.Format("<< putting '%s' (%X) in standby mode", GetLogicalAddressName(), m_iLogicalAddress
);
133 AddLog(CEC_LOG_DEBUG
, strLog
.c_str());
135 return m_handler
->TransmitStandby(GetMyLogicalAddress(), m_iLogicalAddress
);
140 cec_version
CCECBusDevice::GetCecVersion(void)
142 CLockObject
lock(&m_mutex
);
143 if (GetStatus() == CEC_DEVICE_STATUS_PRESENT
&&
144 m_cecVersion
== CEC_VERSION_UNKNOWN
)
150 bool CCECBusDevice::RequestCecVersion(void)
153 if (!MyLogicalAddressContains(m_iLogicalAddress
))
156 strLog
.Format("<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress
);
157 AddLog(CEC_LOG_NOTICE
, strLog
);
159 bReturn
= m_handler
->TransmitRequestCecVersion(GetMyLogicalAddress(), m_iLogicalAddress
);
164 uint64_t CCECBusDevice::GetLastCommandSent(void) const
166 return GetTimeMs() - m_iLastCommandSent
;
169 const char* CCECBusDevice::GetLogicalAddressName(void) const
171 return ToString(m_iLogicalAddress
);
174 cec_menu_language
&CCECBusDevice::GetMenuLanguage(void)
176 CLockObject
lock(&m_mutex
);
177 if (GetStatus() == CEC_DEVICE_STATUS_PRESENT
&&
178 !strcmp(m_menuLanguage
.language
, "???"))
179 RequestMenuLanguage();
181 return m_menuLanguage
;
184 bool CCECBusDevice::RequestMenuLanguage(void)
187 if (!MyLogicalAddressContains(m_iLogicalAddress
))
190 strLog
.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress
);
191 AddLog(CEC_LOG_NOTICE
, strLog
);
192 bReturn
= m_handler
->TransmitRequestMenuLanguage(GetMyLogicalAddress(), m_iLogicalAddress
);
197 cec_logical_address
CCECBusDevice::GetMyLogicalAddress(void) const
199 return m_processor
->GetLogicalAddress();
202 uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const
204 return m_processor
->GetPhysicalAddress();
207 CStdString
CCECBusDevice::GetOSDName(void)
209 CLockObject
lock(&m_mutex
);
210 if (GetStatus() == CEC_DEVICE_STATUS_PRESENT
&&
211 m_strDeviceName
.Equals(ToString(m_iLogicalAddress
)) &&
212 m_type
!= CEC_DEVICE_TYPE_TV
)
215 return m_strDeviceName
;
218 bool CCECBusDevice::RequestOSDName(void)
221 if (!MyLogicalAddressContains(m_iLogicalAddress
))
224 strLog
.Format("<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress
);
225 AddLog(CEC_LOG_NOTICE
, strLog
);
226 bReturn
= m_handler
->TransmitRequestOSDName(GetMyLogicalAddress(), m_iLogicalAddress
);
231 uint16_t CCECBusDevice::GetPhysicalAddress(bool bRefresh
/* = true */)
233 CLockObject
lock(&m_mutex
);
234 if (GetStatus() == CEC_DEVICE_STATUS_PRESENT
&&
235 (m_iPhysicalAddress
== 0xFFFF || bRefresh
))
237 if (!RequestPhysicalAddress())
238 AddLog(CEC_LOG_ERROR
, "failed to request the physical address");
241 return m_iPhysicalAddress
;
244 bool CCECBusDevice::RequestPhysicalAddress(void)
247 if (!MyLogicalAddressContains(m_iLogicalAddress
))
250 strLog
.Format("<< requesting physical address of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress
);
251 AddLog(CEC_LOG_NOTICE
, strLog
);
252 bReturn
= m_handler
->TransmitRequestPhysicalAddress(GetMyLogicalAddress(), m_iLogicalAddress
);
257 cec_power_status
CCECBusDevice::GetPowerStatus(void)
259 CLockObject
lock(&m_mutex
);
260 if (GetStatus() == CEC_DEVICE_STATUS_PRESENT
&&
261 m_powerStatus
== CEC_POWER_STATUS_UNKNOWN
)
262 RequestPowerStatus();
264 return m_powerStatus
;
267 bool CCECBusDevice::RequestPowerStatus(void)
270 if (!MyLogicalAddressContains(m_iLogicalAddress
))
273 strLog
.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress
);
274 AddLog(CEC_LOG_NOTICE
, strLog
);
275 bReturn
= m_handler
->TransmitRequestPowerStatus(GetMyLogicalAddress(), m_iLogicalAddress
);
280 cec_vendor_id
CCECBusDevice::GetVendorId(void)
282 CLockObject
lock(&m_mutex
);
283 if (GetStatus() == CEC_DEVICE_STATUS_PRESENT
&&
284 m_vendor
== CEC_VENDOR_UNKNOWN
)
290 bool CCECBusDevice::RequestVendorId(void)
293 if (!MyLogicalAddressContains(m_iLogicalAddress
))
296 strLog
.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress
);
297 AddLog(CEC_LOG_NOTICE
, strLog
);
298 bReturn
= m_handler
->TransmitRequestVendorId(GetMyLogicalAddress(), m_iLogicalAddress
);
303 const char *CCECBusDevice::GetVendorName(void)
305 return ToString(GetVendorId());
308 bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address
) const
310 return m_processor
->HasLogicalAddress(address
);
313 bool CCECBusDevice::NeedsPoll(void)
315 bool bSendPoll(false);
316 switch (m_iLogicalAddress
)
318 case CECDEVICE_PLAYBACKDEVICE3
:
319 if (m_processor
->m_busDevices
[CECDEVICE_PLAYBACKDEVICE2
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
322 case CECDEVICE_PLAYBACKDEVICE2
:
323 if (m_processor
->m_busDevices
[CECDEVICE_PLAYBACKDEVICE1
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
326 case CECDEVICE_RECORDINGDEVICE3
:
327 if (m_processor
->m_busDevices
[CECDEVICE_RECORDINGDEVICE2
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
330 case CECDEVICE_RECORDINGDEVICE2
:
331 if (m_processor
->m_busDevices
[CECDEVICE_RECORDINGDEVICE1
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
334 case CECDEVICE_TUNER4
:
335 if (m_processor
->m_busDevices
[CECDEVICE_TUNER3
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
338 case CECDEVICE_TUNER3
:
339 if (m_processor
->m_busDevices
[CECDEVICE_TUNER2
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
342 case CECDEVICE_TUNER2
:
343 if (m_processor
->m_busDevices
[CECDEVICE_TUNER1
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
346 case CECDEVICE_AUDIOSYSTEM
:
347 case CECDEVICE_PLAYBACKDEVICE1
:
348 case CECDEVICE_RECORDINGDEVICE1
:
349 case CECDEVICE_TUNER1
:
360 cec_bus_device_status
CCECBusDevice::GetStatus(bool bForcePoll
/* = false */)
362 CLockObject
lock(&m_writeMutex
);
363 if (m_deviceStatus
== CEC_DEVICE_STATUS_UNKNOWN
|| bForcePoll
)
366 bool bPollAcked(false);
367 if (bForcePoll
|| NeedsPoll())
368 bPollAcked
= m_processor
->PollDevice(m_iLogicalAddress
);
371 m_deviceStatus
= bPollAcked
? CEC_DEVICE_STATUS_PRESENT
: CEC_DEVICE_STATUS_NOT_PRESENT
;
374 return m_deviceStatus
;
381 void CCECBusDevice::SetCecVersion(const cec_version newVersion
)
383 m_cecVersion
= newVersion
;
386 strLog
.Format("%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress
, ToString(newVersion
));
387 AddLog(CEC_LOG_DEBUG
, strLog
);
390 void CCECBusDevice::SetMenuLanguage(const cec_menu_language
&language
)
392 CLockObject
lock(&m_writeMutex
);
393 if (language
.device
== m_iLogicalAddress
)
396 strLog
.Format(">> %s (%X): menu language set to '%s'", GetLogicalAddressName(), m_iLogicalAddress
, language
.language
);
397 m_processor
->AddLog(CEC_LOG_DEBUG
, strLog
);
398 m_menuLanguage
= language
;
402 void CCECBusDevice::SetOSDName(CStdString strName
)
404 CLockObject
lock(&m_writeMutex
);
405 if (m_strDeviceName
!= strName
)
408 strLog
.Format(">> %s (%X): osd name set to '%s'", GetLogicalAddressName(), m_iLogicalAddress
, strName
);
409 m_processor
->AddLog(CEC_LOG_DEBUG
, strLog
);
410 m_strDeviceName
= strName
;
414 void CCECBusDevice::SetMenuState(const cec_menu_state state
)
416 CLockObject
lock(&m_writeMutex
);
417 if (m_menuState
!= state
)
420 strLog
.Format(">> %s (%X): menu state set to '%s'", GetLogicalAddressName(), m_iLogicalAddress
, ToString(m_menuState
));
421 m_processor
->AddLog(CEC_LOG_DEBUG
, strLog
);
426 void CCECBusDevice::SetInactiveDevice(void)
428 CLockObject
lock(&m_writeMutex
);
429 m_bActiveSource
= false;
432 void CCECBusDevice::SetActiveDevice(void)
434 CLockObject
lock(&m_writeMutex
);
436 for (int iPtr
= 0; iPtr
< 16; iPtr
++)
437 if (iPtr
!= m_iLogicalAddress
)
438 m_processor
->m_busDevices
[iPtr
]->SetInactiveDevice();
440 m_bActiveSource
= true;
441 m_powerStatus
= CEC_POWER_STATUS_ON
;
444 bool CCECBusDevice::TryLogicalAddress(void)
447 strLog
.Format("trying logical address '%s'", GetLogicalAddressName());
448 AddLog(CEC_LOG_DEBUG
, strLog
);
450 m_processor
->SetAckMask(0x1 << m_iLogicalAddress
);
451 if (!TransmitPoll(m_iLogicalAddress
))
453 strLog
.Format("using logical address '%s'", GetLogicalAddressName());
454 AddLog(CEC_LOG_NOTICE
, strLog
);
455 SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC
);
460 strLog
.Format("logical address '%s' already taken", GetLogicalAddressName());
461 AddLog(CEC_LOG_DEBUG
, strLog
);
462 SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT
);
466 void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus
)
468 CLockObject
lock(&m_writeMutex
);
471 case CEC_DEVICE_STATUS_UNKNOWN
:
473 m_powerStatus
= CEC_POWER_STATUS_UNKNOWN
;
474 m_vendor
= CEC_VENDOR_UNKNOWN
;
475 m_menuState
= CEC_MENU_STATE_ACTIVATED
;
476 m_bActiveSource
= false;
477 m_iLastCommandSent
= 0;
479 m_cecVersion
= CEC_VERSION_UNKNOWN
;
480 m_deviceStatus
= newStatus
;
482 case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC
:
484 m_powerStatus
= CEC_POWER_STATUS_ON
;
485 m_vendor
= CEC_VENDOR_UNKNOWN
;
486 m_menuState
= CEC_MENU_STATE_ACTIVATED
;
487 m_bActiveSource
= false;
488 m_iLastCommandSent
= 0;
490 m_cecVersion
= CEC_VERSION_1_3A
;
491 m_deviceStatus
= newStatus
;
493 case CEC_DEVICE_STATUS_PRESENT
:
494 case CEC_DEVICE_STATUS_NOT_PRESENT
:
495 m_deviceStatus
= newStatus
;
500 void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress
)
502 CLockObject
lock(&m_writeMutex
);
503 if (iNewAddress
> 0 && m_iPhysicalAddress
!= iNewAddress
)
506 strLog
.Format(">> %s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress
, m_iPhysicalAddress
, iNewAddress
);
507 AddLog(CEC_LOG_DEBUG
, strLog
.c_str());
509 m_iPhysicalAddress
= iNewAddress
;
513 void CCECBusDevice::SetStreamPath(uint16_t iNewAddress
, uint16_t iOldAddress
/* = 0 */)
515 CLockObject
lock(&m_writeMutex
);
519 strLog
.Format(">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress
, iOldAddress
== 0 ? m_iStreamPath
: iOldAddress
, iNewAddress
);
520 AddLog(CEC_LOG_DEBUG
, strLog
.c_str());
522 m_iStreamPath
= iNewAddress
;
527 SetPowerStatus(CEC_POWER_STATUS_ON
);
532 void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus
)
534 CLockObject
lock(&m_writeMutex
);
535 if (m_powerStatus
!= powerStatus
)
538 strLog
.Format(">> %s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress
, ToString(m_powerStatus
), ToString(powerStatus
));
539 m_processor
->AddLog(CEC_LOG_DEBUG
, strLog
);
540 m_powerStatus
= powerStatus
;
544 bool CCECBusDevice::SetVendorId(uint64_t iVendorId
, bool bInitHandler
/* = true */)
546 bool bVendorChanged(false);
549 CLockObject
lock(&m_writeMutex
);
550 bVendorChanged
= (m_vendor
!= (cec_vendor_id
)iVendorId
);
551 m_vendor
= (cec_vendor_id
)iVendorId
;
558 case CEC_VENDOR_SAMSUNG
:
560 m_handler
= new CANCommandHandler(this);
564 m_handler
= new CSLCommandHandler(this);
566 case CEC_VENDOR_PANASONIC
:
568 m_handler
= new CVLCommandHandler(this);
572 m_handler
= new CCECCommandHandler(this);
577 if (bVendorChanged
&& bInitHandler
)
578 m_handler
->InitHandler();
581 strLog
.Format("%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress
, ToString(m_vendor
), m_vendor
);
582 m_processor
->AddLog(CEC_LOG_DEBUG
, strLog
.c_str());
584 return bVendorChanged
;
588 /** @name Transmit methods */
590 bool CCECBusDevice::TransmitActiveSource(void)
592 bool bSendActiveSource(false);
595 CLockObject
lock(&m_writeMutex
);
596 if (m_powerStatus
!= CEC_POWER_STATUS_ON
)
599 strLog
.Format("<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress
);
600 AddLog(CEC_LOG_DEBUG
, strLog
);
602 else if (m_bActiveSource
)
605 strLog
.Format("<< %s (%X) -> broadcast (F): active source (%4x)", GetLogicalAddressName(), m_iLogicalAddress
, m_iPhysicalAddress
);
606 AddLog(CEC_LOG_NOTICE
, strLog
);
607 bSendActiveSource
= true;
612 strLog
.Format("<< %s (%X) is not the active source", GetLogicalAddressName(), m_iLogicalAddress
);
613 AddLog(CEC_LOG_DEBUG
, strLog
);
617 return bSendActiveSource
? m_handler
->TransmitActiveSource(m_iLogicalAddress
, m_iPhysicalAddress
) : false;
620 bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest
)
624 CLockObject
lock(&m_writeMutex
);
626 strLog
.Format("<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress
, ToString(dest
), dest
, ToString(m_cecVersion
));
627 AddLog(CEC_LOG_NOTICE
, strLog
);
628 version
= m_cecVersion
;
631 return m_handler
->TransmitCECVersion(m_iLogicalAddress
, dest
, version
);
634 bool CCECBusDevice::TransmitInactiveSource(void)
636 uint16_t iPhysicalAddress
;
638 CLockObject
lock(&m_writeMutex
);
640 strLog
.Format("<< %s (%X) -> broadcast (F): inactive source", GetLogicalAddressName(), m_iLogicalAddress
);
641 AddLog(CEC_LOG_NOTICE
, strLog
);
642 iPhysicalAddress
= m_iPhysicalAddress
;
645 return m_handler
->TransmitInactiveSource(m_iLogicalAddress
, iPhysicalAddress
);
648 bool CCECBusDevice::TransmitMenuState(cec_logical_address dest
)
650 cec_menu_state menuState
;
652 CLockObject
lock(&m_writeMutex
);
654 strLog
.Format("<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress
, ToString(dest
), dest
, ToString(m_menuState
));
655 AddLog(CEC_LOG_NOTICE
, strLog
);
656 menuState
= m_menuState
;
659 return m_handler
->TransmitMenuState(m_iLogicalAddress
, dest
, menuState
);
662 bool CCECBusDevice::TransmitOSDName(cec_logical_address dest
)
664 CStdString strDeviceName
;
666 CLockObject
lock(&m_writeMutex
);
668 strLog
.Format("<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress
, ToString(dest
), dest
, m_strDeviceName
.c_str());
669 AddLog(CEC_LOG_NOTICE
, strLog
.c_str());
670 strDeviceName
= m_strDeviceName
;
673 return m_handler
->TransmitOSDName(m_iLogicalAddress
, dest
, strDeviceName
);
676 bool CCECBusDevice::TransmitOSDString(cec_logical_address dest
, cec_display_control duration
, const char *strMessage
)
679 strLog
.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress
, ToString(dest
), dest
, strMessage
);
680 AddLog(CEC_LOG_NOTICE
, strLog
.c_str());
682 return m_handler
->TransmitOSDString(m_iLogicalAddress
, dest
, duration
, strMessage
);
685 bool CCECBusDevice::TransmitPhysicalAddress(void)
687 uint16_t iPhysicalAddress
;
688 cec_device_type type
;
690 CLockObject
lock(&m_writeMutex
);
691 if (m_iPhysicalAddress
== 0xffff)
695 strLog
.Format("<< %s (%X) -> broadcast (F): physical adddress %4x", GetLogicalAddressName(), m_iLogicalAddress
, m_iPhysicalAddress
);
696 AddLog(CEC_LOG_NOTICE
, strLog
.c_str());
698 iPhysicalAddress
= m_iPhysicalAddress
;
702 return m_handler
->TransmitPhysicalAddress(m_iLogicalAddress
, iPhysicalAddress
, type
);
705 bool CCECBusDevice::TransmitPoll(cec_logical_address dest
)
708 if (dest
== CECDEVICE_UNKNOWN
)
709 dest
= m_iLogicalAddress
;
712 strLog
.Format("<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress
, ToString(dest
), dest
);
713 AddLog(CEC_LOG_NOTICE
, strLog
.c_str());
714 bReturn
= m_handler
->TransmitPoll(m_iLogicalAddress
, dest
);
715 AddLog(CEC_LOG_DEBUG
, bReturn
? ">> POLL sent" : ">> POLL not sent");
719 CLockObject
lock(&m_writeMutex
);
720 m_iLastActive
= GetTimeMs();
726 bool CCECBusDevice::TransmitPowerState(cec_logical_address dest
)
728 cec_power_status state
;
730 CLockObject
lock(&m_writeMutex
);
732 strLog
.Format("<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress
, ToString(dest
), dest
, ToString(m_powerStatus
));
733 AddLog(CEC_LOG_NOTICE
, strLog
.c_str());
734 state
= m_powerStatus
;
737 return m_handler
->TransmitPowerState(m_iLogicalAddress
, dest
, state
);
740 bool CCECBusDevice::TransmitVendorID(cec_logical_address dest
)
744 CLockObject
lock(&m_writeMutex
);
745 iVendorId
= (uint64_t)m_vendor
;
748 if (iVendorId
== CEC_VENDOR_UNKNOWN
)
751 strLog
.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress
, ToString(dest
), dest
);
752 AddLog(CEC_LOG_NOTICE
, strLog
);
754 m_processor
->TransmitAbort(dest
, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID
);
760 strLog
.Format("<< %s (%X) -> %s (%X): vendor id %s (%x)", GetLogicalAddressName(), m_iLogicalAddress
, ToString(dest
), dest
, ToString((cec_vendor_id
)iVendorId
), iVendorId
);
761 AddLog(CEC_LOG_NOTICE
, strLog
);
763 return m_handler
->TransmitVendorID(m_iLogicalAddress
, iVendorId
);
767 bool CCECBusDevice::SendKeypress(cec_user_control_code key
)
769 return m_handler
->SendKeypress(m_processor
->GetLogicalAddress(), m_iLogicalAddress
, key
);
772 bool CCECBusDevice::SendKeyRelease(void)
774 return m_handler
->SendKeyRelease(m_processor
->GetLogicalAddress(), m_iLogicalAddress
);