From e0675493479421d43b5ab62a7b5255ba9dfd4046 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Mon, 18 Aug 2014 17:01:59 +0200 Subject: [PATCH] Provide correct sample rate when G722 is involved --- coreapi/linphonecall.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 9d8b6060c..37a1079a3 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -236,6 +236,14 @@ static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, int bandw for(it=codecs;it!=NULL;it=it->next){ PayloadType *pt=(PayloadType*)it->data; if (pt->flags & PAYLOAD_TYPE_ENABLED){ + int sample_rate = payload_type_get_rate(pt); + + if( strcasecmp("G722",pt->mime_type) == 0 ){ + /* G722 spec says 8000 but the codec actually requires 16000 */ + ms_debug("Correcting sample rate for G722"); + sample_rate = 16000; + } + 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 of %i kbit/s", pt->mime_type,pt->clock_rate,bandwidth_limit); @@ -244,7 +252,7 @@ static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, int bandw if (linphone_core_check_payload_type_usability(lc,pt)){ l=ms_list_append(l,payload_type_clone(pt)); nb++; - if (max_sample_rate && payload_type_get_rate(pt)>*max_sample_rate) *max_sample_rate=payload_type_get_rate(pt); + if (max_sample_rate && sample_rate>*max_sample_rate) *max_sample_rate=sample_rate; } } if ((nb_codecs_limit > 0) && (nb >= nb_codecs_limit)) break;