mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-26 21:24:16 +00:00
cross t's and dot i's
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7075 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
e790b22af1
commit
1bbeb4f706
16 files changed
+293
-161
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user