Add a test for video bandwith estimation with tmmbr callback

This commit is contained in:
Mickaël Turnel 2017-09-11 14:44:37 +02:00
parent 81cb216c22
commit df7dccf4ad

View file

@ -2003,6 +2003,69 @@ static void video_call_with_thin_congestion(void){
linphone_core_manager_destroy(pauline);
}
static void on_tmmbr_received(LinphoneCall *call, int stream_index, int tmmbr) {
if (stream_index == call->main_video_stream_index) {
stats* stat = get_stats(call->core);
stat->last_tmmbr_value_received = tmmbr;
}
}
static void call_created(LinphoneCore *lc, LinphoneCall *call){
LinphoneCallCbs *cbs = linphone_factory_create_call_cbs(linphone_factory_get());
linphone_call_cbs_set_tmmbr_received(cbs, on_tmmbr_received);
linphone_call_add_callbacks(call, cbs);
linphone_call_cbs_unref(cbs);
}
/*
* This test simulates a higher bandwith available from marie than expected.
* The stream from pauline to marie is not under test.
* It checks that after a few seconds marie received a TMMBR with the approximate value corresponding to the new bandwidth.
*
**/
static void video_call_with_high_bandwith_available(void) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
LinphoneVideoPolicy pol = {0};
OrtpNetworkSimulatorParams simparams = { 0 };
LinphoneCoreCbs *core_cbs = linphone_factory_create_core_cbs(linphone_factory_get());
linphone_core_set_video_device(marie->lc, "Mire: Mire (synthetic moving picture)");
linphone_core_enable_video_capture(marie->lc, TRUE);
linphone_core_enable_video_display(marie->lc, TRUE);
linphone_core_enable_video_capture(pauline->lc, TRUE);
linphone_core_enable_video_display(pauline->lc, TRUE);
pol.automatically_accept = TRUE;
pol.automatically_initiate = TRUE;
linphone_core_set_video_policy(marie->lc, &pol);
linphone_core_set_video_policy(pauline->lc, &pol);
linphone_core_set_preferred_video_size_by_name(marie->lc, "vga");
simparams.mode = OrtpNetworkSimulatorOutbound;
simparams.enabled = TRUE;
simparams.max_bandwidth = 1000000;
simparams.max_buffer_size = (int)simparams.max_bandwidth;
simparams.latency = 60;
linphone_core_set_network_simulator_params(marie->lc, &simparams);
linphone_core_cbs_set_call_created(core_cbs, call_created);
if (BC_ASSERT_TRUE(call(marie, pauline))){
/*wait a little in order to have traffic*/
BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, NULL, 5, 10000));
BC_ASSERT_GREATER((float)marie->stat.last_tmmbr_value_received, 1030000.f, float, "%f");
BC_ASSERT_LOWER((float)marie->stat.last_tmmbr_value_received, 970000.f, float, "%f");
end_call(marie, pauline);
}
linphone_core_cbs_unref(core_cbs);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
test_t call_video_tests[] = {
#ifdef VIDEO_ENABLED
TEST_NO_TAG("Call paused resumed with video", call_paused_resumed_with_video),
@ -2071,7 +2134,8 @@ test_t call_video_tests[] = {
#endif
TEST_NO_TAG("Video call with no audio and no video codec", video_call_with_no_audio_and_no_video_codec),
TEST_NO_TAG("Call with early media and no SDP in 200 Ok with video", call_with_early_media_and_no_sdp_in_200_with_video),
TEST_NO_TAG("Video call with thin congestion", video_call_with_thin_congestion)
TEST_NO_TAG("Video call with thin congestion", video_call_with_thin_congestion),
TEST_NO_TAG("Video call with high bandwith available", video_call_with_high_bandwith_available)
};
test_suite_t call_video_test_suite = {"Video Call", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,