#pragma once
#include "env.h"
#if defined(HAVE_LINUX_API)
#include "p8-platform/threads/threads.h"
#include "../AdapterCommunication.h"
namespace CEC
{
class CLinuxCECAdapterCommunication : public IAdapterCommunication, public P8PLATFORM::CThread
{
public:
CLinuxCECAdapterCommunication(IAdapterCommunicationCallback *callback);
virtual ~CLinuxCECAdapterCommunication(void);
bool Open(uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT, bool bSkipChecks = false, bool bStartListening = true) override;
void Close(void) override;
bool IsOpen(void) override;
cec_adapter_message_state Write(const cec_command &data, bool &bRetry, uint8_t iLineTimeout, bool bIsReply) override;
bool SetLineTimeout(uint8_t UNUSED(iTimeout)) override { return true; }
bool StartBootloader(void) override { return false; }
bool SetLogicalAddresses(const cec_logical_addresses &addresses) override;
cec_logical_addresses GetLogicalAddresses(void) const override;
bool PingAdapter(void) override { return true; }
uint16_t GetFirmwareVersion(void) override { return 0; }
uint32_t GetFirmwareBuildDate(void) override { return 0; }
bool IsRunningLatestFirmware(void) override { return true; }
bool SetControlledMode(bool UNUSED(controlled)) override { return true; }
bool SaveConfiguration(const libcec_configuration & UNUSED(configuration)) override { return false; }
bool SetAutoMode(bool UNUSED(automode)) override { return false; }
bool GetConfiguration(libcec_configuration & UNUSED(configuration)) override { return false; }
std::string GetPortName(void) override { return std::string("LINUX"); }
uint16_t GetPhysicalAddress(void) override;
cec_vendor_id GetVendorId(void) override;
bool SupportsSourceLogicalAddress(const cec_logical_address address) override { return address > CECDEVICE_TV && address <= CECDEVICE_BROADCAST; }
cec_adapter_type GetAdapterType(void) override { return ADAPTERTYPE_LINUX; }
uint16_t GetAdapterVendorId(void) const override { return 1; }
uint16_t GetAdapterProductId(void) const override { return 1; }
void SetActiveSource(bool UNUSED(bSetTo), bool UNUSED(bClientUnregistered)) override {}
#if CEC_LIB_VERSION_MAJOR >= 5
bool GetStats(struct cec_adapter_stats* UNUSED(stats)) override { return false; }
#endif
void *Process(void) override;
private:
int m_fd;
};
};
#endif