*/
virtual bool SetActiveView(void) = 0;
+ /*!
+ * @brief Change the deck control mode, if this adapter is registered as playback device.
+ * @param mode The new control mode.
+ * @return True if set, false otherwise.
+ */
+ virtual bool SetDeckControlMode(cec_deck_control_mode mode) = 0;
+
+ /*!
+ * @brief Change the deck info, if this adapter is a playback device.
+ * @param info The new deck info.
+ * @return True if set, false otherwise.
+ */
+ virtual bool SetDeckInfo(cec_deck_info info) = 0;
+
/*!
* @brief Broadcast a message that notifies connected CEC capable devices that this device is no longer the active source.
* @return True when the command was sent succesfully, false otherwise.
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
+ CEC_DECK_CONTROL_MODE_SKIP_FORWARD_WIND = 1,
+ CEC_DECK_CONTROL_MODE_SKIP_REVERSE_REWIND = 2,
+ CEC_DECK_CONTROL_MODE_STOP = 3,
+ CEC_DECK_CONTROL_MODE_EJECT = 4
} cec_deck_control_mode;
typedef enum cec_deck_info
return SetActiveSource();
}
+bool CCECProcessor::SetDeckControlMode(cec_deck_control_mode mode)
+{
+ bool bReturn(false);
+
+ CCECBusDevice *device = GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
+ if (device)
+ {
+ ((CCECPlaybackDevice *) device)->SetDeckControlMode(mode);
+ bReturn = true;
+ }
+
+ return bReturn;
+}
+
+bool CCECProcessor::SetDeckInfo(cec_deck_info info)
+{
+ bool bReturn(false);
+
+ CCECBusDevice *device = GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
+ if (device)
+ {
+ ((CCECPlaybackDevice *) device)->SetDeckStatus(info);
+ bReturn = true;
+ }
+
+ return bReturn;
+}
+
bool CCECProcessor::SetStreamPath(uint16_t iStreamPath)
{
bool bReturn(false);
return false;
}
-
CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const
{
CCECBusDevice *device = NULL;
return device;
}
+CCECBusDevice *CCECProcessor::GetDeviceByType(cec_device_type type) const
+{
+ CCECBusDevice *device = NULL;
+
+ for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+ {
+ if (m_busDevices[iPtr]->m_type == type)
+ {
+ device = m_busDevices[iPtr];
+ break;
+ }
+ }
+
+ return device;
+}
+
cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress)
{
return m_busDevices[iAddress]->GetCecVersion();
virtual bool IsMonitoring(void) const { return m_bMonitor; }
virtual CCECBusDevice * GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const;
+ virtual CCECBusDevice * GetDeviceByType(cec_device_type type) 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 SetActiveView(void);
virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
+ virtual bool SetDeckControlMode(cec_deck_control_mode mode);
+ virtual bool SetDeckInfo(cec_deck_info info);
virtual bool SetInactiveView(void);
virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress);
virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress);
return m_cec ? m_cec->SetActiveView() : false;
}
+bool CLibCEC::SetDeckControlMode(cec_deck_control_mode mode)
+{
+ return m_cec ? m_cec->SetDeckControlMode(mode) : false;
+}
+
+bool CLibCEC::SetDeckInfo(cec_deck_info info)
+{
+ return m_cec ? m_cec->SetDeckInfo(info) : false;
+}
+
bool CLibCEC::SetInactiveView(void)
{
return m_cec ? m_cec->SetInactiveView() : false;
virtual bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST);
virtual bool SetActiveView(void);
virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
+ virtual bool SetDeckControlMode(cec_deck_control_mode mode);
+ virtual bool SetDeckInfo(cec_deck_info info);
virtual bool SetInactiveView(void);
virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage);
virtual bool SwitchMonitoring(bool bEnable);
CCECPlaybackDevice::CCECPlaybackDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress /* = 0 */) :
CCECBusDevice(processor, address, iPhysicalAddress),
- m_deckStatus(CEC_DECK_INFO_NO_MEDIA)
+ m_deckStatus(CEC_DECK_INFO_STOP),
+ m_deckControlMode(CEC_DECK_CONTROL_MODE_STOP)
{
m_type = CEC_DEVICE_TYPE_PLAYBACK_DEVICE;
}
}
}
+void CCECPlaybackDevice::SetDeckControlMode(cec_deck_control_mode mode)
+{
+ if (m_deckControlMode != mode)
+ {
+ CStdString strLog;
+ strLog.Format(">> %s (%X): deck control mode changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(m_deckControlMode), CCECCommandHandler::ToString(mode));
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ m_deckControlMode = mode;
+ }
+}
+
bool CCECPlaybackDevice::TransmitDeckStatus(cec_logical_address dest)
{
- // need to support opcodes play and deck control before doing anything with this
CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): deck status feature abort", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest);
+ strLog.Format("<< %s (%X) -> %s (%X): deck status '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest, CCECCommandHandler::ToString(m_deckStatus));
AddLog(CEC_LOG_NOTICE, strLog);
- m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DECK_STATUS);
- return false;
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_GIVE_DECK_STATUS);
+ command.push_back((uint8_t)m_deckStatus);
+
+ return m_processor->Transmit(command);
}
virtual ~CCECPlaybackDevice(void) {};
virtual cec_deck_info GetDeckStatus(void) const { return m_deckStatus; };
+ virtual cec_deck_control_mode GetDeckControlMode(void) const { return m_deckControlMode; };
virtual void SetDeckStatus(cec_deck_info deckStatus);
+ virtual void SetDeckControlMode(cec_deck_control_mode mode);
virtual bool TransmitDeckStatus(cec_logical_address dest);
protected:
- cec_deck_info m_deckStatus;
+ cec_deck_info m_deckStatus;
+ cec_deck_control_mode m_deckControlMode;
};
}
case CEC_OPCODE_GIVE_DECK_STATUS:
HandleGiveDeckStatus(command);
break;
+ case CEC_OPCODE_DECK_CONTROL:
+ HandleDeckControl(command);
+ break;
case CEC_OPCODE_MENU_REQUEST:
HandleMenuRequest(command);
break;
return true;
}
+bool CCECCommandHandler::HandleDeckControl(const cec_command &command)
+{
+ CCECBusDevice *device = GetDevice(command.destination);
+ if (device && device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE && command.parameters.size > 0)
+ {
+ ((CCECPlaybackDevice *) device)->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]);
+ return true;
+ }
+
+ return false;
+}
+
bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command)
{
if (command.parameters.size == 1)
}
}
+const char *CCECCommandHandler::ToString(const cec_deck_control_mode mode)
+{
+ switch (mode)
+ {
+ case CEC_DECK_CONTROL_MODE_SKIP_FORWARD_WIND:
+ return "skip forward wind";
+ case CEC_DECK_CONTROL_MODE_EJECT:
+ return "eject";
+ case CEC_DECK_CONTROL_MODE_SKIP_REVERSE_REWIND:
+ return "reverse rewind";
+ case CEC_DECK_CONTROL_MODE_STOP:
+ return "stop";
+ default:
+ return "unknown";
+ }
+}
+
const char *CCECCommandHandler::ToString(const cec_deck_info status)
{
switch (status)
virtual bool HandleCommand(const cec_command &command);
virtual cec_vendor_id GetVendorId(void) { return CEC_VENDOR_UNKNOWN; };
+ static const char *ToString(const cec_deck_control_mode mode);
static const char *ToString(const cec_version version);
static const char *ToString(const cec_power_status status);
static const char *ToString(const cec_deck_info status);
protected:
virtual bool HandleActiveSource(const cec_command &command);
+ virtual bool HandleDeckControl(const cec_command &command);
virtual bool HandleDeviceCecVersion(const cec_command &command);
virtual bool HandleDeviceVendorCommandWithId(const cec_command &command);
virtual bool HandleDeviceVendorId(const cec_command &command);