MODENDP-310

This commit is contained in:
Anthony Minessale 2010-06-15 15:48:12 -05:00
parent bc2b4795c1
commit 3c688a95f8
6 changed files with 89 additions and 34 deletions

View File

@ -380,20 +380,26 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
*/
#define switch_channel_mark_pre_answered(channel) switch_channel_perform_mark_pre_answered(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line);
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready_value(switch_channel_t *channel,
switch_ring_ready_t rv,
const char *file, const char *func, int line);
/*!
\brief Send Ringing message to a channel
\param channel channel to ring
\return SWITCH_STATUS_SUCCESS if successful
*/
#define switch_channel_ring_ready(channel) switch_channel_perform_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_channel_ring_ready(channel) switch_channel_perform_ring_ready_value(channel, SWITCH_RING_READY_RINGING, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_channel_ring_ready_value(channel, _rv) \
switch_channel_perform_ring_ready_value(channel, _rv, __FILE__, __SWITCH_FUNC__, __LINE__)
SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, const char *file, const char *func, int line);
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_channel_t *channel, const char *file, const char *func, int line);
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line);
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel,
switch_ring_ready_t rv,
const char *file, const char *func, int line);
/*!
\brief Indicate progress on a channel to attempt early media
@ -407,7 +413,11 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch
\param channel channel
\return SWITCH_STATUS_SUCCESS
*/
#define switch_channel_mark_ring_ready(channel) switch_channel_perform_mark_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_channel_mark_ring_ready(channel) \
switch_channel_perform_mark_ring_ready_value(channel, SWITCH_RING_READY_RINGING, __FILE__, __SWITCH_FUNC__, __LINE__)
#define switch_channel_mark_ring_ready_value(channel, _rv) \
switch_channel_perform_mark_ring_ready_value(channel, _rv, __FILE__, __SWITCH_FUNC__, __LINE__)
/*!
\brief add a state handler table to a given channel

View File

@ -934,6 +934,12 @@ typedef enum {
CS_NONE
} switch_channel_state_t;
typedef enum {
SWITCH_RING_READY_NONE,
SWITCH_RING_READY_RINGING,
SWITCH_RING_READY_QUEUED
} switch_ring_ready_t;
/*!
\enum switch_channel_flag_t

View File

@ -2007,29 +2007,54 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
}
break;
case SWITCH_MESSAGE_INDICATE_RINGING:
{
switch_ring_ready_t ring_ready_val = msg->numeric_arg;
if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
switch_channel_mark_ring_ready(channel);
status = SWITCH_STATUS_SUCCESS;
switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO,
"Pretending to send ringing. Not available for 3pcc calls\n");
goto end_lock;
}
if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
switch_channel_mark_ring_ready(channel);
status = SWITCH_STATUS_SUCCESS;
switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO,
"Pretending to send ringing. Not available for 3pcc calls\n");
goto end_lock;
}
if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) &&
!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
if (!switch_channel_test_flag(channel, CF_RING_READY) && !sofia_test_flag(tech_pvt, TFLAG_BYE) &&
!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
nua_respond(tech_pvt->nh, SIP_180_RINGING,
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_HEADER_STR(generate_pai_str(session)),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
switch_safe_free(extra_header);
switch_channel_mark_ring_ready(channel);
switch (ring_ready_val) {
case SWITCH_RING_READY_QUEUED:
nua_respond(tech_pvt->nh, SIP_182_QUEUED,
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_HEADER_STR(generate_pai_str(session)),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
break;
case SWITCH_RING_READY_RINGING:
default:
nua_respond(tech_pvt->nh, SIP_180_RINGING,
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_HEADER_STR(generate_pai_str(session)),
TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
break;
}
switch_safe_free(extra_header);
switch_channel_mark_ring_ready(channel);
}
}
break;
case SWITCH_MESSAGE_INDICATE_ANSWER:

View File

@ -4350,8 +4350,16 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
case nua_callstate_calling:
break;
case nua_callstate_proceeding:
if (status == 180) {
switch (status) {
case 180:
switch_channel_mark_ring_ready(channel);
break;
case 182:
switch_channel_mark_ring_ready_value(channel, SWITCH_RING_READY_QUEUED);
break;
default:
break;
}
if (r_sdp) {

View File

@ -2278,7 +2278,9 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
return channel->state;
}
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line)
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(switch_channel_t *channel,
switch_ring_ready_t rv,
const char *file, const char *func, int line)
{
const char *var;
char *app;
@ -2287,7 +2289,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch
if (!switch_channel_test_flag(channel, CF_RING_READY) && !switch_channel_test_flag(channel, CF_EARLY_MEDIA &&
!switch_channel_test_flag(channel, CF_ANSWERED))) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name);
switch_channel_set_flag(channel, CF_RING_READY);
switch_channel_set_flag_value(channel, CF_RING_READY, rv);
if (channel->caller_profile && channel->caller_profile->times) {
switch_mutex_lock(channel->profile_mutex);
channel->caller_profile->times->progress = switch_micro_time_now();
@ -2423,7 +2425,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
return status;
}
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line)
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready_value(switch_channel_t *channel, switch_ring_ready_t rv,
const char *file, const char *func, int line)
{
switch_core_session_message_t msg = { 0 };
switch_status_t status = SWITCH_STATUS_SUCCESS;
@ -2445,11 +2448,13 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel
if (!switch_channel_test_flag(channel, CF_OUTBOUND)) {
msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
msg.from = channel->name;
msg.numeric_arg = rv;
status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
}
if (status == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
switch_channel_perform_mark_ring_ready_value(channel, rv, file, func, line);
} else {
switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}

View File

@ -413,6 +413,7 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
int pindex = -1;
char bug_key[256] = "";
int send_ringback = 0;
uint32_t ring_ready_val = 0;
oglobals->hups = 0;
oglobals->idx = IDX_NADA;
@ -451,9 +452,9 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
continue;
}
if (switch_channel_test_flag(originate_status[i].peer_channel, CF_RING_READY)) {
if ((ring_ready_val = switch_channel_test_flag(originate_status[i].peer_channel, CF_RING_READY))) {
if (!originate_status[i].ring_ready) {
originate_status[i].ring_ready = 1;
originate_status[i].ring_ready = ring_ready_val;
}
if (oglobals->sending_ringback == 1) {
@ -461,13 +462,13 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
pindex = (uint32_t) i;
} else {
if (!oglobals->ring_ready) {
oglobals->ring_ready = 1;
oglobals->ring_ready = ring_ready_val;
if (caller_channel && !oglobals->ignore_ring_ready) {
if (len == 1) {
switch_channel_pass_callee_id(originate_status[0].peer_channel, caller_channel);
}
switch_channel_ring_ready(caller_channel);
oglobals->sent_ring = 1;
switch_channel_ring_ready_value(caller_channel, ring_ready_val);
oglobals->sent_ring = ring_ready_val;
}
}
}
@ -485,7 +486,7 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
pindex = (uint32_t) i;
} else if (!oglobals->sent_ring && oglobals->ignore_early_media == 2 && len == 1 && caller_channel && !oglobals->ignore_ring_ready) {
switch_channel_pass_callee_id(originate_status[0].peer_channel, caller_channel);
switch_channel_ring_ready(caller_channel);
//switch_channel_ring_ready(caller_channel);
oglobals->sent_ring = 1;
}