diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index cc68a60a3d..cabda97184 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2114,6 +2114,9 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session tech_pvt->dest_to = tech_pvt->dest; } + switch_channel_set_flag(nchannel, CF_OUTBOUND); + switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); + sofia_glue_attach_private(nsession, profile, tech_pvt, dest); if (tech_pvt->local_url) { @@ -2127,8 +2130,6 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session caller_profile = switch_caller_profile_clone(nsession, outbound_profile); caller_profile->destination_number = switch_core_strdup(caller_profile->pool, dest); switch_channel_set_caller_profile(nchannel, caller_profile); - switch_channel_set_flag(nchannel, CF_OUTBOUND); - switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION); if (switch_channel_get_state(nchannel) == CS_NEW) { switch_channel_set_state(nchannel, CS_INIT); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index f481ecc8b5..b15e1a8b16 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -413,7 +413,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t * tech_pvt->dtmf_type = profile->dtmf_type; - if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG)) { + if (switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) && !(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG)) { if (tech_pvt->bcng_pt) { tech_pvt->cng_pt = tech_pvt->bcng_pt; } else if (!tech_pvt->cng_pt) {