update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6971 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
6cd5f4de00
commit
d14909d41d
|
@ -84,7 +84,7 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
|
|||
|
||||
tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SOFIA INIT\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA INIT\n", switch_channel_get_name(channel));
|
||||
if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
|
||||
sofia_glue_tech_absorb_sdp(tech_pvt);
|
||||
}
|
||||
|
@ -112,7 +112,47 @@ static switch_status_t sofia_on_ring(switch_core_session_t *session)
|
|||
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SOFIA RING\n");
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RING\n", switch_channel_get_name(channel));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t sofia_on_reset(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_object_t *tech_pvt = NULL;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(channel));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t sofia_on_hibernate(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_object_t *tech_pvt = NULL;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
|
||||
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(channel));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -128,7 +168,8 @@ static switch_status_t sofia_on_execute(switch_core_session_t *session)
|
|||
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SOFIA EXECUTE\n");
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n", switch_channel_get_name(channel));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -206,7 +247,10 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
|||
switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_audio_port);
|
||||
}
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
|
||||
cause = switch_channel_get_cause(channel);
|
||||
|
||||
#if 0
|
||||
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
|
||||
const char *buuid;
|
||||
switch_core_session_t *bsession;
|
||||
switch_channel_t *bchannel;
|
||||
|
@ -232,8 +276,8 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
|||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
cause = switch_channel_get_cause(channel);
|
||||
sip_cause = hangup_cause_to_sip(cause);
|
||||
|
||||
sofia_glue_deactivate_rtp(tech_pvt);
|
||||
|
@ -1495,7 +1539,10 @@ switch_state_handler_table_t sofia_event_handlers = {
|
|||
/*.on_execute */ sofia_on_execute,
|
||||
/*.on_hangup */ sofia_on_hangup,
|
||||
/*.on_loopback */ sofia_on_loopback,
|
||||
/*.on_transmit */ sofia_on_transmit
|
||||
/*.on_transmit */ sofia_on_transmit,
|
||||
/*.on_hold */ NULL,
|
||||
/*.on_hibernate*/ sofia_on_hibernate,
|
||||
/*.on_reset*/ sofia_on_reset
|
||||
};
|
||||
|
||||
static switch_status_t sofia_manage(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
|
||||
|
|
|
@ -1462,6 +1462,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
|||
if (br_b) {
|
||||
switch_ivr_uuid_bridge(br_a, br_b);
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
|
||||
} else {
|
||||
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
|
||||
|
@ -1763,6 +1764,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
|
||||
NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
|
||||
|
||||
switch_clear_flag_locked(b_tech_pvt, TFLAG_SIP_HOLD);
|
||||
switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER);
|
||||
} else {
|
||||
if (!br_a && !br_b) {
|
||||
|
@ -1786,8 +1788,11 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
t_session = switch_core_session_locate(br_a);
|
||||
hup_channel = channel_b;
|
||||
} else {
|
||||
private_object_t *h_tech_pvt = (private_object_t *) switch_core_session_get_private(b_session);
|
||||
t_session = switch_core_session_locate(br_b);
|
||||
hup_channel = channel_a;
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
|
||||
switch_clear_flag_locked(h_tech_pvt, TFLAG_SIP_HOLD);
|
||||
switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER);
|
||||
}
|
||||
|
||||
|
@ -1936,8 +1941,9 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
struct private_object *tech_pvt = NULL;
|
||||
switch_channel_t *channel = NULL;
|
||||
/* placeholder for string searching */
|
||||
char *signal_ptr;
|
||||
const char *signal_ptr;
|
||||
const char *rec_header;
|
||||
switch_dtmf_t dtmf = { 0, SWITCH_DEFAULT_DTMF_DURATION };
|
||||
|
||||
if (session) {
|
||||
/* Get the channel */
|
||||
|
@ -1952,37 +1958,20 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
/* Barf if we didn't get it */
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
|
||||
if (sip && sip->sip_payload && sip->sip_payload->pl_data) {
|
||||
switch_dtmf_t dtmf = { 0, SWITCH_DEFAULT_DTMF_DURATION };
|
||||
|
||||
if (sip && sip->sip_content_type && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype &&
|
||||
sip->sip_payload && sip->sip_payload->pl_data) {
|
||||
if (!strcasecmp(sip->sip_content_type->c_type, "dtmf") && !strcasecmp(sip->sip_content_type->c_subtype, "relay")) {
|
||||
/* Try and find signal information in the payload */
|
||||
if ((signal_ptr = strstr(sip->sip_payload->pl_data, "Signal="))) {
|
||||
if ((signal_ptr = switch_stristr("Signal=", sip->sip_payload->pl_data))) {
|
||||
/* move signal_ptr where we need it (right past Signal=) */
|
||||
signal_ptr = signal_ptr + 7;
|
||||
dtmf.digit = *signal_ptr;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bad signal\n");
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* unknown info type */
|
||||
if (!signal_ptr) {
|
||||
sip_from_t const *from = sip->sip_from;
|
||||
|
||||
/* print in the logs if something comes through we don't understand */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown INFO Recieved: %s%s" URL_PRINT_FORMAT "[%s]\n",
|
||||
from->a_display ? from->a_display : "",
|
||||
from->a_display ? " " : "",
|
||||
URL_PRINT_ARGS(from->a_url),
|
||||
sip->sip_payload->pl_data);
|
||||
/* Send 415 Unsupported Media response */
|
||||
nua_respond(nh, SIP_415_UNSUPPORTED_MEDIA, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
dtmf.digit = *signal_ptr;
|
||||
if ((signal_ptr = strstr(sip->sip_payload->pl_data, "Duration="))) {
|
||||
if ((signal_ptr = switch_stristr("Duration=", sip->sip_payload->pl_data))) {
|
||||
int tmp;
|
||||
signal_ptr += 8;
|
||||
if ((tmp = atoi(signal_ptr)) < 0) {
|
||||
|
@ -1990,7 +1979,13 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
}
|
||||
dtmf.duration = tmp;
|
||||
}
|
||||
} else if (!strcasecmp(sip->sip_content_type->c_type, "application") && !strcasecmp(sip->sip_content_type->c_subtype, "dtmf")) {
|
||||
dtmf.digit = *sip->sip_payload->pl_data;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (dtmf.digit) {
|
||||
/* queue it up */
|
||||
switch_channel_queue_dtmf(channel, &dtmf);
|
||||
|
||||
|
@ -2001,6 +1996,9 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
|
||||
|
||||
return;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if ((rec_header = sofia_glue_get_unknown_header(sip, "record"))) {
|
||||
|
@ -2037,6 +2035,13 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
|
||||
nua_respond(nh, 488, "Unsupported Request", NUTAG_WITH_THIS(nua), TAG_END());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue