From 3f38e294085de8355617218315be6a719574ee19 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 24 Sep 2015 09:36:45 +0200 Subject: [PATCH] Improved complex sip call tester --- coreapi/linphonecall.c | 10 ++-- tester/complex_sip_call_tester.c | 80 +++++++++++++++++++------------- 2 files changed, 53 insertions(+), 37 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 9d60cff50..d34fdef0a 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -3165,21 +3165,21 @@ static void linphone_call_start_text_stream(LinphoneCall *call) { tstream = sal_media_description_find_best_stream(call->resultdesc, SalText); if (tstream != NULL && tstream->dir != SalStreamInactive && tstream->rtp_port != 0) { - const char *rtp_addr=tstream->rtp_addr[0]!='\0' ? tstream->rtp_addr : call->resultdesc->addr; - const char *rtcp_addr=tstream->rtcp_addr[0]!='\0' ? tstream->rtcp_addr : call->resultdesc->addr; + const char *rtp_addr = tstream->rtp_addr[0] != '\0' ? tstream->rtp_addr : call->resultdesc->addr; + const char *rtcp_addr = tstream->rtcp_addr[0] != '\0' ? tstream->rtcp_addr : call->resultdesc->addr; const SalStreamDescription *local_st_desc = sal_media_description_find_stream(call->localdesc, tstream->proto, SalText); bool_t is_multicast = ms_is_multicast(rtp_addr); call->text_profile = make_profile(call, call->resultdesc, tstream, &used_pt); if (used_pt != -1) { call->current_params->text_codec = rtp_profile_get_payload(call->text_profile, used_pt); - call->current_params->realtimetext_enabled=TRUE; + call->current_params->realtimetext_enabled = TRUE; if (sal_stream_description_has_srtp(tstream) == TRUE) { int crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, tstream->crypto_local_tag); if (crypto_idx >= 0) { - ms_media_stream_sessions_set_srtp_recv_key_b64(&call->textstream->ms.sessions, tstream->crypto[0].algo,tstream->crypto[0].master_key); - ms_media_stream_sessions_set_srtp_send_key_b64(&call->textstream->ms.sessions, tstream->crypto[0].algo,local_st_desc->crypto[crypto_idx].master_key); + ms_media_stream_sessions_set_srtp_recv_key_b64(&call->textstream->ms.sessions, tstream->crypto[0].algo, tstream->crypto[0].master_key); + ms_media_stream_sessions_set_srtp_send_key_b64(&call->textstream->ms.sessions, tstream->crypto[0].algo, local_st_desc->crypto[crypto_idx].master_key); } } configure_rtp_session_for_rtcp_fb(call, tstream); diff --git a/tester/complex_sip_call_tester.c b/tester/complex_sip_call_tester.c index 21b63b679..96c10d354 100644 --- a/tester/complex_sip_call_tester.c +++ b/tester/complex_sip_call_tester.c @@ -141,15 +141,19 @@ static void call_with_audio_mline_before_video_in_sdp() { if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); - call = linphone_core_get_current_call(mgr->lc); - linphone_core_accept_call(mgr->lc, call); - BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); - BC_ASSERT_EQUAL(call->main_audio_stream_index, 0, int, "%d"); - BC_ASSERT_EQUAL(call->main_video_stream_index, 1, int, "%d"); - BC_ASSERT_TRUE(call->main_text_stream_index > 1); - BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); + call = linphone_call_ref(linphone_core_get_current_call(mgr->lc)); + BC_ASSERT_PTR_NOT_NULL(call); + if (call) { + linphone_core_accept_call(mgr->lc, call); + BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); + BC_ASSERT_EQUAL(call->main_audio_stream_index, 0, int, "%d"); + BC_ASSERT_EQUAL(call->main_video_stream_index, 1, int, "%d"); + BC_ASSERT_TRUE(call->main_text_stream_index > 1); + BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); - check_rtcp(call); + check_rtcp(call); + linphone_call_unref(call); + } BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); @@ -179,15 +183,19 @@ static void call_with_video_mline_before_audio_in_sdp() { if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); - call = linphone_core_get_current_call(mgr->lc); - linphone_core_accept_call(mgr->lc, call); - BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); - BC_ASSERT_EQUAL(call->main_audio_stream_index, 1, int, "%d"); - BC_ASSERT_EQUAL(call->main_video_stream_index, 0, int, "%d"); - BC_ASSERT_TRUE(call->main_text_stream_index > 1); - BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); + call = linphone_call_ref(linphone_core_get_current_call(mgr->lc)); + BC_ASSERT_PTR_NOT_NULL(call); + if (call) { + linphone_core_accept_call(mgr->lc, call); + BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); + BC_ASSERT_EQUAL(call->main_audio_stream_index, 1, int, "%d"); + BC_ASSERT_EQUAL(call->main_video_stream_index, 0, int, "%d"); + BC_ASSERT_TRUE(call->main_text_stream_index > 1); + BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); - check_rtcp(call); + check_rtcp(call); + linphone_call_unref(call); + } BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); @@ -217,15 +225,19 @@ static void call_with_multiple_audio_mline_in_sdp() { if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); - call = linphone_core_get_current_call(mgr->lc); - linphone_core_accept_call(mgr->lc, call); - BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); - BC_ASSERT_EQUAL(call->main_audio_stream_index, 0, int, "%d"); - BC_ASSERT_EQUAL(call->main_video_stream_index, 2, int, "%d"); - BC_ASSERT_TRUE(call->main_text_stream_index > 2); - BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); + call = linphone_call_ref(linphone_core_get_current_call(mgr->lc)); + BC_ASSERT_PTR_NOT_NULL(call); + if (call) { + linphone_core_accept_call(mgr->lc, call); + BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); + BC_ASSERT_EQUAL(call->main_audio_stream_index, 0, int, "%d"); + BC_ASSERT_EQUAL(call->main_video_stream_index, 2, int, "%d"); + BC_ASSERT_TRUE(call->main_text_stream_index > 2); + BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); - check_rtcp(call); + check_rtcp(call); + linphone_call_unref(call); + } BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); @@ -255,15 +267,19 @@ static void call_with_multiple_video_mline_in_sdp() { if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); - call = linphone_core_get_current_call(mgr->lc); - linphone_core_accept_call(mgr->lc, call); - BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); - BC_ASSERT_EQUAL(call->main_audio_stream_index, 0, int, "%d"); - BC_ASSERT_EQUAL(call->main_video_stream_index, 1, int, "%d"); - BC_ASSERT_TRUE(call->main_text_stream_index > 3); - BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); + call = linphone_call_ref(linphone_core_get_current_call(mgr->lc)); + BC_ASSERT_PTR_NOT_NULL(call); + if (call) { + linphone_core_accept_call(mgr->lc, call); + BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); + BC_ASSERT_EQUAL(call->main_audio_stream_index, 0, int, "%d"); + BC_ASSERT_EQUAL(call->main_video_stream_index, 1, int, "%d"); + BC_ASSERT_TRUE(call->main_text_stream_index > 3); + BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); - check_rtcp(call); + check_rtcp(call); + linphone_call_unref(call); + } BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out);