X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FLibCEC.h;h=0ef3e832d3d318218eda23c4beeccceefd40947e;hb=c0152c0940ee81c79150dbafafd6621f576c3ccb;hp=e45980075b51cdee4d6ce32b9e2a3acaa0bf367b;hpb=a8559e01ffc0239556097fbbe99f88f663f3fd6f;p=deb_libcec.git diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index e459800..0ef3e83 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -39,75 +39,76 @@ namespace CEC { class CAdapterCommunication; class CCECProcessor; + class CCECClient; class CLibCEC : public ICECAdapter { public: + CLibCEC(const char *strDeviceName, cec_device_type_list types, uint16_t iPhysicalAddress = 0); + CLibCEC(libcec_configuration *configuration); + virtual ~CLibCEC(void); + /*! * ICECAdapter implementation */ //@{ - CLibCEC(const char *strDeviceName, cec_device_type_list types, uint16_t iPhysicalAddress = 0); - CLibCEC(libcec_configuration *configuration); - virtual ~CLibCEC(void); + bool Open(const char *strPort, uint32_t iTimeout = CEC_DEFAULT_CONNECT_TIMEOUT); + void Close(void); + bool EnableCallbacks(void *cbParam, ICECCallbacks *callbacks); + int8_t FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL); + bool PingAdapter(void); + bool StartBootloader(void); + + int8_t GetMinLibVersion(void) const { return CEC_MIN_LIB_VERSION; }; + int8_t GetLibVersionMajor(void) const { return CEC_LIB_VERSION_MAJOR; }; + int8_t GetLibVersionMinor(void) const { return CEC_LIB_VERSION_MINOR; }; + + bool GetNextLogMessage(cec_log_message *message); + bool GetNextKeypress(cec_keypress *key); + bool GetNextCommand(cec_command *command); - virtual bool Open(const char *strPort, uint32_t iTimeout = 10000); - virtual void Close(void); - virtual bool EnableCallbacks(void *cbParam, ICECCallbacks *callbacks); - virtual int8_t FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath = NULL); - virtual bool PingAdapter(void); - virtual bool StartBootloader(void); - - virtual int8_t GetMinLibVersion(void) const { return CEC_MIN_LIB_VERSION; }; - virtual int8_t GetLibVersionMajor(void) const { return CEC_LIB_VERSION_MAJOR; }; - virtual int8_t GetLibVersionMinor(void) const { return CEC_LIB_VERSION_MINOR; }; - - virtual bool GetNextLogMessage(cec_log_message *message); - virtual bool GetNextKeypress(cec_keypress *key); - virtual bool GetNextCommand(cec_command *command); - - virtual bool Transmit(const cec_command &data); - virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1); - virtual bool SetPhysicalAddress(uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS); - - 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 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); - 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 IsActiveDevice(cec_logical_address iAddress); - virtual bool IsActiveDeviceType(cec_device_type type); - virtual bool SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort = CEC_DEFAULT_HDMI_PORT); - virtual uint8_t VolumeUp(bool bSendRelease = true); - virtual uint8_t VolumeDown(bool bSendRelease = true); - virtual uint8_t MuteAudio(bool bSendRelease = true); - virtual bool SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait = true); - virtual bool SendKeyRelease(cec_logical_address iDestination, bool bWait = true); - virtual cec_osd_name GetDeviceOSDName(cec_logical_address iAddress); - virtual bool EnablePhysicalAddressDetection(void); - virtual cec_logical_address GetActiveSource(void); - virtual bool IsActiveSource(cec_logical_address iAddress); - virtual bool SetStreamPath(cec_logical_address iAddress); - virtual bool SetStreamPath(uint16_t iPhysicalAddress); - virtual cec_logical_addresses GetLogicalAddresses(void); - virtual bool GetCurrentConfiguration(libcec_configuration *configuration); - virtual bool SetConfiguration(const libcec_configuration *configuration); - virtual bool CanPersistConfiguration(void); - virtual bool PersistConfiguration(libcec_configuration *configuration); - virtual void RescanActiveDevices(void); - virtual bool IsLibCECActiveSource(void); + bool Transmit(const cec_command &data); + bool SetLogicalAddress(cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1); + bool SetPhysicalAddress(uint16_t iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS); + + bool PowerOnDevices(cec_logical_address address = CECDEVICE_TV); + bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST); + bool SetActiveView(void); + bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED); + bool SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true); + bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true); + bool SetInactiveView(void); + bool SetMenuState(cec_menu_state state, bool bSendUpdate = true); + bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); + bool SwitchMonitoring(bool bEnable); + cec_version GetDeviceCecVersion(cec_logical_address iAddress); + bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language); + uint64_t GetDeviceVendorId(cec_logical_address iAddress); + uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress); + cec_power_status GetDevicePowerStatus(cec_logical_address iAddress); + bool PollDevice(cec_logical_address iAddress); + cec_logical_addresses GetActiveDevices(void); + bool IsActiveDevice(cec_logical_address iAddress); + bool IsActiveDeviceType(cec_device_type type); + bool SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort = CEC_DEFAULT_HDMI_PORT); + uint8_t VolumeUp(bool bSendRelease = true); + uint8_t VolumeDown(bool bSendRelease = true); + uint8_t MuteAudio(bool bSendRelease = true); + bool SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait = true); + bool SendKeyRelease(cec_logical_address iDestination, bool bWait = true); + cec_osd_name GetDeviceOSDName(cec_logical_address iAddress); + bool EnablePhysicalAddressDetection(void); + cec_logical_address GetActiveSource(void); + bool IsActiveSource(cec_logical_address iAddress); + bool SetStreamPath(cec_logical_address iAddress); + bool SetStreamPath(uint16_t iPhysicalAddress); + cec_logical_addresses GetLogicalAddresses(void); + bool GetCurrentConfiguration(libcec_configuration *configuration); + bool SetConfiguration(const libcec_configuration *configuration); + bool CanPersistConfiguration(void); + bool PersistConfiguration(libcec_configuration *configuration); + void RescanActiveDevices(void); + bool IsLibCECActiveSource(void); const char *ToString(const cec_menu_state state); const char *ToString(const cec_version version); @@ -127,33 +128,40 @@ namespace CEC static uint16_t GetMaskForType(cec_logical_address address); static uint16_t GetMaskForType(cec_device_type type); - virtual bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = 10000); + bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT); //@} - static void AddLog(const cec_log_level level, const char *strFormat, ...); - static void AddKey(void); - static void AddKey(const cec_keypress &key); - static void AddCommand(const cec_command &command); - static void ConfigurationChanged(const libcec_configuration &config); - static void SetCurrentButton(cec_user_control_code iButtonCode); - virtual void CheckKeypressTimeout(void); - static int MenuStateChanged(const cec_menu_state newState); - static void Alert(const libcec_alert type, const libcec_parameter ¶m); + void AddLog(const cec_log_level level, const char *strFormat, ...); + static void AddKey(void) {} //UNUSED + static void AddKey(const cec_keypress &key); //UNUSED + static void AddCommand(const cec_command &command); //UNUSED + static void ConfigurationChanged(const libcec_configuration &config); //UNUSED + static void SetCurrentButton(cec_user_control_code iButtonCode); //UNUSED + void CheckKeypressTimeout(void); + void Alert(const libcec_alert type, const libcec_parameter ¶m); + static CLibCEC *GetInstance(void); //UNUSED + static void SetInstance(CLibCEC *instance); //UNUSED + + static bool IsValidPhysicalAddress(uint16_t iPhysicalAddress); + CCECClient *RegisterClient(libcec_configuration &configuration); + void UnregisterClients(void); + std::vector GetClients(void) { return m_clients; }; - static CLibCEC *GetInstance(void); - static void SetInstance(CLibCEC *instance); + CCECProcessor * m_cec; - CCECProcessor * m_cec; protected: int64_t m_iStartTime; - cec_user_control_code m_iCurrentButton; - int64_t m_buttontime; - PLATFORM::SyncedBuffer m_logBuffer; - PLATFORM::SyncedBuffer m_keyBuffer; - PLATFORM::SyncedBuffer m_commandBuffer; - ICECCallbacks * m_callbacks; - void * m_cbParam; + cec_user_control_code m_iCurrentButton; //UNUSED + int64_t m_buttontime; //UNUSED + PLATFORM::SyncedBuffer m_logBuffer; //UNUSED + PLATFORM::SyncedBuffer m_keyBuffer; //UNUSED + PLATFORM::SyncedBuffer m_commandBuffer; //UNUSED + ICECCallbacks * m_callbacks; //UNUSED + void * m_cbParam; //UNUSED PLATFORM::CMutex m_mutex; - PLATFORM::CMutex m_logMutex; + PLATFORM::CMutex m_logMutex; //UNUSED + + CCECClient * m_client; + std::vector m_clients; }; };