[Asterisk-code-review] chan pjsip: Register for "BEFORE MEDIA" responses (asterisk[13])

George Joseph asteriskteam at digium.com
Thu Jun 7 08:52:26 CDT 2018


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/9130


Change subject: chan_pjsip:  Register for "BEFORE_MEDIA" responses
......................................................................

chan_pjsip:  Register for "BEFORE_MEDIA" responses

chan_pjsip wasn't registering for "BEFORE_MEDIA" responses which meant
it was not updating HANGUPCAUSE for 4XX responses.  If the remote end
sent a "180 Ringing", then a "486 Busy", the hangup cause was left at
"180 Normal Clearing".

* Removed chan_pjsip_incoming_response from the original session
  supplement (which was handling only "AFTER MEDIA") and added it to a
  new session supplement which accepts both "BEFORE_MEDIA" and
  "AFTER_MEDIA".

* Also cleaned up some cleanup code in load module.

ASTERISK-27902

Change-Id: If9b860541887aca8ac2c9f2ed51ceb0550fb007a
---
M channels/chan_pjsip.c
1 file changed, 18 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/30/9130/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index c7344d2..3e5fab2 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -147,9 +147,16 @@
 	.session_begin = chan_pjsip_session_begin,
 	.session_end = chan_pjsip_session_end,
 	.incoming_request = chan_pjsip_incoming_request,
-	.incoming_response = chan_pjsip_incoming_response,
 	/* It is important that this supplement runs after media has been negotiated */
 	.response_priority = AST_SIP_SESSION_AFTER_MEDIA,
+};
+
+/*! \brief SIP session supplement structure just for responses */
+static struct ast_sip_session_supplement chan_pjsip_supplement_response = {
+	.method = "INVITE",
+	.priority = AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL,
+	.incoming_response = chan_pjsip_incoming_response,
+	.response_priority = AST_SIP_SESSION_BEFORE_MEDIA | AST_SIP_SESSION_AFTER_MEDIA,
 };
 
 static int chan_pjsip_incoming_ack(struct ast_sip_session *session, struct pjsip_rx_data *rdata);
@@ -2837,6 +2844,11 @@
 		goto end;
 	}
 
+	if (ast_sip_session_register_supplement(&chan_pjsip_supplement_response)) {
+		ast_log(LOG_ERROR, "Unable to register PJSIP supplement\n");
+		goto end;
+	}
+
 	if (!(pjsip_uids_onhold = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_RWLOCK,
 			AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, 37, uid_hold_hash_fn,
 			uid_hold_sort_fn, NULL))) {
@@ -2846,31 +2858,21 @@
 
 	if (ast_sip_session_register_supplement(&call_pickup_supplement)) {
 		ast_log(LOG_ERROR, "Unable to register PJSIP call pickup supplement\n");
-		ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
 		goto end;
 	}
 
 	if (ast_sip_session_register_supplement(&pbx_start_supplement)) {
 		ast_log(LOG_ERROR, "Unable to register PJSIP pbx start supplement\n");
-		ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
-		ast_sip_session_unregister_supplement(&call_pickup_supplement);
 		goto end;
 	}
 
 	if (ast_sip_session_register_supplement(&chan_pjsip_ack_supplement)) {
 		ast_log(LOG_ERROR, "Unable to register PJSIP ACK supplement\n");
-		ast_sip_session_unregister_supplement(&pbx_start_supplement);
-		ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
-		ast_sip_session_unregister_supplement(&call_pickup_supplement);
 		goto end;
 	}
 
 	if (pjsip_channel_cli_register()) {
 		ast_log(LOG_ERROR, "Unable to register PJSIP Channel CLI\n");
-		ast_sip_session_unregister_supplement(&chan_pjsip_ack_supplement);
-		ast_sip_session_unregister_supplement(&pbx_start_supplement);
-		ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
-		ast_sip_session_unregister_supplement(&call_pickup_supplement);
 		goto end;
 	}
 
@@ -2886,6 +2888,11 @@
 end:
 	ao2_cleanup(pjsip_uids_onhold);
 	pjsip_uids_onhold = NULL;
+	ast_sip_session_unregister_supplement(&chan_pjsip_ack_supplement);
+	ast_sip_session_unregister_supplement(&pbx_start_supplement);
+	ast_sip_session_unregister_supplement(&chan_pjsip_supplement_response);
+	ast_sip_session_unregister_supplement(&chan_pjsip_supplement);
+	ast_sip_session_unregister_supplement(&call_pickup_supplement);
 	ast_custom_function_unregister(&dtmf_mode_function);
 	ast_custom_function_unregister(&media_offer_function);
 	ast_custom_function_unregister(&chan_pjsip_dial_contacts_function);

-- 
To view, visit https://gerrit.asterisk.org/9130
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: If9b860541887aca8ac2c9f2ed51ceb0550fb007a
Gerrit-Change-Number: 9130
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180607/5d172b72/attachment-0001.html>


More information about the asterisk-code-review mailing list