summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins2 <jenkins2@gerrit.asterisk.org>2018-03-12 07:23:26 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2018-03-12 07:23:26 -0500
commit114c25e706fd1abf8d4bbc4d5629bb44f2b0a3a5 (patch)
treebd3dda5678a4a7fb84a42d47e63adb191b9141a8
parente5a6c72cd787c198c0a868f1c161044089c6ffd7 (diff)
parent3fb26df4acd712fbbac78dd9e88235d37024b2fa (diff)
Merge "res_pjsip_session: properly handle SDP from a forked call with early media"
-rw-r--r--res/res_pjsip_session.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index fcd190bcb..f25201731 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -876,15 +876,30 @@ static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_
struct ast_stream_topology *topology;
unsigned int changed = 0;
- /* This situation can legitimately happen when an SDP is received in a
- * 183 Session Progress message. In that case, everything's been done
- * by the time this function is called and there are no more pending
- * streams.
- */
if (!session->pending_media_state->topology) {
- ast_debug(1, "Pending topology was NULL for channel '%s'\n",
- session->channel ? ast_channel_name(session->channel) : "unknown");
- return 0;
+ if (session->active_media_state->topology) {
+ /*
+ * This happens when we have negotiated media after receiving a 183,
+ * and we're now receiving a 200 with a new SDP. In this case, there
+ * is active_media_state, but the pending_media_state has been reset.
+ */
+ struct ast_sip_session_media_state *active_media_state_clone;
+
+ active_media_state_clone =
+ ast_sip_session_media_state_clone(session->active_media_state);
+ if (!active_media_state_clone) {
+ ast_log(LOG_WARNING, "Unable to clone active media state for channel '%s'\n",
+ session->channel ? ast_channel_name(session->channel) : "unknown");
+ return -1;
+ }
+
+ ast_sip_session_media_state_free(session->pending_media_state);
+ session->pending_media_state = active_media_state_clone;
+ } else {
+ ast_log(LOG_WARNING, "No pending or active media state for channel '%s'\n",
+ session->channel ? ast_channel_name(session->channel) : "unknown");
+ return -1;
+ }
}
/* If we're handling negotiated streams, then we should already have set