From 1c6fe4dc8315b567ea586cb6b489b7cf599ec3df Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 22 Jun 2015 11:47:53 +0200 Subject: [PATCH] Quality reporting: collector address is now route address of the PUBLISH - if set to NULL, PUBLISH will be sent to proxy config domain --- coreapi/linphonecore.h | 16 +++--- coreapi/quality_reporting.c | 28 ++++++----- tester/quality_reporting_tester.c | 17 +++---- tester/rcfiles/marie_h264_rc | 2 - tester/rcfiles/marie_quality_reporting_rc | 50 +++++++++++++++++++ tester/rcfiles/marie_rc | 2 - tester/rcfiles/marie_sips_rc | 2 - tester/rcfiles/marie_zrtp_aes256_rc | 2 - tester/rcfiles/marie_zrtp_b256_rc | 2 - tester/rcfiles/marie_zrtp_srtpsuite_aes256_rc | 2 - 10 files changed, 83 insertions(+), 40 deletions(-) create mode 100644 tester/rcfiles/marie_quality_reporting_rc diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 60190abca..f0ca66830 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -957,18 +957,20 @@ LINPHONE_PUBLIC void linphone_proxy_config_enable_quality_reporting(LinphoneProx LINPHONE_PUBLIC bool_t linphone_proxy_config_quality_reporting_enabled(LinphoneProxyConfig *cfg); /** - * Set the SIP address of the collector end-point when using quality reporting. This SIP address - * should be used on server-side to process packets directly then discard packets. Collector address - * should be a non existing account and should not received any packets. + * Set the route of the collector end-point when using quality reporting. This SIP address + * should be used on server-side to process packets directly before discarding packets. Collector address + * should be a non existing account and will not receive any messages. + * If NULL, reports will be send to the proxy domain. * @param[in] cfg #LinphoneProxyConfig object - * @param[in] collector SIP address of the collector end-point. + * @param[in] collector route of the collector end-point, if NULL PUBLISH will be sent to the proxy domain. */ LINPHONE_PUBLIC void linphone_proxy_config_set_quality_reporting_collector(LinphoneProxyConfig *cfg, const char *collector); /** - * Get the SIP address of the collector end-point when using quality reporting. This SIP address - * should be used on server-side to process packets directly then discard packets. Collector address - * should be a non existing account and should not received any packets. + * Get the route of the collector end-point when using quality reporting. This SIP address + * should be used on server-side to process packets directly before discarding packets. Collector address + * should be a non existing account and will not receive any messages. + * If NULL, reports will be send to the proxy domain. * @param[in] cfg #LinphoneProxyConfig object * @return The SIP address of the collector end-point. */ diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index 1b389a8dd..0147f9a08 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -258,12 +258,14 @@ static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * off static int send_report(LinphoneCall* call, reporting_session_report_t * report, const char * report_event) { LinphoneContent *content = linphone_content_new(); - LinphoneAddress *addr; int expires = -1; size_t offset = 0; size_t size = 2048; char * buffer; int ret = 0; + LinphoneEvent *lev; + LinphoneAddress *request_uri; + char * domain; /*if we are on a low bandwidth network, do not send reports to not overload it*/ if (linphone_call_params_low_bandwidth_enabled(linphone_call_get_current_params(call))){ @@ -286,14 +288,6 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, goto end; } - addr = linphone_address_new(linphone_proxy_config_get_quality_reporting_collector(call->dest_proxy)); - if (addr == NULL) { - ms_warning("QualityReporting[%p]: Asked to submit reporting statistics but no collector address found" - , call); - ret = 3; - goto end; - } - buffer = (char *) belle_sip_malloc(size); linphone_content_set_type(content, "application"); linphone_content_set_subtype(content, "vq-rtcpxr"); @@ -341,7 +335,18 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, content); } - if (! linphone_core_publish(call->core, addr, "vq-rtcpxr", expires, content)){ + + domain = ms_strdup_printf("sip:%s", linphone_proxy_config_get_domain(call->dest_proxy)); + request_uri = linphone_address_new(domain); + ms_free(domain); + lev=linphone_core_create_publish(call->core, request_uri, "vq-rtcpxr", expires); + if (linphone_proxy_config_get_quality_reporting_collector(call->dest_proxy) != NULL) { + sal_op_set_route(lev->op, linphone_proxy_config_get_quality_reporting_collector(call->dest_proxy)); + } + + if (! linphone_event_send_publish(lev, content)){ + linphone_event_unref(lev); + lev=NULL; ret=4; } else { reset_avg_metrics(report); @@ -352,8 +357,7 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, STR_REASSIGN(report->qos_analyzer.output, NULL); } - linphone_address_destroy(addr); - + linphone_address_destroy(request_uri); linphone_content_unref(content); end: diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 3be839343..9fce7be2b 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -142,19 +142,16 @@ bool_t create_call_for_quality_reporting_tests( } static void quality_reporting_not_used_without_config() { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCall* call_marie = NULL; LinphoneCall* call_pauline = NULL; if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { - // marie has stats collection enabled but pauline has not + // marie has stats collection enabled but pauline has not BC_ASSERT_TRUE(linphone_proxy_config_quality_reporting_enabled(call_marie->dest_proxy)); BC_ASSERT_FALSE(linphone_proxy_config_quality_reporting_enabled(call_pauline->dest_proxy)); - BC_ASSERT_STRING_EQUAL(linphone_proxy_config_get_quality_reporting_collector(call_marie->dest_proxy), - "sip:collector@sip.example.org"); - // this field should be already filled BC_ASSERT_PTR_NOT_NULL(call_marie->log->reporting.reports[0]->info.local_addr.ip); @@ -166,7 +163,7 @@ static void quality_reporting_not_used_without_config() { } static void quality_reporting_not_sent_if_call_not_started() { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCallLog* out_call_log; LinphoneCall* out_call; @@ -197,7 +194,7 @@ static void quality_reporting_not_sent_if_call_not_started() { } static void quality_reporting_not_sent_if_low_bandwidth() { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCallParams* marie_params; @@ -222,7 +219,7 @@ void on_report_send_remove_fields(const LinphoneCall *call, SalStreamType stream } static void quality_reporting_invalid_report() { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCall* call_marie = NULL; LinphoneCall* call_pauline = NULL; @@ -234,6 +231,7 @@ static void quality_reporting_invalid_report() { BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1)); BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishError,1,3000)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishError,1, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); } linphone_core_manager_destroy(marie); @@ -241,7 +239,7 @@ static void quality_reporting_invalid_report() { } static void quality_reporting_at_call_termination() { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr"); LinphoneCall* call_marie = NULL; LinphoneCall* call_pauline = NULL; @@ -262,6 +260,7 @@ static void quality_reporting_at_call_termination() { // PUBLISH submission to the collector should be ok BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,1, int, "%d"); BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishOk,1)); } linphone_core_manager_destroy(marie); diff --git a/tester/rcfiles/marie_h264_rc b/tester/rcfiles/marie_h264_rc index dc89fceb4..8cd970d24 100644 --- a/tester/rcfiles/marie_h264_rc +++ b/tester/rcfiles/marie_h264_rc @@ -22,8 +22,6 @@ reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0 -quality_reporting_collector=sip:collector@sip.example.org -quality_reporting_enabled=1 [friend_0] url="Paupoche" diff --git a/tester/rcfiles/marie_quality_reporting_rc b/tester/rcfiles/marie_quality_reporting_rc new file mode 100644 index 000000000..78068923c --- /dev/null +++ b/tester/rcfiles/marie_quality_reporting_rc @@ -0,0 +1,50 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 +register_only_when_network_is_up=0 +composing_idle_timeout=1 + +[auth_info_0] +username=marie +userid=marie +passwd=secret +realm=sip.example.org + + +[proxy_0] +reg_proxy=sip.example.org;transport=tcp +reg_route=sip.example.org;transport=tcp;lr +reg_identity=sip:marie@sip.example.org +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 +quality_reporting_collector=sip:collector@sip.example.org +quality_reporting_enabled=1 + +[friend_0] +url="Paupoche" +pol=accept +subscribe=0 + + +[rtp] +audio_rtp_port=20070-22070 +video_rtp_port=24000-25000 + +[video] +display=0 +capture=0 +show_local=0 +size=vga +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG diff --git a/tester/rcfiles/marie_rc b/tester/rcfiles/marie_rc index fe9687c36..558671211 100644 --- a/tester/rcfiles/marie_rc +++ b/tester/rcfiles/marie_rc @@ -22,8 +22,6 @@ reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0 -quality_reporting_collector=sip:collector@sip.example.org -quality_reporting_enabled=1 [friend_0] url="Paupoche" diff --git a/tester/rcfiles/marie_sips_rc b/tester/rcfiles/marie_sips_rc index f67cca50d..3556248b0 100644 --- a/tester/rcfiles/marie_sips_rc +++ b/tester/rcfiles/marie_sips_rc @@ -22,8 +22,6 @@ reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0 -quality_reporting_collector=sip:collector@sip2.linphone.org -quality_reporting_enabled=1 [friend_0] url="Paupoche" diff --git a/tester/rcfiles/marie_zrtp_aes256_rc b/tester/rcfiles/marie_zrtp_aes256_rc index 6bf6d2612..2230535b6 100644 --- a/tester/rcfiles/marie_zrtp_aes256_rc +++ b/tester/rcfiles/marie_zrtp_aes256_rc @@ -23,8 +23,6 @@ reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0 -quality_reporting_collector=sip:collector@sip.example.org -quality_reporting_enabled=1 [friend_0] url="Paupoche" diff --git a/tester/rcfiles/marie_zrtp_b256_rc b/tester/rcfiles/marie_zrtp_b256_rc index b7cfca0a4..a9668f2f9 100644 --- a/tester/rcfiles/marie_zrtp_b256_rc +++ b/tester/rcfiles/marie_zrtp_b256_rc @@ -23,8 +23,6 @@ reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0 -quality_reporting_collector=sip:collector@sip.example.org -quality_reporting_enabled=1 [friend_0] url="Paupoche" diff --git a/tester/rcfiles/marie_zrtp_srtpsuite_aes256_rc b/tester/rcfiles/marie_zrtp_srtpsuite_aes256_rc index e966e59c2..3dc5b4d6a 100644 --- a/tester/rcfiles/marie_zrtp_srtpsuite_aes256_rc +++ b/tester/rcfiles/marie_zrtp_srtpsuite_aes256_rc @@ -23,8 +23,6 @@ reg_expires=3600 reg_sendregister=1 publish=0 dial_escape_plus=0 -quality_reporting_collector=sip:collector@sip.example.org -quality_reporting_enabled=1 [friend_0] url="Paupoche"