Trying to improve test checking on bandwidth by using max value out of last 3 instead of last value only

This commit is contained in:
Jehan Monnier 2015-05-22 08:46:38 +02:00
parent 30cec33fbd
commit 9f68e464ed
4 changed files with 57 additions and 21 deletions

View file

@ -83,15 +83,24 @@ void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState
void call_stats_updated(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *lstats) {
stats* counters = get_stats(lc);
counters->number_of_LinphoneCallStatsUpdated++;
if (lstats->updated == LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE) {
if (lstats->updated & LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE) {
counters->number_of_rtcp_received++;
} else if (lstats->updated == LINPHONE_CALL_STATS_SENT_RTCP_UPDATE) {
}
if (lstats->updated & LINPHONE_CALL_STATS_SENT_RTCP_UPDATE ) {
counters->number_of_rtcp_sent++;
}
counters->audio_download_bandwidth = linphone_call_get_audio_stats(call)->download_bandwidth;
counters->audio_upload_bandwidth = linphone_call_get_audio_stats(call)->upload_bandwidth;
counters->video_download_bandwidth = linphone_call_get_video_stats(call)->download_bandwidth;
counters->video_upload_bandwidth = linphone_call_get_video_stats(call)->upload_bandwidth;
if (lstats->updated & LINPHONE_CALL_STATS_PERIODICAL_UPDATE ) {
int tab_size = sizeof (counters->audio_download_bandwidth)/sizeof(int);
int index = (counters->current_bandwidth_index++) % tab_size;
counters->current_audio_download_bandwidth = counters->audio_download_bandwidth + index;
counters->current_audio_upload_bandwidth = counters->audio_upload_bandwidth +index;
counters->audio_download_bandwidth[index] = linphone_call_get_audio_stats(call)->download_bandwidth;
counters->audio_upload_bandwidth[index] = linphone_call_get_audio_stats(call)->upload_bandwidth;
counters->video_download_bandwidth[index] = linphone_call_get_video_stats(call)->download_bandwidth;
counters->video_upload_bandwidth[index] = linphone_call_get_video_stats(call)->upload_bandwidth;
}
}
@ -3055,7 +3064,7 @@ static void multiple_early_media(void) {
/*wait a bit that streams are established*/
wait_for_list(lcs,&dummy,1,6000);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth>70);
BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i");
BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth>70);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie2_call)->download_bandwidth>70);
@ -3126,13 +3135,13 @@ void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList*
BC_ASSERT_TRUE(linphone_call_get_audio_stats(call)->upload_bandwidth<5);
case LinphoneMediaDirectionSendOnly:
BC_ASSERT_TRUE(linphone_call_get_video_stats(call)->download_bandwidth<5);
if (audio_dir == LinphoneMediaDirectionSendOnly) BC_ASSERT_TRUE(wait_for_list(lcs,&mgr->stat.audio_upload_bandwidth,70,4000));
if (audio_dir == LinphoneMediaDirectionSendOnly) BC_ASSERT_TRUE(wait_for_list(lcs,mgr->stat.current_audio_upload_bandwidth,70,4000));
break;
case LinphoneMediaDirectionRecvOnly:
BC_ASSERT_TRUE(linphone_call_get_audio_stats(call)->upload_bandwidth<5);
case LinphoneMediaDirectionSendRecv:
BC_ASSERT_TRUE(wait_for_list(lcs,&mgr->stat.audio_download_bandwidth,70,4000));
if (audio_dir == LinphoneMediaDirectionSendRecv) BC_ASSERT_TRUE(wait_for_list(lcs,&mgr->stat.audio_upload_bandwidth,70,4000));
BC_ASSERT_TRUE(wait_for_list(lcs,mgr->stat.current_audio_download_bandwidth,70,4000));
if (audio_dir == LinphoneMediaDirectionSendRecv) BC_ASSERT_TRUE(wait_for_list(lcs,mgr->stat.current_audio_upload_bandwidth,70,4000));
break;
}
}
@ -3449,8 +3458,8 @@ static void call_with_in_dialog_codec_change_base(bool_t no_sdp) {
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
BC_ASSERT_STRING_EQUAL("PCMA",linphone_payload_type_get_mime_type(linphone_call_params_get_used_audio_codec(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)))));
wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(marie->lc))->download_bandwidth>70);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth>70);
BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(marie),70,int,"%i");
BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i");
end_call(marie,pauline);
end:
@ -3711,7 +3720,7 @@ static void call_with_paused_no_sdp_on_resume() {
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
wait_for_until(marie->lc, pauline->lc, &dummy, 1, 3000);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(call_marie)->download_bandwidth>70);
BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(marie),70,int,"%i");
BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth>70);
end:
end_call(marie,pauline);

