summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsua-lib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2012-03-30 07:10:13 +0000
committerBenny Prijono <bennylp@teluu.com>2012-03-30 07:10:13 +0000
commit6b4964727bffb379aca9601e1cf69051ccbf600c (patch)
tree1d9739ea8b3b5e0421f1d99b39e798b1514fb644 /pjsip/src/pjsua-lib
parent85ac546acb235df62169c4ad317da74a62e56a88 (diff)
Re #1474: Merged all changes from 1.12 - HEAD (from the 1.x branch)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3999 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_aud.c68
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c37
-rw-r--r--pjsip/src/pjsua-lib/pjsua_dump.c1
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c4
4 files changed, 70 insertions, 40 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_aud.c b/pjsip/src/pjsua-lib/pjsua_aud.c
index d80981d6..cbe52daf 100644
--- a/pjsip/src/pjsua-lib/pjsua_aud.c
+++ b/pjsip/src/pjsua-lib/pjsua_aud.c
@@ -26,7 +26,7 @@
#define NULL_SND_DEV_ID -99
/*****************************************************************************
-/*
+ *
* Prototypes
*/
/* Open sound dev */
@@ -43,7 +43,7 @@ static pj_status_t create_aud_param(pjmedia_aud_param *param,
unsigned bits_per_sample);
/*****************************************************************************
-/*
+ *
* Call API that are closely tied to PJMEDIA
*/
/*
@@ -223,7 +223,7 @@ on_return:
/*****************************************************************************
-/*
+ *
* Audio media with PJMEDIA backend
*/
@@ -806,13 +806,13 @@ PJ_DEF(pj_status_t) pjsua_conf_connect( pjsua_conf_port_id source,
source, sink));
pj_log_push_indent();
- /* If sound device idle timer is active, cancel it first. */
PJSUA_LOCK();
+
+ /* If sound device idle timer is active, cancel it first. */
if (pjsua_var.snd_idle_timer.id) {
pjsip_endpt_cancel_timer(pjsua_var.endpt, &pjsua_var.snd_idle_timer);
pjsua_var.snd_idle_timer.id = PJ_FALSE;
}
- PJSUA_UNLOCK();
/* For audio switchboard (i.e. APS-Direct):
@@ -910,8 +910,6 @@ PJ_DEF(pj_status_t) pjsua_conf_connect( pjsua_conf_port_id source,
if (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL &&
!pjsua_var.no_snd)
{
- pj_status_t status;
-
status = pjsua_set_snd_dev(pjsua_var.cap_dev, pjsua_var.play_dev);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error opening sound device", status);
@@ -926,9 +924,13 @@ PJ_DEF(pj_status_t) pjsua_conf_connect( pjsua_conf_port_id source,
}
}
- status = pjmedia_conf_connect_port(pjsua_var.mconf, source, sink, 0);
-
on_return:
+ PJSUA_UNLOCK();
+
+ if (status == PJ_SUCCESS) {
+ status = pjmedia_conf_connect_port(pjsua_var.mconf, source, sink, 0);
+ }
+
pj_log_pop_indent();
return status;
}
@@ -1851,8 +1853,11 @@ PJ_DEF(pj_status_t) pjsua_set_snd_dev( int capture_dev,
capture_dev, playback_dev));
pj_log_push_indent();
+ PJSUA_LOCK();
+
/* Null-sound */
if (capture_dev==NULL_SND_DEV_ID && playback_dev==NULL_SND_DEV_ID) {
+ PJSUA_UNLOCK();
status = pjsua_set_null_snd_dev();
pj_log_pop_indent();
return status;
@@ -1903,10 +1908,12 @@ PJ_DEF(pj_status_t) pjsua_set_snd_dev( int capture_dev,
pjsua_var.no_snd = PJ_FALSE;
pjsua_var.snd_is_on = PJ_TRUE;
+ PJSUA_UNLOCK();
pj_log_pop_indent();
return PJ_SUCCESS;
on_error:
+ PJSUA_UNLOCK();
pj_log_pop_indent();
return status;
}
@@ -1920,6 +1927,8 @@ on_error:
PJ_DEF(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
int *playback_dev)
{
+ PJSUA_LOCK();
+
if (capture_dev) {
*capture_dev = pjsua_var.cap_dev;
}
@@ -1927,6 +1936,7 @@ PJ_DEF(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
*playback_dev = pjsua_var.play_dev;
}
+ PJSUA_UNLOCK();
return PJ_SUCCESS;
}
@@ -1942,6 +1952,7 @@ PJ_DEF(pj_status_t) pjsua_set_null_snd_dev(void)
PJ_LOG(4,(THIS_FILE, "Setting null sound device.."));
pj_log_push_indent();
+ PJSUA_LOCK();
/* Close existing sound device */
close_snd_dev();
@@ -1969,6 +1980,7 @@ PJ_DEF(pj_status_t) pjsua_set_null_snd_dev(void)
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to create null sound device",
status);
+ PJSUA_UNLOCK();
pj_log_pop_indent();
return status;
}
@@ -1983,6 +1995,7 @@ PJ_DEF(pj_status_t) pjsua_set_null_snd_dev(void)
pjsua_var.no_snd = PJ_FALSE;
pjsua_var.snd_is_on = PJ_TRUE;
+ PJSUA_UNLOCK();
pj_log_pop_indent();
return PJ_SUCCESS;
}
@@ -1994,10 +2007,14 @@ PJ_DEF(pj_status_t) pjsua_set_null_snd_dev(void)
*/
PJ_DEF(pjmedia_port*) pjsua_set_no_snd_dev(void)
{
+ PJSUA_LOCK();
+
/* Close existing sound device */
close_snd_dev();
-
pjsua_var.no_snd = PJ_TRUE;
+
+ PJSUA_UNLOCK();
+
return pjmedia_conf_get_master_port(pjsua_var.mconf);
}
@@ -2007,13 +2024,18 @@ PJ_DEF(pjmedia_port*) pjsua_set_no_snd_dev(void)
*/
PJ_DEF(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options)
{
+ pj_status_t status = PJ_SUCCESS;
+
+ PJSUA_LOCK();
+
pjsua_var.media_cfg.ec_tail_len = tail_ms;
if (pjsua_var.snd_port)
- return pjmedia_snd_port_set_ec( pjsua_var.snd_port, pjsua_var.pool,
- tail_ms, options);
+ status = pjmedia_snd_port_set_ec(pjsua_var.snd_port, pjsua_var.pool,
+ tail_ms, options);
- return PJ_SUCCESS;
+ PJSUA_UNLOCK();
+ return status;
}
@@ -2050,6 +2072,8 @@ PJ_DEF(pj_status_t) pjsua_snd_set_setting( pjmedia_aud_dev_cap cap,
return PJMEDIA_EAUD_INVCAP;
}
+ PJSUA_LOCK();
+
/* If sound is active, set it immediately */
if (pjsua_snd_is_active()) {
pjmedia_aud_stream *strm;
@@ -2060,8 +2084,10 @@ PJ_DEF(pj_status_t) pjsua_snd_set_setting( pjmedia_aud_dev_cap cap,
status = PJ_SUCCESS;
}
- if (status != PJ_SUCCESS)
+ if (status != PJ_SUCCESS) {
+ PJSUA_UNLOCK();
return status;
+ }
/* Save in internal param for later device open */
if (keep) {
@@ -2069,6 +2095,7 @@ PJ_DEF(pj_status_t) pjsua_snd_set_setting( pjmedia_aud_dev_cap cap,
cap, pval);
}
+ PJSUA_UNLOCK();
return status;
}
@@ -2078,6 +2105,10 @@ PJ_DEF(pj_status_t) pjsua_snd_set_setting( pjmedia_aud_dev_cap cap,
PJ_DEF(pj_status_t) pjsua_snd_get_setting( pjmedia_aud_dev_cap cap,
void *pval)
{
+ pj_status_t status;
+
+ PJSUA_LOCK();
+
/* If sound device has never been opened before, open it to
* retrieve the initial setting from the device (e.g. audio
* volume)
@@ -2093,12 +2124,15 @@ PJ_DEF(pj_status_t) pjsua_snd_get_setting( pjmedia_aud_dev_cap cap,
pjmedia_aud_stream *strm;
strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
- return pjmedia_aud_stream_get_cap(strm, cap, pval);
+ status = pjmedia_aud_stream_get_cap(strm, cap, pval);
} else {
/* Otherwise retrieve from internal param */
- return pjmedia_aud_param_get_cap(&pjsua_var.aud_param,
- cap, pval);
+ status = pjmedia_aud_param_get_cap(&pjsua_var.aud_param,
+ cap, pval);
}
+
+ PJSUA_UNLOCK();
+ return status;
}
#endif /* PJSUA_MEDIA_HAS_PJMEDIA */
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 6a4e4dc7..6f0d1048 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -2929,12 +2929,10 @@ static void pjsua_call_on_state_changed(pjsip_inv_session *inv,
pjsua_call *call;
pj_log_push_indent();
- PJSUA_LOCK();
call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
if (!call) {
- PJSUA_UNLOCK();
pj_log_pop_indent();
return;
}
@@ -3077,21 +3075,21 @@ static void pjsua_call_on_state_changed(pjsip_inv_session *inv,
/* Destroy media session when invite session is disconnected. */
if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
- pj_assert(call != NULL);
-
- if (call)
- pjsua_media_channel_deinit(call->index);
+ PJSUA_LOCK();
+
+ pjsua_media_channel_deinit(call->index);
/* Free call */
call->inv = NULL;
+
+ pj_assert(pjsua_var.call_cnt > 0);
--pjsua_var.call_cnt;
/* Reset call */
reset_call(call->index);
+ PJSUA_UNLOCK();
}
-
- PJSUA_UNLOCK();
pj_log_pop_indent();
}
@@ -3202,7 +3200,6 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv,
//const pj_str_t st_update = {"UPDATE", 6};
pj_log_push_indent();
- PJSUA_LOCK();
call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
@@ -3279,7 +3276,6 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv,
pjsua_var.ua_cfg.cb.on_call_media_state(call->index);
on_return:
- PJSUA_UNLOCK();
pj_log_pop_indent();
}
@@ -3392,8 +3388,6 @@ static void pjsua_call_on_rx_offer(pjsip_inv_session *inv,
unsigned i;
pj_status_t status;
- PJSUA_LOCK();
-
call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
/* Supply candidate answer */
@@ -3480,7 +3474,6 @@ static void pjsua_call_on_rx_offer(pjsip_inv_session *inv,
}
on_return:
- PJSUA_UNLOCK();
pj_log_pop_indent();
}
@@ -3495,7 +3488,6 @@ static void pjsua_call_on_create_offer(pjsip_inv_session *inv,
pj_status_t status;
pj_log_push_indent();
- PJSUA_LOCK();
call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
@@ -3520,7 +3512,6 @@ static void pjsua_call_on_create_offer(pjsip_inv_session *inv,
}
on_return:
- PJSUA_UNLOCK();
pj_log_pop_indent();
}
@@ -3983,7 +3974,6 @@ static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv,
pjsua_call *call;
pj_log_push_indent();
- PJSUA_LOCK();
call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
@@ -3999,6 +3989,17 @@ static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv,
goto on_return;
}
+ /* https://trac.pjsip.org/repos/ticket/1452:
+ * If a request is retried due to 401/407 challenge, don't process the
+ * transaction first but wait until we've retried it.
+ */
+ if (tsx->role == PJSIP_ROLE_UAC &&
+ (tsx->status_code==401 || tsx->status_code==407) &&
+ tsx->last_tx && tsx->last_tx->auth_retry)
+ {
+ goto on_return;
+ }
+
/* Notify application callback first */
if (pjsua_var.ua_cfg.cb.on_call_tsx_state) {
(*pjsua_var.ua_cfg.cb.on_call_tsx_state)(call->index, tsx, e);
@@ -4124,8 +4125,6 @@ static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv,
}
on_return:
-
- PJSUA_UNLOCK();
pj_log_pop_indent();
}
@@ -4139,7 +4138,6 @@ static pjsip_redirect_op pjsua_call_on_redirected(pjsip_inv_session *inv,
pjsip_redirect_op op;
pj_log_push_indent();
- PJSUA_LOCK();
if (pjsua_var.ua_cfg.cb.on_call_redirected) {
op = (*pjsua_var.ua_cfg.cb.on_call_redirected)(call->index,
@@ -4152,7 +4150,6 @@ static pjsip_redirect_op pjsua_call_on_redirected(pjsip_inv_session *inv,
op = PJSIP_REDIRECT_STOP;
}
- PJSUA_UNLOCK();
pj_log_pop_indent();
return op;
diff --git a/pjsip/src/pjsua-lib/pjsua_dump.c b/pjsip/src/pjsua-lib/pjsua_dump.c
index 7279e512..c629e106 100644
--- a/pjsip/src/pjsua-lib/pjsua_dump.c
+++ b/pjsip/src/pjsua-lib/pjsua_dump.c
@@ -413,7 +413,6 @@ static void dump_media_session(const char *indent,
const char *type2 = pj_ice_get_cand_type_name(ii->comp[jj].rcand_type);
char addr1[PJ_INET6_ADDRSTRLEN+10];
char addr2[PJ_INET6_ADDRSTRLEN+10];
- const char *comp_name[2] = {"rtp ", "rtcp"};
if (pj_sockaddr_has_addr(&ii->comp[jj].lcand_addr))
pj_sockaddr_print(&ii->comp[jj].lcand_addr, addr1, sizeof(addr1), 3);
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 2810a24b..56e5bce2 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -97,8 +97,8 @@ pj_status_t pjsua_media_subsys_init(const pjsua_media_config *cfg)
goto on_error;
#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
- /* Initialize SRTP library. */
- status = pjmedia_srtp_init_lib();
+ /* Initialize SRTP library (ticket #788). */
+ status = pjmedia_srtp_init_lib(pjsua_var.med_endpt);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error initializing SRTP library",
status);