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