[Asterisk-code-review] res/res_pjsip_sdp_rtp: Fix MOH transitions (asterisk[16])

Sean Bright asteriskteam at digium.com
Mon Feb 24 09:17:58 CST 2020


Hello Torrey Searle,

I'd like you to do a code review. Please visit

    https://gerrit.asterisk.org/c/asterisk/+/13820

to review the following change.


Change subject: res/res_pjsip_sdp_rtp: Fix MOH transitions
......................................................................

res/res_pjsip_sdp_rtp: Fix MOH transitions

Update the state of remote_hold immediately on receipt of remote
SDP so that the information is available when building the SDP
answer

ASTERISK-28754 #close

Change-Id: I7026032a807e9c95081cb8f060400b05deb4836f
---
M include/asterisk/res_pjsip_session.h
M res/res_pjsip_sdp_rtp.c
2 files changed, 23 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/20/13820/1

diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index 43ac9c0..e8ada40 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -89,6 +89,8 @@
 	int timeout_sched_id;
 	/*! \brief Stream is on hold by remote side */
 	unsigned int remotely_held:1;
+	/*! \brief Stream is hold by remote side changed durign this handshake */
+	unsigned int remotely_held_changed:1;
 	/*! \brief Stream is on hold by local side */
 	unsigned int locally_held:1;
 	/*! \brief Does remote support rtcp_mux */
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index d652fc4..724ff36 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -1406,6 +1406,19 @@
 	/* If ICE support is enabled find all the needed attributes */
 	check_ice_support(session, session_media, stream);
 
+	if (ast_sockaddr_isnull(addrs) ||
+		ast_sockaddr_is_any(addrs) ||
+		pjmedia_sdp_media_find_attr2(stream, "sendonly", NULL) ||
+		pjmedia_sdp_media_find_attr2(stream, "inactive", NULL)) {
+		if (!session_media->remotely_held) {
+			session_media->remotely_held = 1;
+			session_media->remotely_held_changed = 1;
+		}
+	} else if (session_media->remotely_held) {
+		session_media->remotely_held = 0;
+		session_media->remotely_held_changed = 1;
+	}
+
 	if (set_caps(session, session_media, session_media_transport, stream, 1, asterisk_stream)) {
 		return 0;
 	}
@@ -1997,22 +2010,19 @@
 		return 1;
 	}
 
-	if (ast_sockaddr_isnull(addrs) ||
-		ast_sockaddr_is_any(addrs) ||
-		pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL) ||
-		pjmedia_sdp_media_find_attr2(remote_stream, "inactive", NULL)) {
-		if (!session_media->remotely_held) {
+	if (session_media->remotely_held_changed) {
+		if (session_media->remotely_held) {
 			/* The remote side has put us on hold */
 			ast_queue_hold(session->channel, session->endpoint->mohsuggest);
 			ast_rtp_instance_stop(session_media->rtp);
 			ast_queue_frame(session->channel, &ast_null_frame);
-			session_media->remotely_held = 1;
+			session_media->remotely_held_changed = 0;
+		} else {
+			/* The remote side has taken us off hold */
+			ast_queue_unhold(session->channel);
+			ast_queue_frame(session->channel, &ast_null_frame);
+			session_media->remotely_held_changed = 0;
 		}
-	} else if (session_media->remotely_held) {
-		/* The remote side has taken us off hold */
-		ast_queue_unhold(session->channel);
-		ast_queue_frame(session->channel, &ast_null_frame);
-		session_media->remotely_held = 0;
 	} else if ((pjmedia_sdp_neg_was_answer_remote(session->inv_session->neg) == PJ_FALSE)
 		&& (session->inv_session->state == PJSIP_INV_STATE_CONFIRMED)) {
 		ast_queue_control(session->channel, AST_CONTROL_UPDATE_RTP_PEER);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13820
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I7026032a807e9c95081cb8f060400b05deb4836f
Gerrit-Change-Number: 13820
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Torrey Searle <tsearle at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200224/1b3d81f4/attachment-0001.html>


More information about the asterisk-code-review mailing list