diff options
-rw-r--r-- | auto_tests/toxav_basic_test.c | 6 | ||||
-rw-r--r-- | testing/av_test.c | 18 | ||||
-rw-r--r-- | toxav/toxav.api.h | 89 | ||||
-rw-r--r-- | toxav/toxav.c | 50 | ||||
-rw-r--r-- | toxav/toxav.h | 100 |
5 files changed, 157 insertions, 106 deletions
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index bc55d69c..d21df613 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -476,19 +476,19 @@ START_TEST(test_AV_flows) | |||
476 | 476 | ||
477 | printf("Call started as audio only\n"); | 477 | printf("Call started as audio only\n"); |
478 | printf("Turning on video for Alice...\n"); | 478 | printf("Turning on video for Alice...\n"); |
479 | ck_assert(toxav_bit_rate_set_video(AliceAV, 0, 1000, NULL)); | 479 | ck_assert(toxav_video_set_bit_rate(AliceAV, 0, 1000, NULL)); |
480 | 480 | ||
481 | iterate_tox(bootstrap, Alice, Bob); | 481 | iterate_tox(bootstrap, Alice, Bob); |
482 | ck_assert(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_V); | 482 | ck_assert(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_V); |
483 | 483 | ||
484 | printf("Turning off video for Alice...\n"); | 484 | printf("Turning off video for Alice...\n"); |
485 | ck_assert(toxav_bit_rate_set_video(AliceAV, 0, 0, NULL)); | 485 | ck_assert(toxav_video_set_bit_rate(AliceAV, 0, 0, NULL)); |
486 | 486 | ||
487 | iterate_tox(bootstrap, Alice, Bob); | 487 | iterate_tox(bootstrap, Alice, Bob); |
488 | ck_assert(!(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_V)); | 488 | ck_assert(!(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_V)); |
489 | 489 | ||
490 | printf("Turning off audio for Alice...\n"); | 490 | printf("Turning off audio for Alice...\n"); |
491 | ck_assert(toxav_bit_rate_set_audio(AliceAV, 0, 0, NULL)); | 491 | ck_assert(toxav_audio_set_bit_rate(AliceAV, 0, 0, NULL)); |
492 | 492 | ||
493 | iterate_tox(bootstrap, Alice, Bob); | 493 | iterate_tox(bootstrap, Alice, Bob); |
494 | ck_assert(!(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_A)); | 494 | ck_assert(!(BobCC.state & TOXAV_FRIEND_CALL_STATE_SENDING_A)); |
diff --git a/testing/av_test.c b/testing/av_test.c index 71836a52..ce982e32 100644 --- a/testing/av_test.c +++ b/testing/av_test.c | |||
@@ -210,11 +210,15 @@ static void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number, | |||
210 | free(rb_write(cc->arb, f)); | 210 | free(rb_write(cc->arb, f)); |
211 | pthread_mutex_unlock(cc->arb_mutex); | 211 | pthread_mutex_unlock(cc->arb_mutex); |
212 | } | 212 | } |
213 | static void t_toxav_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, | 213 | static void t_toxav_audio_bit_rate_cb(ToxAV *av, uint32_t friend_number, |
214 | uint32_t audio_bit_rate, uint32_t video_bit_rate, | 214 | uint32_t audio_bit_rate, void *user_data) |
215 | void *user_data) | ||
216 | { | 215 | { |
217 | printf("Suggested bit rates: audio: %d video: %d\n", audio_bit_rate, video_bit_rate); | 216 | printf("Suggested bit rate: audio: %d\n", audio_bit_rate); |
217 | } | ||
218 | static void t_toxav_video_bit_rate_cb(ToxAV *av, uint32_t friend_number, | ||
219 | uint32_t video_bit_rate, void *user_data) | ||
220 | { | ||
221 | printf("Suggested bit rate: video: %d\n", video_bit_rate); | ||
218 | } | 222 | } |
219 | static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, | 223 | static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, |
220 | void *userdata) | 224 | void *userdata) |
@@ -302,14 +306,16 @@ static void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceC | |||
302 | /* Alice */ | 306 | /* Alice */ |
303 | toxav_callback_call(*AliceAV, t_toxav_call_cb, AliceCC); | 307 | toxav_callback_call(*AliceAV, t_toxav_call_cb, AliceCC); |
304 | toxav_callback_call_state(*AliceAV, t_toxav_call_state_cb, AliceCC); | 308 | toxav_callback_call_state(*AliceAV, t_toxav_call_state_cb, AliceCC); |
305 | toxav_callback_bit_rate_status(*AliceAV, t_toxav_bit_rate_status_cb, AliceCC); | 309 | toxav_callback_audio_bit_rate(*AliceAV, t_toxav_audio_bit_rate_cb, AliceCC); |
310 | toxav_callback_video_bit_rate(*AliceAV, t_toxav_video_bit_rate_cb, AliceCC); | ||
306 | toxav_callback_video_receive_frame(*AliceAV, t_toxav_receive_video_frame_cb, AliceCC); | 311 | toxav_callback_video_receive_frame(*AliceAV, t_toxav_receive_video_frame_cb, AliceCC); |
307 | toxav_callback_audio_receive_frame(*AliceAV, t_toxav_receive_audio_frame_cb, AliceCC); | 312 | toxav_callback_audio_receive_frame(*AliceAV, t_toxav_receive_audio_frame_cb, AliceCC); |
308 | 313 | ||
309 | /* Bob */ | 314 | /* Bob */ |
310 | toxav_callback_call(*BobAV, t_toxav_call_cb, BobCC); | 315 | toxav_callback_call(*BobAV, t_toxav_call_cb, BobCC); |
311 | toxav_callback_call_state(*BobAV, t_toxav_call_state_cb, BobCC); | 316 | toxav_callback_call_state(*BobAV, t_toxav_call_state_cb, BobCC); |
312 | toxav_callback_bit_rate_status(*BobAV, t_toxav_bit_rate_status_cb, BobCC); | 317 | toxav_callback_audio_bit_rate(*BobAV, t_toxav_audio_bit_rate_cb, BobCC); |
318 | toxav_callback_video_bit_rate(*BobAV, t_toxav_video_bit_rate_cb, BobCC); | ||
313 | toxav_callback_video_receive_frame(*BobAV, t_toxav_receive_video_frame_cb, BobCC); | 319 | toxav_callback_video_receive_frame(*BobAV, t_toxav_receive_video_frame_cb, BobCC); |
314 | toxav_callback_audio_receive_frame(*BobAV, t_toxav_receive_audio_frame_cb, BobCC); | 320 | toxav_callback_audio_receive_frame(*BobAV, t_toxav_receive_audio_frame_cb, BobCC); |
315 | 321 | ||
diff --git a/toxav/toxav.api.h b/toxav/toxav.api.h index 511b9e2d..71cd5aec 100644 --- a/toxav/toxav.api.h +++ b/toxav/toxav.api.h | |||
@@ -405,43 +405,6 @@ error for bit_rate_set { | |||
405 | FRIEND_NOT_IN_CALL, | 405 | FRIEND_NOT_IN_CALL, |
406 | } | 406 | } |
407 | 407 | ||
408 | namespace bit_rate { | ||
409 | /** | ||
410 | * Set the bit rate to be used in subsequent audio frames. | ||
411 | * | ||
412 | * @param friend_number The friend number of the friend for which to set the | ||
413 | * bit rate. | ||
414 | * @param audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable. | ||
415 | * | ||
416 | */ | ||
417 | |||
418 | bool set_audio(uint32_t friend_number, uint32_t audio_bit_rate) with error for bit_rate_set; | ||
419 | /** | ||
420 | * Set the bit rate to be used in subsequent video frames. | ||
421 | * | ||
422 | * @param friend_number The friend number of the friend for which to set the | ||
423 | * bit rate. | ||
424 | * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable. | ||
425 | * | ||
426 | */ | ||
427 | bool set_video(uint32_t friend_number, uint32_t video_bit_rate) with error for bit_rate_set; | ||
428 | |||
429 | event status { | ||
430 | /** | ||
431 | * The function type for the ${event status} callback. The event is triggered | ||
432 | * when the network becomes too saturated for current bit rates at which | ||
433 | * point core suggests new bit rates. | ||
434 | * | ||
435 | * @param friend_number The friend number of the friend for which to set the | ||
436 | * bit rate. | ||
437 | * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec. | ||
438 | * @param video_bit_rate Suggested maximum video bit rate in Kb/sec. | ||
439 | */ | ||
440 | typedef void(uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate); | ||
441 | } | ||
442 | } | ||
443 | |||
444 | |||
445 | /******************************************************************************* | 408 | /******************************************************************************* |
446 | * | 409 | * |
447 | * :: A/V sending | 410 | * :: A/V sending |
@@ -506,6 +469,32 @@ namespace audio { | |||
506 | */ | 469 | */ |
507 | bool send_frame(uint32_t friend_number, const int16_t *pcm, size_t sample_count, | 470 | bool send_frame(uint32_t friend_number, const int16_t *pcm, size_t sample_count, |
508 | uint8_t channels, uint32_t sampling_rate) with error for send_frame; | 471 | uint8_t channels, uint32_t sampling_rate) with error for send_frame; |
472 | |||
473 | uint32_t bit_rate { | ||
474 | /** | ||
475 | * Set the bit rate to be used in subsequent video frames. | ||
476 | * | ||
477 | * @param friend_number The friend number of the friend for which to set the | ||
478 | * bit rate. | ||
479 | * @param bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable. | ||
480 | * | ||
481 | * @return true on success. | ||
482 | */ | ||
483 | set(uint32_t friend_number) with error for bit_rate_set; | ||
484 | } | ||
485 | |||
486 | event bit_rate { | ||
487 | /** | ||
488 | * The function type for the ${event bit_rate} callback. The event is triggered | ||
489 | * when the network becomes too saturated for current bit rates at which | ||
490 | * point core suggests new bit rates. | ||
491 | * | ||
492 | * @param friend_number The friend number of the friend for which to set the | ||
493 | * bit rate. | ||
494 | * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec. | ||
495 | */ | ||
496 | typedef void(uint32_t friend_number, uint32_t audio_bit_rate); | ||
497 | } | ||
509 | } | 498 | } |
510 | 499 | ||
511 | namespace video { | 500 | namespace video { |
@@ -526,6 +515,32 @@ namespace video { | |||
526 | */ | 515 | */ |
527 | bool send_frame(uint32_t friend_number, uint16_t width, uint16_t height, | 516 | bool send_frame(uint32_t friend_number, uint16_t width, uint16_t height, |
528 | const uint8_t *y, const uint8_t *u, const uint8_t *v) with error for send_frame; | 517 | const uint8_t *y, const uint8_t *u, const uint8_t *v) with error for send_frame; |
518 | |||
519 | uint32_t bit_rate { | ||
520 | /** | ||
521 | * Set the bit rate to be used in subsequent video frames. | ||
522 | * | ||
523 | * @param friend_number The friend number of the friend for which to set the | ||
524 | * bit rate. | ||
525 | * @param bit_rate The new video bit rate in Kb/sec. Set to 0 to disable. | ||
526 | * | ||
527 | * @return true on success. | ||
528 | */ | ||
529 | set(uint32_t friend_number) with error for bit_rate_set; | ||
530 | } | ||
531 | |||
532 | event bit_rate { | ||
533 | /** | ||
534 | * The function type for the ${event bit_rate} callback. The event is triggered | ||
535 | * when the network becomes too saturated for current bit rates at which | ||
536 | * point core suggests new bit rates. | ||
537 | * | ||
538 | * @param friend_number The friend number of the friend for which to set the | ||
539 | * bit rate. | ||
540 | * @param video_bit_rate Suggested maximum video bit rate in Kb/sec. | ||
541 | */ | ||
542 | typedef void(uint32_t friend_number, uint32_t video_bit_rate); | ||
543 | } | ||
529 | } | 544 | } |
530 | 545 | ||
531 | 546 | ||
diff --git a/toxav/toxav.c b/toxav/toxav.c index 27575063..c021747a 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -79,7 +79,8 @@ struct ToxAV { | |||
79 | PAIR(toxav_call_state_cb *, void *) scb; /* Call state callback */ | 79 | PAIR(toxav_call_state_cb *, void *) scb; /* Call state callback */ |
80 | PAIR(toxav_audio_receive_frame_cb *, void *) acb; /* Audio frame receive callback */ | 80 | PAIR(toxav_audio_receive_frame_cb *, void *) acb; /* Audio frame receive callback */ |
81 | PAIR(toxav_video_receive_frame_cb *, void *) vcb; /* Video frame receive callback */ | 81 | PAIR(toxav_video_receive_frame_cb *, void *) vcb; /* Video frame receive callback */ |
82 | PAIR(toxav_bit_rate_status_cb *, void *) bcb; /* Bit rate control callback */ | 82 | PAIR(toxav_audio_bit_rate_cb *, void *) abcb; /* Bit rate control callback */ |
83 | PAIR(toxav_video_bit_rate_cb *, void *) vbcb; /* Bit rate control callback */ | ||
83 | 84 | ||
84 | /** Decode time measures */ | 85 | /** Decode time measures */ |
85 | int32_t dmssc; /** Measure count */ | 86 | int32_t dmssc; /** Measure count */ |
@@ -525,7 +526,7 @@ END: | |||
525 | 526 | ||
526 | return rc == TOXAV_ERR_CALL_CONTROL_OK; | 527 | return rc == TOXAV_ERR_CALL_CONTROL_OK; |
527 | } | 528 | } |
528 | bool toxav_bit_rate_set_audio(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, | 529 | bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, |
529 | TOXAV_ERR_BIT_RATE_SET *error) | 530 | TOXAV_ERR_BIT_RATE_SET *error) |
530 | { | 531 | { |
531 | TOXAV_ERR_BIT_RATE_SET rc = TOXAV_ERR_BIT_RATE_SET_OK; | 532 | TOXAV_ERR_BIT_RATE_SET rc = TOXAV_ERR_BIT_RATE_SET_OK; |
@@ -597,7 +598,7 @@ END: | |||
597 | 598 | ||
598 | return rc == TOXAV_ERR_BIT_RATE_SET_OK; | 599 | return rc == TOXAV_ERR_BIT_RATE_SET_OK; |
599 | } | 600 | } |
600 | bool toxav_bit_rate_set_video(ToxAV *av, uint32_t friend_number, uint32_t video_bit_rate, | 601 | bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t video_bit_rate, |
601 | TOXAV_ERR_BIT_RATE_SET *error) | 602 | TOXAV_ERR_BIT_RATE_SET *error) |
602 | { | 603 | { |
603 | TOXAV_ERR_BIT_RATE_SET rc = TOXAV_ERR_BIT_RATE_SET_OK; | 604 | TOXAV_ERR_BIT_RATE_SET rc = TOXAV_ERR_BIT_RATE_SET_OK; |
@@ -669,11 +670,18 @@ END: | |||
669 | 670 | ||
670 | return rc == TOXAV_ERR_BIT_RATE_SET_OK; | 671 | return rc == TOXAV_ERR_BIT_RATE_SET_OK; |
671 | } | 672 | } |
672 | void toxav_callback_bit_rate_status(ToxAV *av, toxav_bit_rate_status_cb *callback, void *user_data) | 673 | void toxav_callback_audio_bit_rate(ToxAV *av, toxav_audio_bit_rate_cb *callback, void *user_data) |
673 | { | 674 | { |
674 | pthread_mutex_lock(av->mutex); | 675 | pthread_mutex_lock(av->mutex); |
675 | av->bcb.first = callback; | 676 | av->abcb.first = callback; |
676 | av->bcb.second = user_data; | 677 | av->abcb.second = user_data; |
678 | pthread_mutex_unlock(av->mutex); | ||
679 | } | ||
680 | void toxav_callback_video_bit_rate(ToxAV *av, toxav_video_bit_rate_cb *callback, void *user_data) | ||
681 | { | ||
682 | pthread_mutex_lock(av->mutex); | ||
683 | av->vbcb.first = callback; | ||
684 | av->vbcb.second = user_data; | ||
677 | pthread_mutex_unlock(av->mutex); | 685 | pthread_mutex_unlock(av->mutex); |
678 | } | 686 | } |
679 | bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pcm, size_t sample_count, | 687 | bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pcm, size_t sample_count, |
@@ -911,20 +919,26 @@ void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *u | |||
911 | 919 | ||
912 | pthread_mutex_lock(call->av->mutex); | 920 | pthread_mutex_lock(call->av->mutex); |
913 | 921 | ||
914 | if (!call->av->bcb.first) { | ||
915 | pthread_mutex_unlock(call->av->mutex); | ||
916 | LOGGER_WARNING(call->av->m->log, "No callback to report loss on"); | ||
917 | return; | ||
918 | } | ||
919 | |||
920 | if (call->video_bit_rate) { | 922 | if (call->video_bit_rate) { |
921 | (*call->av->bcb.first)(call->av, friend_number, call->audio_bit_rate, | 923 | if (!call->av->vbcb.first) { |
922 | call->video_bit_rate - (call->video_bit_rate * loss), | 924 | pthread_mutex_unlock(call->av->mutex); |
923 | call->av->bcb.second); | 925 | LOGGER_WARNING(call->av->m->log, "No callback to report loss on"); |
926 | return; | ||
927 | } | ||
928 | |||
929 | (*call->av->vbcb.first)(call->av, friend_number, | ||
930 | call->video_bit_rate - (call->video_bit_rate * loss), | ||
931 | call->av->vbcb.second); | ||
924 | } else if (call->audio_bit_rate) { | 932 | } else if (call->audio_bit_rate) { |
925 | (*call->av->bcb.first)(call->av, friend_number, | 933 | if (!call->av->abcb.first) { |
926 | call->audio_bit_rate - (call->audio_bit_rate * loss), | 934 | pthread_mutex_unlock(call->av->mutex); |
927 | 0, call->av->bcb.second); | 935 | LOGGER_WARNING(call->av->m->log, "No callback to report loss on"); |
936 | return; | ||
937 | } | ||
938 | |||
939 | (*call->av->abcb.first)(call->av, friend_number, | ||
940 | call->audio_bit_rate - (call->audio_bit_rate * loss), | ||
941 | call->av->abcb.second); | ||
928 | } | 942 | } |
929 | 943 | ||
930 | pthread_mutex_unlock(call->av->mutex); | 944 | pthread_mutex_unlock(call->av->mutex); |
diff --git a/toxav/toxav.h b/toxav/toxav.h index f8a683a6..1f2d6860 100644 --- a/toxav/toxav.h +++ b/toxav/toxav.h | |||
@@ -511,48 +511,6 @@ typedef enum TOXAV_ERR_BIT_RATE_SET { | |||
511 | } TOXAV_ERR_BIT_RATE_SET; | 511 | } TOXAV_ERR_BIT_RATE_SET; |
512 | 512 | ||
513 | 513 | ||
514 | /** | ||
515 | * Set the bit rate to be used in subsequent audio frames. | ||
516 | * | ||
517 | * @param friend_number The friend number of the friend for which to set the | ||
518 | * bit rate. | ||
519 | * @param audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable. | ||
520 | * | ||
521 | */ | ||
522 | bool toxav_bit_rate_set_audio(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, | ||
523 | TOXAV_ERR_BIT_RATE_SET *error); | ||
524 | |||
525 | /** | ||
526 | * Set the bit rate to be used in subsequent video frames. | ||
527 | * | ||
528 | * @param friend_number The friend number of the friend for which to set the | ||
529 | * bit rate. | ||
530 | * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable. | ||
531 | * | ||
532 | */ | ||
533 | bool toxav_bit_rate_set_video(ToxAV *av, uint32_t friend_number, uint32_t video_bit_rate, | ||
534 | TOXAV_ERR_BIT_RATE_SET *error); | ||
535 | |||
536 | /** | ||
537 | * The function type for the bit_rate_status callback. The event is triggered | ||
538 | * when the network becomes too saturated for current bit rates at which | ||
539 | * point core suggests new bit rates. | ||
540 | * | ||
541 | * @param friend_number The friend number of the friend for which to set the | ||
542 | * bit rate. | ||
543 | * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec. | ||
544 | * @param video_bit_rate Suggested maximum video bit rate in Kb/sec. | ||
545 | */ | ||
546 | typedef void toxav_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, | ||
547 | uint32_t video_bit_rate, void *user_data); | ||
548 | |||
549 | |||
550 | /** | ||
551 | * Set the callback for the `bit_rate_status` event. Pass NULL to unset. | ||
552 | * | ||
553 | */ | ||
554 | void toxav_callback_bit_rate_status(ToxAV *av, toxav_bit_rate_status_cb *callback, void *user_data); | ||
555 | |||
556 | 514 | ||
557 | /******************************************************************************* | 515 | /******************************************************************************* |
558 | * | 516 | * |
@@ -634,6 +592,35 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc | |||
634 | uint8_t channels, uint32_t sampling_rate, TOXAV_ERR_SEND_FRAME *error); | 592 | uint8_t channels, uint32_t sampling_rate, TOXAV_ERR_SEND_FRAME *error); |
635 | 593 | ||
636 | /** | 594 | /** |
595 | * Set the bit rate to be used in subsequent video frames. | ||
596 | * | ||
597 | * @param friend_number The friend number of the friend for which to set the | ||
598 | * bit rate. | ||
599 | * @param bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable. | ||
600 | * | ||
601 | * @return true on success. | ||
602 | */ | ||
603 | bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_rate, TOXAV_ERR_BIT_RATE_SET *error); | ||
604 | |||
605 | /** | ||
606 | * The function type for the audio_bit_rate callback. The event is triggered | ||
607 | * when the network becomes too saturated for current bit rates at which | ||
608 | * point core suggests new bit rates. | ||
609 | * | ||
610 | * @param friend_number The friend number of the friend for which to set the | ||
611 | * bit rate. | ||
612 | * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec. | ||
613 | */ | ||
614 | typedef void toxav_audio_bit_rate_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, void *user_data); | ||
615 | |||
616 | |||
617 | /** | ||
618 | * Set the callback for the `audio_bit_rate` event. Pass NULL to unset. | ||
619 | * | ||
620 | */ | ||
621 | void toxav_callback_audio_bit_rate(ToxAV *av, toxav_audio_bit_rate_cb *callback, void *user_data); | ||
622 | |||
623 | /** | ||
637 | * Send a video frame to a friend. | 624 | * Send a video frame to a friend. |
638 | * | 625 | * |
639 | * Y - plane should be of size: height * width | 626 | * Y - plane should be of size: height * width |
@@ -651,6 +638,35 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc | |||
651 | bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, | 638 | bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y, |
652 | const uint8_t *u, const uint8_t *v, TOXAV_ERR_SEND_FRAME *error); | 639 | const uint8_t *u, const uint8_t *v, TOXAV_ERR_SEND_FRAME *error); |
653 | 640 | ||
641 | /** | ||
642 | * Set the bit rate to be used in subsequent video frames. | ||
643 | * | ||
644 | * @param friend_number The friend number of the friend for which to set the | ||
645 | * bit rate. | ||
646 | * @param bit_rate The new video bit rate in Kb/sec. Set to 0 to disable. | ||
647 | * | ||
648 | * @return true on success. | ||
649 | */ | ||
650 | bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_rate, TOXAV_ERR_BIT_RATE_SET *error); | ||
651 | |||
652 | /** | ||
653 | * The function type for the video_bit_rate callback. The event is triggered | ||
654 | * when the network becomes too saturated for current bit rates at which | ||
655 | * point core suggests new bit rates. | ||
656 | * | ||
657 | * @param friend_number The friend number of the friend for which to set the | ||
658 | * bit rate. | ||
659 | * @param video_bit_rate Suggested maximum video bit rate in Kb/sec. | ||
660 | */ | ||
661 | typedef void toxav_video_bit_rate_cb(ToxAV *av, uint32_t friend_number, uint32_t video_bit_rate, void *user_data); | ||
662 | |||
663 | |||
664 | /** | ||
665 | * Set the callback for the `video_bit_rate` event. Pass NULL to unset. | ||
666 | * | ||
667 | */ | ||
668 | void toxav_callback_video_bit_rate(ToxAV *av, toxav_video_bit_rate_cb *callback, void *user_data); | ||
669 | |||
654 | 670 | ||
655 | /******************************************************************************* | 671 | /******************************************************************************* |
656 | * | 672 | * |