class CCECProcessor : public CThread
{
public:
- CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm, const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1, uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
+ CCECProcessor(CLibCEC *controller, const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1, uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
+ CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types);
virtual ~CCECProcessor(void);
- virtual bool Start(void);
- void *Process(void);
+ virtual bool Start(const char *strPort, uint16_t iBaudRate = 38400, uint32_t iTimeoutMs = 10000);
+ virtual void *Process(void);
+
+ virtual bool IsMonitoring(void) const { return m_bMonitor; }
+ virtual CCECBusDevice * GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bRefresh = false) const;
+ virtual CCECBusDevice * GetDeviceByType(cec_device_type type) const;
+ virtual CCECBusDevice * GetPrimaryDevice(void) 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 cec_osd_name GetDeviceOSDName(cec_logical_address iAddress);
+ virtual uint64_t GetDeviceVendorId(cec_logical_address iAddress);
+ virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress);
+ 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 IsPresentDevice(cec_logical_address address);
+ virtual bool IsPresentDeviceType(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 IsInitialised(void) const { return m_bInitialised; }
virtual bool SetActiveView(void);
- virtual bool SetInactiveView(void);
- virtual bool Transmit(const cec_command &data);
- virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress = CECDEVICE_UNKNOWN);
+ virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
+ virtual bool SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true);
+ virtual bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true);
+ virtual bool SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, bool bForce = false);
+ virtual bool TransmitInactiveSource(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 SetActiveSource(uint16_t iStreamPath);
virtual bool SwitchMonitoring(bool bEnable);
- 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 cec_power_status GetDevicePowerStatus(cec_logical_address iAddress);
+ virtual bool PollDevice(cec_logical_address iAddress);
+ virtual uint8_t VolumeUp(bool bSendRelease = true);
+ virtual uint8_t VolumeDown(bool bSendRelease = true);
+ virtual uint8_t MuteAudio(bool bSendRelease = true);
+ virtual bool TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait = true);
+ virtual bool TransmitKeyRelease(cec_logical_address iDestination, bool bWait = true);
+ virtual bool EnablePhysicalAddressDetection(void) { return false; };
+ void SetStandardLineTimeout(uint8_t iTimeout);
+ void SetRetryLineTimeout(uint8_t iTimeout);
+
+ bool SetLineTimeout(uint8_t iTimeout);
- virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; }
- virtual uint16_t GetPhysicalAddress(void) const;
- virtual const std::string &GetDeviceName(void) { return m_strDeviceName; }
+ const char *ToString(const cec_device_type type);
+ const char *ToString(const cec_menu_state state);
+ const char *ToString(const cec_version version);
+ const char *ToString(const cec_power_status status);
+ const char *ToString(const cec_logical_address address);
+ const char *ToString(const cec_deck_control_mode mode);
+ const char *ToString(const cec_deck_info status);
+ const char *ToString(const cec_opcode opcode);
+ const char *ToString(const cec_system_audio_status mode);
+ const char *ToString(const cec_audio_status status);
+ const char *ToString(const cec_vendor_id vendor);
+
+ virtual bool Transmit(const cec_command &data);
+ virtual bool Transmit(CCECAdapterMessage *output);
+ virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, cec_abort_reason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE);
virtual void SetCurrentButton(cec_user_control_code iButtonCode);
virtual void AddCommand(const cec_command &command);
+ virtual void AddKey(cec_keypress &key);
virtual void AddKey(void);
virtual void AddLog(cec_log_level level, const CStdString &strMessage);
- virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, ECecAbortReason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE);
+ virtual bool ChangeDeviceType(cec_device_type from, cec_device_type to);
+ virtual bool FindLogicalAddresses(void);
+ virtual bool SetAckMask(uint16_t iMask);
+
+ virtual bool StartBootloader(void);
+ virtual bool PingAdapter(void);
CCECBusDevice *m_busDevices[16];
+ CMutex m_transmitMutex;
+
+ private:
+ void ReplaceHandlers(void);
+ void ScanCECBus(void);
+ bool PhysicalAddressInUse(uint16_t iPhysicalAddress);
+ bool TryLogicalAddress(cec_logical_address address);
+ bool FindLogicalAddressRecordingDevice(void);
+ bool FindLogicalAddressTuner(void);
+ bool FindLogicalAddressPlaybackDevice(void);
+ bool FindLogicalAddressAudioSystem(void);
- private:
void LogOutput(const cec_command &data);
- bool WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout = 1000);
+ bool WaitForTransmitSucceeded(CCECAdapterMessage *message);
bool ParseMessage(const CCECAdapterMessage &msg);
void ParseCommand(cec_command &command);
- cec_command m_currentframe;
- cec_logical_address m_iLogicalAddress;
- std::string m_strDeviceName;
- CMutex m_mutex;
- CCondition m_startCondition;
- CAdapterCommunication *m_communication;
- CLibCEC *m_controller;
- bool m_bMonitor;
- bool m_bLogicalAddressSet;
+ bool m_bStarted;
+ bool m_bInitialised;
+ uint8_t m_iHDMIPort;
+ cec_logical_address m_iBaseDevice;
+ cec_command m_currentframe;
+ cec_logical_addresses m_logicalAddresses;
+ cec_logical_address m_lastInitiator;
+ std::string m_strDeviceName;
+ cec_device_type_list m_types;
+ CMutex m_mutex;
+ CCondition m_startCondition;
+ CAdapterCommunication* m_communication;
+ CLibCEC* m_controller;
+ bool m_bMonitor;
+ CecBuffer<cec_command> m_commandBuffer;
+ cec_keypress m_previousKey;
+ CThread * m_busScan;
+ uint8_t m_iLineTimeout;
+ uint8_t m_iStandardLineTimeout;
+ uint8_t m_iRetryLineTimeout;
+ uint64_t m_iLastTransmission;
+ };
+
+ class CCECBusScan : public CThread
+ {
+ public:
+ CCECBusScan(CCECProcessor *processor) { m_processor = processor; }
+ virtual ~CCECBusScan(void) { StopThread(true); }
+ virtual void *Process(void);
+
+ private:
+ void WaitUntilIdle(void);
+
+ CCECProcessor *m_processor;
};
};