X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fimplementations%2FCECCommandHandler.cpp;h=037825acb1d4078c6369efcf2c04295841be6471;hb=f8ae32954754d261552c2c11a6a9055f02d61bba;hp=78d7d40e0f964f252363d74423f209a396048630;hpb=6b72afcda7afcd6d6150a36f476c08f0f336fa48;p=deb_libcec.git diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 78d7d40..037825a 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -117,20 +117,33 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) case CEC_OPCODE_ROUTING_CHANGE: HandleRoutingChange(command); break; + case CEC_OPCODE_ROUTING_INFORMATION: + HandleRoutingInformation(command); + break; case CEC_OPCODE_STANDBY: HandleStandby(command); break; case CEC_OPCODE_ACTIVE_SOURCE: HandleActiveSource(command); break; + case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS: + HandleReportPhysicalAddress(command); + break; + case CEC_OPCODE_REPORT_AUDIO_STATUS: + HandleReportAudioStatus(command); + break; + case CEC_OPCODE_SET_OSD_NAME: + HandleSetOSDName(command); + break; default: UnhandledCommand(command); - if (command.destination == CECDEVICE_BROADCAST || m_busDevice->MyLogicalAddressContains(command.destination)) - m_busDevice->GetProcessor()->AddCommand(command); bHandled = false; break; } + if (command.destination == CECDEVICE_BROADCAST || m_busDevice->MyLogicalAddressContains(command.destination)) + m_busDevice->GetProcessor()->AddCommand(command); + return bHandled; } @@ -138,8 +151,6 @@ bool CCECCommandHandler::HandleActiveSource(const cec_command &command) { if (command.parameters.size == 2) { - m_busDevice->GetProcessor()->AddCommand(command); - uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); return m_busDevice->GetProcessor()->SetStreamPath(iAddress); } @@ -152,8 +163,6 @@ bool CCECCommandHandler::HandleDeckControl(const cec_command &command) CCECBusDevice *device = GetDevice(command.destination); if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) && command.parameters.size > 0) { - m_busDevice->GetProcessor()->AddCommand(command); - ((CCECPlaybackDevice *) device)->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]); return true; } @@ -175,8 +184,6 @@ bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command) bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command) { - SetVendorId(command); - if (m_busDevice->MyLogicalAddressContains(command.destination)) m_busDevice->GetProcessor()->TransmitAbort(command.initiator, command.opcode, CEC_ABORT_REASON_REFUSED); @@ -283,15 +290,39 @@ bool CCECCommandHandler::HandleMenuRequest(const cec_command &command) if (device) return device->TransmitMenuState(command.initiator); } - else + } + + return false; +} + +bool CCECCommandHandler::HandleReportAudioStatus(const cec_command &command) +{ + if (command.parameters.size == 1) + { + CCECBusDevice *device = GetDevice(command.initiator); + if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM) { - m_busDevice->GetProcessor()->AddCommand(command); + ((CCECAudioSystem *)device)->SetAudioStatus(command.parameters[0]); + return true; } } - return false; } +bool CCECCommandHandler::HandleReportPhysicalAddress(const cec_command &command) +{ + if (command.parameters.size == 3) + { + uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); + cec_device_type type = (cec_device_type)command.parameters[2]; + + CCECBusDevice *device = GetDevice(command.initiator); + if (device && device->GetType() == type) + device->SetPhysicalAddress(iNewAddress); + } + return true; +} + bool CCECCommandHandler::HandleReportPowerStatus(const cec_command &command) { if (command.parameters.size == 1) @@ -330,6 +361,23 @@ bool CCECCommandHandler::HandleRoutingChange(const cec_command &command) return true; } +bool CCECCommandHandler::HandleRoutingInformation(const cec_command &command) +{ + if (command.parameters.size == 2) + { + uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); + + CCECBusDevice *device = GetDevice(command.initiator); + if (device) + { + device->SetPhysicalAddress(iNewAddress); + return true; + } + } + + return false; +} + bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command) { if (command.parameters.size == 3) @@ -343,12 +391,31 @@ bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command) language.language[iPtr] = command.parameters[iPtr]; language.language[3] = 0; device->SetMenuLanguage(language); + return true; + } + } + return false; +} + +bool CCECCommandHandler::HandleSetOSDName(const cec_command &command) +{ + if (command.parameters.size > 0) + { + CCECBusDevice *device = GetDevice(command.initiator); + if (device) + { + char buf[1024]; + for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) + buf[iPtr] = (char)command.parameters[iPtr]; + buf[command.parameters.size] = 0; - if (m_busDevice->MyLogicalAddressContains(command.destination)) - m_busDevice->GetProcessor()->AddCommand(command); + CStdString strName(buf); + device->SetOSDName(strName); + + return true; } } - return true; + return false; } bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) @@ -369,9 +436,8 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command) device->TransmitMenuState(command.initiator); } } - return false; } - return true; + return false; } bool CCECCommandHandler::HandleSetSystemAudioModeRequest(const cec_command &command) @@ -391,8 +457,6 @@ bool CCECCommandHandler::HandleStandby(const cec_command &command) if (device) device->SetPowerStatus(CEC_POWER_STATUS_STANDBY); - m_busDevice->GetProcessor()->AddCommand(command); - return true; } @@ -429,9 +493,10 @@ bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command) } m_busDevice->GetProcessor()->SetCurrentButton((cec_user_control_code) command.parameters[0]); + return true; } } - return true; + return false; } bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command)