/*!
* @brief Change the deck control mode, if this adapter is registered as playback device.
* @param mode The new control mode.
+ * @param bSendUpdate True to send the status over the CEC line.
* @return True if set, false otherwise.
*/
- virtual bool SetDeckControlMode(cec_deck_control_mode mode) = 0;
+ virtual bool SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true) = 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;
+ virtual bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true) = 0;
/*!
* @brief Broadcast a message that notifies connected CEC capable devices that this device is no longer the active source.
*/
virtual bool SetInactiveView(void) = 0;
+ /*!
+ * @brief Change the menu state.
+ * @param state The new true.
+ * @param bSendUpdate True to send the status over the CEC line.
+ * @return True if set, false otherwise.
+ */
+ virtual bool SetMenuState(cec_menu_state state, bool bSendUpdate = true) = 0;
+
/*!
* @brief Display a message on the device with the given logical address.
* @param iLogicalAddres The device to display the message on.
return SetActiveSource();
}
-bool CCECProcessor::SetDeckControlMode(cec_deck_control_mode mode)
+bool CCECProcessor::SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate /* = true */)
{
bool bReturn(false);
if (device)
{
((CCECPlaybackDevice *) device)->SetDeckControlMode(mode);
+ if (bSendUpdate)
+ ((CCECPlaybackDevice *) device)->TransmitDeckStatus(CECDEVICE_TV);
bReturn = true;
}
return bReturn;
}
-bool CCECProcessor::SetDeckInfo(cec_deck_info info)
+bool CCECProcessor::SetDeckInfo(cec_deck_info info, bool bSendUpdate /* = true */)
{
bool bReturn(false);
if (device)
{
((CCECPlaybackDevice *) device)->SetDeckStatus(info);
+ if (bSendUpdate)
+ ((CCECPlaybackDevice *) device)->TransmitDeckStatus(CECDEVICE_TV);
bReturn = true;
}
return true;
}
+bool CCECProcessor::SetMenuState(cec_menu_state state, bool bSendUpdate /* = true */)
+{
+ for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
+ {
+ if (m_logicalAddresses[iPtr])
+ m_busDevices[iPtr]->SetMenuState(state);
+ }
+
+ if (bSendUpdate)
+ m_busDevices[m_logicalAddresses.primary]->TransmitMenuState(CECDEVICE_TV);
+
+ return true;
+}
+
bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress)
{
if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary])
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 SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true);
+ virtual bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true);
virtual bool SetInactiveView(void);
virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress);
+ virtual bool SetMenuState(cec_menu_state state, bool bSendUpdate = true);
virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress);
virtual bool SetStreamPath(uint16_t iStreamPath);
virtual bool SwitchMonitoring(bool bEnable);
return m_cec ? m_cec->SetActiveView() : false;
}
-bool CLibCEC::SetDeckControlMode(cec_deck_control_mode mode)
+bool CLibCEC::SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate /* = true */)
{
- return m_cec ? m_cec->SetDeckControlMode(mode) : false;
+ return m_cec ? m_cec->SetDeckControlMode(mode, bSendUpdate) : false;
}
-bool CLibCEC::SetDeckInfo(cec_deck_info info)
+bool CLibCEC::SetDeckInfo(cec_deck_info info, bool bSendUpdate /* = true */)
{
- return m_cec ? m_cec->SetDeckInfo(info) : false;
+ return m_cec ? m_cec->SetDeckInfo(info, bSendUpdate) : false;
}
bool CLibCEC::SetInactiveView(void)
return m_cec ? m_cec->SetInactiveView() : false;
}
+bool CLibCEC::SetMenuState(cec_menu_state state, bool bSendUpdate /* = true */)
+{
+ return m_cec ? m_cec->SetMenuState(state, bSendUpdate) : false;
+}
+
bool CLibCEC::SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage)
{
return m_cec && iLogicalAddress >= CECDEVICE_TV && iLogicalAddress <= CECDEVICE_BROADCAST ?
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 SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true);
+ virtual bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true);
virtual bool SetInactiveView(void);
+ virtual bool SetMenuState(cec_menu_state state, bool bSendUpdate = true);
virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage);
virtual bool SwitchMonitoring(bool bEnable);
virtual cec_version GetDeviceCecVersion(cec_logical_address iAddress);
m_powerStatus(CEC_POWER_STATUS_UNKNOWN),
m_processor(processor),
m_vendor(CEC_VENDOR_UNKNOWN),
- m_bMenuActive(true),
+ m_menuState(CEC_MENU_STATE_DEACTIVATED),
m_bActiveSource(false),
m_iLastCommandSent(0),
m_iLastActive(0),
}
}
+void CCECBusDevice::SetMenuState(const cec_menu_state state)
+{
+ if (m_menuState != state)
+ {
+ CStdString strLog;
+ strLog.Format(">> %s (%X): menu state set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_menuState));
+ m_processor->AddLog(CEC_LOG_DEBUG, strLog);
+ m_menuState = state;
+ }
+}
+
void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
{
if (iNewAddress > 0)
bool CCECBusDevice::TransmitMenuState(cec_logical_address dest)
{
CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): ", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
- if (m_bMenuActive)
- strLog.append("menu active");
- else
- strLog.append("menu inactive");
+ strLog.Format("<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState));
AddLog(CEC_LOG_NOTICE, strLog);
cec_command command;
cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS);
- command.parameters.push_back(m_bMenuActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED);
+ command.parameters.push_back((uint8_t)m_menuState);
return m_processor->Transmit(command);
}
virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = 0);
virtual void SetCecVersion(const cec_version newVersion);
virtual void SetMenuLanguage(const cec_menu_language &menuLanguage);
+ virtual void SetMenuState(const cec_menu_state state);
virtual void SetVendorId(uint64_t iVendorId);
virtual void SetPowerStatus(const cec_power_status powerStatus);
CCECProcessor *m_processor;
CCECCommandHandler *m_handler;
cec_vendor_id m_vendor;
- bool m_bMenuActive;
+ cec_menu_state m_menuState;
bool m_bActiveSource;
uint64_t m_iLastCommandSent;
uint64_t m_iLastActive;
AddLog(CEC_LOG_NOTICE, strLog);
cec_command command;
- cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_GIVE_DECK_STATUS);
+ cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_DECK_STATUS);
command.push_back((uint8_t)m_deckStatus);
return m_processor->Transmit(command);
device->SetVendorId(iVendorId);
}
+const char *CCECCommandHandler::ToString(const cec_menu_state state)
+{
+ switch (state)
+ {
+ case CEC_MENU_STATE_ACTIVATED:
+ return "activated";
+ case CEC_MENU_STATE_DEACTIVATED:
+ return "deactivated";
+ default:
+ return "unknown";
+ }
+}
+
const char *CCECCommandHandler::ToString(const cec_version version)
{
switch (version)
virtual bool HandleCommand(const cec_command &command);
virtual cec_vendor_id GetVendorId(void) { return CEC_VENDOR_UNKNOWN; };
+ static const char *ToString(const cec_menu_state state);
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);