Fixed issues when adding new media and deinitializing media (#3821)
This commit is contained in:
parent
19c018affd
commit
f2055ef7a3
|
@ -772,6 +772,7 @@ void pjsua_ice_check_start_trickling(pjsua_call *call,
|
|||
pj_bool_t pjsua_call_media_is_changing(pjsua_call *call);
|
||||
pj_status_t pjsua_call_media_init(pjsua_call_media *call_med,
|
||||
pjmedia_type type,
|
||||
const pjmedia_sdp_session *rem_sdp,
|
||||
const pjsua_transport_config *tcfg,
|
||||
int security_level,
|
||||
int *sip_err_code,
|
||||
|
|
|
@ -1929,14 +1929,14 @@ PJ_DEF(pj_status_t) pjsua_destroy2(unsigned flags)
|
|||
/* Terminate all calls. */
|
||||
if ((flags & PJSUA_DESTROY_NO_TX_MSG) == 0) {
|
||||
pjsua_call_hangup_all();
|
||||
}
|
||||
|
||||
/* Deinit media channel of all calls (see #1717) */
|
||||
for (i=0; i<(int)pjsua_var.ua_cfg.max_calls; ++i) {
|
||||
/* TODO: check if we're not allowed to send to network in the
|
||||
* "flags", and if so do not do TURN allocation...
|
||||
*/
|
||||
pjsua_media_channel_deinit(i);
|
||||
} else {
|
||||
/* Deinit media channel of all calls (see #1717) */
|
||||
for (i=0; i<(int)pjsua_var.ua_cfg.max_calls; ++i) {
|
||||
/* TODO: check if we're not allowed to send to network in the
|
||||
* "flags", and if so do not do TURN allocation...
|
||||
*/
|
||||
pjsua_media_channel_deinit(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set all accounts to offline */
|
||||
|
|
|
@ -246,9 +246,9 @@ pj_status_t pjsua_media_subsys_destroy(unsigned flags)
|
|||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
static int get_media_ip_version(pjsua_call_media *call_med)
|
||||
static int get_media_ip_version(pjsua_call_media *call_med,
|
||||
const pjmedia_sdp_session *rem_sdp)
|
||||
{
|
||||
pjmedia_sdp_session *rem_sdp = call_med->call->async_call.rem_sdp;
|
||||
pjsua_ipv6_use ipv6_use;
|
||||
|
||||
ipv6_use = pjsua_var.acc[call_med->call->acc_id].cfg.ipv6_media_use;
|
||||
|
@ -287,7 +287,8 @@ static int get_media_ip_version(pjsua_call_media *call_med)
|
|||
*/
|
||||
static pj_status_t create_rtp_rtcp_sock(pjsua_call_media *call_med,
|
||||
const pjsua_transport_config *cfg,
|
||||
pjmedia_sock_info *skinfo)
|
||||
pjmedia_sock_info *skinfo,
|
||||
const pjmedia_sdp_session *rem_sdp)
|
||||
{
|
||||
enum {
|
||||
RTP_RETRY = 100
|
||||
|
@ -302,7 +303,7 @@ static pj_status_t create_rtp_rtcp_sock(pjsua_call_media *call_med,
|
|||
pjsua_acc *acc = &pjsua_var.acc[call_med->call->acc_id];
|
||||
pj_sock_t sock[2];
|
||||
|
||||
use_ipv6 = (get_media_ip_version(call_med) == 6);
|
||||
use_ipv6 = (get_media_ip_version(call_med, rem_sdp) == 6);
|
||||
use_nat64 = (acc->cfg.nat64_opt != PJSUA_NAT64_DISABLED);
|
||||
af = (use_ipv6 || use_nat64) ? pj_AF_INET6() : pj_AF_INET();
|
||||
|
||||
|
@ -705,12 +706,13 @@ on_error:
|
|||
|
||||
/* Create normal UDP media transports */
|
||||
static pj_status_t create_udp_media_transport(const pjsua_transport_config *cfg,
|
||||
pjsua_call_media *call_med)
|
||||
pjsua_call_media *call_med,
|
||||
const pjmedia_sdp_session *rem_sdp)
|
||||
{
|
||||
pjmedia_sock_info skinfo;
|
||||
pj_status_t status;
|
||||
|
||||
status = create_rtp_rtcp_sock(call_med, cfg, &skinfo);
|
||||
status = create_rtp_rtcp_sock(call_med, cfg, &skinfo, rem_sdp);
|
||||
if (status != PJ_SUCCESS) {
|
||||
pjsua_perror(THIS_FILE, "Unable to create RTP/RTCP socket",
|
||||
status);
|
||||
|
@ -745,7 +747,8 @@ on_error:
|
|||
/* Create loop media transport */
|
||||
static pj_status_t create_loop_media_transport(
|
||||
const pjsua_transport_config *cfg,
|
||||
pjsua_call_media *call_med)
|
||||
pjsua_call_media *call_med,
|
||||
const pjmedia_sdp_session *rem_sdp)
|
||||
{
|
||||
pj_status_t status;
|
||||
pjmedia_loop_tp_setting opt;
|
||||
|
@ -753,7 +756,7 @@ static pj_status_t create_loop_media_transport(
|
|||
int af;
|
||||
pjsua_acc *acc = &pjsua_var.acc[call_med->call->acc_id];
|
||||
|
||||
use_ipv6 = (get_media_ip_version(call_med) == 6);
|
||||
use_ipv6 = (get_media_ip_version(call_med, rem_sdp) == 6);
|
||||
use_nat64 = (acc->cfg.nat64_opt != PJSUA_NAT64_DISABLED);
|
||||
af = (use_ipv6 || use_nat64) ? pj_AF_INET6() : pj_AF_INET();
|
||||
|
||||
|
@ -996,6 +999,7 @@ static void on_ice_complete(pjmedia_transport *tp,
|
|||
static pj_status_t create_ice_media_transport(
|
||||
const pjsua_transport_config *cfg,
|
||||
pjsua_call_media *call_med,
|
||||
const pjmedia_sdp_session *remote_sdp,
|
||||
pj_bool_t async)
|
||||
{
|
||||
char stunip[PJ_INET6_ADDRSTRLEN];
|
||||
|
@ -1010,7 +1014,7 @@ static pj_status_t create_ice_media_transport(
|
|||
pjmedia_sdp_session *rem_sdp;
|
||||
|
||||
acc_cfg = &pjsua_var.acc[call_med->call->acc_id].cfg;
|
||||
use_ipv6 = (get_media_ip_version(call_med) == 6);
|
||||
use_ipv6 = (get_media_ip_version(call_med, remote_sdp) == 6);
|
||||
use_nat64 = (acc_cfg->nat64_opt != PJSUA_NAT64_DISABLED);
|
||||
|
||||
/* Make sure STUN server resolution has completed */
|
||||
|
@ -1984,6 +1988,7 @@ pj_bool_t pjsua_call_media_is_changing(pjsua_call *call)
|
|||
/* Initialize the media line */
|
||||
pj_status_t pjsua_call_media_init(pjsua_call_media *call_med,
|
||||
pjmedia_type type,
|
||||
const pjmedia_sdp_session *rem_sdp,
|
||||
const pjsua_transport_config *tcfg,
|
||||
int security_level,
|
||||
int *sip_err_code,
|
||||
|
@ -2027,9 +2032,10 @@ pj_status_t pjsua_call_media_init(pjsua_call_media *call_med,
|
|||
pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_CREATING);
|
||||
|
||||
if (acc->cfg.use_loop_med_tp) {
|
||||
status = create_loop_media_transport(tcfg, call_med);
|
||||
status = create_loop_media_transport(tcfg, call_med, rem_sdp);
|
||||
} else if (acc->cfg.ice_cfg.enable_ice) {
|
||||
status = create_ice_media_transport(tcfg, call_med, async);
|
||||
status = create_ice_media_transport(tcfg, call_med, rem_sdp,
|
||||
async);
|
||||
if (async && status == PJ_EPENDING) {
|
||||
/* We will resume call media initialization in the
|
||||
* on_ice_complete() callback.
|
||||
|
@ -2040,7 +2046,7 @@ pj_status_t pjsua_call_media_init(pjsua_call_media *call_med,
|
|||
return PJ_EPENDING;
|
||||
}
|
||||
} else {
|
||||
status = create_udp_media_transport(tcfg, call_med);
|
||||
status = create_udp_media_transport(tcfg, call_med, rem_sdp);
|
||||
}
|
||||
|
||||
if (status != PJ_SUCCESS) {
|
||||
|
@ -2516,15 +2522,17 @@ pj_status_t pjsua_media_channel_init(pjsua_call_id call_id,
|
|||
PJ_LOG(4,(THIS_FILE, "Call %d: setting media direction "
|
||||
"#%d to %d.", call_id, mi,
|
||||
call_med->def_dir));
|
||||
} else if (!reinit) {
|
||||
/* Initialize default initial media direction as bidirectional */
|
||||
} else if (!reinit || mi >= call->med_cnt) {
|
||||
/* Initialize default media direction as bidirectional,
|
||||
* for initial media or newly added media.
|
||||
*/
|
||||
call_med->def_dir = PJMEDIA_DIR_ENCODING_DECODING;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
call_med->enable_rtcp_mux = acc->cfg.enable_rtcp_mux;
|
||||
|
||||
status = pjsua_call_media_init(call_med, media_type,
|
||||
status = pjsua_call_media_init(call_med, media_type, rem_sdp,
|
||||
&acc->cfg.rtp_cfg,
|
||||
security_level, sip_err_code,
|
||||
async,
|
||||
|
|
|
@ -2088,7 +2088,7 @@ static pj_status_t call_add_video(pjsua_call *call,
|
|||
|
||||
/* Initialize call media */
|
||||
call_med = &call->media_prov[call->med_prov_cnt++];
|
||||
status = pjsua_call_media_init(call_med, PJMEDIA_TYPE_VIDEO,
|
||||
status = pjsua_call_media_init(call_med, PJMEDIA_TYPE_VIDEO, NULL,
|
||||
&acc_cfg->rtp_cfg, call->secure_level,
|
||||
NULL, PJ_FALSE, NULL);
|
||||
if (status != PJ_SUCCESS)
|
||||
|
@ -2134,6 +2134,7 @@ static pj_status_t call_add_video(pjsua_call *call,
|
|||
|
||||
pjmedia_sdp_media_add_attr(sdp_m, a);
|
||||
}
|
||||
call_med->def_dir = dir;
|
||||
|
||||
/* Update SDP media line by media transport */
|
||||
status = pjmedia_transport_encode_sdp(call_med->tp, pool,
|
||||
|
@ -2237,7 +2238,7 @@ static pj_status_t call_modify_video(pjsua_call *call,
|
|||
call->opt.vid_cnt++;
|
||||
}
|
||||
|
||||
status = pjsua_call_media_init(call_med, PJMEDIA_TYPE_VIDEO,
|
||||
status = pjsua_call_media_init(call_med, PJMEDIA_TYPE_VIDEO, NULL,
|
||||
&acc_cfg->rtp_cfg, call->secure_level,
|
||||
NULL, PJ_FALSE, NULL);
|
||||
if (status != PJ_SUCCESS)
|
||||
|
|
Loading…
Reference in New Issue