From 5f2f3609d7ee857ac7e5d03600fbd735e99c892f Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 14 May 2012 15:05:34 +0200 Subject: [PATCH] cec: bump version to 1.6.3. check the client version, not the server version in libcec_configuration::operator==(). added a new setting, bMonitorOnly, which will start a monitor-only client. --- include/cec.h | 2 +- include/cectypes.h | 22 ++++++++++++++-------- src/lib/CECClient.cpp | 16 ++++++++++++++++ src/lib/CECProcessor.cpp | 11 +++++++++-- src/lib/LibCEC.cpp | 4 ++++ 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/include/cec.h b/include/cec.h index fada217..abfde74 100644 --- a/include/cec.h +++ b/include/cec.h @@ -36,7 +36,7 @@ #include "cectypes.h" -#define LIBCEC_VERSION_CURRENT CEC_SERVER_VERSION_1_6_2 +#define LIBCEC_VERSION_CURRENT CEC_SERVER_VERSION_1_6_3 namespace CEC { diff --git a/include/cectypes.h b/include/cectypes.h index d70fc81..a8ff6f6 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -1188,7 +1188,8 @@ typedef enum cec_client_version CEC_CLIENT_VERSION_1_5_3 = 0x1503, CEC_CLIENT_VERSION_1_6_0 = 0x1600, CEC_CLIENT_VERSION_1_6_1 = 0x1601, - CEC_CLIENT_VERSION_1_6_2 = 0x1602 + CEC_CLIENT_VERSION_1_6_2 = 0x1602, + CEC_CLIENT_VERSION_1_6_3 = 0x1603 } cec_client_version; typedef enum cec_server_version @@ -1200,7 +1201,8 @@ typedef enum cec_server_version CEC_SERVER_VERSION_1_5_3 = 0x1503, CEC_SERVER_VERSION_1_6_0 = 0x1600, CEC_SERVER_VERSION_1_6_1 = 0x1601, - CEC_SERVER_VERSION_1_6_2 = 0x1602 + CEC_SERVER_VERSION_1_6_2 = 0x1602, + CEC_SERVER_VERSION_1_6_3 = 0x1603 } cec_server_version; typedef struct libcec_configuration @@ -1235,6 +1237,7 @@ typedef struct libcec_configuration uint8_t bShutdownOnStandby; /*!< shutdown this PC when the TV is switched off. only used when bPowerOffOnStandby = 0. added in 1.6.0 */ char strDeviceLanguage[3]; /*!< the menu language used by the client. 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/ added in 1.6.2 */ uint32_t iFirmwareBuildDate; /*!< the build date of the firmware, in seconds since epoch. if not available, this value will be set to 0. added in 1.6.2 */ + uint8_t bMonitorOnly; /*!< won't allocate a CCECClient when starting the connection when set (same as monitor mode). added in 1.6.3 */ #ifdef __cplusplus libcec_configuration(void) { Clear(); } @@ -1260,14 +1263,16 @@ typedef struct libcec_configuration bPowerOffOnStandby == other.bPowerOffOnStandby && bSendInactiveSource == other.bSendInactiveSource && /* libcec 1.5.3+ */ - (other.serverVersion < CEC_SERVER_VERSION_1_5_3 || logicalAddresses == other.logicalAddresses) && + (other.clientVersion < CEC_CLIENT_VERSION_1_5_3 || logicalAddresses == other.logicalAddresses) && /* libcec 1.6.0+ */ - (other.serverVersion < CEC_SERVER_VERSION_1_6_0 || iFirmwareVersion == other.iFirmwareVersion) && - (other.serverVersion < CEC_SERVER_VERSION_1_6_0 || bPowerOffDevicesOnStandby == other.bPowerOffDevicesOnStandby) && - (other.serverVersion < CEC_SERVER_VERSION_1_6_0 || bShutdownOnStandby == other.bShutdownOnStandby) && + (other.clientVersion < CEC_CLIENT_VERSION_1_6_0 || iFirmwareVersion == other.iFirmwareVersion) && + (other.clientVersion < CEC_CLIENT_VERSION_1_6_0 || bPowerOffDevicesOnStandby == other.bPowerOffDevicesOnStandby) && + (other.clientVersion < CEC_CLIENT_VERSION_1_6_0 || bShutdownOnStandby == other.bShutdownOnStandby) && /* libcec 1.6.2+ */ - (other.serverVersion < CEC_SERVER_VERSION_1_6_2 || !strncmp(strDeviceLanguage, other.strDeviceLanguage, 3)) && - (other.serverVersion < CEC_SERVER_VERSION_1_6_2 || iFirmwareBuildDate == other.iFirmwareBuildDate)); + (other.clientVersion < CEC_CLIENT_VERSION_1_6_2 || !strncmp(strDeviceLanguage, other.strDeviceLanguage, 3)) && + (other.clientVersion < CEC_CLIENT_VERSION_1_6_2 || iFirmwareBuildDate == other.iFirmwareBuildDate) && + /* libcec 1.6.3+ */ + (other.clientVersion < CEC_CLIENT_VERSION_1_6_3 || bMonitorOnly == other.bMonitorOnly)); } bool operator!=(const libcec_configuration &other) const @@ -1298,6 +1303,7 @@ typedef struct libcec_configuration bPowerOffDevicesOnStandby = CEC_DEFAULT_SETTING_POWER_OFF_DEVICES_STANDBY; memcpy(strDeviceLanguage, CEC_DEFAULT_DEVICE_LANGUAGE, 3); iFirmwareBuildDate = CEC_FW_BUILD_UNKNOWN; + bMonitorOnly = 0; memset(strDeviceName, 0, 13); deviceTypes.clear(); diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index 013a765..24f196f 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -741,6 +741,13 @@ bool CCECClient::GetCurrentConfiguration(libcec_configuration &configuration) memcpy(configuration.strDeviceLanguage, m_configuration.strDeviceLanguage, 3); configuration.iFirmwareBuildDate = m_configuration.iFirmwareBuildDate; } + + // client version 1.6.3 + if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_6_3) + { + configuration.bMonitorOnly = m_configuration.bMonitorOnly; + } + return true; } @@ -792,6 +799,12 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration) memcpy(m_configuration.strDeviceLanguage, configuration.strDeviceLanguage, 3); } + // client version 1.6.3 + if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_6_3) + { + m_configuration.bMonitorOnly = configuration.bMonitorOnly; + } + // ensure that there is at least 1 device type set if (m_configuration.deviceTypes.IsEmpty()) m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE); @@ -1175,7 +1188,10 @@ bool CCECClient::SwitchMonitoring(bool bEnable) if (bEnable) return m_processor->UnregisterClient(this); else + { + m_configuration.bMonitorOnly = false; return m_processor->RegisterClient(this); + } } return false; diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index e90d5cb..df04a23 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -615,7 +615,15 @@ CCECTuner *CCECProcessor::GetTuner(cec_logical_address address) const bool CCECProcessor::RegisterClient(CCECClient *client) { - if (!client || !CECInitialised()) + if (!client) + return false; + + libcec_configuration &configuration = *client->GetConfiguration(); + + if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_6_3 && configuration.bMonitorOnly == 1) + return true; + + if (!CECInitialised()) { m_libcec->AddLog(CEC_LOG_ERROR, "failed to register a new CEC client: CEC processor is not initialised"); return false; @@ -626,7 +634,6 @@ bool CCECProcessor::RegisterClient(CCECClient *client) UnregisterClient(client); // get the configuration from the client - libcec_configuration &configuration = *client->GetConfiguration(); m_libcec->AddLog(CEC_LOG_NOTICE, "registering new CEC client - v%s", ToString((cec_client_version)configuration.clientVersion)); // mark as uninitialised and unregistered diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 9eaf9ce..b64cdc7 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -823,6 +823,8 @@ const char *CLibCEC::ToString(const cec_client_version version) return "1.6.1"; case CEC_CLIENT_VERSION_1_6_2: return "1.6.2"; + case CEC_CLIENT_VERSION_1_6_3: + return "1.6.3"; default: return "Unknown"; } @@ -848,6 +850,8 @@ const char *CLibCEC::ToString(const cec_server_version version) return "1.6.1"; case CEC_SERVER_VERSION_1_6_2: return "1.6.2"; + case CEC_SERVER_VERSION_1_6_3: + return "1.6.3"; default: return "Unknown"; } -- 2.34.1