mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-25 23:28:09 +00:00
repair linphone_core_check_payload_type_usability() and add non regression test.
This commit is contained in:
parent
fa1c36dddb
commit
3c94dd0b9e
3 changed files with 37 additions and 9 deletions
|
|
@ -224,7 +224,7 @@ void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){
|
|||
}
|
||||
}
|
||||
|
||||
bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, const PayloadType *pt, int bandwidth_limit)
|
||||
bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, const PayloadType *pt, int bandwidth_limit)
|
||||
{
|
||||
double codec_band;
|
||||
bool_t ret=FALSE;
|
||||
|
|
@ -233,8 +233,8 @@ bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, cons
|
|||
case PAYLOAD_AUDIO_CONTINUOUS:
|
||||
case PAYLOAD_AUDIO_PACKETIZED:
|
||||
codec_band=get_audio_payload_bandwidth(lc,pt,bandwidth_limit);
|
||||
ret=bandwidth_is_greater(bandwidth_limit*1000,codec_band);
|
||||
//ms_message("Payload %s: %g",pt->mime_type,codec_band);
|
||||
ret=bandwidth_is_greater(bandwidth_limit,codec_band);
|
||||
/*ms_message("Payload %s: codec_bandwidth=%g, bandwidth_limit=%i",pt->mime_type,codec_band,bandwidth_limit);*/
|
||||
break;
|
||||
case PAYLOAD_VIDEO:
|
||||
if (bandwidth_limit!=0) {/* infinite (-1) or strictly positive*/
|
||||
|
|
@ -248,7 +248,9 @@ bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, cons
|
|||
|
||||
/* return TRUE if codec can be used with bandwidth, FALSE else*/
|
||||
bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, const PayloadType *pt){
|
||||
bool_t ret=linphone_core_is_payload_type_usable_for_bandwidth(lc, pt, linphone_core_get_payload_type_bitrate(lc,pt));
|
||||
int maxbw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc),
|
||||
linphone_core_get_upload_bandwidth(lc));
|
||||
bool_t ret=linphone_core_is_payload_type_usable_for_bandwidth(lc, pt, maxbw);
|
||||
if ((pt->type==PAYLOAD_AUDIO_CONTINUOUS || pt->type==PAYLOAD_AUDIO_PACKETIZED)
|
||||
&& lc->sound_conf.capt_sndcard
|
||||
&& !(ms_snd_card_get_capabilities(lc->sound_conf.capt_sndcard) & MS_SND_CARD_CAP_BUILTIN_ECHO_CANCELLER)
|
||||
|
|
|
|||
|
|
@ -349,14 +349,15 @@ static MS2_INLINE int get_min_bandwidth(int dbw, int ubw){
|
|||
}
|
||||
|
||||
static MS2_INLINE bool_t bandwidth_is_greater(int bw1, int bw2){
|
||||
if (bw1<0) return TRUE;
|
||||
else if (bw2<0) return FALSE;
|
||||
if (bw1<=0) return TRUE;
|
||||
else if (bw2<=0) return FALSE;
|
||||
else return bw1>=bw2;
|
||||
}
|
||||
|
||||
static MS2_INLINE int get_remaining_bandwidth_for_video(int total, int audio){
|
||||
if (total<=0) return 0;
|
||||
return total-audio-10;
|
||||
int ret = total-audio-10;
|
||||
if (ret < 0) ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MS2_INLINE void set_string(char **dest, const char *src){
|
||||
|
|
|
|||
|
|
@ -265,6 +265,30 @@ static void devices_reload_test(void) {
|
|||
linphone_core_manager_destroy(mgr);
|
||||
}
|
||||
|
||||
static void codec_usability_test(void) {
|
||||
LinphoneCoreManager *mgr = linphone_core_manager_new2("empty_rc", FALSE);
|
||||
PayloadType *pt = linphone_core_find_payload_type(mgr->lc, "PCMU", 8000, -1);
|
||||
|
||||
BC_ASSERT_TRUE(pt!=NULL);
|
||||
if (!pt) goto end;
|
||||
/*no limit*/
|
||||
linphone_core_set_upload_bandwidth(mgr->lc, 0);
|
||||
linphone_core_set_download_bandwidth(mgr->lc, 0);
|
||||
BC_ASSERT_TRUE(linphone_core_check_payload_type_usability(mgr->lc, pt));
|
||||
/*low limit*/
|
||||
linphone_core_set_upload_bandwidth(mgr->lc, 50);
|
||||
linphone_core_set_download_bandwidth(mgr->lc, 50);
|
||||
BC_ASSERT_FALSE(linphone_core_check_payload_type_usability(mgr->lc, pt));
|
||||
|
||||
/*reasonable limit*/
|
||||
linphone_core_set_upload_bandwidth(mgr->lc, 200);
|
||||
linphone_core_set_download_bandwidth(mgr->lc, 200);
|
||||
BC_ASSERT_TRUE(linphone_core_check_payload_type_usability(mgr->lc, pt));
|
||||
|
||||
end:
|
||||
linphone_core_manager_destroy(mgr);
|
||||
}
|
||||
|
||||
test_t setup_tests[] = {
|
||||
{ "Version check", linphone_version_test },
|
||||
{ "Linphone Address", linphone_address_test },
|
||||
|
|
@ -278,7 +302,8 @@ test_t setup_tests[] = {
|
|||
{ "LPConfig zero_len value from file", linphone_lpconfig_from_file_zerolen_value },
|
||||
{ "LPConfig zero_len value from XML", linphone_lpconfig_from_xml_zerolen_value },
|
||||
{ "Chat room", chat_root_test },
|
||||
{ "Devices reload", devices_reload_test }
|
||||
{ "Devices reload", devices_reload_test },
|
||||
{ "Codec usability", codec_usability_test }
|
||||
};
|
||||
|
||||
test_suite_t setup_test_suite = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue