From a7fcb9c0c07aa96d917924532309a17e9f9d0de2 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Mon, 28 Feb 2022 19:59:15 +0100 Subject: [PATCH] sip: origin: Try fetching RTCP port from SDP attributes And fallback to the legacy behaviour of RTCP=RTP+1 --- plugins/sip/calls-sip-origin.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c index 81057f5..c79d86a 100644 --- a/plugins/sip/calls-sip-origin.c +++ b/plugins/sip/calls-sip-origin.c @@ -543,15 +543,15 @@ sip_i_state (int status, if (status == 503) { CALLS_EMIT_MESSAGE (origin, "DNS error", GTK_MESSAGE_ERROR); } - /* XXX making some assumptions about the received SDP message here... - * namely: rtcp port = rtp port + 1 - */ + if (r_sdp) { g_autoptr (GList) codecs = calls_sip_media_manager_get_codecs_from_sdp (origin->media_manager, r_sdp->sdp_media); const char *session_ip = NULL; const char *media_ip = NULL; + int rtp_port; + int rtcp_port = 0; g_debug ("Remote SDP was set to:\n%s", r_sdp_str); @@ -575,10 +575,24 @@ sip_i_state (int status, } calls_sip_call_set_codecs (call, codecs); + + /* TODO This needs to adapt for the ICE case */ + rtp_port = r_sdp->sdp_media->m_port; + for (sdp_attribute_t *attr = r_sdp->sdp_media->m_attributes; attr; attr = attr->a_next) { + if (g_strcmp0 (attr->a_name, "rtcp") == 0) { + rtcp_port = atoi (attr->a_value); + break; + } + } + + /* Legacy fallback */ + if (rtcp_port == 0) + rtcp_port = rtp_port + 1; + calls_sip_call_setup_remote_media_connection (call, media_ip ? : session_ip, - r_sdp->sdp_media->m_port, - r_sdp->sdp_media->m_port + 1); + rtp_port, + rtcp_port); } switch (call_state) {