From 0cd71d6548000a88253b85097d19529ff914d604 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 30 May 2014 16:43:15 +0200 Subject: [PATCH] Fix issue with rtcp-fb attributes in SDP of response. --- coreapi/bellesip_sal/sal_sdp.c | 41 ++++++++++++++++++++++++++++------ coreapi/linphonecall.c | 27 +++++++++++++++++++++- include/sal/sal.h | 1 - 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/coreapi/bellesip_sal/sal_sdp.c b/coreapi/bellesip_sal/sal_sdp.c index 628fc6974..158460377 100644 --- a/coreapi/bellesip_sal/sal_sdp.c +++ b/coreapi/bellesip_sal/sal_sdp.c @@ -68,6 +68,31 @@ 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 bool_t is_rtcp_fb_trr_int_the_same_for_all_payloads(const SalStreamDescription *stream, uint8_t *trr_int) { + MSList *pt_it; + bool_t first = TRUE; + for (pt_it = stream->payloads; pt_it != NULL; pt_it = pt_it->next) { + PayloadType *pt = (PayloadType *)pt_it->data; + if (payload_type_get_flags(pt) & PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED) { + if (first == TRUE) { + *trr_int = payload_type_get_avpf_params(pt).trr_interval; + first = FALSE; + } else if (payload_type_get_avpf_params(pt).trr_interval != *trr_int) { + return FALSE; + } + } + } + return TRUE; +} + +static void add_rtcp_fb_trr_int_attribute(belle_sdp_media_description_t *media_desc, int8_t id, uint8_t trr_int) { + belle_sdp_rtcp_fb_attribute_t *attribute = belle_sdp_rtcp_fb_attribute_new(); + belle_sdp_rtcp_fb_attribute_set_id(attribute, id); + belle_sdp_rtcp_fb_attribute_set_type(attribute, BELLE_SDP_RTCP_FB_TRR_INT); + belle_sdp_rtcp_fb_attribute_set_trr_int(attribute, trr_int); + belle_sdp_media_description_add_attribute(media_desc, BELLE_SDP_ATTRIBUTE(attribute)); +} + static void add_rtcp_fb_nack_attribute(belle_sdp_media_description_t *media_desc, int8_t id, belle_sdp_rtcp_fb_val_param_t param) { belle_sdp_rtcp_fb_attribute_t *attribute = belle_sdp_rtcp_fb_attribute_new(); belle_sdp_rtcp_fb_attribute_set_id(attribute, id); @@ -80,12 +105,13 @@ static void add_rtcp_fb_attributes(belle_sdp_media_description_t *media_desc, co MSList *pt_it; PayloadType *pt; PayloadTypeAvpfParams avpf_params; - belle_sdp_rtcp_fb_attribute_t *attribute = belle_sdp_rtcp_fb_attribute_new(); + bool_t general_trr_int; + uint8_t trr_int = 0; - belle_sdp_rtcp_fb_attribute_set_id(attribute, -1); - belle_sdp_rtcp_fb_attribute_set_type(attribute, BELLE_SDP_RTCP_FB_TRR_INT); - belle_sdp_rtcp_fb_attribute_set_trr_int(attribute, md->avpf_rr_interval); - belle_sdp_media_description_add_attribute(media_desc, BELLE_SDP_ATTRIBUTE(attribute)); + general_trr_int = is_rtcp_fb_trr_int_the_same_for_all_payloads(stream, &trr_int); + if (general_trr_int == TRUE) { + add_rtcp_fb_trr_int_attribute(media_desc, -1, trr_int); + } for (pt_it = stream->payloads; pt_it != NULL; pt_it = pt_it->next) { pt = (PayloadType *)pt_it->data; @@ -93,7 +119,6 @@ static void add_rtcp_fb_attributes(belle_sdp_media_description_t *media_desc, co /* AVPF/SAVPF profile is used so enable AVPF for all paylad types. */ payload_type_set_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); avpf_params = payload_type_get_avpf_params(pt); - avpf_params.trr_interval = md->avpf_rr_interval; /* Add rtcp-fb attributes according to the AVPF features of the payload types. */ if (avpf_params.features & PAYLOAD_TYPE_AVPF_PLI) { @@ -457,7 +482,9 @@ static void enable_avpf_for_stream(SalStreamDescription *stream) { pt = (PayloadType *)pt_it->data; avpf_params = payload_type_get_avpf_params(pt); payload_type_set_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); - avpf_params.features |= PAYLOAD_TYPE_AVPF_FIR; + if (stream->type == SalVideo) { + avpf_params.features |= PAYLOAD_TYPE_AVPF_FIR; + } avpf_params.trr_interval = 0; payload_type_set_avpf_params(pt, avpf_params); } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 63ea19a16..25be65fe4 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -281,6 +281,31 @@ static void setup_encryption_keys(LinphoneCall *call, SalMediaDescription *md){ } } +static void setup_rtcp_fb(LinphoneCall *call, SalMediaDescription *md) { + MSList *pt_it; + PayloadType *pt; + PayloadTypeAvpfParams avpf_params; + int i; + + for (i = 0; i < md->n_active_streams; i++) { + for (pt_it = md->streams[i].payloads; pt_it != NULL; pt_it = pt_it->next) { + pt = (PayloadType *)pt_it->data; + if (call->params.avpf_enabled == TRUE) { + payload_type_set_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); + avpf_params = payload_type_get_avpf_params(pt); + avpf_params.trr_interval = call->params.avpf_rr_interval; + if (md->streams[i].type == SalVideo) { + avpf_params.features |= PAYLOAD_TYPE_AVPF_FIR; + } + } else { + payload_type_unset_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); + memset(&avpf_params, 0, sizeof(avpf_params)); + } + payload_type_set_avpf_params(pt, avpf_params); + } + } +} + static void setup_rtcp_xr(LinphoneCall *call, SalMediaDescription *md) { LinphoneCore *lc = call->core; int i; @@ -339,7 +364,6 @@ void linphone_call_make_local_media_description(LinphoneCore *lc, LinphoneCall * md->session_id=(old_md ? old_md->session_id : (rand() & 0xfff)); md->session_ver=(old_md ? (old_md->session_ver+1) : (rand() & 0xfff)); md->n_total_streams=(call->biggestdesc ? call->biggestdesc->n_total_streams : 1); - md->avpf_rr_interval = call->params.avpf_rr_interval; strncpy(md->addr,local_ip,sizeof(md->addr)); strncpy(md->username,linphone_address_get_username(addr),sizeof(md->username)); @@ -392,6 +416,7 @@ void linphone_call_make_local_media_description(LinphoneCore *lc, LinphoneCall * } setup_encryption_keys(call,md); + setup_rtcp_fb(call, md); setup_rtcp_xr(call, md); update_media_description_from_stun(md,&call->ac,&call->vc); diff --git a/include/sal/sal.h b/include/sal/sal.h index b2ce51e22..d5712c09d 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -221,7 +221,6 @@ typedef struct SalMediaDescription{ unsigned int session_ver; unsigned int session_id; SalStreamDir dir; - uint8_t avpf_rr_interval; SalStreamDescription streams[SAL_MEDIA_DESCRIPTION_MAX_STREAMS]; OrtpRtcpXrConfiguration rtcp_xr; char ice_ufrag[SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN];