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);
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;
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;
}
}
}
+#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)
{
}
+#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);
void RemoteLinux::volumeMute()
{
+#if CEC_LIB_VERSION_MAJOR >= 4
+ cec_adap->AudioToggleMute();
+#else
cec_adap->MuteAudio();
+#endif
}
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);
};