View file

@ -212,13 +212,18 @@ typedef struct _stats {
int number_of_LinphoneCoreLogCollectionUploadStateDelivered;
int number_of_LinphoneCoreLogCollectionUploadStateNotDelivered;
int number_of_LinphoneCoreLogCollectionUploadStateInProgress;
int audio_download_bandwidth;
int audio_upload_bandwidth;
int video_download_bandwidth;
int video_upload_bandwidth;
int audio_download_bandwidth[3];
int *current_audio_download_bandwidth;
int audio_upload_bandwidth[3];
int *current_audio_upload_bandwidth;
int video_download_bandwidth[3];
int video_upload_bandwidth[3];
int current_bandwidth_index;
}stats;
typedef struct _LinphoneCoreManager {
LinphoneCoreVTable v_table;
LinphoneCore* lc;
@ -313,5 +318,10 @@ void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList*
static const int audio_cmp_max_shift=20;
/*
* this function return max value in the last 3 seconds*/
int linphone_core_manager_get_max_audio_down_bw(const LinphoneCoreManager *mgr);
int linphone_core_manager_get_max_audio_up_bw(const LinphoneCoreManager *mgr);
#endif /* LIBLINPHONE_TESTER_H_ */

View file

@ -53,9 +53,9 @@ static void call_multicast_base(bool_t video) {
linphone_core_enable_audio_multicast(pauline->lc,TRUE);
BC_ASSERT_TRUE(call(pauline,marie));
wait_for_until(marie->lc, pauline->lc, NULL, 1, 3000);
wait_for_until(marie->lc, pauline->lc, NULL, 1, 4000);
if (linphone_core_get_current_call(marie->lc)) {
BC_ASSERT_GREATER(linphone_call_get_audio_stats(linphone_core_get_current_call(marie->lc))->download_bandwidth,70,int,"%d");
BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(marie),70,int,"%d");
if (video) {
/*check video path*/
linphone_call_set_next_video_frame_decoded_callback(linphone_core_get_current_call(marie->lc),linphone_call_cb,marie->lc);
@ -167,10 +167,10 @@ static void early_media_with_multicast_base(bool_t video) {
wait_for_list(lcs, &dummy, 1, 3000);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth>70);
BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i");
BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth<90);
BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline2->lc))->download_bandwidth>70);
BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline2),70,int,"%i");
BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline2->lc))->download_bandwidth<90);
BC_ASSERT_TRUE(linphone_call_params_audio_multicast_enabled(linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc))));

View file

@ -416,3 +416,20 @@ void liblinphone_tester_add_suites() {
#endif
bc_tester_add_suite(&multicast_call_test_suite);
}
static bool_t linphone_core_manager_get_max_audio_bw_base(const int array[],int array_size) {
int i,result=0;
for (i=0; i<array_size; i++) {
result = MAX(result,array[i]);
}
return result;
}
int linphone_core_manager_get_max_audio_down_bw(const LinphoneCoreManager *mgr) {
return linphone_core_manager_get_max_audio_bw_base(mgr->stat.audio_download_bandwidth
, sizeof(mgr->stat.audio_download_bandwidth)/sizeof(int));
}
int linphone_core_manager_get_max_audio_up_bw(const LinphoneCoreManager *mgr) {
return linphone_core_manager_get_max_audio_bw_base(mgr->stat.audio_upload_bandwidth
, sizeof(mgr->stat.audio_upload_bandwidth)/sizeof(int));
}