cec: use the local cec.h/cectypes.h instead of system wide when compiling libCEC...
[deb_libcec.git] / src / lib / devices / CECBusDevice.h
index 01b74c2de6b57fac04477f6f2e5569a4d01fdbd9..94810fbc8e5b8af874ce7cca898fd23798eecc9c 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * This file is part of the libCEC(R) library.
  *
- * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
  * libCEC(R) is an original work, containing original code.
  *
  * libCEC(R) is a trademark of Pulse-Eight Limited.
  *     http://www.pulse-eight.net/
  */
 
-#include <cectypes.h>
-#include "../platform/threads.h"
-#include "../util/StdString.h"
+#include "../../../include/cectypes.h"
+#include <set>
+#include "../platform/threads/mutex.h"
+#include "../platform/util/StdString.h"
 
 namespace CEC
 {
   class CCECProcessor;
   class CCECCommandHandler;
+  class CSLCommandHandler;
 
   class CCECBusDevice
   {
     friend class CCECProcessor;
+    friend class CSLCommandHandler;
 
   public:
     CCECBusDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0);
     virtual ~CCECBusDevice(void);
 
-    virtual void AddLog(cec_log_level level, const CStdString &strMessage);
     virtual bool HandleCommand(const cec_command &command);
     virtual bool PowerOn(void);
     virtual bool Standby(void);
 
-    virtual cec_version           GetCecVersion(void);
+    virtual cec_version           GetCecVersion(bool bUpdate = false);
     virtual CCECCommandHandler *  GetHandler(void) const { return m_handler; };
-    virtual uint64_t              GetLastCommandSent(void) const;
     virtual uint64_t              GetLastActive(void) const { return m_iLastActive; }
     virtual cec_logical_address   GetLogicalAddress(void) const { return m_iLogicalAddress; }
     virtual const char*           GetLogicalAddressName(void) const;
-    virtual cec_menu_language &   GetMenuLanguage(void);
+    virtual cec_menu_language &   GetMenuLanguage(bool bUpdate = false);
+    virtual cec_menu_state        GetMenuState(void);
     virtual cec_logical_address   GetMyLogicalAddress(void) const;
     virtual uint16_t              GetMyPhysicalAddress(void) const;
-    virtual CStdString            GetOSDName(void);
-    virtual uint16_t              GetPhysicalAddress(bool bRefresh = true);
-    virtual cec_power_status      GetPowerStatus(void);
+    virtual CStdString            GetOSDName(bool bUpdate = false);
+    virtual uint16_t              GetPhysicalAddress(bool bUpdate = false);
+    virtual cec_power_status      GetPowerStatus(bool bUpdate = false);
     virtual CCECProcessor *       GetProcessor(void) const { return m_processor; }
     virtual cec_device_type       GetType(void) const { return m_type; }
-    virtual cec_vendor_id         GetVendorId(void);
-    virtual const char *          GetVendorName(void);
+    virtual cec_vendor_id         GetVendorId(bool bUpdate = false);
+    virtual const char *          GetVendorName(bool bUpdate = false);
     virtual bool                  MyLogicalAddressContains(cec_logical_address address) const;
     virtual cec_bus_device_status GetStatus(bool bForcePoll = false);
+    virtual bool                  IsActiveSource(void) const { return m_bActiveSource; }
+    virtual bool                  IsUnsupportedFeature(cec_opcode opcode) const;
+    virtual void                  SetUnsupportedFeature(cec_opcode opcode);
+    virtual void                  HandlePoll(cec_logical_address initiator);
+    virtual bool                  HandleReceiveFailed(void);
 
-    bool RequestCecVersion(void);
-    bool RequestMenuLanguage(void);
-    bool RequestPowerStatus(void);
-    bool RequestVendorId(void);
-    bool RequestPhysicalAddress(void);
-    bool RequestOSDName(void);
-
-    virtual void SetInactiveDevice(void);
-    virtual void SetActiveDevice(void);
+    virtual void SetInactiveSource(void);
+    virtual void SetActiveSource(void);
     virtual bool TryLogicalAddress(void);
+    virtual bool ActivateSource(void);
 
     virtual void SetDeviceStatus(const cec_bus_device_status newStatus);
     virtual void SetPhysicalAddress(uint16_t iNewAddress);
@@ -90,7 +91,7 @@ namespace CEC
     virtual void SetMenuLanguage(const cec_menu_language &menuLanguage);
     virtual void SetOSDName(CStdString strName);
     virtual void SetMenuState(const cec_menu_state state);
-    virtual void SetVendorId(uint64_t iVendorId);
+    virtual bool SetVendorId(uint64_t iVendorId);
     virtual void SetPowerStatus(const cec_power_status powerStatus);
 
     virtual bool TransmitActiveSource(void);
@@ -102,11 +103,20 @@ namespace CEC
     virtual bool TransmitPhysicalAddress(void);
     virtual bool TransmitPowerState(cec_logical_address dest);
     virtual bool TransmitPoll(cec_logical_address dest);
-    virtual bool TransmitVendorID(cec_logical_address dest);
-    virtual bool SendKeypress(cec_user_control_code key, bool bWait = true);
-    virtual bool SendKeyRelease(bool bWait = true);
+    virtual bool TransmitVendorID(cec_logical_address dest, bool bSendAbort = true);
+    virtual bool TransmitKeypress(cec_user_control_code key, bool bWait = true);
+    virtual bool TransmitKeyRelease(bool bWait = true);
 
   protected:
+    bool ReplaceHandler(bool bInitHandler = true);
+
+    bool RequestCecVersion(void);
+    bool RequestMenuLanguage(void);
+    bool RequestPowerStatus(void);
+    bool RequestVendorId(void);
+    bool RequestPhysicalAddress(void);
+    bool RequestOSDName(void);
+
     bool NeedsPoll(void);
 
     cec_device_type       m_type;
@@ -119,15 +129,16 @@ namespace CEC
     CCECProcessor      *  m_processor;
     CCECCommandHandler *  m_handler;
     cec_vendor_id         m_vendor;
+    bool                  m_bReplaceHandler;
     cec_menu_state        m_menuState;
     bool                  m_bActiveSource;
-    uint64_t              m_iLastCommandSent;
     uint64_t              m_iLastActive;
+    uint64_t              m_iLastPowerStateUpdate;
     cec_version           m_cecVersion;
     cec_bus_device_status m_deviceStatus;
-    CMutex                m_transmitMutex;
-    CMutex                m_writeMutex;
-    CMutex                m_mutex;
-    CCondition            m_condition;
+    std::set<cec_opcode>  m_unsupportedFeatures;
+    PLATFORM::CMutex      m_mutex;
+    PLATFORM::CMutex      m_handlerMutex;
+    bool                  m_bAwaitingReceiveFailed;
   };
 };