From f891abe4db82ef24c9d307b73f18e68937adadd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Fri, 29 Sep 2017 11:53:51 +0200 Subject: [PATCH] Add unit tests for fps in video calls --- tester/call_video_tester.c | 96 +++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index e5ed49465..a1ba11d2b 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -2067,6 +2067,95 @@ static void video_call_with_high_bandwidth_available(void) { linphone_core_manager_destroy(pauline); } +static void video_call_expected_fps_for_specified_bandwidth(int bandwidth, int fps, const char *resolution) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); + LinphoneVideoPolicy pol = {0}; + OrtpNetworkSimulatorParams simparams = { 0 }; + + if (ms_factory_get_cpu_count(marie->lc->factory) >= 2) { + 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, resolution); + simparams.mode = OrtpNetworkSimulatorOutbound; + simparams.enabled = TRUE; + simparams.max_bandwidth = bandwidth; + simparams.max_buffer_size = (int)simparams.max_bandwidth; + simparams.latency = 60; + + linphone_core_set_network_simulator_params(marie->lc, &simparams); + + if (BC_ASSERT_TRUE(call(marie, pauline))){ + LinphoneCall *call = linphone_core_get_current_call(marie->lc); + + /*wait for the first TMMBR*/ + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.last_tmmbr_value_received, 1, 10000)); + BC_ASSERT_EQUAL((int)call->videostream->configured_fps, fps, int, "%d"); + + end_call(marie, pauline); + } + } else { + BC_PASS("Test requires at least a dual core"); + } + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +/* + * This test simulates a video call with a lower bandwidth than the required_bitrate of the lowest given configuration. + * The stream from pauline to marie is not under test. + * It checks that after a few seconds marie, after receiving a TMMBR, has her fps set to the lowest given configuration. + * This test requires at least a computer with 2 CPUs. + * +**/ +static void video_call_expected_fps_for_low_bandwidth(void) { +#if defined(__ANDROID__) || (TARGET_OS_IPHONE == 1) || defined(__arm__) || defined(_M_ARM) + video_call_expected_fps_for_specified_bandwidth(50000, 10, "qvga"); +#else + video_call_expected_fps_for_specified_bandwidth(250000, 15, "vga"); +#endif +} + +/* + * This test simulates a video call with a regular bandwidth that is between a given configuration. + * The stream from pauline to marie is not under test. + * It checks that after a few seconds marie, after receiving a TMMBR, has her fps set to the expected given configuration. + * This test requires at least a computer with 2 CPUs. + * +**/ +static void video_call_expected_fps_for_regular_bandwidth(void) { +#if defined(__ANDROID__) || (TARGET_OS_IPHONE == 1) || defined(__arm__) || defined(_M_ARM) + video_call_expected_fps_for_specified_bandwidth(250000, 18, "qvga"); +#else + video_call_expected_fps_for_specified_bandwidth(450000, 25, "vga"); +#endif +} + +/* + * This test simulates a video call with a higher bandwidth than the bitrate_limit of the highest given configuration. + * The stream from pauline to marie is not under test. + * It checks that after a few seconds marie, after receiving a TMMBR, has her fps set to the highest given configuration. + * This test requires at least a computer with 2 CPUs. + * +**/ +static void video_call_expected_fps_for_high_bandwidth(void) { +#if defined(__ANDROID__) || (TARGET_OS_IPHONE == 1) || defined(__arm__) || defined(_M_ARM) + video_call_expected_fps_for_specified_bandwidth(500000, 18, "qvga"); +#else + video_call_expected_fps_for_specified_bandwidth(5000000, 30, "vga"); +#endif +} + test_t call_video_tests[] = { #ifdef VIDEO_ENABLED TEST_NO_TAG("Call paused resumed with video", call_paused_resumed_with_video), @@ -2132,11 +2221,14 @@ test_t call_video_tests[] = { TEST_NO_TAG("Classic video entry phone setup", classic_video_entry_phone_setup), TEST_NO_TAG("Incoming REINVITE with invalid SDP in ACK", incoming_reinvite_with_invalid_ack_sdp), TEST_NO_TAG("Outgoing REINVITE with invalid SDP in ACK", outgoing_reinvite_with_invalid_ack_sdp), -#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 high bandwidth available", video_call_with_high_bandwidth_available) + TEST_NO_TAG("Video call with high bandwidth available", video_call_with_high_bandwidth_available), + TEST_NO_TAG("Video call expected FPS for low bandwidth", video_call_expected_fps_for_low_bandwidth), + TEST_NO_TAG("Video call expected FPS for regular bandwidth", video_call_expected_fps_for_regular_bandwidth), + TEST_NO_TAG("Video call expected FPS for high bandwidth", video_call_expected_fps_for_high_bandwidth) +#endif }; test_suite_t call_video_test_suite = {"Video Call", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,