cec: added SetDeckControlMode() and SetDeckInfo(). handle deck related opcodes. proba...
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
CommitLineData
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 "CECCommandHandler.h"
eafa9d46 34#include "../devices/CECBusDevice.h"
a1f8fb1b 35#include "../devices/CECAudioSystem.h"
28089abc 36#include "../devices/CECPlaybackDevice.h"
387b6f6f 37#include "../CECProcessor.h"
e9de9629
LOK
38
39using namespace CEC;
8747dd4f 40using namespace std;
e9de9629
LOK
41
42CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice)
43{
44 m_busDevice = busDevice;
45}
46
47bool CCECCommandHandler::HandleCommand(const cec_command &command)
48{
49 bool bHandled(true);
50
5e822b09 51 CStdString strLog;
62f5527d 52 strLog.Format(">> %s (%X) -> %s (%X): %s (%2X)", ToString(command.initiator), command.initiator, ToString(command.destination), command.destination, ToString(command.opcode), command.opcode);
5e822b09
LOK
53 m_busDevice->AddLog(CEC_LOG_NOTICE, strLog);
54
f8513317 55 if (m_busDevice->MyLogicalAddressContains(command.destination))
e9de9629
LOK
56 {
57 switch(command.opcode)
58 {
e55f3f70
LOK
59 case CEC_OPCODE_REPORT_POWER_STATUS:
60 HandleReportPowerStatus(command);
61 break;
6a1c0009
LOK
62 case CEC_OPCODE_CEC_VERSION:
63 HandleDeviceCecVersion(command);
64 break;
a3269a0a
LOK
65 case CEC_OPCODE_SET_MENU_LANGUAGE:
66 HandleSetMenuLanguage(command);
4d6b4433 67 /* pass to listeners */
a9e03a86 68 m_busDevice->GetProcessor()->AddCommand(command);
a3269a0a 69 break;
e9de9629
LOK
70 case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS:
71 HandleGivePhysicalAddress(command);
72 break;
73 case CEC_OPCODE_GIVE_OSD_NAME:
74 HandleGiveOSDName(command);
75 break;
76 case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID:
77 HandleGiveDeviceVendorId(command);
78 break;
79 case CEC_OPCODE_DEVICE_VENDOR_ID:
80 HandleDeviceVendorId(command);
81 break;
82 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
83 HandleDeviceVendorCommandWithId(command);
84 break;
85 case CEC_OPCODE_GIVE_DECK_STATUS:
86 HandleGiveDeckStatus(command);
87 break;
a9232a79
LOK
88 case CEC_OPCODE_DECK_CONTROL:
89 HandleDeckControl(command);
90 break;
e9de9629
LOK
91 case CEC_OPCODE_MENU_REQUEST:
92 HandleMenuRequest(command);
93 break;
94 case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
95 HandleGiveDevicePowerStatus(command);
96 break;
97 case CEC_OPCODE_GET_CEC_VERSION:
98 HandleGetCecVersion(command);
99 break;
100 case CEC_OPCODE_USER_CONTROL_PRESSED:
101 HandleUserControlPressed(command);
102 break;
103 case CEC_OPCODE_USER_CONTROL_RELEASE:
104 HandleUserControlRelease(command);
105 break;
a1f8fb1b
LOK
106 case CEC_OPCODE_GIVE_AUDIO_STATUS:
107 HandleGiveAudioStatus(command);
108 break;
cf0ecd85
LOK
109 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS:
110 HandleGiveSystemAudioModeStatus(command);
111 break;
e5e86c76
LOK
112 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
113 HandleSetSystemAudioModeRequest(command);
114 break;
e9de9629
LOK
115 default:
116 UnhandledCommand(command);
4d6b4433 117 /* pass to listeners */
a9e03a86 118 m_busDevice->GetProcessor()->AddCommand(command);
e9de9629
LOK
119 bHandled = false;
120 break;
121 }
122 }
123 else if (command.destination == CECDEVICE_BROADCAST)
124 {
125 CStdString strLog;
126 switch (command.opcode)
127 {
a3269a0a
LOK
128 case CEC_OPCODE_SET_MENU_LANGUAGE:
129 HandleSetMenuLanguage(command);
4d6b4433 130 /* pass to listeners */
a9e03a86 131 m_busDevice->GetProcessor()->AddCommand(command);
a3269a0a 132 break;
e9de9629
LOK
133 case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
134 HandleRequestActiveSource(command);
135 break;
136 case CEC_OPCODE_SET_STREAM_PATH:
137 HandleSetStreamPath(command);
138 break;
139 case CEC_OPCODE_ROUTING_CHANGE:
140 HandleRoutingChange(command);
141 break;
142 case CEC_OPCODE_DEVICE_VENDOR_ID:
143 HandleDeviceVendorId(command);
144 break;
145 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
146 HandleDeviceVendorCommandWithId(command);
147 break;
4d6b4433
LOK
148 case CEC_OPCODE_STANDBY:
149 HandleStandby(command);
150 /* pass to listeners */
151 m_busDevice->GetProcessor()->AddCommand(command);
152 break;
be5b0e24
LOK
153 case CEC_OPCODE_ACTIVE_SOURCE:
154 HandleActiveSource(command);
155 /* pass to listeners */
156 m_busDevice->GetProcessor()->AddCommand(command);
157 break;
e9de9629
LOK
158 default:
159 UnhandledCommand(command);
4d6b4433 160 /* pass to listeners */
a9e03a86 161 m_busDevice->GetProcessor()->AddCommand(command);
e9de9629
LOK
162 bHandled = false;
163 break;
164 }
165 }
166 else
167 {
168 CStdString strLog;
f8513317 169 strLog.Format("ignoring frame: we're not at destination %x", command.destination);
e9de9629
LOK
170 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
171 bHandled = false;
172 }
173
174 return bHandled;
175}
176
be5b0e24
LOK
177bool CCECCommandHandler::HandleActiveSource(const cec_command &command)
178{
179 if (command.parameters.size == 2)
180 {
181 uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
182 return m_busDevice->GetProcessor()->SetStreamPath(iAddress);
183 }
184
185 return true;
186}
187
a9232a79
LOK
188bool CCECCommandHandler::HandleDeckControl(const cec_command &command)
189{
190 CCECBusDevice *device = GetDevice(command.destination);
191 if (device && device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE && command.parameters.size > 0)
192 {
193 ((CCECPlaybackDevice *) device)->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]);
194 return true;
195 }
196
197 return false;
198}
199
6a1c0009
LOK
200bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command)
201{
202 if (command.parameters.size == 1)
203 {
204 CCECBusDevice *device = GetDevice(command.initiator);
205 if (device)
206 device->SetCecVersion((cec_version) command.parameters[0]);
207 }
208
209 return true;
210}
211
e9de9629
LOK
212bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
213{
181b3475 214 SetVendorId(command);
6a1c0009 215 return true;
e9de9629
LOK
216}
217
218bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
219{
181b3475 220 SetVendorId(command);
6a1c0009 221 return true;
e9de9629
LOK
222}
223
224bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command)
225{
f8513317 226 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 227 if (device)
29912296 228 return device->TransmitCECVersion(command.initiator);
0f23c85c
LOK
229
230 return false;
e9de9629
LOK
231}
232
a1f8fb1b
LOK
233bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command)
234{
235 CCECBusDevice *device = GetDevice(command.destination);
236 if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
237 return ((CCECAudioSystem *) device)->TransmitAudioStatus(command.initiator);
238
239 return false;
240}
241
e9de9629
LOK
242bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command)
243{
f8513317 244 CCECBusDevice *device = GetDevice(command.destination);
28089abc
LOK
245 if (device && device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE)
246 return ((CCECPlaybackDevice *) device)->TransmitDeckStatus(command.initiator);
0f23c85c
LOK
247
248 return false;
e9de9629
LOK
249}
250
251bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command)
252{
f8513317 253 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 254 if (device)
29912296 255 return device->TransmitPowerState(command.initiator);
0f23c85c
LOK
256
257 return false;
e9de9629
LOK
258}
259
260bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command)
261{
f8513317 262 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 263 if (device)
29912296 264 return device->TransmitVendorID(command.initiator);
0f23c85c
LOK
265
266 return false;
e9de9629
LOK
267}
268
269bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command)
270{
f8513317 271 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 272 if (device)
29912296 273 return device->TransmitOSDName(command.initiator);
0f23c85c
LOK
274
275 return false;
e9de9629
LOK
276}
277
278bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command)
279{
f8513317 280 CCECBusDevice *device = GetDevice(command.destination);
09c10b66 281 if (device)
29912296 282 return device->TransmitPhysicalAddress();
09c10b66
LOK
283
284 return false;
e9de9629
LOK
285}
286
287bool CCECCommandHandler::HandleMenuRequest(const cec_command &command)
288{
289 if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_QUERY)
0f23c85c 290 {
f8513317 291 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 292 if (device)
29912296 293 return device->TransmitMenuState(command.initiator);
0f23c85c
LOK
294 }
295 return false;
e9de9629
LOK
296}
297
e55f3f70
LOK
298bool CCECCommandHandler::HandleReportPowerStatus(const cec_command &command)
299{
300 if (command.parameters.size == 1)
301 {
302 CCECBusDevice *device = GetDevice(command.initiator);
303 if (device)
304 device->SetPowerStatus((cec_power_status) command.parameters[0]);
305 }
306 return true;
307}
308
e9de9629
LOK
309bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command)
310{
311 CStdString strLog;
312 strLog.Format(">> %i requests active source", (uint8_t) command.initiator);
313 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
8747dd4f
LOK
314
315 vector<CCECBusDevice *> devices;
316 for (int iDevicePtr = (int)GetMyDevices(devices)-1; iDevicePtr >=0; iDevicePtr--)
317 devices[iDevicePtr]->TransmitActiveSource();
318 return true;
e9de9629
LOK
319}
320
321bool CCECCommandHandler::HandleRoutingChange(const cec_command &command)
322{
323 if (command.parameters.size == 4)
324 {
325 uint16_t iOldAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
326 uint16_t iNewAddress = ((uint16_t)command.parameters[2] << 8) | ((uint16_t)command.parameters[3]);
e9de9629 327
0f23c85c
LOK
328 CCECBusDevice *device = GetDevice(command.initiator);
329 if (device)
9dc04b07 330 device->SetStreamPath(iNewAddress, iOldAddress);
e9de9629
LOK
331 }
332 return true;
333}
334
a3269a0a
LOK
335bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command)
336{
337 if (command.parameters.size == 3)
338 {
339 CCECBusDevice *device = GetDevice(command.initiator);
340 if (device)
341 {
342 cec_menu_language language;
343 language.device = command.initiator;
56701628 344 for (uint8_t iPtr = 0; iPtr < 4; iPtr++)
a3269a0a
LOK
345 language.language[iPtr] = command.parameters[iPtr];
346 language.language[3] = 0;
347 device->SetMenuLanguage(language);
348 }
349 }
350 return true;
351}
352
e9de9629
LOK
353bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command)
354{
355 if (command.parameters.size >= 2)
356 {
f2198ab5 357 uint16_t streamaddr = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
e9de9629 358 CStdString strLog;
04437dcf 359 strLog.Format(">> %i sets stream path to physical address %04x", command.initiator, streamaddr);
e9de9629 360 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
04437dcf
LOK
361
362 return m_busDevice->GetProcessor()->SetStreamPath(streamaddr);
e9de9629
LOK
363 }
364 return true;
365}
366
e5e86c76
LOK
367bool CCECCommandHandler::HandleSetSystemAudioModeRequest(const cec_command &command)
368{
369 if (command.parameters.size >= 1)
370 {
371 CCECBusDevice *device = GetDevice(command.destination);
372 if (device&& device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
373 return ((CCECAudioSystem *) device)->SetSystemAudioMode(command);
374 }
375 return true;
376}
377
4d6b4433
LOK
378bool CCECCommandHandler::HandleStandby(const cec_command &command)
379{
380 CCECBusDevice *device = GetDevice(command.initiator);
381 if (device)
382 device->SetPowerStatus(CEC_POWER_STATUS_STANDBY);
383 return true;
384}
385
cf0ecd85
LOK
386bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command)
387{
388 CCECBusDevice *device = GetDevice(command.destination);
389 if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
390 return ((CCECAudioSystem *) device)->TransmitSystemAudioModeStatus(command.initiator);
391
392 return false;
393}
394
e9de9629
LOK
395bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command)
396{
397 if (command.parameters.size > 0)
398 {
399 m_busDevice->GetProcessor()->AddKey();
400
401 if (command.parameters[0] <= CEC_USER_CONTROL_CODE_MAX)
402 {
403 CStdString strLog;
68391d4f 404 strLog.Format("key pressed: %x", command.parameters[0]);
e9de9629
LOK
405 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
406
68391d4f
LOK
407 if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER ||
408 command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION)
409 {
410 CCECBusDevice *device = GetDevice(command.destination);
411 if (device)
412 device->SetPowerStatus(CEC_POWER_STATUS_ON);
413 }
414
e9de9629
LOK
415 m_busDevice->GetProcessor()->SetCurrentButton((cec_user_control_code) command.parameters[0]);
416 }
417 }
418 return true;
419}
420
421bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command)
422{
423 m_busDevice->GetProcessor()->AddKey();
424 return true;
425}
426
427void CCECCommandHandler::UnhandledCommand(const cec_command &command)
428{
b5b53c7d
LOK
429 CStdString strLog;
430 strLog.Format("unhandled command with opcode %02x from address %d", command.opcode, command.initiator);
431 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog);
0f23c85c
LOK
432}
433
8747dd4f
LOK
434unsigned int CCECCommandHandler::GetMyDevices(vector<CCECBusDevice *> &devices) const
435{
436 unsigned int iReturn(0);
437
438 cec_logical_addresses addresses = m_busDevice->GetProcessor()->GetLogicalAddresses();
f2198ab5 439 for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
8747dd4f
LOK
440 {
441 if (addresses[iPtr])
442 {
443 devices.push_back(GetDevice((cec_logical_address) iPtr));
444 ++iReturn;
445 }
446 }
447
448 return iReturn;
449}
450
0f23c85c
LOK
451CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress) const
452{
453 CCECBusDevice *device = NULL;
454
455 if (iLogicalAddress >= CECDEVICE_TV && iLogicalAddress <= CECDEVICE_BROADCAST)
456 device = m_busDevice->GetProcessor()->m_busDevices[iLogicalAddress];
457
458 return device;
e9de9629 459}
6685ae07
LOK
460
461CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const
462{
8ac9c610 463 return m_busDevice->GetProcessor()->GetDeviceByPhysicalAddress(iPhysicalAddress);
6685ae07 464}
181b3475 465
181b3475
LOK
466void CCECCommandHandler::SetVendorId(const cec_command &command)
467{
468 if (command.parameters.size < 3)
469 {
470 m_busDevice->AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
471 return;
472 }
473
bae71306
LOK
474 uint64_t iVendorId = ((uint64_t)command.parameters[0] << 16) +
475 ((uint64_t)command.parameters[1] << 8) +
181b3475
LOK
476 (uint64_t)command.parameters[2];
477
478 CCECBusDevice *device = GetDevice((cec_logical_address) command.initiator);
479 if (device)
a7bed660 480 device->SetVendorId(iVendorId, command.parameters.size > 3 ? command.parameters[3] : 0);
181b3475 481}
5e822b09 482
c686413b
LOK
483const char *CCECCommandHandler::ToString(const cec_version version)
484{
485 switch (version)
486 {
487 case CEC_VERSION_1_2:
488 return "1.2";
489 case CEC_VERSION_1_2A:
490 return "1.2a";
491 case CEC_VERSION_1_3:
492 return "1.3";
493 case CEC_VERSION_1_3A:
494 return "1.3a";
495 default:
496 return "unknown";
497 }
498}
499
66c16b69
LOK
500const char *CCECCommandHandler::ToString(const cec_power_status status)
501{
502 switch (status)
503 {
504 case CEC_POWER_STATUS_ON:
505 return "on";
506 case CEC_POWER_STATUS_STANDBY:
507 return "standby";
508 case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY:
509 return "in transition from on to standby";
510 case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON:
511 return "in transition from standby to on";
512 default:
513 return "unknown";
514 }
515}
516
62f5527d
LOK
517const char *CCECCommandHandler::ToString(const cec_logical_address address)
518{
519 switch(address)
520 {
521 case CECDEVICE_AUDIOSYSTEM:
522 return "Audio";
523 case CECDEVICE_BROADCAST:
524 return "Broadcast";
525 case CECDEVICE_FREEUSE:
526 return "Free use";
527 case CECDEVICE_PLAYBACKDEVICE1:
528 return "Playback 1";
529 case CECDEVICE_PLAYBACKDEVICE2:
530 return "Playback 2";
531 case CECDEVICE_PLAYBACKDEVICE3:
532 return "Playback 3";
533 case CECDEVICE_RECORDINGDEVICE1:
534 return "Recorder 1";
535 case CECDEVICE_RECORDINGDEVICE2:
536 return "Recorder 2";
537 case CECDEVICE_RECORDINGDEVICE3:
538 return "Recorder 3";
539 case CECDEVICE_RESERVED1:
540 return "Reserved 1";
541 case CECDEVICE_RESERVED2:
542 return "Reserved 2";
543 case CECDEVICE_TUNER1:
544 return "Tuner 1";
545 case CECDEVICE_TUNER2:
546 return "Tuner 2";
547 case CECDEVICE_TUNER3:
548 return "Tuner 3";
549 case CECDEVICE_TUNER4:
550 return "Tuner 4";
551 case CECDEVICE_TV:
552 return "TV";
553 default:
554 return "unknown";
555 }
556}
557
a9232a79
LOK
558const char *CCECCommandHandler::ToString(const cec_deck_control_mode mode)
559{
560 switch (mode)
561 {
562 case CEC_DECK_CONTROL_MODE_SKIP_FORWARD_WIND:
563 return "skip forward wind";
564 case CEC_DECK_CONTROL_MODE_EJECT:
565 return "eject";
566 case CEC_DECK_CONTROL_MODE_SKIP_REVERSE_REWIND:
567 return "reverse rewind";
568 case CEC_DECK_CONTROL_MODE_STOP:
569 return "stop";
570 default:
571 return "unknown";
572 }
573}
574
8ac9c610
LOK
575const char *CCECCommandHandler::ToString(const cec_deck_info status)
576{
577 switch (status)
578 {
579 case CEC_DECK_INFO_PLAY:
580 return "play";
581 case CEC_DECK_INFO_RECORD:
582 return "record";
583 case CEC_DECK_INFO_PLAY_REVERSE:
584 return "play reverse";
585 case CEC_DECK_INFO_STILL:
586 return "still";
587 case CEC_DECK_INFO_SLOW:
588 return "slow";
589 case CEC_DECK_INFO_SLOW_REVERSE:
590 return "slow reverse";
591 case CEC_DECK_INFO_FAST_FORWARD:
592 return "fast forward";
593 case CEC_DECK_INFO_FAST_REVERSE:
594 return "fast reverse";
595 case CEC_DECK_INFO_NO_MEDIA:
596 return "no media";
597 case CEC_DECK_INFO_STOP:
598 return "stop";
599 case CEC_DECK_INFO_SKIP_FORWARD_WIND:
600 return "info skip forward wind";
601 case CEC_DECK_INFO_SKIP_REVERSE_REWIND:
602 return "info skip reverse rewind";
603 case CEC_DECK_INFO_INDEX_SEARCH_FORWARD:
604 return "info index search forward";
605 case CEC_DECK_INFO_INDEX_SEARCH_REVERSE:
606 return "info index search reverse";
607 case CEC_DECK_INFO_OTHER_STATUS:
608 return "other";
609 default:
610 return "unknown";
611 }
612}
613
5e822b09
LOK
614const char *CCECCommandHandler::ToString(const cec_opcode opcode)
615{
616 switch (opcode)
617 {
618 case CEC_OPCODE_ACTIVE_SOURCE:
619 return "active source";
620 case CEC_OPCODE_IMAGE_VIEW_ON:
621 return "image view on";
622 case CEC_OPCODE_TEXT_VIEW_ON:
623 return "text view on";
624 case CEC_OPCODE_INACTIVE_SOURCE:
625 return "inactive source";
626 case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
627 return "request active source";
628 case CEC_OPCODE_ROUTING_CHANGE:
629 return "routing change";
630 case CEC_OPCODE_ROUTING_INFORMATION:
631 return "routing information";
632 case CEC_OPCODE_SET_STREAM_PATH:
633 return "set stream path";
634 case CEC_OPCODE_STANDBY:
635 return "standby";
636 case CEC_OPCODE_RECORD_OFF:
637 return "record off";
638 case CEC_OPCODE_RECORD_ON:
639 return "record on";
640 case CEC_OPCODE_RECORD_STATUS:
641 return "record status";
642 case CEC_OPCODE_RECORD_TV_SCREEN:
643 return "record tv screen";
644 case CEC_OPCODE_CLEAR_ANALOGUE_TIMER:
645 return "clear analogue timer";
646 case CEC_OPCODE_CLEAR_DIGITAL_TIMER:
647 return "clear digital timer";
648 case CEC_OPCODE_CLEAR_EXTERNAL_TIMER:
649 return "clear external timer";
650 case CEC_OPCODE_SET_ANALOGUE_TIMER:
651 return "set analogue timer";
652 case CEC_OPCODE_SET_DIGITAL_TIMER:
653 return "set digital timer";
654 case CEC_OPCODE_SET_EXTERNAL_TIMER:
655 return "set external timer";
656 case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE:
657 return "set timer program title";
658 case CEC_OPCODE_TIMER_CLEARED_STATUS:
659 return "timer cleared status";
660 case CEC_OPCODE_TIMER_STATUS:
661 return "timer status";
662 case CEC_OPCODE_CEC_VERSION:
663 return "cec version";
664 case CEC_OPCODE_GET_CEC_VERSION:
665 return "get cec version";
666 case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS:
667 return "give physical address";
668 case CEC_OPCODE_GET_MENU_LANGUAGE:
669 return "get menu language";
670 case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS:
671 return "report physical address";
672 case CEC_OPCODE_SET_MENU_LANGUAGE:
673 return "set menu language";
674 case CEC_OPCODE_DECK_CONTROL:
675 return "deck control";
676 case CEC_OPCODE_DECK_STATUS:
677 return "deck status";
678 case CEC_OPCODE_GIVE_DECK_STATUS:
679 return "give deck status";
680 case CEC_OPCODE_PLAY:
681 return "play";
682 case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS:
683 return "give tuner status";
684 case CEC_OPCODE_SELECT_ANALOGUE_SERVICE:
685 return "select analogue service";
686 case CEC_OPCODE_SELECT_DIGITAL_SERVICE:
687 return "set digital service";
688 case CEC_OPCODE_TUNER_DEVICE_STATUS:
689 return "tuner device status";
690 case CEC_OPCODE_TUNER_STEP_DECREMENT:
691 return "tuner step decrement";
692 case CEC_OPCODE_TUNER_STEP_INCREMENT:
693 return "tuner step increment";
694 case CEC_OPCODE_DEVICE_VENDOR_ID:
695 return "device vendor id";
696 case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID:
697 return "give device vendor id";
698 case CEC_OPCODE_VENDOR_COMMAND:
699 return "vendor command";
700 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
701 return "vendor command with id";
702 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN:
703 return "vendor remote button down";
704 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP:
705 return "vendor remote button up";
706 case CEC_OPCODE_SET_OSD_STRING:
707 return "set osd string";
708 case CEC_OPCODE_GIVE_OSD_NAME:
709 return "give osd name";
710 case CEC_OPCODE_SET_OSD_NAME:
711 return "set osd name";
712 case CEC_OPCODE_MENU_REQUEST:
713 return "menu request";
714 case CEC_OPCODE_MENU_STATUS:
715 return "menu status";
716 case CEC_OPCODE_USER_CONTROL_PRESSED:
717 return "user control pressed";
718 case CEC_OPCODE_USER_CONTROL_RELEASE:
719 return "user control release";
720 case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
721 return "give device power status";
722 case CEC_OPCODE_REPORT_POWER_STATUS:
723 return "report power status";
724 case CEC_OPCODE_FEATURE_ABORT:
725 return "feature abort";
726 case CEC_OPCODE_ABORT:
727 return "abort";
728 case CEC_OPCODE_GIVE_AUDIO_STATUS:
729 return "give audio status";
730 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS:
731 return "give audio mode status";
732 case CEC_OPCODE_REPORT_AUDIO_STATUS:
733 return "report audio status";
734 case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE:
735 return "set system audio mode";
736 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
737 return "system audio mode request";
738 case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS:
739 return "system audio mode status";
740 case CEC_OPCODE_SET_AUDIO_RATE:
741 return "set audio rate";
742 default:
743 return "UNKNOWN";
744 }
745}