cec: sync C and .NET interfaces with C++
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 29 Mar 2012 11:08:26 +0000 (13:08 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 29 Mar 2012 11:08:26 +0000 (13:08 +0200)
include/cecc.h
src/LibCecSharp/LibCecSharp.cpp
src/lib/LibCECC.cpp

index 7e3512f011edb340fe7fbfef48380d2dc6b9a800..779f211752755dd563090538bbc45d6b2942c2db 100644 (file)
@@ -296,6 +296,12 @@ extern DECLSPEC void cec_rescan_devices(void);
 
 extern DECLSPEC int cec_is_libcec_active_source(void);
 
+#ifdef __cplusplus
+extern DECLSPEC int cec_get_device_information(const char *strPort, CEC::libcec_configuration *config, uint32_t iTimeoutMs);
+#else
+extern DECLSPEC int cec_get_device_information(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs);
+#endif
+
 #ifdef __cplusplus
 };
 #endif
index 76dd00624e7948d3fcbf9eedfcf7d73f156f1b86..0737dbbb77f9adb29eff746fdcdef68efd434e87 100644 (file)
@@ -481,6 +481,31 @@ namespace CecSharp
                        return bReturn;
                }
 
+    bool IsLibCECActiveSource()
+    {
+      return m_libCec->IsLibCECActiveSource();
+    }
+
+    bool GetDeviceInformation(String ^ port, LibCECConfiguration ^configuration, uint32_t timeoutMs)
+    {
+      bool bReturn(false);
+      marshal_context ^ context = gcnew marshal_context();
+
+      libcec_configuration config;
+                       config.Clear();
+
+      const char* strPortC = port->Length > 0 ? context->marshal_as<const char*>(port) : NULL;
+
+      if (m_libCec->GetDeviceInformation(strPortC, &config, timeoutMs))
+                       {
+                               configuration->Update(config);
+        bReturn = true;
+                       }
+
+      delete context;
+      return bReturn;
+    }
+
                String ^ ToString(CecLogicalAddress iAddress)
                {
                        const char *retVal = m_libCec->ToString((cec_logical_address)iAddress);
index 29b08fd98ce429570f57c3e75b69ca69c3c36763..4a7e0be9b8260f8d0a491929be7a9db930f18922 100644 (file)
@@ -421,4 +421,9 @@ int cec_is_libcec_active_source(void)
   return cec_parser ? (cec_parser->IsLibCECActiveSource() ? 1 : 0) : -1;
 }
 
+int cec_get_device_information(const char *strPort, CEC::libcec_configuration *config, uint32_t iTimeoutMs)
+{
+  return cec_parser ? (cec_parser->GetDeviceInformation(strPort, config, iTimeoutMs) ? 1 : 0) : -1;
+}
+
 //@}