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

View File

@ -621,16 +621,16 @@
/* Define to the function return type for send. */
#undef SEND_TYPE_RETV
/* The size of a `curl_off_t', as computed by sizeof. */
/* The size of `curl_off_t', as computed by sizeof. */
#undef SIZEOF_CURL_OFF_T
/* The size of a `long', as computed by sizeof. */
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of a `size_t', as computed by sizeof. */
/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
/* The size of a `time_t', as computed by sizeof. */
/* The size of `time_t', as computed by sizeof. */
#undef SIZEOF_TIME_T
/* Define to 1 if you have the ANSI C header files. */
@ -685,7 +685,7 @@
/* type to use in place of in_addr_t if not defined */
#undef in_addr_t
/* Define to `unsigned' if <sys/types.h> does not define. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* type to use in place of socklen_t if not defined */

View File

@ -1,40 +1,150 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id: mkinstalldirs,v 1.2 2000/01/10 23:36:14 bagder Exp $
scriptversion=2004-02-15.20
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain.
#
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
errstatus=0
dirmode=""
usage="\
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
Create each directory DIR (with mode MODE, if specified), including all
leading file name components.
Report bugs to <bug-automake@gnu.org>."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage"
exit 0
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--version)
echo "$0 $scriptversion"
exit 0
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
if test -d "$file"; then
shift
else
break
fi
done
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
case $# in
0) exit 0 ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error. This is a problem when calling mkinstalldirs
# from a parallel make. We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
'')
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version
fi
;;
*)
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
test ! -d ./--version; then
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
else
# Clean up after NextStep and OpenStep mkdir.
for d in ./-m ./-p ./--version "./$dirmode";
do
test -d $d && rmdir $d
done
fi
;;
esac
mkdir "$pathcomp" || lasterr=$?
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
pathcomp="$pathcomp/"
done
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=""
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

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),

View File

@ -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);

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;

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);

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;

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);

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))) {

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);
}

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);

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);
}

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);
}