From 9280f2ba7371785fa3a9b464fef5aa1b1ef3c9bc Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 7 Jul 2014 16:20:27 +0200 Subject: [PATCH] fix unexpected high loss values in RTCP reports when resuming calls --- .gitignore | 1 + mediastreamer2 | 2 +- oRTP | 2 +- tester/call_tester.c | 81 +++++++++++++++++++++++++++++++++++++------- 4 files changed, 71 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 047ebb08c..6a94843fa 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ tools/lpc2xml_test tools/xml2lpc_test coreapi/help/filetransfer tester/receive_file.dump +tester/tmp.db diff --git a/mediastreamer2 b/mediastreamer2 index 4a919b63a..0622ff738 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 4a919b63a6f4583d8dc464e32b542151359d264f +Subproject commit 0622ff73822d27191e31391f135c90f6e5e8dcbb diff --git a/oRTP b/oRTP index e56d11d0b..ad02c6d5e 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit e56d11d0b062ea96c8356513add39511b7cb4043 +Subproject commit ad02c6d5ed76092157aff9c1061abfd490ac03ae diff --git a/tester/call_tester.c b/tester/call_tester.c index f5eadb3b6..b507b5855 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -306,6 +306,8 @@ static void call_outbound_with_multiple_proxy() { // calling marie should go through the second proxy config CU_ASSERT_TRUE(call(marie, pauline)); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); } #if 0 /* TODO: activate test when the implementation is ready */ @@ -934,15 +936,11 @@ static void call_paused_resumed(void) { wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000); - int exp_cum = - rtp_session_get_rcv_ext_seq_number(call_pauline->audiostream->ms.sessions.rtp_session); - linphone_core_pause_call(pauline->lc,call_pauline); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); - exp_cum += rtp_session_get_seq_number(linphone_core_get_current_call(marie->lc)->audiostream->ms.sessions.rtp_session); - /*stay in pause a little while in order to generate traffic*/ wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); @@ -953,11 +951,58 @@ static void call_paused_resumed(void) { /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/ wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000); - /*there should be a bit of packets loss for the ones sent by PAUSED (pauline) between the latest RTCP SR report received - by PAUSER (marie) because PAUSER will drop any packets received after the pause. Keep a tolerance of 1 more packet lost - in case of ...*/ + /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/ stats = rtp_session_get_stats(call_pauline->sessions->rtp_session); - CU_ASSERT_TRUE(abs(stats->cum_packet_loss - exp_cum)<=1); + CU_ASSERT_EQUAL(stats->cum_packet_loss, 0); + + /*just to sleep*/ + linphone_core_terminate_all_calls(pauline->lc); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1)); + + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_paused_resumed_with_loss(void) { + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); + LinphoneCall* call_pauline; + const rtp_stats_t * stats; + + + OrtpNetworkSimulatorParams params={0}; + params.enabled=TRUE; + params.loss_rate=25; + + + CU_ASSERT_TRUE(call(pauline,marie)); + call_pauline = linphone_core_get_current_call(pauline->lc); + rtp_session_enable_network_simulation(call_pauline->audiostream->ms.sessions.rtp_session,¶ms); + rtp_session_enable_network_simulation(call_pauline->videostream->ms.sessions.rtp_session,¶ms); + + wait_for_until(pauline->lc, marie->lc, NULL, 5, 4000); + + linphone_core_pause_call(pauline->lc,call_pauline); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); + + /*stay in pause a little while in order to generate traffic*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); + + linphone_core_resume_call(pauline->lc,call_pauline); + + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); + /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000); + + /*since stats are NOT totally reset during pause, the stats->packet_recv is computed from + the start of call. This test ensures that the loss rate is consistent during the entire call.*/ + stats = rtp_session_get_stats(call_pauline->sessions->rtp_session); + CU_ASSERT_TRUE(((stats->cum_packet_loss * 100.f / stats->packet_recv) / params.loss_rate) > .5f); /*just to sleep*/ linphone_core_terminate_all_calls(pauline->lc); @@ -984,19 +1029,29 @@ static bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,Linph static void call_paused_resumed_from_callee(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); - LinphoneCall* call_obj; + LinphoneCall* call_marie; + const rtp_stats_t * stats; CU_ASSERT_TRUE(call(pauline,marie)); - call_obj = linphone_core_get_current_call(marie->lc); + call_marie = linphone_core_get_current_call(marie->lc); - linphone_core_pause_call(marie->lc,call_obj); + linphone_core_pause_call(marie->lc,call_marie); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausing,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPaused,1)); - linphone_core_resume_call(marie->lc,call_obj); + /*stay in pause a little while in order to generate traffic*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); + + linphone_core_resume_call(marie->lc,call_marie); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + /*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000); + + /*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/ + stats = rtp_session_get_stats(call_marie->sessions->rtp_session); + CU_ASSERT_EQUAL(stats->cum_packet_loss, 0); /*just to sleep*/ linphone_core_terminate_all_calls(pauline->lc); @@ -1007,7 +1062,6 @@ static void call_paused_resumed_from_callee(void) { linphone_core_manager_destroy(pauline); } - #ifdef VIDEO_ENABLED static bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee) { LinphoneVideoPolicy caller_policy; @@ -2617,6 +2671,7 @@ test_t call_tests[] = { { "Call terminated by caller", call_terminated_by_caller }, { "Call without SDP", call_with_no_sdp}, { "Call paused resumed", call_paused_resumed }, + { "Call paused resumed with loss", call_paused_resumed_with_loss }, { "Call paused resumed from callee", call_paused_resumed_from_callee }, { "SRTP call", srtp_call }, { "ZRTP call",zrtp_call},