From a9e94795f4e12f4cce88155023fd4ffe9caf135a Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 10 Apr 2014 17:13:50 +0200 Subject: [PATCH] Quality reporting: fix submit report time moment --- coreapi/linphonecall.c | 2 ++ coreapi/linphonecore.c | 4 ++-- coreapi/quality_reporting.c | 33 +++++++++++++++++++-------------- coreapi/quality_reporting.h | 6 +++--- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index d1e2d15b7..60baf03ff 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -804,6 +804,8 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const if (lc->vtable.call_state_changed) lc->vtable.call_state_changed(lc,call,cstate,message); if (cstate==LinphoneCallReleased){ + linphone_reporting_publish(call); + if (call->op!=NULL) { /*transfer the last error so that it can be obtained even in Released state*/ if (call->non_op_error.reason==SalReasonNone){ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 9468189f8..13ab2027d 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3470,9 +3470,9 @@ static void terminate_call(LinphoneCore *lc, LinphoneCall *call){ /*stop ringing*/ linphone_core_stop_ringing(lc); - linphone_reporting_publish(call, LINPHONE_CALL_STATS_AUDIO); + linphone_reporting_update(call, LINPHONE_CALL_STATS_AUDIO); if (call->videostream!=NULL){ - linphone_reporting_publish(call, LINPHONE_CALL_STATS_VIDEO); + linphone_reporting_update(call, LINPHONE_CALL_STATS_VIDEO); } linphone_call_stop_media_streams(call); diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index ff8ada7e9..1dd413041 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -31,10 +31,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * TODO / REMINDER LIST ****************************************************************************/ // place pour appeler la fonction submit - // only if call succeeded - // executed AFTER BYE's "OK" response has been received - // si c l'autre qui raccroche on envoi pas les données là + // only if call succeeded and ran + // TO_CHECK: executed AFTER BYE's "OK" response has been received + // memory leaks + char* strdup + // si l'autre en face a pas activé le partage de rtcp xr, on a pas de paquets du tout ? faut rien faire dans ce cas ? // si aucune data d'une catégorie est renseigné, ne pas mettre la section dans le paquet // stats // valeur pour "expires" ? @@ -99,7 +100,8 @@ static void append_to_buffer(char **buff, size_t *buff_size, size_t *offset, con va_end(args); } -static reporting_session_report_t * update_report(LinphoneCall * call, int stats_type) { +reporting_session_report_t * linphone_reporting_update(LinphoneCall * call, int stats_type) { + printf("linphone_reporting_call_stats_updated\n"); int count; reporting_session_report_t * report = call->reports[stats_type]; MediaStream stream; @@ -237,7 +239,7 @@ static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * off // append_to_buffer(buffer, size, offset, " BLD=%d", rm.burst_gap_loss.burst_loss_density); // append_to_buffer(buffer, size, offset, " BD=%d", rm.burst_gap_loss.burst_duration); // APPEND_STR_TO_BUFFER(buffer, size, offset, " GLD=%s", gap_loss_density_str); - // append_to_buffer(buffer, size, offset, " GD=%d", rm.burst_gap_loss.gap_Duration); + // append_to_buffer(buffer, size, offset, " GD=%d", rm.burst_gap_loss.gap_duration); // append_to_buffer(buffer, size, offset, " GMIN=%d", rm.burst_gap_loss.min_gap_threshold); append_to_buffer(buffer, size, offset, "\r\nDelay:"); @@ -278,21 +280,14 @@ static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * off free(moscq_str); } -void linphone_reporting_publish(LinphoneCall* call, int stats_type) { +static void reporting_publish(LinphoneCall* call, reporting_session_report_t * report) { LinphoneContent content = {0}; LinphoneAddress *addr; int expires = 3600; - reporting_session_report_t *report = update_report(call, stats_type); size_t offset = 0; size_t size = 2048; char * buffer; - // Somehow the reporting was not created, hence no need to go further - if (report == NULL) { - PRINT("STATS ARE NULL!"); - return; - } - buffer = (char *) ms_malloc(size); content.type = ms_strdup("application"); @@ -330,7 +325,6 @@ void linphone_reporting_publish(LinphoneCall* call, int stats_type) { linphone_address_destroy(addr); } - void linphone_reporting_call_stats_updated(LinphoneCall *call, int stats_type) { reporting_session_report_t * report = call->reports[stats_type]; reporting_content_metrics_t * metrics = NULL; @@ -397,3 +391,14 @@ void linphone_reporting_call_stats_updated(LinphoneCall *call, int stats_type) { } } } + +void linphone_reporting_publish(LinphoneCall* call) { + printf("linphone_reporting_publish\n"); + if (call->reports[LINPHONE_CALL_STATS_AUDIO] != NULL) { + reporting_publish(call, call->reports[LINPHONE_CALL_STATS_AUDIO]); + } + + if (call->reports[LINPHONE_CALL_STATS_VIDEO] != NULL) { + reporting_publish(call, call->reports[LINPHONE_CALL_STATS_VIDEO]); + } +} diff --git a/coreapi/quality_reporting.h b/coreapi/quality_reporting.h index 5b17dfec8..1c4a3ca4d 100644 --- a/coreapi/quality_reporting.h +++ b/coreapi/quality_reporting.h @@ -74,7 +74,7 @@ typedef struct reporting_content_metrics { // int burst_loss_density; // int burst_duration; // float gap_loss_density; - // int gap_Duration; + // int gap_duration; // int min_gap_threshold; // } burst_gap_loss; @@ -136,8 +136,8 @@ typedef struct reporting_session_report { char * dialog_id; // optional } reporting_session_report_t; - -void linphone_reporting_publish(LinphoneCall* call, int stats_type); +reporting_session_report_t * linphone_reporting_update(LinphoneCall * call, int stats_type); +void linphone_reporting_publish(LinphoneCall* call); void linphone_reporting_call_stats_updated(LinphoneCall *call, int stats_type); #ifdef __cplusplus }