CEC_MINOR_CHANNEL_NUMBER_MASK = 0xFFFF
} ECecChannelIdentifier;
-typedef enum
+typedef enum cec_deck_control_mode
{
CEC_DESK_CONTROL_MODE_SKIP_FORWARD_WIND = 1,
CEC_DESK_CONTROL_MODE_SKIP_REVERSE_REWIND = 2,
CEC_DESK_CONTROL_MODE_STOP = 3,
CEC_DESK_CONTROL_MODE_EJECT = 4
-} ECecDeskControlMode;
+} cec_deck_control_mode;
-typedef enum
+typedef enum cec_deck_info
{
CEC_DECK_INFO_PLAY = 0x11,
CEC_DECK_INFO_RECORD = 0x12,
CEC_DECK_INFO_INDEX_SEARCH_FORWARD = 0x1D,
CEC_DECK_INFO_INDEX_SEARCH_REVERSE = 0x1E,
CEC_DECK_INFO_OTHER_STATUS = 0x1F
-} ECecDeckInfo;
+} cec_deck_info;
typedef enum cec_device_type
{
bool CCECProcessor::SetActiveView(void)
{
+ bool bReturn(false);
+
if (!IsRunning())
- return false;
+ return bReturn;
if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary])
- return m_busDevices[m_logicalAddresses.primary]->TransmitActiveView();
+ {
+ SetStreamPath(m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress());
+ bReturn = m_busDevices[m_logicalAddresses.primary]->TransmitActiveSource();
+ }
+ return false;
+}
+
+bool CCECProcessor::SetStreamPath(uint16_t iStreamPath)
+{
+ CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath);
+ if (device)
+ {
+ for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+ m_busDevices[iPtr]->m_bActiveSource = false;
+
+ device->m_bActiveSource = true;
+ return true;
+ }
+
return false;
}
if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary])
{
m_busDevices[m_logicalAddresses.primary]->SetPhysicalAddress(iPhysicalAddress);
- return m_busDevices[m_logicalAddresses.primary]->TransmitActiveView();
+ return SetActiveView();
}
return false;
}
return false;
}
+
+CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const
+{
+ CCECBusDevice *device = NULL;
+
+ for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+ {
+ if (m_busDevices[iPtr]->GetPhysicalAddress() == iPhysicalAddress)
+ {
+ device = m_busDevices[iPtr];
+ break;
+ }
+ }
+
+ return device;
+}
+
cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress)
{
return m_busDevices[iAddress]->GetCecVersion();
virtual void *Process(void);
virtual bool IsMonitoring(void) const { return m_bMonitor; }
+ virtual CCECBusDevice * GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const;
virtual cec_version GetDeviceCecVersion(cec_logical_address iAddress);
virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language);
virtual const std::string & GetDeviceName(void) { return m_strDeviceName; }
virtual bool SetInactiveView(void);
virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress);
virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress);
+ virtual bool SetStreamPath(uint16_t iStreamPath);
virtual bool SwitchMonitoring(bool bEnable);
virtual bool PollDevice(cec_logical_address iAddress);
return false;
}
-bool CCECBusDevice::TransmitActiveView(void)
-{
- CStdString strLog;
- strLog.Format("<< %s (%X) -> broadcast (F): active view (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
- AddLog(CEC_LOG_NOTICE, strLog);
-
- 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::TransmitCECVersion(cec_logical_address dest)
{
CStdString strLog;
virtual void SetPowerStatus(const cec_power_status powerStatus);
virtual bool TransmitActiveSource(void);
- virtual bool TransmitActiveView(void);
virtual bool TransmitCECVersion(cec_logical_address dest);
virtual bool TransmitInactiveView(void);
virtual bool TransmitMenuState(cec_logical_address dest);
using namespace CEC;
CCECPlaybackDevice::CCECPlaybackDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress /* = 0 */) :
- CCECBusDevice(processor, address, iPhysicalAddress)
+ CCECBusDevice(processor, address, iPhysicalAddress),
+ m_deckStatus(CEC_DECK_INFO_NO_MEDIA)
{
m_type = CEC_DEVICE_TYPE_PLAYBACK_DEVICE;
}
+void CCECPlaybackDevice::SetDeckStatus(cec_deck_info deckStatus)
+{
+ if (m_deckStatus != deckStatus)
+ {
+ CStdString strLog;
+ strLog.Format(">> %s (%X): deck status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(m_deckStatus), CCECCommandHandler::ToString(deckStatus));
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ m_deckStatus = deckStatus;
+ }
+}
+
bool CCECPlaybackDevice::TransmitDeckStatus(cec_logical_address dest)
{
// need to support opcodes play and deck control before doing anything with this
CCECPlaybackDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0);
virtual ~CCECPlaybackDevice(void) {};
+ virtual cec_deck_info GetDeckStatus(void) const { return m_deckStatus; };
+
+ virtual void SetDeckStatus(cec_deck_info deckStatus);
+
virtual bool TransmitDeckStatus(cec_logical_address dest);
+
+ protected:
+ cec_deck_info m_deckStatus;
};
}
CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const
{
- CCECBusDevice *device = NULL;
-
- for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
- {
- if (m_busDevice->GetProcessor()->m_busDevices[iPtr]->GetPhysicalAddress() == iPhysicalAddress)
- {
- device = m_busDevice->GetProcessor()->m_busDevices[iPtr];
- break;
- }
- }
-
- return device;
+ return m_busDevice->GetProcessor()->GetDeviceByPhysicalAddress(iPhysicalAddress);
}
void CCECCommandHandler::SetVendorId(const cec_command &command)
}
}
+const char *CCECCommandHandler::ToString(const cec_deck_info status)
+{
+ switch (status)
+ {
+ case CEC_DECK_INFO_PLAY:
+ return "play";
+ case CEC_DECK_INFO_RECORD:
+ return "record";
+ case CEC_DECK_INFO_PLAY_REVERSE:
+ return "play reverse";
+ case CEC_DECK_INFO_STILL:
+ return "still";
+ case CEC_DECK_INFO_SLOW:
+ return "slow";
+ case CEC_DECK_INFO_SLOW_REVERSE:
+ return "slow reverse";
+ case CEC_DECK_INFO_FAST_FORWARD:
+ return "fast forward";
+ case CEC_DECK_INFO_FAST_REVERSE:
+ return "fast reverse";
+ case CEC_DECK_INFO_NO_MEDIA:
+ return "no media";
+ case CEC_DECK_INFO_STOP:
+ return "stop";
+ case CEC_DECK_INFO_SKIP_FORWARD_WIND:
+ return "info skip forward wind";
+ case CEC_DECK_INFO_SKIP_REVERSE_REWIND:
+ return "info skip reverse rewind";
+ case CEC_DECK_INFO_INDEX_SEARCH_FORWARD:
+ return "info index search forward";
+ case CEC_DECK_INFO_INDEX_SEARCH_REVERSE:
+ return "info index search reverse";
+ case CEC_DECK_INFO_OTHER_STATUS:
+ return "other";
+ default:
+ return "unknown";
+ }
+}
+
const char *CCECCommandHandler::ToString(const cec_opcode opcode)
{
switch (opcode)
virtual bool HandleCommand(const cec_command &command);
virtual cec_vendor_id GetVendorId(void) { return CEC_VENDOR_UNKNOWN; };
+ static const char *ToString(const cec_deck_info status);
static const char* ToString(const cec_logical_address address);
static const char* ToString(const cec_opcode opcode);
if (device)
{
return device->TransmitActiveSource() &&
- device->TransmitActiveView() &&
device->TransmitMenuState(command.initiator);
}
return false;