X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECParser.h;h=c70cc481f0a4aa79c464943d5f92f6f0de417c0b;hb=60fa45780df645538897eb092a736498105ee8c2;hp=6f0caa4ff3c03da3ea498d4a11a6ebdea36396cc;hpb=df7339c665f732faedee7c1d3cde816cc41e3302;p=deb_libcec.git diff --git a/src/lib/CECParser.h b/src/lib/CECParser.h index 6f0caa4..c70cc48 100644 --- a/src/lib/CECParser.h +++ b/src/lib/CECParser.h @@ -35,13 +35,16 @@ #include #include "../../include/CECExports.h" #include "../../include/CECTypes.h" +#include "util/threads.h" #include "util/buffer.h" class CSerialPort; namespace CEC { - class CCECParser : public ICECDevice + class CCommunication; + + class CCECParser : public ICECDevice, public CThread { public: /*! @@ -52,27 +55,30 @@ namespace CEC virtual ~CCECParser(void); virtual bool Open(const char *strPort, int iTimeout = 10000); + virtual void Close(void); virtual int FindDevices(std::vector &deviceList, const char *strDevicePath = NULL); virtual bool Ping(void); virtual bool StartBootloader(void); virtual bool PowerOffDevices(cec_logical_address address = CECDEVICE_BROADCAST); - virtual bool PowerOnDevices(cec_logical_address address = CECDEVICE_BROADCAST); + virtual bool PowerOnDevices(cec_logical_address address = CECDEVICE_TV); virtual bool StandbyDevices(cec_logical_address address = CECDEVICE_BROADCAST); virtual bool SetActiveView(void); virtual bool SetInactiveView(void); virtual bool GetNextLogMessage(cec_log_message *message); virtual bool GetNextKeypress(cec_keypress *key); - virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000); - virtual bool SetAckMask(cec_logical_address ackmask); + virtual bool GetNextCommand(cec_command *command); + virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true); + virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress); + virtual bool SetAckMask(uint16_t iMask); virtual int GetMinVersion(void); virtual int GetLibVersion(void); //@} - static void *ThreadHandler(CCECParser *parser); - bool Process(void); + void *Process(void); + void AddLog(cec_log_level level, const std::string &strMessage); protected: - virtual bool TransmitFormatted(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 2000); - virtual void TransmitAbort(cec_logical_address address, ECecOpcode opcode, ECecAbortReason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE); + virtual bool TransmitFormatted(const cec_frame &data, bool bWaitForAck = true); + virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, ECecAbortReason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE); virtual void ReportCECVersion(cec_logical_address address = CECDEVICE_TV); virtual void ReportPowerState(cec_logical_address address = CECDEVICE_TV, bool bOn = true); virtual void ReportMenuState(cec_logical_address address = CECDEVICE_TV, bool bActive = true); @@ -84,12 +90,12 @@ namespace CEC private: void AddKey(void); - void AddLog(cec_log_level level, const std::string &strMessage); - bool WaitForAck(int64_t iTimeout = (int64_t) 1000); + void AddCommand(cec_logical_address source, cec_logical_address destination, cec_opcode opcode, cec_frame *parameters); + bool WaitForAck(int iTimeout = 1000); bool ReadFromDevice(int iTimeout); void ProcessMessages(void); bool GetMessage(cec_frame &msg, bool bFromBuffer = true); - void ParseMessage(cec_frame &msg); + bool ParseMessage(cec_frame &msg); void ParseCurrentFrame(void); void AddData(uint8_t* data, int len); @@ -97,10 +103,6 @@ namespace CEC void CheckKeypressTimeout(int64_t now); - uint8_t* m_inbuf; - int m_iInbufSize; - int m_iInbufUsed; - CSerialPort * m_serialport; cec_frame m_currentframe; cec_user_control_code m_iCurrentButton; int64_t m_buttontime; @@ -109,9 +111,9 @@ namespace CEC CecBuffer m_frameBuffer; CecBuffer m_logBuffer; CecBuffer m_keyBuffer; + CecBuffer m_commandBuffer; std::string m_strDeviceName; - pthread_t m_thread; CMutex m_mutex; - bool m_bRunning; + CCommunication *m_communication; }; };