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