diff options
author | mannol <eniz_vukovic@hotmail.com> | 2015-06-05 22:14:37 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2015-06-05 22:14:37 +0200 |
commit | d694839d60011900c20b2d947560e2edccd0d8a9 (patch) | |
tree | a1f4b10c1465ffcdf05c440f0403601dad0404c7 /toxav/toxav.h | |
parent | 3100042a2b78f4f80d23f67e6113797cd8fb5df0 (diff) | |
parent | 6d883f488ff59b2394982b62895d50b1d1d55bf4 (diff) |
Rebased on master and removed alpha channel (again)
Diffstat (limited to 'toxav/toxav.h')
-rw-r--r-- | toxav/toxav.h | 150 |
1 files changed, 3 insertions, 147 deletions
diff --git a/toxav/toxav.h b/toxav/toxav.h index c75f8bff..0b9be241 100644 --- a/toxav/toxav.h +++ b/toxav/toxav.h | |||
@@ -82,35 +82,27 @@ typedef struct Tox Tox; | |||
82 | #define TOXAV_DEFINED | 82 | #define TOXAV_DEFINED |
83 | typedef struct ToxAV ToxAV; | 83 | typedef struct ToxAV ToxAV; |
84 | #endif /* TOXAV_DEFINED */ | 84 | #endif /* TOXAV_DEFINED */ |
85 | |||
86 | |||
87 | /******************************************************************************* | 85 | /******************************************************************************* |
88 | * | 86 | * |
89 | * :: API version | 87 | * :: API version |
90 | * | 88 | * |
91 | ******************************************************************************/ | 89 | ******************************************************************************/ |
92 | |||
93 | |||
94 | |||
95 | /** | 90 | /** |
96 | * The major version number. Incremented when the API or ABI changes in an | 91 | * The major version number. Incremented when the API or ABI changes in an |
97 | * incompatible way. | 92 | * incompatible way. |
98 | */ | 93 | */ |
99 | #define TOXAV_VERSION_MAJOR 0u | 94 | #define TOXAV_VERSION_MAJOR 0u |
100 | |||
101 | /** | 95 | /** |
102 | * The minor version number. Incremented when functionality is added without | 96 | * The minor version number. Incremented when functionality is added without |
103 | * breaking the API or ABI. Set to 0 when the major version number is | 97 | * breaking the API or ABI. Set to 0 when the major version number is |
104 | * incremented. | 98 | * incremented. |
105 | */ | 99 | */ |
106 | #define TOXAV_VERSION_MINOR 0u | 100 | #define TOXAV_VERSION_MINOR 0u |
107 | |||
108 | /** | 101 | /** |
109 | * The patch or revision number. Incremented when bugfixes are applied without | 102 | * The patch or revision number. Incremented when bugfixes are applied without |
110 | * changing any functionality or API or ABI. | 103 | * changing any functionality or API or ABI. |
111 | */ | 104 | */ |
112 | #define TOXAV_VERSION_PATCH 0u | 105 | #define TOXAV_VERSION_PATCH 0u |
113 | |||
114 | /** | 106 | /** |
115 | * A macro to check at preprocessing time whether the client code is compatible | 107 | * A macro to check at preprocessing time whether the client code is compatible |
116 | * with the installed version of ToxAV. | 108 | * with the installed version of ToxAV. |
@@ -120,84 +112,65 @@ typedef struct ToxAV ToxAV; | |||
120 | (TOXAV_VERSION_MINOR > MINOR || \ | 112 | (TOXAV_VERSION_MINOR > MINOR || \ |
121 | (TOXAV_VERSION_MINOR == MINOR && \ | 113 | (TOXAV_VERSION_MINOR == MINOR && \ |
122 | TOXAV_VERSION_PATCH >= PATCH))) | 114 | TOXAV_VERSION_PATCH >= PATCH))) |
123 | |||
124 | /** | 115 | /** |
125 | * A macro to make compilation fail if the client code is not compatible with | 116 | * A macro to make compilation fail if the client code is not compatible with |
126 | * the installed version of ToxAV. | 117 | * the installed version of ToxAV. |
127 | */ | 118 | */ |
128 | #define TOXAV_VERSION_REQUIRE(MAJOR, MINOR, PATCH) \ | 119 | #define TOXAV_VERSION_REQUIRE(MAJOR, MINOR, PATCH) \ |
129 | typedef char toxav_required_version[TOXAV_IS_COMPATIBLE(MAJOR, MINOR, PATCH) ? 1 : -1] | 120 | typedef char toxav_required_version[TOXAV_IS_COMPATIBLE(MAJOR, MINOR, PATCH) ? 1 : -1] |
130 | |||
131 | /** | 121 | /** |
132 | * A convenience macro to call toxav_version_is_compatible with the currently | 122 | * A convenience macro to call toxav_version_is_compatible with the currently |
133 | * compiling API version. | 123 | * compiling API version. |
134 | */ | 124 | */ |
135 | #define TOXAV_VERSION_IS_ABI_COMPATIBLE() \ | 125 | #define TOXAV_VERSION_IS_ABI_COMPATIBLE() \ |
136 | toxav_version_is_compatible(TOXAV_VERSION_MAJOR, TOXAV_VERSION_MINOR, TOXAV_VERSION_PATCH) | 126 | toxav_version_is_compatible(TOXAV_VERSION_MAJOR, TOXAV_VERSION_MINOR, TOXAV_VERSION_PATCH) |
137 | |||
138 | /** | 127 | /** |
139 | * Return the major version number of the library. Can be used to display the | 128 | * Return the major version number of the library. Can be used to display the |
140 | * ToxAV library version or to check whether the client is compatible with the | 129 | * ToxAV library version or to check whether the client is compatible with the |
141 | * dynamically linked version of ToxAV. | 130 | * dynamically linked version of ToxAV. |
142 | */ | 131 | */ |
143 | uint32_t toxav_version_major(void); | 132 | uint32_t toxav_version_major(void); |
144 | |||
145 | /** | 133 | /** |
146 | * Return the minor version number of the library. | 134 | * Return the minor version number of the library. |
147 | */ | 135 | */ |
148 | uint32_t toxav_version_minor(void); | 136 | uint32_t toxav_version_minor(void); |
149 | |||
150 | /** | 137 | /** |
151 | * Return the patch number of the library. | 138 | * Return the patch number of the library. |
152 | */ | 139 | */ |
153 | uint32_t toxav_version_patch(void); | 140 | uint32_t toxav_version_patch(void); |
154 | |||
155 | /** | 141 | /** |
156 | * Return whether the compiled library version is compatible with the passed | 142 | * Return whether the compiled library version is compatible with the passed |
157 | * version numbers. | 143 | * version numbers. |
158 | */ | 144 | */ |
159 | bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch); | 145 | bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch); |
160 | |||
161 | |||
162 | /******************************************************************************* | 146 | /******************************************************************************* |
163 | * | 147 | * |
164 | * :: Creation and destruction | 148 | * :: Creation and destruction |
165 | * | 149 | * |
166 | ******************************************************************************/ | 150 | ******************************************************************************/ |
167 | |||
168 | |||
169 | |||
170 | typedef enum TOXAV_ERR_NEW { | 151 | typedef enum TOXAV_ERR_NEW { |
171 | |||
172 | /** | 152 | /** |
173 | * The function returned successfully. | 153 | * The function returned successfully. |
174 | */ | 154 | */ |
175 | TOXAV_ERR_NEW_OK, | 155 | TOXAV_ERR_NEW_OK, |
176 | |||
177 | /** | 156 | /** |
178 | * One of the arguments to the function was NULL when it was not expected. | 157 | * One of the arguments to the function was NULL when it was not expected. |
179 | */ | 158 | */ |
180 | TOXAV_ERR_NEW_NULL, | 159 | TOXAV_ERR_NEW_NULL, |
181 | |||
182 | /** | 160 | /** |
183 | * Memory allocation failure while trying to allocate structures required for | 161 | * Memory allocation failure while trying to allocate structures required for |
184 | * the A/V session. | 162 | * the A/V session. |
185 | */ | 163 | */ |
186 | TOXAV_ERR_NEW_MALLOC, | 164 | TOXAV_ERR_NEW_MALLOC, |
187 | |||
188 | /** | 165 | /** |
189 | * Attempted to create a second session for the same Tox instance. | 166 | * Attempted to create a second session for the same Tox instance. |
190 | */ | 167 | */ |
191 | TOXAV_ERR_NEW_MULTIPLE, | 168 | TOXAV_ERR_NEW_MULTIPLE, |
192 | |||
193 | } TOXAV_ERR_NEW; | 169 | } TOXAV_ERR_NEW; |
194 | |||
195 | |||
196 | /** | 170 | /** |
197 | * Start new A/V session. There can only be only one session per Tox instance. | 171 | * Start new A/V session. There can only be only one session per Tox instance. |
198 | */ | 172 | */ |
199 | ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error); | 173 | ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error); |
200 | |||
201 | /** | 174 | /** |
202 | * Releases all resources associated with the A/V session. | 175 | * Releases all resources associated with the A/V session. |
203 | * | 176 | * |
@@ -206,80 +179,59 @@ ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error); | |||
206 | * called and the av pointer becomes invalid. | 179 | * called and the av pointer becomes invalid. |
207 | */ | 180 | */ |
208 | void toxav_kill(ToxAV *toxAV); | 181 | void toxav_kill(ToxAV *toxAV); |
209 | |||
210 | /** | 182 | /** |
211 | * Returns the Tox instance the A/V object was created for. | 183 | * Returns the Tox instance the A/V object was created for. |
212 | */ | 184 | */ |
213 | Tox *toxav_get_tox(const ToxAV *toxAV); | 185 | Tox *toxav_get_tox(const ToxAV *toxAV); |
214 | |||
215 | |||
216 | /******************************************************************************* | 186 | /******************************************************************************* |
217 | * | 187 | * |
218 | * :: A/V event loop | 188 | * :: A/V event loop |
219 | * | 189 | * |
220 | ******************************************************************************/ | 190 | ******************************************************************************/ |
221 | |||
222 | |||
223 | |||
224 | /** | 191 | /** |
225 | * Returns the interval in milliseconds when the next toxav_iterate call should | 192 | * Returns the interval in milliseconds when the next toxav_iterate call should |
226 | * be. If no call is active at the moment, this function returns 200. | 193 | * be. If no call is active at the moment, this function returns 200. |
227 | */ | 194 | */ |
228 | uint32_t toxav_iteration_interval(const ToxAV *toxAV); | 195 | uint32_t toxav_iteration_interval(const ToxAV *toxAV); |
229 | |||
230 | /** | 196 | /** |
231 | * Main loop for the session. This function needs to be called in intervals of | 197 | * Main loop for the session. This function needs to be called in intervals of |
232 | * toxav_iteration_interval() milliseconds. It is best called in the separate | 198 | * toxav_iteration_interval() milliseconds. It is best called in the separate |
233 | * thread from tox_iterate. | 199 | * thread from tox_iterate. |
234 | */ | 200 | */ |
235 | void toxav_iterate(ToxAV *toxAV); | 201 | void toxav_iterate(ToxAV *toxAV); |
236 | |||
237 | |||
238 | /******************************************************************************* | 202 | /******************************************************************************* |
239 | * | 203 | * |
240 | * :: Call setup | 204 | * :: Call setup |
241 | * | 205 | * |
242 | ******************************************************************************/ | 206 | ******************************************************************************/ |
243 | |||
244 | |||
245 | |||
246 | typedef enum TOXAV_ERR_CALL { | 207 | typedef enum TOXAV_ERR_CALL { |
247 | |||
248 | /** | 208 | /** |
249 | * The function returned successfully. | 209 | * The function returned successfully. |
250 | */ | 210 | */ |
251 | TOXAV_ERR_CALL_OK, | 211 | TOXAV_ERR_CALL_OK, |
252 | |||
253 | /** | 212 | /** |
254 | * A resource allocation error occurred while trying to create the structures | 213 | * A resource allocation error occurred while trying to create the structures |
255 | * required for the call. | 214 | * required for the call. |
256 | */ | 215 | */ |
257 | TOXAV_ERR_CALL_MALLOC, | 216 | TOXAV_ERR_CALL_MALLOC, |
258 | |||
259 | /** | 217 | /** |
260 | * The friend number did not designate a valid friend. | 218 | * The friend number did not designate a valid friend. |
261 | */ | 219 | */ |
262 | TOXAV_ERR_CALL_FRIEND_NOT_FOUND, | 220 | TOXAV_ERR_CALL_FRIEND_NOT_FOUND, |
263 | |||
264 | /** | 221 | /** |
265 | * The friend was valid, but not currently connected. | 222 | * The friend was valid, but not currently connected. |
266 | */ | 223 | */ |
267 | TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED, | 224 | TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED, |
268 | |||
269 | /** | 225 | /** |
270 | * Attempted to call a friend while already in an audio or video call with | 226 | * Attempted to call a friend while already in an audio or video call with |
271 | * them. | 227 | * them. |
272 | */ | 228 | */ |
273 | TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL, | 229 | TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL, |
274 | |||
275 | /** | 230 | /** |
276 | * Audio or video bit rate is invalid. | 231 | * Audio or video bit rate is invalid. |
277 | */ | 232 | */ |
278 | TOXAV_ERR_CALL_INVALID_BIT_RATE, | 233 | TOXAV_ERR_CALL_INVALID_BIT_RATE, |
279 | |||
280 | } TOXAV_ERR_CALL; | 234 | } TOXAV_ERR_CALL; |
281 | |||
282 | |||
283 | /** | 235 | /** |
284 | * Call a friend. This will start ringing the friend. | 236 | * Call a friend. This will start ringing the friend. |
285 | * | 237 | * |
@@ -294,7 +246,6 @@ typedef enum TOXAV_ERR_CALL { | |||
294 | * video sending. | 246 | * video sending. |
295 | */ | 247 | */ |
296 | bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_CALL *error); | 248 | bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_CALL *error); |
297 | |||
298 | /** | 249 | /** |
299 | * The function type for the call callback. | 250 | * The function type for the call callback. |
300 | * | 251 | * |
@@ -303,47 +254,36 @@ bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, u | |||
303 | * @param video_enabled True if friend is sending video. | 254 | * @param video_enabled True if friend is sending video. |
304 | */ | 255 | */ |
305 | typedef void toxav_call_cb(ToxAV *toxAV, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data); | 256 | typedef void toxav_call_cb(ToxAV *toxAV, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data); |
306 | |||
307 | |||
308 | /** | 257 | /** |
309 | * Set the callback for the `call` event. Pass NULL to unset. | 258 | * Set the callback for the `call` event. Pass NULL to unset. |
310 | * | 259 | * |
311 | */ | 260 | */ |
312 | void toxav_callback_call(ToxAV *toxAV, toxav_call_cb *callback, void *user_data); | 261 | void toxav_callback_call(ToxAV *toxAV, toxav_call_cb *callback, void *user_data); |
313 | |||
314 | typedef enum TOXAV_ERR_ANSWER { | 262 | typedef enum TOXAV_ERR_ANSWER { |
315 | |||
316 | /** | 263 | /** |
317 | * The function returned successfully. | 264 | * The function returned successfully. |
318 | */ | 265 | */ |
319 | TOXAV_ERR_ANSWER_OK, | 266 | TOXAV_ERR_ANSWER_OK, |
320 | |||
321 | /** | 267 | /** |
322 | * Failed to initialize codecs for call session. Note that codec initiation | 268 | * Failed to initialize codecs for call session. Note that codec initiation |
323 | * will fail if there is no receive callback registered for either audio or | 269 | * will fail if there is no receive callback registered for either audio or |
324 | * video. | 270 | * video. |
325 | */ | 271 | */ |
326 | TOXAV_ERR_ANSWER_CODEC_INITIALIZATION, | 272 | TOXAV_ERR_ANSWER_CODEC_INITIALIZATION, |
327 | |||
328 | /** | 273 | /** |
329 | * The friend number did not designate a valid friend. | 274 | * The friend number did not designate a valid friend. |
330 | */ | 275 | */ |
331 | TOXAV_ERR_ANSWER_FRIEND_NOT_FOUND, | 276 | TOXAV_ERR_ANSWER_FRIEND_NOT_FOUND, |
332 | |||
333 | /** | 277 | /** |
334 | * The friend was valid, but they are not currently trying to initiate a call. | 278 | * The friend was valid, but they are not currently trying to initiate a call. |
335 | * This is also returned if this client is already in a call with the friend. | 279 | * This is also returned if this client is already in a call with the friend. |
336 | */ | 280 | */ |
337 | TOXAV_ERR_ANSWER_FRIEND_NOT_CALLING, | 281 | TOXAV_ERR_ANSWER_FRIEND_NOT_CALLING, |
338 | |||
339 | /** | 282 | /** |
340 | * Audio or video bit rate is invalid. | 283 | * Audio or video bit rate is invalid. |
341 | */ | 284 | */ |
342 | TOXAV_ERR_ANSWER_INVALID_BIT_RATE, | 285 | TOXAV_ERR_ANSWER_INVALID_BIT_RATE, |
343 | |||
344 | } TOXAV_ERR_ANSWER; | 286 | } TOXAV_ERR_ANSWER; |
345 | |||
346 | |||
347 | /** | 287 | /** |
348 | * Accept an incoming call. | 288 | * Accept an incoming call. |
349 | * | 289 | * |
@@ -357,18 +297,12 @@ typedef enum TOXAV_ERR_ANSWER { | |||
357 | * video sending. | 297 | * video sending. |
358 | */ | 298 | */ |
359 | bool toxav_answer(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_ANSWER *error); | 299 | bool toxav_answer(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_ANSWER *error); |
360 | |||
361 | |||
362 | /******************************************************************************* | 300 | /******************************************************************************* |
363 | * | 301 | * |
364 | * :: Call state graph | 302 | * :: Call state graph |
365 | * | 303 | * |
366 | ******************************************************************************/ | 304 | ******************************************************************************/ |
367 | |||
368 | |||
369 | |||
370 | enum TOXAV_CALL_STATE { | 305 | enum TOXAV_CALL_STATE { |
371 | |||
372 | /** | 306 | /** |
373 | * Set by the AV core if an error occurred on the remote end or if friend | 307 | * Set by the AV core if an error occurred on the remote end or if friend |
374 | * timed out. This is the final state after which no more state | 308 | * timed out. This is the final state after which no more state |
@@ -376,34 +310,28 @@ enum TOXAV_CALL_STATE { | |||
376 | * in combination with other call states. | 310 | * in combination with other call states. |
377 | */ | 311 | */ |
378 | TOXAV_CALL_STATE_ERROR = 1, | 312 | TOXAV_CALL_STATE_ERROR = 1, |
379 | |||
380 | /** | 313 | /** |
381 | * The call has finished. This is the final state after which no more state | 314 | * The call has finished. This is the final state after which no more state |
382 | * transitions can occur for the call. This call state will never be | 315 | * transitions can occur for the call. This call state will never be |
383 | * triggered in combination with other call states. | 316 | * triggered in combination with other call states. |
384 | */ | 317 | */ |
385 | TOXAV_CALL_STATE_FINISHED = 2, | 318 | TOXAV_CALL_STATE_FINISHED = 2, |
386 | |||
387 | /** | 319 | /** |
388 | * The flag that marks that friend is sending audio. | 320 | * The flag that marks that friend is sending audio. |
389 | */ | 321 | */ |
390 | TOXAV_CALL_STATE_SENDING_A = 4, | 322 | TOXAV_CALL_STATE_SENDING_A = 4, |
391 | |||
392 | /** | 323 | /** |
393 | * The flag that marks that friend is sending video. | 324 | * The flag that marks that friend is sending video. |
394 | */ | 325 | */ |
395 | TOXAV_CALL_STATE_SENDING_V = 8, | 326 | TOXAV_CALL_STATE_SENDING_V = 8, |
396 | |||
397 | /** | 327 | /** |
398 | * The flag that marks that friend is receiving audio. | 328 | * The flag that marks that friend is receiving audio. |
399 | */ | 329 | */ |
400 | TOXAV_CALL_STATE_RECEIVING_A = 16, | 330 | TOXAV_CALL_STATE_RECEIVING_A = 16, |
401 | |||
402 | /** | 331 | /** |
403 | * The flag that marks that friend is receiving video. | 332 | * The flag that marks that friend is receiving video. |
404 | */ | 333 | */ |
405 | TOXAV_CALL_STATE_RECEIVING_V = 32, | 334 | TOXAV_CALL_STATE_RECEIVING_V = 32, |
406 | |||
407 | }; | 335 | }; |
408 | 336 | ||
409 | 337 | ||
@@ -415,96 +343,72 @@ enum TOXAV_CALL_STATE { | |||
415 | * the previous state. The state is set to 0 when the call is paused. | 343 | * the previous state. The state is set to 0 when the call is paused. |
416 | */ | 344 | */ |
417 | typedef void toxav_call_state_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t state, void *user_data); | 345 | typedef void toxav_call_state_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t state, void *user_data); |
418 | |||
419 | |||
420 | /** | 346 | /** |
421 | * Set the callback for the `call_state` event. Pass NULL to unset. | 347 | * Set the callback for the `call_state` event. Pass NULL to unset. |
422 | * | 348 | * |
423 | */ | 349 | */ |
424 | void toxav_callback_call_state(ToxAV *toxAV, toxav_call_state_cb *callback, void *user_data); | 350 | void toxav_callback_call_state(ToxAV *toxAV, toxav_call_state_cb *callback, void *user_data); |
425 | |||
426 | |||
427 | /******************************************************************************* | 351 | /******************************************************************************* |
428 | * | 352 | * |
429 | * :: Call control | 353 | * :: Call control |
430 | * | 354 | * |
431 | ******************************************************************************/ | 355 | ******************************************************************************/ |
432 | |||
433 | |||
434 | |||
435 | typedef enum TOXAV_CALL_CONTROL { | 356 | typedef enum TOXAV_CALL_CONTROL { |
436 | |||
437 | /** | 357 | /** |
438 | * Resume a previously paused call. Only valid if the pause was caused by this | 358 | * Resume a previously paused call. Only valid if the pause was caused by this |
439 | * client, if not, this control is ignored. Not valid before the call is accepted. | 359 | * client, if not, this control is ignored. Not valid before the call is accepted. |
440 | */ | 360 | */ |
441 | TOXAV_CALL_CONTROL_RESUME, | 361 | TOXAV_CALL_CONTROL_RESUME, |
442 | |||
443 | /** | 362 | /** |
444 | * Put a call on hold. Not valid before the call is accepted. | 363 | * Put a call on hold. Not valid before the call is accepted. |
445 | */ | 364 | */ |
446 | TOXAV_CALL_CONTROL_PAUSE, | 365 | TOXAV_CALL_CONTROL_PAUSE, |
447 | |||
448 | /** | 366 | /** |
449 | * Reject a call if it was not answered, yet. Cancel a call after it was | 367 | * Reject a call if it was not answered, yet. Cancel a call after it was |
450 | * answered. | 368 | * answered. |
451 | */ | 369 | */ |
452 | TOXAV_CALL_CONTROL_CANCEL, | 370 | TOXAV_CALL_CONTROL_CANCEL, |
453 | |||
454 | /** | 371 | /** |
455 | * Request that the friend stops sending audio. Regardless of the friend's | 372 | * Request that the friend stops sending audio. Regardless of the friend's |
456 | * compliance, this will cause the audio_receive_frame event to stop being | 373 | * compliance, this will cause the audio_receive_frame event to stop being |
457 | * triggered on receiving an audio frame from the friend. | 374 | * triggered on receiving an audio frame from the friend. |
458 | */ | 375 | */ |
459 | TOXAV_CALL_CONTROL_MUTE_AUDIO, | 376 | TOXAV_CALL_CONTROL_MUTE_AUDIO, |
460 | |||
461 | /** | 377 | /** |
462 | * Calling this control will notify client to start sending audio again. | 378 | * Calling this control will notify client to start sending audio again. |
463 | */ | 379 | */ |
464 | TOXAV_CALL_CONTROL_UNMUTE_AUDIO, | 380 | TOXAV_CALL_CONTROL_UNMUTE_AUDIO, |
465 | |||
466 | /** | 381 | /** |
467 | * Request that the friend stops sending video. Regardless of the friend's | 382 | * Request that the friend stops sending video. Regardless of the friend's |
468 | * compliance, this will cause the video_receive_frame event to stop being | 383 | * compliance, this will cause the video_receive_frame event to stop being |
469 | * triggered on receiving an video frame from the friend. | 384 | * triggered on receiving an video frame from the friend. |
470 | */ | 385 | */ |
471 | TOXAV_CALL_CONTROL_HIDE_VIDEO, | 386 | TOXAV_CALL_CONTROL_HIDE_VIDEO, |
472 | |||
473 | /** | 387 | /** |
474 | * Calling this control will notify client to start sending video again. | 388 | * Calling this control will notify client to start sending video again. |
475 | */ | 389 | */ |
476 | TOXAV_CALL_CONTROL_SHOW_VIDEO, | 390 | TOXAV_CALL_CONTROL_SHOW_VIDEO, |
477 | |||
478 | } TOXAV_CALL_CONTROL; | 391 | } TOXAV_CALL_CONTROL; |
479 | |||
480 | |||
481 | typedef enum TOXAV_ERR_CALL_CONTROL { | 392 | typedef enum TOXAV_ERR_CALL_CONTROL { |
482 | |||
483 | /** | 393 | /** |
484 | * The function returned successfully. | 394 | * The function returned successfully. |
485 | */ | 395 | */ |
486 | TOXAV_ERR_CALL_CONTROL_OK, | 396 | TOXAV_ERR_CALL_CONTROL_OK, |
487 | |||
488 | /** | 397 | /** |
489 | * The friend_number passed did not designate a valid friend. | 398 | * The friend_number passed did not designate a valid friend. |
490 | */ | 399 | */ |
491 | TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND, | 400 | TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND, |
492 | |||
493 | /** | 401 | /** |
494 | * This client is currently not in a call with the friend. Before the call is | 402 | * This client is currently not in a call with the friend. Before the call is |
495 | * answered, only CANCEL is a valid control. | 403 | * answered, only CANCEL is a valid control. |
496 | */ | 404 | */ |
497 | TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL, | 405 | TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL, |
498 | |||
499 | /** | 406 | /** |
500 | * Happens if user tried to pause an already paused call or if trying to | 407 | * Happens if user tried to pause an already paused call or if trying to |
501 | * resume a call that is not paused. | 408 | * resume a call that is not paused. |
502 | */ | 409 | */ |
503 | TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION, | 410 | TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION, |
504 | |||
505 | } TOXAV_ERR_CALL_CONTROL; | 411 | } TOXAV_ERR_CALL_CONTROL; |
506 | |||
507 | |||
508 | /** | 412 | /** |
509 | * Sends a call control command to a friend. | 413 | * Sends a call control command to a friend. |
510 | * | 414 | * |
@@ -515,41 +419,29 @@ typedef enum TOXAV_ERR_CALL_CONTROL { | |||
515 | * @return true on success. | 419 | * @return true on success. |
516 | */ | 420 | */ |
517 | bool toxav_call_control(ToxAV *toxAV, uint32_t friend_number, TOXAV_CALL_CONTROL control, TOXAV_ERR_CALL_CONTROL *error); | 421 | bool toxav_call_control(ToxAV *toxAV, uint32_t friend_number, TOXAV_CALL_CONTROL control, TOXAV_ERR_CALL_CONTROL *error); |
518 | |||
519 | |||
520 | /******************************************************************************* | 422 | /******************************************************************************* |
521 | * | 423 | * |
522 | * :: Controlling bit rates | 424 | * :: Controlling bit rates |
523 | * | 425 | * |
524 | ******************************************************************************/ | 426 | ******************************************************************************/ |
525 | |||
526 | |||
527 | |||
528 | typedef enum TOXAV_ERR_SET_BIT_RATE { | 427 | typedef enum TOXAV_ERR_SET_BIT_RATE { |
529 | |||
530 | /** | 428 | /** |
531 | * The function returned successfully. | 429 | * The function returned successfully. |
532 | */ | 430 | */ |
533 | TOXAV_ERR_SET_BIT_RATE_OK, | 431 | TOXAV_ERR_SET_BIT_RATE_OK, |
534 | |||
535 | /** | 432 | /** |
536 | * The bit rate passed was not one of the supported values. | 433 | * The bit rate passed was not one of the supported values. |
537 | */ | 434 | */ |
538 | TOXAV_ERR_SET_BIT_RATE_INVALID, | 435 | TOXAV_ERR_SET_BIT_RATE_INVALID, |
539 | |||
540 | /** | 436 | /** |
541 | * The friend_number passed did not designate a valid friend. | 437 | * The friend_number passed did not designate a valid friend. |
542 | */ | 438 | */ |
543 | TOXAV_ERR_SET_BIT_RATE_FRIEND_NOT_FOUND, | 439 | TOXAV_ERR_SET_BIT_RATE_FRIEND_NOT_FOUND, |
544 | |||
545 | /** | 440 | /** |
546 | * This client is currently not in a call with the friend. | 441 | * This client is currently not in a call with the friend. |
547 | */ | 442 | */ |
548 | TOXAV_ERR_SET_BIT_RATE_FRIEND_NOT_IN_CALL, | 443 | TOXAV_ERR_SET_BIT_RATE_FRIEND_NOT_IN_CALL, |
549 | |||
550 | } TOXAV_ERR_SET_BIT_RATE; | 444 | } TOXAV_ERR_SET_BIT_RATE; |
551 | |||
552 | |||
553 | /** | 445 | /** |
554 | * The function type for the audio_bit_rate_status callback. | 446 | * The function type for the audio_bit_rate_status callback. |
555 | * | 447 | * |
@@ -564,14 +456,11 @@ typedef enum TOXAV_ERR_SET_BIT_RATE { | |||
564 | * @param bit_rate The bit rate in Kb/sec. | 456 | * @param bit_rate The bit rate in Kb/sec. |
565 | */ | 457 | */ |
566 | typedef void toxav_audio_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, bool stable, uint32_t bit_rate, void *user_data); | 458 | typedef void toxav_audio_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, bool stable, uint32_t bit_rate, void *user_data); |
567 | |||
568 | |||
569 | /** | 459 | /** |
570 | * Set the callback for the `audio_bit_rate_status` event. Pass NULL to unset. | 460 | * Set the callback for the `audio_bit_rate_status` event. Pass NULL to unset. |
571 | * | 461 | * |
572 | */ | 462 | */ |
573 | void toxav_callback_audio_bit_rate_status(ToxAV *toxAV, toxav_audio_bit_rate_status_cb *callback, void *user_data); | 463 | void toxav_callback_audio_bit_rate_status(ToxAV *toxAV, toxav_audio_bit_rate_status_cb *callback, void *user_data); |
574 | |||
575 | /** | 464 | /** |
576 | * Set the audio bit rate to be used in subsequent audio frames. If the passed | 465 | * Set the audio bit rate to be used in subsequent audio frames. If the passed |
577 | * bit rate is the same as the current bit rate this function will return true | 466 | * bit rate is the same as the current bit rate this function will return true |
@@ -588,7 +477,6 @@ void toxav_callback_audio_bit_rate_status(ToxAV *toxAV, toxav_audio_bit_rate_sta | |||
588 | * | 477 | * |
589 | */ | 478 | */ |
590 | bool toxav_audio_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE *error); | 479 | bool toxav_audio_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE *error); |
591 | |||
592 | /** | 480 | /** |
593 | * The function type for the video_bit_rate_status callback. | 481 | * The function type for the video_bit_rate_status callback. |
594 | * | 482 | * |
@@ -603,14 +491,11 @@ bool toxav_audio_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, uint32_t aud | |||
603 | * @param bit_rate The bit rate in Kb/sec. | 491 | * @param bit_rate The bit rate in Kb/sec. |
604 | */ | 492 | */ |
605 | typedef void toxav_video_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, bool stable, uint32_t bit_rate, void *user_data); | 493 | typedef void toxav_video_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, bool stable, uint32_t bit_rate, void *user_data); |
606 | |||
607 | |||
608 | /** | 494 | /** |
609 | * Set the callback for the `video_bit_rate_status` event. Pass NULL to unset. | 495 | * Set the callback for the `video_bit_rate_status` event. Pass NULL to unset. |
610 | * | 496 | * |
611 | */ | 497 | */ |
612 | void toxav_callback_video_bit_rate_status(ToxAV *toxAV, toxav_video_bit_rate_status_cb *callback, void *user_data); | 498 | void toxav_callback_video_bit_rate_status(ToxAV *toxAV, toxav_video_bit_rate_status_cb *callback, void *user_data); |
613 | |||
614 | /** | 499 | /** |
615 | * Set the video bit rate to be used in subsequent video frames. If the passed | 500 | * Set the video bit rate to be used in subsequent video frames. If the passed |
616 | * bit rate is the same as the current bit rate this function will return true | 501 | * bit rate is the same as the current bit rate this function will return true |
@@ -627,53 +512,39 @@ void toxav_callback_video_bit_rate_status(ToxAV *toxAV, toxav_video_bit_rate_sta | |||
627 | * | 512 | * |
628 | */ | 513 | */ |
629 | bool toxav_video_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE *error); | 514 | bool toxav_video_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE *error); |
630 | |||
631 | |||
632 | /******************************************************************************* | 515 | /******************************************************************************* |
633 | * | 516 | * |
634 | * :: A/V sending | 517 | * :: A/V sending |
635 | * | 518 | * |
636 | ******************************************************************************/ | 519 | ******************************************************************************/ |
637 | |||
638 | |||
639 | |||
640 | typedef enum TOXAV_ERR_SEND_FRAME { | 520 | typedef enum TOXAV_ERR_SEND_FRAME { |
641 | |||
642 | /** | 521 | /** |
643 | * The function returned successfully. | 522 | * The function returned successfully. |
644 | */ | 523 | */ |
645 | TOXAV_ERR_SEND_FRAME_OK, | 524 | TOXAV_ERR_SEND_FRAME_OK, |
646 | |||
647 | /** | 525 | /** |
648 | * In case of video, one of Y, U, or V was NULL. In case of audio, the samples | 526 | * In case of video, one of Y, U, or V was NULL. In case of audio, the samples |
649 | * data pointer was NULL. | 527 | * data pointer was NULL. |
650 | */ | 528 | */ |
651 | TOXAV_ERR_SEND_FRAME_NULL, | 529 | TOXAV_ERR_SEND_FRAME_NULL, |
652 | |||
653 | /** | 530 | /** |
654 | * The friend_number passed did not designate a valid friend. | 531 | * The friend_number passed did not designate a valid friend. |
655 | */ | 532 | */ |
656 | TOXAV_ERR_SEND_FRAME_FRIEND_NOT_FOUND, | 533 | TOXAV_ERR_SEND_FRAME_FRIEND_NOT_FOUND, |
657 | |||
658 | /** | 534 | /** |
659 | * This client is currently not in a call with the friend. | 535 | * This client is currently not in a call with the friend. |
660 | */ | 536 | */ |
661 | TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL, | 537 | TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL, |
662 | |||
663 | /** | 538 | /** |
664 | * One of the frame parameters was invalid. E.g. the resolution may be too | 539 | * One of the frame parameters was invalid. E.g. the resolution may be too |
665 | * small or too large, or the audio sampling rate may be unsupported. | 540 | * small or too large, or the audio sampling rate may be unsupported. |
666 | */ | 541 | */ |
667 | TOXAV_ERR_SEND_FRAME_INVALID, | 542 | TOXAV_ERR_SEND_FRAME_INVALID, |
668 | |||
669 | /** | 543 | /** |
670 | * Failed to push frame through rtp interface. | 544 | * Failed to push frame through rtp interface. |
671 | */ | 545 | */ |
672 | TOXAV_ERR_SEND_FRAME_RTP_FAILED, | 546 | TOXAV_ERR_SEND_FRAME_RTP_FAILED, |
673 | |||
674 | } TOXAV_ERR_SEND_FRAME; | 547 | } TOXAV_ERR_SEND_FRAME; |
675 | |||
676 | |||
677 | /** | 548 | /** |
678 | * Send an audio frame to a friend. | 549 | * Send an audio frame to a friend. |
679 | * | 550 | * |
@@ -695,7 +566,6 @@ typedef enum TOXAV_ERR_SEND_FRAME { | |||
695 | * rates are 8000, 12000, 16000, 24000, or 48000. | 566 | * rates are 8000, 12000, 16000, 24000, or 48000. |
696 | */ | 567 | */ |
697 | bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, TOXAV_ERR_SEND_FRAME *error); | 568 | bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, TOXAV_ERR_SEND_FRAME *error); |
698 | |||
699 | /** | 569 | /** |
700 | * Send a video frame to a friend. | 570 | * Send a video frame to a friend. |
701 | * | 571 | * |
@@ -710,19 +580,13 @@ bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t | |||
710 | * @param y Y (Luminance) plane data. | 580 | * @param y Y (Luminance) plane data. |
711 | * @param u U (Chroma) plane data. | 581 | * @param u U (Chroma) plane data. |
712 | * @param v V (Chroma) plane data. | 582 | * @param v V (Chroma) plane data. |
713 | * @param a A (Alpha) plane data. | ||
714 | */ | 583 | */ |
715 | bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, const uint8_t *a, TOXAV_ERR_SEND_FRAME *error); | 584 | bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, TOXAV_ERR_SEND_FRAME *error); |
716 | |||
717 | |||
718 | /******************************************************************************* | 585 | /******************************************************************************* |
719 | * | 586 | * |
720 | * :: A/V receiving | 587 | * :: A/V receiving |
721 | * | 588 | * |
722 | ******************************************************************************/ | 589 | ******************************************************************************/ |
723 | |||
724 | |||
725 | |||
726 | /** | 590 | /** |
727 | * The function type for the audio_receive_frame callback. | 591 | * The function type for the audio_receive_frame callback. |
728 | * | 592 | * |
@@ -734,14 +598,11 @@ bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width | |||
734 | * | 598 | * |
735 | */ | 599 | */ |
736 | typedef void toxav_audio_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, void *user_data); | 600 | typedef void toxav_audio_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, void *user_data); |
737 | |||
738 | |||
739 | /** | 601 | /** |
740 | * Set the callback for the `audio_receive_frame` event. Pass NULL to unset. | 602 | * Set the callback for the `audio_receive_frame` event. Pass NULL to unset. |
741 | * | 603 | * |
742 | */ | 604 | */ |
743 | void toxav_callback_audio_receive_frame(ToxAV *toxAV, toxav_audio_receive_frame_cb *callback, void *user_data); | 605 | void toxav_callback_audio_receive_frame(ToxAV *toxAV, toxav_audio_receive_frame_cb *callback, void *user_data); |
744 | |||
745 | /** | 606 | /** |
746 | * The function type for the video_receive_frame callback. | 607 | * The function type for the video_receive_frame callback. |
747 | * | 608 | * |
@@ -755,23 +616,18 @@ void toxav_callback_audio_receive_frame(ToxAV *toxAV, toxav_audio_receive_frame_ | |||
755 | * Y = MAX(width, abs(ystride)) * height, | 616 | * Y = MAX(width, abs(ystride)) * height, |
756 | * U = MAX(width/2, abs(ustride)) * (height/2) and | 617 | * U = MAX(width/2, abs(ustride)) * (height/2) and |
757 | * V = MAX(width/2, abs(vstride)) * (height/2). | 618 | * V = MAX(width/2, abs(vstride)) * (height/2). |
758 | * A = MAX(width, abs(astride)) * height. | ||
759 | * @param ystride | 619 | * @param ystride |
760 | * @param ustride | 620 | * @param ustride |
761 | * @param vstride | 621 | * @param vstride Strides data. Strides represent padding for each plane |
762 | * @param astride Strides data. Strides represent padding for each plane | ||
763 | * that may or may not be present. You must handle strides in | 622 | * that may or may not be present. You must handle strides in |
764 | * your image processing code. Strides are negative if the | 623 | * your image processing code. Strides are negative if the |
765 | * image is bottom-up hence why you MUST abs() it when | 624 | * image is bottom-up hence why you MUST abs() it when |
766 | * calculating plane buffer size. | 625 | * calculating plane buffer size. |
767 | */ | 626 | */ |
768 | typedef void toxav_video_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, const uint8_t *a, int32_t ystride, int32_t ustride, int32_t vstride, int32_t astride, void *user_data); | 627 | typedef void toxav_video_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, int32_t ystride, int32_t ustride, int32_t vstride, void *user_data); |
769 | |||
770 | |||
771 | /** | 628 | /** |
772 | * Set the callback for the `video_receive_frame` event. Pass NULL to unset. | 629 | * Set the callback for the `video_receive_frame` event. Pass NULL to unset. |
773 | * | 630 | * |
774 | */ | 631 | */ |
775 | void toxav_callback_video_receive_frame(ToxAV *toxAV, toxav_video_receive_frame_cb *callback, void *user_data); | 632 | void toxav_callback_video_receive_frame(ToxAV *toxAV, toxav_video_receive_frame_cb *callback, void *user_data); |
776 | |||
777 | #endif | 633 | #endif |