diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index d079787a59..d9399a357f 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -1843,6 +1843,12 @@ static pj_status_t call_media_init_cb(pjsua_call_media *call_med, goto on_return; } + /* Check if media is deinitializing */ + if (call_med->call->async_call.med_ch_deinit || !call_med->tp) { + status = PJ_ECANCELLED; + goto on_return; + } + pjmedia_transport_simulate_lost(call_med->tp, PJMEDIA_DIR_ENCODING, pjsua_var.media_cfg.tx_drop_pct);