From 4c3baa0528a21d08e5e180d952dcd7c5702c2fcf Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 14 Mar 2014 15:14:31 +0100 Subject: [PATCH] Define RTCP XR structure in oRTP instead of sal. --- coreapi/bellesip_sal/sal_sdp.c | 74 +++++++++++++++++----------------- coreapi/linphonecall.c | 10 ++--- include/sal/sal.h | 28 ++----------- 3 files changed, 45 insertions(+), 67 deletions(-) diff --git a/coreapi/bellesip_sal/sal_sdp.c b/coreapi/bellesip_sal/sal_sdp.c index 080a43dcc..b6981b567 100644 --- a/coreapi/bellesip_sal/sal_sdp.c +++ b/coreapi/bellesip_sal/sal_sdp.c @@ -68,22 +68,22 @@ static void add_ice_remote_candidates(belle_sdp_media_description_t *md, const S if (buffer[0] != '\0') belle_sdp_media_description_add_attribute(md,belle_sdp_attribute_create("remote-candidates",buffer)); } -static belle_sdp_attribute_t * create_rtcp_xr_attribute(const SalRtcpXrDescription *desc) { +static belle_sdp_attribute_t * create_rtcp_xr_attribute(const OrtpRtcpXrConfiguration *config) { belle_sdp_rtcp_xr_attribute_t *attribute = belle_sdp_rtcp_xr_attribute_new(); - if (desc->rcvr_rtt_mode != SalRtcpXrRcvrRttNone) { - if (desc->rcvr_rtt_mode == SalRtcpXrRcvrRttAll) belle_sdp_rtcp_xr_attribute_set_rcvr_rtt_mode(attribute, "all"); - else if (desc->rcvr_rtt_mode == SalRtcpXrRcvrRttSender) belle_sdp_rtcp_xr_attribute_set_rcvr_rtt_mode(attribute, "sender"); - belle_sdp_rtcp_xr_attribute_set_rcvr_rtt_max_size(attribute, desc->rcvr_rtt_max_size); + if (config->rcvr_rtt_mode != OrtpRtcpXrRcvrRttNone) { + if (config->rcvr_rtt_mode == OrtpRtcpXrRcvrRttAll) belle_sdp_rtcp_xr_attribute_set_rcvr_rtt_mode(attribute, "all"); + else if (config->rcvr_rtt_mode == OrtpRtcpXrRcvrRttSender) belle_sdp_rtcp_xr_attribute_set_rcvr_rtt_mode(attribute, "sender"); + belle_sdp_rtcp_xr_attribute_set_rcvr_rtt_max_size(attribute, config->rcvr_rtt_max_size); } - belle_sdp_rtcp_xr_attribute_set_stat_summary(attribute, (desc->stat_summary_enabled == TRUE)); - if (desc->stat_summary_enabled == TRUE) { - if (desc->stat_summary_flags & SalRtcpXrStatSummaryLoss) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "loss"); - if (desc->stat_summary_flags & SalRtcpXrStatSummaryDup) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "dup"); - if (desc->stat_summary_flags & SalRtcpXrStatSummaryJitt) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "jitt"); - if (desc->stat_summary_flags & SalRtcpXrStatSummaryTTL) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "TTL"); - if (desc->stat_summary_flags & SalRtcpXrStatSummaryHL) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "HL"); + belle_sdp_rtcp_xr_attribute_set_stat_summary(attribute, (config->stat_summary_enabled == TRUE)); + if (config->stat_summary_enabled == TRUE) { + if (config->stat_summary_flags & OrtpRtcpXrStatSummaryLoss) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "loss"); + if (config->stat_summary_flags & OrtpRtcpXrStatSummaryDup) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "dup"); + if (config->stat_summary_flags & OrtpRtcpXrStatSummaryJitt) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "jitt"); + if (config->stat_summary_flags & OrtpRtcpXrStatSummaryTTL) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "TTL"); + if (config->stat_summary_flags & OrtpRtcpXrStatSummaryHL) belle_sdp_rtcp_xr_attribute_add_stat_summary_flag(attribute, "HL"); } - belle_sdp_rtcp_xr_attribute_set_voip_metrics(attribute, (desc->voip_metrics_enabled == TRUE)); + belle_sdp_rtcp_xr_attribute_set_voip_metrics(attribute, (config->voip_metrics_enabled == TRUE)); return BELLE_SDP_ATTRIBUTE(attribute); } @@ -400,55 +400,55 @@ static void sdp_parse_media_ice_parameters(belle_sdp_media_description_t *media_ } } -static void sal_init_rtcp_xr_description(SalRtcpXrDescription *desc) { - desc->enabled = FALSE; - desc->rcvr_rtt_mode = SalRtcpXrRcvrRttNone; - desc->rcvr_rtt_max_size = -1; - desc->stat_summary_flags = 0; - desc->voip_metrics_enabled = FALSE; +static void sal_init_rtcp_xr_description(OrtpRtcpXrConfiguration *config) { + config->enabled = FALSE; + config->rcvr_rtt_mode = OrtpRtcpXrRcvrRttNone; + config->rcvr_rtt_max_size = -1; + config->stat_summary_flags = 0; + config->voip_metrics_enabled = FALSE; } -static void sdp_parse_rtcp_xr_parameters(const belle_sdp_attribute_t *attribute, SalRtcpXrDescription *desc) { - sal_init_rtcp_xr_description(desc); +static void sdp_parse_rtcp_xr_parameters(const belle_sdp_attribute_t *attribute, OrtpRtcpXrConfiguration *config) { + sal_init_rtcp_xr_description(config); if (attribute != NULL) { const belle_sdp_rtcp_xr_attribute_t *xr_attr = BELLE_SDP_RTCP_XR_ATTRIBUTE(attribute); const char *rcvr_rtt_mode = belle_sdp_rtcp_xr_attribute_get_rcvr_rtt_mode(xr_attr); if (rcvr_rtt_mode != NULL) { if (strcasecmp(rcvr_rtt_mode, "all") == 0) { - desc->rcvr_rtt_mode = SalRtcpXrRcvrRttAll; + config->rcvr_rtt_mode = OrtpRtcpXrRcvrRttAll; } else if (strcasecmp(rcvr_rtt_mode, "sender") == 0) { - desc->rcvr_rtt_mode = SalRtcpXrRcvrRttSender; + config->rcvr_rtt_mode = OrtpRtcpXrRcvrRttSender; } - desc->rcvr_rtt_max_size = belle_sdp_rtcp_xr_attribute_get_rcvr_rtt_max_size(xr_attr); + config->rcvr_rtt_max_size = belle_sdp_rtcp_xr_attribute_get_rcvr_rtt_max_size(xr_attr); } - desc->stat_summary_enabled = (belle_sdp_rtcp_xr_attribute_has_stat_summary(xr_attr) != 0); - if (desc->stat_summary_enabled) { + config->stat_summary_enabled = (belle_sdp_rtcp_xr_attribute_has_stat_summary(xr_attr) != 0); + if (config->stat_summary_enabled) { belle_sip_list_t *stat_summary_flag_it; for (stat_summary_flag_it = belle_sdp_rtcp_xr_attribute_get_stat_summary_flags(xr_attr); stat_summary_flag_it != NULL; stat_summary_flag_it = stat_summary_flag_it->next ) { const char *flag = (const char *)stat_summary_flag_it->data; if (flag != NULL) { - if (strcasecmp(flag, "loss") == 0) desc->stat_summary_flags |= SalRtcpXrStatSummaryLoss; - else if (strcasecmp(flag, "dup") == 0) desc->stat_summary_flags |= SalRtcpXrStatSummaryDup; - else if (strcasecmp(flag, "jitt") == 0) desc->stat_summary_flags |= SalRtcpXrStatSummaryJitt; - else if (strcasecmp(flag, "TTL") == 0) desc->stat_summary_flags |= SalRtcpXrStatSummaryTTL; - else if (strcasecmp(flag, "HL") == 0) desc->stat_summary_flags |= SalRtcpXrStatSummaryHL; + if (strcasecmp(flag, "loss") == 0) config->stat_summary_flags |= OrtpRtcpXrStatSummaryLoss; + else if (strcasecmp(flag, "dup") == 0) config->stat_summary_flags |= OrtpRtcpXrStatSummaryDup; + else if (strcasecmp(flag, "jitt") == 0) config->stat_summary_flags |= OrtpRtcpXrStatSummaryJitt; + else if (strcasecmp(flag, "TTL") == 0) config->stat_summary_flags |= OrtpRtcpXrStatSummaryTTL; + else if (strcasecmp(flag, "HL") == 0) config->stat_summary_flags |= OrtpRtcpXrStatSummaryHL; } } } - desc->voip_metrics_enabled = (belle_sdp_rtcp_xr_attribute_has_voip_metrics(xr_attr) != 0); - desc->enabled = TRUE; + config->voip_metrics_enabled = (belle_sdp_rtcp_xr_attribute_has_voip_metrics(xr_attr) != 0); + config->enabled = TRUE; } } -static void sdp_parse_session_rtcp_xr_parameters(belle_sdp_session_description_t *session_desc, SalRtcpXrDescription *desc) { +static void sdp_parse_session_rtcp_xr_parameters(belle_sdp_session_description_t *session_desc, OrtpRtcpXrConfiguration *config) { const belle_sdp_attribute_t *attribute = belle_sdp_session_description_get_attribute(session_desc, "rtcp-xr"); - sdp_parse_rtcp_xr_parameters(attribute, desc); + sdp_parse_rtcp_xr_parameters(attribute, config); } -static void sdp_parse_media_rtcp_xr_parameters(belle_sdp_media_description_t *media_desc, SalRtcpXrDescription *desc) { +static void sdp_parse_media_rtcp_xr_parameters(belle_sdp_media_description_t *media_desc, OrtpRtcpXrConfiguration *config) { const belle_sdp_attribute_t *attribute = belle_sdp_media_description_get_attribute(media_desc, "rtcp-xr"); - sdp_parse_rtcp_xr_parameters(attribute, desc); + sdp_parse_rtcp_xr_parameters(attribute, config); } static SalStreamDescription * sdp_to_stream_description(SalMediaDescription *md, belle_sdp_media_description_t *media_desc) { diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index eee0e6305..1c88b8531 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -264,15 +264,15 @@ static void setup_rtcp_xr(LinphoneCall *call, SalMediaDescription *md) { md->rtcp_xr.enabled = lp_config_get_int(lc->config, "rtp", "rtcp_xr_enabled", 0); if (md->rtcp_xr.enabled == TRUE) { const char *rcvr_rtt_mode = lp_config_get_string(lc->config, "rtp", "rtcp_xr_rcvr_rtt_mode", "none"); - if (strcasecmp(rcvr_rtt_mode, "all") == 0) md->rtcp_xr.rcvr_rtt_mode = SalRtcpXrRcvrRttAll; - else if (strcasecmp(rcvr_rtt_mode, "sender") == 0) md->rtcp_xr.rcvr_rtt_mode = SalRtcpXrRcvrRttSender; - else md->rtcp_xr.rcvr_rtt_mode = SalRtcpXrRcvrRttNone; - if (md->rtcp_xr.rcvr_rtt_mode != SalRtcpXrRcvrRttNone) { + if (strcasecmp(rcvr_rtt_mode, "all") == 0) md->rtcp_xr.rcvr_rtt_mode = OrtpRtcpXrRcvrRttAll; + else if (strcasecmp(rcvr_rtt_mode, "sender") == 0) md->rtcp_xr.rcvr_rtt_mode = OrtpRtcpXrRcvrRttSender; + else md->rtcp_xr.rcvr_rtt_mode = OrtpRtcpXrRcvrRttNone; + if (md->rtcp_xr.rcvr_rtt_mode != OrtpRtcpXrRcvrRttNone) { md->rtcp_xr.rcvr_rtt_max_size = lp_config_get_int(lc->config, "rtp", "rtcp_xr_rcvr_rtt_max_size", 0); } md->rtcp_xr.stat_summary_enabled = lp_config_get_int(lc->config, "rtp", "rtcp_xr_stat_summary_enabled", 0); if (md->rtcp_xr.stat_summary_enabled == TRUE) { - md->rtcp_xr.stat_summary_flags = SalRtcpXrStatSummaryLoss | SalRtcpXrStatSummaryDup | SalRtcpXrStatSummaryJitt | SalRtcpXrStatSummaryTTL; + md->rtcp_xr.stat_summary_flags = OrtpRtcpXrStatSummaryLoss | OrtpRtcpXrStatSummaryDup | OrtpRtcpXrStatSummaryJitt | OrtpRtcpXrStatSummaryTTL; } md->rtcp_xr.voip_metrics_enabled = lp_config_get_int(lc->config, "rtp", "rtcp_xr_voip_metrics_enabled", 0); } diff --git a/include/sal/sal.h b/include/sal/sal.h index bb4a37d30..650b5085a 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #include "mediastreamer2/mscommon.h" +#include "ortp/rtpsession.h" #include "ortp/ortp_srtp.h" #include "belle-sip/belle-sip.h" @@ -135,20 +136,6 @@ typedef enum{ }SalStreamDir; const char* sal_stream_dir_to_string(SalStreamDir type); -typedef enum { - SalRtcpXrRcvrRttNone, - SalRtcpXrRcvrRttAll, - SalRtcpXrRcvrRttSender -} SalRtcpXrRcvrRttMode; - -typedef enum { - SalRtcpXrStatSummaryLoss = (1 << 0), - SalRtcpXrStatSummaryDup = (1 << 1), - SalRtcpXrStatSummaryJitt = (1 << 2), - SalRtcpXrStatSummaryTTL = (1 << 3), - SalRtcpXrStatSummaryHL = (1 << 4) -} SalRtcpXrStatSummaryFlag; - #define SAL_ENDPOINT_CANDIDATE_MAX 2 @@ -190,15 +177,6 @@ typedef struct SalSrtpCryptoAlgo { #define SAL_CRYPTO_ALGO_MAX 4 -typedef struct SalRtcpXrDescription { - bool_t enabled; - bool_t stat_summary_enabled; - bool_t voip_metrics_enabled; - SalRtcpXrRcvrRttMode rcvr_rtt_mode; - int rcvr_rtt_max_size; - SalRtcpXrStatSummaryFlag stat_summary_flags; -} SalRtcpXrDescription; - typedef struct SalStreamDescription{ char name[16]; /*unique name of stream, in order to ease offer/answer model algorithm*/ SalMediaProto proto; @@ -216,7 +194,7 @@ typedef struct SalStreamDescription{ SalSrtpCryptoAlgo crypto[SAL_CRYPTO_ALGO_MAX]; unsigned int crypto_local_tag; int max_rate; - SalRtcpXrDescription rtcp_xr; + OrtpRtcpXrConfiguration rtcp_xr; SalIceCandidate ice_candidates[SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES]; SalIceRemoteCandidate ice_remote_candidates[SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES]; char ice_ufrag[SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN]; @@ -243,7 +221,7 @@ typedef struct SalMediaDescription{ unsigned int session_id; SalStreamDir dir; SalStreamDescription streams[SAL_MEDIA_DESCRIPTION_MAX_STREAMS]; - SalRtcpXrDescription rtcp_xr; + OrtpRtcpXrConfiguration rtcp_xr; char ice_ufrag[SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN]; char ice_pwd[SAL_MEDIA_DESCRIPTION_MAX_ICE_PWD_LEN]; bool_t ice_lite;