Commit | Line | Data |
---|---|---|
e9de9629 LOK |
1 | /* |
2 | * This file is part of the libCEC(R) library. | |
3 | * | |
4 | * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. | |
5 | * libCEC(R) is an original work, containing original code. | |
6 | * | |
7 | * libCEC(R) is a trademark of Pulse-Eight Limited. | |
8 | * | |
9 | * This program is dual-licensed; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | * | |
23 | * | |
24 | * Alternatively, you can license this library under a commercial license, | |
25 | * please contact Pulse-Eight Licensing for more information. | |
26 | * | |
27 | * For more information contact: | |
28 | * Pulse-Eight Licensing <license@pulse-eight.com> | |
29 | * http://www.pulse-eight.com/ | |
30 | * http://www.pulse-eight.net/ | |
31 | */ | |
32 | ||
33 | #include "CECBusDevice.h" | |
eafa9d46 LOK |
34 | #include "../CECProcessor.h" |
35 | #include "../implementations/ANCommandHandler.h" | |
36 | #include "../implementations/CECCommandHandler.h" | |
37 | #include "../implementations/SLCommandHandler.h" | |
11621576 | 38 | #include "../implementations/VLCommandHandler.h" |
eafa9d46 | 39 | #include "../platform/timeutils.h" |
e9de9629 LOK |
40 | |
41 | using namespace CEC; | |
42 | ||
43 | CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) : | |
44 | m_iPhysicalAddress(iPhysicalAddress), | |
9dc04b07 | 45 | m_iStreamPath(0), |
e9de9629 | 46 | m_iLogicalAddress(iLogicalAddress), |
e55f3f70 | 47 | m_powerStatus(CEC_POWER_STATUS_UNKNOWN), |
e9de9629 | 48 | m_processor(processor), |
1844f5f7 | 49 | m_bMenuActive(true), |
0ab58650 | 50 | m_iVendorClass(CEC_VENDOR_UNKNOWN), |
6a1c0009 | 51 | m_iLastActive(0), |
5e822b09 | 52 | m_cecVersion(CEC_VERSION_UNKNOWN) |
e9de9629 LOK |
53 | { |
54 | m_handler = new CCECCommandHandler(this); | |
51b2a094 | 55 | |
a3269a0a LOK |
56 | for (unsigned int iPtr = 0; iPtr < 4; iPtr++) |
57 | m_menuLanguage.language[iPtr] = '?'; | |
58 | m_menuLanguage.language[3] = 0; | |
59 | m_menuLanguage.device = iLogicalAddress; | |
1fcf5a3f | 60 | |
51b2a094 LOK |
61 | m_vendor.vendor = CEC_VENDOR_UNKNOWN; |
62 | m_type = CEC_DEVICE_TYPE_RESERVED; | |
63 | m_strDeviceName = "Unknown"; | |
e9de9629 LOK |
64 | } |
65 | ||
66 | CCECBusDevice::~CCECBusDevice(void) | |
67 | { | |
6a1c0009 | 68 | m_condition.Broadcast(); |
e9de9629 LOK |
69 | delete m_handler; |
70 | } | |
71 | ||
93729720 | 72 | void CCECBusDevice::AddLog(cec_log_level level, const CStdString &strMessage) |
e9de9629 | 73 | { |
93729720 | 74 | m_processor->AddLog(level, strMessage); |
e9de9629 LOK |
75 | } |
76 | ||
93729720 | 77 | bool CCECBusDevice::HandleCommand(const cec_command &command) |
f8513317 | 78 | { |
93729720 LOK |
79 | CLockObject lock(&m_mutex); |
80 | m_iLastActive = GetTimeMs(); | |
81 | m_handler->HandleCommand(command); | |
82 | m_condition.Signal(); | |
83 | return true; | |
84 | } | |
85 | ||
86 | void CCECBusDevice::PollVendorId(void) | |
87 | { | |
88 | CLockObject lock(&m_mutex); | |
89 | if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST && | |
90 | m_vendor.vendor == CEC_VENDOR_UNKNOWN && | |
315ff809 LOK |
91 | GetTimeMs() - m_iLastActive > 5000 && |
92 | !m_processor->IsMonitoring()) | |
93729720 | 93 | { |
5e822b09 LOK |
94 | CStdString strLog; |
95 | strLog.Format("<< requesting vendor ID of device %x", m_iLogicalAddress); | |
96 | AddLog(CEC_LOG_NOTICE, strLog); | |
93729720 LOK |
97 | m_iLastActive = GetTimeMs(); |
98 | ||
99 | cec_command command; | |
100 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); | |
101 | if (m_processor->Transmit(command)) | |
102 | m_condition.Wait(&m_mutex, 1000); | |
103 | } | |
104 | } | |
105 | ||
106 | bool CCECBusDevice::PowerOn(void) | |
107 | { | |
108 | CStdString strLog; | |
109 | strLog.Format("<< powering on device with logical address %d", (int8_t)m_iLogicalAddress); | |
110 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); | |
111 | ||
112 | cec_command command; | |
113 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON); | |
114 | ||
115 | return m_processor->Transmit(command); | |
116 | } | |
117 | ||
118 | bool CCECBusDevice::Standby(void) | |
119 | { | |
120 | CStdString strLog; | |
121 | strLog.Format("<< putting device with logical address %d in standby mode", (int8_t)m_iLogicalAddress); | |
122 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); | |
123 | ||
124 | cec_command command; | |
125 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY); | |
126 | ||
127 | return m_processor->Transmit(command); | |
128 | } | |
129 | ||
130 | /** @name Getters */ | |
131 | //@{ | |
d7be392a | 132 | cec_version CCECBusDevice::GetCecVersion(void) |
93729720 | 133 | { |
d7be392a | 134 | if (m_cecVersion == CEC_VERSION_UNKNOWN) |
93729720 | 135 | { |
d7be392a LOK |
136 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
137 | { | |
5e822b09 LOK |
138 | CStdString strLog; |
139 | strLog.Format("<< requesting CEC version of device %x", m_iLogicalAddress); | |
140 | AddLog(CEC_LOG_NOTICE, strLog); | |
d7be392a LOK |
141 | cec_command command; |
142 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION); | |
143 | CLockObject lock(&m_mutex); | |
144 | if (m_processor->Transmit(command)) | |
145 | m_condition.Wait(&m_mutex, 1000); | |
146 | } | |
93729720 LOK |
147 | } |
148 | ||
149 | return m_cecVersion; | |
150 | } | |
151 | ||
d7be392a | 152 | cec_menu_language &CCECBusDevice::GetMenuLanguage(void) |
93729720 | 153 | { |
d7be392a | 154 | if (!strcmp(m_menuLanguage.language, "???")) |
93729720 | 155 | { |
d7be392a LOK |
156 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
157 | { | |
5e822b09 LOK |
158 | CStdString strLog; |
159 | strLog.Format("<< requesting menu language of device %x", m_iLogicalAddress); | |
160 | AddLog(CEC_LOG_NOTICE, strLog); | |
d7be392a LOK |
161 | cec_command command; |
162 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE); | |
163 | CLockObject lock(&m_mutex); | |
164 | if (m_processor->Transmit(command)) | |
165 | m_condition.Wait(&m_mutex, 1000); | |
166 | } | |
93729720 LOK |
167 | } |
168 | ||
169 | return m_menuLanguage; | |
170 | } | |
171 | ||
172 | cec_logical_address CCECBusDevice::GetMyLogicalAddress(void) const | |
173 | { | |
174 | return m_processor->GetLogicalAddress(); | |
f8513317 LOK |
175 | } |
176 | ||
e9de9629 LOK |
177 | uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const |
178 | { | |
179 | return m_processor->GetPhysicalAddress(); | |
180 | } | |
181 | ||
d7be392a | 182 | cec_power_status CCECBusDevice::GetPowerStatus(void) |
e9de9629 | 183 | { |
d7be392a | 184 | if (m_powerStatus == CEC_POWER_STATUS_UNKNOWN) |
93729720 | 185 | { |
d7be392a LOK |
186 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
187 | { | |
5e822b09 LOK |
188 | CStdString strLog; |
189 | strLog.Format("<< requesting power status of device %x", m_iLogicalAddress); | |
190 | AddLog(CEC_LOG_NOTICE, strLog); | |
d7be392a LOK |
191 | cec_command command; |
192 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS); | |
193 | CLockObject lock(&m_mutex); | |
194 | if (m_processor->Transmit(command)) | |
195 | m_condition.Wait(&m_mutex, 1000); | |
196 | } | |
93729720 LOK |
197 | } |
198 | ||
199 | return m_powerStatus; | |
e9de9629 LOK |
200 | } |
201 | ||
93729720 | 202 | const cec_vendor &CCECBusDevice::GetVendor(void) |
a3269a0a | 203 | { |
93729720 | 204 | if (m_vendor.vendor == CEC_VENDOR_UNKNOWN) |
a3269a0a | 205 | { |
d7be392a LOK |
206 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
207 | { | |
5e822b09 LOK |
208 | CStdString strLog; |
209 | strLog.Format("<< requesting vendor ID of device %x", m_iLogicalAddress); | |
210 | AddLog(CEC_LOG_NOTICE, strLog); | |
d7be392a LOK |
211 | cec_command command; |
212 | cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); | |
213 | CLockObject lock(&m_mutex); | |
93729720 | 214 | |
d7be392a LOK |
215 | if (m_processor->Transmit(command)) |
216 | m_condition.Wait(&m_mutex, 1000); | |
217 | } | |
a3269a0a | 218 | } |
93729720 LOK |
219 | |
220 | return m_vendor; | |
221 | } | |
222 | ||
223 | bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const | |
224 | { | |
225 | return m_processor->HasLogicalAddress(address); | |
a3269a0a LOK |
226 | } |
227 | ||
93729720 LOK |
228 | //@} |
229 | ||
230 | /** @name Setters */ | |
231 | //@{ | |
e55f3f70 | 232 | void CCECBusDevice::SetCecVersion(const cec_version newVersion) |
6a1c0009 LOK |
233 | { |
234 | CStdString strLog; | |
235 | m_cecVersion = newVersion; | |
236 | ||
237 | switch (newVersion) | |
238 | { | |
239 | case CEC_VERSION_1_2: | |
5e822b09 | 240 | strLog.Format("device %d: CEC version 1.2", m_iLogicalAddress); |
6a1c0009 LOK |
241 | break; |
242 | case CEC_VERSION_1_2A: | |
5e822b09 | 243 | strLog.Format("device %d: CEC version 1.2a", m_iLogicalAddress); |
6a1c0009 LOK |
244 | break; |
245 | case CEC_VERSION_1_3: | |
5e822b09 | 246 | strLog.Format("device %d: CEC version 1.3", m_iLogicalAddress); |
6a1c0009 LOK |
247 | break; |
248 | case CEC_VERSION_1_3A: | |
5e822b09 | 249 | strLog.Format("device %d: CEC version 1.3a", m_iLogicalAddress); |
6a1c0009 LOK |
250 | break; |
251 | default: | |
5e822b09 | 252 | strLog.Format("device %d: unknown CEC version", m_iLogicalAddress); |
6a1c0009 LOK |
253 | m_cecVersion = CEC_VERSION_UNKNOWN; |
254 | break; | |
255 | } | |
256 | AddLog(CEC_LOG_DEBUG, strLog); | |
257 | } | |
258 | ||
93729720 LOK |
259 | void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language) |
260 | { | |
261 | if (language.device == m_iLogicalAddress) | |
262 | { | |
263 | CStdString strLog; | |
264 | strLog.Format("device %d menu language set to '%s'", m_iLogicalAddress, language.language); | |
265 | m_processor->AddLog(CEC_LOG_DEBUG, strLog); | |
266 | m_menuLanguage = language; | |
267 | } | |
268 | } | |
269 | ||
9dc04b07 | 270 | void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) |
93729720 LOK |
271 | { |
272 | if (iNewAddress > 0) | |
273 | { | |
274 | CStdString strLog; | |
275 | strLog.Format(">> %i changed physical address from %04x to %04x", m_iLogicalAddress, m_iPhysicalAddress, iNewAddress); | |
276 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); | |
277 | ||
278 | m_iPhysicalAddress = iNewAddress; | |
279 | } | |
280 | } | |
281 | ||
9dc04b07 LOK |
282 | void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */) |
283 | { | |
284 | if (iNewAddress > 0) | |
285 | { | |
286 | CStdString strLog; | |
287 | strLog.Format(">> %i stream path from %04x to %04x", m_iLogicalAddress, iOldAddress, iNewAddress); | |
288 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); | |
289 | ||
290 | m_iStreamPath = iNewAddress; | |
291 | } | |
292 | } | |
293 | ||
e55f3f70 LOK |
294 | void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus) |
295 | { | |
b0271d54 LOK |
296 | if (m_powerStatus != powerStatus) |
297 | { | |
298 | CStdString strLog; | |
299 | strLog.Format("device %d power status changed from %2x to %2x", m_iLogicalAddress, m_powerStatus, powerStatus); | |
300 | m_processor->AddLog(CEC_LOG_DEBUG, strLog); | |
301 | m_powerStatus = powerStatus; | |
302 | } | |
e55f3f70 LOK |
303 | } |
304 | ||
2cd8b5d0 | 305 | void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 */) |
e9de9629 | 306 | { |
0500da96 | 307 | m_vendor.vendor = (cec_vendor_id)iVendorId; |
e9de9629 LOK |
308 | m_iVendorClass = iVendorClass; |
309 | ||
310 | switch (iVendorId) | |
311 | { | |
312 | case CEC_VENDOR_SAMSUNG: | |
0ab58650 LOK |
313 | if (m_handler->GetVendorId() != CEC_VENDOR_SAMSUNG) |
314 | { | |
315 | delete m_handler; | |
316 | m_handler = new CANCommandHandler(this); | |
317 | } | |
e9de9629 LOK |
318 | break; |
319 | case CEC_VENDOR_LG: | |
0ab58650 LOK |
320 | if (m_handler->GetVendorId() != CEC_VENDOR_LG) |
321 | { | |
322 | delete m_handler; | |
323 | m_handler = new CSLCommandHandler(this); | |
324 | } | |
e9de9629 | 325 | break; |
11621576 LOK |
326 | case CEC_VENDOR_PANASONIC: |
327 | if (m_handler->GetVendorId() != CEC_VENDOR_PANASONIC) | |
328 | { | |
329 | delete m_handler; | |
330 | m_handler = new CVLCommandHandler(this); | |
331 | } | |
332 | break; | |
e9de9629 | 333 | default: |
0ab58650 LOK |
334 | if (m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN) |
335 | { | |
336 | delete m_handler; | |
337 | m_handler = new CCECCommandHandler(this); | |
338 | } | |
e9de9629 LOK |
339 | break; |
340 | } | |
341 | ||
342 | CStdString strLog; | |
0f23c85c | 343 | strLog.Format("device %d: vendor = %s (%06x) class = %2x", m_iLogicalAddress, GetVendorName(), GetVendorId(), GetVendorClass()); |
e9de9629 LOK |
344 | m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str()); |
345 | } | |
93729720 | 346 | //@} |
e9de9629 | 347 | |
93729720 LOK |
348 | /** @name Transmit methods */ |
349 | //@{ | |
350 | bool CCECBusDevice::TransmitActiveSource(void) | |
0f23c85c | 351 | { |
d7be392a | 352 | CStdString strLog; |
6685ae07 | 353 | strLog.Format("<< %x -> broadcast: active source (%4x)", m_iLogicalAddress, m_iPhysicalAddress); |
d7be392a | 354 | AddLog(CEC_LOG_NOTICE, strLog); |
0f23c85c LOK |
355 | |
356 | cec_command command; | |
93729720 LOK |
357 | cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE); |
358 | command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); | |
359 | command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF)); | |
0f23c85c LOK |
360 | |
361 | return m_processor->Transmit(command); | |
362 | } | |
363 | ||
93729720 | 364 | bool CCECBusDevice::TransmitActiveView(void) |
0f23c85c | 365 | { |
d7be392a | 366 | CStdString strLog; |
6685ae07 | 367 | strLog.Format("<< %x -> broadcast: active view (%4x)", m_iLogicalAddress, m_iPhysicalAddress); |
d7be392a | 368 | AddLog(CEC_LOG_NOTICE, strLog); |
0f23c85c LOK |
369 | |
370 | cec_command command; | |
93729720 LOK |
371 | cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE); |
372 | command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF); | |
373 | command.parameters.push_back(m_iPhysicalAddress & 0xFF); | |
0f23c85c LOK |
374 | |
375 | return m_processor->Transmit(command); | |
376 | } | |
377 | ||
29912296 | 378 | bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest) |
0f23c85c | 379 | { |
d7be392a LOK |
380 | CStdString strLog; |
381 | strLog.Format("<< %x -> %x: cec version ", m_iLogicalAddress, dest); | |
382 | switch (m_cecVersion) | |
383 | { | |
384 | case CEC_VERSION_1_2: | |
385 | strLog.append("1.2"); | |
386 | break; | |
387 | case CEC_VERSION_1_2A: | |
388 | strLog.append("1.2a"); | |
389 | break; | |
390 | case CEC_VERSION_1_3: | |
391 | strLog.append("1.3"); | |
392 | break; | |
393 | case CEC_VERSION_1_3A: | |
394 | strLog.append("1.3a"); | |
395 | break; | |
396 | default: | |
397 | strLog.append("unknown"); | |
398 | break; | |
399 | } | |
400 | AddLog(CEC_LOG_NOTICE, strLog); | |
0f23c85c LOK |
401 | |
402 | cec_command command; | |
f8513317 | 403 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_CEC_VERSION); |
700c1ea7 | 404 | command.parameters.push_back(m_cecVersion); |
0f23c85c LOK |
405 | |
406 | return m_processor->Transmit(command); | |
407 | } | |
408 | ||
29912296 | 409 | bool CCECBusDevice::TransmitDeckStatus(cec_logical_address dest) |
0f23c85c LOK |
410 | { |
411 | // need to support opcodes play and deck control before doing anything with this | |
d7be392a LOK |
412 | CStdString strLog; |
413 | strLog.Format("<< %x -> %x: deck status feature abort", m_iLogicalAddress, dest); | |
414 | AddLog(CEC_LOG_NOTICE, strLog); | |
415 | ||
a1f8fb1b | 416 | m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DECK_STATUS); |
0f23c85c LOK |
417 | return false; |
418 | } | |
419 | ||
93729720 LOK |
420 | bool CCECBusDevice::TransmitInactiveView(void) |
421 | { | |
d7be392a LOK |
422 | CStdString strLog; |
423 | strLog.Format("<< %x -> broadcast: inactive view", m_iLogicalAddress); | |
424 | AddLog(CEC_LOG_NOTICE, strLog); | |
93729720 LOK |
425 | |
426 | cec_command command; | |
427 | cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE); | |
428 | command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF); | |
429 | command.parameters.push_back(m_iPhysicalAddress & 0xFF); | |
430 | ||
431 | return m_processor->Transmit(command); | |
432 | } | |
433 | ||
29912296 | 434 | bool CCECBusDevice::TransmitMenuState(cec_logical_address dest) |
0f23c85c | 435 | { |
d7be392a LOK |
436 | CStdString strLog; |
437 | strLog.Format("<< %x -> %x: ", m_iLogicalAddress, dest); | |
1844f5f7 | 438 | if (m_bMenuActive) |
d7be392a | 439 | strLog.append("menu active"); |
0f23c85c | 440 | else |
d7be392a LOK |
441 | strLog.append("menu inactive"); |
442 | AddLog(CEC_LOG_NOTICE, strLog); | |
0f23c85c LOK |
443 | |
444 | cec_command command; | |
f8513317 | 445 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS); |
1844f5f7 | 446 | command.parameters.push_back(m_bMenuActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED); |
0f23c85c LOK |
447 | |
448 | return m_processor->Transmit(command); | |
449 | } | |
450 | ||
29912296 | 451 | bool CCECBusDevice::TransmitOSDName(cec_logical_address dest) |
0f23c85c | 452 | { |
0f23c85c | 453 | CStdString strLog; |
d7be392a | 454 | strLog.Format("<< %x -> %x: OSD name '%s'", m_iLogicalAddress, dest, m_strDeviceName.c_str()); |
0f23c85c LOK |
455 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
456 | ||
457 | cec_command command; | |
f8513317 | 458 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_NAME); |
787a3cb8 LOK |
459 | for (unsigned int iPtr = 0; iPtr < m_strDeviceName.length(); iPtr++) |
460 | command.parameters.push_back(m_strDeviceName.at(iPtr)); | |
0f23c85c LOK |
461 | |
462 | return m_processor->Transmit(command); | |
463 | } | |
464 | ||
38bdb943 LOK |
465 | bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage) |
466 | { | |
467 | CStdString strLog; | |
d7be392a | 468 | strLog.Format("<< %x -> %x: display OSD message '%s'", m_iLogicalAddress, dest, strMessage); |
38bdb943 LOK |
469 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
470 | ||
471 | cec_command command; | |
472 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_STRING); | |
473 | command.parameters.push_back((uint8_t)duration); | |
474 | ||
475 | unsigned int iLen = strlen(strMessage); | |
476 | if (iLen > 13) iLen = 13; | |
477 | ||
478 | for (unsigned int iPtr = 0; iPtr < iLen; iPtr++) | |
479 | command.parameters.push_back(strMessage[iPtr]); | |
480 | ||
481 | return m_processor->Transmit(command); | |
482 | } | |
483 | ||
29912296 | 484 | bool CCECBusDevice::TransmitPhysicalAddress(void) |
0f23c85c LOK |
485 | { |
486 | CStdString strLog; | |
d7be392a | 487 | strLog.Format("<< %x -> broadcast: physical adddress %4x", m_iLogicalAddress, m_iPhysicalAddress); |
0f23c85c LOK |
488 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
489 | ||
490 | cec_command command; | |
f8513317 | 491 | cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS); |
0f23c85c LOK |
492 | command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); |
493 | command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF)); | |
6fc97923 | 494 | command.parameters.push_back((uint8_t) (m_type)); |
0f23c85c LOK |
495 | |
496 | return m_processor->Transmit(command); | |
497 | } | |
498 | ||
93729720 | 499 | bool CCECBusDevice::TransmitPoll(cec_logical_address dest) |
57f45e6c LOK |
500 | { |
501 | bool bReturn(false); | |
502 | ||
93729720 LOK |
503 | if (dest == CECDEVICE_UNKNOWN) |
504 | dest = m_iLogicalAddress; | |
f8513317 | 505 | |
57f45e6c | 506 | CStdString strLog; |
d7be392a LOK |
507 | strLog.Format("<< %x -> %x: POLL", m_iLogicalAddress, dest); |
508 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); | |
57f45e6c LOK |
509 | |
510 | cec_command command; | |
93729720 | 511 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_NONE); |
57f45e6c LOK |
512 | CLockObject lock(&m_mutex); |
513 | ||
514 | bReturn = m_processor->Transmit(command); | |
515 | AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent"); | |
516 | return bReturn; | |
517 | } | |
93729720 LOK |
518 | |
519 | bool CCECBusDevice::TransmitPowerState(cec_logical_address dest) | |
520 | { | |
521 | CStdString strLog; | |
d7be392a LOK |
522 | strLog.Format("<< %x -> %x: ", m_iLogicalAddress, dest); |
523 | ||
524 | switch (m_powerStatus) | |
525 | { | |
526 | case CEC_POWER_STATUS_ON: | |
527 | strLog.append("powered on"); | |
528 | break; | |
529 | case CEC_POWER_STATUS_STANDBY: | |
530 | strLog.append("in standby mode"); | |
531 | break; | |
532 | case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY: | |
533 | strLog.append("in transition from on to standby"); | |
534 | break; | |
535 | case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON: | |
536 | strLog.append("in transition from standby to on"); | |
537 | break; | |
538 | default: | |
539 | strLog.append("power state unknown"); | |
540 | break; | |
541 | } | |
542 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); | |
543 | ||
93729720 LOK |
544 | strLog.Format("<< reporting power status '%d'", m_powerStatus); |
545 | AddLog(CEC_LOG_NOTICE, strLog); | |
546 | ||
547 | cec_command command; | |
548 | cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_POWER_STATUS); | |
549 | command.parameters.push_back((uint8_t) m_powerStatus); | |
550 | ||
551 | return m_processor->Transmit(command); | |
552 | } | |
553 | ||
554 | bool CCECBusDevice::TransmitVendorID(cec_logical_address dest) | |
555 | { | |
d7be392a LOK |
556 | CStdString strLog; |
557 | strLog.Format("<< %x -> %x: vendor id feature abort", m_iLogicalAddress, dest); | |
558 | AddLog(CEC_LOG_NOTICE, strLog); | |
559 | ||
93729720 LOK |
560 | m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); |
561 | return false; | |
562 | } | |
563 | //@} |