Skip to content

Commit a8259e9

Browse files
committed
autogenerated version numbers, drop some backwards compat code
1 parent c87595c commit a8259e9

15 files changed

+119
-236
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*.user
1919
*.aps
2020
env.h
21+
version.h
2122

2223
*.rc
2324
AssemblyInfo.cs

CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ project(libcec)
22
cmake_minimum_required(VERSION 2.6)
33

44
set(LIBCEC_VERSION_MAJOR 2)
5-
set(LIBCEC_VERSION_MINOR 2)
5+
set(LIBCEC_VERSION_MINOR 3)
66
set(LIBCEC_VERSION_PATCH 0)
77

88
# cec-client
@@ -12,6 +12,10 @@ add_dependencies(cec-client cec)
1212
# libCEC
1313
add_subdirectory(src/libcec)
1414

15+
# version number
16+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/version.h.in
17+
${CMAKE_CURRENT_SOURCE_DIR}/include/version.h)
18+
1519
# resource files for windows
1620
if(WIN32)
1721
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/project/LibCecSharp/LibCecSharp.rc.in

include/cec.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
#define CECEXPORTS_H_
3636

3737
#include "cectypes.h"
38-
39-
#define LIBCEC_VERSION_CURRENT CEC_SERVER_VERSION_CURRENT
38+
#include <string>
4039

4140
namespace CEC
4241
{
@@ -419,10 +418,9 @@ namespace CEC
419418
virtual const char *ToString(const cec_system_audio_status mode) = 0;
420419
virtual const char *ToString(const cec_audio_status status) = 0;
421420
virtual const char *ToString(const cec_vendor_id vendor) = 0;
422-
virtual const char *ToString(const cec_client_version version) = 0;
423-
virtual const char *ToString(const cec_server_version version) = 0;
424421
virtual const char *ToString(const cec_user_control_code key) = 0;
425422
virtual const char *ToString(const cec_adapter_type type) = 0;
423+
virtual std::string VersionToString(uint32_t version) = 0;
426424

427425
/*!
428426
* @brief Toggle the mute status of the AVR (if present)

include/cectypes.h

+8-72
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#ifndef CECTYPES_H_
3535
#define CECTYPES_H_
3636

37+
#include "version.h"
3738
#include <stdint.h>
3839
#include <string.h>
3940

@@ -1424,73 +1425,8 @@ typedef struct ICECCallbacks
14241425
#endif
14251426
} ICECCallbacks;
14261427

1427-
typedef enum cec_client_version
1428-
{
1429-
CEC_CLIENT_VERSION_PRE_1_5 = 0,
1430-
CEC_CLIENT_VERSION_1_5_0 = 0x1500,
1431-
CEC_CLIENT_VERSION_1_5_1 = 0x1501,
1432-
CEC_CLIENT_VERSION_1_5_2 = 0x1502,
1433-
CEC_CLIENT_VERSION_1_5_3 = 0x1503,
1434-
CEC_CLIENT_VERSION_1_6_0 = 0x1600,
1435-
CEC_CLIENT_VERSION_1_6_1 = 0x1601,
1436-
CEC_CLIENT_VERSION_1_6_2 = 0x1602,
1437-
CEC_CLIENT_VERSION_1_6_3 = 0x1603,
1438-
CEC_CLIENT_VERSION_1_7_0 = 0x1700,
1439-
CEC_CLIENT_VERSION_1_7_1 = 0x1701,
1440-
CEC_CLIENT_VERSION_1_7_2 = 0x1702,
1441-
CEC_CLIENT_VERSION_1_8_0 = 0x1800,
1442-
CEC_CLIENT_VERSION_1_8_1 = 0x1801,
1443-
CEC_CLIENT_VERSION_1_8_2 = 0x1802,
1444-
CEC_CLIENT_VERSION_1_9_0 = 0x1900,
1445-
CEC_CLIENT_VERSION_1_99_0 = 0x1990,
1446-
CEC_CLIENT_VERSION_2_0_0 = 0x2000,
1447-
CEC_CLIENT_VERSION_2_0_1 = 0x2001,
1448-
CEC_CLIENT_VERSION_2_0_2 = 0x2002,
1449-
CEC_CLIENT_VERSION_2_0_3 = 0x2003,
1450-
CEC_CLIENT_VERSION_2_0_4 = 0x2004,
1451-
CEC_CLIENT_VERSION_2_0_5 = 0x2005,
1452-
CEC_CLIENT_VERSION_2_1_0 = 0x2100,
1453-
CEC_CLIENT_VERSION_2_1_1 = 0x2101,
1454-
CEC_CLIENT_VERSION_2_1_2 = 0x2102,
1455-
CEC_CLIENT_VERSION_2_1_3 = 0x2103,
1456-
CEC_CLIENT_VERSION_2_1_4 = 0x2104,
1457-
CEC_CLIENT_VERSION_2_2_0 = 0x2200,
1458-
CEC_CLIENT_VERSION_CURRENT = 0x2200
1459-
} cec_client_version;
1460-
1461-
typedef enum cec_server_version
1462-
{
1463-
CEC_SERVER_VERSION_PRE_1_5 = 0,
1464-
CEC_SERVER_VERSION_1_5_0 = 0x1500,
1465-
CEC_SERVER_VERSION_1_5_1 = 0x1501,
1466-
CEC_SERVER_VERSION_1_5_2 = 0x1502,
1467-
CEC_SERVER_VERSION_1_5_3 = 0x1503,
1468-
CEC_SERVER_VERSION_1_6_0 = 0x1600,
1469-
CEC_SERVER_VERSION_1_6_1 = 0x1601,
1470-
CEC_SERVER_VERSION_1_6_2 = 0x1602,
1471-
CEC_SERVER_VERSION_1_6_3 = 0x1603,
1472-
CEC_SERVER_VERSION_1_7_0 = 0x1700,
1473-
CEC_SERVER_VERSION_1_7_1 = 0x1701,
1474-
CEC_SERVER_VERSION_1_7_2 = 0x1702,
1475-
CEC_SERVER_VERSION_1_8_0 = 0x1800,
1476-
CEC_SERVER_VERSION_1_8_1 = 0x1801,
1477-
CEC_SERVER_VERSION_1_8_2 = 0x1802,
1478-
CEC_SERVER_VERSION_1_9_0 = 0x1900,
1479-
CEC_SERVER_VERSION_1_99_0 = 0x1990,
1480-
CEC_SERVER_VERSION_2_0_0 = 0x2000,
1481-
CEC_SERVER_VERSION_2_0_1 = 0x2001,
1482-
CEC_SERVER_VERSION_2_0_2 = 0x2002,
1483-
CEC_SERVER_VERSION_2_0_3 = 0x2003,
1484-
CEC_SERVER_VERSION_2_0_4 = 0x2004,
1485-
CEC_SERVER_VERSION_2_0_5 = 0x2005,
1486-
CEC_SERVER_VERSION_2_1_0 = 0x2100,
1487-
CEC_SERVER_VERSION_2_1_1 = 0x2101,
1488-
CEC_SERVER_VERSION_2_1_2 = 0x2102,
1489-
CEC_SERVER_VERSION_2_1_3 = 0x2103,
1490-
CEC_SERVER_VERSION_2_1_4 = 0x2104,
1491-
CEC_SERVER_VERSION_2_2_0 = 0x2200,
1492-
CEC_SERVER_VERSION_CURRENT = 0x2200
1493-
} cec_server_version;
1428+
typedef uint32_t cec_client_version2;
1429+
typedef uint32_t cec_server_version2;
14941430

14951431
struct libcec_configuration
14961432
{
@@ -1566,9 +1502,9 @@ struct libcec_configuration
15661502
cecVersion == other.cecVersion &&
15671503
adapterType == other.adapterType &&
15681504
iDoubleTapTimeout50Ms == other.iDoubleTapTimeout50Ms &&
1569-
(other.clientVersion <= CEC_CLIENT_VERSION_2_0_4 || comboKey == other.comboKey) &&
1570-
(other.clientVersion <= CEC_CLIENT_VERSION_2_0_4 || iComboKeyTimeoutMs == other.iComboKeyTimeoutMs) &&
1571-
(other.clientVersion < CEC_CLIENT_VERSION_2_1_0 || bPowerOnScreensaver == other.bPowerOnScreensaver));
1505+
(other.clientVersion <= LIBCEC_VERSION_TO_UINT(2, 0, 4) || comboKey == other.comboKey) &&
1506+
(other.clientVersion <= LIBCEC_VERSION_TO_UINT(2, 0, 4) || iComboKeyTimeoutMs == other.iComboKeyTimeoutMs) &&
1507+
(other.clientVersion < LIBCEC_VERSION_TO_UINT(2, 1, 0) || bPowerOnScreensaver == other.bPowerOnScreensaver));
15721508
}
15731509

15741510
bool operator!=(const libcec_configuration &other) const
@@ -1585,8 +1521,8 @@ struct libcec_configuration
15851521
baseDevice = (cec_logical_address)CEC_DEFAULT_BASE_DEVICE;
15861522
iHDMIPort = CEC_DEFAULT_HDMI_PORT;
15871523
tvVendor = (uint64_t)CEC_VENDOR_UNKNOWN;
1588-
clientVersion = (uint32_t)CEC_CLIENT_VERSION_CURRENT;
1589-
serverVersion = (uint32_t)CEC_SERVER_VERSION_CURRENT;
1524+
clientVersion = LIBCEC_VERSION_CURRENT;
1525+
serverVersion = LIBCEC_VERSION_CURRENT;
15901526
bAutodetectAddress = 0;
15911527
bGetSettingsFromROM = CEC_DEFAULT_SETTING_GET_SETTINGS_FROM_ROM;
15921528
bUseTVMenuLanguage = CEC_DEFAULT_SETTING_USE_TV_MENU_LANGUAGE;

include/version.h.in

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#pragma once
2+
/*
3+
* This file is part of the libCEC(R) library.
4+
*
5+
* libCEC(R) is Copyright (C) 2011-2015 Pulse-Eight Limited. All rights reserved.
6+
* libCEC(R) is an original work, containing original code.
7+
*
8+
* libCEC(R) is a trademark of Pulse-Eight Limited.
9+
*
10+
* This program is dual-licensed; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License as published by
12+
* the Free Software Foundation; either version 2 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU General Public License
21+
* along with this program; if not, write to the Free Software
22+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23+
*
24+
*
25+
* Alternatively, you can license this library under a commercial license,
26+
* please contact Pulse-Eight Licensing for more information.
27+
*
28+
* For more information contact:
29+
* Pulse-Eight Licensing <[email protected]>
30+
* http://www.pulse-eight.com/
31+
* http://www.pulse-eight.net/
32+
*/
33+
34+
/**
35+
* Convert a version number to an uint32_t
36+
* @param[in] major Major version number
37+
* @param[in] minor Minor version number
38+
* @param[in] patch Patch number
39+
*
40+
* @return The version number as uint32_t
41+
*/
42+
#define LIBCEC_VERSION_TO_UINT(major, minor, patch) \
43+
((major < 2 || (major == 2 && minor <= 2)) ? \
44+
(uint32_t) (major << 8) | (minor << 4) | (patch) : \
45+
(uint32_t) (major << 16) | (minor << 8) | (patch))
46+
47+
/* new style version numbers, 2.3.0 and later */
48+
#define LIBCEC_UINT_TO_VERSION_MAJOR(x) ((x >> 16) & 0xFF)
49+
#define LIBCEC_UINT_TO_VERSION_MINOR(x) ((x >> 8 ) & 0xFF)
50+
#define LIBCEC_UINT_TO_VERSION_PATCH(x) ((x >> 0 ) & 0xFF)
51+
52+
/* old style version numbers, before 2.3.0 */
53+
#define LIBCEC_UINT_TO_VERSION_MAJOR_OLD(x) ((x >> 8) & 0xFF)
54+
#define LIBCEC_UINT_TO_VERSION_MINOR_OLD(x) ((x >> 4) & 0x0F)
55+
#define LIBCEC_UINT_TO_VERSION_PATCH_OLD(x) ((x >> 0) & 0x0F)
56+
57+
/* current libCEC version number */
58+
#define LIBCEC_VERSION_CURRENT \
59+
LIBCEC_VERSION_TO_UINT(@LIBCEC_VERSION_MAJOR@, @LIBCEC_VERSION_MINOR@, @LIBCEC_VERSION_PATCH@)
60+

src/cec-client/cec-client.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ using namespace CEC;
5050
using namespace std;
5151
using namespace PLATFORM;
5252

53-
#define CEC_CONFIG_VERSION CEC_CLIENT_VERSION_CURRENT;
54-
5553
#include "cecloader.h"
5654

5755
static void PrintToStdOut(const char *strFormat, ...);
@@ -235,9 +233,9 @@ int CecAlert(void *UNUSED(cbParam), const libcec_alert type, const libcec_parame
235233
void ListDevices(ICECAdapter *parser)
236234
{
237235
cec_adapter_descriptor devices[10];
238-
std::string strMessage = StringUtils::Format("libCEC version: %s", parser->ToString((cec_server_version)g_config.serverVersion));
239-
if (g_config.serverVersion >= CEC_SERVER_VERSION_1_7_2)
240-
strMessage += StringUtils::Format(", %s", parser->GetLibInfo());
236+
std::string strMessage = StringUtils::Format("libCEC version: %s, %s",
237+
parser->VersionToString(g_config.serverVersion).c_str(),
238+
parser->GetLibInfo());
241239
PrintToStdOut(strMessage.c_str());
242240

243241
int8_t iDevicesFound = parser->DetectAdapters(devices, 10, NULL);
@@ -1095,9 +1093,9 @@ bool ProcessCommandLineArguments(int argc, char *argv[])
10951093
if (parser)
10961094
{
10971095
std::string strMessage;
1098-
strMessage = StringUtils::Format("libCEC version: %s", parser->ToString((cec_server_version)g_config.serverVersion));
1099-
if (g_config.serverVersion >= CEC_SERVER_VERSION_1_7_2)
1100-
strMessage += StringUtils::Format(", %s", parser->GetLibInfo());
1096+
strMessage = StringUtils::Format("libCEC version: %s, %s",
1097+
parser->VersionToString(g_config.serverVersion).c_str(),
1098+
parser->GetLibInfo());
11011099
PrintToStdOut(strMessage.c_str());
11021100
UnloadLibCec(parser);
11031101
parser = NULL;
@@ -1217,7 +1215,7 @@ int main (int argc, char *argv[])
12171215
g_config.Clear();
12181216
g_callbacks.Clear();
12191217
snprintf(g_config.strDeviceName, 13, "CECTester");
1220-
g_config.clientVersion = CEC_CONFIG_VERSION;
1218+
g_config.clientVersion = LIBCEC_VERSION_CURRENT;
12211219
g_config.bActivateSource = 0;
12221220
g_callbacks.CBCecLogMessage = &CecLogMessage;
12231221
g_callbacks.CBCecKeyPress = &CecKeyPress;
@@ -1259,7 +1257,7 @@ int main (int argc, char *argv[])
12591257
if (!g_bSingleCommand)
12601258
{
12611259
std::string strLog;
1262-
strLog = StringUtils::Format("CEC Parser created - libCEC version %s", g_parser->ToString((cec_server_version)g_config.serverVersion));
1260+
strLog = StringUtils::Format("CEC Parser created - libCEC version %s", g_parser->VersionToString(g_config.serverVersion).c_str());
12631261
cout << strLog.c_str() << endl;
12641262

12651263
//make stdin non-blocking

src/libcec/CECClient.cpp

+15-12
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration)
853853
EnableCallbacks(configuration.callbackParam, configuration.callbacks);
854854

855855
// update the client version
856-
SetClientVersion((cec_client_version)configuration.clientVersion);
856+
SetClientVersion(configuration.clientVersion);
857857

858858
// update the OSD name
859859
std::string strOSDName(configuration.strDeviceName);
@@ -882,7 +882,7 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration)
882882
m_configuration.iDoubleTapTimeout50Ms = configuration.iDoubleTapTimeout50Ms;
883883
m_configuration.deviceTypes.Add(configuration.deviceTypes[0]);
884884

885-
if (m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5)
885+
if (m_configuration.clientVersion >= LIBCEC_VERSION_TO_UINT(2, 0, 5))
886886
{
887887
m_configuration.comboKey = configuration.comboKey;
888888
m_configuration.iComboKeyTimeoutMs = configuration.iComboKeyTimeoutMs;
@@ -893,7 +893,7 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration)
893893
m_configuration.iComboKeyTimeoutMs = defaultSettings.iComboKeyTimeoutMs;
894894
}
895895

896-
if (m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_1_0)
896+
if (m_configuration.clientVersion >= LIBCEC_VERSION_TO_UINT(2, 1, 0))
897897
m_configuration.bPowerOnScreensaver = configuration.bPowerOnScreensaver;
898898
else
899899
m_configuration.bPowerOnScreensaver = defaultSettings.bPowerOnScreensaver;
@@ -1007,7 +1007,7 @@ void CCECClient::AddKey(const cec_keypress &key)
10071007
}
10081008

10091009
cec_keypress transmitKey(key);
1010-
cec_user_control_code comboKey(m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5 ?
1010+
cec_user_control_code comboKey(m_configuration.clientVersion >= LIBCEC_VERSION_TO_UINT(2, 0, 5) ?
10111011
m_configuration.comboKey : CEC_USER_CONTROL_CODE_STOP);
10121012

10131013
{
@@ -1067,9 +1067,9 @@ void CCECClient::CheckKeypressTimeout(void)
10671067
{
10681068
CLockObject lock(m_mutex);
10691069
uint64_t iNow = GetTimeMs();
1070-
cec_user_control_code comboKey(m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5 ?
1070+
cec_user_control_code comboKey(m_configuration.clientVersion >= LIBCEC_VERSION_TO_UINT(2, 0, 5) ?
10711071
m_configuration.comboKey : CEC_USER_CONTROL_CODE_STOP);
1072-
uint32_t iTimeoutMs(m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_0_5 ?
1072+
uint32_t iTimeoutMs(m_configuration.clientVersion >= LIBCEC_VERSION_TO_UINT(2, 0, 5) ?
10731073
m_configuration.iComboKeyTimeoutMs : CEC_DEFAULT_COMBO_TIMEOUT_MS);
10741074

10751075
if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN &&
@@ -1108,7 +1108,10 @@ bool CCECClient::PingAdapter(void)
11081108
std::string CCECClient::GetConnectionInfo(void)
11091109
{
11101110
std::string strLog;
1111-
strLog = StringUtils::Format("libCEC version = %s, client version = %s, firmware version = %d", ToString((cec_server_version)m_configuration.serverVersion), ToString((cec_client_version)m_configuration.clientVersion), m_configuration.iFirmwareVersion);
1111+
strLog = StringUtils::Format("libCEC version = %s, client version = %s, firmware version = %d",
1112+
CCECTypeUtils::VersionToString(m_configuration.serverVersion).c_str(),
1113+
CCECTypeUtils::VersionToString(m_configuration.clientVersion).c_str(),
1114+
m_configuration.iFirmwareVersion);
11121115
if (m_configuration.iFirmwareBuildDate != CEC_FW_BUILD_UNKNOWN)
11131116
{
11141117
time_t buildTime = (time_t)m_configuration.iFirmwareBuildDate;
@@ -1229,18 +1232,18 @@ bool CCECClient::AutodetectPhysicalAddress(void)
12291232
return bPhysicalAutodetected;
12301233
}
12311234

1232-
void CCECClient::SetClientVersion(const cec_client_version version)
1235+
void CCECClient::SetClientVersion(uint32_t version)
12331236
{
1234-
LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - using client version '%s'", __FUNCTION__, ToString(version));
1237+
LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - using client version '%s'", __FUNCTION__, CCECTypeUtils::VersionToString(version).c_str());
12351238

12361239
CLockObject lock(m_mutex);
12371240
m_configuration.clientVersion = (uint32_t)version;
12381241
}
12391242

1240-
cec_client_version CCECClient::GetClientVersion(void)
1243+
uint32_t CCECClient::GetClientVersion(void)
12411244
{
12421245
CLockObject lock(m_mutex);
1243-
return (cec_client_version)m_configuration.clientVersion;
1246+
return m_configuration.clientVersion;
12441247
}
12451248

12461249
bool CCECClient::SetDeviceTypes(const cec_device_type_list &deviceTypes)
@@ -1463,7 +1466,7 @@ void CCECClient::CallbackAddCommand(const cec_command &command)
14631466
uint32_t CCECClient::DoubleTapTimeoutMS(void)
14641467
{
14651468
CLockObject lock(m_cbMutex);
1466-
return m_configuration.clientVersion >= CEC_CLIENT_VERSION_2_2_0 ?
1469+
return m_configuration.clientVersion >= LIBCEC_VERSION_TO_UINT(2, 2, 0) ?
14671470
m_configuration.iDoubleTapTimeout50Ms * DOUBLE_TAP_TIMEOUT_UNIT_SIZE :
14681471
m_configuration.iDoubleTapTimeout50Ms;
14691472
}

src/libcec/CECClient.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace CEC
118118
/*!
119119
* @return The version of this client.
120120
*/
121-
virtual cec_client_version GetClientVersion(void);
121+
virtual uint32_t GetClientVersion(void);
122122

123123
/*!
124124
* @return The device types that this client is controlling.
@@ -233,7 +233,7 @@ namespace CEC
233233
* @brief Change the value of the client version setting.
234234
* @param version The new version setting.
235235
*/
236-
virtual void SetClientVersion(const cec_client_version version);
236+
virtual void SetClientVersion(uint32_t version);
237237

238238
/*!
239239
* @brief Change the device types that this client is controlling.

0 commit comments

Comments
 (0)