sofia_dispatch_event_t *de = *dep;
switch_memory_pool_t *pool;
//sofia_profile_t *profile = (*dep)->profile;
- switch_thread_data_t *td;
+
switch_core_new_memory_pool(&pool);
*dep = NULL;
de->pool = pool;
- td = switch_core_alloc(pool, sizeof(*td));
- td->func = sofia_msg_thread_run_once;
- td->obj = de;
- switch_thread_pool_launch_thread(&td);
}
switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) {
- switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE|SMF_REPLYONLY_B);
+ switch_ivr_3p_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE|SMF_REPLYONLY_B);
} else {
- switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE);
+ switch_ivr_3p_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE);
}
case nua_callstate_received:
tech_pvt->recv_invites++;
tech_pvt->sent_last_invite = 0;
+
if (!sofia_test_flag(tech_pvt, TFLAG_SDP)) {
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
goto done;
}
}
+
if (r_sdp && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
is_t38 = 1;
}
+
if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if ((sofia_test_media_flag(profile, SCMF_DISABLE_HOLD)
|| ((var = switch_channel_get_variable(channel, "rtp_disable_hold")) && switch_true(var)))
int media_on_hold = switch_true(switch_channel_get_variable_dup(channel, "bypass_media_resume_on_hold", SWITCH_FALSE, -1));
switch_core_media_clear_rtp_flag(other_session, SWITCH_MEDIA_TYPE_AUDIO, SWITCH_RTP_FLAG_AUTOADJ);
+
if (switch_channel_test_flag(channel, CF_PROXY_MODE) && !is_t38 &&
((profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) || media_on_hold)) {
switch_core_media_clear_rtp_flag(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, SWITCH_RTP_FLAG_AUTOADJ);
if (!switch_channel_media_ready(channel)) {
- if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) {
+ //if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) {
//const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
status = SWITCH_STATUS_FALSE;
switch_core_session_rwunlock(other_session);
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
goto done;
}
- }
+ //}
}
goto done;
}
}
+
switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 1);
if (sofia_use_soa(tech_pvt)) {
}
}
- other_tech_pvt = switch_core_session_get_private(other_session);
- if(sofia_test_flag(other_tech_pvt, TFLAG_REINVITED)) {
+ other_tech_pvt = switch_core_session_get_private(other_session);
+
+ if (sofia_test_flag(other_tech_pvt, TFLAG_REINVITED)) {
/* The other leg won the reinvite race */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Other leg already handling reinvite, so responding with 491\n");
nua_respond(tech_pvt->nh, SIP_491_REQUEST_PENDING, TAG_END());
}
}
-
+
if (is_ok) {
if (switch_core_session_local_crypto_key(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_gen_local_sdp(session, SDP_TYPE_RESPONSE, NULL, 0, NULL, 0);
}
- if (sofia_use_soa(tech_pvt)) {
- nua_respond(tech_pvt->nh, SIP_200_OK,
- SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
- SOATAG_USER_SDP_STR(tech_pvt->mparams.local_sdp_str),
- SOATAG_REUSE_REJECTED(1),
- SOATAG_AUDIO_AUX("cn telephone-event"),
- TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
- } else {
- nua_respond(tech_pvt->nh, SIP_200_OK,
- NUTAG_MEDIA_ENABLE(0),
- SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
- SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->mparams.local_sdp_str), TAG_END());
- }
+
+ nua_respond(tech_pvt->nh, SIP_200_OK,
+ NUTAG_MEDIA_ENABLE(0),
+ SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
+ SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->mparams.local_sdp_str), TAG_END());
+
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REINVITE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));
switch_event_fire(&s_event);
if (session) {
channel = switch_core_session_get_channel(session);
tech_pvt = switch_core_session_get_private(session);
+
+
+ if (sip->sip_payload && sip->sip_payload->pl_data) {
+ tech_pvt->mparams.last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data);
+ }
}
if (session && profile && sip && sofia_test_pflag(profile, PFLAG_TRACK_CALLS)) {
uint8_t new_ice;
uint8_t new_dtls;
uint32_t sdp_bw;
+ uint8_t reject_avp;
} switch_rtp_engine_t;
struct switch_media_handle_s {
v_engine->new_ice = 1;
a_engine->new_dtls = 1;
a_engine->new_ice = 1;
-
+ a_engine->reject_avp = 0;
+
switch_core_session_parse_crypto_prefs(session);
clear_pmaps(a_engine);
/* do nothing here, mod_fax will trigger a response (if it's listening =/) */
match = 1;
goto done;
+ } else if (m->m_type == sdp_media_audio && m->m_port && got_audio && got_savp) {
+ a_engine->reject_avp = 1;
} else if (m->m_type == sdp_media_audio && m->m_port && !got_audio) {
sdp_rtpmap_t *map;
int ice = 0;
if (b_channel && (switch_channel_test_flag(session->channel, CF_BYPASS_MEDIA_AFTER_HOLD) ||
switch_channel_test_flag(b_channel, CF_BYPASS_MEDIA_AFTER_HOLD) || bypass_after_hold_a || bypass_after_hold_b)) {
/* try to stay out from media stream */
- switch_ivr_nomedia(switch_core_session_get_uuid(session), SMF_REBRIDGE);
+ switch_ivr_bg_media(switch_core_session_get_uuid(session), SMF_REBRIDGE, SWITCH_FALSE, SWITCH_TRUE, 200);
}
if (a_engine->max_missed_packets && a_engine->rtp_session) {
//switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=encryption:optional\r\n");
}
+ if (a_engine->reject_avp) {
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "m=audio 0 RTP/AVP 19\r\n");
+ }
+
} else if (smh->mparams->num_codecs) {
int i;
int cur_ptime = 0, this_ptime = 0, cng_type = 0;
return SWITCH_STATUS_SUCCESS;
}
+
+
+
+
SWITCH_DECLARE(switch_status_t) switch_ivr_3p_media(const char *uuid, switch_media_flag_t flags)
{
const char *other_uuid = NULL;
if (!switch_core_session_in_thread(session)) {
switch_channel_set_state(channel, CS_PARK);
}
+
switch_channel_set_state(other_channel, CS_PARK);
+
if (switch_core_session_in_thread(session)) {
switch_yield(100000);
} else {
msg.from = __FILE__;
if ((session = switch_core_session_locate(uuid))) {
+
status = SWITCH_STATUS_SUCCESS;
channel = switch_core_session_get_channel(session);
return status;
}
+typedef struct {
+ switch_memory_pool_t *pool;
+ const char *uuid;
+ switch_media_flag_t flags;
+ switch_bool_t on;
+ switch_bool_t is3p;
+ uint32_t delay;
+} media_job_t;
+
+static void *SWITCH_THREAD_FUNC media_thread_run(switch_thread_t *thread, void *obj)
+{
+ media_job_t *job = (media_job_t *) obj;
+
+ if (job->delay) {
+ switch_yield(job->delay * 1000);
+ }
+
+ if (job->on) {
+ if (job->is3p) {
+ switch_ivr_3p_media(job->uuid, job->flags);
+ } else {
+ switch_ivr_media(job->uuid, job->flags);
+ }
+ } else {
+ if (job->is3p) {
+ switch_ivr_3p_nomedia(job->uuid, job->flags);
+ } else {
+ switch_ivr_nomedia(job->uuid, job->flags);
+ }
+ }
+
+ return NULL;
+}
+
+
+SWITCH_DECLARE(void) switch_ivr_bg_media(const char *uuid, switch_media_flag_t flags, switch_bool_t on, switch_bool_t is3p, uint32_t delay)
+{
+ switch_thread_data_t *td;
+ switch_memory_pool_t *pool;
+ media_job_t *job;
+
+ switch_core_new_memory_pool(&pool);
+ td = switch_core_alloc(pool, sizeof(*td));
+ job = switch_core_alloc(pool, sizeof(*job));
+ td->func = media_thread_run;
+ job->pool = pool;
+ job->uuid = switch_core_strdup(pool, uuid);
+ job->flags = flags;
+ job->on = on;
+ job->is3p = is3p;
+ job->delay = delay;
+ td->obj = job;
+ td->pool = pool;
+ switch_thread_pool_launch_thread(&td);
+
+}
+
+
SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, const char *extension, const char *dialplan,
const char *context)
{
/* reset temp hold music */
switch_channel_set_variable(channel, SWITCH_TEMP_HOLD_MUSIC_VARIABLE, NULL);
+ switch_channel_execute_on(channel, "execute_on_blind_transfer");
+
if ((profile = switch_channel_get_caller_profile(channel))) {
const char *var;