diff options
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r-- | toxav/toxav.c | 50 |
1 files changed, 32 insertions, 18 deletions
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); |