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_PTR_NOT_NULL(pt); 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); }
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){ 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; }