Use a struct to store reporting data

parent ce0d3bde
......@@ -25,9 +25,105 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "private.h"
#include "sal/sal.h"
#define PRINT2(x, f) ms_message(#x ": " #f, x)
#define PRINT2(x, f) printf(#x ": " #f "\n", x)
#define PRINT(x) PRINT2(x, "%s")
// since printf family functions are LOCALE dependent, float separator may differ
// depending on the user's locale (LC_NUMERIC env var).
static char * float_to_one_decimal_string(float f) {
int floor_part = (int)f;
int one_decimal_part = (int) (10.f * (f - floor_part));
return ms_strdup_printf(_("%d.%d"), floor_part, one_decimal_part);
}
struct _reporting_metrics_st {
time_t ts_start;
time_t ts_stop;
int sd_pt;
char * sd_pd;
int sd_sr;
int sd_fd;
int sd_fo;
int sd_fpp;
int sd_pps;
char * sd_fmtp;
int sd_plc;
char * sd_ssup;
int jb_jba;
int jb_jbr;
int jb_jbn;
int jb_jbm;
int jb_jbx;
float pl_nlr;
float pl_jdr;
int bgl_bld;
int bgl_bd;
float bgl_gld;
int bgl_gd;
int bgl_gmin;
int d_rtd;
int d_esd;
int d_sowd;
int d_iaj;
int d_maj;
int s_sl;
int s_nl;
int s_rerl;
int qe_rlq;
int qe_rcq;
int qe_extri;
float qe_moslq;
float qe_moscq;
char * qe_qoeestalg;
};
static char * add_metrics(char * dest, struct _reporting_metrics_st rm) {
char * tmp = dest;
dest = ms_strdup_printf(_("%sTimestamps:START=%s STOP=%s\r\n"), tmp,
linphone_timestamp_to_rfc3339_string(rm.ts_start),
linphone_timestamp_to_rfc3339_string(rm.ts_stop));
ms_free(tmp);
tmp = dest;
dest = ms_strdup_printf(_("%sSessionDesc:PT=%d PD=%s SR=%d FD=%d FO=%d FPP=%d PPS=%d FMTP=%s PLC=%d SSUP=%s\r\n"),
tmp, rm.sd_pt, rm.sd_pd, rm.sd_sr, rm.sd_fd, rm.sd_fo, rm.sd_fpp, rm.sd_pps, rm.sd_fmtp, rm.sd_plc, rm.sd_ssup);
ms_free(tmp);
tmp = dest;
dest = ms_strdup_printf(_("%sJitterBuffer:JBA=%d JBR=%d JBN=%d JBM=%d JBX=%d\r\n"),
tmp, rm.jb_jba, rm.jb_jbr, rm.jb_jbn, rm.jb_jbm, rm.jb_jbx);
ms_free(tmp);
tmp = dest;
dest = ms_strdup_printf(_("%sPacketLoss:NLR=%s JDR=%s\r\n"),
tmp, float_to_one_decimal_string(rm.pl_nlr), float_to_one_decimal_string(rm.pl_jdr));
ms_free(tmp);
tmp = dest;
dest = ms_strdup_printf(_("%sBurstGapLoss:BLD=%d BD=%d GLD=%s GD=%d GMIN=%d\r\n"),
tmp, rm.bgl_bld, rm.bgl_bd, float_to_one_decimal_string(rm.bgl_gld), rm.bgl_gd, rm.bgl_gmin);
ms_free(tmp);
tmp = dest;
dest = ms_strdup_printf(_("%sDelay:RTD=%d ESD=%d SOWD=%d IAJ=%d MAJ=%d\r\n"),
tmp, rm.d_rtd, rm.d_esd, rm.d_sowd, rm.d_iaj, rm.d_maj);
ms_free(tmp);
tmp = dest;
dest = ms_strdup_printf(_("%sSignal:SL=%d NL=%d RERL=%d\r\n"),
tmp, rm.s_sl, rm.s_nl, rm.s_rerl);
ms_free(tmp);
tmp = dest;
dest = ms_strdup_printf(_("%sQualityEst:RLQ=%d RCQ=%d EXTRI=%d MOSLQ=%s MOSCQ=%s QoEEstAlg=%s\r\n"),
tmp, rm.qe_rlq, rm.qe_rcq, rm.qe_extri, float_to_one_decimal_string(rm.qe_moslq), float_to_one_decimal_string(rm.qe_moscq), rm.qe_qoeestalg);
ms_free(tmp);
return dest;
}
void linphone_quality_reporting_submit(LinphoneCall* call) {
// example at http://tools.ietf.org/html/rfc6035#section-4.7.3
// only if this is a linphone account
......@@ -37,21 +133,24 @@ void linphone_quality_reporting_submit(LinphoneCall* call) {
// expires value?
// un envoi à faire par stream ? (ssrc différent pour chaque stream)
// memory leaks
// belle_sip_snprintf
//ex RERL 404 code différent potentiellement avec info manquante
// 3611 pour savoir les valeurs pour les champs non disponibles
LinphoneContent content = {0};
LinphoneAddress *addr;
int expires = 3600;
const char *remote_identity;
const char *local_identity;
const char *orig_identity;
const char *local_ip = call->localdesc->addr; //or call->localip ?
const char *local_ip = "TODO";//stream dependentcall->localdesc->addr; //or call->localip ?
const char *remote_ip = "TODO";
uint32_t local_ssrc = rtp_session_get_send_ssrc(call->audiostream->ms.session);
uint32_t remote_ssrc = rtp_session_get_recv_ssrc(call->audiostream->ms.session);
int local_port = 0; //TODO
int remote_port = 0;//linphone_address_get_port(linphone_call_get_remote_address(call));
uint32_t local_ssrc = rtp_session_get_send_ssrc(call->audiostream->ms.session);
uint32_t remote_ssrc = rtp_session_get_recv_ssrc(call->audiostream->ms.session);
struct _reporting_metrics_st local_metrics = {0};
struct _reporting_metrics_st remote_metrics = {0};
const char *remote_identity;
const char *local_identity;
const char *orig_identity;
if (call->dir == LinphoneCallIncoming) {
remote_identity = linphone_address_as_string(call->log->from);
local_identity = linphone_address_as_string(call->log->to);
......@@ -64,30 +163,6 @@ void linphone_quality_reporting_submit(LinphoneCall* call) {
ms_message("Submitting PUBLISH packet for call between %s and %s", local_identity, remote_identity);
PRINT(call->dest_proxy->contact_params);
PRINT(call->dest_proxy->contact_uri_params);
PRINT(call->dest_proxy->dial_prefix);
PRINT(call->dest_proxy->realm);
PRINT(call->dest_proxy->type);
PRINT(call->dest_proxy->reg_identity);
PRINT(call->dest_proxy->reg_proxy);
PRINT(call->dest_proxy->reg_route);
PRINT(sal_op_get_route(call->op));
PRINT(sal_op_get_from(call->op));
PRINT(sal_op_get_to(call->op));
PRINT(sal_op_get_proxy(call->op));
PRINT(sal_op_get_remote_contact(call->op));
PRINT(sal_op_get_network_origin(call->op));
PRINT(call->log->refkey);
PRINT(call->localdesc->addr);
PRINT2(call->log->start_date_time, "%ld");
PRINT2(call->log->start_date_time + call->log->duration, "%ld");
PRINT(linphone_timestamp_to_rfc3339_string(call->log->start_date_time));
content.type = ms_strdup("application");
content.subtype = ms_strdup("vq-rtcpxr");
content.data = ms_strdup_printf(_("VQSessionReport: CallTerm\r\n"));
......@@ -104,22 +179,22 @@ void linphone_quality_reporting_submit(LinphoneCall* call) {
// content.data = ms_strdup_printf(_("%sRemoteMAC: %s\r\n"), content.data, "TO_DO");
content.data = ms_strdup_printf(_("%sLocalMetrics:\r\n"), content.data);
content.data = ms_strdup_printf(_("%sTimestamps: START=%s STOP=%s\r\n"), content.data,
linphone_timestamp_to_rfc3339_string(call->log->start_date_time),
linphone_timestamp_to_rfc3339_string(call->log->start_date_time + call->log->duration));
content.data = ms_strdup_printf(_("%sRemoteMetrics:\r\n"), content.data, "TO_DO");
content.data = ms_strdup_printf(_("%sRemoteMetrics:\r\n"), content.data, "TO_DO");
content.data = ms_strdup_printf(_("%sTimestamps: %s\r\n"), content.data, "TO_DO");
local_metrics.ts_start = call->log->start_date_time;
local_metrics.ts_stop = call->log->start_date_time + call->log->duration;
content.data = add_metrics((char*)content.data, local_metrics);
content.data = ms_strdup_printf(_("%sRemoteMetrics:\r\n"), content.data);
remote_metrics.bgl_gld = 42.34f;
content.data = add_metrics((char*)content.data, remote_metrics);
content.data = ms_strdup_printf(_("%sDialogID: %s\r\n"), content.data, "TO_DO");
// for debug purpose only
PRINT(content.data);
content.size = strlen((char*)content.data);
addr = linphone_address_new("sip:collector@sip.linphone.org");
ms_message("packet content: %s", (char*)content.data);
addr = linphone_address_new("sip:collector@sip.linphone.org");
linphone_core_publish(call->core, addr, "vq-rtcpxr", expires, &content);
linphone_address_destroy(addr);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment