using namespace std;
CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm, const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS*/) :
- m_iPhysicalAddress(iPhysicalAddress),
m_iLogicalAddress(iLogicalAddress),
m_strDeviceName(strDeviceName),
m_communication(serComm),
{
for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, 0);
+
+ m_busDevices[m_iLogicalAddress]->SetPhysicalAddress(iPhysicalAddress);
}
CCECProcessor::~CCECProcessor(void)
return NULL;
}
-bool CCECProcessor::PowerOnDevices(cec_logical_address address /* = CECDEVICE_TV */)
-{
- if (!IsRunning())
- return false;
-
- CStdString strLog;
- strLog.Format("<< powering on device with logical address %d", (int8_t)address);
- m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, address, CEC_OPCODE_IMAGE_VIEW_ON);
-
- return Transmit(command);
-}
-
-bool CCECProcessor::StandbyDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
-{
- if (!IsRunning())
- return false;
-
- CStdString strLog;
- strLog.Format("<< putting device with logical address %d in standby mode", (int8_t)address);
- m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, address, CEC_OPCODE_STANDBY);
-
- return Transmit(command);
-}
-
bool CCECProcessor::SetActiveView(void)
{
if (!IsRunning())
return false;
- m_controller->AddLog(CEC_LOG_DEBUG, "<< setting active view");
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
- command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
- command.parameters.push_back(m_iPhysicalAddress & 0xFF);
-
- return Transmit(command);
+ return m_busDevices[m_iLogicalAddress]->BroadcastActiveView();
}
bool CCECProcessor::SetInactiveView(void)
if (!IsRunning())
return false;
- m_controller->AddLog(CEC_LOG_DEBUG, "<< setting inactive view");
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE);
- command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
- command.parameters.push_back(m_iPhysicalAddress & 0xFF);
-
- return Transmit(command);
+ return m_busDevices[m_iLogicalAddress]->BroadcastInactiveView();
}
void CCECProcessor::LogOutput(const cec_command &data)
bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress)
{
- CStdString strLog;
- strLog.Format("<< setting physical address to %2x", iPhysicalAddress);
- m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
-
- m_iPhysicalAddress = iPhysicalAddress;
- return SetActiveView();
-}
-
-bool CCECProcessor::SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage)
-{
- CStdString strLog;
- strLog.Format("<< display message '%s'", strMessage);
- m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, iLogicalAddress, CEC_OPCODE_SET_OSD_STRING);
- command.parameters.push_back((uint8_t)duration);
-
- for (unsigned int iPtr = 0; iPtr < strlen(strMessage); iPtr++)
- command.parameters.push_back(strMessage[iPtr]);
-
- return Transmit(command);
+ m_busDevices[m_iLogicalAddress]->SetPhysicalAddress(iPhysicalAddress);
+ return m_busDevices[m_iLogicalAddress]->BroadcastActiveView();
}
bool CCECProcessor::SwitchMonitoring(bool bEnable)
Transmit(command);
}
-void CCECProcessor::ReportCECVersion(cec_logical_address address /* = CECDEVICE_TV */)
-{
- m_controller->AddLog(CEC_LOG_NOTICE, "<< reporting CEC version as 1.3a");
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, address, CEC_OPCODE_CEC_VERSION);
- command.parameters.push_back(CEC_VERSION_1_3A);
-
- Transmit(command);
-}
-
-void CCECProcessor::ReportPowerState(cec_logical_address address /*= CECDEVICE_TV */, bool bOn /* = true */)
-{
- if (bOn)
- m_controller->AddLog(CEC_LOG_NOTICE, "<< reporting \"On\" power status");
- else
- m_controller->AddLog(CEC_LOG_NOTICE, "<< reporting \"Off\" power status");
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, address, CEC_OPCODE_REPORT_POWER_STATUS);
- command.parameters.push_back(bOn ? (uint8_t) CEC_POWER_STATUS_ON : (uint8_t) CEC_POWER_STATUS_STANDBY);
-
- Transmit(command);
-}
-
-void CCECProcessor::ReportMenuState(cec_logical_address address /* = CECDEVICE_TV */, bool bActive /* = true */)
-{
- if (bActive)
- m_controller->AddLog(CEC_LOG_NOTICE, "<< reporting menu state as active");
- else
- m_controller->AddLog(CEC_LOG_NOTICE, "<< reporting menu state as inactive");
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, address, CEC_OPCODE_MENU_STATUS);
- command.parameters.push_back(bActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED);
-
- Transmit(command);
-}
-
-void CCECProcessor::ReportVendorID(cec_logical_address address /* = CECDEVICE_TV */)
-{
- m_controller->AddLog(CEC_LOG_NOTICE, "<< vendor ID requested, feature abort");
- TransmitAbort(address, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
-}
-
-void CCECProcessor::ReportOSDName(cec_logical_address address /* = CECDEVICE_TV */)
-{
- const char *osdname = m_strDeviceName.c_str();
- CStdString strLog;
- strLog.Format("<< reporting OSD name as %s", osdname);
- m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, address, CEC_OPCODE_SET_OSD_NAME);
- for (unsigned int iPtr = 0; iPtr < strlen(osdname); iPtr++)
- command.parameters.push_back(osdname[iPtr]);
-
- Transmit(command);
-}
-
-void CCECProcessor::ReportPhysicalAddress(void)
-{
- CStdString strLog;
- strLog.Format("<< reporting physical address as %04x", m_iPhysicalAddress);
- m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str());
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS);
- command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
- command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
- command.parameters.push_back((uint8_t) (CEC_DEVICE_TYPE_PLAYBACK_DEVICE));
-
- Transmit(command);
-}
-
-void CCECProcessor::BroadcastActiveSource(void)
-{
- m_controller->AddLog(CEC_LOG_NOTICE, "<< broadcasting active source");
-
- cec_command command;
- cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
- command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
- command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
-
- Transmit(command);
-}
-
bool CCECProcessor::WaitForAck(bool *bError, uint32_t iTimeout /* = 1000 */)
{
bool bTransmitSucceeded = false, bEom = false;
}
}
-void CCECProcessor::ParseVendorId(cec_logical_address device, const cec_datapacket &data)
-{
- if (data.size < 3)
- {
- m_controller->AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
- return;
- }
-
- uint64_t iVendorId = ((uint64_t)data[0] << 3) +
- ((uint64_t)data[1] << 2) +
- (uint64_t)data[2];
-
- m_busDevices[(uint8_t)device]->SetVendorId(iVendorId, data.size >= 4 ? data[3] : 0);
-}
-
void CCECProcessor::ParseCommand(cec_command &command)
{
CStdString dataStr;
m_busDevices[(uint8_t)command.initiator]->HandleCommand(command);
}
+uint16_t CCECProcessor::GetPhysicalAddress(void) const
+{
+ return m_busDevices[m_iLogicalAddress]->GetPhysicalAddress();
+}
+
void CCECProcessor::SetCurrentButton(cec_user_control_code iButtonCode)
{
m_controller->SetCurrentButton(iButtonCode);
virtual bool Start(void);
void *Process(void);
- virtual bool PowerOnDevices(cec_logical_address address = CECDEVICE_TV);
- virtual bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST);
virtual bool SetActiveView(void);
virtual bool SetInactiveView(void);
virtual bool Transmit(const cec_command &data, bool bWaitForAck = true);
virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress);
virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress);
- virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage);
virtual bool SwitchMonitoring(bool bEnable);
virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; }
- virtual uint16_t GetPhysicalAddress(void) const { return m_iPhysicalAddress; }
+ virtual uint16_t GetPhysicalAddress(void) const;
+ virtual const std::string &GetDeviceName(void) { return m_strDeviceName; }
virtual void SetCurrentButton(cec_user_control_code iButtonCode);
virtual void AddCommand(const cec_command &command);
virtual bool TransmitFormatted(const cec_adapter_message &data, bool bWaitForAck = true);
virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, ECecAbortReason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE);
- virtual void ReportCECVersion(cec_logical_address address = CECDEVICE_TV);
- virtual void ReportPowerState(cec_logical_address address = CECDEVICE_TV, bool bOn = true);
- virtual void ReportMenuState(cec_logical_address address = CECDEVICE_TV, bool bActive = true);
- virtual void ReportVendorID(cec_logical_address address = CECDEVICE_TV);
- virtual void ReportOSDName(cec_logical_address address = CECDEVICE_TV);
- virtual void ReportPhysicalAddress(void);
- virtual void BroadcastActiveSource(void);
- virtual void ParseVendorId(cec_logical_address device, const cec_datapacket &data);
+
+ CCECBusDevice *m_busDevices[16];
private:
void LogOutput(const cec_command &data);
void ParseCommand(cec_command &command);
cec_command m_currentframe;
- uint16_t m_iPhysicalAddress;
cec_logical_address m_iLogicalAddress;
CecBuffer<cec_adapter_message> m_frameBuffer;
std::string m_strDeviceName;
CMutex m_mutex;
CAdapterCommunication *m_communication;
CLibCEC *m_controller;
- CCECBusDevice *m_busDevices[16];
bool m_bMonitor;
};
};
#include "AdapterCommunication.h"
#include "AdapterDetection.h"
#include "CECProcessor.h"
+#include "devices/CECBusDevice.h"
#include "util/StdString.h"
#include "platform/timeutils.h"
bool CLibCEC::PowerOnDevices(cec_logical_address address /* = CECDEVICE_TV */)
{
- return m_cec ? m_cec->PowerOnDevices(address) : false;
+ return m_cec && address >= CECDEVICE_TV && address <= CECDEVICE_BROADCAST ? m_cec->m_busDevices[(uint8_t)address]->PowerOn() : false;
}
bool CLibCEC::StandbyDevices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
{
- return m_cec ? m_cec->StandbyDevices(address) : false;
+ return m_cec && address >= CECDEVICE_TV && address <= CECDEVICE_BROADCAST ? m_cec->m_busDevices[(uint8_t)address]->Standby() : false;
}
bool CLibCEC::SetActiveView(void)
bool CLibCEC::SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage)
{
- return m_cec ? m_cec->SetOSDString(iLogicalAddress, duration, strMessage) : false;
+ return m_cec && iLogicalAddress >= CECDEVICE_TV && iLogicalAddress <= CECDEVICE_BROADCAST ? m_cec->m_busDevices[(uint8_t)iLogicalAddress]->SetOSDString(duration, strMessage) : false;
}
bool CLibCEC::SwitchMonitoring(bool bEnable)
m_processor->AddLog(level, strMessage);
}
+void CCECBusDevice::SetVendorId(const cec_datapacket &data)
+{
+ if (data.size < 3)
+ {
+ AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
+ return;
+ }
+
+ uint64_t iVendorId = ((uint64_t)data[0] << 3) +
+ ((uint64_t)data[1] << 2) +
+ (uint64_t)data[2];
+
+ SetVendorId(iVendorId, data.size >= 4 ? data[3] : 0);
+}
+
void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 */)
{
m_iVendorId = iVendorId;
}
CStdString strLog;
- strLog.Format("device %d: vendor = %s (%04x) class = %2x", m_iLogicalAddress, GetVendorName(), GetVendorId(), GetVendorClass());
+ strLog.Format("device %d: vendor = %s (%06x) class = %2x", m_iLogicalAddress, GetVendorName(), GetVendorId(), GetVendorClass());
m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str());
}
void CCECBusDevice::PollVendorId(void)
{
CLockObject lock(&m_mutex);
- if (m_iLastActive > 0 && m_iVendorId == CEC_VENDOR_UNKNOWN &&
+ if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST &&
+ m_iVendorId == CEC_VENDOR_UNKNOWN &&
GetTimeMs() - m_iLastActive > 5000)
{
m_iLastActive = GetTimeMs();
m_iPhysicalAddress = iNewAddress;
}
+bool CCECBusDevice::PowerOn(void)
+{
+ CStdString strLog;
+ strLog.Format("<< powering on device with logical address %d", (int8_t)m_iLogicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::Standby(void)
+{
+ CStdString strLog;
+ strLog.Format("<< putting device with logical address %d in standby mode", (int8_t)m_iLogicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::SetOSDString(cec_display_control duration, const char *strMessage)
+{
+ CStdString strLog;
+ strLog.Format("<< display message '%s'", strMessage);
+ AddLog(CEC_LOG_NOTICE, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_SET_OSD_STRING);
+ command.parameters.push_back((uint8_t)duration);
+
+ for (unsigned int iPtr = 0; iPtr < strlen(strMessage); iPtr++)
+ command.parameters.push_back(strMessage[iPtr]);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportCECVersion(void)
+{
+ AddLog(CEC_LOG_NOTICE, "<< reporting CEC version as 1.3a");
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_CEC_VERSION);
+ command.parameters.push_back(CEC_VERSION_1_3A);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportDeckStatus(void)
+{
+ // need to support opcodes play and deck control before doing anything with this
+ AddLog(CEC_LOG_NOTICE, "<< deck status requested, feature abort");
+ m_processor->TransmitAbort(m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ return false;
+}
+
+bool CCECBusDevice::ReportMenuState(bool bActive /* = true */)
+{
+ if (bActive)
+ AddLog(CEC_LOG_NOTICE, "<< reporting menu state as active");
+ else
+ AddLog(CEC_LOG_NOTICE, "<< reporting menu state as inactive");
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_MENU_STATUS);
+ command.parameters.push_back(bActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportOSDName(void)
+{
+ const char *osdname = m_processor->GetDeviceName().c_str();
+ CStdString strLog;
+ strLog.Format("<< reporting OSD name as %s", osdname);
+ AddLog(CEC_LOG_NOTICE, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_SET_OSD_NAME);
+ for (unsigned int iPtr = 0; iPtr < strlen(osdname); iPtr++)
+ command.parameters.push_back(osdname[iPtr]);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportPowerState(bool bOn /* = true */)
+{
+ if (bOn)
+ AddLog(CEC_LOG_NOTICE, "<< reporting \"On\" power status");
+ else
+ AddLog(CEC_LOG_NOTICE, "<< reporting \"Off\" power status");
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_REPORT_POWER_STATUS);
+ command.parameters.push_back(bOn ? (uint8_t) CEC_POWER_STATUS_ON : (uint8_t) CEC_POWER_STATUS_STANDBY);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportVendorID(void)
+{
+ AddLog(CEC_LOG_NOTICE, "<< vendor ID requested, feature abort");
+ m_processor->TransmitAbort(m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ return false;
+}
+
+bool CCECBusDevice::BroadcastActiveView(void)
+{
+ AddLog(CEC_LOG_DEBUG, "<< setting active view");
+
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
+ command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
+ command.parameters.push_back(m_iPhysicalAddress & 0xFF);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::BroadcastInactiveView(void)
+{
+ AddLog(CEC_LOG_DEBUG, "<< setting inactive view");
+
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE);
+ command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
+ command.parameters.push_back(m_iPhysicalAddress & 0xFF);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::BroadcastPhysicalAddress(void)
+{
+ CStdString strLog;
+ strLog.Format("<< reporting physical address as %04x", m_iPhysicalAddress);
+ AddLog(CEC_LOG_NOTICE, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS);
+ command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
+ command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
+ command.parameters.push_back((uint8_t) (CEC_DEVICE_TYPE_PLAYBACK_DEVICE));
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::BroadcastActiveSource(void)
+{
+ AddLog(CEC_LOG_NOTICE, "<< broadcasting active source");
+
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
+ command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
+ command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
+
+ return m_processor->Transmit(command);
+}
+
const char *CCECBusDevice::CECVendorIdToString(const uint64_t iVendorId)
{
switch (iVendorId)
virtual cec_logical_address GetMyLogicalAddress(void) const;
virtual uint16_t GetMyPhysicalAddress(void) const;
+ virtual void SetVendorId(const cec_datapacket &data);
virtual void SetVendorId(uint64_t iVendorId, uint8_t iVendorClass = 0);
virtual const char *GetVendorName(void) const { return CECVendorIdToString(m_iVendorId); }
virtual uint64_t GetVendorId(void) const { return m_iVendorId; }
virtual CCECCommandHandler *GetHandler(void) const { return m_handler; };
virtual void PollVendorId(void);
+ virtual bool PowerOn(void);
+ virtual bool Standby(void);
+ virtual bool SetOSDString(cec_display_control duration, const char *strMessage);
+ virtual bool ReportCECVersion(void);
+ virtual bool ReportDeckStatus(void);
+ virtual bool ReportMenuState(bool bActive = true);
+ virtual bool ReportOSDName(void);
+ virtual bool ReportPowerState(bool bOn = true);
+ virtual bool ReportVendorID(void);
+
+ virtual bool BroadcastActiveView(void);
+ virtual bool BroadcastInactiveView(void);
+ virtual bool BroadcastPhysicalAddress(void);
+ virtual bool BroadcastActiveSource(void);
static const char *CECVendorIdToString(const uint64_t iVendorId);
bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
{
- m_busDevice->GetProcessor()->ParseVendorId(command.initiator, command.parameters);
- return true;
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ device->SetVendorId(command.parameters);
+
+ return false;
}
bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
{
- m_busDevice->GetProcessor()->ParseVendorId(command.initiator, command.parameters);
- return true;
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ device->SetVendorId(command.parameters);
+
+ return false;
}
bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command)
{
- m_busDevice->GetProcessor()->ReportCECVersion(command.initiator);
- return true;
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ return device->ReportCECVersion();
+
+ return false;
}
bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command)
{
- // need to support opcodes play and deck control before doing anything with this
- m_busDevice->GetProcessor()->TransmitAbort(command.initiator, CEC_OPCODE_GIVE_DECK_STATUS);
- return true;
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ return device->ReportDeckStatus();
+
+ return false;
}
bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command)
{
- m_busDevice->GetProcessor()->ReportPowerState(command.initiator);
- return true;
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ return device->ReportPowerState();
+
+ return false;
}
bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command)
{
- m_busDevice->GetProcessor()->ReportVendorID(command.initiator);
- return true;
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ return device->ReportVendorID();
+
+ return false;
}
bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command)
{
- m_busDevice->GetProcessor()->ReportOSDName(command.initiator);
- return true;
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ return device->ReportOSDName();
+
+ return false;
}
bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command)
{
- m_busDevice->GetProcessor()->ReportPhysicalAddress();
- return true;
+ return m_busDevice->BroadcastPhysicalAddress();
}
bool CCECCommandHandler::HandleMenuRequest(const cec_command &command)
{
if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_QUERY)
- m_busDevice->GetProcessor()->ReportMenuState(command.initiator);
- return true;
+ {
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ return device->ReportMenuState();
+ }
+ return false;
}
bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command)
CStdString strLog;
strLog.Format(">> %i requests active source", (uint8_t) command.initiator);
m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
- m_busDevice->GetProcessor()->BroadcastActiveSource();
+ m_busDevice->BroadcastActiveSource();
return true;
}
uint16_t iOldAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
uint16_t iNewAddress = ((uint16_t)command.parameters[2] << 8) | ((uint16_t)command.parameters[3]);
- m_busDevice->SetPhysicalAddress(iNewAddress, iOldAddress);
+ CCECBusDevice *device = GetDevice(command.initiator);
+ if (device)
+ device->SetPhysicalAddress(iNewAddress, iOldAddress);
}
return true;
}
strLog.Format(">> %i requests stream path from physical address %04x", command.initiator, streamaddr);
m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
if (streamaddr == m_busDevice->GetMyPhysicalAddress())
- m_busDevice->GetProcessor()->BroadcastActiveSource();
+ m_busDevice->BroadcastActiveSource();
}
return true;
}
void CCECCommandHandler::UnhandledCommand(const cec_command &command)
{
- m_busDevice->GetProcessor()->AddCommand(command);;
+ m_busDevice->GetProcessor()->AddCommand(command);
+}
+
+CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress) const
+{
+ CCECBusDevice *device = NULL;
+
+ if (iLogicalAddress >= CECDEVICE_TV && iLogicalAddress <= CECDEVICE_BROADCAST)
+ device = m_busDevice->GetProcessor()->m_busDevices[iLogicalAddress];
+
+ return device;
}
bool HandleUserControlRelease(const cec_command &command);
void UnhandledCommand(const cec_command &command);
+ CCECBusDevice *GetDevice(cec_logical_address iLogicalAddress) const;
CCECBusDevice *m_busDevice;
};
};