win32: sync project files and fixed compilation warnings.
[deb_libcec.git] / src / lib / devices / CECBusDevice.h
CommitLineData
e9de9629
LOK
1#pragma once
2/*
3 * This file is part of the libCEC(R) library.
4 *
b492c10e 5 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
e9de9629
LOK
6 * libCEC(R) is an original work, containing original code.
7 *
8 * libCEC(R) is a trademark of Pulse-Eight Limited.
9 *
10 * This program is dual-licensed; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 *
25 * Alternatively, you can license this library under a commercial license,
26 * please contact Pulse-Eight Licensing for more information.
27 *
28 * For more information contact:
29 * Pulse-Eight Licensing <license@pulse-eight.com>
30 * http://www.pulse-eight.com/
31 * http://www.pulse-eight.net/
32 */
33
4c9b9776 34#include "../../../include/cectypes.h"
4d738fe3 35#include <set>
ba65909d
LOK
36#include "../platform/threads/mutex.h"
37#include "../platform/util/StdString.h"
e9de9629
LOK
38
39namespace CEC
40{
004b8382 41 class CCECClient;
e9de9629 42 class CCECProcessor;
1b5cc4a2 43 class CCECCommandHandler;
004b8382
LOK
44 class CCECAudioSystem;
45 class CCECPlaybackDevice;
46 class CCECRecordingDevice;
47 class CCECTuner;
48 class CCECTV;
e9de9629
LOK
49
50 class CCECBusDevice
51 {
787a3cb8
LOK
52 friend class CCECProcessor;
53
e9de9629 54 public:
d2d1660c 55 CCECBusDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = CEC_INVALID_PHYSICAL_ADDRESS);
e9de9629
LOK
56 virtual ~CCECBusDevice(void);
57
004b8382
LOK
58 virtual bool ReplaceHandler(bool bActivateSource = true);
59 virtual CCECCommandHandler * GetHandler(void) const { return m_handler; };
60 virtual CCECProcessor * GetProcessor(void) const { return m_processor; }
61 virtual uint64_t GetLastActive(void) const { return m_iLastActive; }
62 virtual cec_device_type GetType(void) const { return m_type; }
f8ae3295
LOK
63 virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; }
64 virtual const char* GetLogicalAddressName(void) const;
004b8382
LOK
65 virtual bool IsPresent(void);
66 virtual bool IsHandledByLibCEC(void);
67
68 virtual bool HandleCommand(const cec_command &command);
33dd87a9 69 virtual bool IsUnsupportedFeature(cec_opcode opcode);
4d738fe3 70 virtual void SetUnsupportedFeature(cec_opcode opcode);
004b8382
LOK
71
72 virtual bool TransmitKeypress(const cec_logical_address initiator, cec_user_control_code key, bool bWait = true);
73 virtual bool TransmitKeyRelease(const cec_logical_address initiator, bool bWait = true);
74
75 virtual cec_version GetCecVersion(const cec_logical_address initiator, bool bUpdate = false);
76 virtual void SetCecVersion(const cec_version newVersion);
77 virtual bool RequestCecVersion(const cec_logical_address initiator, bool bWaitForResponse = true);
78 virtual bool TransmitCECVersion(const cec_logical_address destination);
79
80 virtual cec_menu_language & GetMenuLanguage(const cec_logical_address initiator, bool bUpdate = false);
81 virtual void SetMenuLanguage(const char *strLanguage);
82 virtual void SetMenuLanguage(const cec_menu_language &menuLanguage);
83 virtual bool RequestMenuLanguage(const cec_logical_address initiator, bool bWaitForResponse = true);
84 virtual bool TransmitSetMenuLanguage(const cec_logical_address destination);
85
86 virtual bool TransmitOSDString(const cec_logical_address destination, cec_display_control duration, const char *strMessage);
87
88 virtual CStdString GetOSDName(const cec_logical_address initiator, bool bUpdate = false);
89 virtual void SetOSDName(CStdString strName);
90 virtual bool RequestOSDName(const cec_logical_address source, bool bWaitForResponse = true);
91 virtual bool TransmitOSDName(const cec_logical_address destination);
92
93 virtual uint16_t GetCurrentPhysicalAddress(void);
94 virtual bool HasValidPhysicalAddress(void);
95 virtual uint16_t GetPhysicalAddress(const cec_logical_address initiator, bool bSuppressUpdate = false);
96 virtual bool SetPhysicalAddress(uint16_t iNewAddress);
97 virtual bool RequestPhysicalAddress(const cec_logical_address initiator, bool bWaitForResponse = true);
98 virtual bool TransmitPhysicalAddress(void);
99
100 virtual cec_power_status GetCurrentPowerStatus(void);
101 virtual cec_power_status GetPowerStatus(const cec_logical_address initiator, bool bUpdate = false);
102 virtual void SetPowerStatus(const cec_power_status powerStatus);
103 virtual bool RequestPowerStatus(const cec_logical_address initiator, bool bWaitForResponse = true);
104 virtual bool TransmitPowerState(const cec_logical_address destination);
105
106 virtual cec_vendor_id GetCurrentVendorId(void);
107 virtual cec_vendor_id GetVendorId(const cec_logical_address initiator, bool bUpdate = false);
108 virtual const char * GetVendorName(const cec_logical_address initiator, bool bUpdate = false);
109 virtual bool SetVendorId(uint64_t iVendorId);
110 virtual bool RequestVendorId(const cec_logical_address initiator, bool bWaitForResponse = true);
111 virtual bool TransmitVendorID(const cec_logical_address destination, bool bSendAbort = true);
112
113 virtual cec_bus_device_status GetCurrentStatus(void) { return GetStatus(false, true); }
114 virtual cec_bus_device_status GetStatus(bool bForcePoll = false, bool bSuppressPoll = false);
115 virtual void SetDeviceStatus(const cec_bus_device_status newStatus);
116 virtual void ResetDeviceStatus(void);
117 virtual bool TransmitPoll(const cec_logical_address destination);
118 virtual void HandlePoll(const cec_logical_address destination);
119 virtual void HandlePollFrom(const cec_logical_address initiator);
0cfdeb5a 120 virtual bool HandleReceiveFailed(void);
e9de9629 121
004b8382
LOK
122 virtual cec_menu_state GetMenuState(const cec_logical_address initiator);
123 virtual void SetMenuState(const cec_menu_state state);
124 virtual bool TransmitMenuState(const cec_logical_address destination);
125
126 virtual bool ActivateSource(void);
127 virtual bool IsActiveSource(void) const { return m_bActiveSource; }
128 virtual bool RequestActiveSource(bool bWaitForResponse = true);
129 virtual void MarkAsActiveSource(void);
130 virtual void MarkAsInactiveSource(void);
131 virtual bool TransmitActiveSource(void);
132 virtual bool TransmitImageViewOn(void);
133 virtual bool TransmitInactiveSource(void);
134 virtual bool TransmitPendingActiveSourceCommands(void);
135 virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = CEC_INVALID_PHYSICAL_ADDRESS);
136
137 virtual bool PowerOn(const cec_logical_address initiator);
138 virtual bool Standby(const cec_logical_address initiator);
139
140 virtual bool TryLogicalAddress(void);
141
142 CCECClient * GetClient(void);
143
144 CCECAudioSystem * AsAudioSystem(void);
145 static CCECAudioSystem * AsAudioSystem(CCECBusDevice *device);
146 CCECPlaybackDevice * AsPlaybackDevice(void);
147 static CCECPlaybackDevice * AsPlaybackDevice(CCECBusDevice *device);
148 CCECRecordingDevice * AsRecordingDevice(void);
149 static CCECRecordingDevice * AsRecordingDevice(CCECBusDevice *device);
150 CCECTuner * AsTuner(void);
151 static CCECTuner * AsTuner(CCECBusDevice *device);
152 CCECTV * AsTV(void);
153 static CCECTV * AsTV(CCECBusDevice *device);
5734016c 154
e9de9629 155 protected:
004b8382 156 void CheckVendorIdRequested(const cec_logical_address source);
1344fd1a
LOK
157 void MarkBusy(void);
158 void MarkReady(void);
b64db02e 159
9fd73dd4
LOK
160 bool NeedsPoll(void);
161
f8ae3295
LOK
162 cec_device_type m_type;
163 CStdString m_strDeviceName;
164 uint16_t m_iPhysicalAddress;
165 uint16_t m_iStreamPath;
166 cec_logical_address m_iLogicalAddress;
167 cec_power_status m_powerStatus;
168 cec_menu_language m_menuLanguage;
169 CCECProcessor * m_processor;
170 CCECCommandHandler * m_handler;
171 cec_vendor_id m_vendor;
b64db02e 172 bool m_bReplaceHandler;
f8ae3295
LOK
173 cec_menu_state m_menuState;
174 bool m_bActiveSource;
f8ae3295 175 uint64_t m_iLastActive;
2efa39b7 176 uint64_t m_iLastPowerStateUpdate;
f8ae3295
LOK
177 cec_version m_cecVersion;
178 cec_bus_device_status m_deviceStatus;
4d738fe3 179 std::set<cec_opcode> m_unsupportedFeatures;
f00ff009
LOK
180 PLATFORM::CMutex m_mutex;
181 PLATFORM::CMutex m_handlerMutex;
67b9d205 182 PLATFORM::CEvent m_replacing;
1344fd1a 183 unsigned m_iHandlerUseCount;
ef583662 184 bool m_bAwaitingReceiveFailed;
ebb6ddb3 185 bool m_bVendorIdRequested;
e9de9629
LOK
186 };
187};