]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_session: Set stream state on created streams for incoming SDP.
authorJoshua C. Colp <jcolp@sangoma.com>
Mon, 16 Dec 2019 11:23:07 +0000 (07:23 -0400)
committerJoshua C. Colp <jcolp@digium.com>
Mon, 16 Dec 2019 11:24:12 +0000 (05:24 -0600)
A previous review, 13174, made a change whereby on an incoming offer SDP
the pending topology was initialized to the configured. This caused a problem
for bundle with WebRTC where bundle could reference a stream that did not
actually exist if the configuration had both audio and video but the
offer SDP only contained audio.

This change undoes that review and instead fixes the original problem it
sought to solve by setting the state of created streams based on the
contents of the offer SDP. This way the stream state is not inactive
until negotiation later completes.

ASTERISK-28659

Change-Id: Ic5ae5a86437d3e686ac5afd91d133cc916198355

res/res_pjsip_session.c

index bc01548b61b2beff0d1d43c81a7acf8a8372ace2..76740c145546140e2d7e0a8a45c95e2a1b3d53d1 100644 (file)
@@ -712,7 +712,7 @@ static int handle_incoming_sdp(struct ast_sip_session *session, const pjmedia_sd
 
        /* It is possible for SDP deferral to have already created a pending topology */
        if (!session->pending_media_state->topology) {
-               session->pending_media_state->topology = ast_stream_topology_clone(session->endpoint->media.topology);
+               session->pending_media_state->topology = ast_stream_topology_alloc();
                if (!session->pending_media_state->topology) {
                        return -1;
                }
@@ -753,6 +753,24 @@ static int handle_incoming_sdp(struct ast_sip_session *session, const pjmedia_sd
                                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)) {
+                               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
+                                        * is.
+                                        */
+                                       ast_stream_set_state(stream, AST_STREAM_STATE_RECVONLY);
+                               } else if (pjmedia_sdp_media_find_attr2(remote_stream, "recvonly", NULL)) {
+                                       ast_stream_set_state(stream, AST_STREAM_STATE_SENDONLY);
+                               } else if (pjmedia_sdp_media_find_attr2(remote_stream, "inactive", NULL)) {
+                                       ast_stream_set_state(stream, AST_STREAM_STATE_INACTIVE);
+                               } else {
+                                       ast_stream_set_state(stream, AST_STREAM_STATE_SENDRECV);
+                               }
+                       } else {
+                               ast_stream_set_state(stream, AST_STREAM_STATE_SENDRECV);
+                       }
                }
 
                session_media = ast_sip_session_media_state_add(session, session->pending_media_state, ast_media_type_from_str(media), i);