cec: a recording device inherits all the features of a playback device. changed defau...
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index 1c0f8d95ed81ce53184a1efd0f717996cf79fd86..4446c9d3ed9b4de4ce04f1b2dcbbf6fbb38f944c 100644 (file)
@@ -87,9 +87,15 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command)
       break;
     case CEC_OPCODE_DECK_CONTROL:
       HandleDeckControl(command);
+      /* pass to listeners */
+      m_busDevice->GetProcessor()->AddCommand(command);
       break;
     case CEC_OPCODE_MENU_REQUEST:
-      HandleMenuRequest(command);
+      if (!HandleMenuRequest(command))
+      {
+        /* pass to listeners */
+        m_busDevice->GetProcessor()->AddCommand(command);
+      }
       break;
     case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
       HandleGiveDevicePowerStatus(command);
@@ -188,7 +194,7 @@ bool CCECCommandHandler::HandleActiveSource(const cec_command &command)
 bool CCECCommandHandler::HandleDeckControl(const cec_command &command)
 {
   CCECBusDevice *device = GetDevice(command.destination);
-  if (device && device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE && command.parameters.size > 0)
+  if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) && command.parameters.size > 0)
   {
     ((CCECPlaybackDevice *) device)->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]);
     return true;
@@ -243,7 +249,7 @@ bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command)
 bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command)
 {
   CCECBusDevice *device = GetDevice(command.destination);
-  if (device && device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE)
+  if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE))
     return ((CCECPlaybackDevice *) device)->TransmitDeckStatus(command.initiator);
 
   return false;
@@ -356,12 +362,21 @@ bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command)
 {
   if (command.parameters.size >= 2)
   {
-    uint16_t streamaddr = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
+    uint16_t iStreamAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
     CStdString strLog;
-    strLog.Format(">> %i sets stream path to physical address %04x", command.initiator, streamaddr);
+    strLog.Format(">> %i sets stream path to physical address %04x", command.initiator, iStreamAddress);
     m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
 
-    return m_busDevice->GetProcessor()->SetStreamPath(streamaddr);
+    if (m_busDevice->GetProcessor()->SetStreamPath(iStreamAddress))
+    {
+      CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress);
+      if (device)
+      {
+        return device->TransmitActiveSource() &&
+            device->TransmitMenuState(command.initiator);
+      }
+    }
+    return false;
   }
   return true;
 }
@@ -487,6 +502,19 @@ void CCECCommandHandler::SetVendorId(const cec_command &command)
     device->SetVendorId(iVendorId);
 }
 
+const char *CCECCommandHandler::ToString(const cec_menu_state state)
+{
+  switch (state)
+  {
+  case CEC_MENU_STATE_ACTIVATED:
+    return "activated";
+  case CEC_MENU_STATE_DEACTIVATED:
+    return "deactivated";
+  default:
+    return "unknown";
+  }
+}
+
 const char *CCECCommandHandler::ToString(const cec_version version)
 {
   switch (version)