summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2016-09-28 15:14:33 -0400
committerirungentoo <irungentoo@gmail.com>2016-09-28 15:14:33 -0400
commitdcf2aaa53005060608353b9d66b9917fd7ed18a9 (patch)
tree7d4e35183076b99ecd12007da1f4fcdb2a960bf0
parent496af600ca93b00cb29c3623f987b53a6f50452c (diff)
parent403f5a22e0977fb59ea27e5d0ca090ef5f9019c3 (diff)
Merge branch 'ghost-avswitch'
-rw-r--r--other/apidsl/toxav.in.h104
-rw-r--r--toxav/toxav.h131
2 files changed, 191 insertions, 44 deletions
diff --git a/other/apidsl/toxav.in.h b/other/apidsl/toxav.in.h
index ab89b0ea..63397420 100644
--- a/other/apidsl/toxav.in.h
+++ b/other/apidsl/toxav.in.h
@@ -1,6 +1,6 @@
1%{ 1%{
2/* toxav.h 2/* toxav.h
3 * 3 *
4 * Copyright (C) 2013-2015 Tox project All Rights Reserved. 4 * Copyright (C) 2013-2015 Tox project All Rights Reserved.
5 * 5 *
6 * This file is part of Tox. 6 * This file is part of Tox.
@@ -17,7 +17,7 @@
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 19 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 */ 21 */
22 22
23#ifndef TOXAV_H 23#ifndef TOXAV_H
@@ -33,39 +33,39 @@ extern "C" {
33%} 33%}
34 34
35/** \page av Public audio/video API for Tox clients. 35/** \page av Public audio/video API for Tox clients.
36 * 36 *
37 * This API can handle multiple calls. Each call has its state, in very rare 37 * This API can handle multiple calls. Each call has its state, in very rare
38 * occasions the library can change the state of the call without apps knowledge. 38 * occasions the library can change the state of the call without apps knowledge.
39 * 39 *
40 */ 40 */
41 41
42/** \subsection events Events and callbacks 42/** \subsection events Events and callbacks
43 * 43 *
44 * As in Core API, events are handled by callbacks. One callback can be 44 * As in Core API, events are handled by callbacks. One callback can be
45 * registered per event. All events have a callback function type named 45 * registered per event. All events have a callback function type named
46 * `toxav_{event}_cb` and a function to register it named `tox_callback_{event}`. 46 * `toxav_{event}_cb` and a function to register it named `toxav_callback_{event}`.
47 * Passing a NULL callback will result in no callback being registered for that 47 * Passing a NULL callback will result in no callback being registered for that
48 * event. Only one callback per event can be registered, so if a client needs 48 * event. Only one callback per event can be registered, so if a client needs
49 * multiple event listeners, it needs to implement the dispatch functionality 49 * multiple event listeners, it needs to implement the dispatch functionality
50 * itself. Unlike Core API, lack of some event handlers will cause the the 50 * itself. Unlike Core API, lack of some event handlers will cause the the
51 * library to drop calls before they are started. Hanging up call from a 51 * library to drop calls before they are started. Hanging up call from a
52 * callback causes undefined behaviour. 52 * callback causes undefined behaviour.
53 * 53 *
54 */ 54 */
55 55
56/** \subsection threading Threading implications 56/** \subsection threading Threading implications
57 * 57 *
58 * Unlike the Core API, this API is fully thread-safe. The library will ensure 58 * Unlike the Core API, this API is fully thread-safe. The library will ensure
59 * the proper synchronization of parallel calls. 59 * the proper synchronization of parallel calls.
60 * 60 *
61 * A common way to run ToxAV (multiple or single instance) is to have a thread, 61 * A common way to run ToxAV (multiple or single instance) is to have a thread,
62 * separate from tox instance thread, running a simple ${toxAV.iterate} loop, 62 * separate from tox instance thread, running a simple ${toxAV.iterate} loop,
63 * sleeping for ${toxAV.iteration_interval} * milliseconds on each iteration. 63 * sleeping for ${toxAV.iteration_interval} * milliseconds on each iteration.
64 * 64 *
65 * An important thing to note is that events are triggered from both tox and 65 * An important thing to note is that events are triggered from both tox and
66 * toxav thread (see above). audio and video receive frame events are triggered 66 * toxav thread (see above). Audio and video receive frame events are triggered
67 * from toxav thread while all the other events are triggered from tox thread. 67 * from toxav thread while all the other events are triggered from tox thread.
68 * 68 *
69 * Tox thread has priority with mutex mechanisms. Any api function can 69 * Tox thread has priority with mutex mechanisms. Any api function can
70 * fail if mutexes are held by tox thread in which case they will set SYNC 70 * fail if mutexes are held by tox thread in which case they will set SYNC
71 * error code. 71 * error code.
@@ -87,9 +87,9 @@ class toxAV {
87 * The ToxAV instance type. Each ToxAV instance can be bound to only one Tox 87 * The ToxAV instance type. Each ToxAV instance can be bound to only one Tox
88 * instance, and Tox instance can have only one ToxAV instance. One must make 88 * instance, and Tox instance can have only one ToxAV instance. One must make
89 * sure to close ToxAV instance prior closing Tox instance otherwise undefined 89 * sure to close ToxAV instance prior closing Tox instance otherwise undefined
90 * behaviour occurs. Upon closing of ToxAV instance, all active calls will be 90 * behaviour occurs. Upon closing of ToxAV instance, all active calls will be
91 * forcibly terminated without notifying peers. 91 * forcibly terminated without notifying peers.
92 * 92 *
93 */ 93 */
94struct this; 94struct this;
95/******************************************************************************* 95/*******************************************************************************
@@ -166,7 +166,7 @@ static namespace version {
166 166
167} 167}
168/******************************************************************************* 168/*******************************************************************************
169 * 169 *
170 * :: Creation and destruction 170 * :: Creation and destruction
171 * 171 *
172 ******************************************************************************/ 172 ******************************************************************************/
@@ -433,9 +433,10 @@ bool call_control (uint32_t friend_number, CALL_CONTROL control) {
433 ******************************************************************************/ 433 ******************************************************************************/
434namespace bit_rate { 434namespace bit_rate {
435 /** 435 /**
436 * Set the audio bit rate to be used in subsequent audio/video frames. 436 * Set the bit rate to be used in subsequent audio/video frames.
437 * 437 *
438 * @param friend_number The friend number. 438 * @param friend_number The friend number of the friend for which to set the
439 * bit rate.
439 * @param audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable 440 * @param audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable
440 * audio sending. Set to -1 to leave unchanged. 441 * audio sending. Set to -1 to leave unchanged.
441 * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable 442 * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable
@@ -448,9 +449,13 @@ namespace bit_rate {
448 */ 449 */
449 SYNC, 450 SYNC,
450 /** 451 /**
451 * The bit rate passed was not one of the supported values. 452 * The audio bit rate passed was not one of the supported values.
453 */
454 INVALID_AUDIO_BIT_RATE,
455 /**
456 * The video bit rate passed was not one of the supported values.
452 */ 457 */
453 INVALID, 458 INVALID_VIDEO_BIT_RATE,
454 /** 459 /**
455 * The friend_number passed did not designate a valid friend. 460 * The friend_number passed did not designate a valid friend.
456 */ 461 */
@@ -466,7 +471,8 @@ namespace bit_rate {
466 * when the network becomes too saturated for current bit rates at which 471 * when the network becomes too saturated for current bit rates at which
467 * point core suggests new bit rates. 472 * point core suggests new bit rates.
468 * 473 *
469 * @param friend_number The friend number. 474 * @param friend_number The friend number of the friend for which to set the
475 * bit rate.
470 * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec. 476 * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec.
471 * @param video_bit_rate Suggested maximum video bit rate in Kb/sec. 477 * @param video_bit_rate Suggested maximum video bit rate in Kb/sec.
472 */ 478 */
@@ -607,7 +613,53 @@ namespace video {
607} 613}
608 614
609} 615}
616
610%{ 617%{
618/**
619 * NOTE Compatibility with old toxav group calls TODO remove
620 */
621/* Create a new toxav group.
622 *
623 * return group number on success.
624 * return -1 on failure.
625 *
626 * Audio data callback format:
627 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
628 *
629 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
630 */
631int toxav_add_av_groupchat(Tox *tox, void (*audio_callback)(void *, int, int, const int16_t *, unsigned int, uint8_t,
632 unsigned int, void *), void *userdata);
633
634/* Join a AV group (you need to have been invited first.)
635 *
636 * returns group number on success
637 * returns -1 on failure.
638 *
639 * Audio data callback format (same as the one for toxav_add_av_groupchat()):
640 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
641 *
642 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
643 */
644int toxav_join_av_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *data, uint16_t length,
645 void (*audio_callback)(void *, int, int, const int16_t *, unsigned int, uint8_t, unsigned int, void *), void *userdata);
646
647/* Send audio to the group chat.
648 *
649 * return 0 on success.
650 * return -1 on failure.
651 *
652 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
653 *
654 * Valid number of samples are ((sample rate) * (audio length (Valid ones are: 2.5, 5, 10, 20, 40 or 60 ms)) / 1000)
655 * Valid number of channels are 1 or 2.
656 * Valid sample rates are 8000, 12000, 16000, 24000, or 48000.
657 *
658 * Recommended values are: samples = 960, channels = 1, sample_rate = 48000
659 */
660int toxav_group_send_audio(Tox *tox, int groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
661 unsigned int sample_rate);
662
611#ifdef __cplusplus 663#ifdef __cplusplus
612} 664}
613#endif 665#endif
diff --git a/toxav/toxav.h b/toxav/toxav.h
index 08a6d265..947d3c2c 100644
--- a/toxav/toxav.h
+++ b/toxav/toxav.h
@@ -96,6 +96,9 @@ typedef struct ToxAV ToxAV;
96 * :: API version 96 * :: API version
97 * 97 *
98 ******************************************************************************/ 98 ******************************************************************************/
99
100
101
99/** 102/**
100 * The major version number. Incremented when the API or ABI changes in an 103 * The major version number. Incremented when the API or ABI changes in an
101 * incompatible way. 104 * incompatible way.
@@ -168,26 +171,35 @@ bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch)
168 * :: Creation and destruction 171 * :: Creation and destruction
169 * 172 *
170 ******************************************************************************/ 173 ******************************************************************************/
174
175
176
171typedef enum TOXAV_ERR_NEW { 177typedef enum TOXAV_ERR_NEW {
178
172 /** 179 /**
173 * The function returned successfully. 180 * The function returned successfully.
174 */ 181 */
175 TOXAV_ERR_NEW_OK, 182 TOXAV_ERR_NEW_OK,
183
176 /** 184 /**
177 * One of the arguments to the function was NULL when it was not expected. 185 * One of the arguments to the function was NULL when it was not expected.
178 */ 186 */
179 TOXAV_ERR_NEW_NULL, 187 TOXAV_ERR_NEW_NULL,
188
180 /** 189 /**
181 * Memory allocation failure while trying to allocate structures required for 190 * Memory allocation failure while trying to allocate structures required for
182 * the A/V session. 191 * the A/V session.
183 */ 192 */
184 TOXAV_ERR_NEW_MALLOC, 193 TOXAV_ERR_NEW_MALLOC,
194
185 /** 195 /**
186 * Attempted to create a second session for the same Tox instance. 196 * Attempted to create a second session for the same Tox instance.
187 */ 197 */
188 TOXAV_ERR_NEW_MULTIPLE, 198 TOXAV_ERR_NEW_MULTIPLE,
199
189} TOXAV_ERR_NEW; 200} TOXAV_ERR_NEW;
190 201
202
191/** 203/**
192 * Start new A/V session. There can only be only one session per Tox instance. 204 * Start new A/V session. There can only be only one session per Tox instance.
193 */ 205 */
@@ -213,6 +225,9 @@ Tox *toxav_get_tox(const ToxAV *toxAV);
213 * :: A/V event loop 225 * :: A/V event loop
214 * 226 *
215 ******************************************************************************/ 227 ******************************************************************************/
228
229
230
216/** 231/**
217 * Returns the interval in milliseconds when the next toxav_iterate call should 232 * Returns the interval in milliseconds when the next toxav_iterate call should
218 * be. If no call is active at the moment, this function returns 200. 233 * be. If no call is active at the moment, this function returns 200.
@@ -232,39 +247,51 @@ void toxav_iterate(ToxAV *toxAV);
232 * :: Call setup 247 * :: Call setup
233 * 248 *
234 ******************************************************************************/ 249 ******************************************************************************/
250
251
252
235typedef enum TOXAV_ERR_CALL { 253typedef enum TOXAV_ERR_CALL {
254
236 /** 255 /**
237 * The function returned successfully. 256 * The function returned successfully.
238 */ 257 */
239 TOXAV_ERR_CALL_OK, 258 TOXAV_ERR_CALL_OK,
259
240 /** 260 /**
241 * A resource allocation error occurred while trying to create the structures 261 * A resource allocation error occurred while trying to create the structures
242 * required for the call. 262 * required for the call.
243 */ 263 */
244 TOXAV_ERR_CALL_MALLOC, 264 TOXAV_ERR_CALL_MALLOC,
265
245 /** 266 /**
246 * Synchronization error occurred. 267 * Synchronization error occurred.
247 */ 268 */
248 TOXAV_ERR_CALL_SYNC, 269 TOXAV_ERR_CALL_SYNC,
270
249 /** 271 /**
250 * The friend number did not designate a valid friend. 272 * The friend number did not designate a valid friend.
251 */ 273 */
252 TOXAV_ERR_CALL_FRIEND_NOT_FOUND, 274 TOXAV_ERR_CALL_FRIEND_NOT_FOUND,
275
253 /** 276 /**
254 * The friend was valid, but not currently connected. 277 * The friend was valid, but not currently connected.
255 */ 278 */
256 TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED, 279 TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED,
280
257 /** 281 /**
258 * Attempted to call a friend while already in an audio or video call with 282 * Attempted to call a friend while already in an audio or video call with
259 * them. 283 * them.
260 */ 284 */
261 TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL, 285 TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL,
286
262 /** 287 /**
263 * Audio or video bit rate is invalid. 288 * Audio or video bit rate is invalid.
264 */ 289 */
265 TOXAV_ERR_CALL_INVALID_BIT_RATE, 290 TOXAV_ERR_CALL_INVALID_BIT_RATE,
291
266} TOXAV_ERR_CALL; 292} TOXAV_ERR_CALL;
267 293
294
268/** 295/**
269 * Call a friend. This will start ringing the friend. 296 * Call a friend. This will start ringing the friend.
270 * 297 *
@@ -279,8 +306,8 @@ typedef enum TOXAV_ERR_CALL {
279 * @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable 306 * @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable
280 * video sending. 307 * video sending.
281 */ 308 */
282bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, 309bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate,
283 uint32_t video_bit_rate, TOXAV_ERR_CALL *error); 310 TOXAV_ERR_CALL *error);
284 311
285/** 312/**
286 * The function type for the call callback. 313 * The function type for the call callback.
@@ -289,8 +316,9 @@ bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate,
289 * @param audio_enabled True if friend is sending audio. 316 * @param audio_enabled True if friend is sending audio.
290 * @param video_enabled True if friend is sending video. 317 * @param video_enabled True if friend is sending video.
291 */ 318 */
292typedef void toxav_call_cb(ToxAV *toxAV, uint32_t friend_number, bool audio_enabled, 319typedef void toxav_call_cb(ToxAV *toxAV, uint32_t friend_number, bool audio_enabled, bool video_enabled,
293 bool video_enabled, void *user_data); 320 void *user_data);
321
294 322
295/** 323/**
296 * Set the callback for the `call` event. Pass NULL to unset. 324 * Set the callback for the `call` event. Pass NULL to unset.
@@ -299,35 +327,43 @@ typedef void toxav_call_cb(ToxAV *toxAV, uint32_t friend_number, bool audio_enab
299void toxav_callback_call(ToxAV *toxAV, toxav_call_cb *callback, void *user_data); 327void toxav_callback_call(ToxAV *toxAV, toxav_call_cb *callback, void *user_data);
300 328
301typedef enum TOXAV_ERR_ANSWER { 329typedef enum TOXAV_ERR_ANSWER {
330
302 /** 331 /**
303 * The function returned successfully. 332 * The function returned successfully.
304 */ 333 */
305 TOXAV_ERR_ANSWER_OK, 334 TOXAV_ERR_ANSWER_OK,
335
306 /** 336 /**
307 * Synchronization error occurred. 337 * Synchronization error occurred.
308 */ 338 */
309 TOXAV_ERR_ANSWER_SYNC, 339 TOXAV_ERR_ANSWER_SYNC,
340
310 /** 341 /**
311 * Failed to initialize codecs for call session. Note that codec initiation 342 * Failed to initialize codecs for call session. Note that codec initiation
312 * will fail if there is no receive callback registered for either audio or 343 * will fail if there is no receive callback registered for either audio or
313 * video. 344 * video.
314 */ 345 */
315 TOXAV_ERR_ANSWER_CODEC_INITIALIZATION, 346 TOXAV_ERR_ANSWER_CODEC_INITIALIZATION,
347
316 /** 348 /**
317 * The friend number did not designate a valid friend. 349 * The friend number did not designate a valid friend.
318 */ 350 */
319 TOXAV_ERR_ANSWER_FRIEND_NOT_FOUND, 351 TOXAV_ERR_ANSWER_FRIEND_NOT_FOUND,
352
320 /** 353 /**
321 * The friend was valid, but they are not currently trying to initiate a call. 354 * The friend was valid, but they are not currently trying to initiate a call.
322 * This is also returned if this client is already in a call with the friend. 355 * This is also returned if this client is already in a call with the friend.
323 */ 356 */
324 TOXAV_ERR_ANSWER_FRIEND_NOT_CALLING, 357 TOXAV_ERR_ANSWER_FRIEND_NOT_CALLING,
358
325 /** 359 /**
326 * Audio or video bit rate is invalid. 360 * Audio or video bit rate is invalid.
327 */ 361 */
328 TOXAV_ERR_ANSWER_INVALID_BIT_RATE, 362 TOXAV_ERR_ANSWER_INVALID_BIT_RATE,
363
329} TOXAV_ERR_ANSWER; 364} TOXAV_ERR_ANSWER;
330 365
366
331/** 367/**
332 * Accept an incoming call. 368 * Accept an incoming call.
333 * 369 *
@@ -350,7 +386,11 @@ bool toxav_answer(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate,
350 * :: Call state graph 386 * :: Call state graph
351 * 387 *
352 ******************************************************************************/ 388 ******************************************************************************/
389
390
391
353enum TOXAV_FRIEND_CALL_STATE { 392enum TOXAV_FRIEND_CALL_STATE {
393
354 /** 394 /**
355 * Set by the AV core if an error occurred on the remote end or if friend 395 * Set by the AV core if an error occurred on the remote end or if friend
356 * timed out. This is the final state after which no more state 396 * timed out. This is the final state after which no more state
@@ -358,30 +398,37 @@ enum TOXAV_FRIEND_CALL_STATE {
358 * in combination with other call states. 398 * in combination with other call states.
359 */ 399 */
360 TOXAV_FRIEND_CALL_STATE_ERROR = 1, 400 TOXAV_FRIEND_CALL_STATE_ERROR = 1,
401
361 /** 402 /**
362 * The call has finished. This is the final state after which no more state 403 * The call has finished. This is the final state after which no more state
363 * transitions can occur for the call. This call state will never be 404 * transitions can occur for the call. This call state will never be
364 * triggered in combination with other call states. 405 * triggered in combination with other call states.
365 */ 406 */
366 TOXAV_FRIEND_CALL_STATE_FINISHED = 2, 407 TOXAV_FRIEND_CALL_STATE_FINISHED = 2,
408
367 /** 409 /**
368 * The flag that marks that friend is sending audio. 410 * The flag that marks that friend is sending audio.
369 */ 411 */
370 TOXAV_FRIEND_CALL_STATE_SENDING_A = 4, 412 TOXAV_FRIEND_CALL_STATE_SENDING_A = 4,
413
371 /** 414 /**
372 * The flag that marks that friend is sending video. 415 * The flag that marks that friend is sending video.
373 */ 416 */
374 TOXAV_FRIEND_CALL_STATE_SENDING_V = 8, 417 TOXAV_FRIEND_CALL_STATE_SENDING_V = 8,
418
375 /** 419 /**
376 * The flag that marks that friend is receiving audio. 420 * The flag that marks that friend is receiving audio.
377 */ 421 */
378 TOXAV_FRIEND_CALL_STATE_ACCEPTING_A = 16, 422 TOXAV_FRIEND_CALL_STATE_ACCEPTING_A = 16,
423
379 /** 424 /**
380 * The flag that marks that friend is receiving video. 425 * The flag that marks that friend is receiving video.
381 */ 426 */
382 TOXAV_FRIEND_CALL_STATE_ACCEPTING_V = 32, 427 TOXAV_FRIEND_CALL_STATE_ACCEPTING_V = 32,
428
383}; 429};
384 430
431
385/** 432/**
386 * The function type for the call_state callback. 433 * The function type for the call_state callback.
387 * 434 *
@@ -393,79 +440,100 @@ enum TOXAV_FRIEND_CALL_STATE {
393 */ 440 */
394typedef void toxav_call_state_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t state, void *user_data); 441typedef void toxav_call_state_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t state, void *user_data);
395 442
443
396/** 444/**
397 * Set the callback for the `call_state` event. Pass NULL to unset. 445 * Set the callback for the `call_state` event. Pass NULL to unset.
398 * 446 *
399 */ 447 */
400void toxav_callback_call_state(ToxAV *toxAV, toxav_call_state_cb *callback, void *user_data); 448void toxav_callback_call_state(ToxAV *toxAV, toxav_call_state_cb *callback, void *user_data);
401 449
450
402/******************************************************************************* 451/*******************************************************************************
403 * 452 *
404 * :: Call control 453 * :: Call control
405 * 454 *
406 ******************************************************************************/ 455 ******************************************************************************/
456
457
458
407typedef enum TOXAV_CALL_CONTROL { 459typedef enum TOXAV_CALL_CONTROL {
460
408 /** 461 /**
409 * Resume a previously paused call. Only valid if the pause was caused by this 462 * Resume a previously paused call. Only valid if the pause was caused by this
410 * client, if not, this control is ignored. Not valid before the call is accepted. 463 * client, if not, this control is ignored. Not valid before the call is accepted.
411 */ 464 */
412 TOXAV_CALL_CONTROL_RESUME, 465 TOXAV_CALL_CONTROL_RESUME,
466
413 /** 467 /**
414 * Put a call on hold. Not valid before the call is accepted. 468 * Put a call on hold. Not valid before the call is accepted.
415 */ 469 */
416 TOXAV_CALL_CONTROL_PAUSE, 470 TOXAV_CALL_CONTROL_PAUSE,
471
417 /** 472 /**
418 * Reject a call if it was not answered, yet. Cancel a call after it was 473 * Reject a call if it was not answered, yet. Cancel a call after it was
419 * answered. 474 * answered.
420 */ 475 */
421 TOXAV_CALL_CONTROL_CANCEL, 476 TOXAV_CALL_CONTROL_CANCEL,
477
422 /** 478 /**
423 * Request that the friend stops sending audio. Regardless of the friend's 479 * Request that the friend stops sending audio. Regardless of the friend's
424 * compliance, this will cause the audio_receive_frame event to stop being 480 * compliance, this will cause the audio_receive_frame event to stop being
425 * triggered on receiving an audio frame from the friend. 481 * triggered on receiving an audio frame from the friend.
426 */ 482 */
427 TOXAV_CALL_CONTROL_MUTE_AUDIO, 483 TOXAV_CALL_CONTROL_MUTE_AUDIO,
484
428 /** 485 /**
429 * Calling this control will notify client to start sending audio again. 486 * Calling this control will notify client to start sending audio again.
430 */ 487 */
431 TOXAV_CALL_CONTROL_UNMUTE_AUDIO, 488 TOXAV_CALL_CONTROL_UNMUTE_AUDIO,
489
432 /** 490 /**
433 * Request that the friend stops sending video. Regardless of the friend's 491 * Request that the friend stops sending video. Regardless of the friend's
434 * compliance, this will cause the video_receive_frame event to stop being 492 * compliance, this will cause the video_receive_frame event to stop being
435 * triggered on receiving a video frame from the friend. 493 * triggered on receiving a video frame from the friend.
436 */ 494 */
437 TOXAV_CALL_CONTROL_HIDE_VIDEO, 495 TOXAV_CALL_CONTROL_HIDE_VIDEO,
496
438 /** 497 /**
439 * Calling this control will notify client to start sending video again. 498 * Calling this control will notify client to start sending video again.
440 */ 499 */
441 TOXAV_CALL_CONTROL_SHOW_VIDEO, 500 TOXAV_CALL_CONTROL_SHOW_VIDEO,
501
442} TOXAV_CALL_CONTROL; 502} TOXAV_CALL_CONTROL;
443 503
504
444typedef enum TOXAV_ERR_CALL_CONTROL { 505typedef enum TOXAV_ERR_CALL_CONTROL {
506
445 /** 507 /**
446 * The function returned successfully. 508 * The function returned successfully.
447 */ 509 */
448 TOXAV_ERR_CALL_CONTROL_OK, 510 TOXAV_ERR_CALL_CONTROL_OK,
511
449 /** 512 /**
450 * Synchronization error occurred. 513 * Synchronization error occurred.
451 */ 514 */
452 TOXAV_ERR_CALL_CONTROL_SYNC, 515 TOXAV_ERR_CALL_CONTROL_SYNC,
516
453 /** 517 /**
454 * The friend_number passed did not designate a valid friend. 518 * The friend_number passed did not designate a valid friend.
455 */ 519 */
456 TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND, 520 TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND,
521
457 /** 522 /**
458 * This client is currently not in a call with the friend. Before the call is 523 * This client is currently not in a call with the friend. Before the call is
459 * answered, only CANCEL is a valid control. 524 * answered, only CANCEL is a valid control.
460 */ 525 */
461 TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL, 526 TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL,
527
462 /** 528 /**
463 * Happens if user tried to pause an already paused call or if trying to 529 * Happens if user tried to pause an already paused call or if trying to
464 * resume a call that is not paused. 530 * resume a call that is not paused.
465 */ 531 */
466 TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION, 532 TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION,
533
467} TOXAV_ERR_CALL_CONTROL; 534} TOXAV_ERR_CALL_CONTROL;
468 535
536
469/** 537/**
470 * Sends a call control command to a friend. 538 * Sends a call control command to a friend.
471 * 539 *
@@ -484,33 +552,44 @@ bool toxav_call_control(ToxAV *toxAV, uint32_t friend_number, TOXAV_CALL_CONTROL
484 * :: Controlling bit rates 552 * :: Controlling bit rates
485 * 553 *
486 ******************************************************************************/ 554 ******************************************************************************/
555
556
557
487typedef enum TOXAV_ERR_BIT_RATE_SET { 558typedef enum TOXAV_ERR_BIT_RATE_SET {
559
488 /** 560 /**
489 * The function returned successfully. 561 * The function returned successfully.
490 */ 562 */
491 TOXAV_ERR_BIT_RATE_SET_OK, 563 TOXAV_ERR_BIT_RATE_SET_OK,
564
492 /** 565 /**
493 * Synchronization error occurred. 566 * Synchronization error occurred.
494 */ 567 */
495 TOXAV_ERR_BIT_RATE_SET_SYNC, 568 TOXAV_ERR_BIT_RATE_SET_SYNC,
569
496 /** 570 /**
497 * The audio bit rate passed was not one of the supported values. 571 * The audio bit rate passed was not one of the supported values.
498 */ 572 */
499 TOXAV_ERR_BIT_RATE_SET_INVALID_AUDIO_BIT_RATE, 573 TOXAV_ERR_BIT_RATE_SET_INVALID_AUDIO_BIT_RATE,
574
500 /** 575 /**
501 * The video bit rate passed was not one of the supported values. 576 * The video bit rate passed was not one of the supported values.
502 */ 577 */
503 TOXAV_ERR_BIT_RATE_SET_INVALID_VIDEO_BIT_RATE, 578 TOXAV_ERR_BIT_RATE_SET_INVALID_VIDEO_BIT_RATE,
579
504 /** 580 /**
505 * The friend_number passed did not designate a valid friend. 581 * The friend_number passed did not designate a valid friend.
506 */ 582 */
507 TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_FOUND, 583 TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_FOUND,
584
508 /** 585 /**
509 * This client is currently not in a call with the friend. 586 * This client is currently not in a call with the friend.
510 */ 587 */
511 TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL, 588 TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL,
589
512} TOXAV_ERR_BIT_RATE_SET; 590} TOXAV_ERR_BIT_RATE_SET;
513 591
592
514/** 593/**
515 * Set the bit rate to be used in subsequent audio/video frames. 594 * Set the bit rate to be used in subsequent audio/video frames.
516 * 595 *
@@ -522,8 +601,8 @@ typedef enum TOXAV_ERR_BIT_RATE_SET {
522 * video sending. Set to -1 to leave unchanged. 601 * video sending. Set to -1 to leave unchanged.
523 * 602 *
524 */ 603 */
525bool toxav_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, int32_t audio_bit_rate, 604bool toxav_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, int32_t audio_bit_rate, int32_t video_bit_rate,
526 int32_t video_bit_rate, TOXAV_ERR_BIT_RATE_SET *error); 605 TOXAV_ERR_BIT_RATE_SET *error);
527 606
528/** 607/**
529 * The function type for the bit_rate_status callback. The event is triggered 608 * The function type for the bit_rate_status callback. The event is triggered
@@ -538,6 +617,7 @@ bool toxav_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, int32_t audio_bit_
538typedef void toxav_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, 617typedef void toxav_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate,
539 uint32_t video_bit_rate, void *user_data); 618 uint32_t video_bit_rate, void *user_data);
540 619
620
541/** 621/**
542 * Set the callback for the `bit_rate_status` event. Pass NULL to unset. 622 * Set the callback for the `bit_rate_status` event. Pass NULL to unset.
543 * 623 *
@@ -550,44 +630,57 @@ void toxav_callback_bit_rate_status(ToxAV *toxAV, toxav_bit_rate_status_cb *call
550 * :: A/V sending 630 * :: A/V sending
551 * 631 *
552 ******************************************************************************/ 632 ******************************************************************************/
633
634
635
553typedef enum TOXAV_ERR_SEND_FRAME { 636typedef enum TOXAV_ERR_SEND_FRAME {
637
554 /** 638 /**
555 * The function returned successfully. 639 * The function returned successfully.
556 */ 640 */
557 TOXAV_ERR_SEND_FRAME_OK, 641 TOXAV_ERR_SEND_FRAME_OK,
642
558 /** 643 /**
559 * In case of video, one of Y, U, or V was NULL. In case of audio, the samples 644 * In case of video, one of Y, U, or V was NULL. In case of audio, the samples
560 * data pointer was NULL. 645 * data pointer was NULL.
561 */ 646 */
562 TOXAV_ERR_SEND_FRAME_NULL, 647 TOXAV_ERR_SEND_FRAME_NULL,
648
563 /** 649 /**
564 * The friend_number passed did not designate a valid friend. 650 * The friend_number passed did not designate a valid friend.
565 */ 651 */
566 TOXAV_ERR_SEND_FRAME_FRIEND_NOT_FOUND, 652 TOXAV_ERR_SEND_FRAME_FRIEND_NOT_FOUND,
653
567 /** 654 /**
568 * This client is currently not in a call with the friend. 655 * This client is currently not in a call with the friend.
569 */ 656 */
570 TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL, 657 TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL,
658
571 /** 659 /**
572 * Synchronization error occurred. 660 * Synchronization error occurred.
573 */ 661 */
574 TOXAV_ERR_SEND_FRAME_SYNC, 662 TOXAV_ERR_SEND_FRAME_SYNC,
663
575 /** 664 /**
576 * One of the frame parameters was invalid. E.g. the resolution may be too 665 * One of the frame parameters was invalid. E.g. the resolution may be too
577 * small or too large, or the audio sampling rate may be unsupported. 666 * small or too large, or the audio sampling rate may be unsupported.
578 */ 667 */
579 TOXAV_ERR_SEND_FRAME_INVALID, 668 TOXAV_ERR_SEND_FRAME_INVALID,
669
580 /** 670 /**
581 * Either friend turned off audio or video receiving or we turned off sending 671 * Either friend turned off audio or video receiving or we turned off sending
582 * for the said payload. 672 * for the said payload.
583 */ 673 */
584 TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED, 674 TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED,
675
585 /** 676 /**
586 * Failed to push frame through rtp interface. 677 * Failed to push frame through rtp interface.
587 */ 678 */
588 TOXAV_ERR_SEND_FRAME_RTP_FAILED, 679 TOXAV_ERR_SEND_FRAME_RTP_FAILED,
680
589} TOXAV_ERR_SEND_FRAME; 681} TOXAV_ERR_SEND_FRAME;
590 682
683
591/** 684/**
592 * Send an audio frame to a friend. 685 * Send an audio frame to a friend.
593 * 686 *
@@ -608,9 +701,8 @@ typedef enum TOXAV_ERR_SEND_FRAME {
608 * @param sampling_rate Audio sampling rate used in this frame. Valid sampling 701 * @param sampling_rate Audio sampling rate used in this frame. Valid sampling
609 * rates are 8000, 12000, 16000, 24000, or 48000. 702 * rates are 8000, 12000, 16000, 24000, or 48000.
610 */ 703 */
611bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, 704bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count,
612 size_t sample_count, uint8_t channels, uint32_t sampling_rate, 705 uint8_t channels, uint32_t sampling_rate, TOXAV_ERR_SEND_FRAME *error);
613 TOXAV_ERR_SEND_FRAME *error);
614 706
615/** 707/**
616 * Send a video frame to a friend. 708 * Send a video frame to a friend.
@@ -627,9 +719,8 @@ bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t
627 * @param u U (Chroma) plane data. 719 * @param u U (Chroma) plane data.
628 * @param v V (Chroma) plane data. 720 * @param v V (Chroma) plane data.
629 */ 721 */
630bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width, 722bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y,
631 uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, 723 const uint8_t *u, const uint8_t *v, TOXAV_ERR_SEND_FRAME *error);
632 TOXAV_ERR_SEND_FRAME *error);
633 724
634 725
635/******************************************************************************* 726/*******************************************************************************
@@ -637,6 +728,9 @@ bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width
637 * :: A/V receiving 728 * :: A/V receiving
638 * 729 *
639 ******************************************************************************/ 730 ******************************************************************************/
731
732
733
640/** 734/**
641 * The function type for the audio_receive_frame callback. The callback can be 735 * The function type for the audio_receive_frame callback. The callback can be
642 * called multiple times per single iteration depending on the amount of queued 736 * called multiple times per single iteration depending on the amount of queued
@@ -649,9 +743,9 @@ bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width
649 * @param sampling_rate Sampling rate used in this frame. 743 * @param sampling_rate Sampling rate used in this frame.
650 * 744 *
651 */ 745 */
652typedef void toxav_audio_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, 746typedef void toxav_audio_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm, size_t sample_count,
653 size_t sample_count, uint8_t channels, uint32_t sampling_rate, 747 uint8_t channels, uint32_t sampling_rate, void *user_data);
654 void *user_data); 748
655 749
656/** 750/**
657 * Set the callback for the `audio_receive_frame` event. Pass NULL to unset. 751 * Set the callback for the `audio_receive_frame` event. Pass NULL to unset.
@@ -680,9 +774,10 @@ void toxav_callback_audio_receive_frame(ToxAV *toxAV, toxav_audio_receive_frame_
680 * image is bottom-up hence why you MUST abs() it when 774 * image is bottom-up hence why you MUST abs() it when
681 * calculating plane buffer size. 775 * calculating plane buffer size.
682 */ 776 */
683typedef void toxav_video_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, uint16_t width, 777typedef void toxav_video_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, uint16_t width, uint16_t height,
684 uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v, 778 const uint8_t *y, const uint8_t *u, const uint8_t *v, int32_t ystride, int32_t ustride, int32_t vstride,
685 int32_t ystride, int32_t ustride, int32_t vstride, void *user_data); 779 void *user_data);
780
686 781
687/** 782/**
688 * Set the callback for the `video_receive_frame` event. Pass NULL to unset. 783 * Set the callback for the `video_receive_frame` event. Pass NULL to unset.