summaryrefslogtreecommitdiff
path: root/toxav/toxav.h
diff options
context:
space:
mode:
authorEniz Vukovic <eniz_vukovic@hotmail.com>2015-10-10 23:54:23 +0200
committerEniz Vukovic <eniz_vukovic@hotmail.com>2015-10-10 23:54:23 +0200
commitd6fdf16520b6f242935ca95eeb739ec9a8eaa14c (patch)
tree069f3355835aa0497fe494c36554ea24d0b222f1 /toxav/toxav.h
parentbf5e9b89d2a67c293aae503c03e193307ea7990b (diff)
New Adaptive BR algorithm, cleanups and fixes
Diffstat (limited to 'toxav/toxav.h')
-rw-r--r--toxav/toxav.h226
1 files changed, 113 insertions, 113 deletions
diff --git a/toxav/toxav.h b/toxav/toxav.h
index 58d5503f..e83f4edc 100644
--- a/toxav/toxav.h
+++ b/toxav/toxav.h
@@ -52,12 +52,19 @@ extern "C" {
52/** \subsection threading Threading implications 52/** \subsection threading Threading implications
53 * 53 *
54 * Unlike the Core API, this API is fully thread-safe. The library will ensure 54 * Unlike the Core API, this API is fully thread-safe. The library will ensure
55 * the proper synchronisation of parallel calls. 55 * the proper synchronization of parallel calls.
56 * 56 *
57 * A common way to run ToxAV (multiple or single instance) is to have a thread, 57 * A common way to run ToxAV (multiple or single instance) is to have a thread,
58 * separate from tox instance thread, running a simple toxav_iterate loop, 58 * separate from tox instance thread, running a simple toxav_iterate loop,
59 * sleeping for toxav_iteration_interval * milliseconds on each iteration. 59 * sleeping for toxav_iteration_interval * milliseconds on each iteration.
60 * 60 *
61 * An important thing to note is that events are triggered from both tox and
62 * toxav thread (see above). Audio and video receive frame events are triggered
63 * from toxav thread while all the other events are triggered from tox thread.
64 *
65 * Tox thread has priority with mutex mechanisms. Any api function can
66 * fail if mutexes are held by tox thread in which case they will set SYNC
67 * error code.
61 */ 68 */
62/** 69/**
63 * External Tox type. 70 * External Tox type.
@@ -80,8 +87,10 @@ typedef struct Tox Tox;
80 */ 87 */
81#ifndef TOXAV_DEFINED 88#ifndef TOXAV_DEFINED
82#define TOXAV_DEFINED 89#define TOXAV_DEFINED
83typedef struct ToxAV ToxAV; 90typedef struct ToxAV_s ToxAV;
84#endif /* TOXAV_DEFINED */ 91#endif /* TOXAV_DEFINED */
92
93
85/******************************************************************************* 94/*******************************************************************************
86 * 95 *
87 * :: API version 96 * :: API version
@@ -92,17 +101,20 @@ typedef struct ToxAV ToxAV;
92 * incompatible way. 101 * incompatible way.
93 */ 102 */
94#define TOXAV_VERSION_MAJOR 0u 103#define TOXAV_VERSION_MAJOR 0u
104
95/** 105/**
96 * The minor version number. Incremented when functionality is added without 106 * The minor version number. Incremented when functionality is added without
97 * breaking the API or ABI. Set to 0 when the major version number is 107 * breaking the API or ABI. Set to 0 when the major version number is
98 * incremented. 108 * incremented.
99 */ 109 */
100#define TOXAV_VERSION_MINOR 0u 110#define TOXAV_VERSION_MINOR 0u
111
101/** 112/**
102 * The patch or revision number. Incremented when bugfixes are applied without 113 * The patch or revision number. Incremented when bugfixes are applied without
103 * changing any functionality or API or ABI. 114 * changing any functionality or API or ABI.
104 */ 115 */
105#define TOXAV_VERSION_PATCH 0u 116#define TOXAV_VERSION_PATCH 0u
117
106/** 118/**
107 * A macro to check at preprocessing time whether the client code is compatible 119 * A macro to check at preprocessing time whether the client code is compatible
108 * with the installed version of ToxAV. 120 * with the installed version of ToxAV.
@@ -112,37 +124,45 @@ typedef struct ToxAV ToxAV;
112 (TOXAV_VERSION_MINOR > MINOR || \ 124 (TOXAV_VERSION_MINOR > MINOR || \
113 (TOXAV_VERSION_MINOR == MINOR && \ 125 (TOXAV_VERSION_MINOR == MINOR && \
114 TOXAV_VERSION_PATCH >= PATCH))) 126 TOXAV_VERSION_PATCH >= PATCH)))
127
115/** 128/**
116 * A macro to make compilation fail if the client code is not compatible with 129 * A macro to make compilation fail if the client code is not compatible with
117 * the installed version of ToxAV. 130 * the installed version of ToxAV.
118 */ 131 */
119#define TOXAV_VERSION_REQUIRE(MAJOR, MINOR, PATCH) \ 132#define TOXAV_VERSION_REQUIRE(MAJOR, MINOR, PATCH) \
120 typedef char toxav_required_version[TOXAV_IS_COMPATIBLE(MAJOR, MINOR, PATCH) ? 1 : -1] 133 typedef char toxav_required_version[TOXAV_IS_COMPATIBLE(MAJOR, MINOR, PATCH) ? 1 : -1]
134
121/** 135/**
122 * A convenience macro to call toxav_version_is_compatible with the currently 136 * A convenience macro to call toxav_version_is_compatible with the currently
123 * compiling API version. 137 * compiling API version.
124 */ 138 */
125#define TOXAV_VERSION_IS_ABI_COMPATIBLE() \ 139#define TOXAV_VERSION_IS_ABI_COMPATIBLE() \
126 toxav_version_is_compatible(TOXAV_VERSION_MAJOR, TOXAV_VERSION_MINOR, TOXAV_VERSION_PATCH) 140 toxav_version_is_compatible(TOXAV_VERSION_MAJOR, TOXAV_VERSION_MINOR, TOXAV_VERSION_PATCH)
141
127/** 142/**
128 * Return the major version number of the library. Can be used to display the 143 * Return the major version number of the library. Can be used to display the
129 * ToxAV library version or to check whether the client is compatible with the 144 * ToxAV library version or to check whether the client is compatible with the
130 * dynamically linked version of ToxAV. 145 * dynamically linked version of ToxAV.
131 */ 146 */
132uint32_t toxav_version_major(void); 147uint32_t toxav_version_major(void);
148
133/** 149/**
134 * Return the minor version number of the library. 150 * Return the minor version number of the library.
135 */ 151 */
136uint32_t toxav_version_minor(void); 152uint32_t toxav_version_minor(void);
153
137/** 154/**
138 * Return the patch number of the library. 155 * Return the patch number of the library.
139 */ 156 */
140uint32_t toxav_version_patch(void); 157uint32_t toxav_version_patch(void);
158
141/** 159/**
142 * Return whether the compiled library version is compatible with the passed 160 * Return whether the compiled library version is compatible with the passed
143 * version numbers. 161 * version numbers.
144 */ 162 */
145bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch); 163bool toxav_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch);
164
165
146/******************************************************************************* 166/*******************************************************************************
147 * 167 *
148 * :: Creation and destruction 168 * :: Creation and destruction
@@ -167,10 +187,12 @@ typedef enum TOXAV_ERR_NEW {
167 */ 187 */
168 TOXAV_ERR_NEW_MULTIPLE, 188 TOXAV_ERR_NEW_MULTIPLE,
169} TOXAV_ERR_NEW; 189} TOXAV_ERR_NEW;
190
170/** 191/**
171 * Start new A/V session. There can only be only one session per Tox instance. 192 * Start new A/V session. There can only be only one session per Tox instance.
172 */ 193 */
173ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error); 194ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error);
195
174/** 196/**
175 * Releases all resources associated with the A/V session. 197 * Releases all resources associated with the A/V session.
176 * 198 *
@@ -179,10 +201,13 @@ ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error);
179 * called and the av pointer becomes invalid. 201 * called and the av pointer becomes invalid.
180 */ 202 */
181void toxav_kill(ToxAV *toxAV); 203void toxav_kill(ToxAV *toxAV);
204
182/** 205/**
183 * Returns the Tox instance the A/V object was created for. 206 * Returns the Tox instance the A/V object was created for.
184 */ 207 */
185Tox *toxav_get_tox(const ToxAV *toxAV); 208Tox *toxav_get_tox(const ToxAV *toxAV);
209
210
186/******************************************************************************* 211/*******************************************************************************
187 * 212 *
188 * :: A/V event loop 213 * :: A/V event loop
@@ -193,12 +218,15 @@ Tox *toxav_get_tox(const ToxAV *toxAV);
193 * be. If no call is active at the moment, this function returns 200. 218 * be. If no call is active at the moment, this function returns 200.
194 */ 219 */
195uint32_t toxav_iteration_interval(const ToxAV *toxAV); 220uint32_t toxav_iteration_interval(const ToxAV *toxAV);
221
196/** 222/**
197 * Main loop for the session. This function needs to be called in intervals of 223 * Main loop for the session. This function needs to be called in intervals of
198 * toxav_iteration_interval() milliseconds. It is best called in the separate 224 * toxav_iteration_interval() milliseconds. It is best called in the separate
199 * thread from tox_iterate. 225 * thread from tox_iterate.
200 */ 226 */
201void toxav_iterate(ToxAV *toxAV); 227void toxav_iterate(ToxAV *toxAV);
228
229
202/******************************************************************************* 230/*******************************************************************************
203 * 231 *
204 * :: Call setup 232 * :: Call setup
@@ -215,6 +243,10 @@ typedef enum TOXAV_ERR_CALL {
215 */ 243 */
216 TOXAV_ERR_CALL_MALLOC, 244 TOXAV_ERR_CALL_MALLOC,
217 /** 245 /**
246 * Synchronization error occurred.
247 */
248 TOXAV_ERR_CALL_SYNC,
249 /**
218 * The friend number did not designate a valid friend. 250 * The friend number did not designate a valid friend.
219 */ 251 */
220 TOXAV_ERR_CALL_FRIEND_NOT_FOUND, 252 TOXAV_ERR_CALL_FRIEND_NOT_FOUND,
@@ -232,6 +264,7 @@ typedef enum TOXAV_ERR_CALL {
232 */ 264 */
233 TOXAV_ERR_CALL_INVALID_BIT_RATE, 265 TOXAV_ERR_CALL_INVALID_BIT_RATE,
234} TOXAV_ERR_CALL; 266} TOXAV_ERR_CALL;
267
235/** 268/**
236 * Call a friend. This will start ringing the friend. 269 * Call a friend. This will start ringing the friend.
237 * 270 *
@@ -246,7 +279,9 @@ typedef enum TOXAV_ERR_CALL {
246 * @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable 279 * @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable
247 * video sending. 280 * video sending.
248 */ 281 */
249bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_CALL *error); 282bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate,
283 uint32_t video_bit_rate, TOXAV_ERR_CALL *error);
284
250/** 285/**
251 * The function type for the call callback. 286 * The function type for the call callback.
252 * 287 *
@@ -254,18 +289,25 @@ bool toxav_call(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, u
254 * @param audio_enabled True if friend is sending audio. 289 * @param audio_enabled True if friend is sending audio.
255 * @param video_enabled True if friend is sending video. 290 * @param video_enabled True if friend is sending video.
256 */ 291 */
257typedef void toxav_call_cb(ToxAV *toxAV, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data); 292typedef void toxav_call_cb(ToxAV *toxAV, uint32_t friend_number, bool audio_enabled,
293 bool video_enabled, void *user_data);
294
258/** 295/**
259 * Set the callback for the `call` event. Pass NULL to unset. 296 * Set the callback for the `call` event. Pass NULL to unset.
260 * 297 *
261 */ 298 */
262void toxav_callback_call(ToxAV *toxAV, toxav_call_cb *callback, void *user_data); 299void toxav_callback_call(ToxAV *toxAV, toxav_call_cb *callback, void *user_data);
300
263typedef enum TOXAV_ERR_ANSWER { 301typedef enum TOXAV_ERR_ANSWER {
264 /** 302 /**
265 * The function returned successfully. 303 * The function returned successfully.
266 */ 304 */
267 TOXAV_ERR_ANSWER_OK, 305 TOXAV_ERR_ANSWER_OK,
268 /** 306 /**
307 * Synchronization error occurred.
308 */
309 TOXAV_ERR_ANSWER_SYNC,
310 /**
269 * Failed to initialize codecs for call session. Note that codec initiation 311 * Failed to initialize codecs for call session. Note that codec initiation
270 * will fail if there is no receive callback registered for either audio or 312 * will fail if there is no receive callback registered for either audio or
271 * video. 313 * video.
@@ -285,6 +327,7 @@ typedef enum TOXAV_ERR_ANSWER {
285 */ 327 */
286 TOXAV_ERR_ANSWER_INVALID_BIT_RATE, 328 TOXAV_ERR_ANSWER_INVALID_BIT_RATE,
287} TOXAV_ERR_ANSWER; 329} TOXAV_ERR_ANSWER;
330
288/** 331/**
289 * Accept an incoming call. 332 * Accept an incoming call.
290 * 333 *
@@ -299,6 +342,8 @@ typedef enum TOXAV_ERR_ANSWER {
299 * video sending. 342 * video sending.
300 */ 343 */
301bool toxav_answer(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_ANSWER *error); 344bool toxav_answer(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_ANSWER *error);
345
346
302/******************************************************************************* 347/*******************************************************************************
303 * 348 *
304 * :: Call state graph 349 * :: Call state graph
@@ -336,7 +381,6 @@ enum TOXAV_FRIEND_CALL_STATE {
336 TOXAV_FRIEND_CALL_STATE_ACCEPTING_V = 32, 381 TOXAV_FRIEND_CALL_STATE_ACCEPTING_V = 32,
337}; 382};
338 383
339
340/** 384/**
341 * The function type for the call_state callback. 385 * The function type for the call_state callback.
342 * 386 *
@@ -347,11 +391,13 @@ enum TOXAV_FRIEND_CALL_STATE {
347 * friend. 391 * friend.
348 */ 392 */
349typedef void toxav_call_state_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t state, void *user_data); 393typedef void toxav_call_state_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t state, void *user_data);
394
350/** 395/**
351 * Set the callback for the `call_state` event. Pass NULL to unset. 396 * Set the callback for the `call_state` event. Pass NULL to unset.
352 * 397 *
353 */ 398 */
354void toxav_callback_call_state(ToxAV *toxAV, toxav_call_state_cb *callback, void *user_data); 399void toxav_callback_call_state(ToxAV *toxAV, toxav_call_state_cb *callback, void *user_data);
400
355/******************************************************************************* 401/*******************************************************************************
356 * 402 *
357 * :: Call control 403 * :: Call control
@@ -393,12 +439,17 @@ typedef enum TOXAV_CALL_CONTROL {
393 */ 439 */
394 TOXAV_CALL_CONTROL_SHOW_VIDEO, 440 TOXAV_CALL_CONTROL_SHOW_VIDEO,
395} TOXAV_CALL_CONTROL; 441} TOXAV_CALL_CONTROL;
442
396typedef enum TOXAV_ERR_CALL_CONTROL { 443typedef enum TOXAV_ERR_CALL_CONTROL {
397 /** 444 /**
398 * The function returned successfully. 445 * The function returned successfully.
399 */ 446 */
400 TOXAV_ERR_CALL_CONTROL_OK, 447 TOXAV_ERR_CALL_CONTROL_OK,
401 /** 448 /**
449 * Synchronization error occurred.
450 */
451 TOXAV_ERR_CALL_CONTROL_SYNC,
452 /**
402 * The friend_number passed did not designate a valid friend. 453 * The friend_number passed did not designate a valid friend.
403 */ 454 */
404 TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND, 455 TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND,
@@ -413,6 +464,7 @@ typedef enum TOXAV_ERR_CALL_CONTROL {
413 */ 464 */
414 TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION, 465 TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION,
415} TOXAV_ERR_CALL_CONTROL; 466} TOXAV_ERR_CALL_CONTROL;
467
416/** 468/**
417 * Sends a call control command to a friend. 469 * Sends a call control command to a friend.
418 * 470 *
@@ -423,48 +475,40 @@ typedef enum TOXAV_ERR_CALL_CONTROL {
423 * @return true on success. 475 * @return true on success.
424 */ 476 */
425bool toxav_call_control(ToxAV *toxAV, uint32_t friend_number, TOXAV_CALL_CONTROL control, TOXAV_ERR_CALL_CONTROL *error); 477bool toxav_call_control(ToxAV *toxAV, uint32_t friend_number, TOXAV_CALL_CONTROL control, TOXAV_ERR_CALL_CONTROL *error);
478
479
426/******************************************************************************* 480/*******************************************************************************
427 * 481 *
428 * :: Controlling bit rates 482 * :: Controlling bit rates
429 * 483 *
430 ******************************************************************************/ 484 ******************************************************************************/
431typedef enum TOXAV_ERR_SET_BIT_RATE { 485typedef enum TOXAV_ERR_BIT_RATE_SET {
432 /** 486 /**
433 * The function returned successfully. 487 * The function returned successfully.
434 */ 488 */
435 TOXAV_ERR_SET_BIT_RATE_OK, 489 TOXAV_ERR_BIT_RATE_SET_OK,
490 /**
491 * Synchronization error occurred.
492 */
493 TOXAV_ERR_BIT_RATE_SET_SYNC,
436 /** 494 /**
437 * The bit rate passed was not one of the supported values. 495 * The audio bit rate passed was not one of the supported values.
438 */ 496 */
439 TOXAV_ERR_SET_BIT_RATE_INVALID, 497 TOXAV_ERR_BIT_RATE_SET_INVALID_AUDIO_BIT_RATE,
498 /**
499 * The video bit rate passed was not one of the supported values.
500 */
501 TOXAV_ERR_BIT_RATE_SET_INVALID_VIDEO_BIT_RATE,
440 /** 502 /**
441 * The friend_number passed did not designate a valid friend. 503 * The friend_number passed did not designate a valid friend.
442 */ 504 */
443 TOXAV_ERR_SET_BIT_RATE_FRIEND_NOT_FOUND, 505 TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_FOUND,
444 /** 506 /**
445 * This client is currently not in a call with the friend. 507 * This client is currently not in a call with the friend.
446 */ 508 */
447 TOXAV_ERR_SET_BIT_RATE_FRIEND_NOT_IN_CALL, 509 TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL,
448} TOXAV_ERR_SET_BIT_RATE; 510} TOXAV_ERR_BIT_RATE_SET;
449/** 511
450 * The function type for the audio_bit_rate_status callback.
451 *
452 * @param friend_number The friend number of the friend for which to set the
453 * audio bit rate.
454 * @param stable Is the stream stable enough to keep the bit rate.
455 * Upon successful, non forceful, bit rate change, this is set to
456 * true and 'bit_rate' is set to new bit rate.
457 * The stable is set to false with bit_rate set to the unstable
458 * bit rate when either current stream is unstable with said bit rate
459 * or the non forceful change failed.
460 * @param bit_rate The bit rate in Kb/sec.
461 */
462typedef void toxav_audio_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, bool stable, uint32_t bit_rate, void *user_data);
463/**
464 * Set the callback for the `audio_bit_rate_status` event. Pass NULL to unset.
465 *
466 */
467void toxav_callback_audio_bit_rate_status(ToxAV *toxAV, toxav_audio_bit_rate_status_cb *callback, void *user_data);
468/** 512/**
469 * Set the audio bit rate to be used in subsequent audio frames. If the passed 513 * Set the audio bit rate to be used in subsequent audio frames. If the passed
470 * bit rate is the same as the current bit rate this function will return true 514 * bit rate is the same as the current bit rate this function will return true
@@ -476,46 +520,33 @@ void toxav_callback_audio_bit_rate_status(ToxAV *toxAV, toxav_audio_bit_rate_sta
476 * @param friend_number The friend number of the friend for which to set the 520 * @param friend_number The friend number of the friend for which to set the
477 * audio bit rate. 521 * audio bit rate.
478 * @param audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable 522 * @param audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable
479 * audio sending. 523 * audio sending. Set to -1 to leave unchanged.
480 * @param force True if the bit rate change is forceful. 524 * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable
525 * video sending. Set to -1 to leave unchanged.
481 * 526 *
482 */ 527 */
483bool toxav_audio_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE *error); 528bool toxav_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, int32_t audio_bit_rate,
529 int32_t video_bit_rate, TOXAV_ERR_BIT_RATE_SET *error);
530
484/** 531/**
485 * The function type for the video_bit_rate_status callback. 532 * The function type for the bit_rate_status callback. The event is triggered
533 * when the network becomes too saturated for current bit rates at which
534 * point core suggests new bit rates.
486 * 535 *
487 * @param friend_number The friend number of the friend for which to set the 536 * @param friend_number The friend number of the friend for which to set the
488 * video bit rate. 537 * audio bit rate.
489 * @param stable Is the stream stable enough to keep the bit rate. 538 * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec.
490 * Upon successful, non forceful, bit rate change, this is set to 539 * @param video_bit_rate Suggested maximum video bit rate in Kb/sec.
491 * true and 'bit_rate' is set to new bit rate.
492 * The stable is set to false with bit_rate set to the unstable
493 * bit rate when either current stream is unstable with said bit rate
494 * or the non forceful change failed.
495 * @param bit_rate The bit rate in Kb/sec.
496 */ 540 */
497typedef void toxav_video_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, bool stable, uint32_t bit_rate, void *user_data); 541typedef void toxav_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, void *user_data);
542
498/** 543/**
499 * Set the callback for the `video_bit_rate_status` event. Pass NULL to unset. 544 * Set the callback for the `bit_rate_status` event. Pass NULL to unset.
500 * 545 *
501 */ 546 */
502void toxav_callback_video_bit_rate_status(ToxAV *toxAV, toxav_video_bit_rate_status_cb *callback, void *user_data); 547void toxav_callback_bit_rate_status(ToxAV *toxAV, toxav_bit_rate_status_cb *callback, void *user_data);
503/** 548
504 * Set the video bit rate to be used in subsequent video frames. If the passed 549
505 * bit rate is the same as the current bit rate this function will return true
506 * without calling a callback. If there is an active non forceful setup with the
507 * passed video bit rate and the new set request is forceful, the bit rate is
508 * forcefully set and the previous non forceful request is cancelled. The active
509 * non forceful setup will be canceled in favour of new non forceful setup.
510 *
511 * @param friend_number The friend number of the friend for which to set the
512 * video bit rate.
513 * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable
514 * video sending.
515 * @param force True if the bit rate change is forceful.
516 *
517 */
518bool toxav_video_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, uint32_t video_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE *error);
519/******************************************************************************* 550/*******************************************************************************
520 * 551 *
521 * :: A/V sending 552 * :: A/V sending
@@ -554,6 +585,7 @@ typedef enum TOXAV_ERR_SEND_FRAME {
554 */ 585 */
555 TOXAV_ERR_SEND_FRAME_RTP_FAILED, 586 TOXAV_ERR_SEND_FRAME_RTP_FAILED,
556} TOXAV_ERR_SEND_FRAME; 587} TOXAV_ERR_SEND_FRAME;
588
557/** 589/**
558 * Send an audio frame to a friend. 590 * Send an audio frame to a friend.
559 * 591 *
@@ -574,7 +606,10 @@ typedef enum TOXAV_ERR_SEND_FRAME {
574 * @param sampling_rate Audio sampling rate used in this frame. Valid sampling 606 * @param sampling_rate Audio sampling rate used in this frame. Valid sampling
575 * rates are 8000, 12000, 16000, 24000, or 48000. 607 * rates are 8000, 12000, 16000, 24000, or 48000.
576 */ 608 */
577bool 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); 609bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm,
610 size_t sample_count, uint8_t channels, uint32_t sampling_rate,
611 TOXAV_ERR_SEND_FRAME *error);
612
578/** 613/**
579 * Send a video frame to a friend. 614 * Send a video frame to a friend.
580 * 615 *
@@ -590,7 +625,11 @@ bool toxav_audio_send_frame(ToxAV *toxAV, uint32_t friend_number, const int16_t
590 * @param u U (Chroma) plane data. 625 * @param u U (Chroma) plane data.
591 * @param v V (Chroma) plane data. 626 * @param v V (Chroma) plane data.
592 */ 627 */
593bool 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); 628bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width,
629 uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v,
630 TOXAV_ERR_SEND_FRAME *error);
631
632
594/******************************************************************************* 633/*******************************************************************************
595 * 634 *
596 * :: A/V receiving 635 * :: A/V receiving
@@ -600,7 +639,7 @@ bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width
600 * The function type for the audio_receive_frame callback. The callback can be 639 * The function type for the audio_receive_frame callback. The callback can be
601 * called multiple times per single iteration depending on the amount of queued 640 * called multiple times per single iteration depending on the amount of queued
602 * frames in the buffer. The received format is the same as in send function. 641 * frames in the buffer. The received format is the same as in send function.
603 * 642 *
604 * @param friend_number The friend number of the friend who sent an audio frame. 643 * @param friend_number The friend number of the friend who sent an audio frame.
605 * @param pcm An array of audio samples (sample_count * channels elements). 644 * @param pcm An array of audio samples (sample_count * channels elements).
606 * @param sample_count The number of audio samples per channel in the PCM array. 645 * @param sample_count The number of audio samples per channel in the PCM array.
@@ -608,12 +647,16 @@ bool toxav_video_send_frame(ToxAV *toxAV, uint32_t friend_number, uint16_t width
608 * @param sampling_rate Sampling rate used in this frame. 647 * @param sampling_rate Sampling rate used in this frame.
609 * 648 *
610 */ 649 */
611typedef 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); 650typedef void toxav_audio_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, const int16_t *pcm,
651 size_t sample_count, uint8_t channels, uint32_t sampling_rate,
652 void *user_data);
653
612/** 654/**
613 * Set the callback for the `audio_receive_frame` event. Pass NULL to unset. 655 * Set the callback for the `audio_receive_frame` event. Pass NULL to unset.
614 * 656 *
615 */ 657 */
616void toxav_callback_audio_receive_frame(ToxAV *toxAV, toxav_audio_receive_frame_cb *callback, void *user_data); 658void toxav_callback_audio_receive_frame(ToxAV *toxAV, toxav_audio_receive_frame_cb *callback, void *user_data);
659
617/** 660/**
618 * The function type for the video_receive_frame callback. 661 * The function type for the video_receive_frame callback.
619 * 662 *
@@ -635,60 +678,17 @@ void toxav_callback_audio_receive_frame(ToxAV *toxAV, toxav_audio_receive_frame_
635 * image is bottom-up hence why you MUST abs() it when 678 * image is bottom-up hence why you MUST abs() it when
636 * calculating plane buffer size. 679 * calculating plane buffer size.
637 */ 680 */
638typedef 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); 681typedef void toxav_video_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number, uint16_t width,
682 uint16_t height, const uint8_t *y, const uint8_t *u, const uint8_t *v,
683 int32_t ystride, int32_t ustride, int32_t vstride, void *user_data);
684
639/** 685/**
640 * Set the callback for the `video_receive_frame` event. Pass NULL to unset. 686 * Set the callback for the `video_receive_frame` event. Pass NULL to unset.
641 * 687 *
642 */ 688 */
643void toxav_callback_video_receive_frame(ToxAV *toxAV, toxav_video_receive_frame_cb *callback, void *user_data); 689void toxav_callback_video_receive_frame(ToxAV *toxAV, toxav_video_receive_frame_cb *callback, void *user_data);
644 690
645/**
646 * NOTE Compatibility with old toxav group calls TODO remove
647 */
648/* Create a new toxav group.
649 *
650 * return group number on success.
651 * return -1 on failure.
652 *
653 * Audio data callback format:
654 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
655 *
656 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
657 */
658int toxav_add_av_groupchat(Tox *tox, void (*audio_callback)(void*, int, int, const int16_t *, unsigned int, uint8_t,
659 unsigned int, void *), void *userdata);
660
661/* Join a AV group (you need to have been invited first.)
662 *
663 * returns group number on success
664 * returns -1 on failure.
665 *
666 * Audio data callback format (same as the one for toxav_add_av_groupchat()):
667 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
668 *
669 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
670 */
671int toxav_join_av_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *data, uint16_t length,
672 void (*audio_callback)(void*, int, int, const int16_t *, unsigned int, uint8_t, unsigned int, void *), void *userdata);
673
674/* Send audio to the group chat.
675 *
676 * return 0 on success.
677 * return -1 on failure.
678 *
679 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
680 *
681 * Valid number of samples are ((sample rate) * (audio length (Valid ones are: 2.5, 5, 10, 20, 40 or 60 ms)) / 1000)
682 * Valid number of channels are 1 or 2.
683 * Valid sample rates are 8000, 12000, 16000, 24000, or 48000.
684 *
685 * Recommended values are: samples = 960, channels = 1, sample_rate = 48000
686 */
687int toxav_group_send_audio(Tox *tox, int groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
688 unsigned int sample_rate);
689
690#ifdef __cplusplus 691#ifdef __cplusplus
691} 692}
692#endif 693#endif
693
694#endif /* TOXAV_H */ 694#endif /* TOXAV_H */