cec: moved SetVendorId(const cec_datapacket &packet) to CCECCommandHandler
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index e30810c6671c7c564721c0906ed5db94630db0c1..122c4be1c51e2eaedbc681b9c5b2a163992e67c2 100644 (file)
@@ -167,19 +167,13 @@ bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command)
 
 bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
 {
-  CCECBusDevice *device = GetDevice(command.initiator);
-  if (device)
-    device->SetVendorId(command.parameters);
-
+  SetVendorId(command);
   return true;
 }
 
 bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
 {
-  CCECBusDevice *device = GetDevice(command.initiator);
-  if (device)
-    device->SetVendorId(command.parameters);
-
+  SetVendorId(command);
   return true;
 }
 
@@ -288,7 +282,7 @@ bool CCECCommandHandler::HandleRoutingChange(const cec_command &command)
 
     CCECBusDevice *device = GetDevice(command.initiator);
     if (device)
-      device->SetPhysicalAddress(iNewAddress, iOldAddress);
+      device->SetStreamPath(iNewAddress, iOldAddress);
   }
   return true;
 }
@@ -402,3 +396,21 @@ CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysical
 
   return device;
 }
+
+
+void CCECCommandHandler::SetVendorId(const cec_command &command)
+{
+  if (command.parameters.size < 3)
+  {
+    m_busDevice->AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
+    return;
+  }
+
+  uint64_t iVendorId = ((uint64_t)command.parameters[0] << 3) +
+                       ((uint64_t)command.parameters[1] << 2) +
+                        (uint64_t)command.parameters[2];
+
+  CCECBusDevice *device = GetDevice((cec_logical_address) command.initiator);
+  if (device)
+    device->SetVendorId(iVendorId, iVendorId);
+}