From 651ef3adb6299e66745cc1d1b57feb29fd17090a Mon Sep 17 00:00:00 2001 From: xhe Date: Sun, 28 Jan 2018 19:14:04 +0800 Subject: Make audio/video bit rates "properties" follow TokTok#731. This commit completely removed all things in namespace bit_rate, and deprecated functions are to be added back in another commit. set_xxx() is treadted as a property of namespace audio&video, same as bit_rate change event. toxav_basic_test is fixed, either. --- toxav/toxav.h | 100 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 42 deletions(-) (limited to 'toxav/toxav.h') 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 { } TOXAV_ERR_BIT_RATE_SET; -/** - * Set the bit rate to be used in subsequent audio frames. - * - * @param friend_number The friend number of the friend for which to set the - * bit rate. - * @param audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable. - * - */ -bool toxav_bit_rate_set_audio(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, - TOXAV_ERR_BIT_RATE_SET *error); - -/** - * Set the bit rate to be used in subsequent video frames. - * - * @param friend_number The friend number of the friend for which to set the - * bit rate. - * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable. - * - */ -bool toxav_bit_rate_set_video(ToxAV *av, uint32_t friend_number, uint32_t video_bit_rate, - TOXAV_ERR_BIT_RATE_SET *error); - -/** - * The function type for the bit_rate_status callback. The event is triggered - * when the network becomes too saturated for current bit rates at which - * point core suggests new bit rates. - * - * @param friend_number The friend number of the friend for which to set the - * bit rate. - * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec. - * @param video_bit_rate Suggested maximum video bit rate in Kb/sec. - */ -typedef void toxav_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, - uint32_t video_bit_rate, void *user_data); - - -/** - * Set the callback for the `bit_rate_status` event. Pass NULL to unset. - * - */ -void toxav_callback_bit_rate_status(ToxAV *av, toxav_bit_rate_status_cb *callback, void *user_data); - /******************************************************************************* * @@ -633,6 +591,35 @@ typedef enum TOXAV_ERR_SEND_FRAME { bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, TOXAV_ERR_SEND_FRAME *error); +/** + * Set the bit rate to be used in subsequent video frames. + * + * @param friend_number The friend number of the friend for which to set the + * bit rate. + * @param bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable. + * + * @return true on success. + */ +bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_rate, TOXAV_ERR_BIT_RATE_SET *error); + +/** + * The function type for the audio_bit_rate callback. The event is triggered + * when the network becomes too saturated for current bit rates at which + * point core suggests new bit rates. + * + * @param friend_number The friend number of the friend for which to set the + * bit rate. + * @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec. + */ +typedef void toxav_audio_bit_rate_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, void *user_data); + + +/** + * Set the callback for the `audio_bit_rate` event. Pass NULL to unset. + * + */ +void toxav_callback_audio_bit_rate(ToxAV *av, toxav_audio_bit_rate_cb *callback, void *user_data); + /** * Send a video frame to a friend. * @@ -651,6 +638,35 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc bool toxav_video_send_frame(ToxAV *av, 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); +/** + * Set the bit rate to be used in subsequent video frames. + * + * @param friend_number The friend number of the friend for which to set the + * bit rate. + * @param bit_rate The new video bit rate in Kb/sec. Set to 0 to disable. + * + * @return true on success. + */ +bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_rate, TOXAV_ERR_BIT_RATE_SET *error); + +/** + * The function type for the video_bit_rate callback. The event is triggered + * when the network becomes too saturated for current bit rates at which + * point core suggests new bit rates. + * + * @param friend_number The friend number of the friend for which to set the + * bit rate. + * @param video_bit_rate Suggested maximum video bit rate in Kb/sec. + */ +typedef void toxav_video_bit_rate_cb(ToxAV *av, uint32_t friend_number, uint32_t video_bit_rate, void *user_data); + + +/** + * Set the callback for the `video_bit_rate` event. Pass NULL to unset. + * + */ +void toxav_callback_video_bit_rate(ToxAV *av, toxav_video_bit_rate_cb *callback, void *user_data); + /******************************************************************************* * -- cgit v1.2.3