summaryrefslogtreecommitdiff
path: root/pjsip/include/pjsip/sip_transport.h
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2010-04-14 06:57:35 +0000
committerNanang Izzuddin <nanang@teluu.com>2010-04-14 06:57:35 +0000
commit3e4dd6d305b65dcd7db9a1d8f36d7f5dcc1b6938 (patch)
tree225967cd5f010b59b68a191a7888c0e9ca7cb2a7 /pjsip/include/pjsip/sip_transport.h
parentccfb2e74fd1223e7bee765d1d0fbaece6e507deb (diff)
Ticket #1056:
- Added functions to set/unset transport state notification callback on specific transport. - Updated transaction to immediately terminate the transactions when their transport gets disconnected. - Minor update: renamed function pjsip_tpmgr_set/get_status_cb() to pjsip_tpmgr_set/get_state_cb(). git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3138 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include/pjsip/sip_transport.h')
-rw-r--r--pjsip/include/pjsip/sip_transport.h72
1 files changed, 63 insertions, 9 deletions
diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h
index 92c624fe..bdcc6db4 100644
--- a/pjsip/include/pjsip/sip_transport.h
+++ b/pjsip/include/pjsip/sip_transport.h
@@ -750,6 +750,8 @@ struct pjsip_transport
pjsip_tpmgr *tpmgr; /**< Transport manager. */
pj_timer_entry idle_timer; /**< Timer when ref cnt is zero.*/
+ void *data; /**< Internal transport data. */
+
/**
* Function to be called by transport manager to send SIP message.
*
@@ -1270,6 +1272,11 @@ typedef enum pjsip_transport_state
/**
+ * Definition of transport state listener key.
+ */
+typedef void pjsip_tp_state_listener_key;
+
+/**
* Structure of transport state info passed by #pjsip_tp_state_callback.
*/
typedef struct pjsip_transport_state_info {
@@ -1282,6 +1289,13 @@ typedef struct pjsip_transport_state_info {
* Optional extended info, the content is specific for each transport type.
*/
void *ext_info;
+
+ /**
+ * Optional user data. In global transport state notification, this will
+ * always be NULL.
+ */
+ void *user_data;
+
} pjsip_transport_state_info;
@@ -1301,29 +1315,69 @@ typedef void (*pjsip_tp_state_callback)(
/**
- * Setting callback of transport state notification. The caller will be
- * notified whenever the state of transport is changed. The type of
- * events are defined in #pjsip_transport_state.
+ * Set callback of global transport state notification. The caller will be
+ * notified whenever the state of any transport is changed. The type of events
+ * are defined in #pjsip_transport_state.
+ *
+ * Note that this function will override the existing callback, if any, so
+ * application is recommended to keep the old callback and manually forward
+ * the notification to the old callback, otherwise other component that
+ * concerns about the transport state will no longer receive transport state
+ * events.
*
* @param mgr Transport manager.
* @param cb Callback to be called to notify caller about transport
- * status changing.
+ * state changing.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*/
-PJ_DECL(pj_status_t) pjsip_tpmgr_set_status_cb(pjsip_tpmgr *mgr,
- pjsip_tp_state_callback cb);
+PJ_DECL(pj_status_t) pjsip_tpmgr_set_state_cb(pjsip_tpmgr *mgr,
+ pjsip_tp_state_callback cb);
/**
- * Getting the callback of transport state notification.
+ * Get the callback of global transport state notification.
*
* @param mgr Transport manager.
*
* @return The transport state callback or NULL if it is not set.
*/
-PJ_DECL(pjsip_tp_state_callback) pjsip_tpmgr_get_status_cb(
- const pjsip_tpmgr *mgr);
+PJ_DECL(pjsip_tp_state_callback) pjsip_tpmgr_get_state_cb(
+ const pjsip_tpmgr *mgr);
+
+
+/**
+ * Add a listener to the specified transport for transport state notification.
+ *
+ * @param tp The transport.
+ * @param cb Callback to be called to notify listener about transport
+ * state changing.
+ * @param user_data The user data.
+ * @param key Output key, used to remove this listener.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjsip_transport_add_state_listener (
+ pjsip_transport *tp,
+ pjsip_tp_state_callback cb,
+ void *user_data,
+ pjsip_tp_state_listener_key **key);
+
+
+/**
+ * Remove a listener from the specified transport for transport state
+ * notification.
+ *
+ * @param tp The transport.
+ * @param key The listener key.
+ * @param user_data The user data, for validation purpose.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjsip_transport_remove_state_listener (
+ pjsip_transport *tp,
+ pjsip_tp_state_listener_key *key,
+ const void *user_data);
/**