git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4229 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-02-13 14:58:06 +00:00
parent dcb452bcf7
commit 9a870c5fb6
8 changed files with 59 additions and 56 deletions

View File

@ -301,16 +301,16 @@ 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__) #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_ringback(switch_channel_t *channel, SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel,
const char *file, const char *file,
const char *func, const char *func,
int line); int line);
/*! /*!
\brief Send Ringing message to a channel \brief Send Ringing message to a channel
\param channel channel to ring \param channel channel to ring
\return SWITCH_STATUS_SUCCESS if successful \return SWITCH_STATUS_SUCCESS if successful
*/ */
#define switch_channel_ringback(channel) switch_channel_perform_ringback(channel, __FILE__, __SWITCH_FUNC__, __LINE__) #define switch_channel_ring_ready(channel) switch_channel_perform_ring_ready(channel, __FILE__, __SWITCH_FUNC__, __LINE__)
SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel,

View File

@ -485,8 +485,8 @@ CF_CONTROLLED = (1 << 12) - Channel is under control
CF_NOMEDIA = (1 << 13) - Channel has no media CF_NOMEDIA = (1 << 13) - Channel has no media
CF_SUSPEND = (1 << 14) - Suspend i/o CF_SUSPEND = (1 << 14) - Suspend i/o
CF_EVENT_PARSE = (1 << 15) - Suspend control events CF_EVENT_PARSE = (1 << 15) - Suspend control events
CF_NO_INDICATE = (1 << 16) - Disable Indications CF_REPEAT_STATE = (1 << 16) - Tell the state machine to repeat a state
CF_REPEAT_STATE = (1 << 17) - Tell the state machine to repeat a state CF_GEN_RINGBACK = (1 << 17) - Channel is generating it's own ringback
CF_RING_READY = (1 << 18) - Channel is ready to send ringback CF_RING_READY = (1 << 18) - Channel is ready to send ringback
</pre> </pre>
*/ */
@ -508,8 +508,8 @@ typedef enum {
CF_NOMEDIA = (1 << 13), CF_NOMEDIA = (1 << 13),
CF_SUSPEND = (1 << 14), CF_SUSPEND = (1 << 14),
CF_EVENT_PARSE = (1 << 15), CF_EVENT_PARSE = (1 << 15),
CF_NO_INDICATE = (1 << 16), CF_REPEAT_STATE = (1 << 16),
CF_REPEAT_STATE = (1 << 17), CF_GEN_RINGBACK = (1 << 17),
CF_RING_READY = (1 << 18) CF_RING_READY = (1 << 18)
} switch_channel_flag_t; } switch_channel_flag_t;

View File

@ -63,12 +63,12 @@ static void detect_speech_function(switch_core_session_t *session, char *data)
} }
static void ringback_function(switch_core_session_t *session, char *data) static void ring_ready_function(switch_core_session_t *session, char *data)
{ {
switch_channel_t *channel; switch_channel_t *channel;
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
assert(channel != NULL); assert(channel != NULL);
switch_channel_ringback(channel); switch_channel_ring_ready(channel);
} }
static void queue_dtmf_function(switch_core_session_t *session, char *data) static void queue_dtmf_function(switch_core_session_t *session, char *data)
@ -538,11 +538,11 @@ static const switch_application_interface_t detect_speech_application_interface
/*.next */ &ivr_application_interface /*.next */ &ivr_application_interface
}; };
static const switch_application_interface_t ringback_application_interface = { static const switch_application_interface_t ring_ready_application_interface = {
/*.interface_name */ "ringback", /*.interface_name */ "ring_ready",
/*.application_function */ ringback_function, /*.application_function */ ring_ready_function,
/* long_desc */ "Indicate Ringback on a channel.", /* long_desc */ "Indicate Ring_Ready on a channel.",
/* short_desc */ "Indicate Ringback", /* short_desc */ "Indicate Ring_Ready",
/* syntax */ "", /* syntax */ "",
/*.next */ &detect_speech_application_interface /*.next */ &detect_speech_application_interface
}; };
@ -553,7 +553,7 @@ static const switch_application_interface_t unset_application_interface = {
/* long_desc */ "Unset a channel varaible for the channel calling the application.", /* long_desc */ "Unset a channel varaible for the channel calling the application.",
/* short_desc */ "Unset a channel varaible", /* short_desc */ "Unset a channel varaible",
/* syntax */ "<varname>", /* syntax */ "<varname>",
/*.next */ &ringback_application_interface /*.next */ &ring_ready_application_interface
}; };
static const switch_application_interface_t set_application_interface = { static const switch_application_interface_t set_application_interface = {

View File

@ -2810,25 +2810,27 @@ static void sip_i_state(int status,
break; break;
case nua_callstate_proceeding: case nua_callstate_proceeding:
if (channel) { if (channel) {
if (status == 180 && !(switch_channel_test_flag(channel, CF_NO_INDICATE))) { if (status == 180) {
switch_channel_mark_ring_ready(channel); switch_channel_mark_ring_ready(channel);
if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) { if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK)) {
if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) { if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
switch_core_session_message_t msg; if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING; switch_core_session_message_t msg;
msg.from = __FILE__; msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
switch_core_session_receive_message(other_session, &msg); msg.from = __FILE__;
switch_core_session_rwunlock(other_session); switch_core_session_receive_message(other_session, &msg);
} switch_core_session_rwunlock(other_session);
}
} else {
switch_core_session_message_t *msg; } else {
if ((msg = malloc(sizeof(*msg)))) { switch_core_session_message_t *msg;
memset(msg, 0, sizeof(*msg)); if ((msg = malloc(sizeof(*msg)))) {
msg->message_id = SWITCH_MESSAGE_INDICATE_RINGING; memset(msg, 0, sizeof(*msg));
msg->from = __FILE__; msg->message_id = SWITCH_MESSAGE_INDICATE_RINGING;
switch_core_session_queue_message(session, msg); msg->from = __FILE__;
switch_set_flag(msg, SCSMF_DYNAMIC); switch_core_session_queue_message(session, msg);
switch_set_flag(msg, SCSMF_DYNAMIC);
}
} }
} }
} }
@ -2837,12 +2839,13 @@ static void sip_i_state(int status,
if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) { if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
switch_channel_mark_pre_answered(channel); switch_channel_mark_pre_answered(channel);
if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) { if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK) &&
(uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
other_channel = switch_core_session_get_channel(other_session); other_channel = switch_core_session_get_channel(other_session);
if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) { if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, (char *)r_sdp); switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, (char *)r_sdp);
} }
switch_channel_pre_answer(other_channel); switch_channel_pre_answer(other_channel);
switch_core_session_rwunlock(other_session); switch_core_session_rwunlock(other_session);
} }

