]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_session/BUNDLE: Handle no audio codecs on endpoint
authorGeorge Joseph <gjoseph@digium.com>
Thu, 21 Sep 2017 14:47:11 +0000 (08:47 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Fri, 22 Sep 2017 12:02:47 +0000 (07:02 -0500)
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

res/res_pjsip_session.c

index 163c2b8681e0dd5b2f2bb08b724d86f5cc028260..d50937fd44fadcaa34e26b0c85ed372a5e4582c9 100644 (file)
@@ -549,6 +549,16 @@ static int set_mid_and_bundle_group(struct ast_sip_session *session,
        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,9 +621,7 @@ static int handle_incoming_sdp(struct ast_sip_session *session, const pjmedia_sd
                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;
                }
 
@@ -628,6 +636,11 @@ static int handle_incoming_sdp(struct ast_sip_session *session, const pjmedia_sd
                        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),
@@ -655,8 +668,12 @@ static int handle_incoming_sdp(struct ast_sip_session *session, const pjmedia_sd
                        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);