Re: PJSUA: on_pager_status2() never called when sending MESSAGE inside call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11.12.19 16:29, Andreas Wehrmann wrote:
Hello people,

I found that when you send a SIP MESSAGE inside a call by using pjsua_call_send_im()
the pager status callback on_pager_status2() is never called.

I then played around a little and found that on_pager_status() (the first variant) does work. After doing some digging, I looks like you forgot to check for the second variant in pjsua_call.c.

Best Regards,
Andreas Wehrmann

Hello again,

attached to this message you'll find a patch that seems to fix the problem I described in my previous mail.
Also while I was testing this I noticed that the on_pager_status()
callback would always be called twice when a MESSAGE is sent inside a call
(one for event TSX_STATE and one afterwards for event TIMER).

The patch should fix both problems:

- on_pager_status2() will now be called when set and an IM is sent inside a call - on_pager_status() and on_pager_status2() will only be called once for a message after sending an IM inside a call

Best Regards,
Andreas Wehrmann

Index: pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- pjsip/src/pjsua-lib/pjsua_call.c	(revision 6117)
+++ pjsip/src/pjsua-lib/pjsua_call.c	(working copy)
@@ -5432,8 +5432,12 @@
 			       &inv->dlg->local.info_str, rdata);
 
     }
-    else if (tsx->role == PJSIP_ROLE_UAC &&
-	     pjsip_method_cmp(&tsx->method, &pjsip_message_method)==0)
+    else if (e->type == PJSIP_EVENT_TSX_STATE &&
+	     tsx->role == PJSIP_ROLE_UAC &&
+	     pjsip_method_cmp(&tsx->method, &pjsip_message_method)==0 &&
+	     (tsx->state == PJSIP_TSX_STATE_COMPLETED ||
+	     (tsx->state == PJSIP_TSX_STATE_TERMINATED &&
+	      e->body.tsx_state.prev_state != PJSIP_TSX_STATE_COMPLETED)))
     {
 	/* Handle outgoing pager status */
 	if (tsx->status_code >= 200) {
@@ -5442,14 +5446,35 @@
 	    im_data = (pjsua_im_data*) tsx->mod_data[pjsua_var.mod.id];
 	    /* im_data can be NULL if this is typing indication */
 
-	    if (im_data && pjsua_var.ua_cfg.cb.on_pager_status) {
-		pjsua_var.ua_cfg.cb.on_pager_status(im_data->call_id,
+	    if (im_data) {
+	        if (pjsua_var.ua_cfg.cb.on_pager_status) {
+	        pjsua_var.ua_cfg.cb.on_pager_status(im_data->call_id,
 						    &im_data->to,
 						    &im_data->body,
 						    im_data->user_data,
 						    (pjsip_status_code)
 						    	tsx->status_code,
 						    &tsx->status_text);
+	        }
+
+	        if (pjsua_var.ua_cfg.cb.on_pager_status2) {
+	        pjsip_rx_data* rdata;
+
+	        if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG)
+            rdata = e->body.tsx_state.src.rdata;
+            else
+            rdata = NULL;
+
+            pjsua_var.ua_cfg.cb.on_pager_status2(im_data->call_id, 
+						    &im_data->to,
+						    &im_data->body,
+						    im_data->user_data,
+						    (pjsip_status_code) 
+						    	tsx->status_code,
+						    &tsx->status_text,
+						    tsx->last_tx,
+						    rdata, im_data->acc_id);
+	        }
 	    }
 	}
     } else if (tsx->role == PJSIP_ROLE_UAC &&
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux