Commit | Line | Data |
---|---|---|
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 | |
39 | namespace 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 | 58 | virtual bool ReplaceHandler(bool bActivateSource = true); |
91ef4e2d LOK |
59 | |
60 | // TODO use something smarter than this | |
61 | /*! | |
62 | * @brief Get the command handler for this device. Call MarkHandlerReady() when done with it. | |
63 | * @return The current handler. | |
64 | */ | |
65 | virtual CCECCommandHandler * GetHandler(void); | |
66 | ||
67 | /*! | |
68 | * @brief To be called after GetHandler(), when no longer using it. | |
69 | */ | |
70 | virtual void MarkHandlerReady(void) { MarkReady(); } | |
71 | ||
004b8382 LOK |
72 | virtual CCECProcessor * GetProcessor(void) const { return m_processor; } |
73 | virtual uint64_t GetLastActive(void) const { return m_iLastActive; } | |
74 | virtual cec_device_type GetType(void) const { return m_type; } | |
f8ae3295 LOK |
75 | virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; } |
76 | virtual const char* GetLogicalAddressName(void) const; | |
004b8382 LOK |
77 | virtual bool IsPresent(void); |
78 | virtual bool IsHandledByLibCEC(void); | |
79 | ||
80 | virtual bool HandleCommand(const cec_command &command); | |
33dd87a9 | 81 | virtual bool IsUnsupportedFeature(cec_opcode opcode); |
4d738fe3 | 82 | virtual void SetUnsupportedFeature(cec_opcode opcode); |
004b8382 LOK |
83 | |
84 | virtual bool TransmitKeypress(const cec_logical_address initiator, cec_user_control_code key, bool bWait = true); | |
85 | virtual bool TransmitKeyRelease(const cec_logical_address initiator, bool bWait = true); | |
86 | ||
87 | virtual cec_version GetCecVersion(const cec_logical_address initiator, bool bUpdate = false); | |
88 | virtual void SetCecVersion(const cec_version newVersion); | |
89 | virtual bool RequestCecVersion(const cec_logical_address initiator, bool bWaitForResponse = true); | |
90 | virtual bool TransmitCECVersion(const cec_logical_address destination); | |
91 | ||
92 | virtual cec_menu_language & GetMenuLanguage(const cec_logical_address initiator, bool bUpdate = false); | |
93 | virtual void SetMenuLanguage(const char *strLanguage); | |
94 | virtual void SetMenuLanguage(const cec_menu_language &menuLanguage); | |
95 | virtual bool RequestMenuLanguage(const cec_logical_address initiator, bool bWaitForResponse = true); | |
96 | virtual bool TransmitSetMenuLanguage(const cec_logical_address destination); | |
97 | ||
98 | virtual bool TransmitOSDString(const cec_logical_address destination, cec_display_control duration, const char *strMessage); | |
99 | ||
c0152c09 | 100 | virtual CStdString GetCurrentOSDName(void); |
004b8382 LOK |
101 | virtual CStdString GetOSDName(const cec_logical_address initiator, bool bUpdate = false); |
102 | virtual void SetOSDName(CStdString strName); | |
103 | virtual bool RequestOSDName(const cec_logical_address source, bool bWaitForResponse = true); | |
104 | virtual bool TransmitOSDName(const cec_logical_address destination); | |
105 | ||
106 | virtual uint16_t GetCurrentPhysicalAddress(void); | |
107 | virtual bool HasValidPhysicalAddress(void); | |
108 | virtual uint16_t GetPhysicalAddress(const cec_logical_address initiator, bool bSuppressUpdate = false); | |
109 | virtual bool SetPhysicalAddress(uint16_t iNewAddress); | |
110 | virtual bool RequestPhysicalAddress(const cec_logical_address initiator, bool bWaitForResponse = true); | |
111 | virtual bool TransmitPhysicalAddress(void); | |
112 | ||
113 | virtual cec_power_status GetCurrentPowerStatus(void); | |
114 | virtual cec_power_status GetPowerStatus(const cec_logical_address initiator, bool bUpdate = false); | |
115 | virtual void SetPowerStatus(const cec_power_status powerStatus); | |
116 | virtual bool RequestPowerStatus(const cec_logical_address initiator, bool bWaitForResponse = true); | |
117 | virtual bool TransmitPowerState(const cec_logical_address destination); | |
118 | ||
119 | virtual cec_vendor_id GetCurrentVendorId(void); | |
120 | virtual cec_vendor_id GetVendorId(const cec_logical_address initiator, bool bUpdate = false); | |
121 | virtual const char * GetVendorName(const cec_logical_address initiator, bool bUpdate = false); | |
122 | virtual bool SetVendorId(uint64_t iVendorId); | |
123 | virtual bool RequestVendorId(const cec_logical_address initiator, bool bWaitForResponse = true); | |
124 | virtual bool TransmitVendorID(const cec_logical_address destination, bool bSendAbort = true); | |
125 | ||
126 | virtual cec_bus_device_status GetCurrentStatus(void) { return GetStatus(false, true); } | |
127 | virtual cec_bus_device_status GetStatus(bool bForcePoll = false, bool bSuppressPoll = false); | |
128 | virtual void SetDeviceStatus(const cec_bus_device_status newStatus); | |
129 | virtual void ResetDeviceStatus(void); | |
130 | virtual bool TransmitPoll(const cec_logical_address destination); | |
131 | virtual void HandlePoll(const cec_logical_address destination); | |
132 | virtual void HandlePollFrom(const cec_logical_address initiator); | |
0cfdeb5a | 133 | virtual bool HandleReceiveFailed(void); |
e9de9629 | 134 | |
004b8382 LOK |
135 | virtual cec_menu_state GetMenuState(const cec_logical_address initiator); |
136 | virtual void SetMenuState(const cec_menu_state state); | |
137 | virtual bool TransmitMenuState(const cec_logical_address destination); | |
138 | ||
139 | virtual bool ActivateSource(void); | |
140 | virtual bool IsActiveSource(void) const { return m_bActiveSource; } | |
141 | virtual bool RequestActiveSource(bool bWaitForResponse = true); | |
142 | virtual void MarkAsActiveSource(void); | |
143 | virtual void MarkAsInactiveSource(void); | |
144 | virtual bool TransmitActiveSource(void); | |
145 | virtual bool TransmitImageViewOn(void); | |
146 | virtual bool TransmitInactiveSource(void); | |
147 | virtual bool TransmitPendingActiveSourceCommands(void); | |
148 | virtual void SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress = CEC_INVALID_PHYSICAL_ADDRESS); | |
149 | ||
150 | virtual bool PowerOn(const cec_logical_address initiator); | |
151 | virtual bool Standby(const cec_logical_address initiator); | |
152 | ||
153 | virtual bool TryLogicalAddress(void); | |
154 | ||
155 | CCECClient * GetClient(void); | |
156 | ||
157 | CCECAudioSystem * AsAudioSystem(void); | |
158 | static CCECAudioSystem * AsAudioSystem(CCECBusDevice *device); | |
159 | CCECPlaybackDevice * AsPlaybackDevice(void); | |
160 | static CCECPlaybackDevice * AsPlaybackDevice(CCECBusDevice *device); | |
161 | CCECRecordingDevice * AsRecordingDevice(void); | |
162 | static CCECRecordingDevice * AsRecordingDevice(CCECBusDevice *device); | |
163 | CCECTuner * AsTuner(void); | |
164 | static CCECTuner * AsTuner(CCECBusDevice *device); | |
165 | CCECTV * AsTV(void); | |
166 | static CCECTV * AsTV(CCECBusDevice *device); | |
5734016c | 167 | |
e9de9629 | 168 | protected: |
004b8382 | 169 | void CheckVendorIdRequested(const cec_logical_address source); |
1344fd1a LOK |
170 | void MarkBusy(void); |
171 | void MarkReady(void); | |
b64db02e | 172 | |
9fd73dd4 LOK |
173 | bool NeedsPoll(void); |
174 | ||
f8ae3295 LOK |
175 | cec_device_type m_type; |
176 | CStdString m_strDeviceName; | |
177 | uint16_t m_iPhysicalAddress; | |
178 | uint16_t m_iStreamPath; | |
179 | cec_logical_address m_iLogicalAddress; | |
180 | cec_power_status m_powerStatus; | |
181 | cec_menu_language m_menuLanguage; | |
182 | CCECProcessor * m_processor; | |
183 | CCECCommandHandler * m_handler; | |
184 | cec_vendor_id m_vendor; | |
b64db02e | 185 | bool m_bReplaceHandler; |
f8ae3295 LOK |
186 | cec_menu_state m_menuState; |
187 | bool m_bActiveSource; | |
f8ae3295 | 188 | uint64_t m_iLastActive; |
2efa39b7 | 189 | uint64_t m_iLastPowerStateUpdate; |
f8ae3295 LOK |
190 | cec_version m_cecVersion; |
191 | cec_bus_device_status m_deviceStatus; | |
4d738fe3 | 192 | std::set<cec_opcode> m_unsupportedFeatures; |
f00ff009 LOK |
193 | PLATFORM::CMutex m_mutex; |
194 | PLATFORM::CMutex m_handlerMutex; | |
67b9d205 | 195 | PLATFORM::CEvent m_replacing; |
1344fd1a | 196 | unsigned m_iHandlerUseCount; |
ef583662 | 197 | bool m_bAwaitingReceiveFailed; |
ebb6ddb3 | 198 | bool m_bVendorIdRequested; |
e9de9629 LOK |
199 | }; |
200 | }; |