summaryrefslogtreecommitdiff
path: root/include/asterisk/res_pjsip_session.h
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-09-02 20:29:58 +0000
committerMark Michelson <mmichelson@digium.com>2014-09-02 20:29:58 +0000
commit1b64f353f1cfb98671e95726160987bd69a2f3ae (patch)
tree5d1660e40482d1f0ed8d0695e2824db57f8e74f9 /include/asterisk/res_pjsip_session.h
parent897cbf6a4f4123a3c7462da2b373e96d784b02be (diff)
Resolve race condition where channels enter dialplan application before media has been negotiated.
Testsuite tests will occasionally fail because on reception of a 200 OK SIP response, an AST_CONTROL_ANSWER frame is queued prior to when media has finished being negotiated. This is because session supplements are called into before PJSIP's inv_session code has told us that media has been updated. Sometimes the queued answer frame is handled by the PBX thread before the ensuing media negotiations occur, causing a test failure. As it turns out, there is another place that session supplements could be called into, which is after media has finished getting negotiated. What this commit introduces is a means for session supplements to indicate when they wish to be called into when handling an incoming SIP response. By default, all session supplements will be run at the same point that they were prior to this commit. However, session supplements may indicate that they wish to be handled earlier than normal on redirects, or they may indicate they wish to be handled after media has been negotiated. In this changeset, two session supplements have been updated to indicate a preference for when they should be run: res_pjsip_diversion executes before handling redirection in order to get information from the Diversion header, and chan_pjsip now handles responses to INVITEs after media negotiation to fix the race condition mentioned previously. ASTERISK-24212 #close Reported by Matt Jordan Review: https://reviewboard.asterisk.org/r/3930 ........ Merged revisions 422536 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 422542 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422543 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/res_pjsip_session.h')
-rw-r--r--include/asterisk/res_pjsip_session.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index 51908f99b..010a74dc0 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -141,6 +141,36 @@ typedef int (*ast_sip_session_response_cb)(struct ast_sip_session *session, pjsi
typedef int (*ast_sip_session_sdp_creation_cb)(struct ast_sip_session *session, pjmedia_sdp_session *sdp);
/*!
+ * \brief Describes when a supplement should be called into on incoming responses.
+ *
+ * In most cases, session supplements will not need to worry about this because in most cases,
+ * the correct value will be automatically applied. However, there are rare circumstances
+ * when a supplement will want to specify when it should be called.
+ *
+ * The values below are listed in chronological order.
+ */
+enum ast_sip_session_response_priority {
+ /*!
+ * When processing 3XX responses, the supplement is called into before
+ * the redirecting information is processed.
+ */
+ AST_SIP_SESSION_BEFORE_REDIRECTING = (1 << 0),
+ /*!
+ * For responses to INVITE transactions, the supplement is called into
+ * before media is negotiated.
+ *
+ * This priority is applied by default to any session supplement that
+ * does not specify a response priority.
+ */
+ AST_SIP_SESSION_BEFORE_MEDIA = (1 << 1),
+ /*!
+ * For INVITE transactions, the supplement is called into after media
+ * is negotiated.
+ */
+ AST_SIP_SESSION_AFTER_MEDIA = (1 << 2),
+};
+
+/*!
* \brief A supplement to SIP message processing
*
* These can be registered by any module in order to add
@@ -214,6 +244,11 @@ struct ast_sip_session_supplement {
void (*outgoing_response)(struct ast_sip_session *session, struct pjsip_tx_data *tdata);
/*! Next item in the list */
AST_LIST_ENTRY(ast_sip_session_supplement) next;
+ /*!
+ * Determines when the supplement is processed when handling a response.
+ * Defaults to AST_SIP_SESSION_BEFORE_MEDIA
+ */
+ enum ast_sip_session_response_priority response_priority;
};
enum ast_sip_session_sdp_stream_defer {