[Asterisk-code-review] res pjsip session/BUNDLE: Handle no audio codecs on endpoint (asterisk[15.0])

George Joseph asteriskteam at digium.com
Thu Sep 21 09:55:45 CDT 2017


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/6556


Change subject: res_pjsip_session/BUNDLE:  Handle no audio codecs on endpoint
......................................................................

res_pjsip_session/BUNDLE:  Handle no audio codecs on endpoint

When an INVITE came in with both audio and video streams but there
were no audio codecs defined for the endpoint, we weren't declining
the audio stream.  Since it's usually the first/transport stream,
when the video stream was processed and tried to use the transport,
it was empty and caused a crash.  We now decline the the stream if
there are no matching codecs so when the video stream is processed,
it's now the first/transport stream and processes normally.

Change-Id: Ic854eda54c95031e66b076ecfae3041d34daa692
---
M res/res_pjsip_session.c
1 file changed, 26 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/56/6556/1

diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index d34b1bb..83f0e67 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -549,6 +549,16 @@
 	return 0;
 }
 
+static void remove_stream_from_bundle(struct ast_sip_session_media *session_media,
+	struct ast_stream *stream)
+{
+	ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);
+	ast_free(session_media->mid);
+	session_media->mid = NULL;
+	session_media->bundle_group = -1;
+	session_media->bundled = 0;
+}
+
 static int handle_incoming_sdp(struct ast_sip_session *session, const pjmedia_sdp_session *sdp)
 {
 	int i;
@@ -611,13 +621,9 @@
 		if (!remote_stream->desc.port || is_stream_limitation_reached(type, session->endpoint, type_streams)) {
 			ast_debug(1, "Declining incoming SDP media stream '%s' at position '%d'\n",
 				ast_codec_media_type2str(type), i);
-			ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);
-			session_media->bundle_group = -1;
-			session_media->bundled = 0;
+			remove_stream_from_bundle(session_media, stream);
 			continue;
 		}
-
-		set_mid_and_bundle_group(session, session_media, sdp, remote_stream);
 
 		if (session_media->handler) {
 			handler = session_media->handler;
@@ -628,11 +634,17 @@
 			if (res < 0) {
 				/* Catastrophic failure. Abort! */
 				return -1;
+			} else if (res == 0) {
+				ast_debug(1, "Declining incoming SDP media stream '%s' at position '%d'\n",
+					ast_codec_media_type2str(type), i);
+				remove_stream_from_bundle(session_media, stream);
+				continue;
 			} else if (res > 0) {
 				ast_debug(1, "Media stream '%s' handled by %s\n",
 					ast_codec_media_type2str(session_media->type),
 					session_media->handler->id);
 				/* Handled by this handler. Move to the next stream */
+				set_mid_and_bundle_group(session, session_media, sdp, remote_stream);
 				handled = 1;
 				++type_streams[type];
 				continue;
@@ -655,12 +667,17 @@
 			if (res < 0) {
 				/* Catastrophic failure. Abort! */
 				return -1;
-			}
-			if (res > 0) {
+			} else if (res == 0) {
+				ast_debug(1, "Declining incoming SDP media stream '%s' at position '%d'\n",
+					ast_codec_media_type2str(type), i);
+				remove_stream_from_bundle(session_media, stream);
+				continue;
+			} else if (res > 0) {
 				ast_debug(1, "Media stream '%s' handled by %s\n",
 					ast_codec_media_type2str(session_media->type),
 					handler->id);
 				/* Handled by this handler. Move to the next stream */
+				set_mid_and_bundle_group(session, session_media, sdp, remote_stream);
 				session_media_set_handler(session_media, handler);
 				handled = 1;
 				++type_streams[type];
@@ -1456,7 +1473,8 @@
 				}
 
 				/* No need to do anything with stream if it's media state is removed */
-				if (ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {
+				if (ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED
+					|| !ast_stream_get_formats(stream)) {
 					continue;
 				}
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 15.0
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic854eda54c95031e66b076ecfae3041d34daa692
Gerrit-Change-Number: 6556
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170921/46461371/attachment.html>


More information about the asterisk-code-review mailing list