[Asterisk-code-review] chan sip : Fix improper RTP framing on outgoing calls (asterisk[15])

Jean Aunis - Prescom asteriskteam at digium.com
Wed Feb 14 07:40:20 CST 2018


Jean Aunis - Prescom has uploaded this change for review. ( https://gerrit.asterisk.org/8208


Change subject: chan_sip : Fix improper RTP framing on outgoing calls
......................................................................

chan_sip : Fix improper RTP framing on outgoing calls

The "ptime" SDP parameter received in a SIP response was not honoured.
Moreover, in the abscence of this "ptime" parameter, locally configured framing
was lost during response processing.
This patch systematically stores the framing information in the ast_rtp_codecs
structure, taking it from the response or from the configuration as appropriate.

ASTERISK-27674

Change-Id: I828a6a98d27a45a8afd07236a2bd0aa3cbd3fb2c
---
M channels/chan_sip.c
1 file changed, 9 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/08/8208/1

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 6bd8205..832f66b 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10917,22 +10917,26 @@
 	if (portno != -1 || vportno != -1 || tportno != -1) {
 		/* We are now ready to change the sip session and RTP structures with the offered codecs, since
 		   they are acceptable */
+		unsigned int framing;
 		ast_format_cap_remove_by_type(p->jointcaps, AST_MEDIA_TYPE_UNKNOWN);
 		ast_format_cap_append_from_cap(p->jointcaps, newjointcapability, AST_MEDIA_TYPE_UNKNOWN); /* Our joint codec profile for this call */
 		ast_format_cap_remove_by_type(p->peercaps, AST_MEDIA_TYPE_UNKNOWN);
 		ast_format_cap_append_from_cap(p->peercaps, newpeercapability, AST_MEDIA_TYPE_UNKNOWN); /* The other side's capability in latest offer */
 		p->jointnoncodeccapability = newnoncodeccapability;     /* DTMF capabilities */
 
+		tmp_fmt = ast_format_cap_get_format(p->jointcaps, 0);
+		framing = ast_format_cap_get_format_framing(p->jointcaps, tmp_fmt);
 		/* respond with single most preferred joint codec, limiting the other side's choice */
 		if (ast_test_flag(&p->flags[1], SIP_PAGE2_PREFERRED_CODEC)) {
-			unsigned int framing;
-
-			tmp_fmt = ast_format_cap_get_format(p->jointcaps, 0);
-			framing = ast_format_cap_get_format_framing(p->jointcaps, tmp_fmt);
 			ast_format_cap_remove_by_type(p->jointcaps, AST_MEDIA_TYPE_UNKNOWN);
 			ast_format_cap_append(p->jointcaps, tmp_fmt, framing);
+		}
+		if(!ast_rtp_codecs_get_framing(&newaudiortp)) {
+			/* Peer did not force us to use a specific framing, so use our own */
+			ast_rtp_codecs_set_framing(&newaudiortp, framing);
 			ao2_ref(tmp_fmt, -1);
 		}
+		ao2_ref(tmp_fmt, -1);
 	}
 
 	/* Setup audio address and port */
@@ -11127,7 +11131,6 @@
 			ao2_ref(caps, -1);
 			ao2_ref(tmp_fmt, -1);
 		}
-
 		ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
 		ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
 	}
@@ -11441,6 +11444,7 @@
 		if (framing && p->autoframing) {
 			ast_debug(1, "Setting framing to %ld\n", framing);
 			ast_format_cap_set_framing(p->caps, framing);
+			ast_rtp_codecs_set_framing(newaudiortp, framing);
 		}
 		found = TRUE;
 	} else if (sscanf(a, "rtpmap: %30u %127[^/]/%30u", &codec, mimeSubtype, &sample_rate) == 3) {

-- 
To view, visit https://gerrit.asterisk.org/8208
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I828a6a98d27a45a8afd07236a2bd0aa3cbd3fb2c
Gerrit-Change-Number: 8208
Gerrit-PatchSet: 1
Gerrit-Owner: Jean Aunis - Prescom <jean.aunis at prescom.fr>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180214/8da5ebd9/attachment.html>


More information about the asterisk-code-review mailing list