]> git.vomp.tv Git - vompclient.git/commitdiff
Stretch: libcec4 changes
authorChris Tallon <chris@vomp.tv>
Sun, 29 Oct 2017 17:59:36 +0000 (17:59 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 29 Oct 2017 17:59:36 +0000 (17:59 +0000)
remotelinux.cc
remotelinux.h

index 2d0270b1ed46571c0be5f2965b8ac967db74dcdf..82069b0dbdf96fe76bbc3045f3518e969ea7a9f7 100644 (file)
@@ -131,14 +131,22 @@ int RemoteLinux::initCec() {
        Log::getInstance()->log("Remote", Log::NOTICE, "Init LibCEC");
        cec_config.Clear();
        cec_callbacks.Clear();
+#if CEC_LIB_VERSION_MAJOR >= 4
+       cec_callbacks.logMessage = cecLogMessage;
+       cec_callbacks.keyPress = cecKeyPress;
+       cec_callbacks.commandReceived = cecCommand;
+       cec_callbacks.configurationChanged = cecConfigurationChanged;
+       cec_callbacks.sourceActivated = cecSourceActivated;
+#else
        cec_callbacks.CBCecLogMessage = cecLogMessage;
        cec_callbacks.CBCecKeyPress = cecKeyPress;
        cec_callbacks.CBCecCommand = cecCommand;
        cec_callbacks.CBCecConfigurationChanged = cecConfigurationChanged;
        cec_callbacks.CBCecSourceActivated = cecSourceActivated;
-       cec_config.clientVersion=LIBCEC_VERSION_CURRENT;
-       cec_config.bActivateSource=1;
        cec_config.bUseTVMenuLanguage=1;
+#endif
+    cec_config.clientVersion=LIBCEC_VERSION_CURRENT;
+       cec_config.bActivateSource=1;
        //cec_config.deviceTypes.Add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
        cec_config.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
        //cec_config.deviceTypes.Add(CEC_DEVICE_TYPE_TUNER);
@@ -157,8 +165,13 @@ int RemoteLinux::initCec() {
        cec_adap->InitVideoStandalone();
 
 
+#if CEC_LIB_VERSION_MAJOR >= 4
+       cec_adapter_descriptor cec_adapter_descriptors[10];
+       int adap_num=cec_adap->DetectAdapters(cec_adapter_descriptors, 10);
+#else
        cec_adapter  cec_devices[10];
        int adap_num=cec_adap->FindAdapters(cec_devices,10,NULL);
+#endif
        if (adap_num<0) {
                Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to find adapter");
                return 1;
@@ -169,8 +182,12 @@ int RemoteLinux::initCec() {
                return 1;
 
        }
+#if CEC_LIB_VERSION_MAJOR >= 4
+       if (!cec_adap->Open(cec_adapter_descriptors[0].strComPath)) {
+#else
        if (!cec_adap->Open(cec_devices[0].comm)) {
-               Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to open adapter");
+#endif
+      Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to open adapter");
                return 1;
        }
 
@@ -904,6 +921,61 @@ void RemoteLinux::changePowerState(bool poweron){
        }
 }
 
+#if CEC_LIB_VERSION_MAJOR >= 4
+
+// libcec4 API changed these params to pointers rather than copies, and the returns to void
+// Otherwise, these two blocks of code are the same
+
+void RemoteLinux::cecLogMessage(void *param, const cec_log_message* message)
+{
+       Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s", message->time, message->level, message->message);
+}
+
+void RemoteLinux::cecKeyPress(void*param, const cec_keypress* key)
+{
+       //Log::getInstance()->log("Remote", Log::DEBUG, "Incoming cec key %d %d", key->keycode,key->duration);
+       if (key->duration==0) ((RemoteLinux*)Remote::getInstance())->incomingCECkey(key->keycode);
+}
+
+void RemoteLinux::cecCommand(void *param, const cec_command* command)
+{
+       Log::getInstance()->log("Remote", Log::DEBUG, "CECCommand: %d",command->opcode);
+       switch (command->opcode) {
+       case CEC_OPCODE_STANDBY: {
+               if (command->initiator==CECDEVICE_TV) {
+                       ((RemoteLinux*)Remote::getInstance())->incomingPowerkey(POWEROFF);
+               }
+       } break;
+       case CEC_OPCODE_DECK_CONTROL: {
+               if (command->initiator==CECDEVICE_TV && command->parameters.size == 1
+                               && command->parameters[0]==CEC_DECK_CONTROL_MODE_STOP) {
+                       ((RemoteLinux*)Remote::getInstance())->incomingCECkey(CEC_USER_CONTROL_CODE_STOP);
+
+               }
+
+       } break;
+       case CEC_OPCODE_PLAY: {
+               if (command->initiator==CECDEVICE_TV && command->parameters.size == 1) {
+                       if (command->parameters[0]==CEC_PLAY_MODE_PLAY_FORWARD) {
+                               ((RemoteLinux*)Remote::getInstance())->incomingCECkey(CEC_USER_CONTROL_CODE_PLAY);
+                       } else if (command->parameters[0]==CEC_PLAY_MODE_PLAY_STILL) {
+                               ((RemoteLinux*)Remote::getInstance())->incomingCECkey(CEC_USER_CONTROL_CODE_PAUSE);
+                       }
+               }
+
+
+       } break;
+       default:
+               break;
+       };
+}
+
+void RemoteLinux::cecConfigurationChanged(void *param, const libcec_configuration* config)
+{
+       Log::getInstance()->log("Remote", Log::DEBUG, "CECConfig:"/*,config->string()*/);
+}
+
+#else
 
 int RemoteLinux::cecLogMessage(void *param, const cec_log_message message)
 {
@@ -958,6 +1030,8 @@ int RemoteLinux::cecConfigurationChanged(void *param, const libcec_configuration
 
 }
 
+#endif
+
 void  RemoteLinux::cecSourceActivated(void*param, const cec_logical_address address, const uint8_t activated)
 {
        Log::getInstance()->log("Remote", Log::DEBUG, "CECSourceActivated: %d %d", address, activated);
@@ -1054,6 +1128,10 @@ void RemoteLinux::volumeDown()
 
 void RemoteLinux::volumeMute()
 {
+#if CEC_LIB_VERSION_MAJOR >= 4
+    cec_adap->AudioToggleMute();
+#else
        cec_adap->MuteAudio();
+#endif
 }
 
index da6b59296cd9250896f5479cf15bd4eb8626f062..84462cfbd534bba9349cfdd321c0d541bef01f54 100644 (file)
@@ -92,11 +92,18 @@ class RemoteLinux : public Remote
     void incomingCECkey(int keys);
     void incomingPowerkey(UCHAR key);
 
+#if CEC_LIB_VERSION_MAJOR >= 4
+       static void cecLogMessage(void *param, const CEC::cec_log_message* message);
+       static void cecKeyPress(void*param, const CEC::cec_keypress* key);
+       static void cecCommand(void *param, const CEC::cec_command* command);
+       static void cecConfigurationChanged(void *param, const CEC::libcec_configuration* config);
+#else
        static int cecLogMessage(void *param, const CEC::cec_log_message message);
        static int cecKeyPress(void*param, const CEC::cec_keypress key);
        static int cecCommand(void *param, const CEC::cec_command command);
        static int cecConfigurationChanged(void *param, const CEC::libcec_configuration config);
-       static void cecSourceActivated(void*param, const CEC::cec_logical_address address, const uint8_t activated);
+#endif
+    static void cecSourceActivated(void*param, const CEC::cec_logical_address address, const uint8_t activated);
 
 };