Commit c4cfbdf9 authored by Simon Morlat's avatar Simon Morlat

fix ordering of newly added codecs

parent 89bbd52d
......@@ -1258,24 +1258,26 @@ static SalStreamType payload_type_get_stream_type(const PayloadType *pt){
static MSList *add_missing_supported_codecs(LinphoneCore *lc, const MSList *default_list, MSList *l){
const MSList *elem;
MSList *newlist;
PayloadType *last_inserted = NULL;
PayloadType *last_seen = NULL;
for(elem=default_list; elem!=NULL; elem=elem->next){
MSList *elem2=ms_list_find(l,elem->data);
if (!elem2){
PayloadType *pt=(PayloadType*)elem->data;
/*this codec from default list should be inserted in the list*/
/*this codec from default list should be inserted in the list, with respect to the default_list order*/
if (!linphone_core_codec_supported(lc, payload_type_get_stream_type(pt), pt->mime_type)) continue;
if (!last_inserted){
if (!last_seen){
l=ms_list_prepend(l,pt);
}else{
const MSList *after=ms_list_find(l,last_inserted);
const MSList *after=ms_list_find(l,last_seen);
l=ms_list_insert(l, after->next, pt);
}
last_inserted = pt;
last_seen = pt;
ms_message("Supported codec %s/%i fmtp=%s automatically added to codec list.", pt->mime_type,
pt->clock_rate, pt->recv_fmtp ? pt->recv_fmtp : "");
}else{
last_seen = (PayloadType*)elem2->data;
}
}
newlist=ms_list_copy_with_data(l,(void *(*)(void*))payload_type_clone);
......
......@@ -53,3 +53,8 @@ echocancellation=0 #to not overload cpu in case of VG
dns_srv_enabled=0 #no srv needed in general
stun_server=stun.linphone.org
#leave this section, which is used by "Codec setup" test of "Setup" suite.
[video_codec_0]
mime=VP8
rate=90000
enabled=1
......@@ -330,6 +330,52 @@ end:
linphone_core_manager_destroy(mgr);
}
/*this test checks default codec list, assuming VP8 and H264 are both supported.
* - with an empty config, the order must be as expected: VP8 first, H264 second.
* - with a config that references only H264, VP8 must be added automatically as first codec.
* - with a config that references only VP8, H264 must be added in second position.
**/
static void codec_setup(void){
LinphoneCoreManager *mgr = linphone_core_manager_new2("empty_rc", FALSE);
PayloadType *vp8, *h264;
const MSList *codecs;
if ((vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1)) == NULL ||
(h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1)) == NULL){
linphone_core_manager_destroy(mgr);
ms_error("H264 or VP8 not available, test skipped.");
BC_PASS("H264 or VP8 not available, test skipped.");
return;
}
codecs = linphone_core_get_video_codecs(mgr->lc);
BC_ASSERT_TRUE(ms_list_size(codecs)>=2);
BC_ASSERT_TRUE(codecs->data == vp8);
BC_ASSERT_TRUE(codecs->next->data == h264);
linphone_core_manager_destroy(mgr);
mgr = linphone_core_manager_new2("marie_h264_rc", FALSE);
vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1);
h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1);
codecs = linphone_core_get_video_codecs(mgr->lc);
BC_ASSERT_TRUE(ms_list_size(codecs)>=2);
BC_ASSERT_PTR_NOT_NULL(vp8);
BC_ASSERT_PTR_NOT_NULL(h264);
BC_ASSERT_TRUE(codecs->data == vp8);
BC_ASSERT_TRUE(codecs->next->data == h264);
linphone_core_manager_destroy(mgr);
mgr = linphone_core_manager_new2("marie_rc", FALSE);
vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1);
h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1);
codecs = linphone_core_get_video_codecs(mgr->lc);
BC_ASSERT_TRUE(ms_list_size(codecs)>=2);
BC_ASSERT_PTR_NOT_NULL(vp8);
BC_ASSERT_PTR_NOT_NULL(h264);
BC_ASSERT_TRUE(codecs->data == vp8);
BC_ASSERT_TRUE(codecs->next->data == h264);
linphone_core_manager_destroy(mgr);
}
test_t setup_tests[] = {
TEST_NO_TAG("Version check", linphone_version_test),
TEST_NO_TAG("Linphone Address", linphone_address_test),
......@@ -344,7 +390,8 @@ test_t setup_tests[] = {
TEST_NO_TAG("LPConfig zero_len value from XML", linphone_lpconfig_from_xml_zerolen_value),
TEST_NO_TAG("Chat room", chat_room_test),
TEST_NO_TAG("Devices reload", devices_reload_test),
TEST_NO_TAG("Codec usability", codec_usability_test)
TEST_NO_TAG("Codec usability", codec_usability_test),
TEST_NO_TAG("Codec setup", codec_setup)
};
test_suite_t setup_test_suite = {"Setup", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment