summaryrefslogtreecommitdiff
path: root/pjsip/include
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2011-09-21 10:20:01 +0000
committerLiong Sauw Ming <ming@teluu.com>2011-09-21 10:20:01 +0000
commit8a8b2bba54aedc161159225259b83e6d7c1d17b3 (patch)
tree45a096a1b1cb6f3d5c5d3e016ce6147969a0d9b0 /pjsip/include
parentbe8d37186b16150716f752883ae6857a0161db40 (diff)
Re #1266: Asynchronous media transport creation
* Add feature that allows ICE media transport to be created asynchronously. * Add new callback, e.g. on_call_media_transport_state(call_id, state_struct) to report media transport status. * Handle outgoing calls while creating media transport asynchronously. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3763 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h90
-rw-r--r--pjsip/include/pjsua-lib/pjsua_internal.h57
2 files changed, 124 insertions, 23 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index f79de1b9..f768438d 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -463,6 +463,78 @@ typedef struct pjsua_reg_info
} pjsua_reg_info;
+/**
+ * Enumeration of media transport state types.
+ */
+typedef enum pjsua_med_tp_st
+{
+ /** Null, this is the state before media transport is created. */
+ PJSUA_MED_TP_NULL,
+
+ /**
+ * Just before media transport is created, which can finish
+ * asynchronously later.
+ */
+ PJSUA_MED_TP_CREATING,
+
+ /** Media transport creation is completed, but not initialized yet. */
+ PJSUA_MED_TP_IDLE,
+
+ /** Initialized (media_create() has been called). */
+ PJSUA_MED_TP_INIT,
+
+ /** Running (media_start() has been called). */
+ PJSUA_MED_TP_RUNNING,
+
+ /** Disabled (transport is initialized, but media is being disabled). */
+ PJSUA_MED_TP_DISABLED
+
+} pjsua_med_tp_st;
+
+
+/**
+ * Structure to be passed on media transport state callback.
+ */
+typedef struct pjsua_med_tp_state_info
+{
+ /**
+ * The media index.
+ */
+ unsigned med_idx;
+
+ /**
+ * The media transport state
+ */
+ pjsua_med_tp_st state;
+
+ /**
+ * The last error code related to the media transport state.
+ */
+ pj_status_t status;
+
+ /**
+ * Optional SIP error code.
+ */
+ int sip_err_code;
+
+ /**
+ * Optional extended info, the content is specific for each transport type.
+ */
+ void *ext_info;
+
+} pjsua_med_tp_state_info;
+
+
+/**
+ * Type of callback to be called when media transport state is changed.
+ *
+ * @param call_id The call ID.
+ * @param info The media transport state info.
+ */
+typedef void (*pjsua_med_tp_state_cb)(pjsua_call_id call_id,
+ const pjsua_med_tp_state_info *info);
+
+
/**
* This structure describes application callback to receive various event
* notification from PJSUA-API. All of these callbacks are OPTIONAL,
@@ -949,6 +1021,12 @@ typedef struct pjsua_callback
pjsip_tp_state_callback on_transport_state;
/**
+ * This callback is called when media transport state is changed. See
+ * also #pjsua_med_tp_state_cb.
+ */
+ pjsua_med_tp_state_cb on_call_media_transport_state;
+
+ /**
* This callback is called to report error in ICE media transport.
* Currently it is used to report TURN Refresh error.
*
@@ -1365,6 +1443,18 @@ PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
/**
+ * Clone message data.
+ *
+ * @param pool Pool to allocate memory for the new message data.
+ * @param rhs Message data to be cloned.
+ *
+ * @return The new message data.
+ */
+PJ_DECL(pjsua_msg_data*) pjsua_msg_data_clone(pj_pool_t *pool,
+ const pjsua_msg_data *rhs);
+
+
+/**
* Instantiate pjsua application. Application must call this function before
* calling any other functions, to make sure that the underlying libraries
* are properly initialized. Once this function has returned success,
diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h
index 01d32887..2a2dc095 100644
--- a/pjsip/include/pjsua-lib/pjsua_internal.h
+++ b/pjsip/include/pjsua-lib/pjsua_internal.h
@@ -27,28 +27,12 @@
PJ_BEGIN_DECL
-/**
- * Media transport state.
- */
-typedef enum pjsua_med_tp_st
-{
- /** Not initialized */
- PJSUA_MED_TP_IDLE,
-
- /** Initialized (media_create() has been called) */
- PJSUA_MED_TP_INIT,
-
- /** Running (media_start() has been called) */
- PJSUA_MED_TP_RUNNING,
-
- /** Disabled (transport is initialized, but media is being disabled) */
- PJSUA_MED_TP_DISABLED
-
-} pjsua_med_tp_st;
-
/** Forward decl of pjsua call */
typedef struct pjsua_call pjsua_call;
+/** Forward decl of pjsua call media */
+typedef struct pjsua_call_media pjsua_call_media;
+
/**
* Call's media stream.
@@ -92,15 +76,23 @@ typedef struct pjsua_call_media
pjmedia_transport *tp; /**< Current media transport (can be 0) */
pj_status_t tp_ready; /**< Media transport status. */
pjmedia_transport *tp_orig; /**< Original media transport */
- pj_bool_t tp_auto_del; /**< May delete media transport */
+ pj_bool_t tp_auto_del; /**< May delete media transport */
pjsua_med_tp_st tp_st; /**< Media transport state */
pj_sockaddr rtp_addr; /**< Current RTP source address
(used to update ICE default
address) */
pjmedia_srtp_use rem_srtp_use; /**< Remote's SRTP usage policy. */
- pjmedia_event_subscription esub_rend;/**< Subscribe renderer events. */
+ pjmedia_event_subscription esub_rend;/**< Subscribe renderer events. */
pjmedia_event_subscription esub_cap;/**< Subscribe capture events. */
+
+ pjsua_med_tp_state_cb med_init_cb;/**< Media transport
+ initialization callback. */
+
+ /** Media transport creation callback. */
+ pj_status_t (*med_create_cb)(pjsua_call_media *call_med,
+ pj_status_t status, int security_level,
+ int *sip_err_code);
} pjsua_call_media;
/**
@@ -132,6 +124,9 @@ struct pjsua_call
unsigned med_cnt; /**< Number of media in SDP. */
pjsua_call_media media[PJSUA_MAX_CALL_MEDIA]; /**< Array of media */
int audio_idx; /**< First active audio media. */
+ pj_mutex_t *med_ch_mutex;/**< Media channel callback's mutex. */
+ pjsua_med_tp_state_cb med_ch_cb;/**< Media channel callback. */
+ pjsua_med_tp_state_info med_ch_info;/**< Media channel info. */
pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this
call was triggered by xfer. */
@@ -147,6 +142,17 @@ struct pjsua_call
} lock_codec; /**< Data for codec locking when answer
contains multiple codecs. */
+ struct {
+ pjsip_dialog *dlg; /**< Call dialog. */
+ pjmedia_sdp_session *rem_sdp;/**< Remote SDP. */
+ union {
+ struct {
+ unsigned options; /**< Outgoing call options. */
+ pjsua_msg_data *msg_data;/**< Headers for outgoing INVITE. */
+ } out_call;
+ } call_var;
+ } async_call; /**< Temporary storage for async
+ outgoing/incoming call. */
};
@@ -508,7 +514,9 @@ pj_status_t pjsua_media_channel_init(pjsua_call_id call_id,
int security_level,
pj_pool_t *tmp_pool,
const pjmedia_sdp_session *rem_sdp,
- int *sip_err_code);
+ int *sip_err_code,
+ pj_bool_t async,
+ pjsua_med_tp_state_cb cb);
pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
pj_pool_t *pool,
const pjmedia_sdp_session *rem_sdp,
@@ -523,12 +531,15 @@ pj_status_t pjsua_call_media_init(pjsua_call_media *call_med,
pjmedia_type type,
const pjsua_transport_config *tcfg,
int security_level,
- int *sip_err_code);
+ int *sip_err_code,
+ pj_bool_t async,
+ pjsua_med_tp_state_cb cb);
pj_status_t video_channel_update(pjsua_call_media *call_med,
pj_pool_t *tmp_pool,
const pjmedia_sdp_session *local_sdp,
const pjmedia_sdp_session *remote_sdp);
void stop_video_stream(pjsua_call_media *call_med);
+void set_media_tp_state(pjsua_call_media *call_med, pjsua_med_tp_st tp_st);
/**