fixed, classes with virtual methods must have a virtual destructor
[deb_libcec.git] / include / CECExports.h
... / ...
CommitLineData
1#pragma once
2/*
3 * This file is part of the libCEC(R) library.
4 *
5 * libCEC(R) is Copyright (C) 2011 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 <license@pulse-eight.com>
30 * http://www.pulse-eight.com/
31 * http://www.pulse-eight.net/
32 */
33
34#ifndef CECEXPORTS_H_
35#define CECEXPORTS_H_
36
37#include <stdint.h>
38#include <string.h>
39
40#if !defined(DECLSPEC)
41#if defined(_WIN32) || defined(_WIN64)
42#include <windows.h>
43#if defined DLL_EXPORT
44#define DECLSPEC __declspec(dllexport)
45#else
46#define DECLSPEC __declspec(dllimport)
47#endif
48#else
49#define DECLSPEC
50#endif
51#endif
52
53#ifdef __cplusplus
54extern "C" {
55namespace CEC {
56#endif
57 #define CEC_MIN_VERSION 5
58 #define CEC_LIB_VERSION 5
59 #define CEC_SETTLE_DOWN_TIME 1000
60 #define CEC_BUTTON_TIMEOUT 500
61
62 typedef enum cec_user_control_code
63 {
64 CEC_USER_CONTROL_CODE_SELECT = 0x00,
65 CEC_USER_CONTROL_CODE_UP = 0x01,
66 CEC_USER_CONTROL_CODE_DOWN = 0x02,
67 CEC_USER_CONTROL_CODE_LEFT = 0x03,
68 CEC_USER_CONTROL_CODE_RIGHT = 0x04,
69 CEC_USER_CONTROL_CODE_RIGHT_UP = 0x05,
70 CEC_USER_CONTROL_CODE_RIGHT_DOWN = 0x06,
71 CEC_USER_CONTROL_CODE_LEFT_UP = 0x07,
72 CEC_USER_CONTROL_CODE_LEFT_DOWN = 0x08,
73 CEC_USER_CONTROL_CODE_ROOT_MENU = 0x09,
74 CEC_USER_CONTROL_CODE_SETUP_MENU = 0x0A,
75 CEC_USER_CONTROL_CODE_CONTENTS_MENU = 0x0B,
76 CEC_USER_CONTROL_CODE_FAVORITE_MENU = 0x0C,
77 CEC_USER_CONTROL_CODE_EXIT = 0x0D,
78 CEC_USER_CONTROL_CODE_NUMBER0 = 0x20,
79 CEC_USER_CONTROL_CODE_NUMBER1 = 0x21,
80 CEC_USER_CONTROL_CODE_NUMBER2 = 0x22,
81 CEC_USER_CONTROL_CODE_NUMBER3 = 0x23,
82 CEC_USER_CONTROL_CODE_NUMBER4 = 0x24,
83 CEC_USER_CONTROL_CODE_NUMBER5 = 0x25,
84 CEC_USER_CONTROL_CODE_NUMBER6 = 0x26,
85 CEC_USER_CONTROL_CODE_NUMBER7 = 0x27,
86 CEC_USER_CONTROL_CODE_NUMBER8 = 0x28,
87 CEC_USER_CONTROL_CODE_NUMBER9 = 0x29,
88 CEC_USER_CONTROL_CODE_DOT = 0x2A,
89 CEC_USER_CONTROL_CODE_ENTER = 0x2B,
90 CEC_USER_CONTROL_CODE_CLEAR = 0x2C,
91 CEC_USER_CONTROL_CODE_NEXT_FAVORITE = 0x2F,
92 CEC_USER_CONTROL_CODE_CHANNEL_UP = 0x30,
93 CEC_USER_CONTROL_CODE_CHANNEL_DOWN = 0x31,
94 CEC_USER_CONTROL_CODE_PREVIOUS_CHANNEL = 0x32,
95 CEC_USER_CONTROL_CODE_SOUND_SELECT = 0x33,
96 CEC_USER_CONTROL_CODE_INPUT_SELECT = 0x34,
97 CEC_USER_CONTROL_CODE_DISPLAY_INFORMATION = 0x35,
98 CEC_USER_CONTROL_CODE_HELP = 0x36,
99 CEC_USER_CONTROL_CODE_PAGE_UP = 0x37,
100 CEC_USER_CONTROL_CODE_PAGE_DOWN = 0x38,
101 CEC_USER_CONTROL_CODE_POWER = 0x40,
102 CEC_USER_CONTROL_CODE_VOLUME_UP = 0x41,
103 CEC_USER_CONTROL_CODE_VOLUME_DOWN = 0x42,
104 CEC_USER_CONTROL_CODE_MUTE = 0x43,
105 CEC_USER_CONTROL_CODE_PLAY = 0x44,
106 CEC_USER_CONTROL_CODE_STOP = 0x45,
107 CEC_USER_CONTROL_CODE_PAUSE = 0x46,
108 CEC_USER_CONTROL_CODE_RECORD = 0x47,
109 CEC_USER_CONTROL_CODE_REWIND = 0x48,
110 CEC_USER_CONTROL_CODE_FAST_FORWARD = 0x49,
111 CEC_USER_CONTROL_CODE_EJECT = 0x4A,
112 CEC_USER_CONTROL_CODE_FORWARD = 0x4B,
113 CEC_USER_CONTROL_CODE_BACKWARD = 0x4C,
114 CEC_USER_CONTROL_CODE_STOP_RECORD = 0x4D,
115 CEC_USER_CONTROL_CODE_PAUSE_RECORD = 0x4E,
116 CEC_USER_CONTROL_CODE_ANGLE = 0x50,
117 CEC_USER_CONTROL_CODE_SUB_PICTURE = 0x51,
118 CEC_USER_CONTROL_CODE_VIDEO_ON_DEMAND = 0x52,
119 CEC_USER_CONTROL_CODE_ELECTRONIC_PROGRAM_GUIDE = 0x53,
120 CEC_USER_CONTROL_CODE_TIMER_PROGRAMMING = 0x54,
121 CEC_USER_CONTROL_CODE_INITIAL_CONFIGURATION = 0x55,
122 CEC_USER_CONTROL_CODE_PLAY_FUNCTION = 0x60,
123 CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION = 0x61,
124 CEC_USER_CONTROL_CODE_RECORD_FUNCTION = 0x62,
125 CEC_USER_CONTROL_CODE_PAUSE_RECORD_FUNCTION = 0x63,
126 CEC_USER_CONTROL_CODE_STOP_FUNCTION = 0x64,
127 CEC_USER_CONTROL_CODE_MUTE_FUNCTION = 0x65,
128 CEC_USER_CONTROL_CODE_RESTORE_VOLUME_FUNCTION = 0x66,
129 CEC_USER_CONTROL_CODE_TUNE_FUNCTION = 0x67,
130 CEC_USER_CONTROL_CODE_SELECT_MEDIA_FUNCTION = 0x68,
131 CEC_USER_CONTROL_CODE_SELECT_AV_INPUT_FUNCTION = 0x69,
132 CEC_USER_CONTROL_CODE_SELECT_AUDIO_INPUT_FUNCTION = 0x6A,
133 CEC_USER_CONTROL_CODE_POWER_TOGGLE_FUNCTION = 0x6B,
134 CEC_USER_CONTROL_CODE_POWER_OFF_FUNCTION = 0x6C,
135 CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION = 0x6D,
136 CEC_USER_CONTROL_CODE_F1_BLUE = 0x71,
137 CEC_USER_CONTROL_CODE_F2_RED = 0X72,
138 CEC_USER_CONTROL_CODE_F3_GREEN = 0x73,
139 CEC_USER_CONTROL_CODE_F4_YELLOW = 0x74,
140 CEC_USER_CONTROL_CODE_F5 = 0x75,
141 CEC_USER_CONTROL_CODE_DATA = 0x76,
142 CEC_USER_CONTROL_CODE_MAX = 0x76,
143 CEC_USER_CONTROL_CODE_UNKNOWN
144 } cec_user_control_code;
145
146 typedef enum cec_logical_address
147 {
148 CECDEVICE_UNKNOWN = -1, //not a valid logical address
149 CECDEVICE_TV,
150 CECDEVICE_RECORDINGDEVICE1,
151 CECDEVICE_RECORDINGDEVICE2,
152 CECDEVICE_TUNER1,
153 CECDEVICE_PLAYBACKDEVICE1,
154 CECDEVICE_AUDIOSYSTEM,
155 CECDEVICE_TUNER2,
156 CECDEVICE_TUNER3,
157 CECDEVICE_PLAYBACKDEVICE2,
158 CECDEVICE_RECORDINGDEVICE3,
159 CECDEVICE_TUNER4,
160 CECDEVICE_PLAYBACKDEVICE3,
161 CECDEVICE_RESERVED1,
162 CECDEVICE_RESERVED2,
163 CECDEVICE_FREEUSE,
164 CECDEVICE_UNREGISTERED = 15,
165 CECDEVICE_BROADCAST = 15
166 } cec_logical_address;
167
168 typedef enum cec_opcode
169 {
170 CEC_OPCODE_ACTIVE_SOURCE = 0x82,
171 CEC_OPCODE_IMAGE_VIEW_ON = 0x04,
172 CEC_OPCODE_TEXT_VIEW_ON = 0x0D,
173 CEC_OPCODE_INACTIVE_SOURCE = 0x9D,
174 CEC_OPCODE_REQUEST_ACTIVE_SOURCE = 0x85,
175 CEC_OPCODE_ROUTING_CHANGE = 0x80,
176 CEC_OPCODE_ROUTING_INFORMATION = 0x81,
177 CEC_OPCODE_SET_STREAM_PATH = 0x86,
178 CEC_OPCODE_STANDBY = 0x36,
179 CEC_OPCODE_RECORD_OFF = 0x0B,
180 CEC_OPCODE_RECORD_ON = 0x09,
181 CEC_OPCODE_RECORD_STATUS = 0x0A,
182 CEC_OPCODE_RECORD_TV_SCREEN = 0x0F,
183 CEC_OPCODE_CLEAR_ANALOGUE_TIMER = 0x33,
184 CEC_OPCODE_CLEAR_DIGITAL_TIMER = 0x99,
185 CEC_OPCODE_CLEAR_EXTERNAL_TIMER = 0xA1,
186 CEC_OPCODE_SET_ANALOGUE_TIMER = 0x34,
187 CEC_OPCODE_SET_DIGITAL_TIMER = 0x97,
188 CEC_OPCODE_SET_EXTERNAL_TIMER = 0xA2,
189 CEC_OPCODE_SET_TIMER_PROGRAM_TITLE = 0x67,
190 CEC_OPCODE_TIMER_CLEARED_STATUS = 0x43,
191 CEC_OPCODE_TIMER_STATUS = 0x35,
192 CEC_OPCODE_CEC_VERSION = 0x9E,
193 CEC_OPCODE_GET_CEC_VERSION = 0x9F,
194 CEC_OPCODE_GIVE_PHYSICAL_ADDRESS = 0x83,
195 CEC_OPCODE_GET_MENU_LANGUAGE = 0x91,
196 CEC_OPCODE_REPORT_PHYSICAL_ADDRESS = 0x84,
197 CEC_OPCODE_SET_MENU_LANGUAGE = 0x32,
198 CEC_OPCODE_DECK_CONTROL = 0x42,
199 CEC_OPCODE_DECK_STATUS = 0x1B,
200 CEC_OPCODE_GIVE_DECK_STATUS = 0x1A,
201 CEC_OPCODE_PLAY = 0x41,
202 CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS = 0x08,
203 CEC_OPCODE_SELECT_ANALOGUE_SERVICE = 0x92,
204 CEC_OPCODE_SELECT_DIGITAL_SERVICE = 0x93,
205 CEC_OPCODE_TUNER_DEVICE_STATUS = 0x07,
206 CEC_OPCODE_TUNER_STEP_DECREMENT = 0x06,
207 CEC_OPCODE_TUNER_STEP_INCREMENT = 0x05,
208 CEC_OPCODE_DEVICE_VENDOR_ID = 0x87,
209 CEC_OPCODE_GIVE_DEVICE_VENDOR_ID = 0x8C,
210 CEC_OPCODE_VENDOR_COMMAND = 0x89,
211 CEC_OPCODE_VENDOR_COMMAND_WITH_ID = 0xA0,
212 CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A,
213 CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP = 0x8B,
214 CEC_OPCODE_SET_OSD_STRING = 0x64,
215 CEC_OPCODE_GIVE_OSD_NAME = 0x46,
216 CEC_OPCODE_SET_OSD_NAME = 0x47,
217 CEC_OPCODE_MENU_REQUEST = 0x8D,
218 CEC_OPCODE_MENU_STATUS = 0x8E,
219 CEC_OPCODE_USER_CONTROL_PRESSED = 0x44,
220 CEC_OPCODE_USER_CONTROL_RELEASE = 0x45,
221 CEC_OPCODE_GIVE_DEVICE_POWER_STATUS = 0x8F,
222 CEC_OPCODE_REPORT_POWER_STATUS = 0x90,
223 CEC_OPCODE_FEATURE_ABORT = 0x00,
224 CEC_OPCODE_ABORT = 0xFF,
225 CEC_OPCODE_GIVE_AUDIO_STATUS = 0x71,
226 CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D,
227 CEC_OPCODE_REPORT_AUDIO_STATUS = 0x7A,
228 CEC_OPCODE_SET_SYSTEM_AUDIO_MODE = 0x72,
229 CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST = 0x70,
230 CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS = 0x7E,
231 CEC_OPCODE_SET_AUDIO_RATE = 0x9A
232 } cec_opcode;
233
234 typedef enum cec_log_level
235 {
236 CEC_LOG_DEBUG = 0,
237 CEC_LOG_NOTICE,
238 CEC_LOG_WARNING,
239 CEC_LOG_ERROR
240 } cec_log_level;
241
242 typedef struct cec_log_message
243 {
244 char message[1024];
245 cec_log_level level;
246 int64_t time;
247 } cec_log_message;
248
249 typedef struct cec_keypress
250 {
251 cec_user_control_code keycode;
252 unsigned int duration;
253 } cec_keypress;
254
255 typedef struct cec_adapter
256 {
257 char path[1024];
258 char comm[1024];
259 } cec_adapter;
260
261 typedef struct cec_frame
262 {
263 uint8_t data[20];
264 uint8_t size;
265
266 void shift(uint8_t iShiftBy)
267 {
268 if (iShiftBy >= size)
269 {
270 clear();
271 }
272 else
273 {
274 for (uint8_t iPtr = 0; iPtr < size; iPtr++)
275 data[iPtr] = (iPtr + iShiftBy < size) ? data[iPtr + iShiftBy] : 0;
276 size = (uint8_t) (size - iShiftBy);
277 }
278 }
279
280 void push_back(uint8_t add)
281 {
282 if (size < 20)
283 data[size++] = add;
284 }
285
286 void clear(void)
287 {
288 memset(data, 0, sizeof(data));
289 size = 0;
290 }
291 } cec_frame;
292
293 typedef struct cec_command
294 {
295 cec_logical_address source;
296 cec_logical_address destination;
297 cec_opcode opcode;
298 cec_frame parameters;
299
300 void clear(void)
301 {
302 source = CECDEVICE_UNKNOWN;
303 destination = CECDEVICE_UNKNOWN;
304 opcode = CEC_OPCODE_FEATURE_ABORT;
305 parameters.clear();
306 };
307 } cec_command;
308
309 typedef enum cec_vendor_id
310 {
311 CEC_VENDOR_SAMSUNG = 240,
312 CEC_VENDOR_UNKNOWN = 0
313 } vendor_id;
314
315 static const char *CECVendorIdToString(const uint64_t iVendorId)
316 {
317 switch (iVendorId)
318 {
319 case CEC_VENDOR_SAMSUNG:
320 return "Samsung";
321 default:
322 return "Unknown";
323 }
324 }
325
326 //default physical address 1.0.0.0
327 #define CEC_DEFAULT_PHYSICAL_ADDRESS 0x1000
328
329#ifdef __cplusplus
330};
331
332#include "CECExportsCpp.h"
333#include "CECExportsC.h"
334};
335#else
336#include "CECExportsC.h"
337#endif
338
339#endif /* CECEXPORTS_H_ */