*/
virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress) = 0;
+ /*!
+ * @brief Get the physical address of the device with the given logical address.
+ * @param iLogicalAddress The device to get the vendor id for.
+ * @return The physical address or 0 if it wasn't found.
+ */
+ virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress) = 0;
+
/*!
* @brief Sends a POLL message to a device.
* @param iAddress The device to send the message to.
*/
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 uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress);
#endif
+#ifdef __cplusplus
+extern DECLSPEC uint16_t cec_get_device_physical_address(CEC::cec_logical_address iLogicalAddress);
+#else
+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
}
lock.Leave();
- if (SetAckMask(m_logicalAddresses.AckMask()) &&
- SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true))
+
+ m_busDevices[CECDEVICE_TV]->GetVendorId();
+
+ if (SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true))
{
m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
m_busScan = new CCECBusScan(this);
}
else
{
- m_busDevices[CECDEVICE_TV]->GetVendorId();
- m_busDevices[m_logicalAddresses.primary]->TransmitVendorID(CECDEVICE_TV, false);
+ SetAckMask(m_logicalAddresses.AckMask());
CLockObject lock(&m_mutex);
m_bStarted = true;
{
bool bReturn(false);
- CStdString strLog;
- strLog.Format("setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice);
- AddLog(CEC_LOG_DEBUG, strLog);
-
m_iBaseDevice = iBaseDevice;
m_iHDMIPort = iPort;
if (!m_bStarted && !bForce)
return true;
+ CStdString strLog;
+ strLog.Format("setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice);
+ AddLog(CEC_LOG_DEBUG, strLog);
+
uint16_t iPhysicalAddress(0);
- iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress();
- uint16_t iPos = 0;
- if (iPhysicalAddress == 0)
- iPos = 0x1000;
- else if (iPhysicalAddress % 0x1000 == 0)
- iPos = 0x100;
- else if (iPhysicalAddress % 0x100 == 0)
- iPos = 0x10;
- else if (iPhysicalAddress % 0x10 == 0)
- iPos = 0x1;
-
- while(!bReturn && iPos > 0)
+ if (iBaseDevice > CECDEVICE_TV)
+ iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress();
+
+ if (iPhysicalAddress == 0xffff)
{
- iPhysicalAddress += (uint16_t)(iPort * iPos);
- strLog.Format("checking physical address %4x", iPhysicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- if (PhysicalAddressInUse(iPhysicalAddress))
- {
- strLog.Format("physical address %4x is in use", iPhysicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- iPos = (iPos == 1) ? 0 : iPos / 0x10;
- }
- else
+ SetPhysicalAddress((uint16_t)iPort * 0x1000);
+ bReturn = false;
+ }
+ else
+ {
+ uint16_t iPos = 0;
+ if (iPhysicalAddress == 0)
+ iPos = 0x1000;
+ else if (iPhysicalAddress % 0x1000 == 0)
+ iPos = 0x100;
+ else if (iPhysicalAddress % 0x100 == 0)
+ iPos = 0x10;
+ else if (iPhysicalAddress % 0x10 == 0)
+ iPos = 0x1;
+
+ while(!bReturn && iPos > 0)
{
- strLog.Format("physical address %4x is free", iPhysicalAddress);
+ iPhysicalAddress += (uint16_t)(iPort * iPos);
+ strLog.Format("checking physical address %4x", iPhysicalAddress);
AddLog(CEC_LOG_DEBUG, strLog);
- SetPhysicalAddress(iPhysicalAddress);
- bReturn = true;
+ if (PhysicalAddressInUse(iPhysicalAddress))
+ {
+ strLog.Format("physical address %4x is in use", iPhysicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog);
+ iPos = (iPos == 1) ? 0 : iPos / 0x10;
+ }
+ else
+ {
+ strLog.Format("physical address %4x is free", iPhysicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog);
+ SetPhysicalAddress(iPhysicalAddress);
+ bReturn = true;
+ }
}
}
for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
if (m_logicalAddresses[iPtr])
{
+ m_busDevices[iPtr]->SetInactiveDevice();
m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress);
m_busDevices[iPtr]->TransmitPhysicalAddress();
}
return false;
}
+uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress)
+{
+ if (m_busDevices[iAddress])
+ return m_busDevices[iAddress]->GetPhysicalAddress(false);
+ return false;
+}
+
cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress)
{
if (m_busDevices[iAddress])
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);
while (!IsStopped())
{
- if (++iCounter < 30)
+ if (++iCounter < 10)
{
Sleep(1000);
continue;
virtual cec_logical_address GetLogicalAddress(void) const { return m_logicalAddresses.primary; }
virtual cec_logical_addresses GetLogicalAddresses(void) const { return m_logicalAddresses; }
virtual cec_logical_addresses GetActiveDevices(void);
+ virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress);
virtual bool HasLogicalAddress(cec_logical_address address) const { return m_logicalAddresses.IsSet(address); }
virtual bool IsActiveDevice(cec_logical_address address);
virtual bool IsActiveDeviceType(cec_device_type type);
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;
}
+uint16_t CLibCEC::GetDevicePhysicalAddress(cec_logical_address iAddress)
+{
+ if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST)
+ return m_cec->GetDevicePhysicalAddress(iAddress);
+ 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 cec_version GetDeviceCecVersion(cec_logical_address iAddress);
virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language);
virtual uint64_t GetDeviceVendorId(cec_logical_address iAddress);
+ virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress);
virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress);
virtual bool PollDevice(cec_logical_address iAddress);
virtual cec_logical_addresses GetActiveDevices(void);
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;
}
+uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress)
+{
+ if (cec_parser)
+ return cec_parser->GetDevicePhysicalAddress(iLogicalAddress);
+ 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)
{
CLockObject lock(&m_writeMutex);
m_iLastActive = GetTimeMs();
+
+ if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
+ m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
}
/* handle the command */
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);
CCECBusDevice *primary = m_processor->m_busDevices[m_processor->GetLogicalAddresses().primary];
if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ {
primary->SetVendorId(CEC_VENDOR_LG, false);
+ primary->TransmitVendorID(CECDEVICE_TV, false);
+ }
if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
{
device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE))
{
((CCECPlaybackDevice *)device)->SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG);
+ ((CCECPlaybackDevice *)device)->TransmitDeckStatus(CECDEVICE_TV);
}
}
}
{
if (addresses[iPtr])
{
- uint64_t iVendorId = parser->GetDeviceVendorId((cec_logical_address)iPtr);
- cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr);
- cec_power_status power = parser->GetDevicePowerStatus((cec_logical_address)iPtr);
- cec_osd_name osdName = parser->GetOSDName((cec_logical_address)iPtr);
+ uint64_t iVendorId = parser->GetDeviceVendorId((cec_logical_address)iPtr);
+ bool bActive = parser->IsActiveSource((cec_logical_address)iPtr);
+ uint16_t iPhysicalAddress = parser->GetDevicePhysicalAddress((cec_logical_address)iPtr);
+ cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr);
+ cec_power_status power = parser->GetDevicePowerStatus((cec_logical_address)iPtr);
+ cec_osd_name osdName = parser->GetOSDName((cec_logical_address)iPtr);
+ CStdString strAddr;
+ strAddr.Format("%04x", iPhysicalAddress);
cec_menu_language lang;
lang.device = CECDEVICE_UNKNOWN;
parser->GetDeviceMenuLanguage((cec_logical_address)iPtr, &lang);
cout << "device #" << (int)iPtr << ": " << parser->ToString((cec_logical_address)iPtr) << 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;
}
}