diff --git a/oRTP b/oRTP index 277534655..a3debbd39 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 27753465516af7ace7769bf7e466043f97b8b787 +Subproject commit a3debbd394fb32ab54ed265d2190711971c890e7 diff --git a/tester/call_tester.c b/tester/call_tester.c index 91fe27286..48bb67864 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -79,6 +79,16 @@ void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState CU_FAIL("unexpected event");break; } } + +void call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *lstats) { + stats* counters = get_stats(lc); + if (lstats->updated == LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE) { + counters->number_of_rtcp_received++; + } else if (lstats->updated == LINPHONE_CALL_STATS_SENT_RTCP_UPDATE) { + counters->number_of_rtcp_sent++; + } +} + void linphone_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token) { char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to); char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from); @@ -1140,52 +1150,57 @@ static void call_paused_resumed(void) { linphone_core_manager_destroy(pauline); } +#define CHECK_CURRENT_LOSS_RATE() \ + rtcp_count_current = pauline->stat.number_of_rtcp_sent; \ + /*wait for an RTCP packet to have an accurate cumulative lost value*/ \ + CU_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_rtcp_sent, rtcp_count_current+1, 10000)); \ + stats = rtp_session_get_stats(call_pauline->audiostream->ms.sessions.rtp_session); \ + loss_percentage = stats->cum_packet_loss * 100.f / (stats->packet_recv + stats->cum_packet_loss); \ + CU_ASSERT_TRUE(.75 * params.loss_rate < loss_percentage); \ + CU_ASSERT_TRUE(loss_percentage < 1.25 * params.loss_rate) + 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; float loss_percentage; + int rtcp_count_current; OrtpNetworkSimulatorParams params={0}; params.enabled=TRUE; - params.loss_rate=25; + params.loss_rate=20; 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); + /*generate some traffic*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 6000); + CHECK_CURRENT_LOSS_RATE(); + /*pause call*/ 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, 10000); + wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000); + CHECK_CURRENT_LOSS_RATE(); + /*resume*/ 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, 6000); /*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); - loss_percentage = stats->cum_packet_loss * 100.f / stats->packet_recv; - CU_ASSERT_TRUE(.75 * params.loss_rate < loss_percentage); - CU_ASSERT_TRUE(loss_percentage < 1.25 * params.loss_rate); - - /*just to sleep*/ - linphone_core_terminate_all_calls(pauline->lc); + CHECK_CURRENT_LOSS_RATE(); + linphone_core_terminate_all_calls(marie->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); } diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index d7f5c26ce..a7c82913a 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -206,6 +206,10 @@ typedef struct _stats { char * dtmf_list_received; int dtmf_count; + + int number_of_rtcp_sent; + int number_of_rtcp_received; + }stats; typedef struct _LinphoneCoreManager { @@ -247,6 +251,7 @@ void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char * void linphone_configuration_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message); void linphone_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token); void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf); +void call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats); LinphoneAddress * create_linphone_address(const char * domain); bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value); diff --git a/tester/tester.c b/tester/tester.c index a74b0a675..d8639db47 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -247,6 +247,7 @@ LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_f mgr->v_table.call_encryption_changed=linphone_call_encryption_changed; mgr->v_table.network_reachable=network_reachable; mgr->v_table.dtmf_received=dtmf_received; + mgr->v_table.call_stats_updated=call_stats_updated; reset_counters(&mgr->stat); if (rc_file) rc_path = ms_strdup_printf("rcfiles/%s", rc_file);