[Asterisk-code-review] res/res rtp asterisk: ensure marker bit is correctly set on ... (asterisk[15])

Torrey Searle asteriskteam at digium.com
Mon May 14 07:09:13 CDT 2018


Torrey Searle has uploaded this change for review. ( https://gerrit.asterisk.org/8988


Change subject: res/res_rtp_asterisk: ensure marker bit is correctly set on ssrc change
......................................................................

res/res_rtp_asterisk: ensure marker bit is correctly set on ssrc change

Certain race conditions between changing bridge types and DTMF can
cause the current FLAG_NEED_MARKER_BIT to send the marker bit before
the actual first packet of native bridging.

This logic keeps track of the ssrc the bridge is currently sending
and will correctly ensure the marker bit is set if SSRC as changed
from the previous sent packet.

ASTERISK-27845

Change-Id: I01858bd0235f1e5e629e20de71b422b16f55759b
---
M res/res_rtp_asterisk.c
1 file changed, 12 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/88/8988/1

diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 5579914..e5f6b0a 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -5877,6 +5877,7 @@
 	int res = 0, payload = 0, bridged_payload = 0, mark;
 	RAII_VAR(struct ast_rtp_payload_type *, payload_type, NULL, ao2_cleanup);
 	int reconstruct = ntohl(rtpheader[0]);
+	unsigned int ssrc = ntohl(rtpheader[2]);
 	struct ast_sockaddr remote_address = { {0,} };
 	int ice;
 	unsigned int timestamp = ntohl(rtpheader[1]);
@@ -5984,6 +5985,17 @@
 		ast_clear_flag(bridged, FLAG_NEED_MARKER_BIT);
 	}
 
+	/* While in the middle of a DTMF digit it is possible for the marker bit to get set on the
+	 * DTMF packet, which carries the old SSRC. To combat this store the actual bridged SSRC and
+	 * use it for packets even after the bridge is over. This way we can determine if the SSRC
+	 * is different than we expect and set the marker bit.
+	 */
+	if (!mark && ssrc != bridged->ssrc) {
+		bridged->ssrc = ssrc;
+		mark = 1;
+		ast_debug(1, "Setting Marker bit for ssrc change\n");
+	}
+
 	/* Reconstruct part of the packet */
 	reconstruct &= 0xFF80FFFF;
 	reconstruct |= (bridged_payload << 16);

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I01858bd0235f1e5e629e20de71b422b16f55759b
Gerrit-Change-Number: 8988
Gerrit-PatchSet: 1
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180514/da0949c6/attachment.html>


More information about the asterisk-code-review mailing list