From e4c70dd7ad50b3debd56281c66ec08dfe6d0a3f8 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 22 May 2017 17:32:09 +0200 Subject: [PATCH 1/2] Added test for video bandwidth estimator --- tester/call_single_tester.c | 1 + tester/liblinphone_tester.h | 1 + tester/quality_reporting_tester.c | 38 ++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 416a5c74b..a078e6f21 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -89,6 +89,7 @@ static void rtcp_received(stats* counters, mblk_t *packet) { do{ if (rtcp_is_type(packet, RTCP_RTPFB)){ if (rtcp_RTPFB_get_type(packet) == RTCP_RTPFB_TMMBR) { + counters->number_of_tmmbr_received++; counters->last_tmmbr_value_received = (int)rtcp_RTPFB_tmmbr_get_max_bitrate(packet); } } diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index cf180625c..15f55b0d6 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -259,6 +259,7 @@ typedef struct _stats { int current_bandwidth_index[2] /*audio and video only*/; int number_of_rtcp_generic_nack; + int number_of_tmmbr_received; int last_tmmbr_value_received; }stats; diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 055813480..5d3818e2e 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -429,6 +429,41 @@ static void quality_reporting_interval_report_video_and_rtt(void) { } #endif +static void video_bandwidth_estimation(void){ + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); + LinphoneVideoPolicy pol = {0}; + OrtpNetworkSimulatorParams simparams = { 0 }; + + 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 = 300000; + linphone_core_set_network_simulator_params(marie->lc, &simparams); + + if (BC_ASSERT_TRUE(call(marie, pauline))){ + /*wait for the first TMMBR*/ + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_tmmbr_received, 1, 50000)); + BC_ASSERT_GREATER((float)marie->stat.last_tmmbr_value_received, 270000.f, float, "%f"); + BC_ASSERT_LOWER((float)marie->stat.last_tmmbr_value_received, 330000.f, float, "%f"); + + end_call(marie, pauline); + } + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + test_t quality_reporting_tests[] = { TEST_NO_TAG("Not used if no config", quality_reporting_not_used_without_config), TEST_NO_TAG("Call term session report not sent if call did not start", quality_reporting_not_sent_if_call_not_started), @@ -440,7 +475,8 @@ test_t quality_reporting_tests[] = { TEST_NO_TAG("Interval report if interval is configured with video and realtime text", quality_reporting_interval_report_video_and_rtt), TEST_NO_TAG("Session report sent if video stopped during call", quality_reporting_session_report_if_video_stopped), #endif - TEST_NO_TAG("Sent using custom route", quality_reporting_sent_using_custom_route) + TEST_NO_TAG("Sent using custom route", quality_reporting_sent_using_custom_route), + TEST_NO_TAG("Video bandwidth estimation", video_bandwidth_estimation) }; test_suite_t quality_reporting_test_suite = {"QualityReporting", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, From 36df948b234fcb94bbe1e2d51b782dceafbfb4db Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 16 Jun 2017 15:12:49 +0200 Subject: [PATCH 2/2] Added expected_bandwidth parameter --- coreapi/linphonecall.c | 3 +++ coreapi/linphonecore.c | 8 ++++++++ include/linphone/core.h | 13 +++++++++++++ 3 files changed, 24 insertions(+) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index fd3a4b5ab..3b91b0b13 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -4791,6 +4791,9 @@ void linphone_call_handle_stream_events(LinphoneCall *call, int stream_index){ if (ms) handle_ice_events(call, ev); } else if (evt==ORTP_EVENT_TELEPHONE_EVENT){ linphone_core_dtmf_received(call,evd->info.telephone_event); + } else if (evt == ORTP_EVENT_NEW_VIDEO_BANDWIDTH_ESTIMATION_AVAILABLE) { + ms_message("Video bandwidth estimation is %i kbit/s", (int)evd->info.video_bandwidth_available / 1000); + //TODO } ortp_event_destroy(ev); } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 4056c294b..9410c41b1 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1054,6 +1054,8 @@ static void net_config_read(LinphoneCore *lc) { linphone_core_set_download_bandwidth(lc,tmp); tmp=lp_config_get_int(config,"net","upload_bw",0); linphone_core_set_upload_bandwidth(lc,tmp); + tmp=lp_config_get_int(config, "net", "expected_bw", 0); + linphone_core_set_expected_bandwidth(lc, tmp); tmpstr=lp_config_get_string(lc->config,"net","nat_address",NULL); if (tmpstr!=NULL && (strlen(tmpstr)<1)) tmpstr=NULL; @@ -1814,6 +1816,11 @@ void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw){ if (linphone_core_ready(lc)) lp_config_set_int(lc->config,"net","upload_bw",bw); } +void linphone_core_set_expected_bandwidth(LinphoneCore *lc, int bw){ + ms_factory_set_expected_bandwidth(lc->factory, bw * 1000); // In linphone we use kbits/s, in ms2 bits/s + if (linphone_core_ready(lc)) lp_config_set_int(lc->config,"net","expected_bw",bw); +} + void linphone_core_set_sip_transport_timeout(LinphoneCore *lc, int timeout_ms) { sal_set_transport_timeout(lc->sal, timeout_ms); if (linphone_core_ready(lc)) @@ -1855,6 +1862,7 @@ int linphone_core_get_download_bandwidth(const LinphoneCore *lc){ int linphone_core_get_upload_bandwidth(const LinphoneCore *lc){ return lc->net_conf.upload_bw; } + void linphone_core_set_download_ptime(LinphoneCore *lc, int ptime) { lp_config_set_int(lc->config,"rtp","download_ptime",ptime); } diff --git a/include/linphone/core.h b/include/linphone/core.h index 463f95f78..757809c47 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -1467,6 +1467,19 @@ LINPHONE_PUBLIC void linphone_core_set_download_bandwidth(LinphoneCore *lc, int */ LINPHONE_PUBLIC void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw); +/** + * Sets expected available upload bandwidth + * This is IP bandwidth, in kbit/s. + * This information is used by liblinphone together with remote + * side available bandwidth signaled in SDP messages to properly + * configure audio & video codec's output bitrate. + * + * @param lc the LinphoneCore object + * @param bw the bandwidth in kbits/s, 0 for infinite + * @ingroup media_parameters + */ +LINPHONE_PUBLIC void linphone_core_set_expected_bandwidth(LinphoneCore *lc, int bw); + /** * Retrieve the maximum available download bandwidth. * This value was set by linphone_core_set_download_bandwidth().