[PATCH] New PJSUA functions to send a request with an attached dialog usage

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

 



New function pjsua_call_send_mod_request: same as 
pjsua_call_send_request, but with two extra arguments, int mod_id and 
void *mod_data, same as the last two arguments to 
pjsip_dlg_send_request. The patch also implements PJSUA wrappers for 
pjsip_dlg_add_usage, pjsip_dlg_set_mod_data, pjsip_dlg_get_mod_data
-------------- next part --------------
Index: pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- pjsip/include/pjsua-lib/pjsua.h	(revision 5087)
+++ pjsip/include/pjsua-lib/pjsua.h	(working copy)
@@ -4837,6 +4837,50 @@
 
 
 /**
+ * Send arbitrary request with the call from a PJSIP module. This is useful
+ * for example to send INFO request. Note that application should not use this
+ * function to send requests which would change the invite session's state,
+ * such as re-INVITE, UPDATE, PRACK, and BYE.
+ *
+ * @param call_id	Call identification.
+ * @param method	SIP method of the request.
+ * @param msg_data	Optional message body and/or list of headers to be 
+ *			included in outgoing request.
+ * @param mod_id	Identifier of the module sending the request.
+ * @param mod_data	Module-specific data to associate to the transaction.
+ *
+ * @return		PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjsua_call_send_mod_request(pjsua_call_id call_id,
+						const pj_str_t *method_str,
+						const pjsua_msg_data *msg_data,
+						int mod_id,
+						void *mod_data);
+
+
+/**
+ * TODO
+ */
+PJ_DECL(pj_status_t) pjsua_call_add_usage( pjsua_call_id call_id,
+					   pjsip_module *mod,
+					   void *mod_data );
+
+
+/**
+ * TODO
+ */
+PJ_DECL(pj_status_t) pjsua_call_set_mod_data( pjsua_call_id call_id,
+					      int mod_id,
+					      void *data );
+
+
+/**
+ * TODO
+ */
+PJ_DECL(void*) pjsua_call_get_mod_data( pjsua_call_id call_id,
+				        int mod_id);
+					
+/**
  * Terminate all calls. This will initiate #pjsua_call_hangup() for all
  * currently active calls. 
  */
Index: pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- pjsip/src/pjsua-lib/pjsua_call.c	(revision 5087)
+++ pjsip/src/pjsua-lib/pjsua_call.c	(working copy)
@@ -2992,9 +2992,11 @@
 /*
  * Send arbitrary request.
  */
-PJ_DEF(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
-					    const pj_str_t *method_str,
-					    const pjsua_msg_data *msg_data)
+PJ_DEF(pj_status_t) pjsua_call_send_mod_request(pjsua_call_id call_id,
+					        const pj_str_t *method_str,
+					        const pjsua_msg_data *msg_data,
+					        int mod_id,
+					        void *mod_data)
 {
     pjsua_call *call;
     pjsip_dialog *dlg = NULL;
@@ -3027,7 +3029,7 @@
     pjsua_process_msg_data( tdata, msg_data);
 
     /* Send the request. */
-    status = pjsip_dlg_send_request( call->inv->dlg, tdata, -1, NULL);
+    status = pjsip_dlg_send_request( call->inv->dlg, tdata, mod_id, mod_data);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to send request", status);
 	goto on_return;
@@ -3040,6 +3042,77 @@
 }
 
 
+PJ_DEF(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
+					    const pj_str_t *method_str,
+					    const pjsua_msg_data *msg_data)
+{
+    return pjsua_call_send_mod_request(call_id, method_str, msg_data, -1, NULL);
+}
+
+
+PJ_DEF(pj_status_t) pjsua_call_add_usage( pjsua_call_id call_id,
+					  pjsip_module *mod,
+					  void *mod_data )
+{
+    pjsua_call *call;
+    pjsip_dialog *dlg;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, PJ_EINVAL);
+
+    status = acquire_call("pjsua_call_add_usage", call_id, &call, &dlg);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    status = pjsip_dlg_add_usage (dlg, mod, mod_data);
+
+    pjsip_dlg_dec_lock(dlg);
+    return status;
+}
+
+
+PJ_DEF(pj_status_t) pjsua_call_set_mod_data( pjsua_call_id call_id,
+					     int mod_id,
+					     void *data )
+{
+    pjsua_call *call;
+    pjsip_dialog *dlg;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, PJ_EINVAL);
+
+    status = acquire_call("pjsua_call_set_mod_data", call_id, &call, &dlg);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    status = pjsip_dlg_set_mod_data (dlg, mod_id, data);
+
+    pjsip_dlg_dec_lock(dlg);
+    return status;
+}
+
+
+PJ_DEF(void*) pjsua_call_get_mod_data( pjsua_call_id call_id,
+				       int mod_id)
+{
+    pjsua_call *call;
+    pjsip_dialog *dlg;
+    pj_status_t status;
+    void *data;
+
+    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, NULL);
+
+    status = acquire_call("pjsua_call_get_mod_data", call_id, &call, &dlg);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    data = pjsip_dlg_get_mod_data (dlg, mod_id);
+
+    pjsip_dlg_dec_lock(dlg);
+    return data;
+}
+
+
 /*
  * Terminate all calls.
  */


[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