summaryrefslogtreecommitdiff
path: root/pjsip/include/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2012-10-04 06:11:58 +0000
committerBenny Prijono <bennylp@teluu.com>2012-10-04 06:11:58 +0000
commitc2ede788507ad621f7f7120d287bbca9a48c9148 (patch)
tree090cebfe2319211da3f14adf4f37c62f6c800548 /pjsip/include/pjsip
parent3b6f93a2d59fc491662ee1f720f97b04205462fa (diff)
Close #1590: APIs to facilitate pending processing of pjsip_rx_data
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4275 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include/pjsip')
-rw-r--r--pjsip/include/pjsip/sip_endpoint.h71
-rw-r--r--pjsip/include/pjsip/sip_transport.h36
2 files changed, 107 insertions, 0 deletions
diff --git a/pjsip/include/pjsip/sip_endpoint.h b/pjsip/include/pjsip/sip_endpoint.h
index 86dc9bef..265b7f23 100644
--- a/pjsip/include/pjsip/sip_endpoint.h
+++ b/pjsip/include/pjsip/sip_endpoint.h
@@ -213,6 +213,77 @@ PJ_DECL(pj_status_t) pjsip_endpt_register_module( pjsip_endpoint *endpt,
PJ_DECL(pj_status_t) pjsip_endpt_unregister_module( pjsip_endpoint *endpt,
pjsip_module *module );
+/**
+ * This describes additional parameters to pjsip_endpt_process_rx_data()
+ * function. Application MUST call pjsip_process_rdata_param_default() to
+ * initialize this structure.
+ */
+typedef struct pjsip_process_rdata_param
+{
+ /**
+ * Specify the minimum priority number of the modules that are allowed
+ * to process the message. Default is zero to allow all modules to
+ * process the message.
+ */
+ unsigned start_prio;
+
+ /**
+ * Specify the pointer of the module where processing will start.
+ * The default is NULL, meaning processing will start from the start
+ * of the module list.
+ */
+ void *start_mod;
+
+ /**
+ * Set to N, then processing will start at Nth module after start
+ * module (where start module can be an explicit module as specified
+ * by \a start_mod or the start of module list when \a start_mod is
+ * NULL). For example, if set to 1, then processing will start from
+ * the next module after start module. Default is zero.
+ */
+ unsigned idx_after_start;
+
+ /**
+ * Print nothing to log. Default is PJ_FALSE.
+ */
+ pj_bool_t silent;
+
+} pjsip_process_rdata_param;
+
+/**
+ * Initialize with default.
+ *
+ * @param p The param.
+ */
+PJ_DECL(void) pjsip_process_rdata_param_default(pjsip_process_rdata_param *p);
+
+/**
+ * Manually distribute the specified pjsip_rx_data to registered modules.
+ * Normally application does not need to call this function because received
+ * messages will be given to endpoint automatically by transports.
+ *
+ * Application can use this function when it has postponed the processing of
+ * an incoming message, for example to perform long operations such as
+ * database operation or to consult other servers to decide what to do with
+ * the message. In this case, application clones the original rdata, return
+ * from the callback, and perform the long operation. Upon completing the
+ * long operation, it resumes pjsip's module processing by calling this
+ * function, and then free the cloned rdata.
+ *
+ * @param endpt The endpoint instance.
+ * @param rdata The rdata to be distributed.
+ * @param p Optional pointer to param to specify from which module
+ * the processing should start.
+ * @param p_handled Optional pointer to receive last return value of
+ * module's \a on_rx_request() or \a on_rx_response()
+ * callback.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_endpt_process_rx_data(pjsip_endpoint *endpt,
+ pjsip_rx_data *rdata,
+ pjsip_process_rdata_param *p,
+ pj_bool_t *p_handled);
/**
* Create pool from the endpoint. All SIP components should allocate their
diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h
index e3e44884..4ff3597c 100644
--- a/pjsip/include/pjsip/sip_transport.h
+++ b/pjsip/include/pjsip/sip_transport.h
@@ -427,6 +427,42 @@ struct pjsip_rx_data
*/
PJ_DECL(char*) pjsip_rx_data_get_info(pjsip_rx_data *rdata);
+/**
+ * Clone pjsip_rx_data. This will duplicate the contents of
+ * pjsip_rx_data and add reference count to the transport.
+ * Once application has finished using the cloned pjsip_rx_data,
+ * it must release it by calling #pjsip_rx_data_free_cloned().
+ *
+ * By default (if flags is set to zero), this function copies the
+ * transport pointer in \a tp_info, duplicates the \a pkt_info,
+ * perform deep clone of the \a msg_info parts of the rdata, and
+ * fills the \a endpt_info (i.e. the \a mod_data) with zeros.
+ *
+ * @param src The source to be cloned.
+ * @param flags Optional flags. Must be zero for now.
+ * @param p_rdata Pointer to receive the cloned rdata.
+ *
+ * @return PJ_SUCCESS on success or the appropriate error.
+ */
+PJ_DECL(pj_status_t) pjsip_rx_data_clone(const pjsip_rx_data *src,
+ unsigned flags,
+ pjsip_rx_data **p_rdata);
+
+/**
+ * Free cloned pjsip_rx_data. This function must be and must only
+ * be called for a cloned pjsip_rx_data. Specifically, it must NOT
+ * be called for the original pjsip_rx_data that is returned by
+ * transports.
+ *
+ * This function will free the memory used by the pjsip_rx_data and
+ * decrement the transport reference counter.
+ *
+ * @param rdata The receive data buffer.
+ *
+ * @return PJ_SUCCESS on success or the appropriate error.
+ */
+PJ_DECL(pj_status_t) pjsip_rx_data_free_cloned(pjsip_rx_data *rdata);
+
/*****************************************************************************
*