cec: added hooks for vendor specific cec handling for LG and Samsung
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 25 Oct 2011 22:59:09 +0000 (00:59 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 25 Oct 2011 22:59:09 +0000 (00:59 +0200)
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h

index 27848252eb7215ecf47536ac9f55e840b8063161..43535a62441df186117f83bec8144ae251cf3dad 100644 (file)
@@ -541,19 +541,69 @@ void CCECProcessor::ParseVendorId(cec_logical_address device, const cec_datapack
   m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
 }
 
-void CCECProcessor::ParseCommand(cec_command &command)
+bool CCECProcessor::HandleANCommand(cec_command &command)
 {
-  CStdString dataStr;
-  dataStr.Format(">> received frame: %1x%1x:%02x", command.initiator, command.destination, command.opcode);
-  if (command.parameters.size > 1)
+  bool bHandled(true);
+  if (command.destination == m_iLogicalAddress)
   {
-    for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
-      dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]);
+    switch(command.opcode)
+    {
+    // TODO
+    default:
+      bHandled = false;
+      break;
+    }
+  }
+  else if (command.destination == CECDEVICE_BROADCAST)
+  {
+    switch(command.opcode)
+    {
+    // TODO
+    default:
+      bHandled = false;
+      break;
+    }
   }
-  m_controller->AddLog(CEC_LOG_DEBUG, dataStr.c_str());
 
-  if (m_bMonitor)
-    return;
+  if (!bHandled)
+    bHandled = HandleCecCommand(command);
+
+  return bHandled;
+}
+
+bool CCECProcessor::HandleSLCommand(cec_command &command)
+{
+  bool bHandled(true);
+  if (command.destination == m_iLogicalAddress)
+  {
+    switch(command.opcode)
+    {
+    // TODO
+    default:
+      bHandled = false;
+      break;
+    }
+  }
+  else if (command.destination == CECDEVICE_BROADCAST)
+  {
+    switch(command.opcode)
+    {
+    // TODO
+    default:
+      bHandled = false;
+      break;
+    }
+  }
+
+  if (!bHandled)
+    bHandled = HandleCecCommand(command);
+
+  return bHandled;
+}
+
+bool CCECProcessor::HandleCecCommand(cec_command &command)
+{
+  bool bHandled(true);
 
   if (command.destination == m_iLogicalAddress)
   {
@@ -608,6 +658,7 @@ void CCECProcessor::ParseCommand(cec_command &command)
       break;
     default:
       m_controller->AddCommand(command);
+      bHandled = false;
       break;
     }
   }
@@ -644,6 +695,7 @@ void CCECProcessor::ParseCommand(cec_command &command)
       break;
     default:
       m_controller->AddCommand(command);
+      bHandled = false;
       break;
     }
   }
@@ -652,6 +704,34 @@ void CCECProcessor::ParseCommand(cec_command &command)
     CStdString strLog;
     strLog.Format("ignoring frame: destination: %u != %u", command.destination, (uint8_t)m_iLogicalAddress);
     m_controller->AddLog(CEC_LOG_DEBUG, strLog.c_str());
+    bHandled = false;
+  }
+
+  return bHandled;
+}
+
+void CCECProcessor::ParseCommand(cec_command &command)
+{
+  CStdString dataStr;
+  dataStr.Format(">> received frame: %1x%1x:%02x", command.initiator, command.destination, command.opcode);
+  if (command.parameters.size > 1)
+  {
+    for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++)
+      dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]);
+  }
+  m_controller->AddLog(CEC_LOG_DEBUG, dataStr.c_str());
+
+  if (!m_bMonitor)
+  {
+    switch(m_vendorIds[command.initiator])
+    {
+    case CEC_VENDOR_LG:
+      HandleSLCommand(command);
+    case CEC_VENDOR_SAMSUNG:
+      HandleANCommand(command);
+    default:
+      HandleCecCommand(command);
+    }
   }
 }
 
index 5ff3e6270cb1dff29a102d90688ee959b83e6a32..4e9d1115c475aba934769702b5dc650ce63db0b1 100644 (file)
@@ -74,6 +74,9 @@ namespace CEC
       virtual void ReportOSDName(cec_logical_address address = CECDEVICE_TV);
       virtual void ReportPhysicalAddress(void);
       virtual void BroadcastActiveSource(void);
+      virtual bool HandleANCommand(cec_command &command);
+      virtual bool HandleSLCommand(cec_command &command);
+      virtual bool HandleCecCommand(cec_command &command);
 
     private:
       void LogOutput(const cec_command &data);