View File

@ -1063,10 +1063,10 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
return status; return status;
} }
SWITCH_DECLARE(switch_status_t) switch_channel_perform_ringback(switch_channel_t *channel, SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel,
const char *file, const char *file,
const char *func, const char *func,
int line) int line)
{ {
switch_core_session_message_t msg; switch_core_session_message_t msg;
char *uuid = switch_core_session_get_uuid(channel->session); char *uuid = switch_core_session_get_uuid(channel->session);
@ -1091,7 +1091,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ringback(switch_channel_t
status = switch_core_session_message_send(uuid, &msg); status = switch_core_session_message_send(uuid, &msg);
if (status == SWITCH_STATUS_SUCCESS) { if (status == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Ringback %s!\n", channel->name); switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
} }
return status; return status;

View File

@ -120,7 +120,7 @@ static int switch_console_process(char *cmd)
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
if (stream.data) { if (stream.data) {
if (switch_api_execute(cmd, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) { if (switch_api_execute(cmd, arg, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", stream.data); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", (char *)stream.data);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unknown Command: %s\n", cmd); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unknown Command: %s\n", cmd);
} }

View File

@ -2067,7 +2067,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
} else { } else {
if (!session->raw_read_buffer) { if (!session->raw_read_buffer) {
switch_size_t bytes = session->read_codec->implementation->bytes_per_frame; switch_size_t bytes = session->read_codec->implementation->bytes_per_frame;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engaging Read Buffer at %u bytes\n", bytes); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engaging Read Buffer at %u bytes\n", (uint32_t)bytes);
switch_buffer_create_dynamic(&session->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, 0); switch_buffer_create_dynamic(&session->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, 0);
} }
if (!switch_buffer_write(session->raw_read_buffer, read_frame->data, read_frame->datalen)) { if (!switch_buffer_write(session->raw_read_buffer, read_frame->data, read_frame->datalen)) {
@ -2321,9 +2321,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
if (!session->raw_write_buffer) { if (!session->raw_write_buffer) {
switch_size_t bytes = session->write_codec->implementation->bytes_per_frame; switch_size_t bytes = session->write_codec->implementation->bytes_per_frame;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Engaging Write Buffer at %u bytes to accomodate %u->%u\n", "Engaging Write Buffer at %u bytes to accomodate %u->%u\n",
bytes, (uint32_t)bytes,
write_frame->datalen, session->write_codec->implementation->bytes_per_frame); write_frame->datalen, session->write_codec->implementation->bytes_per_frame);
if ((status =switch_buffer_create_dynamic(&session->raw_write_buffer, if ((status =switch_buffer_create_dynamic(&session->raw_write_buffer,
bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_BLOCK_FRAMES,
bytes * SWITCH_BUFFER_START_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES,
@ -4132,7 +4132,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(char *console, const char **err
switch_core_sql_thread_launch(); switch_core_sql_thread_launch();
#endif #endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated memory pool. Sessions are %u bytes\n", sizeof(switch_core_session_t)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated memory pool. Sessions are %u bytes\n", (uint32_t)sizeof(switch_core_session_t));
switch_event_init(runtime.memory_pool); switch_event_init(runtime.memory_pool);
switch_rtp_init(runtime.memory_pool); switch_rtp_init(runtime.memory_pool);

View File

@ -1533,7 +1533,7 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
args.buflen = digit_buffer_length; args.buflen = digit_buffer_length;
//Play the file //Play the file
status = switch_ivr_play_file(session, NULL, prompt_audio_file, &args); status = switch_ivr_play_file(session, NULL, prompt_audio_file, &args);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "play gave up %s", digit_buffer); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "play gave up %s", (char *) digit_buffer);
//Make sure we made it out alive //Make sure we made it out alive
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
@ -1545,7 +1545,7 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
if (max_digits == 1 && status == SWITCH_STATUS_BREAK) { if (max_digits == 1 && status == SWITCH_STATUS_BREAK) {
//Check the digit if we have a regex //Check the digit if we have a regex
if (digits_regex != NULL) { if (digits_regex != NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking regex [%s] on [%s]\n", digits_regex, digit_buffer); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking regex [%s] on [%s]\n", digits_regex, (char *) digit_buffer);
//Make sure the digit is allowed //Make sure the digit is allowed
if (switch_regex_match(digit_buffer, digits_regex) == SWITCH_STATUS_SUCCESS) { if (switch_regex_match(digit_buffer, digits_regex) == SWITCH_STATUS_SUCCESS) {
@ -1586,7 +1586,7 @@ SWITCH_DECLARE(switch_status_t) switch_play_and_get_digits(switch_core_session_t
if (min_digits <= strlen(digit_buffer)) { if (min_digits <= strlen(digit_buffer)) {
//See if we need to test a regex //See if we need to test a regex
if (digits_regex != NULL) { if (digits_regex != NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking regex [%s] on [%s]\n", digits_regex, digit_buffer); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking regex [%s] on [%s]\n", digits_regex, (char *) digit_buffer);
//Test the regex //Test the regex
if (switch_regex_match(digit_buffer, digits_regex) == SWITCH_STATUS_SUCCESS) { if (switch_regex_match(digit_buffer, digits_regex) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Match found!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Match found!\n");
@ -2579,7 +2579,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
or_argc = switch_separate_string(data, '|', pipe_names, (sizeof(pipe_names) / sizeof(pipe_names[0]))); or_argc = switch_separate_string(data, '|', pipe_names, (sizeof(pipe_names) / sizeof(pipe_names[0])));
if (caller_channel && or_argc > 1 && !ringback_data) { if (caller_channel && or_argc > 1 && !ringback_data) {
switch_channel_ringback(caller_channel); switch_channel_ring_ready(caller_channel);
sent_ring = 1; sent_ring = 1;
} }
@ -2606,7 +2606,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
and_argc = switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0]))); and_argc = switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0])));
if (caller_channel && !sent_ring && and_argc > 1 && !ringback_data) { if (caller_channel && !sent_ring && and_argc > 1 && !ringback_data) {
switch_channel_ringback(caller_channel); switch_channel_ring_ready(caller_channel);
sent_ring = 1; sent_ring = 1;
} }
@ -2746,7 +2746,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if (caller_channel && !switch_channel_ready(caller_channel)) { if (caller_channel && !switch_channel_ready(caller_channel)) {
goto notready; goto notready;
} }
if ((time(NULL) - start) > (time_t)timelimit_sec) { if ((time(NULL) - start) > (time_t)timelimit_sec) {
to++; to++;
idx = IDX_CANCEL; idx = IDX_CANCEL;
@ -3839,11 +3839,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_event(switch_
if (parser->terminator == '\0') { if (parser->terminator == '\0') {
if (len > parser->maxlen) { if (len > parser->maxlen) {
parser->maxlen = len; parser->maxlen = len;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "max len %u\n",parser->maxlen); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "max len %u\n", (uint32_t) parser->maxlen);
} }
if (parser->minlen == 0 || len < parser->minlen) { if (parser->minlen == 0 || len < parser->minlen) {
parser->minlen = len; parser->minlen = len;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "min len %u\n",parser->minlen); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "min len %u\n", (uint32_t) parser->minlen);
} }
} else { } else {
// since we have a terminator, reset min and max // since we have a terminator, reset min and max