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