From 0becafd272997ab1fcbe93ce3d56b27aae6cd80a Mon Sep 17 00:00:00 2001 From: xhe Date: Sun, 14 Jan 2018 21:46:06 +0800 Subject: Split bit_rate_set(), one for audio, one for video. Fixes #572. As discussed in the issue, there's a risk that toxcore may not hold the maximum bitrates libvpx supports, if toxcore insists on using integer type. I initially proposed to have another flag in set(), so that we can use unsigned type instead. iphydf came up with a better solution, that is splitting the original functions, one for audio, one for video. Now, we could safely replace int32_t with uint32_t. Also: clean video_bit_rate_invalid() Though this is not a part of issue #572, as it's used in the toxav_bit_rate_set(), i cleaned the code. As mannol said, there should be a check. Uint32_t is large enough to hold the maximum bitrates libvpx supports, but user may pass a value larger than uint while smaller than uint32_t. Thanks to the reminding from nurupo, it's no longer a stub function. Bitrate error enums are shared for both audio and video https://github.com/TokTok/c-toxcore/pull/578#issuecomment-360095609, just as iphydf said. --- toxav/toxav.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'toxav/toxav.h') diff --git a/toxav/toxav.h b/toxav/toxav.h index 2e48d599..f8a683a6 100644 --- a/toxav/toxav.h +++ b/toxav/toxav.h @@ -494,14 +494,9 @@ typedef enum TOXAV_ERR_BIT_RATE_SET { TOXAV_ERR_BIT_RATE_SET_SYNC, /** - * The audio bit rate passed was not one of the supported values. + * The bit rate passed was not one of the supported values. */ - TOXAV_ERR_BIT_RATE_SET_INVALID_AUDIO_BIT_RATE, - - /** - * The video bit rate passed was not one of the supported values. - */ - TOXAV_ERR_BIT_RATE_SET_INVALID_VIDEO_BIT_RATE, + TOXAV_ERR_BIT_RATE_SET_INVALID_BIT_RATE, /** * The friend_number passed did not designate a valid friend. @@ -517,18 +512,26 @@ typedef enum TOXAV_ERR_BIT_RATE_SET { /** - * Set the bit rate to be used in subsequent audio/video frames. + * 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 audio_bit_rate The new audio bit rate in Kb/sec. Set to 0 to disable - * audio sending. Set to -1 to leave unchanged. - * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable - * video sending. Set to -1 to leave unchanged. + * @param video_bit_rate The new video bit rate in Kb/sec. Set to 0 to disable. * */ -bool toxav_bit_rate_set(ToxAV *av, uint32_t friend_number, int32_t audio_bit_rate, int32_t video_bit_rate, - TOXAV_ERR_BIT_RATE_SET *error); +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 -- cgit v1.2.3