virtual bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST) = 0;
/*!
- * @brief Broadcast a message that notifies connected CEC capable devices that this device is the active source.
+ * @brief Change the active source.
+ * @param type The new active source. Leave empty to use the primary type
* @return True when the command was sent succesfully, false otherwise.
*/
+ virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED) = 0;
+
+ /*!
+ * @deprecated Use SetActiveSource() instead
+ */
virtual bool SetActiveView(void) = 0;
/*!
extern DECLSPEC int cec_set_active_view(void);
+#ifdef __cplusplus
+extern DECLSPEC int cec_set_active_source(CEC::cec_device_type type = CEC::CEC_DEVICE_TYPE_RESERVED);
+#else
+extern DECLSPEC int cec_set_active_source(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
+#endif
+
extern DECLSPEC int cec_set_inactive_view(void);
#ifdef __cplusplus
return NULL;
}
-bool CCECProcessor::SetActiveView(void)
+bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */)
{
bool bReturn(false);
if (!IsRunning())
return bReturn;
- if (!m_logicalAddresses.empty() && m_busDevices[m_logicalAddresses.primary])
- bReturn = SetStreamPath(m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress());
+ cec_logical_address addr = m_logicalAddresses.primary;
- return bReturn;
+ if (type != CEC_DEVICE_TYPE_RESERVED)
+ {
+ for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+ {
+ if (m_logicalAddresses[iPtr] && m_busDevices[iPtr]->m_type == type)
+ {
+ addr = (cec_logical_address) iPtr;
+ break;
+ }
+ }
+ }
+
+ return SetStreamPath(m_busDevices[addr]->GetPhysicalAddress());
+}
+
+bool CCECProcessor::SetActiveView(void)
+{
+ return SetActiveSource();
}
bool CCECProcessor::SetStreamPath(uint16_t iStreamPath)
virtual uint16_t GetPhysicalAddress(void) const;
virtual bool SetActiveView(void);
+ virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
virtual bool SetInactiveView(void);
virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress);
virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress);
return m_cec && address >= CECDEVICE_TV && address <= CECDEVICE_BROADCAST ? m_cec->m_busDevices[(uint8_t)address]->Standby() : false;
}
+bool CLibCEC::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */)
+{
+ return m_cec ? m_cec->SetActiveSource(type) : false;
+}
+
bool CLibCEC::SetActiveView(void)
{
return m_cec ? m_cec->SetActiveView() : false;
virtual bool PowerOnDevices(cec_logical_address address = CECDEVICE_TV);
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 SetInactiveView(void);
virtual bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage);
virtual bool SwitchMonitoring(bool bEnable);
return -1;
}
+int cec_set_active_source(cec_device_type type)
+{
+ if (cec_parser)
+ return cec_parser->SetActiveSource(type) ? 1 : 0;
+ return -1;
+}
+
int cec_set_inactive_view(void)
{
if (cec_parser)
parser->PowerOnDevices(CECDEVICE_TV);
flush_log(parser);
- parser->SetActiveView();
+ parser->SetActiveSource();
flush_log(parser);
bool bContinue(true);
parser->Open(g_strPort.c_str());
flush_log(parser);
- cout << "setting active view" << endl;
- parser->SetActiveView();
+ cout << "setting active source" << endl;
+ parser->SetActiveSource();
}
else if (command == "h" || command == "help")
{