implement linphone_call_params_set_audio_bandwidth_limit()

This commit is contained in:
Simon Morlat 2010-11-26 18:20:52 +01:00
parent 8e6a63ee84
commit 7d90f44fae
4 changed files with 25 additions and 8 deletions

View file

@ -40,13 +40,19 @@ static MSWebCam *get_nowebcam_device(){
#endif
static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs){
static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, int bandwidth_limit){
MSList *l=NULL;
const MSList *it;
for(it=codecs;it!=NULL;it=it->next){
PayloadType *pt=(PayloadType*)it->data;
if ((pt->flags & PAYLOAD_TYPE_ENABLED) && linphone_core_check_payload_type_usability(lc,pt)){
l=ms_list_append(l,payload_type_clone(pt));
if (pt->flags & PAYLOAD_TYPE_ENABLED){
if (bandwidth_limit>0 && !linphone_core_is_payload_type_usable_for_bandwidth(lc,pt,bandwidth_limit)){
ms_message("Codec %s/%i eliminated because of audio bandwidth constraint.",pt->mime_type,pt->clock_rate);
continue;
}
if (linphone_core_check_payload_type_usability(lc,pt)){
l=ms_list_append(l,payload_type_clone(pt));
}
}
}
return l;
@ -70,7 +76,7 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCa
md->streams[0].proto=SalProtoRtpAvp;
md->streams[0].type=SalAudio;
md->streams[0].ptime=lc->net_conf.down_ptime;
l=make_codec_list(lc,lc->codecs_conf.audio_codecs);
l=make_codec_list(lc,lc->codecs_conf.audio_codecs,call->params.audio_bw);
pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event"));
l=ms_list_append(l,pt);
md->streams[0].payloads=l;
@ -83,7 +89,7 @@ SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCa
md->streams[1].port=call->video_port;
md->streams[1].proto=SalProtoRtpAvp;
md->streams[1].type=SalVideo;
l=make_codec_list(lc,lc->codecs_conf.video_codecs);
l=make_codec_list(lc,lc->codecs_conf.video_codecs,0);
md->streams[1].payloads=l;
if (lc->dw_video_bw)
md->streams[1].bandwidth=lc->dw_video_bw;
@ -533,6 +539,14 @@ bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams
return cp->real_early_media;
}
/**
* Refine bandwidth settings for this call by setting a bandwidth limit for audio streams.
* As a consequence, codecs whose bitrates are not compatible with this limit won't be used.
**/
void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bandwidth){
cp->audio_bw=bandwidth;
}
/**
*
**/

View file

@ -180,6 +180,7 @@ void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled);
bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp);
void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled);
bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp);
void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bw);
void linphone_call_params_destroy(LinphoneCallParams *cp);
/**

View file

@ -258,7 +258,7 @@ void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){
}
}
bool_t linphone_core_is_payload_type_usable(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit)
bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit)
{
double codec_band;
bool_t ret=FALSE;
@ -288,8 +288,6 @@ bool_t linphone_core_is_payload_type_usable(LinphoneCore *lc, PayloadType *pt,
else ret=FALSE;
break;
}
/*if (!ret) ms_warning("Payload %s is not usable with your internet connection.",pt->mime_type);*/
return ret;
}

View file

@ -58,6 +58,7 @@
struct _LinphoneCallParams{
LinphoneCall *referer; /*in case this call creation is consecutive to an incoming transfer, this points to the original call */
int audio_bw; /* bandwidth limit for audio stream */
bool_t has_video;
bool_t real_early_media; /*send real media even during early media (for outgoing calls)*/
bool_t pad[2];
@ -441,6 +442,9 @@ void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const
SalMediaDescription *create_local_media_description(LinphoneCore *lc, LinphoneCall *call);
void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md);
bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit);
#define linphone_core_ready(lc) ((lc)->state!=LinphoneGlobalStartup)
void _linphone_core_configure_resolver();