[Asterisk-code-review] res_pjsip_session: Don't restrict non-audio default streams to sendrecv. (asterisk[16])

Joshua Colp asteriskteam at digium.com
Thu Mar 19 11:06:56 CDT 2020


Joshua Colp has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13954 )


Change subject: res_pjsip_session: Don't restrict non-audio default streams to sendrecv.
......................................................................

res_pjsip_session: Don't restrict non-audio default streams to sendrecv.

The state of the default audio stream is used for hold/unhold so we
restrict it to sendrecv as the core does not handle when it changes as
a result of hold/unhold.

This restriction does not apply to other media types though so we now
only restrict it to audio. This allows the other default streams to
store their state at all values, and not just sendrecv and removed.

ASTERISK-28783

Change-Id: I139740f38cea7f7d92a876ec2631ef50681f6625
---
M res/res_pjsip_session.c
1 file changed, 12 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/54/13954/1

diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index b9448b9..ebd0516 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -760,8 +760,8 @@
 				ast_stream_free(stream);
 				return -1;
 			}
-			/* For backwards compatibility with the core default streams are always sendrecv */
-			if (!ast_sip_session_is_pending_stream_default(session, stream)) {
+			/* For backwards compatibility with the core the default audio stream is always sendrecv */
+			if (!ast_sip_session_is_pending_stream_default(session, stream) || strcmp(media, "audio")) {
 				if (pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL)) {
 					/* Stream state reflects our state of a stream, so in the case of
 					 * sendonly and recvonly we store the opposite since that is what ours
@@ -871,12 +871,16 @@
 	RAII_VAR(struct sdp_handler_list *, handler_list, NULL, ao2_cleanup);
 	int res;
 
+	/* We need a null-terminated version of the media string */
+	ast_copy_pj_str(media, &local->media[index]->desc.media, sizeof(media));
+
 	/* For backwards compatibility we only reflect the stream state correctly on
-	 * the non-default streams. This is because the stream state is also used for
-	 * signaling that someone has placed us on hold. This situation is not handled
-	 * currently and can result in the remote side being sort of placed on hold too.
+	 * the non-default streams and any non-audio streams. This is because the stream
+	 * state of the default audio stream is also used for signaling that someone has
+	 * placed us on hold. This situation is not handled currently and can result in
+	 * the remote side being sorted of placed on hold too.
 	 */
-	if (!ast_sip_session_is_pending_stream_default(session, asterisk_stream)) {
+	if (!ast_sip_session_is_pending_stream_default(session, asterisk_stream) || strcmp(media, "audio")) {
 		/* Determine the state of the stream based on our local SDP */
 		if (pjmedia_sdp_media_find_attr2(local_stream, "sendonly", NULL)) {
 			ast_stream_set_state(asterisk_stream, AST_STREAM_STATE_SENDONLY);
@@ -891,9 +895,6 @@
 		ast_stream_set_state(asterisk_stream, AST_STREAM_STATE_SENDRECV);
 	}
 
-	/* We need a null-terminated version of the media string */
-	ast_copy_pj_str(media, &local->media[index]->desc.media, sizeof(media));
-
 	set_mid_and_bundle_group(session, session_media, remote, remote->media[index]);
 	set_remote_mslabel_and_stream_group(session, session_media, remote, remote->media[index], asterisk_stream);
 
@@ -1965,8 +1966,8 @@
 			return -1;
 		}
 
-		/* For backwards compatibility with the core default streams are always sendrecv */
-		if (!ast_sip_session_is_pending_stream_default(session, stream)) {
+		/* For backwards compatibility with the core the default audio stream is always sendrecv */
+		if (!ast_sip_session_is_pending_stream_default(session, stream) || strcmp(media, "audio")) {
 			if (pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL)) {
 				/* Stream state reflects our state of a stream, so in the case of
 				 * sendonly and recvonly we store the opposite since that is what ours

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I139740f38cea7f7d92a876ec2631ef50681f6625
Gerrit-Change-Number: 13954
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200319/368d6931/attachment-0001.html>


More information about the asterisk-code-review mailing list