*/
#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
\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
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
}
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:
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) {
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;
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();
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;
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);
}
int pindex = -1;
char bug_key[256] = "";
int send_ringback = 0;
+ uint32_t ring_ready_val = 0;
oglobals->hups = 0;
oglobals->idx = IDX_NADA;
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) {
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;
}
}
}
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;
}