diff --git a/conf/autoload_configs/conference.conf.xml b/conf/autoload_configs/conference.conf.xml
index 19b7e25f37..5079b6a7bd 100644
--- a/conf/autoload_configs/conference.conf.xml
+++ b/conf/autoload_configs/conference.conf.xml
@@ -68,7 +68,7 @@
-
+
diff --git a/conf/dialplan/default.xml b/conf/dialplan/default.xml
index 05c7fb9d32..a5ba393a52 100644
--- a/conf/dialplan/default.xml
+++ b/conf/dialplan/default.xml
@@ -98,6 +98,7 @@
+
@@ -166,7 +167,7 @@
-
+
@@ -215,6 +216,13 @@
+
+
+
+
+
+
+
diff --git a/libs/libedit/configure b/libs/libedit/configure
index 1ecd349bee..8e2c8448dc 100755
--- a/libs/libedit/configure
+++ b/libs/libedit/configure
@@ -420,7 +420,7 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='libedit'
-PACKAGE_TARNAME='libedit-20071219'
+PACKAGE_TARNAME='libedit-20071230'
PACKAGE_VERSION='2.10'
PACKAGE_STRING='libedit 2.10'
PACKAGE_BUGREPORT=''
@@ -1816,7 +1816,7 @@ fi
# Define the identity of the package.
- PACKAGE='libedit-20071219'
+ PACKAGE='libedit-20071230'
VERSION='2.10'
diff --git a/scripts/socket/sock.pl b/scripts/socket/sock.pl
index 2bdb39339f..cf601363c3 100755
--- a/scripts/socket/sock.pl
+++ b/scripts/socket/sock.pl
@@ -22,7 +22,7 @@ print "Call: $data->{'caller-channel-name'} $data->{'unique-id'}\n";
$o = $fs->call_command("answer");
#to turn on events when in async mode
$o = $fs->raw_command("myevents");
-$o = $fs->call_command("playback", "/ram/swimp.raw");
+$o = $fs->call_command("echo");
#comment exit in async mode
@@ -38,6 +38,7 @@ while(my $r = $fs->readhash(undef)) {
}
if ($r->{event}->{'event-name'} !~ /execute/i) {
printf "wtf $data->{'unique-id'}\n";
+ print ".";
$o = $fs->call_command("break");
$o = $fs->call_command("hangup");
}
diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h
index acdb4ff72c..be6125ee6e 100644
--- a/src/include/switch_ivr.h
+++ b/src/include/switch_ivr.h
@@ -205,7 +205,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech_unload_grammar(switch_c
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh);
SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session_t *session, const char *uuid, switch_eavesdrop_flag_t flags);
-SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags);
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags);
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file);
/*!
diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h
index ebdda1abf4..cc9e5cdf29 100644
--- a/src/include/switch_module_interfaces.h
+++ b/src/include/switch_module_interfaces.h
@@ -195,6 +195,8 @@ struct switch_timer {
switch_memory_pool_t *memory_pool;
/*! private data for loadable modules to store information */
void *private_info;
+ /*! remaining time from last call to _check()*/
+ switch_size_t diff;
};
typedef enum {
diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c
index 2c64dcee5a..63d1c1db8a 100644
--- a/src/mod/applications/mod_commands/mod_commands.c
+++ b/src/mod/applications/mod_commands/mod_commands.c
@@ -2028,7 +2028,7 @@ SWITCH_STANDARD_API(uuid_dump_function)
}
switch_assert(buf);
- stream->write_function(stream, buf);
+ stream->raw_write_function(stream, (unsigned char *)buf, strlen(buf));
switch_event_destroy(&event);
free(buf);
} else {
diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c
index 4e2e9edbdb..1a5df6a109 100644
--- a/src/mod/applications/mod_conference/mod_conference.c
+++ b/src/mod/applications/mod_conference/mod_conference.c
@@ -558,7 +558,7 @@ static switch_status_t conference_add_member(conference_obj_t * conference, conf
conference_stop_file(conference, FILE_STOP_ASYNC);
}
if(conference->enter_sound) {
- conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 0);
+ conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 1);
}
}
@@ -808,7 +808,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread,
/* Lead in time */
if (conference->fnode->leadin) {
conference->fnode->leadin--;
- } else {
+ } else if (!conference->fnode->done) {
file_sample_len = samples;
if (conference->fnode->type == NODE_TYPE_SPEECH) {
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
@@ -837,7 +837,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread,
/* Lead in time */
if (conference->async_fnode->leadin) {
conference->async_fnode->leadin--;
- } else {
+ } else if (!conference->async_fnode->done) {
file_sample_len = samples;
switch_core_file_read(&conference->async_fnode->fh, async_file_frame, &file_sample_len);
if (file_sample_len <= 0) {
diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c
index 42eb6d8d6a..4cce5dbf31 100644
--- a/src/mod/applications/mod_fifo/mod_fifo.c
+++ b/src/mod/applications/mod_fifo/mod_fifo.c
@@ -84,6 +84,7 @@ static struct {
switch_hash_t *fifo_hash;
switch_mutex_t *mutex;
switch_memory_pool_t *pool;
+ int running;
} globals;
@@ -105,6 +106,10 @@ static fifo_node_t *create_node(const char *name)
{
fifo_node_t *node;
+ if (!globals.running) {
+ return NULL;
+ }
+
node = switch_core_alloc(globals.pool, sizeof(*node));
node->name = switch_core_strdup(globals.pool, name);
@@ -122,6 +127,10 @@ static void send_presence(fifo_node_t *node)
{
switch_event_t *event;
+ if (!globals.running) {
+ return;
+ }
+
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%s", "park");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "login", "%s", node->name);
@@ -139,7 +148,6 @@ static void send_presence(fifo_node_t *node)
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-state", "%s", node->waiting_count > 0 ? "CS_RING" : "CS_HANGUP");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "unique-id", "%s", node->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "answer-state", "%s", node->waiting_count > 0 ? "early" : "terminated");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "astate", "%s", node->waiting_count > 0 ? "early" : "terminated");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-direction", "%s", "inbound");
switch_event_fire(&event);
}
@@ -151,6 +159,10 @@ static void pres_event_handler(switch_event_t *event)
char *to = switch_event_get_header(event, "to");
char *dup_to = NULL, *node_name;
fifo_node_t *node;
+
+ if (!globals.running) {
+ return;
+ }
if (!to || strncasecmp(to, "park+", 5)) {
return;
@@ -192,7 +204,9 @@ SWITCH_STANDARD_APP(fifo_function)
switch_time_t ts = switch_timestamp_now();
switch_size_t retsize;
-
+ if (!globals.running) {
+ return;
+ }
if (switch_strlen_zero(data)) {
@@ -577,6 +591,11 @@ SWITCH_STANDARD_API(fifo_api_function)
const void *var;
int x = 0, verbose = 0;
+
+ if (!globals.running) {
+ return SWITCH_STATUS_FALSE;
+ }
+
if (!switch_strlen_zero(cmd)) {
data = strdup(cmd);
switch_assert(data);
@@ -672,6 +691,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_fifo_load)
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_APP(app_interface, "fifo", "Park with FIFO", FIFO_DESC, fifo_function, FIFO_USAGE, SAF_NONE);
SWITCH_ADD_API(commands_api_interface, "fifo", "Return data about a fifo", fifo_api_function, FIFO_API_SYNTAX);
+ globals.running = 1;
return SWITCH_STATUS_SUCCESS;
}
@@ -684,7 +704,10 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
switch_hash_index_t *hi;
void *val, *pop;
fifo_node_t *node;
+ switch_memory_pool_t *pool = globals.pool;
switch_mutex_lock(globals.mutex);
+
+ globals.running = 0;
/* Cleanup*/
for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, NULL, NULL, &val);
@@ -695,9 +718,11 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fifo_shutdown)
switch_core_hash_destroy(&node->caller_hash);
switch_core_hash_destroy(&node->consumer_hash);
}
- switch_mutex_unlock(globals.mutex);
switch_core_hash_destroy(&globals.fifo_hash);
- switch_core_destroy_memory_pool(&globals.pool);
+ memset(&globals, 0, sizeof(globals));
+ switch_mutex_unlock(globals.mutex);
+
+ switch_core_destroy_memory_pool(&pool);
return SWITCH_STATUS_SUCCESS;
}
diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c
index 135f0ec742..c562884e83 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.c
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c
@@ -252,30 +252,11 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
cause = switch_channel_get_cause(channel);
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
- const char *buuid;
- switch_core_session_t *bsession;
- switch_channel_t *bchannel;
- const char *lost_ext;
-
-
+
if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
}
switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
- if ((buuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
- if ((bsession = switch_core_session_locate(buuid))) {
- bchannel = switch_core_session_get_channel(bsession);
- if (switch_channel_test_flag(bchannel, CF_BROADCAST)) {
- if ((lost_ext = switch_channel_get_variable(bchannel, "left_hanging_extension"))) {
- switch_ivr_session_transfer(bsession, lost_ext, NULL, NULL);
- }
- switch_channel_clear_flag(bchannel, CF_BROADCAST);
- switch_channel_set_flag(bchannel, CF_BREAK);
- }
- switch_core_session_rwunlock(bsession);
- }
- }
-
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
}
diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c
index bc77f8203c..68366dff48 100644
--- a/src/mod/endpoints/mod_sofia/sofia_glue.c
+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c
@@ -1382,25 +1382,38 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
if (sendonly) {
if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
const char *stream;
+
switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_presence(tech_pvt->channel, "unknown", "hold");
+
if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets * 10);
}
+
if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
stream = tech_pvt->profile->hold_music;
}
+
if (stream) {
- switch_ivr_broadcast(switch_core_session_get_uuid(tech_pvt->session), stream, SMF_ECHO_BLEG | SMF_LOOP);
+ switch_ivr_displace_session(tech_pvt->session, stream, 0, "rl");
}
}
} else {
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
- switch_channel_clear_flag_partner(tech_pvt->channel, CF_BROADCAST);
+ const char *stream;
+
if (tech_pvt->max_missed_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
}
- switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
+
+ if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+ stream = tech_pvt->profile->hold_music;
+ }
+
+ if (stream) {
+ switch_ivr_stop_displace_session(tech_pvt->session, stream);
+ }
+
switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
switch_channel_presence(tech_pvt->channel, "unknown", "unhold");
}
diff --git a/src/switch_core_io.c b/src/switch_core_io.c
index 29a404d024..9813b26ba3 100644
--- a/src/switch_core_io.c
+++ b/src/switch_core_io.c
@@ -94,7 +94,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
{
switch_io_event_hook_read_frame_t *ptr;
switch_status_t status;
- int need_codec, perfect, do_bugs = 0, do_resample = 0;
+ int need_codec, perfect, do_bugs = 0, do_resample = 0, is_cng = 0;
unsigned int flag = 0;
top:
@@ -131,11 +131,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
switch_assert(session != NULL);
switch_assert(*frame != NULL);
-
if (switch_test_flag(*frame, SFF_CNG)) {
status = SWITCH_STATUS_SUCCESS;
- goto done;
- }
+ if (!session->bugs) {
+ goto done;
+ }
+ is_cng = 1;
+
+ }
switch_assert((*frame)->codec != NULL);
if ((session->read_codec && (*frame)->codec && session->read_codec->implementation != (*frame)->codec->implementation)) {
@@ -163,16 +166,25 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
if (status == SWITCH_STATUS_SUCCESS && need_codec) {
switch_frame_t *enc_frame, *read_frame = *frame;
- if (read_frame->codec) {
+ if (read_frame->codec || is_cng) {
session->raw_read_frame.datalen = session->raw_read_frame.buflen;
- status = switch_core_codec_decode(read_frame->codec,
- session->read_codec,
- read_frame->data,
- read_frame->datalen,
- session->read_codec->implementation->actual_samples_per_second,
- session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
- if (do_resample && status == SWITCH_STATUS_SUCCESS) {
+ if (is_cng) {
+ memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->bytes_per_frame);
+ session->raw_read_frame.datalen = read_frame->codec->implementation->bytes_per_frame;
+ session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
+ read_frame = &session->raw_read_frame;
+ status = SWITCH_STATUS_SUCCESS;
+ } else {
+ status = switch_core_codec_decode(read_frame->codec,
+ session->read_codec,
+ read_frame->data,
+ read_frame->datalen,
+ session->read_codec->implementation->actual_samples_per_second,
+ session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
+ }
+
+ if (do_resample && ((status == SWITCH_STATUS_SUCCESS) || is_cng)) {
status = SWITCH_STATUS_RESAMPLE;
}
diff --git a/src/switch_event.c b/src/switch_event.c
index 2627c57c61..7156c0cca9 100644
--- a/src/switch_event.c
+++ b/src/switch_event.c
@@ -506,6 +506,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_del_header(switch_event_t *event, c
} else {
event->headers = hp->next;
}
+ if (hp == event->last_header || !hp->next) {
+ event->last_header = lp;
+ }
FREE(hp->name);
FREE(hp->value);
memset(hp, 0, sizeof(*hp));
diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c
index 9fd5305111..459c4e4e5c 100644
--- a/src/switch_ivr_async.c
+++ b/src/switch_ivr_async.c
@@ -98,9 +98,10 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session)
typedef struct {
switch_file_handle_t fh;
int mux;
+ int loop;
} displace_helper_t;
-static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+static switch_bool_t write_displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
{
displace_helper_t *dh = (displace_helper_t *) user_data;
uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
@@ -154,7 +155,12 @@ static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data,
}
if (st != SWITCH_STATUS_SUCCESS || len == 0) {
- return SWITCH_FALSE;
+ if (dh->loop) {
+ uint32_t pos = 0;
+ switch_core_file_seek(&dh->fh, &pos, 0, SEEK_SET);
+ } else {
+ return SWITCH_FALSE;
+ }
}
switch_core_media_bug_set_write_replace_frame(bug, rframe);
@@ -168,6 +174,80 @@ static switch_bool_t displace_callback(switch_media_bug_t *bug, void *user_data,
return SWITCH_TRUE;
}
+
+
+static switch_bool_t read_displace_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
+{
+ displace_helper_t *dh = (displace_helper_t *) user_data;
+ uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ switch_frame_t frame = { 0 };
+
+ frame.data = data;
+ frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
+
+ switch (type) {
+ case SWITCH_ABC_TYPE_INIT:
+ break;
+ case SWITCH_ABC_TYPE_CLOSE:
+ if (dh) {
+ switch_core_file_close(&dh->fh);
+ }
+ break;
+ case SWITCH_ABC_TYPE_WRITE_REPLACE:
+ {
+ switch_frame_t *rframe = switch_core_media_bug_get_write_replace_frame(bug);
+ if (dh && !dh->mux) {
+ memset(rframe->data, 255, rframe->datalen);
+ }
+ switch_core_media_bug_set_write_replace_frame(bug, rframe);
+ }
+ break;
+ case SWITCH_ABC_TYPE_READ_REPLACE:
+ if (dh) {
+ switch_frame_t *rframe = NULL;
+ switch_size_t len;
+ switch_status_t st;
+ rframe = switch_core_media_bug_get_read_replace_frame(bug);
+ len = rframe->samples;
+
+ if (dh->mux) {
+ int16_t buf[1024];
+ int16_t *fp = rframe->data;
+ uint32_t x;
+
+ st = switch_core_file_read(&dh->fh, buf, &len);
+
+ for(x = 0; x < (uint32_t) len; x++) {
+ int32_t mixed = fp[x] + buf[x];
+ switch_normalize_to_16bit(mixed);
+ fp[x] = (int16_t) mixed;
+ }
+ } else {
+ st = switch_core_file_read(&dh->fh, rframe->data, &len);
+ rframe->samples = (uint32_t) len;
+ rframe->datalen = rframe->samples * 2;
+ }
+
+ if (st != SWITCH_STATUS_SUCCESS || len == 0) {
+ if (dh->loop) {
+ uint32_t pos = 0;
+ switch_core_file_seek(&dh->fh, &pos, 0, SEEK_SET);
+ } else {
+ return SWITCH_FALSE;
+ }
+ }
+
+ switch_core_media_bug_set_read_replace_frame(bug, rframe);
+ }
+ break;
+ case SWITCH_ABC_TYPE_WRITE:
+ default:
+ break;
+ }
+
+ return SWITCH_TRUE;
+}
+
SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_session_t *session, const char *file)
{
switch_media_bug_t *bug;
@@ -184,7 +264,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_displace_session(switch_core_ses
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, char *file, uint32_t limit, const char *flags)
+SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_t *session, const char *file, uint32_t limit, const char *flags)
{
switch_channel_t *channel;
switch_codec_t *read_codec;
@@ -206,15 +286,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_
return SWITCH_STATUS_MEMERR;
}
-
-
+
read_codec = switch_core_session_get_read_codec(session);
switch_assert(read_codec != NULL);
dh->fh.channels = read_codec->implementation->number_of_channels;
dh->fh.samplerate = read_codec->implementation->actual_samples_per_second;
-
-
+
if (switch_core_file_open(&dh->fh,
file,
read_codec->implementation->number_of_channels,
@@ -236,7 +314,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_
dh->mux++;
}
- if ((status = switch_core_media_bug_add(session, displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
+ if (flags && strchr(flags, 'l')) {
+ dh->loop++;
+ }
+
+ if (flags && strchr(flags, 'r')) {
+ status = switch_core_media_bug_add(session, read_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug);
+ } else {
+ status = switch_core_media_bug_add(session, write_displace_callback, dh, to, SMBF_WRITE_REPLACE | SMBF_READ_REPLACE, &bug);
+ }
+
+ if (status != SWITCH_STATUS_SUCCESS) {
switch_core_file_close(&dh->fh);
return status;
}
@@ -1600,105 +1688,108 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(const char *uuid, const cha
switch_core_session_t *other_session = NULL;
const char *other_uuid = NULL;
char *app = "playback";
+ char *cause = NULL;
+ char *mypath;
+ char *p;
switch_assert(path);
- if ((session = switch_core_session_locate(uuid))) {
- char *cause = NULL;
- char *mypath;
- char *p;
-
- master = session;
-
- channel = switch_core_session_get_channel(session);
- switch_assert(channel != NULL);
-
- if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n",
- switch_channel_get_name(channel));
- switch_core_session_rwunlock(session);
- return SWITCH_STATUS_FALSE;
- }
-
- mypath = strdup(path);
-
-
- if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
- switch_ivr_media(uuid, SMF_REBRIDGE);
- }
-
- if ((p = strchr(mypath, ':')) && *(p+1) == ':') {
- app = mypath;
- *p++ = '\0';
- *p++ = '\0';
- path = p;
- }
-
- if ((cause = strchr(app, '!'))) {
- *cause++ = '\0';
- if (!cause) {
- cause = "normal_clearing";
- }
- }
-
- if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE))
- && (other_session = switch_core_session_locate(other_uuid))) {
- if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- 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);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
- if ((flags & SMF_LOOP)) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
- }
-
- switch_core_session_queue_private_event(other_session, &event);
- }
-
- switch_core_session_rwunlock(other_session);
- master = other_session;
- other_session = NULL;
- }
-
- if ((flags & SMF_ECHO_ALEG)) {
- if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- 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);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
- if ((flags & SMF_LOOP)) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
- }
- switch_core_session_queue_private_event(session, &event);
- }
- master = session;
- }
-
- if (nomedia) {
- if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
- switch_core_session_queue_private_event(master, &event);
- }
- }
-
- if (cause) {
- if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
- switch_core_session_queue_private_event(session, &event);
- }
- }
-
- switch_core_session_rwunlock(session);
- switch_safe_free(mypath);
+ if (!(session = switch_core_session_locate(uuid))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "uuid [%s] does not match an existing session.\n", switch_str_nil(uuid));
+ return SWITCH_STATUS_FALSE;
}
+ master = session;
+
+ channel = switch_core_session_get_channel(session);
+ switch_assert(channel != NULL);
+
+ if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n",
+ switch_channel_get_name(channel));
+ switch_core_session_rwunlock(session);
+ return SWITCH_STATUS_FALSE;
+ }
+
+ mypath = strdup(path);
+
+
+ if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
+ switch_ivr_media(uuid, SMF_REBRIDGE);
+ }
+
+ if ((p = strchr(mypath, ':')) && *(p+1) == ':') {
+ app = mypath;
+ *p++ = '\0';
+ *p++ = '\0';
+ path = p;
+ }
+
+ if ((cause = strchr(app, '!'))) {
+ *cause++ = '\0';
+ if (!cause) {
+ cause = "normal_clearing";
+ }
+ }
+
+ if ((flags & SMF_ECHO_BLEG) && (other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+ && (other_session = switch_core_session_locate(other_uuid))) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ 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);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+ if ((flags & SMF_LOOP)) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
+ }
+
+ switch_core_session_queue_private_event(other_session, &event);
+ }
+
+ switch_core_session_rwunlock(other_session);
+ master = other_session;
+ other_session = NULL;
+ }
+
+ if ((flags & SMF_ECHO_ALEG)) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ 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);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+ if ((flags & SMF_LOOP)) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
+ }
+ switch_core_session_queue_private_event(session, &event);
+ }
+ master = session;
+ }
+
+ if (nomedia) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+ switch_core_session_queue_private_event(master, &event);
+ }
+ }
+
+ if (cause) {
+ if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
+ switch_core_session_queue_private_event(session, &event);
+ }
+ }
+
+ switch_core_session_rwunlock(session);
+ switch_safe_free(mypath);
+
+
return SWITCH_STATUS_SUCCESS;
diff --git a/src/switch_rtp.c b/src/switch_rtp.c
index 2792feb3ba..fe8fe6761e 100644
--- a/src/switch_rtp.c
+++ b/src/switch_rtp.c
@@ -1101,12 +1101,8 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
break;
do_continue:
-
- if (rtp_session->ms_per_packet) {
- switch_yield((rtp_session->ms_per_packet / 1000) * 750);
- } else {
- switch_yield(1000);
- }
+
+ switch_yield(1000);
}
*payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;
diff --git a/src/switch_time.c b/src/switch_time.c
index a4a4e0dd65..1239084b68 100644
--- a/src/switch_time.c
+++ b/src/switch_time.c
@@ -187,7 +187,7 @@ static switch_status_t timer_check(switch_timer_t *timer)
{
timer_private_t *private_info = timer->private_info;
switch_status_t status = SWITCH_STATUS_SUCCESS;
- switch_size_t diff;
+
if (globals.RUNNING != 1 || !private_info->ready) {
return SWITCH_STATUS_SUCCESS;
@@ -196,12 +196,12 @@ static switch_status_t timer_check(switch_timer_t *timer)
check_roll();
if (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
- diff = private_info->reference - TIMER_MATRIX[timer->interval].tick;
+ timer->diff = private_info->reference - TIMER_MATRIX[timer->interval].tick;
} else {
- diff = 0;
+ timer->diff = 0;
}
- if (diff) {
+ if (timer->diff) {
status = SWITCH_STATUS_FALSE;
} else {
timer_step(timer);