X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FAdapterCommunication.h;h=39f0c9801deb54c304bd58558209b0c3020138bc;hb=8f69060da89a711b1a45bc7d5958a3436b71ac4a;hp=db0fbe6cc4e72f1cc3c4a915ddd3a37e111ee50e;hpb=b2f56d355ff33088445ad8a7f159c1d51d4d48dd;p=deb_libcec.git diff --git a/src/lib/adapter/AdapterCommunication.h b/src/lib/adapter/AdapterCommunication.h index db0fbe6..39f0c98 100644 --- a/src/lib/adapter/AdapterCommunication.h +++ b/src/lib/adapter/AdapterCommunication.h @@ -2,7 +2,7 @@ /* * This file is part of the libCEC(R) library. * - * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved. * libCEC(R) is an original work, containing original code. * * libCEC(R) is a trademark of Pulse-Eight Limited. @@ -31,11 +31,23 @@ * http://www.pulse-eight.net/ */ -#include "../platform/util/StdString.h" -#include "USBCECAdapterMessage.h" +#include namespace CEC { + class CLibCEC; + + typedef enum cec_adapter_message_state + { + ADAPTER_MESSAGE_STATE_UNKNOWN = 0, /**< the initial state */ + ADAPTER_MESSAGE_STATE_WAITING_TO_BE_SENT, /**< waiting in the send queue of the adapter, or timed out */ + ADAPTER_MESSAGE_STATE_SENT, /**< sent and waiting on an ACK */ + ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED, /**< sent, but failed to ACK */ + ADAPTER_MESSAGE_STATE_SENT_ACKED, /**< sent, and ACK received */ + ADAPTER_MESSAGE_STATE_INCOMING, /**< received from another device */ + ADAPTER_MESSAGE_STATE_ERROR /**< an error occured */ + } cec_adapter_message_state; + class IAdapterCommunicationCallback { public: @@ -62,6 +74,20 @@ namespace CEC * @return True when this is an error, false otherwise. */ virtual bool HandleReceiveFailed(cec_logical_address initiator) = 0; + + /*! + * @brief Callback method for IAdapterCommunication, called when a logical address that libCEC uses was taken by another device. + * @param oldAddress The logical address that was taken by another device. + */ + virtual void HandleLogicalAddressLost(cec_logical_address oldAddress) = 0; + + /*! + * @brief Callback method for IAdapterCommunication, called when the physical address changed. + * @param iNewAddress The new physical address. + */ + virtual void HandlePhysicalAddressChanged(uint16_t iNewAddress) = 0; + + virtual CLibCEC *GetLib(void) const = 0; }; class IAdapterCommunication @@ -81,7 +107,7 @@ namespace CEC * @param bStartListening Start a listener thread when true. False to just open a connection, read the device info, and close the connection. * @return True when connected, false otherwise */ - virtual bool Open(uint32_t iTimeoutMs = 10000, bool bSkipChecks = false, bool bStartListening = true) = 0; + virtual bool Open(uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT, bool bSkipChecks = false, bool bStartListening = true) = 0; /*! * @brief Close an open connection @@ -96,16 +122,17 @@ namespace CEC /*! * @return The last error message, or an empty string if there was none */ - virtual CStdString GetError(void) const = 0; + virtual std::string GetError(void) const = 0; /*! * @brief Write a cec_command to the adapter * @param data The command to write * @param bRetry The command can be retried * @param iLineTimeout The line timeout to be used + * @param bIsReply True when this message is a reply, false otherwise * @return The last state of the transmitted command */ - virtual cec_adapter_message_state Write(const cec_command &data, bool &bRetry, uint8_t iLineTimeout = 3) = 0; + virtual cec_adapter_message_state Write(const cec_command &data, bool &bRetry, uint8_t iLineTimeout, bool bIsReply) = 0; /*! * @brief Change the current line timeout on the CEC bus @@ -120,12 +147,8 @@ namespace CEC */ virtual bool StartBootloader(void) = 0; - /*! - * @brief Change the ACK-mask of the device, the mask for logical addresses to which the CEC device should ACK - * @param iMask The new mask - * @return True when set, false otherwise. - */ - virtual bool SetAckMask(uint16_t iMask) = 0; + virtual bool SetLogicalAddresses(const cec_logical_addresses &addresses) = 0; + virtual cec_logical_addresses GetLogicalAddresses(void) = 0; /*! * @brief Check whether the CEC adapter responds @@ -143,6 +166,11 @@ namespace CEC */ virtual uint32_t GetFirmwareBuildDate(void) = 0; + /*! + * @return True when this adapter is using the latest firmware build, or when the latest firmware build for this adapter type is unknown. False otherwise. + */ + virtual bool IsRunningLatestFirmware(void) = 0; + /*! * @return True when the control mode has been set, false otherwise. */ @@ -153,26 +181,59 @@ namespace CEC * @brief The configuration to store. * @return True when the configuration was persisted, false otherwise. */ - virtual bool PersistConfiguration(libcec_configuration *configuration) = 0; + virtual bool PersistConfiguration(const libcec_configuration &configuration) = 0; /*! * @brief Get the persisted configuration from the adapter (if supported) * @param configuration The updated configuration. * @return True when the configuration was updated, false otherwise. */ - virtual bool GetConfiguration(libcec_configuration *configuration) = 0; + virtual bool GetConfiguration(libcec_configuration &configuration) = 0; /*! * @return The name of the port */ - virtual CStdString GetPortName(void) = 0; + virtual std::string GetPortName(void) = 0; /*! * @return The physical address, if the adapter supports this. 0 otherwise. */ virtual uint16_t GetPhysicalAddress(void) = 0; - protected: + /*! + * @return The vendor id for this device + */ + virtual cec_vendor_id GetVendorId(void) = 0; + + /*! + * @brief Checks whether a logical address is supported by the adapter. + * @param address The address to check. + * @return True when supported, false otherwise. + */ + virtual bool SupportsSourceLogicalAddress(const cec_logical_address address) = 0; + + /*! + * @return The type of adapter that this instance is connected to. + */ + virtual cec_adapter_type GetAdapterType(void) = 0; + + /*! + * @return The (virtual) USB vendor id + */ + virtual uint16_t GetAdapterVendorId(void) const = 0; + + /*! + * @return The (virtual) USB product id + */ + virtual uint16_t GetAdapterProductId(void) const = 0; + + /*! + * @brief Marks the adapter as active or inactive source + * @param bSetTo True to mark as active source, false to mark as inactive source + * @param bClientUnregistered True when the client was unregistered, false when the device was explicitly marked as (in)active source + */ + virtual void SetActiveSource(bool bSetTo, bool bClientUnregistered) = 0; + IAdapterCommunicationCallback *m_callback; }; };