From df7dccf4ad5fc07627e0abfe801b515415f059a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Mon, 11 Sep 2017 14:44:37 +0200 Subject: [PATCH] Add a test for video bandwith estimation with tmmbr callback --- tester/call_video_tester.c | 66 +++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index b0de949c6..e6634b7c9 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -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,