*/
virtual cec_osd_name GetOSDName(cec_logical_address iAddress) = 0;
+ /*!
+ * @brief Get the logical address of the device that is currently the active source on the CEC bus.
+ * @return The active source or CECDEVICE_UNKNOWN when unknown.
+ */
+ virtual cec_logical_address GetActiveSource(void) = 0;
+
+ /*!
+ * @brief Check whether a device is currently the active source on the CEC bus.
+ * @param iAddress The address to check.
+ * @return True when it is the active source, false otherwise.
+ */
+ virtual bool IsActiveSource(cec_logical_address iAddress) = 0;
+
virtual const char *ToString(const cec_menu_state state) = 0;
virtual const char *ToString(const cec_version version) = 0;
virtual const char *ToString(const cec_power_status status) = 0;
extern DECLSPEC uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress);
#endif
+#ifdef __cplusplus
+extern DECLSPEC CEC::cec_logical_address cec_get_active_source(void);
+#else
+extern DECLSPEC cec_logical_address cec_get_active_source(void);
+#endif
+
+#ifdef __cplusplus
+extern DECLSPEC int cec_is_active_source(CEC::cec_logical_address iAddress);
+#else
+extern DECLSPEC int cec_is_active_source(cec_logical_address iAddress);
+#endif
+
#ifdef __cplusplus
extern DECLSPEC CEC::cec_power_status cec_get_device_power_status(CEC::cec_logical_address iLogicalAddress);
#else
return CEC_POWER_STATUS_UNKNOWN;
}
+cec_logical_address CCECProcessor::GetActiveSource(void)
+{
+ for (uint8_t iPtr = 0; iPtr <= 11; iPtr++)
+ {
+ if (m_busDevices[iPtr]->IsActiveSource())
+ return (cec_logical_address)iPtr;
+ }
+
+ return CECDEVICE_UNKNOWN;
+}
+
+bool CCECProcessor::IsActiveSource(cec_logical_address iAddress)
+{
+ return m_busDevices[iAddress]->IsActiveSource();
+}
+
bool CCECProcessor::Transmit(const cec_command &data)
{
bool bReturn(false);
virtual uint16_t GetPhysicalAddress(void) const;
virtual uint64_t GetLastTransmission(void) const { return m_iLastTransmission; }
virtual bool IsStarted(void) const { return m_bStarted; }
+ virtual cec_logical_address GetActiveSource(void);
+ virtual bool IsActiveSource(cec_logical_address iAddress);
virtual bool SetActiveView(void);
virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
return 0;
}
+cec_logical_address CLibCEC::GetActiveSource(void)
+{
+ return m_cec ? m_cec->GetActiveSource() : CECDEVICE_UNKNOWN;
+}
+
+bool CLibCEC::IsActiveSource(cec_logical_address iAddress)
+{
+ if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
+ return m_cec->IsActiveSource(iAddress);
+ return false;
+}
+
cec_power_status CLibCEC::GetDevicePowerStatus(cec_logical_address iAddress)
{
if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
virtual bool SendKeyRelease(cec_logical_address iDestination, bool bWait = false);
virtual cec_osd_name GetOSDName(cec_logical_address iAddress);
virtual bool EnablePhysicalAddressDetection(void);
+ virtual cec_logical_address GetActiveSource(void);
+ virtual bool IsActiveSource(cec_logical_address iAddress);
const char *ToString(const cec_menu_state state);
const char *ToString(const cec_version version);
return 0;
}
+cec_logical_address cec_get_active_source(void)
+{
+ if (cec_parser)
+ return cec_parser->GetActiveSource();
+ return CECDEVICE_UNKNOWN;
+}
+
+int cec_is_active_source(cec_logical_address iAddress)
+{
+ if (cec_parser)
+ return cec_parser->IsActiveSource(iAddress);
+ return false;
+}
+
cec_power_status cec_get_device_power_status(cec_logical_address iLogicalAddress)
{
if (cec_parser)
virtual const char * GetVendorName(bool bUpdate = false);
virtual bool MyLogicalAddressContains(cec_logical_address address) const;
virtual cec_bus_device_status GetStatus(bool bForcePoll = false);
+ virtual bool IsActiveSource(void) const { return m_bActiveSource; }
+
virtual void SetInactiveDevice(void);
virtual void SetActiveDevice(void);
{
if (addresses[iPtr])
{
+ bool bActive = parser->IsActiveSource((cec_logical_address)iPtr);
uint16_t iPhysicalAddress = parser->GetDevicePhysicalAddress((cec_logical_address)iPtr);
uint64_t iVendorId = parser->GetDeviceVendorId((cec_logical_address)iPtr);
cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr);
parser->GetDeviceMenuLanguage((cec_logical_address)iPtr, &lang);
cout << "device #" << (int)iPtr << ": " << parser->ToString((cec_logical_address)iPtr) << endl;
- cout << "address: " << strAddr.c_str() << endl;
- cout << "vendor: " << parser->ToString((cec_vendor_id)iVendorId) << endl;
- cout << "osd string: " << osdName.name << endl;
- cout << "CEC version: " << parser->ToString(iCecVersion) << endl;
- cout << "power status: " << parser->ToString(power) << endl;
+ cout << "address: " << strAddr.c_str() << endl;
+ cout << "active source: " << (bActive ? "yes" : "no") << endl;
+ cout << "vendor: " << parser->ToString((cec_vendor_id)iVendorId) << endl;
+ cout << "osd string: " << osdName.name << endl;
+ cout << "CEC version: " << parser->ToString(iCecVersion) << endl;
+ cout << "power status: " << parser->ToString(power) << endl;
if ((uint8_t)lang.device == iPtr)
- cout << "language: " << lang.language << endl;
+ cout << "language: " << lang.language << endl;
cout << endl;
}
}