summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsua-lib/pjsua_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_core.c')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 362ed0cd..d19bb744 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -67,6 +67,10 @@ static void init_data()
pj_list_init(&pjsua_var.outbound_proxy);
pjsua_config_default(&pjsua_var.ua_cfg);
+
+ for (i=0; i<PJSUA_MAX_VID_WINS; ++i) {
+ pjsua_vid_win_reset(i);
+ }
}
@@ -103,10 +107,8 @@ PJ_DEF(void) pjsua_config_default(pjsua_config *cfg)
cfg->stun_ignore_failure = PJ_TRUE;
cfg->force_lr = PJ_TRUE;
cfg->enable_unsolicited_mwi = PJ_TRUE;
-#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
cfg->use_srtp = PJSUA_DEFAULT_USE_SRTP;
cfg->srtp_secure_signaling = PJSUA_DEFAULT_SRTP_SECURE_SIGNALING;
-#endif
cfg->hangup_forked_call = PJ_TRUE;
cfg->use_timer = PJSUA_SIP_TIMER_OPTIONAL;
@@ -177,11 +179,13 @@ PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
cfg->timer_setting = pjsua_var.ua_cfg.timer_setting;
cfg->ka_interval = 15;
cfg->ka_data = pj_str("\r\n");
-#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
+ cfg->max_audio_cnt = 1;
+ cfg->vid_cap_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV;
+ cfg->vid_rend_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV;
+ pjsua_transport_config_default(&cfg->rtp_cfg);
cfg->use_srtp = pjsua_var.ua_cfg.use_srtp;
cfg->srtp_secure_signaling = pjsua_var.ua_cfg.srtp_secure_signaling;
cfg->srtp_optional_dup_offer = pjsua_var.ua_cfg.srtp_optional_dup_offer;
-#endif
cfg->reg_retry_interval = PJSUA_REG_RETRY_INTERVAL;
cfg->contact_rewrite_method = PJSUA_CONTACT_REWRITE_METHOD;
cfg->use_rfc5626 = PJ_TRUE;
@@ -225,7 +229,6 @@ PJ_DEF(void) pjsua_media_config_default(pjsua_media_config *cfg)
cfg->turn_conn_type = PJ_TURN_TP_UDP;
}
-
/*****************************************************************************
* This is a very simple PJSIP module, whose sole purpose is to display
* incoming and outgoing messages to log. This module will have priority
@@ -380,6 +383,7 @@ static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata)
}
/* Get media socket info, make sure transport is ready */
+#if DISABLED_FOR_TICKET_1185
if (pjsua_var.calls[0].med_tp) {
pjmedia_transport_info_init(&tpinfo);
pjmedia_transport_get_info(pjsua_var.calls[0].med_tp, &tpinfo);
@@ -391,8 +395,9 @@ static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata)
pjsip_create_sdp_body(tdata->pool, sdp, &tdata->msg->body);
}
}
+#endif
- /* Send response statelessly */
+ /* Send response */
pjsip_get_response_addr(tdata->pool, rdata, &res_addr);
status = pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, tdata, NULL, NULL);
if (status != PJ_SUCCESS)
@@ -637,6 +642,10 @@ PJ_DEF(pj_status_t) pjsua_create(void)
pjsua_var.cap_dev = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV;
pjsua_var.play_dev = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV;
+ /* Set default video device ID */
+ pjsua_var.vcap_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV;
+ pjsua_var.vrdr_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV;
+
/* Init caching pool. */
pj_caching_pool_init(&pjsua_var.cp, NULL, 0);
@@ -661,6 +670,7 @@ PJ_DEF(pj_status_t) pjsua_create(void)
&pjsua_var.endpt);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
+ pjsua_set_state(PJSUA_STATE_CREATED);
return PJ_SUCCESS;
}
@@ -929,6 +939,8 @@ PJ_DEF(pj_status_t) pjsua_init( const pjsua_config *ua_cfg,
PJ_LOG(3,(THIS_FILE, "pjsua version %s for %s initialized",
pj_get_version(), pj_get_sys_info()->info.ptr));
+ pjsua_set_state(PJSUA_STATE_INIT);
+
return PJ_SUCCESS;
on_error:
@@ -1286,6 +1298,12 @@ PJ_DEF(pj_status_t) pjsua_destroy(void)
{
int i; /* Must be signed */
+ if (pjsua_var.state > PJSUA_STATE_NULL &&
+ pjsua_var.state < PJSUA_STATE_CLOSING)
+ {
+ pjsua_set_state(PJSUA_STATE_CLOSING);
+ }
+
/* Signal threads to quit: */
pjsua_var.thread_quit_flag = 1;
@@ -1448,6 +1466,8 @@ PJ_DEF(pj_status_t) pjsua_destroy(void)
pjsua_var.pool = NULL;
pj_caching_pool_destroy(&pjsua_var.cp);
+ pjsua_set_state(PJSUA_STATE_NULL);
+
PJ_LOG(4,(THIS_FILE, "PJSUA destroyed..."));
/* End logging */
@@ -1467,6 +1487,28 @@ PJ_DEF(pj_status_t) pjsua_destroy(void)
return PJ_SUCCESS;
}
+void pjsua_set_state(pjsua_state new_state)
+{
+ const char *state_name[] = {
+ "NULL",
+ "CREATED",
+ "INIT",
+ "STARTING",
+ "RUNNING",
+ "CLOSING"
+ };
+ pjsua_state old_state = pjsua_var.state;
+
+ pjsua_var.state = new_state;
+ PJ_LOG(4,(THIS_FILE, "PJSUA state changed: %s --> %s",
+ state_name[old_state], state_name[new_state]));
+}
+
+/* Get state */
+PJ_DEF(pjsua_state) pjsua_get_state(void)
+{
+ return pjsua_var.state;
+}
/**
* Application is recommended to call this function after all initialization
@@ -1479,6 +1521,8 @@ PJ_DEF(pj_status_t) pjsua_start(void)
{
pj_status_t status;
+ pjsua_set_state(PJSUA_STATE_STARTING);
+
status = pjsua_call_subsys_start();
if (status != PJ_SUCCESS)
return status;
@@ -1491,6 +1535,8 @@ PJ_DEF(pj_status_t) pjsua_start(void)
if (status != PJ_SUCCESS)
return status;
+ pjsua_set_state(PJSUA_STATE_RUNNING);
+
return PJ_SUCCESS;
}
@@ -2574,6 +2620,7 @@ PJ_DEF(void) pjsua_dump(pj_bool_t detail)
pjmedia_endpt_dump(pjsua_get_pjmedia_endpt());
PJ_LOG(3,(THIS_FILE, "Dumping media transports:"));
+#if DISABLED_FOR_TICKET_1185
for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) {
pjsua_call *call = &pjsua_var.calls[i];
pjmedia_transport_info tpinfo;
@@ -2590,6 +2637,7 @@ PJ_DEF(void) pjsua_dump(pj_bool_t detail)
pj_sockaddr_print(&tpinfo.sock_info.rtp_addr_name, addr_buf,
sizeof(addr_buf), 3)));
}
+#endif
pjsip_tsx_layer_dump(detail);
pjsip_ua_dump(detail);