From dba8b0de5644daa5eb2083170df5a95c48e4980b Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 11 Jun 2014 14:36:47 +0200 Subject: [PATCH] Quality reporting: add decisions' timestamp in adaptive algorithm section and fix on_action_suggested callback setting --- coreapi/quality_reporting.c | 97 +++++++++++++++++-------------- coreapi/quality_reporting.h | 9 +-- mediastreamer2 | 2 +- tester/quality_reporting_tester.c | 2 - 4 files changed, 59 insertions(+), 51 deletions(-) diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index b59c3a36c..5de9a33f5 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -42,8 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - The Session report when codec change session fork - - if BYE and continue received packet drop them *************************************************************************** * END OF TODO / REMINDER LIST ****************************************************************************/ @@ -154,6 +152,7 @@ static uint8_t are_metrics_filled(const reporting_content_metrics_t rm) { if (rm.signal.level != 127) ret|=METRICS_SIGNAL; if (rm.signal.noise_level != 127) ret|=METRICS_SIGNAL; + if (rm.qos_analyzer.timestamp!=NULL) ret|=METRICS_ADAPTIVE_ALGORITHM; if (rm.qos_analyzer.input_leg!=NULL) ret|=METRICS_ADAPTIVE_ALGORITHM; if (rm.qos_analyzer.input!=NULL) ret|=METRICS_ADAPTIVE_ALGORITHM; if (rm.qos_analyzer.output_leg!=NULL) ret|=METRICS_ADAPTIVE_ALGORITHM; @@ -287,6 +286,7 @@ static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * off if ((available_metrics & METRICS_ADAPTIVE_ALGORITHM) != 0){ append_to_buffer(buffer, size, offset, "\r\nAdaptiveAlg:"); + APPEND_IF_NOT_NULL_STR(buffer, size, offset, " TS=%s", rm.qos_analyzer.timestamp); APPEND_IF_NOT_NULL_STR(buffer, size, offset, " IN_LEG=%s", rm.qos_analyzer.input_leg); APPEND_IF_NOT_NULL_STR(buffer, size, offset, " IN=%s", rm.qos_analyzer.input); APPEND_IF_NOT_NULL_STR(buffer, size, offset, " OUT_LEG=%s", rm.qos_analyzer.output_leg); @@ -416,6 +416,9 @@ static void qos_analyzer_on_action_suggested(void *user_data, int datac, const c reporting_content_metrics_t *metrics = (reporting_content_metrics_t*) user_data; char * appendbuf; + appendbuf=ms_strdup_printf("%s%d;", metrics->qos_analyzer.timestamp?metrics->qos_analyzer.timestamp:"", ms_time(0)); + STR_REASSIGN(metrics->qos_analyzer.timestamp,appendbuf); + STR_REASSIGN(metrics->qos_analyzer.input_leg, ms_strdup(data[0])); appendbuf=ms_strdup_printf("%s%s;", metrics->qos_analyzer.input?metrics->qos_analyzer.input:"", data[1]); STR_REASSIGN(metrics->qos_analyzer.input,appendbuf); @@ -575,6 +578,53 @@ int linphone_reporting_publish_interval_report(LinphoneCall* call) { return publish_report(call, "VQIntervalReport"); } +void linphone_reporting_call_state_updated(LinphoneCall *call){ + LinphoneCallState state=linphone_call_get_state(call); + bool_t enabled=media_report_enabled(call, LINPHONE_CALL_STATS_VIDEO); + + switch (state){ + case LinphoneCallStreamsRunning:{ + int i; + MediaStream *streams[2] = {(MediaStream*) call->audiostream, (MediaStream *) call->videostream}; + MSQosAnalyzer *analyzer; + for (i=0;i<2;i++){ + if (streams[i]==NULL||streams[i]->rc==NULL){ + ms_message("QualityReporting[%p] Cannot set on_action_suggested" + " callback for %s stream because something is null", call, i?"video":"audio"); + continue; + } + + analyzer=ms_bitrate_controller_get_qos_analyzer(streams[i]->rc); + if (analyzer){ + ms_qos_analyzer_set_on_action_suggested(analyzer, + qos_analyzer_on_action_suggested, + &call->log->reporting.reports[i]->local_metrics); + } + } + linphone_reporting_update_ip(call); + if (!enabled && call->log->reporting.was_video_running){ + ms_message("QualityReporting[%p]: Send midterm report with status %d", + call, + send_report(call, call->log->reporting.reports[LINPHONE_CALL_STATS_VIDEO], "VQSessionReport") + ); + } + call->log->reporting.was_video_running=enabled; + break; + } + case LinphoneCallEnd:{ + if (call->log->status==LinphoneCallSuccess || call->log->status==LinphoneCallAborted){ + ms_message("QualityReporting[%p]: Send end reports with status %d", + call, + linphone_reporting_publish_session_report(call, TRUE) + ); + } + break; + } + default:{ + break; + } + } +} reporting_session_report_t * linphone_reporting_new() { int i; reporting_session_report_t * rm = ms_new0(reporting_session_report_t,1); @@ -625,6 +675,7 @@ void linphone_reporting_destroy(reporting_session_report_t * report) { if (report->local_metrics.session_description.payload_desc != NULL) ms_free(report->local_metrics.session_description.payload_desc); if (report->remote_metrics.session_description.fmtp != NULL) ms_free(report->remote_metrics.session_description.fmtp); if (report->remote_metrics.session_description.payload_desc != NULL) ms_free(report->remote_metrics.session_description.payload_desc); + if (report->local_metrics.qos_analyzer.timestamp != NULL) ms_free(report->local_metrics.qos_analyzer.timestamp); if (report->local_metrics.qos_analyzer.input_leg != NULL) ms_free(report->local_metrics.qos_analyzer.input_leg); if (report->local_metrics.qos_analyzer.input != NULL) ms_free(report->local_metrics.qos_analyzer.input); if (report->local_metrics.qos_analyzer.output_leg != NULL) ms_free(report->local_metrics.qos_analyzer.output_leg); @@ -633,46 +684,4 @@ void linphone_reporting_destroy(reporting_session_report_t * report) { ms_free(report); } -void linphone_reporting_call_state_updated(LinphoneCall *call){ - LinphoneCallState state=linphone_call_get_state(call); - bool_t enabled=media_report_enabled(call, LINPHONE_CALL_STATS_VIDEO); - switch (state){ - case LinphoneCallConnected:{ - int i; - MediaStream *streams[2] = {(MediaStream*) call->audiostream, (MediaStream *) call->videostream}; - MSQosAnalyzer *analyzer; - for (i=0;i<2;i++){ - if (streams[i]==NULL||streams[i]->rc==NULL) - continue; - analyzer=ms_bitrate_controller_get_qos_analyzer(streams[i]->rc); - if (analyzer){ - ms_qos_analyzer_set_on_action_suggested(analyzer, - qos_analyzer_on_action_suggested, - &call->log->reporting.reports[i]->local_metrics); - } - } - break; - } - case LinphoneCallStreamsRunning: - linphone_reporting_update_ip(call); - if (!enabled && call->log->reporting.was_video_running){ - ms_message("QualityReporting[%p]: Send midterm report with status %d", - call, - send_report(call, call->log->reporting.reports[LINPHONE_CALL_STATS_VIDEO], "VQSessionReport") - ); - } - call->log->reporting.was_video_running=enabled; - break; - case LinphoneCallEnd: - if (call->log->status==LinphoneCallSuccess || call->log->status==LinphoneCallAborted){ - ms_message("QualityReporting[%p]: Send report with status %d", - call, - linphone_reporting_publish_session_report(call, TRUE) - ); - } - break; - default: - break; - } -} diff --git a/coreapi/quality_reporting.h b/coreapi/quality_reporting.h index 29fb3c4d0..67a4eed8f 100644 --- a/coreapi/quality_reporting.h +++ b/coreapi/quality_reporting.h @@ -98,10 +98,11 @@ typedef struct reporting_content_metrics { /* This should allow us to analysis bad network conditions and quality adaptation on server side*/ struct { - char* input_leg; - char* input; - char* output_leg; - char* output; + char* timestamp; /*time of each decision in seconds*/ + char* input_leg; /*input parameters' name*/ + char* input; /*set of inputs for each decision, semicolon separated*/ + char* output_leg; /*output parameters' name*/ + char* output; /*set of outputs for each decision, semicolon separated*/ } qos_analyzer; // for internal processing diff --git a/mediastreamer2 b/mediastreamer2 index 24427ed56..8e0f6fb25 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 24427ed565a93f523b44b43ed9b2d20f8cea5385 +Subproject commit 8e0f6fb250ed655a136f72e44fbe92fc6c886ae7 diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 3fccb6c83..4bc8a75f4 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -139,7 +139,6 @@ static void quality_reporting_interval_report() { static void quality_reporting_session_report_if_video_stopped() { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); - /*LinphoneCall* call_marie = NULL;*/ LinphoneCall* call_pauline = NULL; LinphoneCallParams* pauline_params; LinphoneCallParams* marie_params; @@ -153,7 +152,6 @@ static void quality_reporting_session_report_if_video_stopped() { pauline_params=linphone_core_create_default_call_parameters(pauline->lc); linphone_call_params_enable_video(pauline_params,TRUE); CU_ASSERT_TRUE(call_with_params(pauline,marie,pauline_params,marie_params)); - /*call_marie=linphone_core_get_current_call(marie->lc);*/ call_pauline=linphone_core_get_current_call(pauline->lc); CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0);