|
|
|
@ -208,6 +208,8 @@ struct pj_ice_strans
|
|
|
|
|
|
|
|
|
|
pj_ice_strans_state state; /**< Session state. */
|
|
|
|
|
pj_ice_sess *ice; /**< ICE session. */
|
|
|
|
|
pj_ice_sess *ice_prev; /**< Previous ICE session. */
|
|
|
|
|
pj_grp_lock_handler ice_prev_hndlr; /**< Handler of prev ICE */
|
|
|
|
|
pj_time_val start_time;/**< Time when ICE was started */
|
|
|
|
|
|
|
|
|
|
unsigned comp_cnt; /**< Number of components. */
|
|
|
|
@ -985,6 +987,12 @@ static void ice_st_on_destroy(void *obj)
|
|
|
|
|
{
|
|
|
|
|
pj_ice_strans *ice_st = (pj_ice_strans*)obj;
|
|
|
|
|
|
|
|
|
|
/* Destroy any previous ICE session */
|
|
|
|
|
if (ice_st->ice_prev) {
|
|
|
|
|
(*ice_st->ice_prev_hndlr)(ice_st->ice_prev);
|
|
|
|
|
ice_st->ice_prev = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PJ_LOG(4,(ice_st->obj_name, "ICE stream transport %p destroyed", obj));
|
|
|
|
|
|
|
|
|
|
/* Done */
|
|
|
|
@ -1016,8 +1024,9 @@ static void destroy_ice_st(pj_ice_strans *ice_st)
|
|
|
|
|
|
|
|
|
|
/* Destroy ICE if we have ICE */
|
|
|
|
|
if (ice_st->ice) {
|
|
|
|
|
pj_ice_sess_destroy(ice_st->ice);
|
|
|
|
|
pj_ice_sess *ice = ice_st->ice;
|
|
|
|
|
ice_st->ice = NULL;
|
|
|
|
|
pj_ice_sess_destroy(ice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Destroy all components */
|
|
|
|
@ -1279,6 +1288,15 @@ PJ_DEF(pj_status_t) pj_ice_strans_init_ice(pj_ice_strans *ice_st,
|
|
|
|
|
ice_cb.on_rx_data = &ice_rx_data;
|
|
|
|
|
ice_cb.on_tx_pkt = &ice_tx_pkt;
|
|
|
|
|
|
|
|
|
|
/* Release the pool of previous ICE session to avoid memory bloat,
|
|
|
|
|
* as otherwise it will only be released after ICE strans is destroyed
|
|
|
|
|
* (due to group lock).
|
|
|
|
|
*/
|
|
|
|
|
if (ice_st->ice_prev) {
|
|
|
|
|
(*ice_st->ice_prev_hndlr)(ice_st->ice_prev);
|
|
|
|
|
ice_st->ice_prev = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create! */
|
|
|
|
|
status = pj_ice_sess_create(&ice_st->cfg.stun_cfg, ice_st->obj_name, role,
|
|
|
|
|
ice_st->comp_cnt, &ice_cb,
|
|
|
|
@ -1726,8 +1744,10 @@ PJ_DEF(pj_status_t) pj_ice_strans_stop_ice(pj_ice_strans *ice_st)
|
|
|
|
|
pj_grp_lock_acquire(ice_st->grp_lock);
|
|
|
|
|
|
|
|
|
|
if (ice_st->ice) {
|
|
|
|
|
pj_ice_sess_destroy(ice_st->ice);
|
|
|
|
|
ice_st->ice_prev = ice_st->ice;
|
|
|
|
|
ice_st->ice = NULL;
|
|
|
|
|
pj_ice_sess_detach_grp_lock(ice_st->ice_prev, &ice_st->ice_prev_hndlr);
|
|
|
|
|
pj_ice_sess_destroy(ice_st->ice_prev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ice_st->state = PJ_ICE_STRANS_STATE_INIT;
|
|
|
|
|