diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c index 100631f345..aad68e15d1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c @@ -326,9 +326,11 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ ftdm_set_ton(val, &span->default_caller_data.rdnis.type); } else if (!strcasecmp(var, "outbound-rdnis-npi")) { ftdm_set_npi(val, &span->default_caller_data.rdnis.plan); - } else if (!strcasecmp(var, "outbound-bearer_cap")) { + } else if (!strcasecmp(var, "outbound-bearer_cap") || + !strcasecmp(var, "outbound-bc-transfer-cap")) { ftdm_set_bearer_capability(val, (uint8_t*)&span->default_caller_data.bearer_capability); - } else if (!strcasecmp(var, "outbound-bearer_layer1")) { + } else if (!strcasecmp(var, "outbound-bearer_layer1") || + !strcasecmp(var, "outbound-bc-user-layer1")) { ftdm_set_bearer_layer1(val, (uint8_t*)&span->default_caller_data.bearer_layer1); } else if (!strcasecmp(var, "channel-restart-on-link-up")) { parse_yesno(var, val, &signal_data->restart_opt); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 8f01290407..eb5e2ad1ae 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -3627,7 +3627,7 @@ SWITCH_STANDARD_API(sofia_function) "--------------------------------------------------------------------------------\n" "sofia help\n" "sofia profile [[start|stop|restart|rescan]|" - "flush_inbound_reg [] [reboot]|" + "flush_inbound_reg [|<[user]@domain>] [reboot]|" "[register|unregister] [|all]|" "killgw |" "[stun-auto-disable|stun-enabled] [true|false]]|" diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index bf7c1aa7a1..dfd6a76974 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -70,7 +70,7 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t * port = tech_pvt->proxy_sdp_audio_port; } } - + if (!port) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%s NO PORT!\n", switch_channel_get_name(tech_pvt->channel)); return; @@ -377,6 +377,13 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 sofia_glue_check_dtmf_type(tech_pvt); + if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) || + ((val = switch_channel_get_variable(tech_pvt->channel, "supress_cng")) && switch_true(val)) || + ((val = switch_channel_get_variable(tech_pvt->channel, "suppress_cng")) && switch_true(val))) { + use_cng = 0; + tech_pvt->cng_pt = 0; + } + if (!tech_pvt->payload_space) { int i; @@ -388,6 +395,13 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 tech_pvt->ianacodes[i] = imp->ianacode; if (tech_pvt->ianacodes[i] > 64) { + if (tech_pvt->dtmf_type == DTMF_2833 && tech_pvt->te > 95 && tech_pvt->te == tech_pvt->payload_space) { + tech_pvt->payload_space++; + } + if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && + tech_pvt->cng_pt && use_cng && tech_pvt->cng_pt == tech_pvt->payload_space) { + tech_pvt->payload_space++; + } tech_pvt->ianacodes[i] = tech_pvt->payload_space++; } } @@ -401,13 +415,6 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32 verbose_sdp = 1; } - if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) || - ((val = switch_channel_get_variable(tech_pvt->channel, "supress_cng")) && switch_true(val)) || - ((val = switch_channel_get_variable(tech_pvt->channel, "suppress_cng")) && switch_true(val))) { - use_cng = 0; - tech_pvt->cng_pt = 0; - } - if (!force && !ip && !sr && (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) || switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA))) { return; @@ -4040,7 +4047,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s sdp_attribute_t *attr; int first = 0, last = 0; int ptime = 0, dptime = 0, maxptime = 0, dmaxptime = 0; - int sendonly = 0; + int sendonly = 0, recvonly = 0; int greedy = 0, x = 0, skip = 0, mine = 0; switch_channel_t *channel = switch_core_session_get_channel(session); const char *val; @@ -4108,6 +4115,19 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s if (!strcasecmp(attr->a_name, "sendonly") || !strcasecmp(attr->a_name, "inactive")) { sendonly = 1; + switch_channel_set_variable(tech_pvt->channel, "media_audio_mode", "recvonly"); + } else if (!strcasecmp(attr->a_name, "recvonly")) { + switch_channel_set_variable(tech_pvt->channel, "media_audio_mode", "sendonly"); + recvonly = 1; + + if (switch_rtp_ready(tech_pvt->rtp_session)) { + switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, 0); + tech_pvt->max_missed_hold_packets = 0; + tech_pvt->max_missed_packets = 0; + } else { + switch_channel_set_variable(tech_pvt->channel, "rtp_timeout_sec", "0"); + switch_channel_set_variable(tech_pvt->channel, "rtp_hold_timeout_sec", "0"); + } } else if (sendonly < 2 && !strcasecmp(attr->a_name, "sendrecv")) { sendonly = 0; } else if (!strcasecmp(attr->a_name, "ptime")) { @@ -4117,6 +4137,11 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s } } + if (sendonly != 1 && recvonly != 1) { + switch_channel_set_variable(tech_pvt->channel, "media_audio_mode", NULL); + } + + if (sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_HOLD) || ((val = switch_channel_get_variable(tech_pvt->channel, "sip_disable_hold")) && switch_true(val))) { sendonly = 0; diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 344e51774d..f644ff772b 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -606,16 +606,16 @@ void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,rpid,expires" ",user_agent,server_user,server_host,profile_name,network_ip" ",%d from sip_registrations where call_id='%q' %s", reboot, call_id, sqlextra); - switch_safe_free(sqlextra); switch_mutex_lock(profile->ireg_mutex); sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile); switch_mutex_unlock(profile->ireg_mutex); switch_safe_free(sql); - sql = switch_mprintf("delete from sip_registrations where call_id='%q' or (sip_user='%q' and sip_host='%q')", call_id, user, host); + sql = switch_mprintf("delete from sip_registrations where call_id='%q' %s", call_id, sqlextra); sofia_glue_execute_sql_now(profile, &sql, SWITCH_FALSE); + switch_safe_free(sqlextra); switch_safe_free(sql); switch_safe_free(dup); diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index d17105a465..d156c700fd 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -1705,6 +1705,16 @@ static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void * switch_channel_get_state(_peer) == CS_RESET || \ !switch_channel_test_flag(_peer, CF_ORIGINATING))) +static void wait_for_cause(switch_channel_t *channel) +{ + int sanity = 5; + + while (--sanity > 0 && peer_eligible(channel) && switch_channel_get_cause(channel) == SWITCH_CAUSE_NONE) { + switch_yield(10000); + } +} + + SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session, switch_core_session_t **bleg, @@ -3271,7 +3281,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (i != oglobals.idx) { holding = NULL; - + if (oglobals.idx == IDX_TIMEOUT || to) { reason = SWITCH_CAUSE_NO_ANSWER; } else { @@ -3280,6 +3290,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } else { if (and_argc > 1) { reason = SWITCH_CAUSE_LOSE_RACE; + } else if (!switch_channel_ready(originate_status[i].peer_channel)) { + wait_for_cause(originate_status[i].peer_channel); + if (switch_channel_down(originate_status[i].peer_channel)) { + reason = switch_channel_get_cause(originate_status[i].peer_channel); + } } else { reason = SWITCH_CAUSE_NO_ANSWER; } @@ -3385,6 +3400,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } if (peer_channel) { + wait_for_cause(peer_channel); *cause = switch_channel_get_cause(peer_channel); } else { for (i = 0; i < and_argc; i++) { @@ -3435,6 +3451,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess *cause = switch_channel_get_cause(caller_channel); } else { *cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + for (i = 0; i < and_argc; i++) { + if (!peer_eligible(originate_status[i].peer_channel)) { + continue; + } + + wait_for_cause(originate_status[i].peer_channel); + + if (switch_channel_down(originate_status[i].peer_channel)) { + *cause = switch_channel_get_cause(originate_status[i].peer_channel); + break; + } + + } } } @@ -3529,7 +3558,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess continue; } pchannel = switch_core_session_get_channel(originate_status[i].peer_session); - + wait_for_cause(pchannel); if (switch_channel_down(pchannel)) { cause_str = switch_channel_cause2str(switch_channel_get_cause(pchannel)); if (switch_stristr(cause_str, fail_on_single_reject_var)) {