res_pjsip_session: Set stream state on created streams for incoming SDP.

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
This commit is contained in:
Joshua C. Colp
2019-12-16 07:23:07 -04:00
committed by Joshua C. Colp
parent 0aa75cd2cb
commit ef0bca0a05

View 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);