diff options
author | Liong Sauw Ming <ming@teluu.com> | 2011-10-24 09:28:13 +0000 |
---|---|---|
committer | Liong Sauw Ming <ming@teluu.com> | 2011-10-24 09:28:13 +0000 |
commit | 2068f13bc42cf3a47374aa2765f82724a5782028 (patch) | |
tree | 29fbeaa152ab51e59b650c0d7cd83a38111e1ecc /pjsip/src/pjsua-lib/pjsua_core.c | |
parent | 1c72a42676e7aa0c2ae0734549050f738f3bdf02 (diff) |
Re #1395: Backport of PJSIP 1.x branch into PJSIP 2.0 trunk
* Backport of r3557:r3832
TODO: ticket #1268 (Option for automatic/manual sending of RTCP SDES/BYE for the stream) for video stream.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3841 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_core.c')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_core.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index 31133b2c..52054226 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -234,6 +234,7 @@ PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg) pj_list_init(&cfg->reg_hdr_list); pj_list_init(&cfg->sub_hdr_list); cfg->call_hold_type = PJSUA_CALL_HOLD_TYPE_DEFAULT; + cfg->register_on_acc_add = PJ_TRUE; } PJ_DEF(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg) @@ -1340,7 +1341,7 @@ pj_status_t resolve_stun_server(pj_bool_t wait) /* * Destroy pjsua. */ -PJ_DEF(pj_status_t) pjsua_destroy(void) +PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags) { int i; /* Must be signed */ @@ -1365,12 +1366,14 @@ PJ_DEF(pj_status_t) pjsua_destroy(void) if (pjsua_var.endpt) { unsigned max_wait; - PJ_LOG(4,(THIS_FILE, "Shutting down...")); + PJ_LOG(4,(THIS_FILE, "Shutting down, flags=%d...", flags)); pj_log_push_indent(); /* Terminate all calls. */ - pjsua_call_hangup_all(); + if ((flags & PJSUA_DESTROY_NO_TX_MSG) == 0) { + pjsua_call_hangup_all(); + } /* Set all accounts to offline */ for (i=0; i<(int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { @@ -1381,10 +1384,10 @@ PJ_DEF(pj_status_t) pjsua_destroy(void) } /* Terminate all presence subscriptions. */ - pjsua_pres_shutdown(); + pjsua_pres_shutdown(flags); /* Destroy media (to shutdown media transports etc) */ - pjsua_media_subsys_destroy(); + pjsua_media_subsys_destroy(flags); /* Wait for sometime until all publish client sessions are done * (ticket #364) @@ -1398,6 +1401,11 @@ PJ_DEF(pj_status_t) pjsua_destroy(void) max_wait = pjsua_var.acc[i].cfg.unpublish_max_wait_time_msec; } + /* No waiting if RX is disabled */ + if (flags & PJSUA_DESTROY_NO_RX_MSG) { + max_wait = 0; + } + /* Second stage, wait for unpublications to complete */ for (i=0; i<(int)(max_wait/50); ++i) { unsigned j; @@ -1427,7 +1435,8 @@ PJ_DEF(pj_status_t) pjsua_destroy(void) if (!pjsua_var.acc[i].valid) continue; - if (pjsua_var.acc[i].regc) { + if (pjsua_var.acc[i].regc && (flags & PJSUA_DESTROY_NO_TX_MSG)==0) + { pjsua_acc_set_registration(i, PJ_FALSE); } } @@ -1452,6 +1461,11 @@ PJ_DEF(pj_status_t) pjsua_destroy(void) max_wait = pjsua_var.acc[i].cfg.unreg_timeout; } + /* No waiting if RX is disabled */ + if (flags & PJSUA_DESTROY_NO_RX_MSG) { + max_wait = 0; + } + /* Second stage, wait for unregistrations to complete */ for (i=0; i<(int)(max_wait/50); ++i) { unsigned j; @@ -1472,8 +1486,9 @@ PJ_DEF(pj_status_t) pjsua_destroy(void) /* Wait for some time to allow unregistration and ICE/TURN * transports shutdown to complete: */ - if (i < 20) + if (i < 20 && (flags & PJSUA_DESTROY_NO_RX_MSG) == 0) { busy_sleep(1000 - i*50); + } PJ_LOG(4,(THIS_FILE, "Destroying...")); @@ -1560,6 +1575,12 @@ PJ_DEF(pjsua_state) pjsua_get_state(void) return pjsua_var.state; } +PJ_DEF(pj_status_t) pjsua_destroy(void) +{ + return pjsua_destroy2(0); +} + + /** * Application is recommended to call this function after all initialization * is done, so that the library can do additional checking set up |