summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2011-10-03 08:22:48 +0000
committerLiong Sauw Ming <ming@teluu.com>2011-10-03 08:22:48 +0000
commitf3f2c4b1e8ec8416fce15fc5db9ea6c6059f307d (patch)
tree7d26081a3f71a384befdc68f71054f028f6f8ffa
parent1685526712e312b701db96c977604343c3550ba1 (diff)
Re #1266: Modified pjsua_media_channel_deinit() to resume deinit in the callback (instead of returning PJ_EBUSY) and make sure the right transport is used before calling dlg_respond()
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3780 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/include/pjsua-lib/pjsua_internal.h1
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c34
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c12
3 files changed, 34 insertions, 13 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h
index 0b65a7f0..b15a102e 100644
--- a/pjsip/include/pjsua-lib/pjsua_internal.h
+++ b/pjsip/include/pjsua-lib/pjsua_internal.h
@@ -156,6 +156,7 @@ struct pjsua_call
pjsip_dialog *dlg; /**< Call dialog. */
pjmedia_sdp_session *rem_sdp;/**< Remote SDP. */
pj_pool_t *pool_prov;/**< Provisional pool. */
+ pj_bool_t med_ch_deinit;/**< Media channel de-init-ed? */
union {
struct {
unsigned options; /**< Outgoing call options. */
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index fe9befd4..64aeac4d 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -357,6 +357,10 @@ on_make_call_med_tp_complete(pjsua_call_id call_id,
goto on_error;
}
+ /* pjsua_media_channel_deinit() has been called. */
+ if (call->async_call.med_ch_deinit)
+ goto on_error;
+
/* Create offer */
status = pjsua_media_channel_create_sdp(call->index, dlg->pool, NULL,
&offer, NULL);
@@ -708,7 +712,15 @@ on_incoming_call_med_tp_complete(pjsua_call_id call_id,
pjsua_perror(THIS_FILE, "Error initializing media channel", status);
goto on_return;
}
-
+
+ /* pjsua_media_channel_deinit() has been called. */
+ if (call->async_call.med_ch_deinit) {
+ pjsua_media_channel_deinit(call->index);
+ call->med_ch_cb = NULL;
+ PJSUA_UNLOCK();
+ return PJ_SUCCESS;
+ }
+
/* Get remote SDP offer (if any). */
if (call->inv->neg)
pjmedia_sdp_neg_get_neg_remote(call->inv->neg, &offer);
@@ -1057,6 +1069,16 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
goto on_return;
}
+ /* If account is locked to specific transport, then lock dialog
+ * to this transport too.
+ */
+ if (pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) {
+ pjsip_tpselector tp_sel;
+
+ pjsua_init_tpselector(pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel);
+ pjsip_dlg_set_transport(dlg, &tp_sel);
+ }
+
/* Create and attach pjsua_var data to the dialog: */
call->inv = inv;
dlg->mod_data[pjsua_var.mod.id] = call;
@@ -1128,16 +1150,6 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
update_remote_nat_type(call, remote_sdp);
}
- /* If account is locked to specific transport, then lock dialog
- * to this transport too.
- */
- if (pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) {
- pjsip_tpselector tp_sel;
-
- pjsua_init_tpselector(pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel);
- pjsip_dlg_set_transport(dlg, &tp_sel);
- }
-
/* Must answer with some response to initial INVITE. We'll do this before
* attaching the call to the invite session/dialog, so that the application
* will not get notification about this event (on another scenario, it is
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 7cd133a4..876f26b6 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -2113,12 +2113,20 @@ pj_status_t pjsua_media_channel_deinit(pjsua_call_id call_id)
pjsua_call *call = &pjsua_var.calls[call_id];
unsigned mi;
+ PJSUA_LOCK();
for (mi=0; mi<call->med_cnt; ++mi) {
pjsua_call_media *call_med = &call->media[mi];
- if (call_med->tp_st == PJSUA_MED_TP_CREATING)
- return PJ_EBUSY;
+ if (call_med->tp_st == PJSUA_MED_TP_CREATING) {
+ /* We will do the deinitialization after media transport
+ * creation is completed.
+ */
+ call->async_call.med_ch_deinit = PJ_TRUE;
+ PJSUA_UNLOCK();
+ return PJ_SUCCESS;
+ }
}
+ PJSUA_UNLOCK();
PJ_LOG(4,(THIS_FILE, "Call %d: deinitializing media..", call_id));
pj_log_push_indent();