cec: added a new setting to control whether to put the TV in standby when the player...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 2 Apr 2012 14:31:30 +0000 (16:31 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 2 Apr 2012 14:31:30 +0000 (16:31 +0200)
include/cectypes.h
src/LibCecSharp/CecSharpTypes.h
src/LibCecSharp/LibCecSharp.cpp
src/lib/CECProcessor.cpp
src/lib/LibCEC.cpp

index 451b2ab83c0efff0fcb1f3276f6d744708814e5f..3beef1cc391a779871d9347f9ecd4fa91d6b2932 100644 (file)
@@ -80,6 +80,7 @@ namespace CEC {
 #define CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER 1
 #define CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY  1
 #define CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE  1
+#define CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY 1
 
 #define CEC_DEFAULT_TRANSMIT_RETRY_WAIT 500
 #define CEC_DEFAULT_TRANSMIT_TIMEOUT    1000
@@ -1006,7 +1007,8 @@ typedef struct libcec_configuration
   ICECCallbacks *       callbacks;            /*!< the callback methods to use. set this to NULL when not using callbacks */
 
   cec_logical_addresses logicalAddresses;     /*!< the current logical addresses. read-only. added in 1.5.3 */
-  uint16_t              iFirmwareVersion;     /*!< the firmware version of the adapter. in 1.6.0 */
+  uint16_t              iFirmwareVersion;     /*!< the firmware version of the adapter. added in 1.6.0 */
+  uint8_t               bPowerOffDevicesOnStandby; /*!< put devices in standby when the PC/player is put in standby. added in 1.6.0 */
 
 #ifdef __cplusplus
   void Clear(void)
@@ -1037,6 +1039,7 @@ typedef struct libcec_configuration
     bSendInactiveSource  = CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE;
     logicalAddresses.Clear();
     iFirmwareVersion = 0;
+    bPowerOffDevicesOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY;
 
     callbackParam    = NULL;
     callbacks        = NULL;
index 8cdaa89a0e9e797f2931fedb936534c3009a2bd2..d9fcc9d2a0fcc7cde1c312b685a2c6f071596ce7 100644 (file)
@@ -328,7 +328,9 @@ namespace CecSharp
                VersionPre1_5 = 0,
                Version1_5_0  = 0x1500,
     Version1_5_1  = 0x1501,
-    Version1_5_2  = 0x1502
+    Version1_5_2  = 0x1502,
+    Version1_5_3  = 0x1503,
+    Version1_6_0  = 0x1600
        };
 
   public enum class CecServerVersion
@@ -336,7 +338,9 @@ namespace CecSharp
                VersionPre1_5 = 0,
                Version1_5_0  = 0x1500,
     Version1_5_1  = 0x1501,
-    Version1_5_2  = 0x1502
+    Version1_5_2  = 0x1502,
+    Version1_5_3  = 0x1503,
+    Version1_6_0  = 0x1600
        };
 
        public ref class CecAdapter
@@ -552,6 +556,9 @@ namespace CecSharp
                        PowerOffScreensaver = CEC_DEFAULT_SETTING_POWER_OFF_SCREENSAVER == 1;
                        PowerOffOnStandby   = CEC_DEFAULT_SETTING_POWER_OFF_ON_STANDBY == 1;
       SendInactiveSource  = CEC_DEFAULT_SETTING_SEND_INACTIVE_SOURCE == 1;
+      LogicalAddresses    = gcnew CecLogicalAddresses();
+      FirmwareVersion     = 1;
+      PowerOffDevicesOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY == 1;
                }
 
                void SetCallbacks(CecCallbackMethods ^callbacks)
@@ -591,7 +598,23 @@ namespace CecSharp
 
                        PowerOffScreensaver = config.bPowerOffScreensaver == 1;
                        PowerOffOnStandby = config.bPowerOffOnStandby == 1;
