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 "ANCommandHandler.h"
36 #include "SLCommandHandler.h"
40 CCECBusDevice::CCECBusDevice(CCECProcessor
*processor
, cec_logical_address iLogicalAddress
, uint16_t iPhysicalAddress
) :
41 m_iPhysicalAddress(iPhysicalAddress
),
42 m_iLogicalAddress(iLogicalAddress
),
43 m_processor(processor
),
47 m_handler
= new CCECCommandHandler(this);
50 CCECBusDevice::~CCECBusDevice(void)
55 cec_logical_address
CCECBusDevice::GetMyLogicalAddress(void) const
57 return m_processor
->GetLogicalAddress();
60 uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const
62 return m_processor
->GetPhysicalAddress();
65 void CCECBusDevice::AddLog(cec_log_level level
, const CStdString
&strMessage
)
67 m_processor
->AddLog(level
, strMessage
);
70 void CCECBusDevice::SetVendorId(uint16_t iVendorId
, uint8_t iVendorClass
/* = 0 */)
73 m_iVendorId
= iVendorId
;
74 m_iVendorClass
= iVendorClass
;
78 case CEC_VENDOR_SAMSUNG
:
79 m_handler
= new CANCommandHandler(this);
82 m_handler
= new CSLCommandHandler(this);
85 m_handler
= new CCECCommandHandler(this);
90 strLog
.Format("device %d: vendor = %s (%04x) class = %2x", m_iLogicalAddress
, CECVendorIdToString(iVendorId
), iVendorId
, iVendorClass
);
91 m_processor
->AddLog(CEC_LOG_DEBUG
, strLog
.c_str());
94 bool CCECBusDevice::HandleCommand(const cec_command
&command
)
96 CLockObject
lock(&m_mutex
);
97 m_handler
->HandleCommand(command
);
101 const char *CCECBusDevice::CECVendorIdToString(const uint64_t iVendorId
)
105 case CEC_VENDOR_SAMSUNG
: