d03bfe0b2d77fd3262cf851caa3a7a799202d7e7
[deb_libcec.git] / include / CECExportsC.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_C_H_
35 #define CECEXPORTS_C_H_
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /*!
42 * @brief Load the CEC adapter library.
43 * @param strDeviceName How to present this device to other devices.
44 * @param iLogicalAddress The logical of this device. PLAYBACKDEVICE1 by default.
45 * @param iPhysicalAddress The physical address of this device. 0x1000 by default.
46 * @return True when initialised, false otherwise.
47 */
48 #ifdef __cplusplus
49 extern DECLSPEC bool cec_init(const char *strDeviceName, CEC::cec_logical_address iLogicalAddress = CEC::CECDEVICE_PLAYBACKDEVICE1, int iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
50 #else
51 extern DECLSPEC bool cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress = CECDEVICE_PLAYBACKDEVICE1, int iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS);
52 #endif
53
54 /*!
55 * @brief Unload the CEC adapter library.
56 */
57 extern DECLSPEC void cec_destroy(void);
58
59 /*!
60 * @brief Open a connection to the CEC adapter.
61 * @param strPort The path to the port.
62 * @param iTimeout Connection timeout in ms.
63 * @return True when connected, false otherwise.
64 */
65 extern DECLSPEC bool cec_open(const char *strPort, int iTimeout);
66
67 /*!
68 * @brief Close the connection to the CEC adapter.
69 */
70 extern DECLSPEC void cec_close(void);
71
72 /*!
73 * @brief Ping the CEC adapter.
74 * @return True when the ping was succesful, false otherwise.
75 */
76 extern DECLSPEC bool cec_ping(void);
77
78 /*!
79 * @brief Start the bootloader of the CEC adapter.
80 * @return True when the command was sent succesfully, false otherwise.
81 */
82 extern DECLSPEC bool cec_start_bootloader(void);
83
84 /*!
85 * @depcrecated Use cec_standby_devices() instead
86 */
87 #ifdef __cplusplus
88 extern DECLSPEC bool cec_power_off_devices(CEC::cec_logical_address address = CEC::CECDEVICE_BROADCAST);
89 #else
90 extern DECLSPEC bool cec_power_off_devices(cec_logical_address address = CECDEVICE_BROADCAST);
91 #endif
92
93 /*!
94 * @brief Power on the connected CEC capable devices.
95 * @param address The logical address to power on.
96 * @return True when the command was sent succesfully, false otherwise.
97 */
98 #ifdef __cplusplus
99 extern DECLSPEC bool cec_power_on_devices(CEC::cec_logical_address address = CEC::CECDEVICE_TV);
100 #else
101 extern DECLSPEC bool cec_power_on_devices(cec_logical_address address = CECDEVICE_TV);
102 #endif
103
104 /*!
105 * @brief Put connected CEC capable devices in standby mode.
106 * @brief address The logical address of the device to put in standby.
107 * @return True when the command was sent succesfully, false otherwise.
108 */
109 #ifdef __cplusplus
110 extern DECLSPEC bool cec_standby_devices(CEC::cec_logical_address address = CEC::CECDEVICE_BROADCAST);
111 #else
112 extern DECLSPEC bool cec_standby_devices(cec_logical_address address = CECDEVICE_BROADCAST);
113 #endif
114
115 /*!
116 * @brief Broadcast a message that notifies connected CEC capable devices that this device is the active source.
117 * @return True when the command was sent succesfully, false otherwise.
118 */
119 extern DECLSPEC bool cec_set_active_view(void);
120
121 /*!
122 * @brief Broadcast a message that notifies connected CEC capable devices that this device is no longer the active source.
123 * @return True when the command was sent succesfully, false otherwise.
124 */
125 extern DECLSPEC bool cec_set_inactive_view(void);
126
127 /*!
128 * @brief Get the next log message in the queue, if there is one.
129 * @param message The next message.
130 * @return True if a message was passed, false otherwise.
131 */
132 #ifdef __cplusplus
133 extern DECLSPEC bool cec_get_next_log_message(CEC::cec_log_message *message);
134 #else
135 extern DECLSPEC bool cec_get_next_log_message(cec_log_message *message);
136 #endif
137
138 /*!
139 * @brief Get the next keypress in the queue, if there is one.
140 * @param key The next keypress.
141 * @return True if a key was passed, false otherwise.
142 */
143 #ifdef __cplusplus
144 extern DECLSPEC bool cec_get_next_keypress(CEC::cec_keypress *key);
145 #else
146 extern DECLSPEC bool cec_get_next_keypress(cec_keypress *key);
147 #endif
148
149 /*!
150 * @brief Get the next CEC command that was received by the adapter.
151 * @param action The next command.
152 * @return True when a command was passed, false otherwise.
153 */
154 #ifdef __cplusplus
155 extern DECLSPEC bool cec_get_next_command(CEC::cec_command *command);
156 #else
157 extern DECLSPEC bool cec_get_next_command(cec_command *command);
158 #endif
159
160 /*!
161 * @brief Transmit a frame on the CEC line.
162 * @param data The frame to send.
163 * @param bWaitForAck Wait for an ACK message for 1 second after this frame has been sent.
164 * @return True when the data was sent and acked, false otherwise.
165 */
166 #ifdef __cplusplus
167 extern DECLSPEC bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck = true);
168 #else
169 extern DECLSPEC bool cec_transmit(const cec_frame &data, bool bWaitForAck = true);
170 #endif
171
172 /*!
173 * @brief Set the logical address of the CEC adapter.
174 * @param iLogicalAddress The cec adapter's logical address.
175 * @return True when the logical address was set succesfully, false otherwise.
176 */
177 #ifdef __cplusplus
178 extern DECLSPEC bool cec_set_logical_address(CEC::cec_logical_address iLogicalAddress);
179 #else
180 extern DECLSPEC bool cec_set_logical_address(cec_logical_address myAddress, cec_logical_address targetAddress);
181 #endif
182
183 /*!
184 * @deprecated Use cec_set_logical_address() instead.
185 * @brief Set the ack mask of the CEC adapter.
186 * @param iMask The cec adapter's ack mask.
187 * @return True when the ack mask was sent succesfully, false otherwise.
188 */
189 extern DECLSPEC bool cec_set_ack_mask(uint16_t iMask);
190
191 /*!
192 * @return Get the minimal version of libcec that this version of libcec can interface with.
193 */
194 extern DECLSPEC int cec_get_min_version(void);
195
196 /*!
197 * @return Get the version of libcec.
198 */
199 extern DECLSPEC int cec_get_lib_version(void);
200
201 /*!
202 * @brief Try to find all connected CEC adapters. Only implemented on Linux at the moment.
203 * @param deviceList The vector to store device descriptors in.
204 * @param strDevicePath Optional device path. Only adds device descriptors that match the given device path.
205 * @return The number of devices that were found, or -1 when an error occured.
206 */
207 #ifdef __cplusplus
208 extern DECLSPEC int cec_find_devices(std::vector<CEC::cec_device> &deviceList, const char *strDevicePath = NULL);
209 #else
210 extern DECLSPEC int cec_find_devices(std::vector<cec_device> &deviceList, const char *strDevicePath = NULL);
211 #endif
212
213 #ifdef __cplusplus
214 };
215 #endif
216
217 #endif /* CECEXPORTS_C_H_ */