-      SendInactiveSource = config.bSendInactiveSource == 1;
+
+      if (ServerVersion >= CecServerVersion::Version1_5_1)
+        SendInactiveSource = config.bSendInactiveSource == 1;
+
+      if (ServerVersion >= CecServerVersion::Version1_5_3)
+      {
+        LogicalAddresses->Clear();
+                         for (uint8_t iPtr = 0; iPtr <= 16; iPtr++)
+                                 if (config.logicalAddresses[iPtr])
+                                       LogicalAddresses->Set((CecLogicalAddress)iPtr);
+      }
+
+      if (ServerVersion >= CecServerVersion::Version1_6_0)
+      {
+        FirmwareVersion          = config.iFirmwareVersion;
+        PowerOffDevicesOnStandby = config.bPowerOffDevicesOnStandby == 1;
+      }
                }
 
                property System::String ^     DeviceName;
@@ -613,6 +636,9 @@ namespace CecSharp
                property bool                 PowerOffScreensaver;
                property bool                 PowerOffOnStandby;
     property bool                 SendInactiveSource;
+    property CecLogicalAddresses ^LogicalAddresses;
+    property uint16_t             FirmwareVersion;
+    property bool                 PowerOffDevicesOnStandby;
 
                property CecCallbackMethods ^ Callbacks;
        };
index 0737dbbb77f9adb29eff746fdcdef68efd434e87..2338671d577dfa53448185aacfd58abafc89a753 100644 (file)
@@ -117,7 +117,13 @@ namespace CecSharp
                        }
                        config.bPowerOffScreensaver = netConfig->PowerOffScreensaver ? 1 : 0;
                        config.bPowerOffOnStandby   = netConfig->PowerOffOnStandby ? 1 : 0;
-      config.bSendInactiveSource  = netConfig->SendInactiveSource ? 1 : 0;
+
+      if (netConfig->ServerVersion >= CecServerVersion::Version1_5_1)
+        config.bSendInactiveSource  = netConfig->SendInactiveSource ? 1 : 0;
+
+      if (netConfig->ServerVersion >= CecServerVersion::Version1_6_0)
+        config.bPowerOffDevicesOnStandby  = netConfig->PowerOffDevicesOnStandby ? 1 : 0;
+
                        config.callbacks            = &g_cecCallbacks;
                }
 
index 095fb63335fed7322d71506df85d607abe9f1caf..20ae10abd71ac33dc3059272d53650107070c884 100644 (file)
@@ -1623,6 +1623,10 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
   if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1)
     m_configuration.bSendInactiveSource = configuration->bSendInactiveSource;
 
+  // client version 1.6.0
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_6_0)
+    m_configuration.bPowerOffDevicesOnStandby = configuration->bPowerOffDevicesOnStandby;
+
   // ensure that there is at least 1 device type set
   if (m_configuration.deviceTypes.IsEmpty())
     m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
@@ -1675,8 +1679,11 @@ bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)
     configuration->logicalAddresses    = m_configuration.logicalAddresses;
 
   // client version 1.6.0
-  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_3)
-    configuration->logicalAddresses    = m_configuration.logicalAddresses;
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_6_0)
+  {
+    configuration->iFirmwareVersion          = m_configuration.iFirmwareVersion;
+    configuration->bPowerOffDevicesOnStandby = m_configuration.bPowerOffDevicesOnStandby;
+  }
 
   return true;
 }
index 03962e2ce0907616cd2bbd0531bf5ffba9371e30..2e149c7da0ce1b816be7a95f6fb98af719b439a9 100644 (file)
@@ -60,7 +60,7 @@ CLibCEC::CLibCEC(libcec_configuration *configuration) :
     m_callbacks(configuration->callbacks),
     m_cbParam(configuration->callbackParam)
 {
-  configuration->serverVersion = CEC_SERVER_VERSION_1_5_3;
+  configuration->serverVersion = CEC_SERVER_VERSION_1_6_0;
   m_cec = new CCECProcessor(this, configuration);
 }