cec: fixed - report physical address sends 3 parameters, not 2. check whether the...
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index 78d7d40e0f964f252363d74423f209a396048630..366f7dd01b5c20aee7d3fcfe204423b2adf0d639 100644 (file)
@@ -117,12 +117,18 @@ 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;
   default:
     UnhandledCommand(command);
     if (command.destination == CECDEVICE_BROADCAST || m_busDevice->MyLogicalAddressContains(command.destination))
@@ -175,8 +181,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);
 
@@ -292,6 +296,20 @@ bool CCECCommandHandler::HandleMenuRequest(const cec_command &command)
   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 +348,18 @@ 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);
+  }
+}
+
 bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command)
 {
   if (command.parameters.size == 3)