mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
Merge remote branch 'fsorig/master'
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
/applications/mod_fax/mod_fax.log
|
||||
/applications/mod_fifo/Makefile
|
||||
/applications/mod_fsv/Makefile
|
||||
/applications/mod_httapi/Makefile
|
||||
/applications/mod_limit/Makefile
|
||||
/applications/mod_sms/Makefile
|
||||
/applications/mod_spandsp/Makefile
|
||||
@@ -62,5 +63,7 @@
|
||||
/loggers/mod_logfile/Makefile
|
||||
/loggers/mod_syslog/Makefile
|
||||
/say/mod_say_en/Makefile
|
||||
/say/mod_say_ja/Makefile
|
||||
/say/mod_say_ru/Makefile
|
||||
/timers/mod_posix_timer/Makefile
|
||||
/timers/mod_timerfd/Makefile
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -59,13 +59,17 @@
|
||||
#define TO_HZ(r, f) (((r) * (f)) / (2.0 * M_PI))
|
||||
/*! Minimum beep frequency in Hertz */
|
||||
#define MIN_FREQUENCY (300.0)
|
||||
#define MIN_FREQUENCY_R(r) ((2.0 * M_PI * MIN_FREQUENCY) / (r))
|
||||
/*! Maximum beep frequency in Hertz */
|
||||
#define MAX_FREQUENCY (1500.0)
|
||||
#define MAX_FREQUENCY (2500.0)
|
||||
#define MAX_FREQUENCY_R(r) ((2.0 * M_PI * MAX_FREQUENCY) / (r))
|
||||
/* decrease this value to eliminate false positives */
|
||||
#define VARIANCE_THRESHOLD (0.001)
|
||||
|
||||
#include "amplitude.h"
|
||||
#include "buffer.h"
|
||||
#include "desa2.h"
|
||||
#include "goertzel.h"
|
||||
//#include "goertzel.h"
|
||||
#include "psi.h"
|
||||
#include "sma_buf.h"
|
||||
#include "options.h"
|
||||
@@ -111,7 +115,9 @@ typedef struct {
|
||||
uint32_t rate;
|
||||
circ_buffer_t b;
|
||||
sma_buffer_t sma_b;
|
||||
sma_buffer_t sqa_b;
|
||||
size_t pos;
|
||||
double f;
|
||||
/* freq_table_t ft; */
|
||||
avmd_state_t state;
|
||||
} avmd_session_t;
|
||||
@@ -134,6 +140,7 @@ static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_se
|
||||
|
||||
avmd_session->session = fs_session;
|
||||
avmd_session->pos = 0;
|
||||
avmd_session->f = 0.0;
|
||||
avmd_session->state.last_beep = 0;
|
||||
avmd_session->state.beep_state = BEEP_NOTDETECTED;
|
||||
|
||||
@@ -142,6 +149,12 @@ static void init_avmd_session_data(avmd_session_t *avmd_session, switch_core_se
|
||||
BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate),
|
||||
fs_session
|
||||
);
|
||||
|
||||
INIT_SMA_BUFFER(
|
||||
&avmd_session->sqa_b,
|
||||
BEEP_LEN(avmd_session->rate) / SINE_LEN(avmd_session->rate),
|
||||
fs_session
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -474,17 +487,18 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
|
||||
circ_buffer_t *b;
|
||||
size_t pos;
|
||||
double f;
|
||||
double a;
|
||||
double error = 0.0;
|
||||
double success = 0.0;
|
||||
double amp = 0.0;
|
||||
double s_rate;
|
||||
double v;
|
||||
// double error = 0.0;
|
||||
// double success = 0.0;
|
||||
// double amp = 0.0;
|
||||
// double s_rate;
|
||||
// double e_rate;
|
||||
double avg_a;
|
||||
double sine_len;
|
||||
// double avg_a;
|
||||
//double sine_len;
|
||||
uint32_t sine_len_i;
|
||||
int valid;
|
||||
|
||||
//uint32_t beep_len_i;
|
||||
// int valid;
|
||||
|
||||
b = &session->b;
|
||||
|
||||
/*! If beep has already been detected skip the CPU heavy stuff */
|
||||
@@ -494,57 +508,39 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
|
||||
|
||||
/*! Precompute values used heavily in the inner loop */
|
||||
sine_len_i = SINE_LEN(session->rate);
|
||||
sine_len = (double)sine_len_i;
|
||||
|
||||
|
||||
//sine_len = (double)sine_len_i;
|
||||
//beep_len_i = BEEP_LEN(session->rate);
|
||||
|
||||
channel = switch_core_session_get_channel(session->session);
|
||||
|
||||
/*! Insert frame of 16 bit samples into buffer */
|
||||
INSERT_INT16_FRAME(b, (int16_t *)(frame->data), frame->samples);
|
||||
|
||||
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_INFO, "<<< AVMD sine_len_i=%d >>>\n", sine_len_i);
|
||||
|
||||
/*! INNER LOOP -- OPTIMIZATION TARGET */
|
||||
for(pos = GET_BACKLOG_POS(b); pos != (GET_CURRENT_POS(b) - P); pos++){
|
||||
for(pos = session->pos; pos < (GET_CURRENT_POS(b) - P); pos++){
|
||||
if ((pos % sine_len_i) == 0) {
|
||||
/*! Get a desa2 frequency estimate every sine len */
|
||||
f = desa2(b, pos);
|
||||
|
||||
/*! Get a desa2 frequency estimate in Hertz */
|
||||
f = TO_HZ(session->rate, desa2(b, pos));
|
||||
if(f < MIN_FREQUENCY_R(session->rate) || f > MAX_FREQUENCY_R(session->rate)) {
|
||||
v = 99999.0;
|
||||
RESET_SMA_BUFFER(&session->sma_b);
|
||||
RESET_SMA_BUFFER(&session->sqa_b);
|
||||
} else {
|
||||
APPEND_SMA_VAL(&session->sma_b, f);
|
||||
APPEND_SMA_VAL(&session->sqa_b, f * f);
|
||||
|
||||
/* calculate variance */
|
||||
v = session->sqa_b.sma - (session->sma_b.sma * session->sma_b.sma);
|
||||
|
||||
/*! Don't caculate amplitude if frequency is not within range */
|
||||
if(f < MIN_FREQUENCY || f > MAX_FREQUENCY) {
|
||||
a = 0.0;
|
||||
error += 1.0;
|
||||
} else {
|
||||
a = amplitude(b, pos, f);
|
||||
success += 1.0;
|
||||
if(!ISNAN(a)){
|
||||
amp += a;
|
||||
}
|
||||
}
|
||||
|
||||
/*! Every once in a while we evaluate the desa2 and amplitude results */
|
||||
if(((pos + 1) % sine_len_i) == 0){
|
||||
s_rate = success / (error + success);
|
||||
// e_rate = error / (error + success);
|
||||
avg_a = amp / sine_len;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_INFO, "<<< AVMD v=%f f=%f %fHz sma=%f sqa=%f >>>\n", v, f, TO_HZ(session->rate, f), session->sma_b.sma, session->sqa_b.sma);
|
||||
}
|
||||
|
||||
/*! Results out of these ranges are considered invalid */
|
||||
valid = 0;
|
||||
if( s_rate > 0.60 && avg_a > 0.50) valid = 1;
|
||||
else if(s_rate > 0.65 && avg_a > 0.45) valid = 1;
|
||||
else if(s_rate > 0.70 && avg_a > 0.40) valid = 1;
|
||||
else if(s_rate > 0.80 && avg_a > 0.30) valid = 1;
|
||||
else if(s_rate > 0.95 && avg_a > 0.05) valid = 1;
|
||||
else if(s_rate >= 0.99 && avg_a > 0.04) valid = 1;
|
||||
else if(s_rate == 1.00 && avg_a > 0.02) valid = 1;
|
||||
/*! If variance is less than threshold then we have detection */
|
||||
if(v < VARIANCE_THRESHOLD){
|
||||
|
||||
if(valid) {
|
||||
APPEND_SMA_VAL(&session->sma_b, s_rate * avg_a);
|
||||
}
|
||||
else {
|
||||
APPEND_SMA_VAL(&session->sma_b, 0.0 );
|
||||
}
|
||||
|
||||
/*! If sma is higher then 0 we have some kind of detection (increase this value to eliminate false positives ex: 0.01) */
|
||||
if(session->sma_b.sma > 0.00){
|
||||
/*! Throw an event to FreeSWITCH */
|
||||
status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, AVMD_EVENT_BEEP);
|
||||
if(status != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -565,16 +561,18 @@ static void avmd_process(avmd_session_t *session, switch_frame_t *frame)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session->session), SWITCH_LOG_INFO, "<<< AVMD - Beep Detected >>>\n");
|
||||
switch_channel_set_variable(channel, "avmd_detect", "TRUE");
|
||||
RESET_SMA_BUFFER(&session->sma_b);
|
||||
RESET_SMA_BUFFER(&session->sqa_b);
|
||||
session->state.beep_state = BEEP_DETECTED;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
amp = 0.0;
|
||||
success = 0.0;
|
||||
error = 0.0;
|
||||
//amp = 0.0;
|
||||
//success = 0.0;
|
||||
//error = 0.0;
|
||||
}
|
||||
}
|
||||
session->pos = pos;
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -188,7 +188,7 @@ static switch_bool_t cidlookup_execute_sql_callback(char *sql, switch_core_db_ca
|
||||
switch_bool_t retval = SWITCH_FALSE;
|
||||
switch_cache_db_handle_t *dbh = NULL;
|
||||
|
||||
if (globals.odbc_dsn && (dbh = cidlookup_get_db_handle())) {
|
||||
if (!zstr(globals.odbc_dsn) && (dbh = cidlookup_get_db_handle())) {
|
||||
if (switch_cache_db_execute_sql_callback(dbh, sql, callback, (void *) cbt, err) != SWITCH_STATUS_SUCCESS) {
|
||||
retval = SWITCH_FALSE;
|
||||
} else {
|
||||
@@ -533,7 +533,7 @@ static char *do_db_lookup(switch_memory_pool_t *pool, switch_event_t *event, con
|
||||
callback_t cbt = { 0 };
|
||||
cbt.pool = pool;
|
||||
|
||||
if (globals.odbc_dsn) {
|
||||
if (!zstr(globals.odbc_dsn)) {
|
||||
newsql = switch_event_expand_headers(event, sql);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "SQL: %s\n", newsql);
|
||||
if (cidlookup_execute_sql_callback(newsql, cidlookup_callback, &cbt, &err)) {
|
||||
@@ -655,8 +655,6 @@ static cid_data_t *do_lookup(switch_memory_pool_t *pool, switch_event_t *event,
|
||||
|
||||
SWITCH_STANDARD_APP(cidlookup_app_function)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
char *argv[4] = { 0 };
|
||||
int argc;
|
||||
char *mydata = NULL;
|
||||
@@ -705,7 +703,7 @@ SWITCH_STANDARD_APP(cidlookup_app_function)
|
||||
|
||||
if (switch_string_var_check_const(cid->name)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name);
|
||||
switch_goto_status(SWITCH_STATUS_GENERR, done);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (cid && channel) {
|
||||
@@ -719,7 +717,6 @@ SWITCH_STANDARD_APP(cidlookup_app_function)
|
||||
profile->caller_id_name = switch_core_strdup(profile->pool, cid->name);;
|
||||
}
|
||||
|
||||
switch_goto_status(SWITCH_STATUS_SUCCESS, done);
|
||||
|
||||
done:
|
||||
if (event) {
|
||||
@@ -728,9 +725,6 @@ SWITCH_STANDARD_APP(cidlookup_app_function)
|
||||
if (!session && pool) {
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
}
|
||||
/* This is so compile doesn't failed because status is never used */
|
||||
if (status) {
|
||||
}
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(cidlookup_function)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -1559,27 +1559,22 @@ SWITCH_STANDARD_API(regex_function)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((proceed = switch_regex_perform(argv[0], argv[1], &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
if (argc > 2) {
|
||||
len = (strlen(argv[0]) + strlen(argv[2]) + 10) * proceed;
|
||||
substituted = malloc(len);
|
||||
switch_assert(substituted);
|
||||
memset(substituted, 0, len);
|
||||
switch_replace_char(argv[2], '%', '$', SWITCH_FALSE);
|
||||
switch_perform_substitution(re, proceed, argv[2], argv[0], substituted, len, ovector);
|
||||
proceed = switch_regex_perform(argv[0], argv[1], &re, ovector, sizeof(ovector) / sizeof(ovector[0]));
|
||||
|
||||
stream->write_function(stream, "%s", substituted);
|
||||
free(substituted);
|
||||
} else {
|
||||
stream->write_function(stream, "true");
|
||||
}
|
||||
if (argc > 2) {
|
||||
len = (strlen(argv[0]) + strlen(argv[2]) + 10) * proceed;
|
||||
substituted = malloc(len);
|
||||
switch_assert(substituted);
|
||||
memset(substituted, 0, len);
|
||||
switch_replace_char(argv[2], '%', '$', SWITCH_FALSE);
|
||||
switch_perform_substitution(re, proceed, argv[2], argv[0], substituted, len, ovector);
|
||||
|
||||
stream->write_function(stream, "%s", substituted);
|
||||
free(substituted);
|
||||
} else {
|
||||
if (argc > 2) {
|
||||
stream->write_function(stream, "%s", argv[0]);
|
||||
} else {
|
||||
stream->write_function(stream, "false");
|
||||
}
|
||||
stream->write_function(stream, proceed ? "true" : "false");
|
||||
}
|
||||
|
||||
goto ok;
|
||||
|
||||
error:
|
||||
@@ -2649,9 +2644,10 @@ SWITCH_STANDARD_API(sched_hangup_function)
|
||||
char *cause_str = argv[2];
|
||||
time_t when;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT;
|
||||
int sec = atol(argv[0] + 1);
|
||||
|
||||
if (*argv[0] == '+') {
|
||||
when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
|
||||
when = switch_epoch_time_now(NULL) + sec;
|
||||
} else {
|
||||
when = atol(argv[0]);
|
||||
}
|
||||
@@ -2661,7 +2657,13 @@ SWITCH_STANDARD_API(sched_hangup_function)
|
||||
}
|
||||
|
||||
if ((hsession = switch_core_session_locate(uuid))) {
|
||||
switch_ivr_schedule_hangup(when, uuid, cause, SWITCH_FALSE);
|
||||
if (sec == 0) {
|
||||
switch_channel_t *hchannel = switch_core_session_get_channel(hsession);
|
||||
switch_channel_hangup(hchannel, cause);
|
||||
} else {
|
||||
switch_ivr_schedule_hangup(when, uuid, cause, SWITCH_FALSE);
|
||||
}
|
||||
|
||||
stream->write_function(stream, "+OK\n");
|
||||
switch_core_session_rwunlock(hsession);
|
||||
} else {
|
||||
|
||||
@@ -120,6 +120,10 @@
|
||||
<!-- <param name="ivr-input-timeout" value="0" /> -->
|
||||
<!-- Delay before a conference is asked to be terminated -->
|
||||
<!-- <param name="endconf-grace-time" value="120" /> -->
|
||||
<!-- Can be | delim of wait-mod|audio-always|video-bridge|video-floor-only
|
||||
wait_mod will wait until the moderator in,
|
||||
audio-always will always mix audio from all members regardless they are talking or not -->
|
||||
<!-- <param name="conference-flags" value="audio-always"/> -->
|
||||
</profile>
|
||||
|
||||
<profile name="wideband">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -83,7 +83,7 @@ static int EC = 0;
|
||||
/* the maximum value for the IIR score [keeps loud & longwinded people from getting overweighted] */
|
||||
#define SCORE_MAX_IIR 25000
|
||||
/* the minimum score for which you can be considered to be loud enough to now have the floor */
|
||||
#define SCORE_IIR_SPEAKING_MAX 3000
|
||||
#define SCORE_IIR_SPEAKING_MAX 300
|
||||
/* the threshold below which you cede the floor to someone loud (see above value). */
|
||||
#define SCORE_IIR_SPEAKING_MIN 100
|
||||
|
||||
@@ -174,7 +174,8 @@ typedef enum {
|
||||
CFLAG_INHASH = (1 << 11),
|
||||
CFLAG_EXIT_SOUND = (1 << 12),
|
||||
CFLAG_ENTER_SOUND = (1 << 13),
|
||||
CFLAG_VIDEO_BRIDGE = (1 << 14)
|
||||
CFLAG_VIDEO_BRIDGE = (1 << 14),
|
||||
CFLAG_AUDIO_ALWAYS = (1 << 15)
|
||||
} conf_flag_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -216,7 +217,8 @@ typedef enum {
|
||||
EFLAG_FLOOR_CHANGE = (1 << 25),
|
||||
EFLAG_MUTE_DETECT = (1 << 26),
|
||||
EFLAG_RECORD = (1 << 27),
|
||||
EFLAG_HUP_MEMBER = (1 << 28)
|
||||
EFLAG_HUP_MEMBER = (1 << 28),
|
||||
EFLAG_PLAY_FILE_DONE = (1 << 29),
|
||||
} event_type_t;
|
||||
|
||||
typedef struct conference_file_node {
|
||||
@@ -334,6 +336,7 @@ typedef struct conference_obj {
|
||||
switch_time_t end_time;
|
||||
char *log_dir;
|
||||
struct vid_helper vh[2];
|
||||
struct vid_helper mh;
|
||||
} conference_obj_t;
|
||||
|
||||
/* Relationship with another member */
|
||||
@@ -476,7 +479,8 @@ static switch_status_t chat_send(switch_event_t *message_event);
|
||||
|
||||
|
||||
static void launch_conference_record_thread(conference_obj_t *conference, char *path);
|
||||
static void launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b);
|
||||
static int launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b);
|
||||
static void launch_conference_video_mirror_thread(conference_member_t *member_a);
|
||||
|
||||
typedef switch_status_t (*conf_api_args_cmd_t) (conference_obj_t *, switch_stream_handle_t *, int, char **);
|
||||
typedef switch_status_t (*conf_api_member_cmd_t) (conference_member_t *, switch_stream_handle_t *, void *);
|
||||
@@ -657,9 +661,10 @@ static void conference_cdr_render(conference_obj_t *conference)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_safe_free(path);
|
||||
switch_safe_free(xml_text);
|
||||
switch_xml_free(cdr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1220,6 +1225,62 @@ static void *SWITCH_THREAD_FUNC conference_video_bridge_thread_run(switch_thread
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void *SWITCH_THREAD_FUNC conference_video_mirror_thread_run(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
struct vid_helper *vh = obj;
|
||||
switch_core_session_t *session_a = vh->member_a->session;
|
||||
switch_channel_t *channel_a = switch_core_session_get_channel(session_a);
|
||||
switch_status_t status;
|
||||
switch_frame_t *read_frame;
|
||||
conference_obj_t *conference = vh->member_a->conference;
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
|
||||
switch_thread_rwlock_rdlock(conference->rwlock);
|
||||
switch_thread_rwlock_rdlock(vh->member_a->rwlock);
|
||||
|
||||
/* Acquire locks for both sessions so the helper object and member structures don't get destroyed before we exit */
|
||||
switch_core_session_read_lock(session_a);
|
||||
|
||||
/* Tell the channel to request a fresh vid frame */
|
||||
msg.from = __FILE__;
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
|
||||
switch_core_session_receive_message(session_a, &msg);
|
||||
|
||||
vh->up = 1;
|
||||
while (vh->up > 0 && switch_test_flag(vh->member_a, MFLAG_RUNNING) &&
|
||||
switch_channel_ready(channel_a)) {
|
||||
|
||||
if (vh->up == 1) {
|
||||
status = switch_core_session_read_video_frame(session_a, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!switch_test_flag(read_frame, SFF_CNG)) {
|
||||
if (switch_core_session_write_video_frame(session_a, read_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch_yield(100000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_thread_rwlock_unlock(vh->member_a->rwlock);
|
||||
|
||||
switch_core_session_rwunlock(session_a);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s video mirror thread ended.\n", switch_channel_get_name(channel_a));
|
||||
|
||||
switch_thread_rwlock_unlock(conference->rwlock);
|
||||
|
||||
vh->up = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Main video monitor thread (1 per distinct conference room) */
|
||||
static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thread, void *obj)
|
||||
{
|
||||
@@ -1522,8 +1583,22 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
switch_channel_ready(switch_core_session_get_channel(video_bridge_members[0]->session)) &&
|
||||
switch_channel_ready(switch_core_session_get_channel(video_bridge_members[1]->session))
|
||||
) {
|
||||
conference->mh.up = 2;
|
||||
if (launch_conference_video_bridge_thread(video_bridge_members[0], video_bridge_members[1])) {
|
||||
conference->mh.up = 1;
|
||||
} else {
|
||||
conference->mh.up = -1;
|
||||
}
|
||||
} else if (conference->vh[0].up == 0 &&
|
||||
conference->vh[1].up == 0 &&
|
||||
conference->mh.up == 0 &&
|
||||
video_bridge_members[0] &&
|
||||
!video_bridge_members[1] &&
|
||||
switch_test_flag(video_bridge_members[0], MFLAG_RUNNING) &&
|
||||
switch_channel_ready(switch_core_session_get_channel(video_bridge_members[0]->session))
|
||||
) {
|
||||
|
||||
launch_conference_video_bridge_thread(video_bridge_members[0], video_bridge_members[1]);
|
||||
launch_conference_video_mirror_thread(video_bridge_members[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1547,7 +1622,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||
}
|
||||
|
||||
if (file_sample_len <= 0) {
|
||||
if (test_eflag(conference, EFLAG_PLAY_FILE) &&
|
||||
if (test_eflag(conference, EFLAG_PLAY_FILE_DONE) &&
|
||||
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
|
||||
conference_add_event_data(conference, event);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "play-file-done");
|
||||
@@ -2500,6 +2575,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
|
||||
switch_clear_flag_locked(member, MFLAG_TALKING);
|
||||
check_agc_levels(member);
|
||||
clear_avg(member);
|
||||
member->score_iir = 0;
|
||||
|
||||
if (test_eflag(member->conference, EFLAG_STOP_TALKING) &&
|
||||
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -2670,8 +2746,8 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
|
||||
}
|
||||
|
||||
/* skip frames that are not actual media or when we are muted or silent */
|
||||
if ((switch_test_flag(member, MFLAG_TALKING) || member->energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) &&
|
||||
!switch_test_flag(member->conference, CFLAG_WAIT_MOD)) {
|
||||
if ((switch_test_flag(member, MFLAG_TALKING) || member->energy_level == 0 || switch_test_flag(member->conference, CFLAG_AUDIO_ALWAYS))
|
||||
&& switch_test_flag(member, MFLAG_CAN_SPEAK) && !switch_test_flag(member->conference, CFLAG_WAIT_MOD)) {
|
||||
switch_audio_resampler_t *read_resampler = member->read_resampler;
|
||||
void *data;
|
||||
uint32_t datalen;
|
||||
@@ -4426,6 +4502,10 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer
|
||||
switch_xml_set_attr_d(x_conference, "wait_mod", "true");
|
||||
}
|
||||
|
||||
if (switch_test_flag(conference, CFLAG_AUDIO_ALWAYS)) {
|
||||
switch_xml_set_attr_d(x_conference, "audio_always", "true");
|
||||
}
|
||||
|
||||
if (switch_test_flag(conference, CFLAG_RUNNING)) {
|
||||
switch_xml_set_attr_d(x_conference, "running", "true");
|
||||
}
|
||||
@@ -5605,6 +5685,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
|
||||
char appdata[512];
|
||||
int rdlock = 0;
|
||||
switch_bool_t have_flags = SWITCH_FALSE;
|
||||
const char *outcall_flags;
|
||||
|
||||
*cause = SWITCH_CAUSE_NORMAL_CLEARING;
|
||||
|
||||
@@ -5690,6 +5771,12 @@ static switch_status_t conference_outcall(conference_obj_t *conference,
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((outcall_flags = switch_channel_get_variable(peer_channel, "outcall_flags"))) {
|
||||
if (!zstr(outcall_flags)) {
|
||||
flags = (char *)outcall_flags;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags && strcasecmp(flags, "none")) {
|
||||
have_flags = SWITCH_TRUE;
|
||||
}
|
||||
@@ -5962,6 +6049,8 @@ static void set_cflags(const char *flags, uint32_t *f)
|
||||
*f |= CFLAG_VID_FLOOR;
|
||||
} else if (!strcasecmp(argv[i], "video-bridge")) {
|
||||
*f |= CFLAG_VIDEO_BRIDGE;
|
||||
} else if (!strcasecmp(argv[i], "audio-always")) {
|
||||
*f |= CFLAG_AUDIO_ALWAYS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6019,6 +6108,8 @@ static void clear_eflags(char *events, uint32_t *f)
|
||||
*f &= ~EFLAG_VOLUME_OUT_MEMBER;
|
||||
} else if (!strcmp(event, "play-file")) {
|
||||
*f &= ~EFLAG_PLAY_FILE;
|
||||
} else if (!strcmp(event, "play-file-done")) {
|
||||
*f &= ~EFLAG_PLAY_FILE;
|
||||
} else if (!strcmp(event, "play-file-member")) {
|
||||
*f &= ~EFLAG_PLAY_FILE_MEMBER;
|
||||
} else if (!strcmp(event, "speak-text")) {
|
||||
@@ -6756,11 +6847,11 @@ static void launch_conference_video_thread(conference_obj_t *conference)
|
||||
}
|
||||
|
||||
/* Create a video thread for the conference and launch it */
|
||||
static void launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b)
|
||||
static int launch_conference_video_bridge_thread(conference_member_t *member_a, conference_member_t *member_b)
|
||||
{
|
||||
conference_obj_t *conference = member_a->conference;
|
||||
switch_memory_pool_t *pool = conference->pool;
|
||||
int sanity = 10000;
|
||||
int sanity = 10000, r = 0;
|
||||
|
||||
memset(conference->vh, 0, sizeof(conference->vh));
|
||||
|
||||
@@ -6779,14 +6870,33 @@ static void launch_conference_video_bridge_thread(conference_member_t *member_a,
|
||||
|
||||
if (conference->vh[0].up == 1 && conference->vh[1].up != 1) {
|
||||
conference->vh[0].up = -1;
|
||||
r = -1;
|
||||
}
|
||||
|
||||
if (conference->vh[1].up == 1 && conference->vh[0].up != 1) {
|
||||
conference->vh[1].up = -1;
|
||||
r = -1;
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Create a video thread for the conference and launch it */
|
||||
static void launch_conference_video_mirror_thread(conference_member_t *member_a)
|
||||
{
|
||||
conference_obj_t *conference = member_a->conference;
|
||||
switch_memory_pool_t *pool = conference->pool;
|
||||
|
||||
memset(&conference->mh, 0, sizeof(conference->mh));
|
||||
|
||||
conference->mh.member_a = member_a;
|
||||
|
||||
launch_thread_detached(conference_video_mirror_thread_run, pool, &conference->mh);
|
||||
}
|
||||
|
||||
static void launch_conference_record_thread(conference_obj_t *conference, char *path)
|
||||
{
|
||||
switch_thread_t *thread;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -24,7 +24,7 @@
|
||||
* Contributor(s):
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Ken Rice, Asteria Solutions Group, Inc <ken@asteriasgi.com>
|
||||
* Ken Rice <krice@freeswitch.org>
|
||||
* Michael Murdock <mike at mmurdock dot org>
|
||||
* Neal Horman <neal at wanlink dot com>
|
||||
* Bret McDanel <trixter AT 0xdecafbad dot com>
|
||||
@@ -38,7 +38,8 @@
|
||||
#include <switch.h>
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_dptools, mod_dptools_load, NULL, NULL);
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dptools_shutdown);
|
||||
SWITCH_MODULE_DEFINITION(mod_dptools, mod_dptools_load, mod_dptools_shutdown, NULL);
|
||||
|
||||
SWITCH_STANDARD_DIALPLAN(inline_dialplan_hunt)
|
||||
{
|
||||
@@ -464,6 +465,7 @@ SWITCH_STANDARD_APP(play_and_detect_speech_function)
|
||||
char *lbuf = NULL;
|
||||
const char *response = "DONE";
|
||||
char *detect = NULL;
|
||||
char *s;
|
||||
|
||||
switch_channel_set_variable(channel, "detect_speech_result", "");
|
||||
|
||||
@@ -474,6 +476,12 @@ SWITCH_STANDARD_APP(play_and_detect_speech_function)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* trim any trailing space */
|
||||
s = detect;
|
||||
while (--s >= lbuf && switch_isspace(*s)) {
|
||||
*s = '\0';
|
||||
}
|
||||
|
||||
/* split input at "detect:" */
|
||||
detect[0] = '\0';
|
||||
detect += 7;
|
||||
@@ -1021,9 +1029,10 @@ SWITCH_STANDARD_APP(sched_hangup_function)
|
||||
time_t when;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT;
|
||||
switch_bool_t bleg = SWITCH_FALSE;
|
||||
int sec = atol(argv[0] + 1);
|
||||
|
||||
if (*argv[0] == '+') {
|
||||
when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
|
||||
when = switch_epoch_time_now(NULL) + sec;
|
||||
} else {
|
||||
when = atol(argv[0]);
|
||||
}
|
||||
@@ -1036,7 +1045,11 @@ SWITCH_STANDARD_APP(sched_hangup_function)
|
||||
bleg = SWITCH_TRUE;
|
||||
}
|
||||
|
||||
switch_ivr_schedule_hangup(when, switch_core_session_get_uuid(session), cause, bleg);
|
||||
if (sec == 0) {
|
||||
switch_channel_hangup(switch_core_session_get_channel(session), cause);
|
||||
} else {
|
||||
switch_ivr_schedule_hangup(when, switch_core_session_get_uuid(session), cause, bleg);
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No time specified.\n");
|
||||
}
|
||||
@@ -1965,7 +1978,7 @@ SWITCH_STANDARD_APP(speak_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char buf[10];
|
||||
char *argv[4] = { 0 };
|
||||
char *argv[3] = { 0 };
|
||||
int argc;
|
||||
const char *engine = NULL;
|
||||
const char *voice = NULL;
|
||||
@@ -1984,14 +1997,14 @@ SWITCH_STANDARD_APP(speak_function)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Params!\n");
|
||||
return;
|
||||
} else if (argc == 1) {
|
||||
text = argv[0];
|
||||
text = switch_core_session_strdup(session, data); /* unstripped text */
|
||||
} else if (argc == 2) {
|
||||
voice = argv[0];
|
||||
text = argv[1];
|
||||
text = switch_core_session_strdup(session, data + (argv[1] - argv[0])); /* unstripped text */
|
||||
} else {
|
||||
engine = argv[0];
|
||||
voice = argv[1];
|
||||
text = argv[2];
|
||||
text = switch_core_session_strdup(session, data + (argv[2] - argv[0])); /* unstripped text */
|
||||
}
|
||||
|
||||
if (!engine) {
|
||||
@@ -2109,6 +2122,12 @@ static switch_status_t hanguphook(switch_core_session_t *session)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static void att_xfer_set_result(switch_channel_t *channel, switch_status_t status)
|
||||
{
|
||||
switch_channel_set_variable(channel, SWITCH_ATT_XFER_RESULT_VARIABLE, status == SWITCH_STATUS_SUCCESS ? "success" : "failure");
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(att_xfer_function)
|
||||
{
|
||||
switch_core_session_t *peer_session = NULL;
|
||||
@@ -2154,7 +2173,8 @@ SWITCH_STANDARD_APP(att_xfer_function)
|
||||
|
||||
if (!switch_channel_down(peer_channel)) {
|
||||
if (!switch_channel_ready(channel)) {
|
||||
switch_ivr_uuid_bridge(switch_core_session_get_uuid(peer_session), bond);
|
||||
switch_status_t status = switch_ivr_uuid_bridge(switch_core_session_get_uuid(peer_session), bond);
|
||||
att_xfer_set_result(peer_channel, status);
|
||||
br++;
|
||||
} else if ((b_session = switch_core_session_locate(bond))) {
|
||||
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
|
||||
@@ -2172,7 +2192,8 @@ SWITCH_STANDARD_APP(att_xfer_function)
|
||||
}
|
||||
|
||||
if (!br) {
|
||||
switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), bond);
|
||||
switch_status_t status = switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), bond);
|
||||
att_xfer_set_result(channel, status);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2766,7 +2787,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
|
||||
switch_thread_t *thread = NULL;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
char *camp_data = NULL;
|
||||
switch_status_t status;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
int camp_loops = 0;
|
||||
|
||||
if (zstr(data)) {
|
||||
@@ -3087,6 +3108,485 @@ SWITCH_STANDARD_APP(audio_bridge_function)
|
||||
}
|
||||
}
|
||||
|
||||
static struct {
|
||||
switch_memory_pool_t *pool;
|
||||
switch_hash_t *pickup_hash;
|
||||
switch_mutex_t *pickup_mutex;
|
||||
} globals;
|
||||
|
||||
/* pickup channel */
|
||||
|
||||
|
||||
|
||||
typedef struct pickup_node_s {
|
||||
char *key;
|
||||
char *uuid;
|
||||
struct pickup_node_s *next;
|
||||
} pickup_node_t;
|
||||
|
||||
|
||||
#define PICKUP_PROTO "pickup"
|
||||
static int EC = 0;
|
||||
|
||||
static int pickup_count(const char *key_name)
|
||||
{
|
||||
int count = 0;
|
||||
pickup_node_t *head, *np;
|
||||
|
||||
switch_mutex_lock(globals.pickup_mutex);
|
||||
if ((head = switch_core_hash_find(globals.pickup_hash, key_name))) {
|
||||
for (np = head; np; np = np->next) count++;
|
||||
}
|
||||
switch_mutex_unlock(globals.pickup_mutex);
|
||||
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
static void pickup_send_presence(const char *key_name)
|
||||
{
|
||||
|
||||
char *domain_name, *dup_key_name = NULL, *dup_domain_name = NULL, *dup_id = NULL;
|
||||
switch_event_t *event;
|
||||
int count;
|
||||
|
||||
|
||||
dup_key_name = strdup(key_name);
|
||||
key_name = dup_key_name;
|
||||
|
||||
if ((domain_name = strchr(dup_key_name, '@'))) {
|
||||
*domain_name++ = '\0';
|
||||
}
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
dup_domain_name = switch_core_get_variable_dup("domain");
|
||||
domain_name = dup_domain_name;
|
||||
}
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
domain_name = "cluecon.com";
|
||||
}
|
||||
|
||||
dup_id = switch_mprintf("%s@%s", key_name, domain_name);
|
||||
|
||||
count = pickup_count(dup_id);
|
||||
|
||||
if (count > 0) {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", dup_id);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", dup_id);
|
||||
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d call%s)", count, count == 1 ? "" : "s");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", key_name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
} else {
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", dup_id);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", dup_id);
|
||||
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", dup_id);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free(dup_domain_name);
|
||||
switch_safe_free(dup_key_name);
|
||||
switch_safe_free(dup_id);
|
||||
|
||||
}
|
||||
|
||||
static void pickup_pres_event_handler(switch_event_t *event)
|
||||
{
|
||||
char *to = switch_event_get_header(event, "to");
|
||||
char *dup_to = NULL, *key_name, *dup_key_name = NULL, *domain_name, *dup_domain_name = NULL;
|
||||
int count = 0;
|
||||
|
||||
if (!to || strncasecmp(to, "pickup+", 7) || !strchr(to, '@')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(dup_to = strdup(to))) {
|
||||
return;
|
||||
}
|
||||
|
||||
key_name = dup_to + 7;
|
||||
|
||||
if ((domain_name = strchr(key_name, '@'))) {
|
||||
*domain_name++ = '\0';
|
||||
} else {
|
||||
dup_domain_name = switch_core_get_variable_dup("domain");
|
||||
domain_name = dup_domain_name;
|
||||
}
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
switch_safe_free(dup_to);
|
||||
return;
|
||||
}
|
||||
|
||||
dup_key_name = switch_mprintf("%q@%q", key_name, domain_name);
|
||||
count = pickup_count(dup_key_name);
|
||||
|
||||
switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN);
|
||||
|
||||
if (count) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", key_name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", key_name, domain_name);
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d call%s)", count, count == 1 ? "" : "s");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", key_name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||
} else {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", key_name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", key_name, domain_name);
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", key_name);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||
|
||||
}
|
||||
|
||||
switch_event_fire(&event);
|
||||
switch_safe_free(dup_to);
|
||||
switch_safe_free(dup_key_name);
|
||||
switch_safe_free(dup_domain_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void pickup_add_session(switch_core_session_t *session, const char *key)
|
||||
{
|
||||
pickup_node_t *head, *node, *np;
|
||||
char *dup_key = NULL;
|
||||
|
||||
if (!strchr(key, '@')) {
|
||||
dup_key = switch_mprintf("%s@%s", key, switch_core_get_variable("domain"));
|
||||
key = dup_key;
|
||||
}
|
||||
|
||||
node = malloc(sizeof(*node));
|
||||
node->key = strdup(key);
|
||||
node->uuid = strdup(switch_core_session_get_uuid(session));
|
||||
node->next = NULL;
|
||||
|
||||
switch_mutex_lock(globals.pickup_mutex);
|
||||
head = switch_core_hash_find(globals.pickup_hash, key);
|
||||
|
||||
if (head) {
|
||||
for (np = head; np && np->next; np = np->next);
|
||||
np->next = node;
|
||||
} else {
|
||||
head = node;
|
||||
switch_core_hash_insert(globals.pickup_hash, key, head);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(globals.pickup_mutex);
|
||||
|
||||
pickup_send_presence(key);
|
||||
|
||||
switch_safe_free(dup_key);
|
||||
}
|
||||
|
||||
static char *pickup_pop_uuid(const char *key, const char *uuid)
|
||||
{
|
||||
pickup_node_t *node = NULL, *head;
|
||||
char *r = NULL;
|
||||
char *dup_key = NULL;
|
||||
|
||||
if (!strchr(key, '@')) {
|
||||
dup_key = switch_mprintf("%s@%s", key, switch_core_get_variable("domain"));
|
||||
key = dup_key;
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.pickup_mutex);
|
||||
|
||||
if ((head = switch_core_hash_find(globals.pickup_hash, key))) {
|
||||
|
||||
switch_core_hash_delete(globals.pickup_hash, key);
|
||||
|
||||
if (uuid) {
|
||||
pickup_node_t *np, *lp = NULL;
|
||||
|
||||
for(np = head; np; np = np->next) {
|
||||
if (!strcmp(np->uuid, uuid)) {
|
||||
if (lp) {
|
||||
lp->next = np->next;
|
||||
} else {
|
||||
head = np->next;
|
||||
}
|
||||
|
||||
node = np;
|
||||
break;
|
||||
}
|
||||
|
||||
lp = np;
|
||||
}
|
||||
|
||||
} else {
|
||||
node = head;
|
||||
head = head->next;
|
||||
}
|
||||
|
||||
|
||||
if (head) {
|
||||
switch_core_hash_insert(globals.pickup_hash, key, head);
|
||||
}
|
||||
}
|
||||
|
||||
if (node) {
|
||||
r = node->uuid;
|
||||
free(node->key);
|
||||
free(node);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(globals.pickup_mutex);
|
||||
|
||||
if (r) pickup_send_presence(key);
|
||||
|
||||
switch_safe_free(dup_key);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
typedef struct pickup_pvt_s {
|
||||
char *key;
|
||||
switch_event_t *vars;
|
||||
} pickup_pvt_t;
|
||||
|
||||
switch_endpoint_interface_t *pickup_endpoint_interface;
|
||||
static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *session,
|
||||
switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
|
||||
switch_call_cause_t *cancel_cause);
|
||||
switch_io_routines_t pickup_io_routines = {
|
||||
/*.outgoing_channel */ pickup_outgoing_channel
|
||||
};
|
||||
|
||||
static switch_status_t pickup_event_handler(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_channel_state_t state = switch_channel_get_running_state(channel);
|
||||
pickup_pvt_t *tech_pvt = switch_core_session_get_private(session);
|
||||
|
||||
switch(state) {
|
||||
case CS_DESTROY:
|
||||
if (tech_pvt->vars) {
|
||||
switch_event_destroy(&tech_pvt->vars);
|
||||
}
|
||||
break;
|
||||
case CS_REPORTING:
|
||||
return SWITCH_STATUS_FALSE;
|
||||
case CS_HANGUP:
|
||||
{
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_CHANNEL_SWAP)) {
|
||||
const char *key = switch_channel_get_variable(channel, "channel_swap_uuid");
|
||||
switch_core_session_t *swap_session;
|
||||
|
||||
if ((swap_session = switch_core_session_locate(key))) {
|
||||
switch_channel_t *swap_channel = switch_core_session_get_channel(swap_session);
|
||||
switch_channel_hangup(swap_channel, SWITCH_CAUSE_PICKED_OFF);
|
||||
switch_core_session_rwunlock(swap_session);
|
||||
}
|
||||
switch_channel_clear_flag(channel, CF_CHANNEL_SWAP);
|
||||
}
|
||||
|
||||
pickup_pop_uuid(tech_pvt->key, switch_core_session_get_uuid(session));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_state_handler_table_t pickup_event_handlers = {
|
||||
/*.on_init */ pickup_event_handler,
|
||||
/*.on_routing */ pickup_event_handler,
|
||||
/*.on_execute */ pickup_event_handler,
|
||||
/*.on_hangup */ pickup_event_handler,
|
||||
/*.on_exchange_media */ pickup_event_handler,
|
||||
/*.on_soft_execute */ pickup_event_handler,
|
||||
/*.on_consume_media */ pickup_event_handler,
|
||||
/*.on_hibernate */ pickup_event_handler,
|
||||
/*.on_reset */ pickup_event_handler,
|
||||
/*.on_park */ pickup_event_handler,
|
||||
/*.on_reporting */ pickup_event_handler,
|
||||
/*.on_destroy */ pickup_event_handler
|
||||
};
|
||||
|
||||
static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *session,
|
||||
switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
|
||||
switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
char *pickup;
|
||||
switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
switch_core_session_t *nsession;
|
||||
switch_channel_t *nchannel;
|
||||
char *name;
|
||||
pickup_pvt_t *tech_pvt;
|
||||
switch_caller_profile_t *caller_profile;
|
||||
|
||||
if (zstr(outbound_profile->destination_number)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
pickup = outbound_profile->destination_number;
|
||||
|
||||
|
||||
if (!(nsession = switch_core_session_request(pickup_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
tech_pvt = switch_core_session_alloc(nsession, sizeof(*tech_pvt));
|
||||
tech_pvt->key = switch_core_session_strdup(nsession, pickup);
|
||||
switch_event_dup(&tech_pvt->vars, var_event);
|
||||
|
||||
switch_core_session_set_private(nsession, tech_pvt);
|
||||
|
||||
nchannel = switch_core_session_get_channel(nsession);
|
||||
caller_profile = switch_caller_profile_clone(nsession, outbound_profile);
|
||||
switch_channel_set_caller_profile(nchannel, caller_profile);
|
||||
|
||||
switch_channel_set_state(nchannel, CS_ROUTING);
|
||||
|
||||
|
||||
|
||||
*new_session = nsession;
|
||||
cause = SWITCH_CAUSE_SUCCESS;
|
||||
name = switch_core_session_sprintf(nsession, "pickup/%s", pickup);
|
||||
switch_channel_set_name(nchannel, name);
|
||||
switch_channel_set_variable(nchannel, "process_cdr", "false");
|
||||
pickup_add_session(nsession, pickup);
|
||||
switch_channel_set_flag(nchannel, CF_PICKUP);
|
||||
|
||||
goto done;
|
||||
|
||||
error:
|
||||
|
||||
if (nsession) {
|
||||
switch_core_session_destroy(&nsession);
|
||||
}
|
||||
|
||||
if (pool) {
|
||||
*pool = NULL;
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
|
||||
return cause;
|
||||
}
|
||||
|
||||
#define PICKUP_SYNTAX "[<key>]"
|
||||
SWITCH_STANDARD_APP(pickup_function)
|
||||
{
|
||||
char *uuid = NULL;
|
||||
switch_core_session_t *pickup_session;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (zstr(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing data. Usage: pickup %s\n", PICKUP_SYNTAX);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((uuid = pickup_pop_uuid((char *)data, NULL))) {
|
||||
if ((pickup_session = switch_core_session_locate(uuid))) {
|
||||
switch_channel_t *pickup_channel = switch_core_session_get_channel(pickup_session);
|
||||
switch_caller_profile_t *pickup_caller_profile = switch_channel_get_caller_profile(pickup_channel),
|
||||
*caller_profile = switch_channel_get_caller_profile(channel);
|
||||
const char *name, *num;
|
||||
switch_event_t *event;
|
||||
switch_event_header_t *hp;
|
||||
pickup_pvt_t *tech_pvt = switch_core_session_get_private(pickup_session);
|
||||
|
||||
for(hp = tech_pvt->vars->headers; hp; hp = hp->next) {
|
||||
switch_channel_set_variable(channel, hp->name, hp->value);
|
||||
}
|
||||
|
||||
|
||||
switch_channel_set_flag(pickup_channel, CF_CHANNEL_SWAP);
|
||||
switch_channel_set_variable(pickup_channel, "channel_swap_uuid", switch_core_session_get_uuid(session));
|
||||
|
||||
name = caller_profile->caller_id_name;
|
||||
num = caller_profile->caller_id_number;
|
||||
|
||||
caller_profile->caller_id_name = switch_core_strdup(caller_profile->pool, pickup_caller_profile->caller_id_name);
|
||||
caller_profile->caller_id_number = switch_core_strdup(caller_profile->pool, pickup_caller_profile->caller_id_number);
|
||||
|
||||
caller_profile->callee_id_name = name;
|
||||
caller_profile->callee_id_number = num;
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
|
||||
const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
|
||||
|
||||
if (!uuid) {
|
||||
uuid = switch_channel_get_variable(channel, "originate_signal_bond");
|
||||
}
|
||||
|
||||
|
||||
if (uuid) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
|
||||
}
|
||||
switch_channel_event_set_data(channel, event);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
|
||||
switch_channel_set_state(channel, CS_HIBERNATE);
|
||||
|
||||
switch_channel_mark_answered(pickup_channel);
|
||||
switch_core_session_rwunlock(pickup_session);
|
||||
}
|
||||
free(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* fake chan_error */
|
||||
switch_endpoint_interface_t *error_endpoint_interface;
|
||||
static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session,
|
||||
@@ -3936,7 +4436,7 @@ static switch_status_t file_string_file_read(switch_file_handle_t *handle, void
|
||||
*len = context->samples;
|
||||
}
|
||||
|
||||
context->samples -= *len;
|
||||
context->samples -= (int) *len;
|
||||
memset(data, 255, *len *2);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
@@ -3978,6 +4478,14 @@ static char *file_string_supported_formats[SWITCH_MAX_CODECS] = { 0 };
|
||||
#define LOG_LONG_DESC "Logs a channel variable for the channel calling the application."
|
||||
#define TRANSFER_LONG_DESC "Immediately transfer the calling channel to a new extension"
|
||||
#define SLEEP_LONG_DESC "Pause the channel for a given number of milliseconds, consuming the audio for that period of time."
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dptools_shutdown)
|
||||
{
|
||||
switch_event_unbind_callback(pickup_pres_event_handler);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
{
|
||||
switch_api_interface_t *api_interface;
|
||||
@@ -3986,12 +4494,19 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
switch_chat_interface_t *chat_interface;
|
||||
switch_file_interface_t *file_interface;
|
||||
|
||||
globals.pool = pool;
|
||||
switch_core_hash_init(&globals.pickup_hash, NULL);
|
||||
switch_mutex_init(&globals.pickup_mutex, SWITCH_MUTEX_NESTED, globals.pool);
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pickup_pres_event_handler, NULL);
|
||||
|
||||
|
||||
file_string_supported_formats[0] = "file_string";
|
||||
|
||||
file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE);
|
||||
file_interface = (switch_file_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE);
|
||||
file_interface->interface_name = modname;
|
||||
file_interface->extens = file_string_supported_formats;
|
||||
file_interface->file_open = file_string_file_open;
|
||||
@@ -4000,18 +4515,23 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
file_interface->file_seek = file_string_file_seek;
|
||||
|
||||
|
||||
error_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
error_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
error_endpoint_interface->interface_name = "error";
|
||||
error_endpoint_interface->io_routines = &error_io_routines;
|
||||
|
||||
group_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
group_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
group_endpoint_interface->interface_name = "group";
|
||||
group_endpoint_interface->io_routines = &group_io_routines;
|
||||
|
||||
user_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
user_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
user_endpoint_interface->interface_name = "user";
|
||||
user_endpoint_interface->io_routines = &user_io_routines;
|
||||
|
||||
pickup_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
pickup_endpoint_interface->interface_name = "pickup";
|
||||
pickup_endpoint_interface->io_routines = &pickup_io_routines;
|
||||
pickup_endpoint_interface->state_handler = &pickup_event_handlers;
|
||||
|
||||
SWITCH_ADD_CHAT(chat_interface, "event", event_chat_send);
|
||||
SWITCH_ADD_CHAT(chat_interface, "api", api_chat_send);
|
||||
|
||||
@@ -4186,6 +4706,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
SWITCH_ADD_APP(app_interface, "limit_execute", "Limit", LIMITEXECUTE_DESC, limit_execute_function, LIMITEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "limit_hash_execute", "Limit", LIMITHASHEXECUTE_DESC, limit_hash_execute_function, LIMITHASHEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "pickup", "Pickup", "Pickup a call", pickup_function, PICKUP_SYNTAX, SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
|
||||
SWITCH_ADD_DIALPLAN(dp_interface, "inline", inline_dialplan_hunt);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -226,7 +226,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
bytes = 16;
|
||||
switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes);
|
||||
|
||||
for (;;) {
|
||||
while (switch_channel_ready(channel)) {
|
||||
|
||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -1121,7 +1121,7 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
|
||||
"(fifo_name,caller_uuid,caller_caller_id_name,caller_caller_id_number,consumer_uuid,consumer_outgoing_uuid,bridge_start) "
|
||||
"values ('%q','%q','%q','%q','%q','%q',%ld)",
|
||||
MANUAL_QUEUE_NAME,
|
||||
"N/A",
|
||||
(msg->string_arg && strchr(msg->string_arg, '-')) ? msg->string_arg : "00000000-0000-0000-0000-000000000000",
|
||||
ced_name,
|
||||
ced_number,
|
||||
switch_core_session_get_uuid(session),
|
||||
@@ -2926,12 +2926,27 @@ SWITCH_STANDARD_APP(fifo_function)
|
||||
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_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,
|
||||
"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_variable(other_channel, "caller_id_number"),
|
||||
switch_channel_get_variable(channel, "caller_id_name"),
|
||||
switch_channel_get_variable(channel, "caller_id_number"));
|
||||
|
||||
switch_channel_wait_for_state_timeout(other_channel, CS_HIBERNATE, 5000);
|
||||
|
||||
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);
|
||||
@@ -2940,6 +2955,7 @@ SWITCH_STANDARD_APP(fifo_function)
|
||||
} else {
|
||||
switch_channel_hangup(other_channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
}
|
||||
switch_channel_set_variable(other_channel, "fifo_vip", "true");
|
||||
|
||||
switch_core_session_rwunlock(other_session);
|
||||
break;
|
||||
@@ -3098,6 +3114,7 @@ SWITCH_STANDARD_APP(fifo_function)
|
||||
|
||||
send_presence(node);
|
||||
check_cancel(node);
|
||||
|
||||
switch_core_session_rwunlock(other_session);
|
||||
|
||||
|
||||
@@ -3230,7 +3247,6 @@ SWITCH_STANDARD_APP(fifo_function)
|
||||
switch_channel_clear_app_flag_key(FIFO_APP_KEY, channel, FIFO_APP_BRIDGE_TAG);
|
||||
|
||||
switch_core_media_bug_resume(session);
|
||||
|
||||
}
|
||||
|
||||
struct xml_helper {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -451,8 +451,6 @@ SWITCH_STANDARD_APP(hash_function)
|
||||
value = strdup(argv[3]);
|
||||
switch_assert(value);
|
||||
switch_core_hash_insert(globals.db_hash, hash_key, value);
|
||||
} else {
|
||||
switch_safe_free(value);
|
||||
}
|
||||
|
||||
} else if (!strcasecmp(argv[0], "delete")) {
|
||||
@@ -466,9 +464,9 @@ SWITCH_STANDARD_APP(hash_function)
|
||||
}
|
||||
if ((value = switch_core_hash_find(globals.db_hash, hash_key))) {
|
||||
if(!strcmp(argv[3], value)) {
|
||||
switch_safe_free(value);
|
||||
switch_core_hash_delete(globals.db_hash, hash_key);
|
||||
}
|
||||
switch_safe_free(value);
|
||||
}
|
||||
} else {
|
||||
goto usage;
|
||||
@@ -527,7 +525,6 @@ SWITCH_STANDARD_API(hash_api_function)
|
||||
switch_thread_rwlock_wrlock(globals.db_hash_rwlock);
|
||||
if ((value = switch_core_hash_find(globals.db_hash, hash_key))) {
|
||||
stream->write_function(stream, "-ERR key already exists\n");
|
||||
switch_safe_free(value);
|
||||
} else {
|
||||
value = strdup(argv[3]);
|
||||
switch_assert(value);
|
||||
@@ -552,12 +549,12 @@ SWITCH_STANDARD_API(hash_api_function)
|
||||
switch_thread_rwlock_wrlock(globals.db_hash_rwlock);
|
||||
if ((value = switch_core_hash_find(globals.db_hash, hash_key))) {
|
||||
if(!strcmp(argv[3],value)) {
|
||||
switch_safe_free(value);
|
||||
switch_core_hash_delete(globals.db_hash, hash_key);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR Doesn't match\n");
|
||||
}
|
||||
switch_safe_free(value);
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR Not found\n");
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ user-agent : <string> mod_httapi/1.0 User Agent header value.
|
||||
|
||||
|
||||
<permissions>: * = default
|
||||
<permission name="" value="">
|
||||
<permission name="" value="true">
|
||||
|
||||
*set-params : <params> tag can be parsed for session params.
|
||||
set-vars : <variables> tag can be parsed to set channel vars.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -1142,7 +1142,8 @@ static switch_status_t parse_xml(client_t *client)
|
||||
switch_channel_get_variables(client->channel, &templ_data);
|
||||
switch_event_merge(templ_data, client->params);
|
||||
expanded = switch_event_expand_headers_check(templ_data, tag->txt,
|
||||
client->profile->var_params.expand_var_list, client->profile->var_params.api_list);
|
||||
client->profile->var_params.expand_var_list,
|
||||
client->profile->var_params.api_list, 0);
|
||||
switch_event_destroy(&templ_data);
|
||||
}
|
||||
|
||||
@@ -1324,7 +1325,7 @@ static void cleanup_attachments(client_t *client)
|
||||
|
||||
for (hp = client->params->headers; hp; hp = hp->next) {
|
||||
if (!strncasecmp(hp->name, "attach_file:", 12)) {
|
||||
if (switch_file_exists(hp->value, client->pool)) {
|
||||
if (switch_file_exists(hp->value, client->pool) == SWITCH_STATUS_SUCCESS) {
|
||||
printf("DELETE %s\n", hp->value);
|
||||
unlink(hp->value);
|
||||
}
|
||||
@@ -1498,7 +1499,7 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
|
||||
|
||||
if (method != NULL && strcasecmp(method, "get") && strcasecmp(method, "post")) {
|
||||
if (!zstr(method)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, method);
|
||||
}
|
||||
|
||||
@@ -2160,6 +2161,7 @@ SWITCH_STANDARD_APP(httapi_function)
|
||||
if (!zstr(url) && switch_stristr("://", url)) {
|
||||
if (!params) {
|
||||
switch_event_create(¶ms, SWITCH_EVENT_CLONE);
|
||||
params->flags |= EF_UNIQ_HEADERS;
|
||||
}
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "url", url);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
<param name="max-urls" value="10000"/>
|
||||
<param name="location" value="$${base_dir}/http_cache"/>
|
||||
<param name="default-max-age" value="86400"/>
|
||||
<param name="ssl-cacert" value="$${base_dir}/conf/cacert.pem"/>
|
||||
<param name="ssl-verifyhost" value="true"/>
|
||||
<param name="ssl-verifypeer" value="true"/>
|
||||
</settings>
|
||||
</configuration>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -96,12 +96,12 @@ struct http_get_data {
|
||||
};
|
||||
typedef struct http_get_data http_get_data_t;
|
||||
|
||||
static switch_status_t http_get(cached_url_t *url, switch_core_session_t *session);
|
||||
static switch_status_t http_get(url_cache_t *cache, cached_url_t *url, switch_core_session_t *session);
|
||||
static size_t get_file_callback(void *ptr, size_t size, size_t nmemb, void *get);
|
||||
static size_t get_header_callback(void *ptr, size_t size, size_t nmemb, void *url);
|
||||
static void process_cache_control_header(cached_url_t *url, char *data);
|
||||
|
||||
static switch_status_t http_put(switch_core_session_t *session, const char *url, const char *filename);
|
||||
static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *session, const char *url, const char *filename);
|
||||
|
||||
/**
|
||||
* Queue used for clock cache replacement algorithm. This
|
||||
@@ -159,6 +159,12 @@ struct url_cache {
|
||||
int shutdown;
|
||||
/** Synchronizes shutdown of cache */
|
||||
switch_thread_rwlock_t *shutdown_lock;
|
||||
/** SSL cert filename */
|
||||
char *ssl_cacert;
|
||||
/** Verify certificate */
|
||||
int ssl_verifypeer;
|
||||
/** Verify that hostname matches certificate */
|
||||
int ssl_verifyhost;
|
||||
};
|
||||
static url_cache_t gcache;
|
||||
|
||||
@@ -173,12 +179,13 @@ static void url_cache_clear(url_cache_t *cache, switch_core_session_t *session);
|
||||
|
||||
/**
|
||||
* Put a file to the URL
|
||||
* @param cache the cache
|
||||
* @param session the (optional) session uploading the file
|
||||
* @param url The URL
|
||||
* @param filename The file to upload
|
||||
* @return SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
static switch_status_t http_put(switch_core_session_t *session, const char *url, const char *filename)
|
||||
static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *session, const char *url, const char *filename)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
CURL *curl_handle = NULL;
|
||||
@@ -223,6 +230,18 @@ static switch_status_t http_put(switch_core_session_t *session, const char *url,
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0");
|
||||
if (!cache->ssl_verifypeer) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
} else {
|
||||
/* this is the file with all the trusted certificate authorities */
|
||||
if (!zstr(cache->ssl_cacert)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, cache->ssl_cacert);
|
||||
}
|
||||
/* verify that the host name matches the cert */
|
||||
if (!cache->ssl_verifyhost) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
}
|
||||
}
|
||||
switch_curl_easy_perform(curl_handle);
|
||||
switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
@@ -346,7 +365,7 @@ static void process_cache_control_header(cached_url_t *url, char *data)
|
||||
return;
|
||||
}
|
||||
|
||||
url->max_age = switch_time_now() + (max_age * 1000 * 1000);
|
||||
url->max_age = max_age * 1000 * 1000;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "setting max age to %u seconds from now\n", (int)max_age);
|
||||
}
|
||||
|
||||
@@ -485,7 +504,7 @@ static char *url_cache_get(url_cache_t *cache, switch_core_session_t *session, c
|
||||
|
||||
/* download the file */
|
||||
url_cache_unlock(cache, session);
|
||||
if (http_get(u, session) == SWITCH_STATUS_SUCCESS) {
|
||||
if (http_get(cache, u, session) == SWITCH_STATUS_SUCCESS) {
|
||||
/* Got the file, let the waiters know it is available */
|
||||
url_cache_lock(cache, session);
|
||||
u->status = CACHED_URL_AVAILABLE;
|
||||
@@ -708,11 +727,12 @@ static void cached_url_destroy(cached_url_t *url, switch_memory_pool_t *pool)
|
||||
|
||||
/**
|
||||
* Fetch a file via HTTP
|
||||
* @param cache the cache
|
||||
* @param url The cached URL entry
|
||||
* @param session the (optional) session
|
||||
* @return SWITCH_STATUS_SUCCESS if successful
|
||||
*/
|
||||
static switch_status_t http_get(cached_url_t *url, switch_core_session_t *session)
|
||||
static switch_status_t http_get(url_cache_t *cache, cached_url_t *url, switch_core_session_t *session)
|
||||
{
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_CURL *curl_handle = NULL;
|
||||
@@ -734,7 +754,19 @@ static switch_status_t http_get(cached_url_t *url, switch_core_session_t *sessio
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &get_data);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, get_header_callback);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, (void *) url);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0");
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "freeswitch-http-cache/1.0");
|
||||
if (!cache->ssl_verifypeer) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
} else {
|
||||
/* this is the file with all the trusted certificate authorities */
|
||||
if (!zstr(cache->ssl_cacert)) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, cache->ssl_cacert);
|
||||
}
|
||||
/* verify that the host name matches the cert */
|
||||
if (!cache->ssl_verifyhost) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
}
|
||||
}
|
||||
switch_curl_easy_perform(curl_handle);
|
||||
switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
@@ -791,7 +823,7 @@ static void setup_dir(url_cache_t *cache)
|
||||
|
||||
static int isUrl(const char *filename)
|
||||
{
|
||||
return !zstr(filename) && !strncmp("http://", filename, strlen("http://"));
|
||||
return !zstr(filename) && (!strncmp("http://", filename, strlen("http://")) || !strncmp("https://", filename, strlen("https://")));
|
||||
}
|
||||
|
||||
#define HTTP_PREFETCH_SYNTAX "<url>"
|
||||
@@ -910,7 +942,7 @@ SWITCH_STANDARD_API(http_cache_put)
|
||||
char *argv[10] = { 0 };
|
||||
int argc = 0;
|
||||
|
||||
if (zstr(cmd) || strncmp("http://", cmd, strlen("http://"))) {
|
||||
if (zstr(cmd) || (strncmp("http://", cmd, strlen("http://")) && strncmp("https://", cmd, strlen("https://")))) {
|
||||
stream->write_function(stream, "USAGE: %s\n", HTTP_PUT_SYNTAX);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
goto done;
|
||||
@@ -924,7 +956,7 @@ SWITCH_STANDARD_API(http_cache_put)
|
||||
goto done;
|
||||
}
|
||||
|
||||
status = http_put(session, argv[0], argv[1]);
|
||||
status = http_put(&gcache, session, argv[0], argv[1]);
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else {
|
||||
@@ -1013,6 +1045,9 @@ static switch_status_t do_config(url_cache_t *cache)
|
||||
cache->location = SWITCH_PREFIX_DIR "/http_cache";
|
||||
cache->prefetch_queue_size = 100;
|
||||
cache->prefetch_thread_count = 8;
|
||||
cache->ssl_cacert = SWITCH_PREFIX_DIR "/conf/cacert.pem";
|
||||
cache->ssl_verifyhost = 1;
|
||||
cache->ssl_verifypeer = 1;
|
||||
|
||||
/* get params */
|
||||
settings = switch_xml_child(cfg, "settings");
|
||||
@@ -1035,6 +1070,15 @@ static switch_status_t do_config(url_cache_t *cache)
|
||||
} else if (!strcasecmp(var, "prefetch-thread-count")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting prefetch-thread-count to %s\n", val);
|
||||
cache->prefetch_thread_count = atoi(val);
|
||||
} else if (!strcasecmp(var, "ssl-cacert")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting ssl-cacert to %s\n", val);
|
||||
cache->ssl_cacert = switch_core_strdup(cache->pool, val);
|
||||
} else if (!strcasecmp(var, "ssl-verifyhost")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting ssl-verifyhost to %s\n", val);
|
||||
cache->ssl_verifyhost = !switch_false(val); /* only disable if explicitly set to false */
|
||||
} else if (!strcasecmp(var, "ssl-verifypeer")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting ssl-verifypeer to %s\n", val);
|
||||
cache->ssl_verifypeer = !switch_false(val); /* only disable if explicitly set to false */
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unsupported param: %s\n", var);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -24,6 +24,9 @@ $(MONGO_CXX_DRIVER_SRC):
|
||||
|
||||
|
||||
$(LIBMONGOCLIENT_A): $(MONGO_CXX_DRIVER_SRC)
|
||||
cd $(MONGO_CXX_DRIVER_SRC) && scons
|
||||
(cd $(MONGO_CXX_DRIVER_SRC) && \
|
||||
sed -i SConstruct -e "s/Environment()/Environment(ENV = {'PATH' : os.environ['PATH'],'CFLAGS' : os.environ['CFLAGS'],'CXXFLAGS' : os.environ['CXXFLAGS']})/" && \
|
||||
echo "env.Append(PATH=os.environ['PATH'])" >> SConstruct && \
|
||||
scons)
|
||||
$(TOUCH_TARGET)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
FreeSWITCH Open Settlement Protocol (OSP) module
|
||||
|
||||
This module provides OSP based call authentication, authorization, routing lookup and call detail record (CDR) collection services using standard FreeSWITCH application and dailplan interfaces.
|
||||
|
||||
The OSP module can be configured by the following parameters in osp.conf.xml:
|
||||
|
||||
Global parameters:
|
||||
|
||||
<settings>
|
||||
<param name="*NAME*" value="*VALUE*"/>
|
||||
</settings>
|
||||
|
||||
Global parameter names and values can be:
|
||||
|
||||
debug-info: Flag to show OSP module debug information. The default is "disabled".
|
||||
log-level: At which log level to show OSP module debug information. The default is "info".
|
||||
crypto-hardware: If to use hardware for OpenSSL. The default is "disabled".
|
||||
sip: Used SIP module and profile. The default is "sofia" and "external".
|
||||
h323: Used H.323 module and profile. The default is "h323" and "external". This option has not been implemented.
|
||||
iax: Used IAX2 module and profile. The default is "iax" and "external". This option has not been implemented.
|
||||
skype: Used Skype module and profile. The default is "skypopen" and "external". This option has not been implemented.
|
||||
default-protocol: The VoIP protocol for destinations with unknown/undefined protocol. The default is "sip".
|
||||
|
||||
OSP provider parameters:
|
||||
|
||||
<profiles>
|
||||
<profile name="default">
|
||||
<param name="*NAME*" value="*VALUE*"/>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
OSP provider parameter names ane values cab be:
|
||||
|
||||
profile: OSP provider profile name.
|
||||
service-point-url: OSP service point URL. This parameter must be defined. Up to 8 URLs are allowed.
|
||||
device-ip: FreeSWITCH IP for OSP module. This parameter must be defined.
|
||||
ssl-lifetime: SSL lifetime. The default is 300 in seconds.
|
||||
http-max-connections: HTTP max connections. The default is 20.
|
||||
http-persistence: HTTP persistence. The default is 60 in seconds.
|
||||
http-retry-delay: HTTP retry delay. The default is 0 in seconds.
|
||||
http-retry-limit: HTTP retry times. The default is 2.
|
||||
http-timeout: HTTP timeout. The default is 10000 in ms.
|
||||
work-mode: OSP module work mode (direct and indirect). The default is "direct".
|
||||
service-type: OSP service type (voice and npquery). The default is "voice".
|
||||
max-destinations: Max destinations OSP server will return. It is up to 12. The default is 12.
|
||||
|
||||
The OSP application is called in dial plan like this:
|
||||
|
||||
<action application="osp" data="<profilename>"/>
|
||||
|
||||
The OSP dialplan is called in dial plan like this:
|
||||
|
||||
<param name="dialplan" value="osp:<profilename>"/>
|
||||
|
||||
For both OSP application and dialplan, the <profilename> is an OSP service provider name configured in osp.conf.xml. If it is empty, profile "default" is used.
|
||||
|
||||
Both OSP application and dialplan accept a set of inbound channel variables that are used to pass additional call information to OSP module. These channel variables include:
|
||||
|
||||
osp_source_device: Actual source device IP address channel variable. It is only for FreeSWITH OSP module running in indirect mode.
|
||||
osp_source_nid: Source device network ID channel variable.
|
||||
osp_custom_info_N: Up to 8 custom info channel variables. N is the index starting from 1.
|
||||
osp_networkid_userparam: The URI user parameter name that is used to present destination network ID.
|
||||
osp_networkid_uriparam: The URI parameter name that is used to present destination network ID.
|
||||
osp_user_phone: Flag to add "user=phone" URI parameter. The default is "disabled".
|
||||
osp_outbound_proxy: Outbound proxy IP address channel variable.
|
||||
|
||||
Both OSP application and dialplan also export a set of channel variables for outbound channels and FreeSWITCH dial plan logic (for OSP dialplan, some exported channel variables are not visible for dial plan). These channel variables include:
|
||||
|
||||
osp_profile: Used OSP profile name. Used by outbound channels.
|
||||
osp_transaction_id: OSP transaction ID. Used by outbound channels.
|
||||
osp_calling: Original inbound calling number. Used by outbound channels.
|
||||
osp_called: Original inbound called number. Used by outbound channels.
|
||||
osp_start_time: Inbound call start time. Used by outbound channels.
|
||||
osp_source_device: Actual source device. Used by outbound channels. It is only for FreeSWITH OSP module running in indirect mode.
|
||||
osp_source_nid: Source network ID. Used by outbound channels.
|
||||
osp_destination_total: Total number of destinations from OSP servers. Used by outbound channels.
|
||||
osp_destination_count: Destination index. Used by outbound channels.
|
||||
osp_destination_ip: Destination IP. Used by outbound channels.
|
||||
osp_destination_nid: Destination network ID. Used by outbound channels.
|
||||
osp_authreq_status: Authorization request result status.
|
||||
osp_route_count: Number of supported destinations.
|
||||
osp_route_N: Destination route string. N is the index starting from 1.
|
||||
osp_auto_route: Bridge route string.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -43,12 +43,17 @@ typedef struct {
|
||||
uint32_t last_digit_end;
|
||||
uint32_t digit_begin;
|
||||
uint32_t min_dup_digit_spacing;
|
||||
int twist;
|
||||
int reverse_twist;
|
||||
int filter_dialtone;
|
||||
int threshold;
|
||||
} switch_inband_dtmf_t;
|
||||
|
||||
static void spandsp_dtmf_rx_realtime_callback(void *user_data, int code, int level, int delay)
|
||||
static void spandsp_dtmf_rx_realtime_callback(void *user_data, int code, int level, int duration)
|
||||
{
|
||||
switch_inband_dtmf_t *pvt = (switch_inband_dtmf_t *)user_data;
|
||||
char digit = (char)code;
|
||||
pvt->samples += duration;
|
||||
if (digit) {
|
||||
/* prevent duplicate DTMF */
|
||||
if (digit != pvt->last_digit || (pvt->samples - pvt->last_digit_end) > pvt->min_dup_digit_spacing) {
|
||||
@@ -74,16 +79,12 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
|
||||
{
|
||||
switch_inband_dtmf_t *pvt = (switch_inband_dtmf_t *) user_data;
|
||||
switch_frame_t *frame = NULL;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
|
||||
|
||||
switch (type) {
|
||||
case SWITCH_ABC_TYPE_INIT: {
|
||||
const char *min_dup_digit_spacing_str = switch_channel_get_variable(channel, "min_dup_digit_spacing_ms");
|
||||
pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL);
|
||||
dtmf_rx_parms(pvt->dtmf_detect, pvt->filter_dialtone, pvt->twist, pvt->reverse_twist, pvt->threshold);
|
||||
dtmf_rx_set_realtime_callback(pvt->dtmf_detect, spandsp_dtmf_rx_realtime_callback, pvt);
|
||||
if (!zstr(min_dup_digit_spacing_str)) {
|
||||
pvt->min_dup_digit_spacing = atoi(min_dup_digit_spacing_str) * 8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SWITCH_ABC_TYPE_CLOSE:
|
||||
@@ -93,7 +94,6 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_READ_REPLACE:
|
||||
if ((frame = switch_core_media_bug_get_read_replace_frame(bug))) {
|
||||
pvt->samples += frame->samples;
|
||||
dtmf_rx(pvt->dtmf_detect, frame->data, frame->samples);
|
||||
switch_core_media_bug_set_read_replace_frame(bug, frame);
|
||||
}
|
||||
@@ -126,6 +126,7 @@ switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session)
|
||||
switch_status_t status;
|
||||
switch_inband_dtmf_t *pvt;
|
||||
switch_codec_implementation_t read_impl = { 0 };
|
||||
const char *value;
|
||||
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
@@ -133,8 +134,60 @@ switch_status_t spandsp_inband_dtmf_session(switch_core_session_t *session)
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
pvt->session = session;
|
||||
pvt->session = session;
|
||||
|
||||
/* get detector params */
|
||||
pvt->min_dup_digit_spacing = 0;
|
||||
value = switch_channel_get_variable(channel, "min_dup_digit_spacing_ms");
|
||||
if (!zstr(value) && switch_is_number(value)) {
|
||||
int val = atoi(value) * 8; /* convert from ms to samples */
|
||||
if (val < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "min_dup_digit_spacing_ms must be >= 0\n");
|
||||
} else {
|
||||
pvt->min_dup_digit_spacing = val;
|
||||
}
|
||||
}
|
||||
|
||||
pvt->threshold = -100;
|
||||
value = switch_channel_get_variable(channel, "spandsp_dtmf_rx_threshold");
|
||||
if (!zstr(value) && switch_is_number(value)) {
|
||||
int val = atoi(value);
|
||||
if (val < -99) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "spandsp_dtmf_rx_threshold must be >= -99 dBm0\n");
|
||||
} else {
|
||||
pvt->threshold = val;
|
||||
}
|
||||
}
|
||||
|
||||
pvt->twist = -1;
|
||||
value = switch_channel_get_variable(channel, "spandsp_dtmf_rx_twist");
|
||||
if (!zstr(value) && switch_is_number(value)) {
|
||||
int val = atoi(value);
|
||||
if (val < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "spandsp_dtmf_rx_twist must be >= 0 dB\n");
|
||||
} else {
|
||||
pvt->twist = val;
|
||||
}
|
||||
}
|
||||
|
||||
pvt->reverse_twist = -1;
|
||||
value = switch_channel_get_variable(channel, "spandsp_dtmf_rx_reverse_twist");
|
||||
if (!zstr(value) && switch_is_number(value)) {
|
||||
int val = atoi(value);
|
||||
if (val < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "spandsp_dtmf_rx_reverse_twist must be >= 0 dB\n");
|
||||
} else {
|
||||
pvt->reverse_twist = val;
|
||||
}
|
||||
}
|
||||
|
||||
pvt->filter_dialtone = -1;
|
||||
value = switch_channel_get_variable(channel, "spandsp_dtmf_rx_filter_dialtone");
|
||||
if (switch_true(value)) {
|
||||
pvt->filter_dialtone = 1;
|
||||
} else if (switch_false(value)) {
|
||||
pvt->filter_dialtone = 0;
|
||||
}
|
||||
|
||||
if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -629,6 +629,7 @@ vm_profile_t *profile_set_config(vm_profile_t *profile)
|
||||
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_date-fmt", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
|
||||
&profile->date_fmt, "%A, %B %d %Y, %I:%M %p", &profile->config_str_pool, NULL, NULL);
|
||||
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "odbc-dsn", SWITCH_CONFIG_STRING, 0, &profile->odbc_dsn, NULL, &profile->config_str_pool, NULL, NULL);
|
||||
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "dbname", SWITCH_CONFIG_STRING, 0, &profile->dbname, NULL, &profile->config_str_pool, NULL, NULL);
|
||||
SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "email_template-file", SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
|
||||
NULL, NULL, profile, vm_config_email_callback, NULL, NULL);
|
||||
SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "email_notify-template-file", SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
|
||||
@@ -722,7 +723,9 @@ static vm_profile_t *load_profile(const char *profile_name)
|
||||
}
|
||||
}
|
||||
|
||||
profile->dbname = switch_core_sprintf(profile->pool, "voicemail_%s", profile_name);
|
||||
if (zstr(profile->dbname)) {
|
||||
profile->dbname = switch_core_sprintf(profile->pool, "voicemail_%s", profile_name);
|
||||
}
|
||||
|
||||
if (!(dbh = vm_get_db_handle(profile))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot open DB!\n");
|
||||
@@ -1544,7 +1547,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
|
||||
char cid_buf[1024] = "";
|
||||
|
||||
if (switch_channel_ready(channel)) {
|
||||
switch_snprintf(cid_buf, sizeof(cid_buf), "%s|%s", cbt->cid_number, cbt->cid_name);
|
||||
switch_snprintf(cid_buf, sizeof(cid_buf), "%s|%s", cbt->cid_name, cbt->cid_number);
|
||||
|
||||
msg.from = __FILE__;
|
||||
msg.string_arg = cid_buf;
|
||||
@@ -2583,8 +2586,6 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
|
||||
switch_status_t ret = SWITCH_STATUS_SUCCESS;
|
||||
char *convert_cmd = profile->convert_cmd;
|
||||
char *convert_ext = profile->convert_ext;
|
||||
int del_file = 0;
|
||||
|
||||
|
||||
if (!params) {
|
||||
switch_event_create(&local_event, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
@@ -2901,10 +2902,6 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
|
||||
switch_safe_free(headers);
|
||||
}
|
||||
}
|
||||
|
||||
if (!insert_db) {
|
||||
del_file = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (session) {
|
||||
@@ -2926,7 +2923,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
|
||||
|
||||
failed:
|
||||
|
||||
if (del_file && file_path && switch_file_exists(file_path, pool)) {
|
||||
if (!insert_db && file_path && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
if (unlink(file_path) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to delete file [%s]\n", file_path);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -12,35 +12,43 @@ POCKETSPHINX_LA=$(POCKETSPHINX_BUILDDIR)/src/libpocketsphinx/libpocketsphinx.la
|
||||
SPHINXMODEL=communicator_semi_6000_20080321
|
||||
|
||||
LOCAL_CFLAGS=-I$(SPHINXBASE_DIR)/include -I$(POCKETSPHINX_DIR)/include
|
||||
LOCAL_LIBADD=$(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
|
||||
LOCAL_LIBADD=$(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
|
||||
BASE=../../../..
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
mod_pocketsphinx.lo: $(POCKETSPHINX_LA) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
|
||||
|
||||
$(SPHINXBASE_DIR):
|
||||
$(GETLIB) $(SPHINXBASE).tar.gz
|
||||
|
||||
$(SPHINXBASE_BUILDDIR)/buildstamp: $(SPHINXBASE_DIR)
|
||||
$(SPHINXBASE_BUILDDIR)/Makefile: $(SPHINXBASE_DIR)
|
||||
mkdir -p $(SPHINXBASE_BUILDDIR)
|
||||
test -f $(SPHINXBASE_BUILDDIR)/Makefile || (cd $(SPHINXBASE_BUILDDIR) && $(DEFAULT_VARS) $(SPHINXBASE_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(SPHINXBASE_DIR) --without-python CFLAGS=)
|
||||
test -f $(SPHINXBASE_BUILDDIR)/buildstamp || (touch $(SPHINXBASE_BUILDDIR)/buildstamp)
|
||||
(cd $(SPHINXBASE_BUILDDIR) && $(DEFAULT_VARS) $(SPHINXBASE_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(SPHINXBASE_DIR) --without-python CFLAGS=)
|
||||
$(TOUCH_TARGET)
|
||||
|
||||
$(SPHINXBASE_BUILDDIR)/buildstamp: $(SPHINXBASE_BUILDDIR)/Makefile
|
||||
(cd $(SPHINXBASE_BUILDDIR) && $(MAKE))
|
||||
touch $@
|
||||
|
||||
$(SPHINXBASE_LA): $(SPHINXBASE_BUILDDIR)/buildstamp
|
||||
cd $(SPHINXBASE_BUILDDIR) && $(MAKE)
|
||||
$(TOUCH_TARGET)
|
||||
|
||||
$(SPHINXBASE_LA2): $(SPHINXBASE_BUILDDIR)/buildstamp
|
||||
$(TOUCH_TARGET)
|
||||
|
||||
$(POCKETSPHINX_DIR):
|
||||
$(GETLIB) $(POCKETSPHINX).tar.gz
|
||||
|
||||
$(POCKETSPHINX_BUILDDIR)/Makefile: $(POCKETSPHINX_DIR) $(SPHINXBASE_LA)
|
||||
$(POCKETSPHINX_BUILDDIR)/Makefile: $(POCKETSPHINX_DIR) $(SPHINXBASE_LA) $(SPHINXBASE_LA2)
|
||||
mkdir -p $(POCKETSPHINX_BUILDDIR)
|
||||
cd $(POCKETSPHINX_BUILDDIR) && $(DEFAULT_VARS) $(POCKETSPHINX_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(POCKETSPHINX_DIR) --without-python --with-sphinxbase=$(SPHINXBASE_DIR) --with-sphinxbase-build=$(SPHINXBASE_BUILDDIR) CFLAGS=
|
||||
(cd $(POCKETSPHINX_BUILDDIR) && $(DEFAULT_VARS) $(POCKETSPHINX_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(POCKETSPHINX_DIR) --without-python --with-sphinxbase=$(SPHINXBASE_DIR) --with-sphinxbase-build=$(SPHINXBASE_BUILDDIR) CFLAGS=)
|
||||
$(TOUCH_TARGET)
|
||||
|
||||
$(POCKETSPHINX_BUILDDIR)/buildstamp: $(POCKETSPHINX_BUILDDIR)/Makefile
|
||||
test -f $(POCKETSPHINX_BUILDDIR)/buildstamp || touch $(POCKETSPHINX_BUILDDIR)/buildstamp
|
||||
(cd $(POCKETSPHINX_BUILDDIR) && $(MAKE))
|
||||
touch $@
|
||||
|
||||
$(POCKETSPHINX_LA): $(POCKETSPHINX_BUILDDIR)/Makefile
|
||||
cd $(POCKETSPHINX_BUILDDIR) && $(MAKE)
|
||||
$(POCKETSPHINX_LA): $(POCKETSPHINX_BUILDDIR)/buildstamp
|
||||
$(TOUCH_TARGET)
|
||||
|
||||
$(DESTDIR)$(grammardir)/model:
|
||||
@@ -52,6 +60,7 @@ $(DESTDIR)$(grammardir)/model/communicator:
|
||||
cp -rp $(switch_srcdir)/libs/Communicator_semi_40.cd_semi_6000/* $(DESTDIR)$(grammardir)/model/communicator
|
||||
|
||||
dictionary:
|
||||
@cp -f $(POCKETSPHINX_DIR)/model/lm/en_US/cmu07a.dic $(DESTDIR)$(grammardir)/default.dic
|
||||
@install -m0644 $(POCKETSPHINX_DIR)/model/lm/en_US/cmu07a.dic $(DESTDIR)$(grammardir)/default.dic
|
||||
|
||||
local_install: $(DESTDIR)$(grammardir)/model $(DESTDIR)$(grammardir)/model/communicator dictionary
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2009-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2009-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -117,51 +117,143 @@ struct speex_context {
|
||||
|
||||
static switch_status_t switch_speex_fmtp_parse(const char *fmtp, switch_codec_fmtp_t *codec_fmtp)
|
||||
{
|
||||
if (codec_fmtp) {
|
||||
speex_codec_settings_t *codec_settings = NULL;
|
||||
if (codec_fmtp->private_info) {
|
||||
codec_settings = codec_fmtp->private_info;
|
||||
memcpy(codec_settings, &default_codec_settings, sizeof(*codec_settings));
|
||||
}
|
||||
speex_codec_settings_t *codec_settings = NULL;
|
||||
int x, argc;
|
||||
char *argv[10];
|
||||
char *fmtp_dup = NULL;
|
||||
|
||||
if (fmtp) {
|
||||
int x, argc;
|
||||
char *argv[10];
|
||||
char *fmtp_dup = strdup(fmtp);
|
||||
if (!codec_fmtp) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
switch_assert(fmtp_dup);
|
||||
|
||||
argc = switch_separate_string(fmtp_dup, ';', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
for (x = 0; x < argc; x++) {
|
||||
char *data = argv[x];
|
||||
char *arg;
|
||||
switch_assert(data);
|
||||
while (*data == ' ') {
|
||||
data++;
|
||||
}
|
||||
if ((arg = strchr(data, '='))) {
|
||||
*arg++ = '\0';
|
||||
/*
|
||||
if (!strcasecmp(data, "bitrate")) {
|
||||
bit_rate = atoi(arg);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (codec_settings) {
|
||||
if (!strcasecmp(data, "vad")) {
|
||||
bit_rate = atoi(arg);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
free(fmtp_dup);
|
||||
}
|
||||
/*codec_fmtp->bits_per_second = bit_rate;*/
|
||||
/* load default settings */
|
||||
if (codec_fmtp->private_info) {
|
||||
codec_settings = codec_fmtp->private_info;
|
||||
memcpy(codec_settings, &default_codec_settings, sizeof(*codec_settings));
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "codec_fmtp->private_info is NULL\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
if (!fmtp) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "got fmtp: %s\n", fmtp);
|
||||
|
||||
fmtp_dup = strdup(fmtp);
|
||||
switch_assert(fmtp_dup);
|
||||
|
||||
/* parse ; separated fmtp args */
|
||||
argc = switch_separate_string(fmtp_dup, ';', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
for (x = 0; x < argc; x++) {
|
||||
char *data = argv[x];
|
||||
char *arg;
|
||||
switch_assert(data);
|
||||
while (*data == ' ') {
|
||||
data++;
|
||||
}
|
||||
if (!(arg = strchr(data, '='))) {
|
||||
continue;
|
||||
}
|
||||
*arg++ = '\0';
|
||||
if (zstr(arg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcasecmp("vbr", data)) {
|
||||
/* vbr can be on/off/vad */
|
||||
if (!strcasecmp("vad", arg)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "enabling speex vbr=vad\n");
|
||||
codec_settings->vbr = 0;
|
||||
codec_settings->vad = 1;
|
||||
codec_settings->pp_vad = 1;
|
||||
} else {
|
||||
if (switch_true(arg)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "enabling speex vbr\n");
|
||||
codec_settings->vbr = 1;
|
||||
codec_settings->vad = 0;
|
||||
codec_settings->pp_vad = 1;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "disabling speex vbr\n");
|
||||
codec_settings->vbr = 0;
|
||||
codec_settings->vad = 0;
|
||||
codec_settings->pp_vad = 0;
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp("cng", data)) {
|
||||
/* TODO don't know how to turn on CNG */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "speex cng is unsupported\n");
|
||||
} else if (!strcasecmp("mode", data)) {
|
||||
/* mode is a comma-separate list of preferred modes. Use the first mode in the list */
|
||||
char *arg_dup;
|
||||
char *mode[2];
|
||||
if (!strncasecmp("any", arg, 3)) {
|
||||
/* "any", keep the default setting */
|
||||
continue;
|
||||
}
|
||||
arg_dup = strdup(arg);
|
||||
if (switch_separate_string(arg_dup, ',', mode, (sizeof(mode) / sizeof(mode[0])))) {
|
||||
int mode_num = -1;
|
||||
char *mode_str = mode[0];
|
||||
if (mode_str[0] == '"') {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "mode starts with \"\n");
|
||||
mode_str++;
|
||||
}
|
||||
if (switch_is_number(mode_str)) {
|
||||
mode_num = atoi(mode_str);
|
||||
}
|
||||
/* TODO there might be a way to set the mode directly instead of changing the quality */
|
||||
if (codec_fmtp->actual_samples_per_second == 8000) {
|
||||
switch (mode_num) {
|
||||
case 1:
|
||||
codec_settings->quality = 0;
|
||||
break;
|
||||
case 2:
|
||||
codec_settings->quality = 2;
|
||||
break;
|
||||
case 3:
|
||||
codec_settings->quality = 4;
|
||||
break;
|
||||
case 4:
|
||||
codec_settings->quality = 6;
|
||||
break;
|
||||
case 5:
|
||||
codec_settings->quality = 8;
|
||||
break;
|
||||
case 6:
|
||||
codec_settings->quality = 9;
|
||||
break;
|
||||
case 7:
|
||||
codec_settings->quality = 10;
|
||||
break;
|
||||
case 8:
|
||||
codec_settings->quality = 1;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "ignoring invalid speex/8000 mode %s\n", mode_str);
|
||||
continue;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "choosing speex/8000 mode %s\n", mode_str);
|
||||
codec_settings->quality = codec_settings->quality;
|
||||
codec_settings->vbr_quality = codec_settings->quality;
|
||||
} else {
|
||||
if (mode_num >= 0 && mode_num <= 10) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "choosing speex/%d mode %s\n", codec_fmtp->actual_samples_per_second, mode_str);
|
||||
codec_settings->quality = mode_num;
|
||||
codec_settings->vbr_quality = mode_num;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "ignoring invalid speex/%d mode %s\n", codec_fmtp->actual_samples_per_second, mode_str);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(arg_dup);
|
||||
}
|
||||
}
|
||||
free(fmtp_dup);
|
||||
/*codec_fmtp->bits_per_second = bit_rate;*/
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +274,7 @@ static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_fla
|
||||
|
||||
memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp));
|
||||
codec_fmtp.private_info = &codec_settings;
|
||||
codec_fmtp.actual_samples_per_second = codec->implementation->actual_samples_per_second;
|
||||
switch_speex_fmtp_parse(codec->fmtp_in, &codec_fmtp);
|
||||
|
||||
memcpy(&context->codec_settings, &codec_settings, sizeof(context->codec_settings));
|
||||
@@ -205,11 +298,24 @@ static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_fla
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_GET_FRAME_SIZE, &context->encoder_frame_size);
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_COMPLEXITY, &context->codec_settings.complexity);
|
||||
if (context->codec_settings.preproc) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "preprocessor on\n");
|
||||
context->pp = speex_preprocess_state_init(context->encoder_frame_size, codec->implementation->actual_samples_per_second);
|
||||
if (context->codec_settings.pp_vad) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "preprocessor vad on\n");
|
||||
}
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_VAD, &context->codec_settings.pp_vad);
|
||||
if (context->codec_settings.pp_agc) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "preprocessor agc on\n");
|
||||
}
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_AGC, &context->codec_settings.pp_agc);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_AGC_LEVEL, &context->codec_settings.pp_agc_level);
|
||||
if (context->codec_settings.pp_denoise) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "preprocessor denoise on\n");
|
||||
}
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DENOISE, &context->codec_settings.pp_denoise);
|
||||
if (context->codec_settings.pp_dereverb) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "preprocessor dereverb on\n");
|
||||
}
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB, &context->codec_settings.pp_dereverb);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &context->codec_settings.pp_dereverb_decay);
|
||||
speex_preprocess_ctl(context->pp, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &context->codec_settings.pp_dereverb_level);
|
||||
@@ -218,17 +324,21 @@ static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_fla
|
||||
if (!context->codec_settings.abr && !context->codec_settings.vbr) {
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_QUALITY, &context->codec_settings.quality);
|
||||
if (context->codec_settings.vad) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "vad on\n");
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_VAD, &context->codec_settings.vad);
|
||||
}
|
||||
}
|
||||
if (context->codec_settings.vbr) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "vbr on\n");
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_VBR, &context->codec_settings.vbr);
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_VBR_QUALITY, &context->codec_settings.vbr_quality);
|
||||
}
|
||||
if (context->codec_settings.abr) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "abr on\n");
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_ABR, &context->codec_settings.abr);
|
||||
}
|
||||
if (context->codec_settings.dtx) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "dtx on\n");
|
||||
speex_encoder_ctl(context->encoder_state, SPEEX_SET_DTX, &context->codec_settings.dtx);
|
||||
}
|
||||
}
|
||||
@@ -243,6 +353,7 @@ static switch_status_t switch_speex_init(switch_codec_t *codec, switch_codec_fla
|
||||
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "initialized Speex codec \n");
|
||||
codec->private_info = context;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -279,17 +390,15 @@ static switch_status_t switch_speex_encode(switch_codec_t *codec,
|
||||
|
||||
if (is_speech) {
|
||||
switch_clear_flag(context, SWITCH_CODEC_FLAG_SILENCE);
|
||||
*flag |= SWITCH_CODEC_FLAG_SILENCE_STOP;
|
||||
*flag &= ~SFF_CNG;
|
||||
} else {
|
||||
if (switch_test_flag(context, SWITCH_CODEC_FLAG_SILENCE)) {
|
||||
*encoded_data_len = 0;
|
||||
*flag |= SWITCH_CODEC_FLAG_SILENCE | SFF_CNG;
|
||||
*flag |= SFF_CNG;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_set_flag(context, SWITCH_CODEC_FLAG_SILENCE);
|
||||
*flag |= SWITCH_CODEC_FLAG_SILENCE_START;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user