#include "../CECProcessor.h"
using namespace CEC;
+using namespace std;
CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice)
{
bool bHandled(true);
CStdString strLog;
- strLog.Format(">> %x -> %x: %s (%2x)", command.initiator, command.destination, ToString(command.opcode), command.opcode);
+ strLog.Format(">> %s (%X) -> %s (%X): %s (%2X)", ToString(command.initiator), command.initiator, ToString(command.destination), command.destination, ToString(command.opcode), command.opcode);
m_busDevice->AddLog(CEC_LOG_NOTICE, strLog);
if (m_busDevice->MyLogicalAddressContains(command.destination))
CStdString strLog;
strLog.Format(">> %i requests active source", (uint8_t) command.initiator);
m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
- CCECBusDevice *device = m_busDevice->GetProcessor()->m_busDevices[m_busDevice->GetMyLogicalAddress()];
- if (device)
- return device->TransmitActiveSource();
- return false;
+
+ vector<CCECBusDevice *> devices;
+ for (int iDevicePtr = (int)GetMyDevices(devices)-1; iDevicePtr >=0; iDevicePtr--)
+ devices[iDevicePtr]->TransmitActiveSource();
+ return true;
}
bool CCECCommandHandler::HandleRoutingChange(const cec_command &command)
m_busDevice->AddLog(CEC_LOG_DEBUG, strLog);
}
+unsigned int CCECCommandHandler::GetMyDevices(vector<CCECBusDevice *> &devices) const
+{
+ unsigned int iReturn(0);
+
+ cec_logical_addresses addresses = m_busDevice->GetProcessor()->GetLogicalAddresses();
+ for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+ {
+ if (addresses[iPtr])
+ {
+ devices.push_back(GetDevice((cec_logical_address) iPtr));
+ ++iReturn;
+ }
+ }
+
+ return iReturn;
+}
+
CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress) const
{
CCECBusDevice *device = NULL;
return;
}
- uint64_t iVendorId = ((uint64_t)command.parameters[0] << 3) +
- ((uint64_t)command.parameters[1] << 2) +
+ uint64_t iVendorId = ((uint64_t)command.parameters[0] << 16) +
+ ((uint64_t)command.parameters[1] << 8) +
(uint64_t)command.parameters[2];
CCECBusDevice *device = GetDevice((cec_logical_address) command.initiator);
device->SetVendorId(iVendorId, command.parameters.size > 3 ? command.parameters[3] : 0);
}
+const char *CCECCommandHandler::ToString(const cec_logical_address address)
+{
+ switch(address)
+ {
+ case CECDEVICE_AUDIOSYSTEM:
+ return "Audio";
+ case CECDEVICE_BROADCAST:
+ return "Broadcast";
+ case CECDEVICE_FREEUSE:
+ return "Free use";
+ case CECDEVICE_PLAYBACKDEVICE1:
+ return "Playback 1";
+ case CECDEVICE_PLAYBACKDEVICE2:
+ return "Playback 2";
+ case CECDEVICE_PLAYBACKDEVICE3:
+ return "Playback 3";
+ case CECDEVICE_RECORDINGDEVICE1:
+ return "Recorder 1";
+ case CECDEVICE_RECORDINGDEVICE2:
+ return "Recorder 2";
+ case CECDEVICE_RECORDINGDEVICE3:
+ return "Recorder 3";
+ case CECDEVICE_RESERVED1:
+ return "Reserved 1";
+ case CECDEVICE_RESERVED2:
+ return "Reserved 2";
+ case CECDEVICE_TUNER1:
+ return "Tuner 1";
+ case CECDEVICE_TUNER2:
+ return "Tuner 2";
+ case CECDEVICE_TUNER3:
+ return "Tuner 3";
+ case CECDEVICE_TUNER4:
+ return "Tuner 4";
+ case CECDEVICE_TV:
+ return "TV";
+ default:
+ return "unknown";
+ }
+}
+
const char *CCECCommandHandler::ToString(const cec_opcode opcode)
{
switch (opcode)