these aren't the droids you're looking for....

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5115 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2007-05-09 19:44:15 +00:00
parent 2f6798fdb8
commit d6efffd9bc
13 changed files with 200 additions and 63 deletions
+3 -2
View File
@@ -95,6 +95,7 @@ SWITCH_BEGIN_EXTERN_C
#define SWITCH_PATH_SEPARATOR "/"
#endif
#define SWITCH_URL_SEPARATOR "://"
#define SWITCH_BYPASS_MEDIA_VARIABLE "bypass_media"
#define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition"
#define SWITCH_HOLD_MUSIC_VARIABLE "hold_music"
#define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
@@ -544,7 +545,7 @@ CF_SERVICE = (1 << 9) - Channel has a service thread
CF_TAGGED = (1 << 10) - Channel is tagged
CF_WINNER = (1 << 11) - Channel is the winner
CF_CONTROLLED = (1 << 12) - Channel is under control
CF_NOMEDIA = (1 << 13) - Channel has no media
CF_BYPASS_MEDIA = (1 << 13) - Channel has no media
CF_SUSPEND = (1 << 14) - Suspend i/o
CF_EVENT_PARSE = (1 << 15) - Suspend control events
CF_REPEAT_STATE = (1 << 16) - Tell the state machine to repeat a state
@@ -571,7 +572,7 @@ typedef enum {
CF_TAGGED = (1 << 10),
CF_WINNER = (1 << 11),
CF_CONTROLLED = (1 << 12),
CF_NOMEDIA = (1 << 13),
CF_BYPASS_MEDIA = (1 << 13),
CF_SUSPEND = (1 << 14),
CF_EVENT_PARSE = (1 << 15),
CF_REPEAT_STATE = (1 << 16),
@@ -61,11 +61,11 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
do_continue = switch_true(var);
}
if (switch_channel_test_flag(caller_channel, CF_NOMEDIA)
|| ((var = switch_channel_get_variable(caller_channel, "no_media")) && switch_true(var))) {
if (switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA)
|| ((var = switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_VARIABLE)) && switch_true(var))) {
if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
&& !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
switch_channel_set_flag(caller_channel, CF_NOMEDIA);
switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying point-to-point mode 'till both legs are up.\n");
no_media_bridge = 1;
@@ -107,7 +107,7 @@ static void audio_bridge_function(switch_core_session_t *session, char *data)
switch_ivr_nomedia(switch_core_session_get_uuid(peer_session), SMF_FORCE);
switch_ivr_signal_bridge(session, peer_session);
} else {
if (switch_channel_test_flag(caller_channel, CF_NOMEDIA)) {
if (switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA)) {
switch_ivr_signal_bridge(session, peer_session);
} else {
switch_ivr_multi_threaded_bridge(session, peer_session, NULL, NULL, NULL);
+1 -1
View File
@@ -102,7 +102,7 @@ static void bcast_function(switch_core_session_t *session, char *data)
}
if (switch_true(switch_channel_get_variable(channel, "no_media"))) {
if (switch_true(switch_channel_get_variable(channel, SWITCH_BYPASS_MEDIA_VARIABLE))) {
switch_core_session_message_t msg = { 0 };
ready = SEND_TYPE_NOMEDIA;
+2 -2
View File
@@ -431,7 +431,7 @@ SWITCH_DECLARE(switch_bool_t) switch_channel_set_flag_partner(switch_channel_t *
assert(channel != NULL);
if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))) {
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
switch_core_session_t *session;
if ((session = switch_core_session_locate(uuid))) {
switch_channel_set_flag(switch_core_session_get_channel(session), flags);
@@ -449,7 +449,7 @@ SWITCH_DECLARE(switch_bool_t) switch_channel_clear_flag_partner(switch_channel_t
assert(channel != NULL);
if ((uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))) {
if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
switch_core_session_t *session;
if ((session = switch_core_session_locate(uuid))) {
switch_channel_clear_flag(switch_core_session_get_channel(session), flags);
+4 -3
View File
@@ -296,8 +296,8 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
switch_channel_set_variable(peer_channel, SWITCH_MAX_FORWARDS_VARIABLE, val);
}
if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
switch_channel_set_flag(peer_channel, CF_NOMEDIA);
if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
switch_channel_set_flag(peer_channel, CF_BYPASS_MEDIA);
}
if (profile) {
@@ -606,6 +606,7 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session)
switch_ivr_deactivate_unicast(session);
switch_channel_clear_flag(channel, CF_BREAK);
}
@@ -996,7 +997,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_se
goto done;
}
if (switch_channel_test_flag(session->channel, CF_NOMEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
if (switch_channel_test_flag(session->channel, CF_BYPASS_MEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Application %s Cannot be used with NO_MEDIA mode!\n",
extension->current_application->application_name);
status = SWITCH_STATUS_FALSE;
+1 -1
View File
@@ -129,7 +129,7 @@ static void switch_core_standard_on_execute(switch_core_session_t *session)
return;
}
if (switch_channel_test_flag(session->channel, CF_NOMEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
if (switch_channel_test_flag(session->channel, CF_BYPASS_MEDIA) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Application %s Cannot be used with NO_MEDIA mode!\n",
extension->current_application->application_name);
switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+22 -6
View File
@@ -271,7 +271,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
unsigned long CMD_HANGUP = switch_hashfunc_default("hangup", &hlen);
unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen);
unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen);
char *lead_frames = switch_event_get_header(event, "lead-frames");
assert(channel != NULL);
assert(event != NULL);
@@ -285,6 +286,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
switch_channel_set_flag(channel, CF_EVENT_PARSE);
if (lead_frames) {
switch_frame_t *read_frame;
int frame_count = atoi(lead_frames);
switch_status_t status;
while(frame_count > 0) {
status = switch_core_session_read_frame(session, &read_frame, -1, 0);
if (!SWITCH_READ_ACCEPTABLE(status)) {
return status;
}
if (!switch_test_flag(read_frame, SFF_CNG)) {
frame_count--;
}
}
}
if (cmd_hash == CMD_EXECUTE) {
const switch_application_interface_t *application_interface;
@@ -304,7 +320,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
switch_channel_set_flag(channel, CF_BROADCAST);
for (x = 0; x < loops || loops < 0; x++) {
switch_core_session_exec(session, application_interface, app_arg);
if (!switch_channel_test_flag(channel, CF_BROADCAST)) {
if (!switch_channel_ready(channel) || !switch_channel_test_flag(channel, CF_BROADCAST)) {
break;
}
}
@@ -718,9 +734,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(char *uuid, switch_media_flag_t
swap = 1;
}
if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
status = SWITCH_STATUS_SUCCESS;
switch_channel_clear_flag(channel, CF_NOMEDIA);
switch_channel_clear_flag(channel, CF_BYPASS_MEDIA);
switch_core_session_receive_message(session, &msg);
if ((flags & SMF_REBRIDGE)
@@ -773,8 +789,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(char *uuid, switch_media_flag
swap = 1;
}
if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_NOMEDIA)) {
switch_channel_set_flag(channel, CF_NOMEDIA);
if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
switch_core_session_receive_message(session, &msg);
if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
(other_session = switch_core_session_locate(other_uuid))) {
+5 -3
View File
@@ -779,10 +779,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
if ((nomedia = switch_channel_test_flag(channel, CF_NOMEDIA))) {
if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
switch_ivr_media(uuid, SMF_REBRIDGE);
}
if ((p = strchr(mypath, ':'))) {
app = mypath;
*p++ = '\0';
@@ -802,10 +802,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
if ((flags & SMF_LOOP)) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
}
switch_core_session_queue_private_event(other_session, &event);
}
@@ -819,6 +820,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
if ((flags & SMF_LOOP)) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
}
+14 -7
View File
@@ -52,7 +52,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
switch_input_callback_function_t input_callback;
switch_core_session_message_t *message, msg = { 0 };
void *user_data;
switch_channel_t *chan_a, *chan_b;
switch_frame_t *read_frame;
switch_core_session_t *session_a, *session_b;
@@ -81,7 +80,7 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
switch_channel_state_t b_state;
switch_status_t status;
switch_event_t *event;
/* if you really want to make sure it's not ready, test it twice because it might be just a break */
if (!switch_channel_ready(chan_a) && !switch_channel_ready(chan_a)) {
break;
@@ -97,12 +96,24 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
break;
}
if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
switch_yield(100000);
continue;
}
if (switch_core_session_dequeue_private_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
switch_channel_set_flag(chan_b, CF_SUSPEND);
msg.string_arg = data->b_uuid;
msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
msg.from = __FILE__;
switch_core_session_receive_message(session_a, &msg);
switch_ivr_parse_event(session_a, event);
msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
switch_core_session_receive_message(session_a, &msg);
switch_channel_clear_flag(chan_b, CF_SUSPEND);
switch_event_destroy(&event);
}
/* if 1 channel has DTMF pass it to the other */
if (switch_channel_has_dtmf(chan_a)) {
@@ -154,11 +165,6 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
}
if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
switch_yield(10000);
continue;
}
/* read audio from 1 channel and write it to the other */
status = switch_core_session_read_frame(session_a, &read_frame, -1, stream_id);
@@ -180,6 +186,7 @@ static void *audio_bridge_thread(switch_thread_t * thread, void *obj)
msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
msg.from = __FILE__;
switch_core_session_receive_message(session_a, &msg);
switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL);
+3 -3
View File
@@ -607,7 +607,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
if (session && (read_codec = switch_core_session_get_read_codec(session)) &&
(ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
(ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) {
if (!(pass = (uint8_t) switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
if (switch_core_codec_init(&write_codec,
@@ -713,7 +713,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
/* read from the channel while we wait if the audio is up on it */
if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA)) &&
if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA)) &&
(switch_channel_test_flag(caller_channel, CF_ANSWERED)
|| switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA))) {
switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
@@ -777,7 +777,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
idx = IDX_CANCEL;
}
if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_NOMEDIA))) {
if (session && (ringback_data || !switch_channel_test_flag(caller_channel, CF_BYPASS_MEDIA))) {
switch_core_session_reset(session);
}
+3 -3
View File
@@ -375,7 +375,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_s
done:
if (status != SWITCH_STATUS_SUCCESS) {
rtp_session->ready = 0;
rtp_session->ready = 1;
}
if (new_sock) {
@@ -817,7 +817,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
switch_status_t status;
uint8_t check = 1;
stfu_frame_t *jb_frame;
if (!rtp_session->timer.interval) {
rtp_session->last_time = switch_time_now();
}
@@ -825,7 +825,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
while (switch_rtp_ready(rtp_session)) {
bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *) &rtp_session->recv_msg, &bytes);
if (!SWITCH_STATUS_IS_BREAK(status) && rtp_session->timer.interval) {
switch_core_timer_step(&rtp_session->timer);
}