From 53be75eda65769dcd3b086ed953fdef70f0a5ea2 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 13 Dec 2010 14:36:11 +0100 Subject: [PATCH] bugfixes again for bandwidth management --- coreapi/linphonecall.c | 4 ++-- coreapi/misc.c | 2 +- coreapi/private.h | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index bd62d6c83..7c06ecd3a 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -738,13 +738,13 @@ static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *m /*case where b=AS is given globally, not per stream*/ remote_bw=md->bandwidth; if (desc->type==SalVideo){ - remote_bw-=call->audio_bw+10; + remote_bw=get_video_bandwidth(remote_bw,call->audio_bw); } } if (desc->type==SalAudio){ bw=get_min_bandwidth(call->audio_bw,remote_bw); - }else bw=get_min_bandwidth(linphone_core_get_upload_bandwidth (lc)-call->audio_bw,remote_bw); + }else bw=get_min_bandwidth(get_video_bandwidth(linphone_core_get_upload_bandwidth (lc),call->audio_bw),remote_bw); if (bw>0) pt->normal_bitrate=bw*1000; else if (desc->type==SalAudio){ pt->normal_bitrate=-1; diff --git a/coreapi/misc.c b/coreapi/misc.c index 4ee5347f4..059c6228c 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -298,7 +298,7 @@ bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType allowed_bw=-1; video_bw=1500; /*around 1.5 Mbit/s*/ }else - video_bw=allowed_bw-lc->audio_bw-10; + video_bw=get_video_bandwidth(allowed_bw,lc->audio_bw); switch (pt->type){ case PAYLOAD_AUDIO_CONTINUOUS: diff --git a/coreapi/private.h b/coreapi/private.h index ca9b46fda..5759bbc19 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -148,6 +148,11 @@ static inline bool_t bandwidth_is_greater(int bw1, int bw2){ else return bw1>=bw2; } +static inline int get_video_bandwidth(int total, int audio){ + if (total<=0) return 0; + return total-audio-10; +} + static inline void set_string(char **dest, const char *src){ if (*dest){ ms_free(*dest);