-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Travis Cross <tc@traviscross.com>
*
args.buflen = sizeof(buf);
args.read_frame_callback = chime_read_frame_callback;
args.user_data = user_data;
-
+
status = switch_ivr_play_file(session, NULL, cd->list[cd->index], &args);
-
+
if (match_key(cd->exit_key, *buf)) {
cd->abort = 1;
return SWITCH_STATUS_BREAK;
}
-
+
if (status != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_BREAK;
}
char *pre_trans_execute;
char *post_trans_execute;
char *inner_pre_trans_execute;
- char *inner_post_trans_execute;
+ char *inner_post_trans_execute;
switch_sql_queue_manager_t *qm;
int allow_transcoding;
} globals;
}
}
switch_mutex_unlock(globals.use_mutex);
-
+
return r;
}
-static int fifo_get_use_count(const char *outbound_id)
+static int fifo_get_use_count(const char *outbound_id)
{
int r = 0, *count;
r = *count;
}
switch_mutex_unlock(globals.use_mutex);
-
+
return r;
}
-static int fifo_inc_use_count(const char *outbound_id)
+static int fifo_inc_use_count(const char *outbound_id)
{
int r = 0, *count;
r = ++(*count);
switch_mutex_unlock(globals.use_mutex);
-
+
return r;
}
-static void fifo_init_use_count(void)
+static void fifo_init_use_count(void)
{
switch_mutex_lock(globals.use_mutex);
if (globals.use_hash) {
switch_cache_db_handle_t *dbh = NULL;
char *dsn;
-
+
if (!zstr(globals.odbc_dsn)) {
dsn = globals.odbc_dsn;
} else {
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
dbh = NULL;
}
-
+
return dbh;
}
char *sql;
switch_assert(sqlp && *sqlp);
- sql = *sqlp;
+ sql = *sqlp;
if (switch_stristr("insert", sql)) {
callback_t cbt = { 0 };
char *sql = NULL;
char *domain_name = NULL;
-
+
if (!globals.running) {
return NULL;
}
cbt.len = sizeof(outbound_count);
sql = switch_mprintf("select count(*) from fifo_outbound where fifo_name = '%q'", name);
fifo_execute_sql_callback(mutex, sql, sql2str_callback, &cbt);
- node->member_count = atoi(outbound_count);
+ node->member_count = atoi(outbound_count);
if (node->member_count > 0) {
node->has_outbound = 1;
} else {
- node->has_outbound = 0;
- }
+ node->has_outbound = 0;
+ }
switch_safe_free(sql);
node->importance = importance;
if ((outbound_id = switch_channel_get_variable(consumer_channel, "fifo_outbound_uuid"))) {
use_count = fifo_get_use_count(outbound_id);
}
-
+
ts = switch_micro_time_now();
switch_time_exp_lt(&tm, ts);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
if (use_ent) {
stream.write_function(&stream, "{ignore_early_media=true,outbound_redirect_fatal=true,leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s}%s%s",
- h->timeout, h->uuid, node->name,
+ h->timeout, h->uuid, node->name,
parsed ? parsed : expanded_originate_string, (i == cbh->rowcount - 1) ? "" : SWITCH_ENT_ORIGINATE_DELIM);
} else {
stream.write_function(&stream, "[leg_timeout=%d,fifo_outbound_uuid=%s,fifo_name=%s]%s,",
if (!total) goto end;
- if (!globals.allow_transcoding && !switch_true(switch_event_get_header(pop, "variable_fifo_allow_transcoding")) &&
+ if (!globals.allow_transcoding && !switch_true(switch_event_get_header(pop, "variable_fifo_allow_transcoding")) &&
(codec = switch_event_get_header(pop, "variable_rtp_use_codec_name"))) {
const char *rate = switch_event_get_header(pop, "variable_rtp_use_codec_rate");
const char *ptime = switch_event_get_header(pop, "variable_rtp_use_codec_ptime");
}
}
}
-
+
if (++cur_priority > 10) {
cur_priority = 1;
const char *arg_fifo_name = NULL;
const char *arg_inout = NULL;
const char *serviced_uuid = NULL;
-
+
if (!globals.running) {
return;
}
if (!(switch_channel_ready(channel))) {
const char *app = switch_channel_get_variable(other_channel, "current_application");
const char *arg = switch_channel_get_variable(other_channel, "current_application_data");
- switch_caller_extension_t *extension = NULL;
+ switch_caller_extension_t *extension = NULL;
- switch_channel_set_variable_printf(channel, "last_sent_callee_id_name", "%s (AGENT FAIL)",
+ switch_channel_set_variable_printf(channel, "last_sent_callee_id_name", "%s (AGENT FAIL)",
switch_channel_get_variable(other_channel, "caller_id_name"));
switch_channel_set_variable(channel, "last_sent_callee_id_number", switch_channel_get_variable(other_channel, "caller_id_number"));
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"Customer %s %s [%s] appears to be abandoned by agent %s [%s] "
"but is still on the line, redirecting them back to the queue with VIP status.\n",
- switch_channel_get_name(other_channel),
- switch_channel_get_variable(other_channel, "caller_id_name"),
+ switch_channel_get_name(other_channel),
+ switch_channel_get_variable(other_channel, "caller_id_name"),
switch_channel_get_variable(other_channel, "caller_id_number"),
switch_channel_get_variable(channel, "caller_id_name"),
switch_channel_get_variable(channel, "caller_id_number"));
send_presence(node);
check_cancel(node);
-
+
if (app) {
extension = switch_caller_extension_new(other_session, app, arg);
switch_caller_extension_add_application(other_session, extension, app, arg);
originator_cp = switch_channel_get_caller_profile(channel);
originatee_cp = switch_channel_get_caller_profile(other_channel);
-
+
switch_channel_set_originator_caller_profile(other_channel, switch_caller_profile_clone(other_session, originator_cp));
switch_channel_set_originatee_caller_profile(channel, switch_caller_profile_clone(session, originatee_cp));
-
-
+
+
originator_cp->callee_id_name = switch_core_strdup(originator_cp->pool, originatee_cp->callee_id_name);
originator_cp->callee_id_number = switch_core_strdup(originator_cp->pool, originatee_cp->callee_id_number);
originatee_cp->callee_id_name = switch_core_strdup(originatee_cp->pool, originatee_cp->caller_id_name);
originatee_cp->callee_id_number = switch_core_strdup(originatee_cp->pool, originatee_cp->caller_id_number);
-
+
originatee_cp->caller_id_name = switch_core_strdup(originatee_cp->pool, originator_cp->caller_id_name);
originatee_cp->caller_id_number = switch_core_strdup(originatee_cp->pool, originator_cp->caller_id_number);
switch_event_fire(&event);
}
-
+
add_bridge_call(switch_core_session_get_uuid(other_session));
add_bridge_call(switch_core_session_get_uuid(session));
switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_initiated_bridge", NULL);
switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_bridge_role", NULL);
}
-
+
if (switch_channel_test_flag(channel, CF_TRANSFER) && switch_channel_up(channel)) {
switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_initiated_bridge", NULL);
switch_channel_set_variable(switch_core_session_get_channel(other_session), "fifo_bridge_role", NULL);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-us", "%"SWITCH_TIME_T_FMT, hold_usec);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-ms", "%"SWITCH_TIME_T_FMT, (uint64_t)(hold_usec / 1000));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Hold-Time-s", "%"SWITCH_TIME_T_FMT, (uint64_t)(hold_usec / 1000000));
-
+
switch_event_fire(&event);
}
if (outbound_id) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Outbound-ID", outbound_id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Consumer-Use-Count", "%d", fifo_get_use_count(outbound_id));
- }
+ }
switch_event_fire(&event);
}
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
continue;
}
switch_thread_rwlock_unlock(node->rwlock);
-
+
if (node->ready == 1 && do_destroy && node_caller_count(node) == 0 && node->consumer_count == 0) {
switch_core_hash_delete(globals.fifo_hash, node->name);
node->ready = 0;
}
globals.dbname = "fifo";
-
+
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char*)switch_xml_attr_soft(param, "name");
{
char digest[SWITCH_MD5_DIGEST_STRING_SIZE] = { 0 };
char *sql, *name_dup, *p;
- char outbound_count[80] = "";
- callback_t cbt = { 0 };
+ char outbound_count[80] = "";
+ callback_t cbt = { 0 };
fifo_node_t *node = NULL;
if (!fifo_name) return;
fifo_execute_sql_queued(&sql, SWITCH_TRUE, SWITCH_TRUE);
free(name_dup);
- cbt.buf = outbound_count;
- cbt.len = sizeof(outbound_count);
- sql = switch_mprintf("select count(*) from fifo_outbound where fifo_name = '%q'", fifo_name);
- fifo_execute_sql_callback(globals.sql_mutex, sql, sql2str_callback, &cbt);
- node->member_count = atoi(outbound_count);
- if (node->member_count > 0) {
- node->has_outbound = 1;
- } else {
- node->has_outbound = 0;
- }
- switch_safe_free(sql);
+ cbt.buf = outbound_count;
+ cbt.len = sizeof(outbound_count);
+ sql = switch_mprintf("select count(*) from fifo_outbound where fifo_name = '%q'", fifo_name);
+ fifo_execute_sql_callback(globals.sql_mutex, sql, sql2str_callback, &cbt);
+ node->member_count = atoi(outbound_count);
+ if (node->member_count > 0) {
+ node->has_outbound = 1;
+ } else {
+ node->has_outbound = 0;
+ }
+ switch_safe_free(sql);
}
static void fifo_member_del(char *fifo_name, char *originate_string)
cbt.len = sizeof(outbound_count);
sql = switch_mprintf("select count(*) from fifo_outbound where fifo_name = '%q'", node->name);
fifo_execute_sql_callback(globals.sql_mutex, sql, sql2str_callback, &cbt);
- node->member_count = atoi(outbound_count);
+ node->member_count = atoi(outbound_count);
if (node->member_count > 0) {
- node->has_outbound = 1;
+ node->has_outbound = 1;
} else {
- node->has_outbound = 0;
+ node->has_outbound = 0;
}
switch_safe_free(sql);
}
this_node = node;
node = node->next;
-
+
switch_mutex_lock(this_node->update_mutex);
switch_mutex_lock(this_node->mutex);
for (x = 0; x < MAX_PRI; x++) {