mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 14:44:17 +00:00
FS-9924: Removed extra space in source files
This commit is contained in:
1 parent
60d4e87487
commit
df1ab07ca4
455 files changed
+9699
-9698
No files matched your search
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Marc Olivier Chouinard <mochouinard@moctel.com>
|
||||
*
|
||||
*
|
||||
@@ -38,7 +38,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_abstraction_load);
|
||||
|
||||
const char *global_cf = "abstraction.conf";
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_abstraction, mod_abstraction_load, mod_abstraction_shutdown, NULL);
|
||||
@@ -86,12 +86,12 @@ SWITCH_STANDARD_API(api_abstraction_function)
|
||||
}
|
||||
switch_api_execute(destination, api_args, session, stream);
|
||||
|
||||
switch_safe_free(substituted);
|
||||
switch_safe_free(substituted);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No match for API %s (%s != %s)\n", api_name, parse, cmd);
|
||||
}
|
||||
switch_regex_safe_free(re);
|
||||
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "API %s doesn't exist inside the xml structure. You might have forgot to reload the module after editing it\n", api_name);
|
||||
}
|
||||
|
||||
@@ -821,7 +821,7 @@ static switch_status_t consume_nalu(h264_codec_context_t *context, switch_frame_
|
||||
static switch_status_t open_encoder(h264_codec_context_t *context, uint32_t width, uint32_t height)
|
||||
{
|
||||
int sane = 0;
|
||||
|
||||
|
||||
if (!context->encoder) {
|
||||
if (context->av_codec_id == AV_CODEC_ID_H264) {
|
||||
if (context->codec_settings.video.try_hardware_encoder && (context->encoder = avcodec_find_encoder_by_name("nvenc_h264"))) {
|
||||
@@ -889,7 +889,7 @@ static switch_status_t open_encoder(h264_codec_context_t *context, uint32_t widt
|
||||
}
|
||||
|
||||
context->bandwidth *= 3;
|
||||
|
||||
|
||||
//context->encoder_ctx->bit_rate = context->bandwidth * 1024;
|
||||
context->encoder_ctx->width = context->codec_settings.video.width;
|
||||
context->encoder_ctx->height = context->codec_settings.video.height;
|
||||
@@ -1286,7 +1286,7 @@ static switch_status_t switch_h264_decode(switch_codec_t *codec, switch_frame_t
|
||||
if (got_picture && decoded_len > 0) {
|
||||
int width = picture->width;
|
||||
int height = picture->height;
|
||||
|
||||
|
||||
if (!context->img || (context->img->d_w != width || context->img->d_h != height)) {
|
||||
switch_img_free(&context->img);
|
||||
context->img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, width, height, 1);
|
||||
|
||||
@@ -303,7 +303,7 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
||||
}
|
||||
mst->st->id = fc->nb_streams - 1;
|
||||
c = mst->st->codec;
|
||||
|
||||
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "id:%d den:%d num:%d\n", mst->st->id, mst->st->time_base.den, mst->st->time_base.num);
|
||||
|
||||
if (threads > 4) {
|
||||
@@ -340,7 +340,7 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
||||
} else {
|
||||
mm->fps = fps;
|
||||
}
|
||||
|
||||
|
||||
if (mm->vw && mm->vh) {
|
||||
mst->width = mm->vw;
|
||||
mst->height = mm->vh;
|
||||
@@ -392,7 +392,7 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
||||
c->level = 52;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch (mm->vencspd) {
|
||||
case SWITCH_VIDEO_ENCODE_SPEED_SLOW:
|
||||
av_opt_set(c->priv_data, "preset", "veryslow", 0);
|
||||
@@ -657,7 +657,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
||||
goto top;
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
size = switch_queue_size(eh->video_queue);
|
||||
|
||||
if (size > 5 && !eh->finalize) {
|
||||
@@ -672,12 +672,12 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//switch_mutex_lock(eh->mutex);
|
||||
|
||||
eh->in_callback = 1;
|
||||
|
||||
av_init_packet(&pkt);
|
||||
|
||||
av_init_packet(&pkt);
|
||||
|
||||
if (eh->video_st->frame) {
|
||||
ret = av_frame_make_writable(eh->video_st->frame);
|
||||
@@ -688,7 +688,7 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
||||
}
|
||||
|
||||
fill_avframe(eh->video_st->frame, img);
|
||||
|
||||
|
||||
if (eh->finalize) {
|
||||
if (delta_i && !delta_avg) {
|
||||
delta_avg = (int)(double)(delta_sum / delta_i);
|
||||
@@ -714,13 +714,13 @@ static void *SWITCH_THREAD_FUNC video_thread_run(switch_thread_t *thread, void *
|
||||
if (delta_tmp != last_ts) {
|
||||
delta_sum += delta_tmp;
|
||||
delta_i++;
|
||||
|
||||
|
||||
if (delta_i >= 60) {
|
||||
delta_avg = (int)(double)(delta_sum / delta_i);
|
||||
delta_i = 0;
|
||||
delta_sum = delta_avg;
|
||||
}
|
||||
|
||||
|
||||
eh->video_st->frame->pts = eh->timer->samplecount;
|
||||
}
|
||||
}
|
||||
@@ -977,12 +977,12 @@ SWITCH_STANDARD_APP(record_av_function)
|
||||
int offset = DFT_RECORD_OFFSET;
|
||||
int fps = codec.implementation->actual_samples_per_second / samples;
|
||||
int lead_frames = (offset * fps) / 1000;
|
||||
|
||||
|
||||
for (int x = 0; x < lead_frames; x++) {
|
||||
switch_buffer_write(buffer, buf, datalen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while (switch_channel_ready(channel)) {
|
||||
|
||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_SINGLE_READ, 0);
|
||||
@@ -1585,16 +1585,16 @@ again:
|
||||
*pts = vframe->pkt_pts;
|
||||
avframe2img(vframe, img);
|
||||
img->user_priv = pts;
|
||||
|
||||
|
||||
#ifdef ALT_WAY
|
||||
diff = sleep - (switch_time_now() - context->last_vid_push);
|
||||
|
||||
|
||||
if (diff > 0 && diff <= sleep) {
|
||||
switch_core_timer_next(&context->video_timer);
|
||||
} else {
|
||||
switch_core_timer_sync(&context->video_timer);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
context->vid_ready = 1;
|
||||
switch_queue_push(context->eh.video_queue, img);
|
||||
@@ -1686,7 +1686,7 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
switch_set_string(file, path);
|
||||
|
||||
|
||||
if ((ext = strrchr((char *)path, '.')) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
@@ -1923,7 +1923,7 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
|
||||
|
||||
switch_buffer_write(context->audio_buffer, data, datalen);
|
||||
}
|
||||
|
||||
|
||||
bytes = context->audio_st.frame->nb_samples * 2 * context->audio_st.st->codec->channels;
|
||||
|
||||
|
||||
@@ -1937,15 +1937,15 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
|
||||
switch_buffer_write(context->audio_buffer, buf, bytes - inuse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
while ((inuse = switch_buffer_inuse(context->audio_buffer)) >= bytes) {
|
||||
AVPacket pkt = { 0 };
|
||||
int got_packet = 0;
|
||||
int ret;
|
||||
|
||||
av_init_packet(&pkt);
|
||||
|
||||
|
||||
if (context->audio_st.resample_ctx) { // need resample
|
||||
int out_samples = avresample_get_out_samples(context->audio_st.resample_ctx, context->audio_st.frame->nb_samples);
|
||||
av_frame_make_writable(context->audio_st.frame);
|
||||
@@ -1955,7 +1955,7 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
|
||||
ret = avresample_convert(context->audio_st.resample_ctx,
|
||||
context->audio_st.tmp_frame->data, 0, out_samples,
|
||||
(uint8_t **)context->audio_st.frame->data, 0, context->audio_st.frame->nb_samples);
|
||||
|
||||
|
||||
if (ret < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while converting %d samples, error text: %s\n",
|
||||
context->audio_st.frame->nb_samples, get_error_text(ret));
|
||||
@@ -1964,7 +1964,7 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
|
||||
|
||||
context->audio_st.tmp_frame->pts = context->audio_st.next_pts;
|
||||
context->audio_st.next_pts += context->audio_st.frame->nb_samples;
|
||||
ret = avcodec_encode_audio2(context->audio_st.st->codec, &pkt, context->audio_st.tmp_frame, &got_packet);
|
||||
ret = avcodec_encode_audio2(context->audio_st.st->codec, &pkt, context->audio_st.tmp_frame, &got_packet);
|
||||
} else {
|
||||
av_frame_make_writable(context->audio_st.frame);
|
||||
switch_buffer_read(context->audio_buffer, context->audio_st.frame->data[0], bytes);
|
||||
@@ -2010,9 +2010,9 @@ static switch_status_t av_file_command(switch_file_handle_t *handle, switch_file
|
||||
|
||||
switch(command) {
|
||||
case SCFC_FLUSH_AUDIO:
|
||||
switch_mutex_lock(context->mutex);
|
||||
switch_mutex_lock(context->mutex);
|
||||
switch_buffer_zero(context->audio_buffer);
|
||||
switch_mutex_unlock(context->mutex);
|
||||
switch_mutex_unlock(context->mutex);
|
||||
break;
|
||||
case SCFC_PAUSE_READ:
|
||||
if (context->read_paused) {
|
||||
@@ -2131,7 +2131,7 @@ static switch_status_t av_file_read(switch_file_handle_t *handle, void *data, si
|
||||
|
||||
if (size == 0) {
|
||||
size_t blank = (handle->samplerate / 20) * 2 * handle->real_channels;
|
||||
|
||||
|
||||
if (need > blank) {
|
||||
need = blank;
|
||||
}
|
||||
@@ -2165,7 +2165,7 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
|
||||
if ((flags & SVR_FLUSH)) {
|
||||
flush_video_queue(context->eh.video_queue, 1);
|
||||
}
|
||||
|
||||
|
||||
if ((flags & SVR_BLOCK)) {
|
||||
status = switch_queue_pop(context->eh.video_queue, &pop);
|
||||
} else {
|
||||
@@ -2185,7 +2185,7 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
|
||||
|
||||
return (flags & SVR_FLUSH) ? SWITCH_STATUS_BREAK : status;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
|
||||
static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_frame_t *frame, switch_video_read_flag_t flags)
|
||||
{
|
||||
@@ -2343,7 +2343,7 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "picture is too late, off: %" SWITCH_INT64_T_FMT " max delta: %" SWITCH_INT64_T_FMT " queue size:%u fps:%u/%0.2f\n", (int64_t)(now - mst->next_pts), max_delta, switch_queue_size(context->eh.video_queue), context->read_fps, handle->mm.fps);
|
||||
switch_img_free(&img);
|
||||
//max_delta = AV_TIME_BASE;
|
||||
|
||||
|
||||
if (switch_queue_size(context->eh.video_queue) > 0) {
|
||||
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "WTF again\n");
|
||||
goto again;
|
||||
@@ -2351,7 +2351,7 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
|
||||
mst->next_pts = 0;
|
||||
context->video_start_time = 0;
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & SVR_BLOCK) || do_fl) {
|
||||
@@ -2369,7 +2369,7 @@ static switch_status_t av_file_read_video(switch_file_handle_t *handle, switch_f
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Piotr Gregor <piotrgregor@rsyncme.org>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Eric des Courtis <eric.des.courtis@benbria.com>
|
||||
@@ -43,7 +43,7 @@ typedef union {
|
||||
float f;
|
||||
} float_conv_t;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Manipulate these parameters to change
|
||||
* mapping's resolution. The sine tone
|
||||
* of 1600Hz is detected even with 20
|
||||
@@ -241,7 +241,7 @@ dump_table_summary(void)
|
||||
i_1 = index_from_float(1.0);
|
||||
di = (i_1 - i_0)/100;
|
||||
if (di == 0) di = 1;
|
||||
|
||||
|
||||
for (; i < ACOS_TABLE_LENGTH; i += di )
|
||||
{
|
||||
f = float_from_index(i);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Eric des Courtis <eric.des.courtis@benbria.com>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
#define AVMD_MIN_FREQUENCY (440.0)
|
||||
/*! Minimum frequency as digital normalized frequency */
|
||||
#define AVMD_MIN_FREQUENCY_R(r) ((2.0 * M_PI * AVMD_MIN_FREQUENCY) / (r))
|
||||
/*!
|
||||
/*!
|
||||
* Maximum beep frequency in Hertz
|
||||
* Note: The maximum frequency the DESA-2 algorithm can uniquely
|
||||
* identify is 0.25 of the sampling rate. All the frequencies
|
||||
@@ -733,7 +733,7 @@ static void avmd_fire_event(enum avmd_event type, switch_core_session_t *fs_s, d
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detector-offset", "ERROR (TRUNCATED)");
|
||||
}
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detector-offset", buf);
|
||||
|
||||
|
||||
res = snprintf(buf, AVMD_CHAR_BUF_LEN, "%u", idx);
|
||||
if (res < 0 || res > AVMD_CHAR_BUF_LEN - 1) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fs_s), SWITCH_LOG_ERROR, "Error, truncated [%s], [%d] attempeted!\n", buf, res);
|
||||
@@ -1137,7 +1137,7 @@ static switch_status_t avmd_parse_cmd_data_one_entry(char *candidate, struct avm
|
||||
}
|
||||
|
||||
/* this may be option parameter if valid */
|
||||
key = candidate_parsed[0]; /* option name */
|
||||
key = candidate_parsed[0]; /* option name */
|
||||
if (zstr(key)) { /* empty key */
|
||||
return SWITCH_STATUS_NOT_INITALIZED;
|
||||
}
|
||||
@@ -1399,7 +1399,7 @@ SWITCH_STANDARD_APP(avmd_start_app) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to add media bug!\n");
|
||||
goto end_unlock;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(avmd_globals.mutex);
|
||||
++avmd_globals.session_n;
|
||||
switch_mutex_unlock(avmd_globals.mutex);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -230,7 +230,7 @@ SWITCH_STANDARD_APP(bert_test_function)
|
||||
|
||||
/* Proceed to read and process the received frame ...
|
||||
* Note that switch_core_session_read_frame is a blocking operation, we could do reathing in another thread like the playback() app
|
||||
* does using switch_core_service_session() but OTOH that would lead to more load/cpu usage, extra threads being launched per call leg
|
||||
* does using switch_core_service_session() but OTOH that would lead to more load/cpu usage, extra threads being launched per call leg
|
||||
* and most likely reduce the overall capacity of the test system */
|
||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
@@ -381,23 +381,23 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_bert_load)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_TIMEOUT);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (switch_event_reserve_subclass(BERT_EVENT_LOST_SYNC) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_LOST_SYNC);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (switch_event_reserve_subclass(BERT_EVENT_IN_SYNC) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_IN_SYNC);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "bert_test", "Start BERT Test", "Start BERT Test", bert_test_function, "", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "bert_test", "Start BERT Test", "Start BERT Test", bert_test_function, "", SAF_NONE);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_bert_shutdown)
|
||||
switch_event_free_subclass(BERT_EVENT_TIMEOUT);
|
||||
switch_event_free_subclass(BERT_EVENT_LOST_SYNC);
|
||||
switch_event_free_subclass(BERT_EVENT_IN_SYNC);
|
||||
|
||||
|
||||
return SWITCH_STATUS_UNLOAD;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Mathieu Rene <mrene@avgs.ca>
|
||||
* Raymond Chandler <intralanman@freeswitch.org>
|
||||
*
|
||||
@@ -53,19 +53,19 @@ static struct {
|
||||
switch_memory_pool_t *pool;
|
||||
} globals;
|
||||
|
||||
blacklist_t *blacklist_create(const char *name)
|
||||
blacklist_t *blacklist_create(const char *name)
|
||||
{
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
blacklist_t *bl = NULL;
|
||||
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
bl = switch_core_alloc(pool, sizeof(*bl));
|
||||
switch_assert(bl);
|
||||
bl->pool = pool;
|
||||
|
||||
|
||||
switch_core_hash_init(&bl->list);
|
||||
switch_mutex_init(&bl->list_mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
|
||||
|
||||
return bl;
|
||||
}
|
||||
|
||||
@@ -117,14 +117,14 @@ static switch_status_t do_config(switch_bool_t reload)
|
||||
/* Load up blacklists */
|
||||
switch_xml_t xml, cfg, lists, list;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
|
||||
|
||||
if (!(xml = switch_xml_open_cfg("mod_blacklist.conf", &cfg, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load configuration section\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
|
||||
|
||||
/* Destroy any active lists */
|
||||
while ((hi = switch_core_hash_first_iter( globals.lists, hi))) {
|
||||
const void *key;
|
||||
@@ -133,7 +133,7 @@ static switch_status_t do_config(switch_bool_t reload)
|
||||
blacklist_free((blacklist_t*)val);
|
||||
switch_core_hash_delete(globals.lists, (const char*)key);
|
||||
}
|
||||
|
||||
|
||||
if ((lists = switch_xml_child(cfg, "lists"))) {
|
||||
for (list = switch_xml_child(lists, "list"); list; list = list->next) {
|
||||
const char *name = switch_xml_attr_soft(list, "name");
|
||||
@@ -151,9 +151,9 @@ static switch_status_t do_config(switch_bool_t reload)
|
||||
load_list(name, filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
|
||||
if (xml) {
|
||||
switch_xml_free(xml);
|
||||
xml = NULL;
|
||||
@@ -175,33 +175,33 @@ SWITCH_STANDARD_API(blacklist_api_function)
|
||||
char *data;
|
||||
int argc;
|
||||
char *argv[3];
|
||||
|
||||
|
||||
data = strdup(cmd);
|
||||
trim(data);
|
||||
if (!(argc = switch_separate_string(data, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid usage\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
if (!strcasecmp(argv[0], "check")) {
|
||||
blacklist_t *bl = NULL;
|
||||
switch_bool_t result;
|
||||
|
||||
|
||||
if (argc < 2 || zstr(argv[1]) || zstr(argv[2])) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
bl = switch_core_hash_find(globals.lists, argv[1]);
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
|
||||
if (!bl) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
|
||||
stream->write_function(stream, "false");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(bl->list_mutex);
|
||||
result = (switch_bool_t)(intptr_t)switch_core_hash_find(bl->list, argv[2]);
|
||||
stream->write_function(stream, "%s", result ? "true" : "false");
|
||||
@@ -212,17 +212,17 @@ SWITCH_STANDARD_API(blacklist_api_function)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
bl = switch_core_hash_find(globals.lists, argv[1]);
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
|
||||
if (!bl) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
|
||||
stream->write_function(stream, "-ERR Unknown blacklist\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(bl->list_mutex);
|
||||
switch_core_hash_insert(bl->list, argv[2], (void*)SWITCH_TRUE);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added [%s] to list [%s]\n", argv[2], argv[1]);
|
||||
@@ -234,17 +234,17 @@ SWITCH_STANDARD_API(blacklist_api_function)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Wrong syntax");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
bl = switch_core_hash_find(globals.lists, argv[1]);
|
||||
switch_mutex_unlock(globals.lists_mutex);
|
||||
|
||||
|
||||
if (!bl) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown blacklist [%s]\n", argv[1]);
|
||||
stream->write_function(stream, "-ERR Unknown blacklist\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(bl->list_mutex);
|
||||
switch_core_hash_delete(bl->list, argv[2]);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Removed [%s] from list [%s]\n", argv[2], argv[1]);
|
||||
@@ -278,7 +278,7 @@ SWITCH_STANDARD_API(blacklist_api_function)
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Saving %s to %s\n", argv[1], filename);
|
||||
|
||||
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
if (switch_file_open(&fd, filename, SWITCH_FOPEN_WRITE | SWITCH_FOPEN_TRUNCATE | SWITCH_FOPEN_CREATE, SWITCH_FPROT_OS_DEFAULT, globals.pool)
|
||||
== SWITCH_STATUS_SUCCESS) {
|
||||
@@ -287,7 +287,7 @@ SWITCH_STANDARD_API(blacklist_api_function)
|
||||
switch_file_printf(fd, "%s\n", (char *)var);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "adding %s to the dump file\n", (char *)var);
|
||||
}
|
||||
stream->write_function(stream, "+OK\n");
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "couldn't open %s for writing\n", filename);
|
||||
}
|
||||
@@ -300,7 +300,7 @@ SWITCH_STANDARD_API(blacklist_api_function)
|
||||
} else if (!zstr(argv[0])) {
|
||||
stream->write_function(stream, "-ERR: No such command: %s (see 'blacklist help')\n", argv[0]);
|
||||
}
|
||||
|
||||
|
||||
done:
|
||||
switch_safe_free(data);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -313,7 +313,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_blacklist_load)
|
||||
//switch_application_interface_t *app_interface;
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
globals.pool = pool;
|
||||
|
||||
|
||||
@@ -36,4 +36,4 @@
|
||||
<!-- <tier agent="1000@default" queue="support@default" level="1" position="1"/> -->
|
||||
</tiers>
|
||||
|
||||
</configuration>
|
||||
</configuration>
|
||||
@@ -17,12 +17,12 @@
|
||||
|
||||
<!-- comment out sql to not setup a database (directory) lookup -->
|
||||
<param name="sql" value="
|
||||
SELECT name||' ('||type||')' AS name
|
||||
SELECT name||' ('||type||')' AS name
|
||||
FROM phonebook p JOIN numbers n ON p.id = n.phonebook_id
|
||||
WHERE n.number='${caller_id_number}'
|
||||
WHERE n.number='${caller_id_number}'
|
||||
LIMIT 1
|
||||
"/>
|
||||
<!-- comment out citystate-sql to not setup a database (city/state)
|
||||
<!-- comment out citystate-sql to not setup a database (city/state)
|
||||
lookup -->
|
||||
<param name="citystate-sql" value="
|
||||
SELECT ratecenter||' '||state as name
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Rupa Schomaker <rupa@rupa.com>
|
||||
*
|
||||
* mod_cidlookup.c -- API for querying cid->name services and local data
|
||||
@@ -39,7 +39,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cidlookup_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_cidlookup_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_cidlookup, mod_cidlookup_load, mod_cidlookup_shutdown, NULL);
|
||||
@@ -90,7 +90,7 @@ static switch_cache_db_handle_t *cidlookup_get_db_handle(void)
|
||||
{
|
||||
switch_cache_db_handle_t *dbh = NULL;
|
||||
char *dsn;
|
||||
|
||||
|
||||
if (!zstr(globals.odbc_dsn)) {
|
||||
dsn = globals.odbc_dsn;
|
||||
} else {
|
||||
@@ -100,7 +100,7 @@ static switch_cache_db_handle_t *cidlookup_get_db_handle(void)
|
||||
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
|
||||
dbh = NULL;
|
||||
}
|
||||
|
||||
|
||||
return dbh;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
|
||||
/*
|
||||
TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree
|
||||
TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree
|
||||
*/
|
||||
#ifdef CURLOPT_TIMEOUT_MS
|
||||
if (timeout > 0) {
|
||||
@@ -452,12 +452,12 @@ static cid_data_t *do_whitepages_lookup(switch_memory_pool_t *pool, switch_event
|
||||
|
||||
query = switch_event_expand_headers(event, "http://api.whitepages.com/reverse_phone/1.0/?phone=${whitepages-cid};api_key=${whitepages-api-key}");
|
||||
do_lookup_url(pool, event, &xml_s, query, NULL, NULL, 0);
|
||||
|
||||
|
||||
if (zstr(xml_s)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No XML returned for number %s\n", num);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
xml = switch_xml_parse_str_dup(xml_s);
|
||||
|
||||
if (!xml) {
|
||||
@@ -706,7 +706,7 @@ SWITCH_STANDARD_APP(cidlookup_app_function)
|
||||
if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
|
||||
const char *uuid = switch_channel_get_partner_uuid(channel);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
|
||||
|
||||
|
||||
if (uuid) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Neal Horman <neal at wanlink dot com>
|
||||
*
|
||||
@@ -37,7 +37,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cluechoo_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_cluechoo_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_cluechoo_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_cluechoo, mod_cluechoo_load, mod_cluechoo_shutdown, NULL);
|
||||
@@ -102,7 +102,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cluechoo_shutdown)
|
||||
|
||||
/*========================================
|
||||
* sl.c:
|
||||
* Copyright 1993,1998 Toyoda Masashi
|
||||
* Copyright 1993,1998 Toyoda Masashi
|
||||
* (toyoda@is.titech.ac.jp)
|
||||
* Last Modified: 1998/ 7/22
|
||||
*========================================
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*========================================
|
||||
* sl.h: Text data of SL version 3.01
|
||||
* Copyright 1993 Toyoda Masashi
|
||||
* Copyright 1993 Toyoda Masashi
|
||||
* (toyoda@is.titech.ac.jp)
|
||||
* Last Modified: 1992/12/23
|
||||
*========================================
|
||||
|
||||
@@ -445,7 +445,7 @@ SWITCH_STANDARD_API(list_users_function)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_domain) {
|
||||
tag_name = "domain";
|
||||
key_name = "name";
|
||||
@@ -3147,7 +3147,7 @@ SWITCH_STANDARD_API(uuid_drop_dtmf)
|
||||
if (argv[0]) {
|
||||
uuid = argv[0];
|
||||
}
|
||||
|
||||
|
||||
if (argv[1]) {
|
||||
action = argv[1];
|
||||
}
|
||||
@@ -3191,15 +3191,15 @@ SWITCH_STANDARD_API(uuid_drop_dtmf)
|
||||
switch_channel_set_variable(channel, "drop_dtmf", "false");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
is_on = switch_channel_test_flag(channel, CF_DROP_DTMF);
|
||||
file = switch_channel_get_variable_dup(channel, "drop_dtmf_masking_file", SWITCH_FALSE, -1);
|
||||
digits = switch_channel_get_variable_dup(channel, "drop_dtmf_masking_digits", SWITCH_FALSE, -1);
|
||||
|
||||
stream->write_function(stream, "+OK %s is %s DTMF. mask_file: %s mask_digits: %s\n", uuid, is_on ? "dropping" : "not dropping",
|
||||
stream->write_function(stream, "+OK %s is %s DTMF. mask_file: %s mask_digits: %s\n", uuid, is_on ? "dropping" : "not dropping",
|
||||
file ? file : "NONE",
|
||||
digits ? digits : "NONE");
|
||||
|
||||
|
||||
switch_core_session_rwunlock(tsession);
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such channel %s!\n", uuid);
|
||||
@@ -3308,7 +3308,7 @@ SWITCH_STANDARD_API(uuid_set_media_stats)
|
||||
static void jsonify_stats(cJSON *json, const char *name, switch_rtp_stats_t *stats)
|
||||
{
|
||||
cJSON *jstats = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(json, name, jstats);
|
||||
cJSON_AddItemToObject(json, name, jstats);
|
||||
|
||||
stats->inbound.std_deviation = sqrt(stats->inbound.variance);
|
||||
|
||||
@@ -3345,7 +3345,7 @@ static void jsonify_stats(cJSON *json, const char *name, switch_rtp_stats_t *sta
|
||||
|
||||
add_stat(stats->rtcp.packet_count, "rtcp_packet_count");
|
||||
add_stat(stats->rtcp.octet_count, "rtcp_octet_count");
|
||||
|
||||
|
||||
}
|
||||
|
||||
static switch_bool_t true_enough(cJSON *json)
|
||||
@@ -3367,37 +3367,37 @@ SWITCH_STANDARD_JSON_API(json_stats_function)
|
||||
switch_core_session_t *tsession;
|
||||
|
||||
reply = cJSON_CreateObject();
|
||||
*json_reply = reply;
|
||||
*json_reply = reply;
|
||||
|
||||
if (zstr(uuid)) {
|
||||
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((tsession = switch_core_session_locate(uuid))) {
|
||||
cJSON *jevent;
|
||||
switch_rtp_stats_t *audio_stats = NULL, *video_stats = NULL;
|
||||
|
||||
switch_core_media_set_stats(tsession);
|
||||
|
||||
|
||||
audio_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_AUDIO, switch_core_session_get_pool(tsession));
|
||||
video_stats = switch_core_media_get_stats(tsession, SWITCH_MEDIA_TYPE_VIDEO, switch_core_session_get_pool(tsession));
|
||||
|
||||
|
||||
if (audio_stats) {
|
||||
jsonify_stats(reply, "audio", audio_stats);
|
||||
}
|
||||
|
||||
|
||||
if (video_stats) {
|
||||
jsonify_stats(reply, "video", video_stats);
|
||||
}
|
||||
|
||||
|
||||
if (true_enough(cdata) && switch_ivr_generate_json_cdr(tsession, &jevent, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
|
||||
cJSON_AddItemToObject(reply, "channelData", jevent);
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(tsession);
|
||||
|
||||
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("Session does not exist"));
|
||||
@@ -4225,7 +4225,7 @@ SWITCH_STANDARD_API(uuid_video_bitrate_function)
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_BITRATE_REQ;
|
||||
msg.numeric_arg = kps * 1024;
|
||||
msg.from = __FILE__;
|
||||
|
||||
|
||||
switch_core_session_receive_message(lsession, &msg);
|
||||
switch_core_session_video_reinit(lsession);
|
||||
switch_channel_video_sync(switch_core_session_get_channel(lsession));
|
||||
@@ -4276,7 +4276,7 @@ SWITCH_STANDARD_API(uuid_codec_debug_function)
|
||||
msg.numeric_arg = level;
|
||||
msg.numeric_reply = type;
|
||||
msg.from = __FILE__;
|
||||
|
||||
|
||||
switch_core_session_receive_message(lsession, &msg);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
switch_core_session_rwunlock(lsession);
|
||||
@@ -4321,7 +4321,7 @@ SWITCH_STANDARD_API(uuid_codec_param_function)
|
||||
msg.string_array_arg[2] = argv[3];
|
||||
msg.string_array_arg[3] = argv[4];
|
||||
msg.from = __FILE__;
|
||||
|
||||
|
||||
switch_core_session_receive_message(lsession, &msg);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
switch_core_session_rwunlock(lsession);
|
||||
@@ -5918,7 +5918,7 @@ SWITCH_STANDARD_API(uuid_getvar_function)
|
||||
char *ptr = NULL;
|
||||
int idx = -1;
|
||||
char *vname = strdup(var_name);
|
||||
|
||||
|
||||
if ((ptr = strchr(vname, '[')) && strchr(ptr, ']')) {
|
||||
*ptr++ = '\0';
|
||||
idx = atoi(ptr);
|
||||
@@ -5927,11 +5927,11 @@ SWITCH_STANDARD_API(uuid_getvar_function)
|
||||
|
||||
free(vname);
|
||||
}
|
||||
|
||||
|
||||
if (!var_value) {
|
||||
var_value = switch_channel_get_variable(channel, var_name);
|
||||
}
|
||||
|
||||
|
||||
if (var_value != NULL) {
|
||||
stream->write_function(stream, "%s", var_value);
|
||||
} else {
|
||||
@@ -6389,7 +6389,7 @@ SWITCH_STANDARD_API(quote_shell_arg_function)
|
||||
}
|
||||
|
||||
#define GETCPUTIME_SYNTAX "[reset]"
|
||||
SWITCH_STANDARD_API(getcputime_function)
|
||||
SWITCH_STANDARD_API(getcputime_function)
|
||||
{
|
||||
static int64_t reset_ums = 0, reset_kms = 0; // Last reset times in ms
|
||||
switch_cputime t = { 0 };
|
||||
@@ -6885,14 +6885,14 @@ SWITCH_STANDARD_JSON_API(json_channel_data_function)
|
||||
|
||||
|
||||
reply = cJSON_CreateObject();
|
||||
*json_reply = reply;
|
||||
*json_reply = reply;
|
||||
|
||||
if (zstr(uuid)) {
|
||||
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((tsession = switch_core_session_locate(uuid))) {
|
||||
cJSON *jevent;
|
||||
|
||||
@@ -6901,7 +6901,7 @@ SWITCH_STANDARD_JSON_API(json_channel_data_function)
|
||||
}
|
||||
|
||||
switch_core_session_rwunlock(tsession);
|
||||
|
||||
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("Session does not exist"));
|
||||
@@ -6921,7 +6921,7 @@ SWITCH_STANDARD_JSON_API(json_execute_function)
|
||||
switch_core_session_t *tsession;
|
||||
|
||||
reply = cJSON_CreateObject();
|
||||
*json_reply = reply;
|
||||
*json_reply = reply;
|
||||
|
||||
if (!data) {
|
||||
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT"));
|
||||
@@ -6938,7 +6938,7 @@ SWITCH_STANDARD_JSON_API(json_execute_function)
|
||||
cJSON_AddItemToObject(reply, "response", cJSON_CreateString("INVALID INPUT"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if ((tsession = switch_core_session_locate(uuid))) {
|
||||
if (switch_true(edata)) {
|
||||
cJSON *jevent = NULL;
|
||||
@@ -6974,7 +6974,7 @@ SWITCH_STANDARD_API(event_channel_broadcast_api_function)
|
||||
{
|
||||
cJSON *jdata = NULL;
|
||||
const char *channel;
|
||||
|
||||
|
||||
if (!cmd) {
|
||||
stream->write_function(stream, "-ERR parsing channel\n", SWITCH_VA_NONE);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -6999,7 +6999,7 @@ SWITCH_STANDARD_API(event_channel_broadcast_api_function)
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_JSON_API(json_api_function)
|
||||
@@ -7024,7 +7024,7 @@ SWITCH_STANDARD_JSON_API(json_api_function)
|
||||
reply = cJSON_CreateObject();
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
|
||||
if (cmd && (status = switch_api_execute(cmd->valuestring, arg ? arg->valuestring : NULL, session, &stream)) == SWITCH_STATUS_SUCCESS) {
|
||||
cJSON_AddItemToObject(reply, "message", cJSON_CreateString((char *) stream.data));
|
||||
} else {
|
||||
@@ -7067,10 +7067,10 @@ SWITCH_STANDARD_JSON_API(json_status_function)
|
||||
cJSON_AddItemToObject(o, "seconds", cJSON_CreateNumber(duration.sec));
|
||||
cJSON_AddItemToObject(o, "milliseconds", cJSON_CreateNumber(duration.ms));
|
||||
cJSON_AddItemToObject(o, "microseconds", cJSON_CreateNumber(duration.mms));
|
||||
|
||||
|
||||
cJSON_AddItemToObject(reply, "uptime", o);
|
||||
cJSON_AddItemToObject(reply, "version", cJSON_CreateString(switch_version_full_human()));
|
||||
|
||||
|
||||
o = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(reply, "sessions", o);
|
||||
|
||||
@@ -7091,7 +7091,7 @@ SWITCH_STANDARD_JSON_API(json_status_function)
|
||||
cJSON_AddItemToObject(oo, "max", cJSON_CreateNumber(sps));
|
||||
cJSON_AddItemToObject(oo, "peak", cJSON_CreateNumber(max_sps));
|
||||
cJSON_AddItemToObject(oo, "peak5Min", cJSON_CreateNumber(max_sps_fivemin));
|
||||
|
||||
|
||||
|
||||
o = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(reply, "idleCPU", o);
|
||||
@@ -7099,7 +7099,7 @@ SWITCH_STANDARD_JSON_API(json_status_function)
|
||||
cJSON_AddItemToObject(o, "used", cJSON_CreateNumber(switch_core_min_idle_cpu(-1.0)));
|
||||
cJSON_AddItemToObject(o, "allowed", cJSON_CreateNumber(switch_core_idle_cpu()));
|
||||
|
||||
|
||||
|
||||
if (switch_core_get_stacksizes(&cur, &max) == SWITCH_STATUS_SUCCESS) {
|
||||
o = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(reply, "stackSizeKB", o);
|
||||
@@ -7107,10 +7107,10 @@ SWITCH_STANDARD_JSON_API(json_status_function)
|
||||
cJSON_AddItemToObject(o, "current", cJSON_CreateNumber((double)(cur / 1024)));
|
||||
cJSON_AddItemToObject(o, "max", cJSON_CreateNumber((double)(max / 1024)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
*json_reply = reply;
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -7119,7 +7119,7 @@ SWITCH_STANDARD_API(json_function)
|
||||
cJSON *jcmd = NULL, *format = NULL;
|
||||
const char *message = "";
|
||||
char *response = NULL;
|
||||
|
||||
|
||||
if (zstr(cmd)) {
|
||||
message = "No JSON supplied.";
|
||||
goto err;
|
||||
@@ -7142,13 +7142,13 @@ SWITCH_STANDARD_API(json_function)
|
||||
} else {
|
||||
response = cJSON_PrintUnformatted(jcmd);
|
||||
}
|
||||
|
||||
|
||||
stream->write_function(stream, "%s\n", switch_str_nil(response));
|
||||
|
||||
|
||||
switch_safe_free(response);
|
||||
|
||||
cJSON_Delete(jcmd);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
err:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!-- http://wiki.freeswitch.org/wiki/Mod_conference -->
|
||||
<!-- http://wiki.freeswitch.org/wiki/Mod_conference -->
|
||||
<!-- None of these paths are real if you want any of these options you need to really set them up -->
|
||||
<configuration name="conference.conf" description="Audio Conference">
|
||||
<!-- Advertise certain presence on startup . -->
|
||||
@@ -6,8 +6,8 @@
|
||||
<room name="3001@$${domain}" status="FreeSWITCH"/>
|
||||
</advertise>
|
||||
|
||||
<!-- These are the default keys that map when you do not specify a caller control group -->
|
||||
<!-- Note: none and default are reserved names for group names. Disabled if dist-dtmf member flag is set. -->
|
||||
<!-- These are the default keys that map when you do not specify a caller control group -->
|
||||
<!-- Note: none and default are reserved names for group names. Disabled if dist-dtmf member flag is set. -->
|
||||
<caller-controls>
|
||||
<group name="default">
|
||||
<control action="mute" digits="0"/>
|
||||
@@ -29,19 +29,19 @@
|
||||
<profiles>
|
||||
<!--If no profile is specified it will default to "default"-->
|
||||
<profile name="default">
|
||||
<!-- Directory to drop CDR's
|
||||
<!-- Directory to drop CDR's
|
||||
'auto' means $PREFIX/logs/conference_cdr/<confernece_uuid>.cdr.xml
|
||||
a non-absolute path means $PREFIX/logs/<value>/<confernece_uuid>.cdr.xml
|
||||
absolute path means <value>/<confernece_uuid>.cdr.xml
|
||||
-->
|
||||
<!-- <param name="cdr-log-dir" value="auto"/> -->
|
||||
<!-- How to create a CDR event
|
||||
<!-- How to create a CDR event
|
||||
'content' means event body will contain CDR as XML
|
||||
'file' means 'CDR-Path' header will contain a path to file created in 'cdr-log-dir'
|
||||
'none' for no event
|
||||
-->
|
||||
<!-- <param name="cdr-event-mode" value="content"/> -->
|
||||
|
||||
|
||||
<!-- Domain (for presence) -->
|
||||
<param name="domain" value="$${domain}"/>
|
||||
<!-- Sample Rate-->
|
||||
|
||||
@@ -523,7 +523,7 @@ switch_status_t conference_api_sub_unvmute(conference_member_t *member, switch_s
|
||||
if (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if ((layer = conference_video_get_layer_locked(member))) {
|
||||
layer->clear = 1;
|
||||
conference_video_release_layer(&layer);
|
||||
@@ -1277,7 +1277,7 @@ switch_status_t conference_api_sub_vid_layout(conference_obj_t *conference, swit
|
||||
} else {
|
||||
group_name = argv[3];
|
||||
}
|
||||
|
||||
|
||||
if (!group_name) {
|
||||
stream->write_function(stream, "Group name not specified.\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -1294,7 +1294,7 @@ switch_status_t conference_api_sub_vid_layout(conference_obj_t *conference, swit
|
||||
}
|
||||
|
||||
stream->write_function(stream, "Change to layout group [%s]\n", group_name);
|
||||
|
||||
|
||||
if (argv[xx]) {
|
||||
if ((idx = atoi(argv[xx])) > 0) {
|
||||
idx--;
|
||||
@@ -1638,7 +1638,7 @@ switch_status_t conference_api_sub_vid_logo_img(conference_member_t *member, swi
|
||||
}
|
||||
|
||||
layer = conference_video_get_layer_locked(member);
|
||||
|
||||
|
||||
if (!layer) {
|
||||
goto end;
|
||||
}
|
||||
@@ -2545,7 +2545,7 @@ switch_status_t conference_api_sub_record(conference_obj_t *conference, switch_s
|
||||
}
|
||||
|
||||
if (id == 0 && conference->canvases[0]) id = 1;
|
||||
|
||||
|
||||
if (id > conference->canvas_count) {
|
||||
id = 1;
|
||||
}
|
||||
@@ -3001,7 +3001,7 @@ switch_status_t conference_api_dispatch(conference_obj_t *conference, switch_str
|
||||
}
|
||||
|
||||
member = conference_member_get_by_var(conference, var, val);
|
||||
|
||||
|
||||
if (member != NULL) {
|
||||
pfn(member, stream, argv[argn + 2]);
|
||||
switch_thread_rwlock_unlock(member->rwlock);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
static cJSON *get_canvas_info(mcu_canvas_t *canvas)
|
||||
{
|
||||
cJSON *obj = cJSON_CreateObject();
|
||||
|
||||
|
||||
cJSON_AddItemToObject(obj, "canvasID", cJSON_CreateNumber(canvas->canvas_id));
|
||||
cJSON_AddItemToObject(obj, "totalLayers", cJSON_CreateNumber(canvas->total_layers));
|
||||
cJSON_AddItemToObject(obj, "layersUsed", cJSON_CreateNumber(canvas->layers_used));
|
||||
@@ -53,7 +53,7 @@ static cJSON *get_canvas_info(mcu_canvas_t *canvas)
|
||||
if (canvas->vlayout) {
|
||||
cJSON_AddItemToObject(obj, "layoutName", cJSON_CreateString(canvas->vlayout->name));
|
||||
}
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -188,24 +188,24 @@ void conference_event_mod_channel_handler(const char *event_channel, cJSON *json
|
||||
}
|
||||
if (member_id < 0) member_id = 0;
|
||||
}
|
||||
|
||||
|
||||
if (member_id > 0) {
|
||||
conference_member_t *member;
|
||||
|
||||
|
||||
if ((member = conference_member_get(conference, member_id))) {
|
||||
mcu_canvas_t *canvas;
|
||||
|
||||
|
||||
if ((canvas = conference_video_get_canvas_locked(member))) {
|
||||
cJSON *obj;
|
||||
|
||||
|
||||
if ((obj = get_canvas_info(canvas))) {
|
||||
cJSON_AddItemToObject(obj, "layerID", cJSON_CreateNumber(member->video_layer_id));
|
||||
cJSON_AddItemToObject(obj, "layerID", cJSON_CreateNumber(member->video_layer_id));
|
||||
cJSON_AddItemToArray(array, obj);
|
||||
}
|
||||
|
||||
|
||||
conference_video_release_canvas(&canvas);
|
||||
}
|
||||
|
||||
|
||||
switch_thread_rwlock_unlock(member->rwlock);
|
||||
}
|
||||
|
||||
@@ -225,12 +225,12 @@ void conference_event_mod_channel_handler(const char *event_channel, cJSON *json
|
||||
|
||||
switch_mutex_unlock(conference->canvas_mutex);
|
||||
}
|
||||
|
||||
|
||||
switch_thread_rwlock_unlock(conference->rwlock);
|
||||
}
|
||||
|
||||
|
||||
addobj = array;
|
||||
|
||||
|
||||
} else if (!strcasecmp(action, "list-videoLayouts")) {
|
||||
switch_hash_index_t *hi;
|
||||
void *val;
|
||||
@@ -245,15 +245,15 @@ void conference_event_mod_channel_handler(const char *event_channel, cJSON *json
|
||||
cJSON *obj = cJSON_CreateObject();
|
||||
cJSON *resarray = cJSON_CreateArray();
|
||||
int i;
|
||||
|
||||
|
||||
switch_core_hash_this(hi, &vvar, NULL, &val);
|
||||
vlayout = (video_layout_t *)val;
|
||||
for (i = 0; i < vlayout->layers; i++) {
|
||||
if (vlayout->images[i].res_id) {
|
||||
cJSON_AddItemToArray(resarray, cJSON_CreateString((char *)vlayout->images[i].res_id));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(obj, "type", cJSON_CreateString("layout"));
|
||||
cJSON_AddItemToObject(obj, "name", cJSON_CreateString((char *)vvar));
|
||||
cJSON_AddItemToObject(obj, "resIDS", resarray);
|
||||
@@ -274,11 +274,11 @@ void conference_event_mod_channel_handler(const char *event_channel, cJSON *json
|
||||
lg = (layout_group_t *) val;
|
||||
|
||||
name = switch_mprintf("group:%s", (char *)vvar);
|
||||
|
||||
|
||||
for (vlnode = lg->layouts; vlnode; vlnode = vlnode->next) {
|
||||
cJSON_AddItemToArray(grouparray, cJSON_CreateString(vlnode->vlayout->name));
|
||||
}
|
||||
|
||||
|
||||
cJSON_AddItemToObject(obj, "type", cJSON_CreateString("layoutGroup"));
|
||||
cJSON_AddItemToObject(obj, "name", cJSON_CreateString(name));
|
||||
cJSON_AddItemToObject(obj, "groupLayouts", grouparray);
|
||||
|
||||
@@ -277,7 +277,7 @@ switch_status_t conference_file_play(conference_obj_t *conference, char *file, u
|
||||
const char *canvasstr = switch_event_get_header(fnode->fh.params, "canvas");
|
||||
const char *loopsstr = switch_event_get_header(fnode->fh.params, "loops");
|
||||
int canvas_id = -1;
|
||||
|
||||
|
||||
if (loopsstr) {
|
||||
fnode->loops = atoi(loopsstr);
|
||||
|
||||
|
||||
@@ -800,8 +800,8 @@ void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *ob
|
||||
}
|
||||
|
||||
member->loop_loop = 1;
|
||||
|
||||
goto do_continue;
|
||||
|
||||
goto do_continue;
|
||||
}
|
||||
|
||||
if (switch_test_flag(read_frame, SFF_CNG)) {
|
||||
@@ -1003,7 +1003,7 @@ void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *ob
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* skip frames that are not actual media or when we are muted or silent */
|
||||
if ((conference_utils_member_test_flag(member, MFLAG_TALKING) || member->energy_level == 0 || conference_utils_test_flag(member->conference, CFLAG_AUDIO_ALWAYS))
|
||||
&& conference_utils_member_test_flag(member, MFLAG_CAN_SPEAK) && !conference_utils_test_flag(member->conference, CFLAG_WAIT_MOD)
|
||||
|
||||
@@ -152,7 +152,7 @@ void conference_member_update_status_field(conference_member_t *member)
|
||||
if (!member->conference->la || !member->json || !member->status_field || conference_utils_member_test_flag(member, MFLAG_SECOND_SCREEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch_live_array_lock(member->conference->la);
|
||||
|
||||
if (!conference_utils_member_test_flag(member, MFLAG_CAN_SPEAK)) {
|
||||
@@ -198,7 +198,7 @@ void conference_member_update_status_field(conference_member_t *member)
|
||||
if (switch_channel_test_flag(member->channel, CF_VIDEO) || member->avatar_png_img) {
|
||||
video = cJSON_CreateObject();
|
||||
|
||||
if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
|
||||
if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
|
||||
member->video_layer_id > -1 && switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY) {
|
||||
cJSON_AddItemToObject(video, "visible", cJSON_CreateTrue());
|
||||
} else {
|
||||
@@ -423,7 +423,7 @@ conference_member_t *conference_member_get_by_var(conference_obj_t *conference,
|
||||
switch_mutex_lock(conference->member_mutex);
|
||||
for (member = conference->members; member; member = member->next) {
|
||||
const char *check_var;
|
||||
|
||||
|
||||
if (conference_utils_member_test_flag(member, MFLAG_NOCHANNEL)) {
|
||||
continue;
|
||||
}
|
||||
@@ -692,7 +692,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
||||
switch_mutex_lock(member->audio_out_mutex);
|
||||
lock_member(member);
|
||||
switch_mutex_lock(conference->member_mutex);
|
||||
|
||||
|
||||
if (member->rec) {
|
||||
conference->recording_members++;
|
||||
}
|
||||
@@ -766,7 +766,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
||||
member->energy_level = id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((var = switch_channel_get_variable_dup(member->channel, "video_initial_canvas", SWITCH_FALSE, -1))) {
|
||||
uint32_t id = atoi(var) - 1;
|
||||
if (id < conference->canvas_count) {
|
||||
@@ -777,16 +777,16 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
||||
|
||||
if ((var = switch_channel_get_variable_dup(member->channel, "video_initial_watching_canvas", SWITCH_FALSE, -1))) {
|
||||
uint32_t id = atoi(var) - 1;
|
||||
|
||||
|
||||
if (id == 0) {
|
||||
id = conference->canvas_count;
|
||||
}
|
||||
|
||||
|
||||
if (id <= conference->canvas_count && conference->canvases[id]) {
|
||||
member->watching_canvas_id = id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
conference_video_reset_member_codec_index(member);
|
||||
|
||||
if (has_video) {
|
||||
@@ -806,7 +806,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
||||
if ((var = switch_channel_get_variable(member->channel, "rtp_video_max_bandwidth_in"))) {
|
||||
member->max_bw_in = switch_parse_bandwidth_string(var);
|
||||
}
|
||||
|
||||
|
||||
if ((var = switch_channel_get_variable(member->channel, "rtp_video_max_bandwidth_out"))) {
|
||||
member->max_bw_out = switch_parse_bandwidth_string(var);
|
||||
|
||||
@@ -816,7 +816,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_channel_set_variable_printf(channel, "conference_member_id", "%d", member->id);
|
||||
switch_channel_set_variable_printf(channel, "conference_moderator", "%s", conference_utils_member_test_flag(member, MFLAG_MOD) ? "true" : "false");
|
||||
switch_channel_set_variable_printf(channel, "conference_ghost", "%s", conference_utils_member_test_flag(member, MFLAG_GHOST) ? "true" : "false");
|
||||
@@ -958,7 +958,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
||||
cJSON *dvars;
|
||||
switch_event_t *var_event;
|
||||
switch_event_header_t *hi;
|
||||
|
||||
|
||||
member->json = cJSON_CreateArray();
|
||||
cJSON_AddItemToArray(member->json, cJSON_CreateStringPrintf("%0.4d", member->id));
|
||||
cJSON_AddItemToArray(member->json, cJSON_CreateString(switch_channel_get_variable(member->channel, "caller_id_number")));
|
||||
@@ -979,7 +979,7 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m
|
||||
for (hi = var_event->headers; hi; hi = hi->next) {
|
||||
if (!strncasecmp(hi->name, "verto_dvar_", 11)) {
|
||||
char *var = hi->name + 11;
|
||||
|
||||
|
||||
if (var) {
|
||||
cJSON_AddItemToObject(dvars, var, cJSON_CreateString(hi->value));
|
||||
}
|
||||
@@ -1147,7 +1147,7 @@ switch_status_t conference_member_del(conference_obj_t *conference, conference_m
|
||||
lock_member(member);
|
||||
conference_utils_member_clear_flag(member, MFLAG_INTREE);
|
||||
|
||||
|
||||
|
||||
switch_safe_free(member->text_framedata);
|
||||
member->text_framesize = 0;
|
||||
if (member->text_buffer) {
|
||||
|
||||
@@ -192,7 +192,7 @@ void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *thread, v
|
||||
member->frame_size = SWITCH_RECOMMENDED_BUFFER_SIZE;
|
||||
member->frame = switch_core_alloc(member->pool, member->frame_size);
|
||||
member->mux_frame = switch_core_alloc(member->pool, member->frame_size);
|
||||
|
||||
|
||||
if (conference->canvases[0]) {
|
||||
member->canvas_id = rec->canvas_id;
|
||||
canvas = conference->canvases[member->canvas_id];
|
||||
|
||||
@@ -113,7 +113,7 @@ void conference_video_parse_layouts(conference_obj_t *conference, int WIDTH, int
|
||||
const char *val = NULL, *name = NULL, *bgimg = NULL;
|
||||
switch_bool_t auto_3d = SWITCH_FALSE;
|
||||
int border = 0;
|
||||
|
||||
|
||||
if ((val = switch_xml_attr(x_layout, "name"))) {
|
||||
name = val;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ void conference_video_parse_layouts(conference_obj_t *conference, int WIDTH, int
|
||||
auto_3d = switch_true(switch_xml_attr(x_layout, "auto-3d-position"));
|
||||
|
||||
bgimg = switch_xml_attr(x_layout, "bgimg");
|
||||
|
||||
|
||||
if ((val = switch_xml_attr(x_layout, "border"))) {
|
||||
border = atoi(val);
|
||||
if (border < 0) border = 0;
|
||||
@@ -147,7 +147,7 @@ void conference_video_parse_layouts(conference_obj_t *conference, int WIDTH, int
|
||||
if ((val = switch_xml_attr(x_image, "x"))) {
|
||||
x = atoi(val);
|
||||
}
|
||||
|
||||
|
||||
if ((val = switch_xml_attr(x_image, "y"))) {
|
||||
y = atoi(val);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ void conference_video_parse_layouts(conference_obj_t *conference, int WIDTH, int
|
||||
if ((val = switch_xml_attr(x_image, "floor-only"))) {
|
||||
flooronly = floor = switch_true(val);
|
||||
}
|
||||
|
||||
|
||||
if ((val = switch_xml_attr(x_image, "file-only"))) {
|
||||
fileonly = switch_true(val);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ void conference_video_parse_layouts(conference_obj_t *conference, int WIDTH, int
|
||||
if ((val = switch_xml_attr(x_image, "audio-position"))) {
|
||||
audio_position = val;
|
||||
}
|
||||
|
||||
|
||||
if ((val = switch_xml_attr(x_image, "border"))) {
|
||||
border = atoi(val);
|
||||
|
||||
@@ -203,9 +203,9 @@ void conference_video_parse_layouts(conference_obj_t *conference, int WIDTH, int
|
||||
if (hscale == -1) {
|
||||
hscale = scale;
|
||||
}
|
||||
|
||||
|
||||
if (!border) border = conference->video_border_size;
|
||||
|
||||
|
||||
if (fileonly) {
|
||||
floor = flooronly = 0;
|
||||
}
|
||||
@@ -220,8 +220,8 @@ void conference_video_parse_layouts(conference_obj_t *conference, int WIDTH, int
|
||||
vlayout->images[vlayout->layers].flooronly = flooronly;
|
||||
vlayout->images[vlayout->layers].fileonly = fileonly;
|
||||
vlayout->images[vlayout->layers].overlap = overlap;
|
||||
|
||||
|
||||
|
||||
|
||||
if (res_id) {
|
||||
vlayout->images[vlayout->layers].res_id = switch_core_strdup(conference->pool, res_id);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ void conference_video_parse_layouts(conference_obj_t *conference, int WIDTH, int
|
||||
vlayout->images[vlayout->layers].audio_position = switch_core_strdup(conference->pool, audio_position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vlayout->layers++;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ void conference_video_clear_layer(mcu_layer_t *layer)
|
||||
|
||||
layer->banner_patched = 0;
|
||||
layer->refresh = 1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void conference_video_reset_layer(mcu_layer_t *layer)
|
||||
@@ -421,7 +421,7 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
|
||||
layer->bug_frame.img = NULL;
|
||||
switch_thread_rwlock_unlock(layer->member->rwlock);
|
||||
}
|
||||
|
||||
|
||||
layer->bugged = 0;
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
|
||||
if (!layer->img) {
|
||||
layer->img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, img_w, img_h, 1);
|
||||
}
|
||||
|
||||
|
||||
if (layer->banner_img && !layer->banner_patched) {
|
||||
switch_img_fill(layer->canvas->img, layer->x_pos + layer->geometry.border, layer->y_pos + layer->geometry.border, layer->screen_w, layer->screen_h, &layer->canvas->letterbox_bgcolor);
|
||||
switch_img_fit(&layer->banner_img, layer->screen_w, layer->screen_h, SWITCH_FIT_SIZE);
|
||||
@@ -556,13 +556,13 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
|
||||
if (layer->geometry.border) {
|
||||
switch_img_fill(IMG, x_pos, y_pos, img_w, img_h, &layer->canvas->border_color);
|
||||
}
|
||||
|
||||
|
||||
img_w -= (layer->geometry.border * 2);
|
||||
img_h -= (layer->geometry.border * 2);
|
||||
|
||||
switch_img_scale(img, &layer->img, img_w, img_h);
|
||||
|
||||
if (layer->img) {
|
||||
if (layer->img) {
|
||||
switch_img_patch(IMG, layer->img, x_pos + layer->geometry.border, y_pos + layer->geometry.border);
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
layer->last_img_addr = img_addr;
|
||||
|
||||
} else {
|
||||
@@ -644,7 +644,7 @@ mcu_layer_t *conference_video_get_layer_locked(conference_member_t *member)
|
||||
conference_video_release_canvas(&canvas);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return layer;
|
||||
}
|
||||
|
||||
@@ -660,7 +660,7 @@ void conference_video_release_layer(mcu_layer_t **layer)
|
||||
|
||||
switch_mutex_unlock(canvas->mutex);
|
||||
conference_video_release_canvas(&canvas);
|
||||
|
||||
|
||||
*layer = NULL;
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ void conference_video_release_canvas(mcu_canvas_t **canvasP)
|
||||
mcu_canvas_t *canvas = NULL;
|
||||
|
||||
switch_assert(canvasP);
|
||||
|
||||
|
||||
canvas = *canvasP;
|
||||
|
||||
if (!canvas) return;
|
||||
@@ -708,7 +708,7 @@ void conference_video_detach_video_layer(conference_member_t *member)
|
||||
mcu_canvas_t *canvas = NULL;
|
||||
|
||||
if (member->canvas_id < 0) return;
|
||||
|
||||
|
||||
if (!(canvas = conference_video_get_canvas_locked(member))) {
|
||||
return;
|
||||
}
|
||||
@@ -718,7 +718,7 @@ void conference_video_detach_video_layer(conference_member_t *member)
|
||||
if (member->video_layer_id < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
layer = &canvas->layers[member->video_layer_id];
|
||||
|
||||
if (layer->geometry.audio_position) {
|
||||
@@ -745,7 +745,7 @@ void conference_video_detach_video_layer(conference_member_t *member)
|
||||
if (conference_utils_test_flag(member->conference, CFLAG_JSON_STATUS)) {
|
||||
conference_member_update_status_field(member);
|
||||
}
|
||||
|
||||
|
||||
if (canvas->bgimg) {
|
||||
conference_video_set_canvas_bgimg(canvas, NULL);
|
||||
}
|
||||
@@ -754,7 +754,7 @@ void conference_video_detach_video_layer(conference_member_t *member)
|
||||
|
||||
switch_mutex_unlock(canvas->mutex);
|
||||
conference_video_release_canvas(&canvas);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1125,7 +1125,7 @@ void conference_video_init_canvas_layers(conference_obj_t *conference, mcu_canva
|
||||
layer->idx = i;
|
||||
layer->refresh = 1;
|
||||
|
||||
|
||||
|
||||
layer->screen_w = (uint32_t)(canvas->img->d_w * layer->geometry.scale / VIDEO_LAYOUT_SCALE);
|
||||
layer->screen_h = (uint32_t)(canvas->img->d_h * layer->geometry.hscale / VIDEO_LAYOUT_SCALE);
|
||||
|
||||
@@ -1177,7 +1177,7 @@ void conference_video_init_canvas_layers(conference_obj_t *conference, mcu_canva
|
||||
if (conference->video_canvas_bgimg && !vlayout->bgimg) {
|
||||
conference_video_set_canvas_bgimg(canvas, conference->video_canvas_bgimg);
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_unlock(canvas->mutex);
|
||||
switch_thread_rwlock_unlock(canvas->video_rwlock);
|
||||
|
||||
@@ -1196,7 +1196,7 @@ switch_status_t conference_video_set_canvas_bgimg(mcu_canvas_t *canvas, const ch
|
||||
} else {
|
||||
scaled = 1;
|
||||
}
|
||||
|
||||
|
||||
if (!canvas->bgimg) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open image for bgimg\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -1434,7 +1434,7 @@ video_layout_t *conference_video_find_best_layout(conference_obj_t *conference,
|
||||
|
||||
for (vlnode = lg->layouts; vlnode; vlnode = vlnode->next) {
|
||||
int x, file_layers = 0, member_count = (int)count - file_count, total = vlnode->vlayout->layers;
|
||||
|
||||
|
||||
for (x = total; x >= 0; x--) {
|
||||
if (vlnode->vlayout->images[x].fileonly) {
|
||||
file_layers++;
|
||||
@@ -1462,7 +1462,7 @@ video_layout_t *conference_video_get_layout(conference_obj_t *conference, const
|
||||
} else {
|
||||
vlayout = switch_core_hash_find(conference->layout_hash, video_layout_name);
|
||||
}
|
||||
|
||||
|
||||
return vlayout;
|
||||
}
|
||||
|
||||
@@ -1473,9 +1473,9 @@ void conference_video_vmute_snap(conference_member_t *member, switch_bool_t clea
|
||||
if (member->canvas_id > -1 && member->video_layer_id > -1) {
|
||||
mcu_layer_t *layer = NULL;
|
||||
mcu_canvas_t *canvas = NULL;
|
||||
|
||||
|
||||
if ((canvas = conference_video_get_canvas_locked(member))) {
|
||||
|
||||
|
||||
switch_mutex_lock(canvas->mutex);
|
||||
layer = &canvas->layers[member->video_layer_id];
|
||||
switch_img_free(&layer->mute_img);
|
||||
@@ -1522,7 +1522,7 @@ void conference_video_canvas_set_fnode_layer(mcu_canvas_t *canvas, conference_fi
|
||||
if (canvas->layout_floor_id > -1) {
|
||||
idx = canvas->layout_floor_id;
|
||||
xlayer = &canvas->layers[idx];
|
||||
|
||||
|
||||
if (xlayer->fnode && xlayer->fnode != fnode) {
|
||||
idx = -1;
|
||||
}
|
||||
@@ -1615,7 +1615,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_
|
||||
} else {
|
||||
pop_status = switch_frame_buffer_pop(member->fb, &pop);
|
||||
}
|
||||
|
||||
|
||||
if (pop_status == SWITCH_STATUS_SUCCESS) {
|
||||
mcu_layer_t *layer = NULL;
|
||||
mcu_canvas_t *canvas = NULL;
|
||||
@@ -1623,14 +1623,14 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_
|
||||
if (!pop) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (loops == 0 || loops == 50) {
|
||||
switch_core_media_gen_key_frame(member->session);
|
||||
switch_core_session_request_video_refresh(member->session);
|
||||
}
|
||||
|
||||
loops++;
|
||||
|
||||
|
||||
if ((switch_size_t)pop != 1) {
|
||||
frame = (switch_frame_t *) pop;
|
||||
if (switch_test_flag(frame, SFF_ENCODED)) {
|
||||
@@ -1641,23 +1641,23 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_write_thread_run(switch_thread_
|
||||
|
||||
if (!switch_test_flag(frame, SFF_ENCODED) || frame->m) {
|
||||
switch_time_t now = switch_time_now();
|
||||
|
||||
|
||||
if (last) {
|
||||
int delta = (int)(now - last);
|
||||
if (delta > member->conference->video_fps.ms * 5000) {
|
||||
switch_core_session_request_video_refresh(member->session);
|
||||
switch_core_session_request_video_refresh(member->session);
|
||||
}
|
||||
}
|
||||
|
||||
last = now;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch_frame_buffer_free(member->fb, &frame);
|
||||
}
|
||||
|
||||
canvas = NULL;
|
||||
canvas = NULL;
|
||||
layer = NULL;
|
||||
patched = 0;
|
||||
|
||||
@@ -1774,7 +1774,7 @@ void conference_video_check_recording(conference_obj_t *conference, mcu_canvas_t
|
||||
if (!imember->rec) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!conference_utils_test_flag(conference, CFLAG_PERSONAL_CANVAS) && canvas && imember->canvas_id != canvas->canvas_id) {
|
||||
continue;
|
||||
}
|
||||
@@ -1805,10 +1805,10 @@ void conference_video_check_avatar(conference_member_t *member, switch_bool_t fo
|
||||
canvas = conference_video_get_canvas_locked(member);
|
||||
|
||||
if (conference_utils_test_flag(member->conference, CFLAG_VIDEO_REQUIRED_FOR_CANVAS) &&
|
||||
(!switch_channel_test_flag(member->channel, CF_VIDEO_READY) ||
|
||||
(!switch_channel_test_flag(member->channel, CF_VIDEO_READY) ||
|
||||
(switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY ||
|
||||
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE))) {
|
||||
|
||||
|
||||
if (canvas) {
|
||||
conference_video_release_canvas(&canvas);
|
||||
}
|
||||
@@ -1821,7 +1821,7 @@ void conference_video_check_avatar(conference_member_t *member, switch_bool_t fo
|
||||
|
||||
member->avatar_patched = 0;
|
||||
|
||||
if (!force && switch_channel_test_flag(member->channel, CF_VIDEO_READY) &&
|
||||
if (!force && switch_channel_test_flag(member->channel, CF_VIDEO_READY) &&
|
||||
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY && switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE) {
|
||||
conference_utils_member_set_flag_locked(member, MFLAG_ACK_VIDEO);
|
||||
switch_core_session_request_video_refresh(member->session);
|
||||
@@ -1888,7 +1888,7 @@ void conference_video_patch_fnode(mcu_canvas_t *canvas, conference_file_node_t *
|
||||
mcu_layer_t *layer = &canvas->layers[fnode->layer_id];
|
||||
switch_frame_t file_frame = { 0 };
|
||||
switch_status_t status = switch_core_file_read_video(&fnode->fh, &file_frame, SVR_FLUSH);
|
||||
|
||||
|
||||
if (status == SWITCH_STATUS_SUCCESS) {
|
||||
switch_img_free(&layer->cur_img);
|
||||
layer->cur_img = file_frame.img;
|
||||
@@ -1904,7 +1904,7 @@ void conference_video_patch_fnode(mcu_canvas_t *canvas, conference_file_node_t *
|
||||
|
||||
void conference_video_fnode_check(conference_file_node_t *fnode, int canvas_id) {
|
||||
mcu_canvas_t *canvas = NULL;
|
||||
|
||||
|
||||
if (switch_core_file_has_video(&fnode->fh, SWITCH_TRUE) && switch_core_file_read_video(&fnode->fh, NULL, SVR_CHECK) == SWITCH_STATUS_BREAK) {
|
||||
int full_screen = 0;
|
||||
char *res_id = NULL;
|
||||
@@ -1915,7 +1915,7 @@ void conference_video_fnode_check(conference_file_node_t *fnode, int canvas_id)
|
||||
}
|
||||
fnode->canvas_id = canvas_id;
|
||||
}
|
||||
|
||||
|
||||
canvas = fnode->conference->canvases[fnode->canvas_id];
|
||||
if (fnode->fh.params && fnode->conference->canvas_count == 1) {
|
||||
full_screen = switch_true(switch_event_get_header(fnode->fh.params, "full-screen"));
|
||||
@@ -1969,7 +1969,7 @@ switch_status_t conference_video_find_layer(conference_obj_t *conference, mcu_ca
|
||||
if (!layer &&
|
||||
(canvas->layers_used < canvas->total_layers ||
|
||||
(avatar_layers && !member->avatar_png_img) || conference_utils_member_test_flag(member, MFLAG_MOD)) &&
|
||||
(member->avatar_png_img || (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY &&
|
||||
(member->avatar_png_img || (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY &&
|
||||
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE))) {
|
||||
|
||||
/* find an empty layer */
|
||||
@@ -2050,7 +2050,7 @@ void conference_video_pop_next_image(conference_member_t *member, switch_image_t
|
||||
//if (member->avatar_png_img && switch_channel_test_flag(member->channel, CF_VIDEO_READY) && conference_utils_member_test_flag(member, MFLAG_ACK_VIDEO)) {
|
||||
// switch_img_free(&member->avatar_png_img);
|
||||
//}
|
||||
|
||||
|
||||
if (switch_channel_test_flag(member->channel, CF_VIDEO_READY)) {
|
||||
do {
|
||||
if (switch_queue_trypop(member->video_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
|
||||
@@ -2063,13 +2063,13 @@ void conference_video_pop_next_image(conference_member_t *member, switch_image_t
|
||||
size = switch_queue_size(member->video_queue);
|
||||
} while(size > 0);
|
||||
|
||||
if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
|
||||
member->video_layer_id > -1 &&
|
||||
if (conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
|
||||
member->video_layer_id > -1 &&
|
||||
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY &&
|
||||
switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE
|
||||
) {
|
||||
switch_vid_params_t vid_params = { 0 };
|
||||
|
||||
|
||||
switch_core_media_get_vid_params(member->session, &vid_params);
|
||||
|
||||
if (!vid_params.fps) {
|
||||
@@ -2081,7 +2081,7 @@ void conference_video_pop_next_image(conference_member_t *member, switch_image_t
|
||||
if ((member->good_img % (int)(vid_params.fps * 10)) == 0) {
|
||||
conference_video_reset_video_bitrate_counters(member);
|
||||
}
|
||||
|
||||
|
||||
if (member->auto_avatar && member->good_img > vid_params.fps * 3) {
|
||||
conference_video_check_flush(member, SWITCH_TRUE);
|
||||
}
|
||||
@@ -2123,7 +2123,7 @@ void conference_video_set_incoming_bitrate(conference_member_t *member, int kps,
|
||||
|
||||
if (!force && kps < member->managed_kps && member->conference->auto_kps_debounce) {
|
||||
member->auto_kps_debounce_ticks = member->conference->auto_kps_debounce / member->conference->video_fps.ms;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "%s setting bitrate debounce timer to %dms\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "%s setting bitrate debounce timer to %dms\n",
|
||||
switch_channel_get_name(member->channel), member->conference->auto_kps_debounce);
|
||||
member->managed_kps = kps;
|
||||
member->managed_kps_set = 0;
|
||||
@@ -2133,8 +2133,8 @@ void conference_video_set_incoming_bitrate(conference_member_t *member, int kps,
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_BITRATE_REQ;
|
||||
msg.numeric_arg = kps * 1024;
|
||||
msg.from = __FILE__;
|
||||
|
||||
switch_core_session_receive_message(member->session, &msg);
|
||||
|
||||
switch_core_session_receive_message(member->session, &msg);
|
||||
|
||||
member->managed_kps_set = 1;
|
||||
member->managed_kps = kps;
|
||||
@@ -2167,7 +2167,7 @@ void conference_video_set_max_incoming_bitrate(conference_obj_t *conference, int
|
||||
conference_video_set_max_incoming_bitrate_member(imember, kps);
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(conference->member_mutex);
|
||||
switch_mutex_unlock(conference->member_mutex);
|
||||
}
|
||||
|
||||
void conference_video_set_absolute_incoming_bitrate(conference_obj_t *conference, int kps)
|
||||
@@ -2180,7 +2180,7 @@ void conference_video_set_absolute_incoming_bitrate(conference_obj_t *conference
|
||||
conference_video_set_absolute_incoming_bitrate_member(imember, kps);
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(conference->member_mutex);
|
||||
switch_mutex_unlock(conference->member_mutex);
|
||||
}
|
||||
|
||||
void conference_video_check_auto_bitrate(conference_member_t *member, mcu_layer_t *layer)
|
||||
@@ -2189,8 +2189,8 @@ void conference_video_check_auto_bitrate(conference_member_t *member, mcu_layer_
|
||||
int kps = 0, kps_in = 0;
|
||||
int max = 0;
|
||||
int min_layer = 0, min = 0;
|
||||
|
||||
if (!conference_utils_test_flag(member->conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE) ||
|
||||
|
||||
if (!conference_utils_test_flag(member->conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE) ||
|
||||
switch_channel_test_flag(member->channel, CF_VIDEO_BITRATE_UNMANAGABLE)) {
|
||||
return;
|
||||
}
|
||||
@@ -2212,7 +2212,7 @@ void conference_video_check_auto_bitrate(conference_member_t *member, mcu_layer_
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (vid_params.width != member->vid_params.width || vid_params.height != member->vid_params.height) {
|
||||
switch_core_session_request_video_refresh(member->session);
|
||||
conference_video_clear_managed_kps(member);
|
||||
@@ -2224,7 +2224,7 @@ void conference_video_check_auto_bitrate(conference_member_t *member, mcu_layer_
|
||||
return;
|
||||
}
|
||||
|
||||
if ((kps_in = switch_calc_bitrate(vid_params.width, vid_params.height,
|
||||
if ((kps_in = switch_calc_bitrate(vid_params.width, vid_params.height,
|
||||
member->conference->video_quality, (int)(member->conference->video_fps.fps))) < 512) {
|
||||
kps_in = 512;
|
||||
}
|
||||
@@ -2237,9 +2237,9 @@ void conference_video_check_auto_bitrate(conference_member_t *member, mcu_layer_
|
||||
|
||||
min_layer = kps / 2;
|
||||
min = kps_in / 2;
|
||||
|
||||
|
||||
if (min_layer > min) min = min_layer;
|
||||
|
||||
|
||||
if (member->conference->max_bw_in) {
|
||||
max = member->conference->max_bw_in;
|
||||
} else {
|
||||
@@ -2294,7 +2294,7 @@ static void wait_for_canvas(mcu_canvas_t *canvas)
|
||||
|
||||
for (i = 0; i < canvas->total_layers; i++) {
|
||||
mcu_layer_t *layer = &canvas->layers[i];
|
||||
|
||||
|
||||
if (layer->need_patch) {
|
||||
if (layer->member_id && layer->member && conference_utils_member_test_flag(layer->member, MFLAG_RUNNING) && layer->member->fb) {
|
||||
switch_frame_buffer_trypush(layer->member->fb, (void *) 1);
|
||||
@@ -2323,18 +2323,18 @@ static void personal_attach(mcu_layer_t *layer, conference_member_t *member)
|
||||
layer->avatar_patched = 0;
|
||||
switch_img_free(&layer->banner_img);
|
||||
switch_img_free(&layer->logo_img);
|
||||
|
||||
|
||||
if (layer->geometry.audio_position) {
|
||||
conference_api_sub_position(member, NULL, layer->geometry.audio_position);
|
||||
}
|
||||
|
||||
|
||||
if (member->channel) {
|
||||
var = NULL;
|
||||
if (member->video_banner_text ||
|
||||
(var = switch_channel_get_variable_dup(member->channel, "video_banner_text", SWITCH_FALSE, -1))) {
|
||||
conference_video_layer_set_banner(member, layer, var);
|
||||
}
|
||||
|
||||
|
||||
var = NULL;
|
||||
if (member->video_logo ||
|
||||
(var = switch_channel_get_variable_dup(member->channel, "video_logo_path", SWITCH_FALSE, -1))) {
|
||||
@@ -2342,7 +2342,7 @@ static void personal_attach(mcu_layer_t *layer, conference_member_t *member)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
layer->member_id = member->id;
|
||||
}
|
||||
|
||||
@@ -2376,7 +2376,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
canvas->video_layout_group = conference->video_layout_group;
|
||||
|
||||
packet = switch_core_alloc(conference->pool, SWITCH_RTP_MAX_BUF_LEN);
|
||||
|
||||
|
||||
while (conference_globals.running && !conference_utils_test_flag(conference, CFLAG_DESTRUCT) && conference_utils_test_flag(conference, CFLAG_VIDEO_MUXING)) {
|
||||
switch_bool_t need_refresh = SWITCH_FALSE, send_keyframe = SWITCH_FALSE, need_reset = SWITCH_FALSE;
|
||||
switch_time_t now;
|
||||
@@ -2429,14 +2429,14 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
int no_muted = conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS);
|
||||
int no_av = conference_utils_test_flag(imember->conference, CFLAG_VIDEO_REQUIRED_FOR_CANVAS);
|
||||
int seen = conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN);
|
||||
|
||||
if (imember->channel && switch_channel_ready(imember->channel) && switch_channel_test_flag(imember->channel, CF_VIDEO_READY) &&
|
||||
|
||||
if (imember->channel && switch_channel_ready(imember->channel) && switch_channel_test_flag(imember->channel, CF_VIDEO_READY) &&
|
||||
!conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN) &&
|
||||
conference_utils_member_test_flag(imember, MFLAG_RUNNING) && (!no_muted || seen) && (!no_av || (no_av && !imember->avatar_png_img))
|
||||
&& imember->canvas_id == canvas->canvas_id && imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY && imember->video_media_flow != SWITCH_MEDIA_FLOW_INACTIVE) {
|
||||
video_count++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2470,7 +2470,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
if (members_with_avatar != conference->members_with_avatar) {
|
||||
count_changed = 1;
|
||||
}
|
||||
|
||||
|
||||
if (conference_utils_test_flag(conference, CFLAG_REFRESH_LAYOUT)) {
|
||||
count_changed = 1;
|
||||
conference_utils_clear_flag(conference, CFLAG_REFRESH_LAYOUT);
|
||||
@@ -2490,7 +2490,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
if (count_changed && !personal) {
|
||||
layout_group_t *lg = NULL;
|
||||
video_layout_t *vlayout = NULL;
|
||||
|
||||
|
||||
if (canvas->video_layout_group && (lg = switch_core_hash_find(conference->layout_group_hash, canvas->video_layout_group))) {
|
||||
if ((vlayout = conference_video_find_best_layout(conference, lg, canvas->video_count, file_count)) && vlayout != canvas->vlayout) {
|
||||
switch_mutex_lock(conference->member_mutex);
|
||||
@@ -2618,17 +2618,17 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
continue;
|
||||
}
|
||||
|
||||
if (conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) &&
|
||||
if (conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) &&
|
||||
!conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN) && imember->video_layer_id > -1) {
|
||||
conference_video_detach_video_layer(imember);
|
||||
switch_img_free(&imember->video_mute_img);
|
||||
|
||||
|
||||
if (imember->id == imember->conference->video_floor_holder) {
|
||||
conference_video_set_floor_holder(conference, NULL, SWITCH_FALSE);
|
||||
} else if (imember->id == imember->conference->last_video_floor_holder) {
|
||||
conference->last_video_floor_holder = 0;
|
||||
}
|
||||
|
||||
|
||||
switch_core_session_rwunlock(imember->session);
|
||||
continue;
|
||||
}
|
||||
@@ -2707,15 +2707,15 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
}
|
||||
|
||||
if (!layer->mute_patched) {
|
||||
|
||||
|
||||
if (!imember->video_mute_img) {
|
||||
conference_video_vmute_snap(imember, SWITCH_FALSE);
|
||||
}
|
||||
|
||||
|
||||
if (imember->video_mute_img || layer->mute_img) {
|
||||
conference_video_clear_layer(layer);
|
||||
|
||||
if (!layer->mute_img) {
|
||||
|
||||
if (!layer->mute_img) {
|
||||
if (imember->video_mute_img) {
|
||||
//layer->mute_img = switch_img_read_png(imember->video_mute_png, SWITCH_IMG_FMT_I420);
|
||||
switch_img_copy(imember->video_mute_img, &layer->mute_img);
|
||||
@@ -2768,7 +2768,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
layout_group_t *lg = NULL;
|
||||
video_layout_t *vlayout = NULL;
|
||||
conference_member_t *omember;
|
||||
|
||||
|
||||
if (video_key_freq && (now - last_key_time) > video_key_freq) {
|
||||
send_keyframe = SWITCH_TRUE;
|
||||
last_key_time = now;
|
||||
@@ -2777,7 +2777,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
switch_mutex_lock(conference->member_mutex);
|
||||
|
||||
for (imember = conference->members; imember; imember = imember->next) {
|
||||
|
||||
|
||||
if (!imember->rec &&
|
||||
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
|
||||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
|
||||
@@ -2797,12 +2797,12 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
conference_video_init_canvas_layers(conference, imember->canvas, conference->new_personal_vlayout);
|
||||
layout_applied++;
|
||||
}
|
||||
|
||||
|
||||
if (imember->channel && switch_channel_test_flag(imember->channel, CF_VIDEO_REFRESH_REQ)) {
|
||||
switch_channel_clear_flag(imember->channel, CF_VIDEO_REFRESH_REQ);
|
||||
send_keyframe = SWITCH_TRUE;
|
||||
}
|
||||
|
||||
|
||||
if (count_changed) {
|
||||
int total = last_video_count;
|
||||
int kps;
|
||||
@@ -2812,12 +2812,12 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
total += conference->members_with_avatar;
|
||||
}
|
||||
|
||||
if (total > 0 &&
|
||||
(!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
|
||||
conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN)) &&
|
||||
if (total > 0 &&
|
||||
(!conference_utils_test_flag(imember->conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
|
||||
conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN)) &&
|
||||
imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY &&
|
||||
imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE) {
|
||||
|
||||
|
||||
total--;
|
||||
}
|
||||
|
||||
@@ -2826,21 +2826,21 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
if (conference->members_with_video == 1 && file_count) {
|
||||
total = 0;
|
||||
}
|
||||
|
||||
|
||||
if (canvas->video_layout_group && (lg = switch_core_hash_find(conference->layout_group_hash, canvas->video_layout_group))) {
|
||||
if ((vlayout = conference_video_find_best_layout(conference, lg, total + file_count, file_count))) {
|
||||
conference_video_init_canvas_layers(conference, imember->canvas, vlayout);
|
||||
}
|
||||
}
|
||||
|
||||
if (imember->channel && !switch_channel_test_flag(imember->channel, CF_VIDEO_BITRATE_UNMANAGABLE) &&
|
||||
|
||||
if (imember->channel && !switch_channel_test_flag(imember->channel, CF_VIDEO_BITRATE_UNMANAGABLE) &&
|
||||
conference_utils_test_flag(conference, CFLAG_MANAGE_INBOUND_VIDEO_BITRATE)) {
|
||||
switch_core_media_get_vid_params(imember->session, &vid_params);
|
||||
kps = switch_calc_bitrate(vid_params.width, vid_params.height, conference->video_quality, (int)(imember->conference->video_fps.fps));
|
||||
conference_video_set_incoming_bitrate(imember, kps, SWITCH_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (imember->session && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY && switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE) {
|
||||
conference_video_pop_next_image(imember, &imember->pcanvas_img);
|
||||
}
|
||||
@@ -2856,10 +2856,10 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
}
|
||||
|
||||
switch_mutex_lock(conference->mutex);
|
||||
|
||||
|
||||
if (check_async_file && conference->async_fnode) {
|
||||
switch_status_t st = switch_core_file_read_video(&conference->async_fnode->fh, &file_frame, SVR_FLUSH);
|
||||
|
||||
|
||||
if (st == SWITCH_STATUS_SUCCESS) {
|
||||
if ((async_file_img = file_frame.img)) {
|
||||
switch_img_free(&file_imgs[j]);
|
||||
@@ -2887,8 +2887,8 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
for (imember = conference->members; imember; imember = imember->next) {
|
||||
int i = 0;
|
||||
mcu_layer_t *floor_layer = NULL;
|
||||
|
||||
if (!imember->rec &&
|
||||
|
||||
if (!imember->rec &&
|
||||
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO) || !imember->canvas ||
|
||||
(switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY ||
|
||||
switch_core_session_media_flow(imember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) ||
|
||||
@@ -2907,19 +2907,19 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
|
||||
if (!file_count && imember->canvas->layout_floor_id > -1 && imember->conference->video_floor_holder &&
|
||||
imember->id != imember->conference->video_floor_holder) {
|
||||
|
||||
|
||||
if ((omember = conference_member_get(imember->conference, imember->conference->video_floor_holder))) {
|
||||
if (conference->members_with_video + conference->members_with_avatar == 1 || imember != omember) {
|
||||
layer = &imember->canvas->layers[imember->canvas->layout_floor_id];
|
||||
floor_layer = layer;
|
||||
layer = NULL;
|
||||
}
|
||||
|
||||
|
||||
switch_thread_rwlock_unlock(omember->rwlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (omember = conference->members; omember; omember = omember->next) {
|
||||
mcu_layer_t *layer = NULL;
|
||||
switch_image_t *use_img = NULL;
|
||||
@@ -2928,7 +2928,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
switch_core_session_media_flow(omember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_SENDONLY || switch_core_session_media_flow(omember->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_INACTIVE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (conference->members_with_video + conference->members_with_avatar != 1 && imember == omember) {
|
||||
continue;
|
||||
}
|
||||
@@ -2936,7 +2936,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
if (file_count && (conference->members_with_video + conference->members_with_avatar == 1)) {
|
||||
floor_layer = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!file_count && floor_layer && omember->id == conference->video_floor_holder) {
|
||||
layer = floor_layer;
|
||||
} else {
|
||||
@@ -2945,7 +2945,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (i < imember->canvas->total_layers) {
|
||||
layer = &imember->canvas->layers[i++];
|
||||
}
|
||||
@@ -2960,11 +2960,11 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
}
|
||||
|
||||
use_img = omember->pcanvas_img;
|
||||
|
||||
|
||||
if (files_playing && layer && layer == &imember->canvas->layers[imember->canvas->layout_floor_id]) {
|
||||
use_img = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (layer) {
|
||||
|
||||
if (use_img && !omember->avatar_png_img) {
|
||||
@@ -3010,7 +3010,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
conference_video_scale_and_patch(layer, img, SWITCH_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (imember->session) {
|
||||
switch_core_session_rwunlock(imember->session);
|
||||
}
|
||||
@@ -3025,7 +3025,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
for (imember = conference->members; imember; imember = imember->next) {
|
||||
switch_frame_t *dupframe;
|
||||
|
||||
if (!imember->rec &&
|
||||
if (!imember->rec &&
|
||||
(!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) || !imember->canvas ||
|
||||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS)) {
|
||||
continue;
|
||||
@@ -3040,7 +3040,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
}
|
||||
|
||||
write_frame.img = imember->canvas->img;
|
||||
|
||||
|
||||
if (imember->rec) {
|
||||
switch_core_file_write_video(&imember->rec->fh, &write_frame);
|
||||
} else {
|
||||
@@ -3066,7 +3066,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
|
||||
switch_mutex_unlock(conference->member_mutex);
|
||||
} else {
|
||||
|
||||
|
||||
if (conference->async_fnode && (conference->async_fnode->canvas_id == canvas->canvas_id || conference->async_fnode->canvas_id == -1)) {
|
||||
if (conference->async_fnode->layer_id > -1) {
|
||||
conference_video_patch_fnode(canvas, conference->async_fnode);
|
||||
@@ -3170,11 +3170,11 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
} else if (file_img) {
|
||||
switch_img_free(&file_img);
|
||||
}
|
||||
|
||||
|
||||
write_frame.img = write_img;
|
||||
|
||||
wait_for_canvas(canvas);
|
||||
|
||||
|
||||
if (canvas->recording) {
|
||||
conference_video_check_recording(conference, canvas, &write_frame);
|
||||
}
|
||||
@@ -3196,14 +3196,14 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
timestamp, need_refresh, send_keyframe, need_reset);
|
||||
|
||||
if (canvas->video_write_bandwidth) {
|
||||
switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
|
||||
switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
|
||||
SCCT_INT, &canvas->video_write_bandwidth, SCCT_NONE, NULL, NULL, NULL);
|
||||
canvas->video_write_bandwidth = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(conference->member_mutex);
|
||||
for (imember = conference->members; imember; imember = imember->next) {
|
||||
switch_frame_t *dupframe;
|
||||
@@ -3218,7 +3218,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
|
||||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (need_refresh) {
|
||||
switch_core_session_request_video_refresh(imember->session);
|
||||
}
|
||||
@@ -3545,7 +3545,7 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
|
||||
conference_video_write_canvas_image_to_codec_group(conference, canvas, write_codecs[i], i, timestamp, need_refresh, send_keyframe, need_reset);
|
||||
|
||||
if (canvas->video_write_bandwidth) {
|
||||
switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
|
||||
switch_core_codec_control(&write_codecs[i]->codec, SCC_VIDEO_BANDWIDTH,
|
||||
SCCT_INT, &canvas->video_write_bandwidth, SCCT_NONE, NULL, NULL, NULL);
|
||||
canvas->video_write_bandwidth = 0;
|
||||
}
|
||||
@@ -3562,7 +3562,7 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!imember->session || !switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ||
|
||||
switch_core_session_read_lock(imember->session) != SWITCH_STATUS_SUCCESS) {
|
||||
continue;
|
||||
@@ -3771,7 +3771,7 @@ void conference_video_set_floor_holder(conference_obj_t *conference, conference_
|
||||
}
|
||||
conference_video_release_canvas(&canvas);
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Adding video floor %s\n",
|
||||
switch_channel_get_name(member->channel));
|
||||
|
||||
@@ -3916,15 +3916,15 @@ void conference_video_write_frame(conference_obj_t *conference, conference_membe
|
||||
if (want_refresh) {
|
||||
for (imember = conference->members; imember; imember = imember->next) {
|
||||
switch_core_session_t *isession = imember->session;
|
||||
|
||||
|
||||
if (!isession || switch_core_session_read_lock(isession) != SWITCH_STATUS_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (switch_channel_test_flag(imember->channel, CF_VIDEO_READY) ) {
|
||||
switch_core_session_request_video_refresh(imember->session);
|
||||
switch_core_session_request_video_refresh(imember->session);
|
||||
}
|
||||
|
||||
|
||||
switch_core_session_rwunlock(isession);
|
||||
}
|
||||
}
|
||||
@@ -3969,7 +3969,7 @@ switch_status_t conference_video_thread_callback(switch_core_session_t *session,
|
||||
if (conference_utils_test_flag(member->conference, CFLAG_VIDEO_MUXING)) {
|
||||
switch_image_t *img_copy = NULL;
|
||||
|
||||
if (frame->img && (member->video_layer_id > -1 || member->canvas) &&
|
||||
if (frame->img && (member->video_layer_id > -1 || member->canvas) &&
|
||||
conference_utils_member_test_flag(member, MFLAG_CAN_BE_SEEN) &&
|
||||
switch_queue_size(member->video_queue) < member->conference->video_fps.fps * 2 &&
|
||||
!member->conference->playing_video_file) {
|
||||
@@ -3992,7 +3992,7 @@ switch_status_t conference_video_thread_callback(switch_core_session_t *session,
|
||||
} else {
|
||||
switch_img_copy(frame->img, &img_copy);
|
||||
}
|
||||
|
||||
|
||||
if (switch_queue_trypush(member->video_queue, img_copy) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_img_free(&img_copy);
|
||||
}
|
||||
|
||||
@@ -258,16 +258,16 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
|
||||
const char *caller_id_name = switch_channel_get_variable(imember->channel, "caller_id_name");
|
||||
unsigned char CR[3] = TEXT_UNICODE_LINEFEED;
|
||||
|
||||
|
||||
|
||||
switch_mutex_lock(imember->text_mutex);
|
||||
|
||||
framedatalen = strlen(imember->text_framedata) + strlen(caller_id_name) + 6;
|
||||
|
||||
switch_zmalloc(framedata, framedatalen);
|
||||
|
||||
|
||||
switch_snprintf(framedata, framedatalen, "%s::\n%s", caller_id_name, imember->text_framedata);
|
||||
memcpy(framedata + strlen(framedata), CR, sizeof(CR));
|
||||
|
||||
|
||||
|
||||
frame.data = framedata;
|
||||
frame.datalen = framedatalen;
|
||||
@@ -277,9 +277,9 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
|
||||
switch_core_session_write_text_frame(omember->session, &frame, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
free(framedata);
|
||||
|
||||
|
||||
imember->text_framedata[0] = '\0';
|
||||
|
||||
switch_mutex_unlock(imember->text_mutex);
|
||||
@@ -295,7 +295,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
|
||||
if (conference_utils_member_test_flag(imember, MFLAG_RUNNING) && imember->session) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(imember->session);
|
||||
switch_media_flow_t video_media_flow;
|
||||
|
||||
|
||||
if ((!floor_holder || (imember->score_iir > SCORE_IIR_SPEAKING_MAX && (floor_holder->score_iir < SCORE_IIR_SPEAKING_MIN)))) {// &&
|
||||
//(!conference_utils_test_flag(conference, CFLAG_VID_FLOOR) || switch_channel_test_flag(channel, CF_VIDEO))) {
|
||||
floor_holder = imember;
|
||||
@@ -316,18 +316,18 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_channel_ready(channel) &&
|
||||
switch_channel_test_flag(channel, CF_VIDEO_READY) &&
|
||||
imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
|
||||
!conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN) &&
|
||||
(!conference_utils_test_flag(conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
|
||||
if (switch_channel_ready(channel) &&
|
||||
switch_channel_test_flag(channel, CF_VIDEO_READY) &&
|
||||
imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
|
||||
!conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN) &&
|
||||
(!conference_utils_test_flag(conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) ||
|
||||
conference_utils_member_test_flag(imember, MFLAG_CAN_BE_SEEN))) {
|
||||
members_with_video++;
|
||||
}
|
||||
|
||||
if (switch_channel_ready(channel) &&
|
||||
switch_channel_test_flag(channel, CF_VIDEO_READY) &&
|
||||
imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
|
||||
if (switch_channel_ready(channel) &&
|
||||
switch_channel_test_flag(channel, CF_VIDEO_READY) &&
|
||||
imember->video_media_flow != SWITCH_MEDIA_FLOW_SENDONLY &&
|
||||
!conference_utils_member_test_flag(imember, MFLAG_SECOND_SCREEN)) {
|
||||
members_seeing_video++;
|
||||
}
|
||||
@@ -455,7 +455,7 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
|
||||
}
|
||||
} else if (conference->fnode->type == NODE_TYPE_FILE) {
|
||||
switch_core_file_read(&conference->fnode->fh, file_frame, &file_sample_len);
|
||||
|
||||
|
||||
if (conference->fnode->fh.vol) {
|
||||
switch_change_sln_volume_granular((void *)file_frame, (uint32_t)file_sample_len * conference->fnode->fh.channels,
|
||||
conference->fnode->fh.vol);
|
||||
@@ -470,13 +470,13 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
|
||||
if (--conference->fnode->loops < 0) {
|
||||
conference->fnode->loops = -1;
|
||||
}
|
||||
|
||||
|
||||
if (conference->fnode->loops) {
|
||||
uint32_t pos = 0;
|
||||
switch_core_file_seek(&conference->fnode->fh, &pos, 0, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!conference->fnode->loops) {
|
||||
conference->fnode->done++;
|
||||
}
|
||||
@@ -501,13 +501,13 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
|
||||
if (--conference->async_fnode->loops < 0) {
|
||||
conference->async_fnode->loops = -1;
|
||||
}
|
||||
|
||||
|
||||
if (conference->async_fnode->loops) {
|
||||
uint32_t pos = 0;
|
||||
switch_core_file_seek(&conference->async_fnode->fh, &pos, 0, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!conference->async_fnode->loops) {
|
||||
conference->async_fnode->done++;
|
||||
}
|
||||
@@ -1814,17 +1814,17 @@ switch_status_t conference_text_thread_callback(switch_core_session_t *session,
|
||||
memcpy(tmp, member->text_framedata, member->text_framesize);
|
||||
|
||||
switch_assert(tmp);
|
||||
|
||||
|
||||
member->text_framesize = inuse + 1024;
|
||||
|
||||
|
||||
free(member->text_framedata);
|
||||
member->text_framedata = tmp;
|
||||
|
||||
}
|
||||
|
||||
bytes = switch_buffer_read(member->text_buffer, member->text_framedata, inuse);
|
||||
*(member->text_framedata + bytes) = '\0';
|
||||
|
||||
*(member->text_framedata + bytes) = '\0';
|
||||
|
||||
/*
|
||||
for(p = member->text_framedata; p && *p; p++) {
|
||||
if (*p > 32 && *p < 127) {
|
||||
@@ -1837,7 +1837,7 @@ switch_status_t conference_text_thread_callback(switch_core_session_t *session,
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_unlock(member->text_mutex);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -2986,7 +2986,7 @@ conference_obj_t *conference_new(char *name, conference_xml_cfg_t cfg, switch_co
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "video-kps-debounce must be 0 or higher\n");
|
||||
}
|
||||
|
||||
|
||||
} else if (!strcasecmp(var, "video-mode") && !zstr(val)) {
|
||||
if (!strcasecmp(val, "passthrough")) {
|
||||
conference_video_mode = CONF_VIDEO_MODE_PASSTHROUGH;
|
||||
@@ -3129,7 +3129,7 @@ conference_obj_t *conference_new(char *name, conference_xml_cfg_t cfg, switch_co
|
||||
if (!video_border_color) {
|
||||
video_border_color = "#000000";
|
||||
}
|
||||
|
||||
|
||||
if (!video_super_canvas_bgcolor) {
|
||||
video_super_canvas_bgcolor = "#068df3";
|
||||
}
|
||||
@@ -3146,7 +3146,7 @@ conference_obj_t *conference_new(char *name, conference_xml_cfg_t cfg, switch_co
|
||||
conference->no_video_avatar = switch_core_strdup(conference->pool, no_video_avatar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
conference->video_canvas_bgcolor = switch_core_strdup(conference->pool, video_canvas_bgcolor);
|
||||
conference->video_border_color = switch_core_strdup(conference->pool, video_border_color);
|
||||
conference->video_super_canvas_bgcolor = switch_core_strdup(conference->pool, video_super_canvas_bgcolor);
|
||||
@@ -3529,7 +3529,7 @@ conference_obj_t *conference_new(char *name, conference_xml_cfg_t cfg, switch_co
|
||||
switch_live_array_set_command_handler(conference->la, conference_event_la_command_handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
end:
|
||||
|
||||
switch_mutex_unlock(conference_globals.hash_mutex);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Rupa Schomaker <rupa@rupa.com>
|
||||
* Yossi Neiman <mishehu@freeswitch.org>
|
||||
* Seven Du <dujinfang@gmail.com>
|
||||
@@ -45,7 +45,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_curl_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_curl, mod_curl_load, mod_curl_shutdown, NULL);
|
||||
@@ -273,14 +273,14 @@ static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data)
|
||||
char *data = NULL;
|
||||
char tmp[32], *f = NULL;
|
||||
switch_curl_slist_t *header = http_data->headers;
|
||||
|
||||
|
||||
if(!top || !headers) {
|
||||
cJSON_Delete(headers);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to alloc memory for cJSON structures.\n");
|
||||
goto curl_json_output_end;
|
||||
}
|
||||
|
||||
|
||||
switch_snprintf(tmp, sizeof(tmp), "%ld", http_data->http_response_code);
|
||||
cJSON_AddItemToObject(top, "status_code", cJSON_CreateString(tmp));
|
||||
if (http_data->http_response) {
|
||||
@@ -334,7 +334,7 @@ static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data)
|
||||
f = cJSON_PrintUnformatted(top);
|
||||
data = switch_core_strdup(pool, f);
|
||||
switch_safe_free(f);
|
||||
|
||||
|
||||
curl_json_output_end:
|
||||
cJSON_Delete(top); /* should free up all children */
|
||||
return data;
|
||||
@@ -344,7 +344,7 @@ static size_t http_sendfile_response_callback(void *ptr, size_t size, size_t nme
|
||||
{
|
||||
register unsigned int realsize = (unsigned int) (size * nmemb);
|
||||
http_sendfile_data_t *http_data = data;
|
||||
|
||||
|
||||
if(http_data->sendfile_response_count + realsize < HTTP_SENDFILE_RESPONSE_SIZE)
|
||||
{
|
||||
// I'm not sure why we need the (realsize+1) here, but it truncates the data by 1 char if I don't do this
|
||||
@@ -356,7 +356,7 @@ static size_t http_sendfile_response_callback(void *ptr, size_t size, size_t nme
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Response page is more than %d bytes long, truncating.\n", HTTP_SENDFILE_RESPONSE_SIZE);
|
||||
realsize = 0;
|
||||
}
|
||||
|
||||
|
||||
return realsize;
|
||||
}
|
||||
|
||||
@@ -365,53 +365,53 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
|
||||
{
|
||||
uint8_t count;
|
||||
http_data->curl_handle = curl_easy_init();
|
||||
|
||||
|
||||
if (!strncasecmp(http_data->url, "https", 5))
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not verifying TLS cert for %s; connection is not secure\n", http_data->url);
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
}
|
||||
|
||||
/* From the docs:
|
||||
* Optionally, you can provide data to POST using the CURLOPT_READFUNCTION and CURLOPT_READDATA
|
||||
|
||||
/* From the docs:
|
||||
* Optionally, you can provide data to POST using the CURLOPT_READFUNCTION and CURLOPT_READDATA
|
||||
* options but then you must make sure to not set CURLOPT_POSTFIELDS to anything but NULL
|
||||
* curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, strlen(data));
|
||||
* curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, (void *) data);
|
||||
*/
|
||||
|
||||
|
||||
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Post data: %s\n", data);
|
||||
|
||||
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_MAXREDIRS, 15);
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_URL, http_data->url);
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_NOSIGNAL, 1);
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_USERAGENT, "freeswitch-curl/1.0");
|
||||
|
||||
|
||||
http_data->sendfile_response = switch_core_alloc(http_data->pool, sizeof(char) * HTTP_SENDFILE_RESPONSE_SIZE);
|
||||
memset(http_data->sendfile_response, 0, sizeof(char) * HTTP_SENDFILE_RESPONSE_SIZE);
|
||||
|
||||
|
||||
// Set the function where we will copy out the response body data to
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEFUNCTION, http_sendfile_response_callback);
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEDATA, (void *) http_data);
|
||||
|
||||
/* Add the file to upload as a POST form field */
|
||||
|
||||
/* Add the file to upload as a POST form field */
|
||||
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, http_data->filename_element_name, CURLFORM_FILE, http_data->filename_element, CURLFORM_END);
|
||||
|
||||
|
||||
if(!zstr(http_data->extrapost_elements))
|
||||
{
|
||||
// Now to parse out the individual post element/value pairs
|
||||
char *argv[64] = { 0 }; // Probably don't need 64 but eh does it really use that much memory?
|
||||
uint32_t argc = 0;
|
||||
char *temp_extrapost = switch_core_strdup(http_data->pool, http_data->extrapost_elements);
|
||||
|
||||
|
||||
argc = switch_separate_string(temp_extrapost, '&', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
|
||||
|
||||
for(count = 0; count < argc; count++)
|
||||
{
|
||||
char *argv2[4] = { 0 };
|
||||
uint32_t argc2 = switch_separate_string(argv[count], '=', argv2, (sizeof(argv2) / sizeof(argv2[0])));
|
||||
|
||||
|
||||
if(argc2 == 2) {
|
||||
switch_url_decode(argv2[0]);
|
||||
switch_url_decode(argv2[1]);
|
||||
@@ -419,19 +419,19 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fill in the submit field too, even if this isn't really needed */
|
||||
|
||||
/* Fill in the submit field too, even if this isn't really needed */
|
||||
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "or_die", CURLFORM_END);
|
||||
|
||||
/* what URL that receives this POST */
|
||||
|
||||
/* what URL that receives this POST */
|
||||
curl_easy_setopt(http_data->curl_handle, CURLOPT_HTTPPOST, http_data->formpost);
|
||||
|
||||
|
||||
// This part actually fires off the curl, captures the HTTP response code, and then frees up the handle.
|
||||
curl_easy_perform(http_data->curl_handle);
|
||||
curl_easy_getinfo(http_data->curl_handle, CURLINFO_RESPONSE_CODE, &http_data->http_response_code);
|
||||
|
||||
|
||||
curl_easy_cleanup(http_data->curl_handle);
|
||||
|
||||
|
||||
// Clean up the form data from POST
|
||||
curl_formfree(http_data->formpost);
|
||||
}
|
||||
@@ -454,14 +454,14 @@ static switch_status_t http_sendfile_test_file_open(http_sendfile_data_t *http_d
|
||||
else
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create event to notify of failure to open file %s\n", http_data->filename_element);
|
||||
}
|
||||
|
||||
|
||||
if((switch_test_flag(http_data, CSO_STREAM) || switch_test_flag(http_data, CSO_NONE)) && http_data->stream)
|
||||
http_data->stream->write_function(http_data->stream, "-Err Unable to open file %s\n", http_data->filename_element);
|
||||
|
||||
|
||||
if(switch_test_flag(http_data, CSO_NONE) && !http_data->stream)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "curl_sendfile: Unable to open file %s\n", http_data->filename_element);
|
||||
}
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -474,31 +474,31 @@ static void http_sendfile_success_report(http_sendfile_data_t *http_data, switch
|
||||
char *code_as_string = switch_core_alloc(http_data->pool, 16);
|
||||
memset(code_as_string, 0, 16);
|
||||
switch_snprintf(code_as_string, 16, "%d", http_data->http_response_code);
|
||||
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Command-Execution-Identifier", http_data->identifier_str);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Filename", http_data->filename_element);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File-Access", "Success");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "REST-HTTP-Code", code_as_string);
|
||||
switch_event_add_body(event, "%s", http_data->sendfile_response);
|
||||
|
||||
|
||||
switch_event_fire(&event);
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
else
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create a event to report on success of curl_sendfile.\n");
|
||||
}
|
||||
|
||||
|
||||
if((switch_test_flag(http_data, CSO_STREAM) || switch_test_flag(http_data, CSO_NONE) || switch_test_flag(http_data, CSO_EVENT)) && http_data->stream)
|
||||
{
|
||||
if(http_data->http_response_code == 200)
|
||||
http_data->stream->write_function(http_data->stream, "+200 Ok\n");
|
||||
else
|
||||
http_data->stream->write_function(http_data->stream, "-%d Err\n", http_data->http_response_code);
|
||||
|
||||
|
||||
if(http_data->sendfile_response_count && switch_test_flag(http_data, CSO_STREAM))
|
||||
http_data->stream->write_function(http_data->stream, "%s\n", http_data->sendfile_response);
|
||||
}
|
||||
|
||||
|
||||
if(switch_test_flag(http_data, CSO_NONE) && !http_data->stream)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Sending of file %s to url %s resulted with code %lu\n", http_data->filename_element, http_data->url, http_data->http_response_code);
|
||||
}
|
||||
@@ -512,31 +512,31 @@ SWITCH_STANDARD_APP(http_sendfile_app_function)
|
||||
http_sendfile_data_t *http_data = NULL;
|
||||
switch_memory_pool_t *pool = switch_core_session_get_pool(session);
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
|
||||
assert(channel != NULL);
|
||||
|
||||
|
||||
http_data = switch_core_alloc(pool, sizeof(http_sendfile_data_t));
|
||||
memset(http_data, 0, sizeof(http_sendfile_data_t));
|
||||
|
||||
|
||||
http_data->pool = pool;
|
||||
|
||||
|
||||
// Either the parameters are provided on the data="" or else they are provided as chanvars. No mixing & matching
|
||||
if(!zstr(data))
|
||||
{
|
||||
http_data->mydata = switch_core_strdup(http_data->pool, data);
|
||||
|
||||
if ((argc = switch_separate_string(http_data->mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))))
|
||||
|
||||
if ((argc = switch_separate_string(http_data->mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))))
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
|
||||
if (argc < 2 || argc > 5)
|
||||
goto http_sendfile_app_usage;
|
||||
|
||||
|
||||
http_data->url = switch_core_strdup(http_data->pool, argv[i++]);
|
||||
|
||||
|
||||
switch_url_decode(argv[i]);
|
||||
argc2 = switch_separate_string(argv[i++], '=', argv2, (sizeof(argv2) / sizeof(argv2[0])));
|
||||
|
||||
|
||||
if(argc2 == 2)
|
||||
{
|
||||
http_data->filename_element_name = switch_core_strdup(pool, argv2[0]);
|
||||
@@ -544,11 +544,11 @@ SWITCH_STANDARD_APP(http_sendfile_app_function)
|
||||
}
|
||||
else
|
||||
goto http_sendfile_app_usage;
|
||||
|
||||
|
||||
if(argc > 2)
|
||||
{
|
||||
http_data->extrapost_elements = switch_core_strdup(pool, argv[i++]);
|
||||
|
||||
|
||||
if(argc > 3)
|
||||
{
|
||||
if(!strncasecmp(argv[i++], "event", 5))
|
||||
@@ -556,7 +556,7 @@ SWITCH_STANDARD_APP(http_sendfile_app_function)
|
||||
switch_set_flag(http_data, CSO_EVENT);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting output to event handler.\n");
|
||||
}
|
||||
|
||||
|
||||
if(argc > 4)
|
||||
{
|
||||
if(strncasecmp(argv[i], "uuid", 4))
|
||||
@@ -572,16 +572,16 @@ SWITCH_STANDARD_APP(http_sendfile_app_function)
|
||||
{
|
||||
char *send_output = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_report", SWITCH_TRUE, -1);
|
||||
char *identifier = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_identifier", SWITCH_TRUE, -1);
|
||||
|
||||
|
||||
http_data->url = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_url", SWITCH_TRUE, -1);
|
||||
http_data->filename_element_name = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_filename_element", SWITCH_TRUE, -1);
|
||||
http_data->filename_element = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_filename", SWITCH_TRUE, -1);
|
||||
http_data->extrapost_elements = (char *) switch_channel_get_variable_dup(channel, "curl_sendfile_extrapost", SWITCH_TRUE, -1);
|
||||
|
||||
|
||||
|
||||
|
||||
if(zstr(http_data->url) || zstr(http_data->filename_element) || zstr(http_data->filename_element_name))
|
||||
goto http_sendfile_app_usage;
|
||||
|
||||
|
||||
if(!zstr(send_output))
|
||||
{
|
||||
if(!strncasecmp(send_output, "event", 5))
|
||||
@@ -599,7 +599,7 @@ SWITCH_STANDARD_APP(http_sendfile_app_function)
|
||||
switch_set_flag(http_data, CSO_NONE);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No parameter specified for curl_sendfile_report. Setting default of 'none'.\n");
|
||||
}
|
||||
|
||||
|
||||
if(!zstr(identifier))
|
||||
{
|
||||
if(!strncasecmp(identifier, "uuid", 4))
|
||||
@@ -608,33 +608,33 @@ SWITCH_STANDARD_APP(http_sendfile_app_function)
|
||||
http_data->identifier_str = identifier;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_url_decode(http_data->filename_element_name);
|
||||
switch_url_decode(http_data->filename_element);
|
||||
|
||||
|
||||
// We need to check the file now...
|
||||
if(http_sendfile_test_file_open(http_data, event) != SWITCH_STATUS_SUCCESS)
|
||||
goto http_sendfile_app_done;
|
||||
|
||||
|
||||
switch_file_close(http_data->file_handle);
|
||||
|
||||
|
||||
switch_url_decode(http_data->url);
|
||||
|
||||
|
||||
http_sendfile_initialize_curl(http_data);
|
||||
|
||||
|
||||
http_sendfile_success_report(http_data, event);
|
||||
|
||||
|
||||
goto http_sendfile_app_done;
|
||||
|
||||
|
||||
http_sendfile_app_usage:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure: Usage: <data=\"%s\">\nOr you can set chanvars curl_senfile_url, curl_sendfile_filename_element, curl_sendfile_filename, curl_sendfile_extrapost\n", HTTP_SENDFILE_APP_SYNTAX);
|
||||
|
||||
|
||||
http_sendfile_app_done:
|
||||
if (http_data->headers)
|
||||
{
|
||||
switch_curl_slist_free_all(http_data->headers);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -648,7 +648,7 @@ SWITCH_STANDARD_API(http_sendfile_function)
|
||||
http_sendfile_data_t *http_data = NULL;
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
switch_event_t *event = NULL;
|
||||
|
||||
|
||||
if(zstr(cmd))
|
||||
{
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
@@ -664,31 +664,31 @@ SWITCH_STANDARD_API(http_sendfile_function)
|
||||
switch_core_new_memory_pool(&pool);
|
||||
new_memory_pool = SWITCH_TRUE; // So we can properly destroy the memory pool
|
||||
}
|
||||
|
||||
|
||||
http_data = switch_core_alloc(pool, sizeof(http_sendfile_data_t));
|
||||
memset(http_data, 0, sizeof(http_sendfile_data_t));
|
||||
|
||||
|
||||
http_data->mydata = switch_core_strdup(pool, cmd);
|
||||
http_data->stream = stream;
|
||||
http_data->pool = pool;
|
||||
|
||||
// stream->write_function(stream,"\ncmd is %s\nmydata is %s\n", cmd, http_data->mydata);
|
||||
|
||||
if ((argc = switch_separate_string(http_data->mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))))
|
||||
|
||||
// stream->write_function(stream,"\ncmd is %s\nmydata is %s\n", cmd, http_data->mydata);
|
||||
|
||||
if ((argc = switch_separate_string(http_data->mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))))
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
|
||||
if (argc < 2 || argc > 5)
|
||||
{
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
goto http_sendfile_usage;
|
||||
}
|
||||
|
||||
|
||||
http_data->url = switch_core_strdup(pool, argv[i++]);
|
||||
|
||||
|
||||
switch_url_decode(argv[i]);
|
||||
argc2 = switch_separate_string(argv[i++], '=', argv2, (sizeof(argv2) / sizeof(argv2[0])));
|
||||
|
||||
|
||||
if(argc2 == 2)
|
||||
{
|
||||
http_data->filename_element_name = switch_core_strdup(pool, argv2[0]);
|
||||
@@ -696,14 +696,14 @@ SWITCH_STANDARD_API(http_sendfile_function)
|
||||
}
|
||||
else
|
||||
goto http_sendfile_usage;
|
||||
|
||||
|
||||
switch_url_decode(http_data->filename_element_name);
|
||||
switch_url_decode(http_data->filename_element);
|
||||
|
||||
|
||||
if(argc > 2)
|
||||
{
|
||||
http_data->extrapost_elements = switch_core_strdup(pool, argv[i++]);
|
||||
|
||||
|
||||
if(argc > 3)
|
||||
{
|
||||
if(!strncasecmp(argv[i], "event", 5))
|
||||
@@ -719,31 +719,31 @@ SWITCH_STANDARD_API(http_sendfile_function)
|
||||
{
|
||||
if(strncasecmp(argv[i], "none", 4))
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Invalid 4th parameter set for curl_sendfile. Defaulting to \"none\"\n");
|
||||
|
||||
|
||||
switch_set_flag(http_data, CSO_NONE);
|
||||
}
|
||||
|
||||
|
||||
i++;
|
||||
|
||||
|
||||
if(argc > 4)
|
||||
http_data->identifier_str = switch_core_strdup(pool, argv[i++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// We need to check the file now...
|
||||
if(http_sendfile_test_file_open(http_data, event) != SWITCH_STATUS_SUCCESS)
|
||||
goto http_sendfile_done;
|
||||
|
||||
|
||||
|
||||
|
||||
switch_file_close(http_data->file_handle);
|
||||
|
||||
|
||||
switch_url_decode(http_data->url);
|
||||
|
||||
|
||||
http_sendfile_initialize_curl(http_data);
|
||||
|
||||
|
||||
http_sendfile_success_report(http_data, event);
|
||||
|
||||
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
goto http_sendfile_done;
|
||||
|
||||
@@ -756,12 +756,12 @@ http_sendfile_done:
|
||||
{
|
||||
switch_curl_slist_free_all(http_data->headers);
|
||||
}
|
||||
|
||||
|
||||
if (new_memory_pool == SWITCH_TRUE)
|
||||
{
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load)
|
||||
SWITCH_ADD_API(api_interface, "curl", "curl API", curl_function, SYNTAX);
|
||||
SWITCH_ADD_APP(app_interface, "curl", "Perform a http request", "Perform a http request",
|
||||
curl_app_function, SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
|
||||
|
||||
SWITCH_ADD_API(api_interface, "curl_sendfile", "curl_sendfile API", http_sendfile_function, HTTP_SENDFILE_SYNTAX);
|
||||
SWITCH_ADD_APP(app_interface, "curl_sendfile", "Send a file and some optional post variables via HTTP", "Send a file and some optional post variables via HTTP",
|
||||
http_sendfile_app_function, HTTP_SENDFILE_APP_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
@@ -1045,7 +1045,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown)
|
||||
{
|
||||
|
||||
switch_event_free_subclass(HTTP_SENDFILE_ACK_EVENT);
|
||||
|
||||
|
||||
/* Cleanup dynamically allocated config settings */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -728,11 +728,11 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
|
||||
|
||||
switch_img_to_raw(frame->img, context->rawImage->imageData, context->rawImage->widthStep, SWITCH_IMG_FMT_RGB24);
|
||||
detectAndDraw(context);
|
||||
|
||||
|
||||
if (context->shape_idx && context->shape[0].w && context->last_shape[0].w) {
|
||||
int max, min;
|
||||
int pct;
|
||||
|
||||
|
||||
if (context->shape[0].w > context->last_shape[0].w) {
|
||||
max = context->shape[0].w;
|
||||
min = context->last_shape[0].w;
|
||||
@@ -742,7 +742,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
|
||||
}
|
||||
|
||||
pct = 100 - (((double)min / (double)max) * 100.0f );
|
||||
|
||||
|
||||
if (pct > 25) {
|
||||
context->detected.simo_count = 0;
|
||||
memset(context->last_shape, 0, sizeof(context->last_shape[0]) * MAX_SHAPES);
|
||||
@@ -1331,7 +1331,7 @@ SWITCH_STANDARD_API(cv_bug_api_function)
|
||||
flags = SMBF_VIDEO_PATCH;
|
||||
}
|
||||
|
||||
if ((status = switch_core_media_bug_add(rsession, function, NULL,
|
||||
if ((status = switch_core_media_bug_add(rsession, function, NULL,
|
||||
cv_bug_callback, context, 0, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "-ERR Failure!\n");
|
||||
switch_thread_rwlock_unlock(MODULE_INTERFACE->rwlock);
|
||||
@@ -1367,7 +1367,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cv_load)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_VIDEO_DETECT);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
MODULE_INTERFACE = *module_interface;
|
||||
@@ -1390,7 +1390,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cv_shutdown)
|
||||
{
|
||||
|
||||
switch_event_free_subclass(MY_EVENT_VIDEO_DETECT);
|
||||
|
||||
|
||||
return SWITCH_STATUS_UNLOAD;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Ken Rice <krice@freeswitch.org>
|
||||
* Mathieu Rene <mathieu.rene@gmail.com>
|
||||
@@ -89,7 +89,7 @@ switch_cache_db_handle_t *limit_get_db_handle(void)
|
||||
{
|
||||
switch_cache_db_handle_t *dbh = NULL;
|
||||
char *dsn;
|
||||
|
||||
|
||||
if (!zstr(globals.odbc_dsn)) {
|
||||
dsn = globals.odbc_dsn;
|
||||
} else {
|
||||
@@ -99,7 +99,7 @@ switch_cache_db_handle_t *limit_get_db_handle(void)
|
||||
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
|
||||
dbh = NULL;
|
||||
}
|
||||
|
||||
|
||||
return dbh;
|
||||
|
||||
}
|
||||
@@ -158,7 +158,7 @@ static char * limit_execute_sql2str(char *sql, char *str, size_t len)
|
||||
cbt.len = len;
|
||||
|
||||
limit_execute_sql_callback(sql, sql2str_callback, &cbt);
|
||||
|
||||
|
||||
return cbt.buf;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ SWITCH_LIMIT_RELEASE(limit_release_db)
|
||||
}
|
||||
limit_execute_sql(sql);
|
||||
switch_safe_free(sql);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -238,12 +238,12 @@ SWITCH_LIMIT_USAGE(limit_usage_db)
|
||||
char usagestr[128] = "";
|
||||
int usage = 0;
|
||||
char *sql = NULL;
|
||||
|
||||
|
||||
sql = switch_mprintf("select count(hostname) from limit_data where realm='%q' and id='%q'", realm, resource);
|
||||
limit_execute_sql2str(sql, usagestr, sizeof(usagestr));
|
||||
switch_safe_free(sql);
|
||||
usage = atoi(usagestr);
|
||||
|
||||
|
||||
return usage;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ SWITCH_LIMIT_RESET(limit_reset_db)
|
||||
sql = switch_mprintf("delete from limit_data where hostname='%q';", globals.hostname);
|
||||
limit_execute_sql(sql);
|
||||
switch_safe_free(sql);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ SWITCH_LIMIT_STATUS(limit_status_db)
|
||||
char count[128] = "";
|
||||
char *ret = NULL;
|
||||
char *sql = NULL;
|
||||
|
||||
|
||||
sql = switch_mprintf("select count(hostname) from limit_data where hostname='%q'", globals.hostname);
|
||||
limit_execute_sql2str(sql, count, sizeof(count));
|
||||
switch_safe_free(sql);
|
||||
@@ -686,7 +686,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_db_load)
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Marc Olivier Chouinard <mochouinard at moctel dot com>
|
||||
* Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
|
||||
*
|
||||
@@ -194,7 +194,7 @@ switch_cache_db_handle_t *directory_get_db_handle(void)
|
||||
{
|
||||
switch_cache_db_handle_t *dbh = NULL;
|
||||
char *dsn;
|
||||
|
||||
|
||||
if (!zstr(globals.odbc_dsn)) {
|
||||
dsn = globals.odbc_dsn;
|
||||
} else {
|
||||
@@ -204,7 +204,7 @@ switch_cache_db_handle_t *directory_get_db_handle(void)
|
||||
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
|
||||
dbh = NULL;
|
||||
}
|
||||
|
||||
|
||||
return dbh;
|
||||
|
||||
}
|
||||
@@ -661,7 +661,7 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro
|
||||
sql = generate_sql_entry_for_user(session, ux, profile->use_number_alias);
|
||||
switch_xml_free(ux);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
sql = generate_sql_entry_for_user(session, ut, profile->use_number_alias);
|
||||
}
|
||||
@@ -677,7 +677,7 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro
|
||||
sql = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (++count >= 100) {
|
||||
count = 0;
|
||||
sql = switch_mprintf("BEGIN;%s;COMMIT;", sqlvalues);
|
||||
@@ -1018,7 +1018,7 @@ SWITCH_STANDARD_APP(directory_function)
|
||||
switch_copy_string(s_param.profile, profile_name, 255);
|
||||
switch_copy_string(s_param.domain, domain_name, 255);
|
||||
|
||||
if (!(search_by = switch_channel_get_variable(channel, "directory_search_order"))) {
|
||||
if (!(search_by = switch_channel_get_variable(channel, "directory_search_order"))) {
|
||||
search_by = profile->search_order;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<include>
|
||||
<include>
|
||||
<extension name="test gateway distro">
|
||||
<condition field="destination_number" expression="^(.*)$">
|
||||
<action application="bridge" data="sofia/gateway/${distributor(test)}/$1"/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Neal Horman <neal at wanlink dot com>
|
||||
*
|
||||
@@ -37,7 +37,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_distributor_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_distributor_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_distributor_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_distributor, mod_distributor_load, mod_distributor_shutdown, NULL);
|
||||
@@ -173,7 +173,7 @@ static int load_config(int reloading)
|
||||
switch_zmalloc(node, sizeof(*node));
|
||||
node->name = strdup(name_attr);
|
||||
node->wval = tmp;
|
||||
|
||||
|
||||
if (np) {
|
||||
np->next = node;
|
||||
} else {
|
||||
@@ -228,7 +228,7 @@ static struct dist_node *find_next(struct dist_list *list, int etotal, char **ex
|
||||
|
||||
for (;;) {
|
||||
top:
|
||||
|
||||
|
||||
if (++loops > 1000) {
|
||||
break;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ static struct dist_node *find_next(struct dist_list *list, int etotal, char **ex
|
||||
|
||||
if (match) {
|
||||
int i;
|
||||
|
||||
|
||||
match->cur_weight++;
|
||||
list->lastnode = match;
|
||||
list->last = mx;
|
||||
@@ -266,7 +266,7 @@ static struct dist_node *find_next(struct dist_list *list, int etotal, char **ex
|
||||
goto top;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Choose %s\n", match->name);
|
||||
return match;
|
||||
@@ -279,7 +279,7 @@ static struct dist_node *find_next(struct dist_list *list, int etotal, char **ex
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ static char *dist_engine(const char *name)
|
||||
int argc = 0;
|
||||
char *argv[100] = { 0 };
|
||||
|
||||
|
||||
|
||||
if ((except = strchr(myname, ' '))) {
|
||||
*except++ = '\0';
|
||||
argc = switch_split(except, ' ', argv);
|
||||
@@ -443,7 +443,7 @@ SWITCH_STANDARD_API(distributor_ctl_function)
|
||||
*e++ = '\0';
|
||||
if ((np = find_node(list, argv[i]))) {
|
||||
int tmp = -1;
|
||||
|
||||
|
||||
if (e) {
|
||||
tmp = atoi(e);
|
||||
}
|
||||
@@ -476,7 +476,7 @@ SWITCH_STANDARD_API(distributor_ctl_function)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
err:
|
||||
|
||||
if (err) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Ken Rice <krice@freeswitch.org>
|
||||
* Michael Murdock <mike at mmurdock dot org>
|
||||
@@ -129,7 +129,7 @@ static switch_status_t digit_nomatch_action_callback(switch_ivr_dmachine_match_t
|
||||
|
||||
switch_channel_set_variable(channel, "last_non_matching_digits", match->match_digits);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_DEBUG, "%s Digit NOT match binding [%s]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_DEBUG, "%s Digit NOT match binding [%s]\n",
|
||||
switch_channel_get_name(channel), match->match_digits);
|
||||
|
||||
if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -137,14 +137,14 @@ static switch_status_t digit_nomatch_action_callback(switch_ivr_dmachine_match_t
|
||||
|
||||
if ((status = switch_core_session_queue_event(use_session, &event)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_destroy(&event);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
|
||||
switch_core_session_get_name(use_session));
|
||||
}
|
||||
}
|
||||
|
||||
/* send it back around and skip the dmachine */
|
||||
switch_channel_queue_dtmf_string(channel, match->match_digits);
|
||||
|
||||
|
||||
if (use_session != session) {
|
||||
switch_core_session_rwunlock(use_session);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
int x = 0;
|
||||
char *flags = "";
|
||||
|
||||
if (act->target == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_BOTH) {
|
||||
if (act->target == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_BOTH) {
|
||||
if (switch_core_session_get_partner(act->session, &use_session) != SWITCH_STATUS_SUCCESS) {
|
||||
use_session = act->session;
|
||||
}
|
||||
@@ -183,14 +183,14 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
|
||||
switch_channel_set_variable(channel, "last_matching_digits", match->match_digits);
|
||||
|
||||
|
||||
|
||||
if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s]\n",
|
||||
switch_channel_get_name(channel), act->string, act->value);
|
||||
|
||||
if (!strncasecmp(string, "exec", 4)) {
|
||||
char *e;
|
||||
|
||||
|
||||
string += 4;
|
||||
if (*string == ':') {
|
||||
string++;
|
||||
@@ -220,7 +220,7 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
|
||||
if ((status = switch_core_session_queue_event(use_session, &event)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_destroy(&event);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n",
|
||||
switch_core_session_get_name(use_session));
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
switch_api_execute(string, act->value, NULL, &stream);
|
||||
if (stream.data) {
|
||||
switch_channel_set_variable(channel, "bind_digit_action_api_result", (char *)stream.data);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s] api executed, %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s] api executed, %s\n",
|
||||
switch_core_session_get_name(use_session), act->string, act->value, (char *)stream.data);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s] api executed\n",
|
||||
@@ -252,7 +252,7 @@ static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
}
|
||||
switch_safe_free(stream.data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (use_session != act->session) {
|
||||
switch_core_session_rwunlock(use_session);
|
||||
@@ -275,7 +275,7 @@ static switch_digit_action_target_t str2target(const char *target_str)
|
||||
if (!strcasecmp(target_str, "both")) {
|
||||
return DIGIT_TARGET_BOTH;
|
||||
}
|
||||
|
||||
|
||||
return DIGIT_TARGET_SELF;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ SWITCH_STANDARD_APP(digit_action_set_realm_function)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((dmachine = switch_core_session_get_dmachine(session, target))) {
|
||||
switch_ivr_dmachine_set_realm(dmachine, realm);
|
||||
}
|
||||
@@ -349,7 +349,7 @@ SWITCH_STANDARD_APP(digit_action_set_realm_function)
|
||||
}
|
||||
|
||||
|
||||
static void bind_to_session(switch_core_session_t *session,
|
||||
static void bind_to_session(switch_core_session_t *session,
|
||||
const char *arg0, const char *arg1, const char *arg2, const char *arg3,
|
||||
switch_digit_action_target_t target, switch_digit_action_target_t bind_target)
|
||||
{
|
||||
@@ -367,16 +367,16 @@ static void bind_to_session(switch_core_session_t *session,
|
||||
if ((var = switch_channel_get_variable(channel, "bind_digit_digit_timeout"))) {
|
||||
digit_timeout = switch_atoul(var);
|
||||
}
|
||||
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "bind_digit_input_timeout"))) {
|
||||
input_timeout = switch_atoul(var);
|
||||
}
|
||||
|
||||
|
||||
switch_ivr_dmachine_create(&dmachine, "DPTOOLS", NULL, digit_timeout, input_timeout, NULL, digit_nomatch_action_callback, session);
|
||||
switch_core_session_set_dmachine(session, dmachine, target);
|
||||
}
|
||||
|
||||
|
||||
|
||||
act = switch_core_session_alloc(session, sizeof(*act));
|
||||
act->realm = switch_core_session_strdup(session, arg0);
|
||||
act->input = switch_core_session_strdup(session, arg1);
|
||||
@@ -404,7 +404,7 @@ static void bind_to_session(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
switch_ivr_dmachine_bind(dmachine, act->realm, act->input, is_priority, 0, digit_action_callback, act);
|
||||
|
||||
|
||||
if ((terminators = switch_channel_get_variable(channel, "bda_terminators"))) {
|
||||
switch_ivr_dmachine_set_terminators(dmachine, terminators);
|
||||
}
|
||||
@@ -617,7 +617,7 @@ SWITCH_STANDARD_APP(keepalive_function)
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_KEEPALIVE;
|
||||
msg.numeric_arg = seconds;
|
||||
switch_core_session_receive_message(session, &msg);
|
||||
|
||||
|
||||
switch_core_session_enable_heartbeat(session, seconds);
|
||||
return;
|
||||
}
|
||||
@@ -660,7 +660,7 @@ SWITCH_STANDARD_APP(rename_function)
|
||||
switch_file_rename(argv[0], argv[1], switch_core_session_get_pool(session));
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s RENAME: %s %s\n",
|
||||
switch_channel_get_name(switch_core_session_get_channel(session)), argv[0], argv[1]);
|
||||
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", RENAME_SYNTAX);
|
||||
}
|
||||
@@ -672,7 +672,7 @@ SWITCH_STANDARD_APP(transfer_vars_function)
|
||||
char *argv[1] = { 0 };
|
||||
int argc;
|
||||
char *lbuf = NULL;
|
||||
|
||||
|
||||
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
|
||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
|
||||
switch_core_session_t *nsession = NULL;
|
||||
@@ -922,7 +922,7 @@ SWITCH_STANDARD_APP(eavesdrop_function)
|
||||
switch_safe_free(e_data.uuid_list[x]);
|
||||
}
|
||||
e_data.total = 0;
|
||||
|
||||
|
||||
if (switch_core_db_handle(&db) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Database Error!\n");
|
||||
break;
|
||||
@@ -1056,7 +1056,7 @@ SWITCH_STANDARD_APP(ring_ready_function)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_channel_ring_ready(switch_core_session_get_channel(session));
|
||||
}
|
||||
|
||||
@@ -1182,7 +1182,7 @@ SWITCH_STANDARD_APP(sched_transfer_function)
|
||||
|
||||
id = switch_ivr_schedule_transfer(when, switch_core_session_get_uuid(session), argv[1], argv[2], argv[3]);
|
||||
snprintf(ids, sizeof(ids), "%u", id);
|
||||
switch_channel_set_variable(switch_core_session_get_channel(session), "last_sched_id", ids);
|
||||
switch_channel_set_variable(switch_core_session_get_channel(session), "last_sched_id", ids);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Args\n");
|
||||
}
|
||||
@@ -1377,7 +1377,7 @@ SWITCH_STANDARD_APP(pre_answer_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *arg = (char *) data;
|
||||
|
||||
|
||||
if (!zstr(arg)) {
|
||||
if (switch_stristr("is_conference", arg)) {
|
||||
switch_channel_set_flag(channel, CF_CONFERENCE);
|
||||
@@ -1559,9 +1559,9 @@ static void base_set (switch_core_session_t *session, const char *data, switch_s
|
||||
expanded = switch_channel_expand_variables(channel, val);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s [%s]=[%s]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s [%s]=[%s]\n",
|
||||
what, switch_channel_get_name(channel), var, expanded ? expanded : "UNDEF");
|
||||
|
||||
|
||||
switch_channel_add_variable_var_check(channel, var, expanded, SWITCH_FALSE, stack);
|
||||
|
||||
if (expanded && expanded != val) {
|
||||
@@ -1586,11 +1586,11 @@ SWITCH_STANDARD_APP(multiset_function)
|
||||
|
||||
arg = switch_core_session_strdup(session, arg);
|
||||
argc = switch_split(arg, delim, array);
|
||||
|
||||
|
||||
for(i = 0; i < argc; i++) {
|
||||
base_set(session, array[i], SWITCH_STACK_BOTTOM);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
base_set(session, data, SWITCH_STACK_BOTTOM);
|
||||
@@ -1933,7 +1933,7 @@ SWITCH_STANDARD_API(strftime_api_function)
|
||||
|
||||
if (!zstr(q) && (p = strchr(q, '|'))) {
|
||||
*p++ = '\0';
|
||||
|
||||
|
||||
thetime = switch_time_make(atol(q), 0);
|
||||
q = p + 1;
|
||||
} else {
|
||||
@@ -2226,7 +2226,7 @@ SWITCH_STANDARD_APP(park_state_function)
|
||||
/********************************************************************************/
|
||||
|
||||
/*
|
||||
dtmf handler function you can hook up to be executed when a digit is dialed during playback
|
||||
dtmf handler function you can hook up to be executed when a digit is dialed during playback
|
||||
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
|
||||
*/
|
||||
static switch_status_t bridge_on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
@@ -2451,7 +2451,7 @@ static switch_status_t tmp_hanguphook(switch_core_session_t *session)
|
||||
|
||||
if (!zstr(bond)) {
|
||||
switch_core_session_t *b_session;
|
||||
|
||||
|
||||
if ((b_session = switch_core_session_locate(bond))) {
|
||||
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
|
||||
if (switch_channel_up(b_channel)) {
|
||||
@@ -2710,7 +2710,7 @@ SWITCH_STANDARD_APP(read_function)
|
||||
valid_terminators = "#";
|
||||
}
|
||||
|
||||
switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name, digit_buffer, sizeof(digit_buffer), timeout, valid_terminators,
|
||||
switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name, digit_buffer, sizeof(digit_buffer), timeout, valid_terminators,
|
||||
digit_timeout);
|
||||
}
|
||||
|
||||
@@ -2799,7 +2799,7 @@ SWITCH_STANDARD_APP(play_and_get_digits_function)
|
||||
}
|
||||
|
||||
switch_play_and_get_digits(session, min_digits, max_digits, max_tries, timeout, valid_terminators,
|
||||
prompt_audio_file, bad_input_audio_file, var_name, digit_buffer, sizeof(digit_buffer),
|
||||
prompt_audio_file, bad_input_audio_file, var_name, digit_buffer, sizeof(digit_buffer),
|
||||
digits_regex, digit_timeout, transfer_on_failure);
|
||||
}
|
||||
|
||||
@@ -3066,7 +3066,7 @@ SWITCH_STANDARD_APP(capture_function)
|
||||
int ovector[30] = {0};
|
||||
char *lbuf;
|
||||
int proceed;
|
||||
|
||||
|
||||
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
|
||||
&& (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 3) {
|
||||
if ((proceed = switch_regex_perform(argv[1], argv[2], &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
|
||||
@@ -3075,7 +3075,7 @@ SWITCH_STANDARD_APP(capture_function)
|
||||
switch_regex_safe_free(re);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No data specified.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(record_function)
|
||||
@@ -3164,7 +3164,7 @@ SWITCH_STANDARD_APP(record_session_function)
|
||||
|
||||
path = switch_core_session_strdup(session, data);
|
||||
|
||||
/* Search for a space then a plus followed by only numbers at the end of the path,
|
||||
/* Search for a space then a plus followed by only numbers at the end of the path,
|
||||
if found trim any spaces to the left/right of the plus use the left side as the
|
||||
path and right side as a time limit on the recording
|
||||
*/
|
||||
@@ -3385,7 +3385,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
|
||||
moh = switch_channel_get_hold_music(caller_channel);
|
||||
}
|
||||
|
||||
if (!zstr(moh) && !strcasecmp(moh, "silence")) {
|
||||
if (!zstr(moh) && !strcasecmp(moh, "silence")) {
|
||||
moh = NULL;
|
||||
}
|
||||
|
||||
@@ -3427,7 +3427,7 @@ SWITCH_STANDARD_APP(audio_bridge_function)
|
||||
|
||||
if (fail) {
|
||||
int64_t wait = (int64_t)campon_sleep * 1000000;
|
||||
|
||||
|
||||
while (stake.running && wait > 0 && switch_channel_ready(caller_channel)) {
|
||||
switch_yield(100000);
|
||||
wait -= 100000;
|
||||
@@ -3436,8 +3436,8 @@ SWITCH_STANDARD_APP(audio_bridge_function)
|
||||
}
|
||||
}
|
||||
|
||||
status = switch_ivr_originate(NULL, &peer_session,
|
||||
&cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE,
|
||||
status = switch_ivr_originate(NULL, &peer_session,
|
||||
&cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE,
|
||||
switch_channel_get_cause_ptr(caller_channel));
|
||||
|
||||
|
||||
@@ -3564,19 +3564,19 @@ static void pickup_send_presence(const char *key_name)
|
||||
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_domain(SWITCH_TRUE);
|
||||
domain_name = dup_domain_name;
|
||||
}
|
||||
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
domain_name = "cluecon.com";
|
||||
}
|
||||
@@ -3591,7 +3591,7 @@ static void pickup_send_presence(const char *key_name)
|
||||
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");
|
||||
@@ -3609,7 +3609,7 @@ static void pickup_send_presence(const char *key_name)
|
||||
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");
|
||||
@@ -3620,13 +3620,13 @@ static void pickup_send_presence(const char *key_name)
|
||||
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)
|
||||
@@ -3667,7 +3667,7 @@ static void pickup_pres_event_handler(switch_event_t *event)
|
||||
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");
|
||||
@@ -3681,7 +3681,7 @@ static void pickup_pres_event_handler(switch_event_t *event)
|
||||
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");
|
||||
@@ -3751,7 +3751,7 @@ static char *pickup_pop_uuid(const char *key, const char *uuid)
|
||||
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;
|
||||
|
||||
@@ -3762,14 +3762,14 @@ static char *pickup_pop_uuid(const char *key, const char *uuid)
|
||||
} else {
|
||||
head = np->next;
|
||||
}
|
||||
|
||||
|
||||
node = np;
|
||||
break;
|
||||
}
|
||||
|
||||
lp = np;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
node = head;
|
||||
head = head->next;
|
||||
@@ -3786,13 +3786,13 @@ static char *pickup_pop_uuid(const char *key, const char *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;
|
||||
}
|
||||
|
||||
@@ -3829,7 +3829,7 @@ static switch_status_t pickup_event_handler(switch_core_session_t *session)
|
||||
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;
|
||||
@@ -3903,7 +3903,7 @@ static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *sessio
|
||||
|
||||
|
||||
switch_core_session_set_private(nsession, tech_pvt);
|
||||
|
||||
|
||||
nchannel = switch_core_session_get_channel(nsession);
|
||||
switch_channel_set_cap(nchannel, CC_PROXY_MEDIA);
|
||||
switch_channel_set_cap(nchannel, CC_BYPASS_MEDIA);
|
||||
@@ -3912,7 +3912,7 @@ static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *sessio
|
||||
switch_channel_set_caller_profile(nchannel, caller_profile);
|
||||
|
||||
switch_channel_set_state(nchannel, CS_ROUTING);
|
||||
|
||||
|
||||
|
||||
|
||||
*new_session = nsession;
|
||||
@@ -3963,7 +3963,7 @@ SWITCH_STANDARD_APP(pickup_function)
|
||||
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),
|
||||
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;
|
||||
@@ -3974,10 +3974,10 @@ SWITCH_STANDARD_APP(pickup_function)
|
||||
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;
|
||||
|
||||
@@ -3986,11 +3986,11 @@ SWITCH_STANDARD_APP(pickup_function)
|
||||
|
||||
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 *partner_uuid = switch_channel_get_partner_uuid(channel);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
|
||||
|
||||
|
||||
if (partner_uuid) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", partner_uuid);
|
||||
}
|
||||
@@ -4221,7 +4221,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
|
||||
}
|
||||
var_event = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (switch_xml_locate_user_merged("id", user, domain, NULL, &x_user, params) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", user, domain);
|
||||
cause = SWITCH_CAUSE_SUBSCRIBER_ABSENT;
|
||||
@@ -4345,7 +4345,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
|
||||
switch_safe_free(d_dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (new_channel && x_user) {
|
||||
if ((x_params = switch_xml_child(x_user, "variables"))) {
|
||||
for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
|
||||
@@ -4493,7 +4493,7 @@ SWITCH_STANDARD_APP(detect_silence_function)
|
||||
}
|
||||
|
||||
static switch_status_t event_chat_send(switch_event_t *message_event)
|
||||
|
||||
|
||||
{
|
||||
switch_event_t *event;
|
||||
const char *to;
|
||||
@@ -4512,7 +4512,7 @@ static switch_status_t event_chat_send(switch_event_t *message_event)
|
||||
if (switch_event_fire(&event) == SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
switch_event_destroy(&event);
|
||||
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
@@ -4521,7 +4521,7 @@ static switch_status_t event_chat_send(switch_event_t *message_event)
|
||||
static switch_status_t api_chat_send(switch_event_t *message_event)
|
||||
{
|
||||
const char *proto;
|
||||
const char *from;
|
||||
const char *from;
|
||||
const char *to;
|
||||
//const char *subject;
|
||||
//const char *body;
|
||||
@@ -4534,7 +4534,7 @@ static switch_status_t api_chat_send(switch_event_t *message_event)
|
||||
//subject = switch_event_get_header(message_event, "subject");
|
||||
//body = switch_event_get_body(message_event);
|
||||
type = switch_event_get_header(message_event, "type");
|
||||
hint = switch_event_get_header(message_event, "hint");
|
||||
hint = switch_event_get_header(message_event, "hint");
|
||||
|
||||
|
||||
if (to) {
|
||||
@@ -4610,7 +4610,7 @@ SWITCH_STANDARD_APP(limit_function)
|
||||
mydata = switch_core_session_strdup(session, data);
|
||||
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
}
|
||||
|
||||
|
||||
backend = argv[0];
|
||||
|
||||
/* must have at least one item */
|
||||
@@ -4618,10 +4618,10 @@ SWITCH_STANDARD_APP(limit_function)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "USAGE: limit %s\n", LIMIT_USAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* if this is an invalid backend, fallback to db backend */
|
||||
/* TODO: remove this when we can! */
|
||||
if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")) &&
|
||||
if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")) &&
|
||||
!switch_loadable_module_get_limit_interface(backend)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown backend '%s'. To maintain backwards compatability, falling back on db backend and shifting argumens. Either update your diaplan to include the backend, fix the typo, or load the appropriate limit implementation module.\n", backend);
|
||||
mydata = switch_core_session_sprintf(session, "db %s", data);
|
||||
@@ -4709,9 +4709,9 @@ SWITCH_STANDARD_APP(limit_execute_function)
|
||||
mydata = switch_core_session_strdup(session, data);
|
||||
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
}
|
||||
|
||||
|
||||
/* backwards compat version, if we have 5, just prepend with db and reparse */
|
||||
if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")) &&
|
||||
if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")) &&
|
||||
argc == 5) {
|
||||
mydata = switch_core_session_sprintf(session, "db %s", data);
|
||||
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
@@ -4758,7 +4758,7 @@ SWITCH_STANDARD_APP(limit_execute_function)
|
||||
/* Only release the resource if we are still in CS_EXECUTE */
|
||||
if (switch_channel_get_state(switch_core_session_get_channel(session)) == CS_EXECUTE) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "immediately releasing\n");
|
||||
switch_limit_release(backend, session, realm, id);
|
||||
switch_limit_release(backend, session, realm, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4902,12 +4902,12 @@ static switch_status_t next_file(switch_file_handle_t *handle)
|
||||
}
|
||||
|
||||
if (context->file && switch_test_flag(handle, SWITCH_FILE_DATA_SHORT)) { /* TODO handle other data type flags */
|
||||
switch_size_t len;
|
||||
switch_size_t len;
|
||||
uint16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
|
||||
switch_status_t stat;
|
||||
switch_file_handle_t fh = { 0 };
|
||||
|
||||
if ((stat = switch_core_file_open(&fh, context->file, handle->channels, handle->samplerate,
|
||||
if ((stat = switch_core_file_open(&fh, context->file, handle->channels, handle->samplerate,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL)) == SWITCH_STATUS_SUCCESS) {
|
||||
do {
|
||||
len = SWITCH_RECOMMENDED_BUFFER_SIZE / handle->channels;
|
||||
@@ -4916,7 +4916,7 @@ static switch_status_t next_file(switch_file_handle_t *handle)
|
||||
}
|
||||
} while (stat == SWITCH_STATUS_SUCCESS);
|
||||
|
||||
switch_core_file_close(&fh);
|
||||
switch_core_file_close(&fh);
|
||||
switch_file_remove(context->file, handle->memory_pool);
|
||||
|
||||
} else {
|
||||
@@ -4962,7 +4962,7 @@ static switch_status_t file_string_file_seek(switch_file_handle_t *handle, unsig
|
||||
context->index = -1;
|
||||
return next_file(handle);
|
||||
}
|
||||
|
||||
|
||||
if (!handle->seekable) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File is not seekable\n");
|
||||
return SWITCH_STATUS_NOTIMPL;
|
||||
@@ -5004,7 +5004,7 @@ static switch_status_t file_string_file_set_string(switch_file_handle_t *handle,
|
||||
file_string_context_t *context = handle->private_info;
|
||||
file_string_audio_col_t *col_ptr = context->audio_cols;
|
||||
|
||||
while (col_ptr && col != col_ptr->col) {
|
||||
while (col_ptr && col != col_ptr->col) {
|
||||
col_ptr = col_ptr->next;
|
||||
}
|
||||
|
||||
@@ -5017,7 +5017,7 @@ static switch_status_t file_string_file_set_string(switch_file_handle_t *handle,
|
||||
col_ptr->next = context->audio_cols;
|
||||
context->audio_cols = col_ptr;
|
||||
}
|
||||
|
||||
|
||||
return switch_core_file_set_string(&context->fh, col, string);
|
||||
}
|
||||
|
||||
@@ -5232,7 +5232,7 @@ static switch_status_t read_frame_callback(switch_core_session_t *session, switc
|
||||
}
|
||||
|
||||
return switch_channel_test_app_flag_key(rf->key, channel, MUTEX_FLAG_WAIT) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void free_node(mutex_node_t **npp)
|
||||
@@ -5256,7 +5256,7 @@ static void cancel(switch_core_session_t *session, master_mutex_t *master)
|
||||
for (np = master->list; np; np = np->next) {
|
||||
if (np && !strcmp(np->uuid, uuid)) {
|
||||
switch_core_event_hook_remove_state_change(session, mutex_hanguphook);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s canceled\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s canceled\n",
|
||||
switch_core_session_get_uuid(session),
|
||||
switch_core_session_get_name(session), master->key);
|
||||
|
||||
@@ -5269,7 +5269,7 @@ static void cancel(switch_core_session_t *session, master_mutex_t *master)
|
||||
}
|
||||
|
||||
free_node(&np);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5288,7 +5288,7 @@ static void advance(master_mutex_t *master, switch_bool_t pop_current)
|
||||
if (!master || !master->list) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
while (master->list) {
|
||||
mutex_node_t *np;
|
||||
|
||||
@@ -5302,14 +5302,14 @@ static void advance(master_mutex_t *master, switch_bool_t pop_current)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ADVANCE POP %p\n", (void *)np);
|
||||
free_node(&np);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (master->list) {
|
||||
switch_core_session_t *session;
|
||||
|
||||
if ((session = switch_core_session_locate(master->list->uuid))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
|
||||
"%s mutex %s advanced\n", switch_channel_get_name(channel), master->key);
|
||||
switch_channel_set_app_flag_key(master->key, channel, MUTEX_FLAG_SET);
|
||||
switch_channel_clear_app_flag_key(master->key, channel, MUTEX_FLAG_WAIT);
|
||||
@@ -5327,7 +5327,7 @@ static void advance(master_mutex_t *master, switch_bool_t pop_current)
|
||||
|
||||
switch_mutex_unlock(globals.mutex_mutex);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void confirm(switch_core_session_t *session, master_mutex_t *master)
|
||||
@@ -5346,7 +5346,7 @@ static void confirm(switch_core_session_t *session, master_mutex_t *master)
|
||||
if (!strcmp(master->list->uuid, switch_core_session_get_uuid(session))) {
|
||||
switch_channel_clear_app_flag_key(master->key, channel, MUTEX_FLAG_SET);
|
||||
switch_core_event_hook_remove_state_change(session, mutex_hanguphook);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s cleared\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s cleared\n",
|
||||
switch_core_session_get_uuid(session),
|
||||
switch_channel_get_name(channel), master->key);
|
||||
advance(master, SWITCH_TRUE);
|
||||
@@ -5396,7 +5396,7 @@ static switch_bool_t do_mutex(switch_core_session_t *session, const char *key, s
|
||||
switch_mutex_unlock(globals.mutex_mutex);
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (!(master = switch_core_hash_find(globals.mutex_hash, key))) {
|
||||
master = switch_core_alloc(globals.pool, sizeof(*master));
|
||||
master->key = switch_core_strdup(globals.pool, key);
|
||||
@@ -5406,7 +5406,7 @@ static switch_bool_t do_mutex(switch_core_session_t *session, const char *key, s
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "EXIST MASTER %s %p\n", key, (void *) master);
|
||||
}
|
||||
|
||||
|
||||
if (on) {
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "HIT ON\n");
|
||||
@@ -5430,7 +5430,7 @@ static switch_bool_t do_mutex(switch_core_session_t *session, const char *key, s
|
||||
switch_channel_clear_app_flag_key(key, channel, MUTEX_FLAG_WAIT);
|
||||
switch_channel_set_private(channel, "_mutex_master", master);
|
||||
switch_core_event_hook_add_state_change(session, mutex_hanguphook);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n",
|
||||
switch_core_session_get_uuid(session),
|
||||
switch_channel_get_name(channel), key);
|
||||
switch_mutex_unlock(globals.mutex_mutex);
|
||||
@@ -5444,7 +5444,7 @@ static switch_bool_t do_mutex(switch_core_session_t *session, const char *key, s
|
||||
}
|
||||
|
||||
switch_mutex_unlock(globals.mutex_mutex);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s mutex %s is busy, waiting...\n", switch_channel_get_name(channel), key);
|
||||
|
||||
if ((feedback = switch_channel_get_variable(channel, "mutex_feedback"))) {
|
||||
@@ -5456,19 +5456,19 @@ static switch_bool_t do_mutex(switch_core_session_t *session, const char *key, s
|
||||
if ((rf.exten = switch_channel_get_variable(channel, "mutex_orbit_exten"))) {
|
||||
to_val = 60;
|
||||
}
|
||||
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "mutex_timeout"))) {
|
||||
long tmp = atol(var);
|
||||
|
||||
|
||||
if (tmp > 0) {
|
||||
to_val = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (to_val) {
|
||||
switch_codec_implementation_t read_impl;
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
|
||||
rf.to = (1000 / (read_impl.microseconds_per_packet / 1000)) * to_val;
|
||||
rf.dp = switch_channel_get_variable(channel, "mutex_orbit_dialplan");
|
||||
rf.context = switch_channel_get_variable(channel, "mutex_orbit_context");
|
||||
@@ -5500,7 +5500,7 @@ static switch_bool_t do_mutex(switch_core_session_t *session, const char *key, s
|
||||
if (switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_WAIT) || !switch_channel_up(channel)) {
|
||||
cancel(session, master);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n",
|
||||
switch_core_session_get_uuid(session),
|
||||
switch_channel_get_name(channel), key);
|
||||
switch_core_event_hook_add_state_change(session, mutex_hanguphook);
|
||||
@@ -5534,7 +5534,7 @@ SWITCH_STANDARD_APP(mutex_function)
|
||||
}
|
||||
|
||||
do_mutex(session, key, on);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5587,7 +5587,7 @@ void *SWITCH_THREAD_FUNC page_thread(switch_thread_t *thread, void *obj)
|
||||
|
||||
if (switch_ivr_originate(NULL, &session, &cause, pd->dial_str, 60, NULL, NULL, NULL, NULL, pd->var_event, SOF_NONE, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
|
||||
switch_channel_set_variable(channel, "page_file", pd->path);
|
||||
|
||||
mypd = switch_core_session_alloc(session, sizeof(*mypd));
|
||||
@@ -5613,14 +5613,14 @@ void *SWITCH_THREAD_FUNC page_thread(switch_thread_t *thread, void *obj)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void launch_call(const char *dial_str,
|
||||
const char *path, const char *exten, const char *context, const char *dp,
|
||||
static void launch_call(const char *dial_str,
|
||||
const char *path, const char *exten, const char *context, const char *dp,
|
||||
switch_mutex_t *mutex, uint32_t *counter, switch_event_t **var_event)
|
||||
{
|
||||
switch_thread_data_t *td;
|
||||
switch_memory_pool_t *pool;
|
||||
page_data_t *pd;
|
||||
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
|
||||
pd = switch_core_alloc(pool, sizeof(*pd));
|
||||
@@ -5648,7 +5648,7 @@ static void launch_call(const char *dial_str,
|
||||
td->obj = pd;
|
||||
|
||||
switch_thread_pool_launch_thread(&td);
|
||||
|
||||
|
||||
}
|
||||
|
||||
typedef struct call_monitor_s {
|
||||
@@ -5689,7 +5689,7 @@ void *SWITCH_THREAD_FUNC call_monitor_thread(switch_thread_t *thread, void *obj)
|
||||
while (data && *data && *data == ' ') {
|
||||
data++;
|
||||
}
|
||||
|
||||
|
||||
while (*data == '<') {
|
||||
char *parsed = NULL;
|
||||
|
||||
@@ -5716,15 +5716,15 @@ void *SWITCH_THREAD_FUNC call_monitor_thread(switch_thread_t *thread, void *obj)
|
||||
}
|
||||
|
||||
while (sent < size) {
|
||||
do {
|
||||
switch_mutex_lock(mutex);
|
||||
do {
|
||||
switch_mutex_lock(mutex);
|
||||
busy = (counter >= cm->chunk_size);
|
||||
switch_mutex_unlock(mutex);
|
||||
|
||||
if (busy) {
|
||||
|
||||
if (busy) {
|
||||
switch_yield(100000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} while (busy);
|
||||
|
||||
launch_call(argv[sent++], cm->path, cm->exten, cm->context, cm->dp, mutex, &counter, &var_event);
|
||||
@@ -5755,7 +5755,7 @@ static void launch_call_monitor(const char *path, int del, const char *data, uin
|
||||
switch_thread_data_t *td;
|
||||
switch_memory_pool_t *pool;
|
||||
call_monitor_t *cm;
|
||||
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
|
||||
cm = switch_core_alloc(pool, sizeof(*cm));
|
||||
@@ -5777,7 +5777,7 @@ static void launch_call_monitor(const char *path, int del, const char *data, uin
|
||||
td->obj = cm;
|
||||
|
||||
switch_thread_pool_launch_thread(&td);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5814,10 +5814,10 @@ SWITCH_STANDARD_APP(page_function)
|
||||
if ((l = switch_channel_get_variable(channel, "page_dp"))) {
|
||||
dp = l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
l = switch_channel_get_variable(channel, "page_record_limit");
|
||||
|
||||
|
||||
if (l) {
|
||||
if (*l == '+') {
|
||||
l++;
|
||||
@@ -5866,7 +5866,7 @@ SWITCH_STANDARD_APP(page_function)
|
||||
}
|
||||
|
||||
switch_ivr_play_file(session, NULL, beep, NULL);
|
||||
|
||||
|
||||
|
||||
switch_ivr_record_file(session, &fh, path, &args, limit);
|
||||
}
|
||||
@@ -5874,7 +5874,7 @@ SWITCH_STANDARD_APP(page_function)
|
||||
if (zstr(exten)) {
|
||||
exten = switch_core_session_sprintf(session, "playback:%s", path);
|
||||
}
|
||||
|
||||
|
||||
if (switch_file_exists(path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
launch_call_monitor(path, del, pdata, chunk_size, exten, context, dp);
|
||||
} else {
|
||||
@@ -5909,7 +5909,7 @@ SWITCH_STANDARD_API(page_api_function)
|
||||
while (data && *data && *data == ' ') {
|
||||
data++;
|
||||
}
|
||||
|
||||
|
||||
while (*data == '(') {
|
||||
char *parsed = NULL;
|
||||
|
||||
@@ -5928,7 +5928,7 @@ SWITCH_STANDARD_API(page_api_function)
|
||||
if (!var_event) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
pdata = data;
|
||||
|
||||
@@ -5948,7 +5948,7 @@ SWITCH_STANDARD_API(page_api_function)
|
||||
if ((l = switch_event_get_header(var_event, "page_dp"))) {
|
||||
dp = l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ((l = switch_event_get_header(var_event, "page_chunk_size"))) {
|
||||
uint32_t tmp = switch_atoui(l);
|
||||
@@ -5967,7 +5967,7 @@ SWITCH_STANDARD_API(page_api_function)
|
||||
oexten = switch_mprintf("playback:%s", path);
|
||||
exten = oexten;
|
||||
}
|
||||
|
||||
|
||||
if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
launch_call_monitor(path, 0, pdata, chunk_size, exten, context, dp);
|
||||
} else {
|
||||
@@ -5976,7 +5976,7 @@ SWITCH_STANDARD_API(page_api_function)
|
||||
|
||||
|
||||
end:
|
||||
|
||||
|
||||
|
||||
switch_safe_free(odata);
|
||||
switch_safe_free(oexten);
|
||||
@@ -6217,16 +6217,16 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "blind_transfer_ack", "", "", blind_transfer_ack_function, "[true|false]", SAF_NONE);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "bind_digit_action", "bind a key sequence or regex to an action",
|
||||
SWITCH_ADD_APP(app_interface, "bind_digit_action", "bind a key sequence or regex to an action",
|
||||
"bind a key sequence or regex to an action", bind_digit_action_function, BIND_DIGIT_ACTION_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "capture", "capture data into a var", "capture data into a var",
|
||||
SWITCH_ADD_APP(app_interface, "capture", "capture data into a var", "capture data into a var",
|
||||
capture_function, "<varname>|<data>|<regex>", SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "clear_digit_action", "clear all digit bindings", "",
|
||||
SWITCH_ADD_APP(app_interface, "clear_digit_action", "clear all digit bindings", "",
|
||||
clear_digit_action_function, CLEAR_DIGIT_ACTION_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "digit_action_set_realm", "change binding realm", "",
|
||||
SWITCH_ADD_APP(app_interface, "digit_action_set_realm", "change binding realm", "",
|
||||
digit_action_set_realm_function, DIGIT_ACTION_SET_REALM_USAGE, SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number",
|
||||
@@ -6258,7 +6258,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
SWITCH_ADD_APP(app_interface, "eval", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "set_media_stats", "Set Media Stats", "Set Media Stats", set_media_stats_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "stop", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "set_zombie_exec", "Enable Zombie Execution", "Enable Zombie Execution",
|
||||
SWITCH_ADD_APP(app_interface, "set_zombie_exec", "Enable Zombie Execution", "Enable Zombie Execution",
|
||||
zombie_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "pre_answer", "Pre-Answer the call", "Pre-Answer the call for a channel.", pre_answer_function, "", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA);
|
||||
@@ -6311,7 +6311,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
SWITCH_ADD_APP(app_interface, "video_decode", "Set video decode.", "Set video decode.", video_set_decode_function, "[[on|wait]|off]",
|
||||
SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "send_info", "Send info", "Send info", send_info_function, "<info>", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "jitterbuffer", "Send session jitterbuffer", "Send a jitterbuffer message to a session.",
|
||||
SWITCH_ADD_APP(app_interface, "jitterbuffer", "Send session jitterbuffer", "Send a jitterbuffer message to a session.",
|
||||
jitterbuffer_function, "<jitterbuffer_data>", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>",
|
||||
SAF_SUPPORT_NOMEDIA);
|
||||
@@ -6377,10 +6377,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
SWITCH_ADD_APP(app_interface, "loop_playback", "Playback File looply", "Playback a file to the channel looply for limted times",
|
||||
loop_playback_function, "[+loops] <path>", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "att_xfer", "Attended Transfer", "Attended Transfer", att_xfer_function, "<channel_url>", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function,
|
||||
SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function,
|
||||
"<min> <max> <file> <var_name> <timeout> <terminators> <digit_timeout>", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "play_and_get_digits", "Play and get Digits", "Play and get Digits",
|
||||
play_and_get_digits_function,
|
||||
play_and_get_digits_function,
|
||||
"\n\t<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> [<digit_timeout>] ['<failure_ext> [failure_dp [failure_context]]']", SAF_NONE);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "stop_video_write_overlay", "Stop video write overlay", "Stop video write overlay", stop_video_write_overlay_session_function, "<path>", SAF_NONE);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<!-- Default Technology and profile -->
|
||||
<param name="default-techprofile" value="sofia/default"/>
|
||||
|
||||
|
||||
<!-- IP or Hostname of Default Route -->
|
||||
<param name="default-gateway" value="192.168.66.6"/>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
call_limit varchar(16) - contains optional call limit
|
||||
tech_prefix varchar(128) - tech prefix used to build dial string (ex: sofia/default )
|
||||
acctcode varchar(128) - used to set channel variable acctcode for logging into the CDRs
|
||||
destination_number varchar(16) - Number returning for the query for building the dial string. (ex: 18005551212)
|
||||
destination_number varchar(16) - Number returning for the query for building the dial string. (ex: 18005551212)
|
||||
See Documentation on the Wiki for further information -->
|
||||
<!-- <param name="custom-query" value="call FS_GET_SIP_LOCATION(%s);"/> -->
|
||||
</settings>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Jay Binks <jaybinks@gmail.com>
|
||||
*
|
||||
@@ -117,7 +117,7 @@ static switch_status_t load_config(void)
|
||||
globals.timeout = 5000;
|
||||
globals.retries = 3;
|
||||
globals.random = 0;
|
||||
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
const char *var = switch_xml_attr_soft(param, "name");
|
||||
@@ -165,8 +165,8 @@ static switch_status_t load_config(void)
|
||||
HKEY hKey;
|
||||
DWORD data_sz;
|
||||
char* buf;
|
||||
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
|
||||
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
|
||||
0, KEY_QUERY_VALUE, &hKey);
|
||||
|
||||
if (hKey) {
|
||||
@@ -249,7 +249,7 @@ static void add_result(enum_record_t **results, int order, int preference, char
|
||||
new_result->service = strdup(service);
|
||||
new_result->route = strdup(route);
|
||||
new_result->supported = supported;
|
||||
|
||||
|
||||
|
||||
if (!*results) {
|
||||
*results = new_result;
|
||||
@@ -310,7 +310,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
||||
char *packstr;
|
||||
|
||||
char *regex, *replace;
|
||||
|
||||
|
||||
if (zstr(str)) {
|
||||
if (str != NULL) {
|
||||
/* In this case ldns_rr2str returned a malloc'd null terminated string */
|
||||
@@ -339,7 +339,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
||||
if (zstr(service) || zstr(packstr)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (!zstr(argv[4])) {
|
||||
order = atoi(argv[4]);
|
||||
}
|
||||
@@ -355,7 +355,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
||||
} else {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
for (p = replace; p && *p; p++) {
|
||||
if (*p == '\\') {
|
||||
*p = '$';
|
||||
@@ -388,11 +388,11 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
||||
} else {
|
||||
orig_uri = replace;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(MUTEX);
|
||||
for (route = globals.route_order; route; route = route->next) {
|
||||
char *uri = orig_uri;
|
||||
|
||||
|
||||
if (strcasecmp(service, route->service)) {
|
||||
continue;
|
||||
}
|
||||
@@ -429,13 +429,13 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
||||
|
||||
supported++;
|
||||
add_result(results, order, preference, service, uri, supported);
|
||||
|
||||
|
||||
}
|
||||
switch_safe_free(uri_expanded);
|
||||
switch_safe_free(substituted_2);
|
||||
switch_regex_safe_free(re2);
|
||||
}
|
||||
switch_mutex_unlock(MUTEX);
|
||||
switch_mutex_unlock(MUTEX);
|
||||
|
||||
if (!supported) {
|
||||
add_result(results, order, preference, service, orig_uri, 0);
|
||||
@@ -449,7 +449,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
|
||||
end:
|
||||
|
||||
switch_safe_free(str);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -471,15 +471,15 @@ switch_status_t ldns_lookup(const char *number, const char *root, char *server_n
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Parse Error!\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (!(domain = ldns_dname_new_frm_str(name))) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (server_name) {
|
||||
res = ldns_resolver_new();
|
||||
switch_assert(res);
|
||||
|
||||
|
||||
for(inameserver=0; inameserver<ENUM_MAXNAMESERVERS; inameserver++) {
|
||||
if ( server_name[inameserver] != NULL ) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding Nameserver [%s]\n", server_name[inameserver]);
|
||||
@@ -488,9 +488,9 @@ switch_status_t ldns_lookup(const char *number, const char *root, char *server_n
|
||||
ldns_rdf_deep_free(serv_rdf);
|
||||
added_server = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!added_server) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No Nameservers specified, using host default\n");
|
||||
/* create a new resolver from /etc/resolv.conf */
|
||||
@@ -520,7 +520,7 @@ switch_status_t ldns_lookup(const char *number, const char *root, char *server_n
|
||||
if ((naptr = ldns_pkt_rr_list_by_type(p, LDNS_RR_TYPE_NAPTR, LDNS_SECTION_ANSWER))) {
|
||||
size_t i;
|
||||
|
||||
ldns_rr_list_sort(naptr);
|
||||
ldns_rr_list_sort(naptr);
|
||||
|
||||
for (i = 0; i < ldns_rr_list_rr_count(naptr); i++) {
|
||||
parse_naptr(ldns_rr_list_rr(naptr, i), number, results);
|
||||
@@ -535,7 +535,7 @@ switch_status_t ldns_lookup(const char *number, const char *root, char *server_n
|
||||
end:
|
||||
|
||||
switch_safe_free(name);
|
||||
|
||||
|
||||
if (domain) {
|
||||
ldns_rdf_deep_free(domain);
|
||||
}
|
||||
@@ -556,7 +556,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
|
||||
switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
|
||||
char *mnum = NULL, *mroot = NULL, *p;
|
||||
char *server[ENUM_MAXNAMESERVERS];
|
||||
int inameserver = 0;
|
||||
int inameserver = 0;
|
||||
char *argv[ ENUM_MAXNAMESERVERS ] = { 0 };
|
||||
int argc;
|
||||
int x = 0;
|
||||
@@ -580,12 +580,12 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
|
||||
/* Empty the server array */
|
||||
for(inameserver=0; inameserver<ENUM_MAXNAMESERVERS; inameserver++) {
|
||||
server[inameserver] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inameserver = 0;
|
||||
|
||||
/* check for enum_nameserver channel var */
|
||||
|
||||
|
||||
if (channel) {
|
||||
enum_nameserver = switch_channel_get_variable(channel, "enum_nameserver");
|
||||
}
|
||||
@@ -691,7 +691,7 @@ SWITCH_STANDARD_APP(enum_app_function)
|
||||
root = argv[1];
|
||||
if (enum_lookup(root, dest, &results, channel, session) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_t *vars;
|
||||
|
||||
|
||||
if (switch_channel_get_variables(channel, &vars) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_header_t *hi;
|
||||
for (hi = vars->headers; hi; hi = hi->next) {
|
||||
@@ -921,7 +921,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_enum_shutdown)
|
||||
|
||||
switch_safe_free(globals.root);
|
||||
switch_safe_free(globals.isn_root);
|
||||
|
||||
|
||||
return SWITCH_STATUS_UNLOAD;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
*
|
||||
@@ -165,7 +165,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
const char *codec_name = "PCMU";
|
||||
int read_rate = 8000;
|
||||
int need_transcode = 0;
|
||||
|
||||
|
||||
inc_serno();
|
||||
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
@@ -313,7 +313,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
while (!ready) {
|
||||
status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
|
||||
@@ -333,7 +333,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
|
||||
alert_packet->audio_header.codec = 0x00;
|
||||
alert_packet->audio_header.flags = 0;
|
||||
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "esf_multicast_write_codec"))) {
|
||||
if (!strcasecmp(var, "PCMU")) {
|
||||
codec_name = var;
|
||||
@@ -379,7 +379,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!(rtp_port = switch_rtp_request_port(source_ip))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Port Error\n");
|
||||
@@ -393,7 +393,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
alert_packet->audio_header.codec,
|
||||
160,
|
||||
20000, flags, "soft", &err, switch_core_session_get_pool(session));
|
||||
|
||||
|
||||
if (!switch_rtp_ready(rtp_session)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error\n");
|
||||
goto fail;
|
||||
@@ -420,7 +420,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
|
||||
strncpy((char *)polycom_packet->cid, caller_id_name, sizeof(polycom_packet->cid));
|
||||
polycom_packet->cid_len = 13;
|
||||
|
||||
|
||||
polycom_packet->op = 0x0F;
|
||||
polycom_packet->channel = 0x1a;
|
||||
polycom_packet->serno = htonl(get_serno());
|
||||
@@ -485,27 +485,27 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
ebuf = read_frame->data;
|
||||
encoded_datalen = read_frame->datalen;
|
||||
}
|
||||
|
||||
|
||||
switch_rtp_write_frame(rtp_session, read_frame);
|
||||
|
||||
|
||||
seq += 160;
|
||||
|
||||
|
||||
alert_packet->audio_header.seq = htonl(seq);
|
||||
|
||||
|
||||
if (last_polycom_len) {
|
||||
memcpy(alert_packet->data, last_polycom_buf, last_polycom_len);
|
||||
memcpy(alert_packet->data + last_polycom_len, ebuf, encoded_datalen);
|
||||
} else {
|
||||
memcpy(alert_packet->data, ebuf, encoded_datalen);
|
||||
}
|
||||
|
||||
|
||||
bytes = sizeof(*alert_packet) + encoded_datalen + last_polycom_len;
|
||||
|
||||
switch_socket_sendto(socket, polycom_addr, 0, (void *) polycom_buf, &bytes);
|
||||
|
||||
|
||||
last_polycom_len = encoded_datalen;
|
||||
memcpy((void *)last_polycom_buf, (void *)ebuf, last_polycom_len);
|
||||
|
||||
|
||||
} else {
|
||||
bytes = read_frame->packetlen;
|
||||
switch_socket_sendto(socket, audio_addr, 0, read_frame->packet, &bytes);
|
||||
@@ -543,7 +543,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
if (socket) {
|
||||
switch_socket_close(socket);
|
||||
}
|
||||
|
||||
|
||||
if (polycom_socket) {
|
||||
switch_socket_close(polycom_socket);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Marc Olivier Chouinard <mochouinard@moctel.com>
|
||||
*
|
||||
*
|
||||
@@ -38,7 +38,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_esl_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_esl_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_esl_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_esl, mod_esl_load, mod_esl_shutdown, NULL);
|
||||
@@ -65,7 +65,7 @@ SWITCH_STANDARD_API(single_esl_api_function)
|
||||
|
||||
if (password && (host = strchr(password, ' '))) {
|
||||
*host++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (host && (s_timeout = strchr(host, ' '))) {
|
||||
*s_timeout++ = '\0';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* Written by:
|
||||
* Hongli Lai <hongli@telekabel.nl>
|
||||
* tkorrovi <tkorrovi@altavista.net> on 2002/02/26.
|
||||
* tkorrovi <tkorrovi@altavista.net> on 2002/02/26.
|
||||
* Andrew Westcott <ajwestco@users.sourceforge.net>
|
||||
*
|
||||
* Offered for use in the public domain without any warranty.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_expr.c -- Framework Demo Module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!--
|
||||
<!--
|
||||
Parking extensions... transferring calls to 5900 will park them in a queue.
|
||||
-->
|
||||
<extension name="park">
|
||||
@@ -8,7 +8,7 @@
|
||||
</condition>
|
||||
</extension>
|
||||
|
||||
<!--
|
||||
<!--
|
||||
Parking pickup extension. Calling 5901 will pickup the call.
|
||||
-->
|
||||
<extension name="unpark">
|
||||
|
||||
@@ -84,7 +84,7 @@ SWITCH_MODULE_DEFINITION(mod_fifo, mod_fifo_load, mod_fifo_shutdown, NULL);
|
||||
* who will be available to answer a single caller. In ringall this
|
||||
* maximum is the number who will be called, in enterprise the need defines
|
||||
* how many agents will be called. outbound_per_cycle_min will define
|
||||
* the minimum agents who will be called to answer a caller regardless of
|
||||
* the minimum agents who will be called to answer a caller regardless of
|
||||
* need, giving the enterprise strategy the ability to ring through more
|
||||
* than one agent for one caller.
|
||||
|
||||
@@ -1999,19 +1999,19 @@ static int place_call_enterprise_callback(void *pArg, int argc, char **argv, cha
|
||||
* care of invoking the handler.
|
||||
*
|
||||
* Within the ringall call strategy outbound_per_cycle is used to define
|
||||
* how many agents exactly are assigned to the caller. With ringall if
|
||||
* how many agents exactly are assigned to the caller. With ringall if
|
||||
* multiple callers are calling in and one is answered, because the call
|
||||
* is assigned to all agents the call to the agents that is not answered
|
||||
* will be lose raced and the other agents will drop the call before the
|
||||
* next one will begin to ring. When oubound_per_cycle is used in the
|
||||
* next one will begin to ring. When oubound_per_cycle is used in the
|
||||
* enterprise strategy it acts as a maximum value for how many agents
|
||||
* are rung at once on any call, the caller is not assigned to any agent
|
||||
* are rung at once on any call, the caller is not assigned to any agent
|
||||
* until the call is answered. Enterprise only rings the number of phones
|
||||
* that are needed, so outbound_per_cycle as a max does not give you the
|
||||
* effect of ringall. outbound_per_cycle_min defines how many agents minimum
|
||||
* will be rung by an incoming caller through fifo, which can give a ringall
|
||||
* effect. outbound_per_cycle and outbound_per_cycle_min both default to 1.
|
||||
*
|
||||
*
|
||||
*/
|
||||
static int find_consumers(fifo_node_t *node)
|
||||
{
|
||||
@@ -4083,7 +4083,7 @@ static void list_node(fifo_node_t *node, switch_xml_t x_report, int *off, int ve
|
||||
switch_xml_set_attr_d(x_fifo, "outbound_per_cycle", tmp);
|
||||
|
||||
switch_snprintf(tmp, sizeof(buffer), "%u", node->outbound_per_cycle_min);
|
||||
switch_xml_set_attr_d(x_fifo, "outbound_per_cycle_min", tmp);
|
||||
switch_xml_set_attr_d(x_fifo, "outbound_per_cycle_min", tmp);
|
||||
|
||||
switch_snprintf(tmp, sizeof(buffer), "%u", node->ring_timeout);
|
||||
switch_xml_set_attr_d(x_fifo, "ring_timeout", tmp);
|
||||
|
||||
@@ -211,7 +211,7 @@ dsp_fsk_handle_t *dsp_fsk_create(dsp_fsk_attr_t *attr)
|
||||
/*
|
||||
* dsp_fsk_destroy
|
||||
*
|
||||
* Destroys a handle, releasing any associated memory. Sets handle pointer to NULL
|
||||
* Destroys a handle, releasing any associated memory. Sets handle pointer to NULL
|
||||
* so A destroyed handle can not be used for anything after the destroy.
|
||||
*/
|
||||
|
||||
@@ -306,11 +306,11 @@ dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample)
|
||||
|
||||
if (handle->cellpos > 1.0) {
|
||||
handle->cellpos -= 1.0;
|
||||
|
||||
|
||||
switch (handle->state) {
|
||||
case FSK_STATE_DATA:
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
(*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -109,5 +109,5 @@ void dsp_fsk_sample(dsp_fsk_handle_t *handle, double normalized_sample);
|
||||
|
||||
extern fsk_modem_definition_t fsk_modem_definitions[];
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_fsk -- FSK data transfer
|
||||
@@ -39,7 +39,7 @@ void bitstream_init(bitstream_t *bsp, uint8_t *data, uint32_t datalen, endian_t
|
||||
bsp->datalen = datalen;
|
||||
bsp->endian = endian;
|
||||
bsp->ss = ss;
|
||||
|
||||
|
||||
if (endian < 0) {
|
||||
bsp->top = bsp->bit_index = 7;
|
||||
bsp->bot = 0;
|
||||
@@ -53,7 +53,7 @@ void bitstream_init(bitstream_t *bsp, uint8_t *data, uint32_t datalen, endian_t
|
||||
int8_t bitstream_get_bit(bitstream_t *bsp)
|
||||
{
|
||||
int8_t bit = -1;
|
||||
|
||||
|
||||
|
||||
if (bsp->byte_index >= bsp->datalen) {
|
||||
goto done;
|
||||
@@ -71,19 +71,19 @@ int8_t bitstream_get_bit(bitstream_t *bsp)
|
||||
}
|
||||
|
||||
bit = (bsp->data[bsp->byte_index] >> (bsp->bit_index)) & 1;
|
||||
|
||||
|
||||
if (bsp->bit_index == bsp->bot) {
|
||||
bsp->bit_index = bsp->top;
|
||||
if (bsp->ss) {
|
||||
bsp->ssv = 2;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (++bsp->byte_index > bsp->datalen) {
|
||||
bit = -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
bsp->bit_index = bsp->bit_index + bsp->endian;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ static void fsk_byte_handler (void *x, int data)
|
||||
if (state->dlen) {
|
||||
goto add_byte;
|
||||
}
|
||||
|
||||
|
||||
if (state->bpos == 1) {
|
||||
state->blen = byte;
|
||||
|
||||
@@ -189,7 +189,7 @@ switch_status_t fsk_data_parse(fsk_data_state_t *state, size_t *type, char **dat
|
||||
|
||||
size_t i;
|
||||
int sum = 0;
|
||||
|
||||
|
||||
top:
|
||||
|
||||
if (state->checksum != 0 || state->ppos >= state->dlen - 1) {
|
||||
@@ -201,7 +201,7 @@ switch_status_t fsk_data_parse(fsk_data_state_t *state, size_t *type, char **dat
|
||||
sum += state->buf[i];
|
||||
}
|
||||
state->checksum = sum % 256;
|
||||
state->ppos = 2;
|
||||
state->ppos = 2;
|
||||
|
||||
if (state->buf[0] != CID_TYPE_MDMF && state->buf[0] != CID_TYPE_SDMF) {
|
||||
state->checksum = -1;
|
||||
@@ -224,7 +224,7 @@ switch_status_t fsk_data_parse(fsk_data_state_t *state, size_t *type, char **dat
|
||||
}
|
||||
}
|
||||
*data = (char *)&state->buf[state->ppos];
|
||||
state->ppos += *len;
|
||||
state->ppos += *len;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if (state->buf[0] == CID_TYPE_MDMF) {
|
||||
*type = state->buf[state->ppos++];
|
||||
@@ -277,7 +277,7 @@ int fsk_demod_init(fsk_data_state_t *state, int rate, uint8_t *buf, size_t bufsi
|
||||
memset(buf, 0, bufsize);
|
||||
state->buf = buf;
|
||||
state->bufsize = bufsize;
|
||||
|
||||
|
||||
dsp_fsk_attr_init (&fsk1200_attr);
|
||||
dsp_fsk_attr_set_samplerate (&fsk1200_attr, rate);
|
||||
dsp_fsk_attr_set_bytehandler (&fsk1200_attr, fsk_byte_handler, state);
|
||||
@@ -293,7 +293,7 @@ int fsk_demod_init(fsk_data_state_t *state, int rate, uint8_t *buf, size_t bufsi
|
||||
size_t fsk_modulator_generate_bit(fsk_modulator_t *fsk_trans, int8_t bit, int16_t *buf, size_t buflen)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
||||
for(i = 0 ; i < buflen; i++) {
|
||||
fsk_trans->bit_accum += fsk_trans->bit_factor;
|
||||
if (fsk_trans->bit_accum >= FSK_MOD_FACTOR) {
|
||||
@@ -333,7 +333,7 @@ void fsk_modulator_generate_chan_sieze(fsk_modulator_t *fsk_trans)
|
||||
uint32_t i = 0;
|
||||
size_t r = 0;
|
||||
int8_t bit = 0;
|
||||
|
||||
|
||||
for (i = 0; i < fsk_trans->chan_sieze_bits; i++) {
|
||||
if ((r = fsk_modulator_generate_bit(fsk_trans, bit, fsk_trans->sample_buffer, sizeof(fsk_trans->sample_buffer) / 2))) {
|
||||
if (fsk_trans->write_sample_callback(fsk_trans->sample_buffer, r, fsk_trans->user_data) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -344,7 +344,7 @@ void fsk_modulator_generate_chan_sieze(fsk_modulator_t *fsk_trans)
|
||||
}
|
||||
bit = !bit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_fsk -- FSK data transfer
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_fsk.c -- FSK data transfer
|
||||
@@ -36,7 +36,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_fsk_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_fsk_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_fsk_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_fsk, mod_fsk_load, mod_fsk_shutdown, NULL);
|
||||
@@ -46,7 +46,7 @@ switch_status_t my_write_sample(int16_t *buf, size_t buflen, void *user_data)
|
||||
switch_buffer_t *buffer = (switch_buffer_t *) user_data;
|
||||
|
||||
switch_buffer_write(buffer, buf, buflen * 2);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ static switch_status_t write_fsk_data(uint32_t rate, int32_t db, switch_buffer_t
|
||||
switch_size_t plen = 0;
|
||||
|
||||
memset(&fsk_trans, 0, sizeof(fsk_trans));
|
||||
|
||||
|
||||
time(&now);
|
||||
localtime_r(&now, &tm);
|
||||
strftime(time_str, sizeof(time_str), "%m%d%H%M", &tm);
|
||||
@@ -91,7 +91,7 @@ static switch_status_t write_fsk_data(uint32_t rate, int32_t db, switch_buffer_t
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoding [%s][%s]\n", hp->name, hp->value);
|
||||
|
||||
|
||||
if (!strcasecmp(name, "phone_num")) {
|
||||
fsk_data_add_mdmf(&fsk_data, MDMF_PHONE_NUM, (uint8_t *)hp->value, strlen(hp->value));
|
||||
} else if (!strcasecmp(name, "phone_name")) {
|
||||
@@ -122,14 +122,14 @@ SWITCH_STANDARD_APP(fsk_send_function) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_frame_t *read_frame;
|
||||
switch_status_t status;
|
||||
|
||||
|
||||
|
||||
if (data) {
|
||||
switch_ivr_sleep(session, 1000, SWITCH_TRUE, NULL);
|
||||
switch_core_session_send_dtmf_string(session, (const char *) data);
|
||||
switch_ivr_sleep(session, 1500, SWITCH_TRUE, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_session_set_codec_slin(session, &sdata) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
|
||||
SWITCH_LOG_ERROR, "FAILURE\n");
|
||||
@@ -139,7 +139,7 @@ SWITCH_STANDARD_APP(fsk_send_function) {
|
||||
switch_buffer_create_dynamic(&buffer, 1024, 2048, 0);
|
||||
|
||||
switch_channel_get_variables(channel, &event);
|
||||
|
||||
|
||||
write_fsk_data(sdata.codec.implementation->actual_samples_per_second, -14, buffer, event, "fsk_");
|
||||
|
||||
while(switch_channel_ready(channel)) {
|
||||
@@ -149,14 +149,14 @@ SWITCH_STANDARD_APP(fsk_send_function) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((sdata.write_frame.datalen = switch_buffer_read(buffer, sdata.write_frame.data,
|
||||
if ((sdata.write_frame.datalen = switch_buffer_read(buffer, sdata.write_frame.data,
|
||||
sdata.codec.implementation->decoded_bytes_per_packet)) <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (sdata.write_frame.datalen < sdata.codec.implementation->decoded_bytes_per_packet) {
|
||||
memset((char *)sdata.write_frame.data + sdata.write_frame.datalen, 255,
|
||||
memset((char *)sdata.write_frame.data + sdata.write_frame.datalen, 255,
|
||||
sdata.codec.implementation->decoded_bytes_per_packet - sdata.write_frame.datalen);
|
||||
sdata.write_frame.datalen = sdata.codec.implementation->decoded_bytes_per_packet;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ SWITCH_STANDARD_APP(fsk_send_function) {
|
||||
switch_buffer_destroy(&buffer);
|
||||
switch_core_codec_destroy(&sdata.codec);
|
||||
switch_core_session_set_read_codec(session, NULL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@@ -191,11 +191,11 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat
|
||||
case SWITCH_ABC_TYPE_INIT: {
|
||||
switch_codec_implementation_t read_impl = { 0 };
|
||||
switch_core_session_get_read_impl(pvt->session, &read_impl);
|
||||
|
||||
|
||||
if (fsk_demod_init(&pvt->fsk_data, read_impl.actual_samples_per_second, pvt->fbuf, sizeof(pvt->fbuf))) {
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case SWITCH_ABC_TYPE_CLOSE:
|
||||
@@ -224,10 +224,10 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat
|
||||
int total = 0;
|
||||
|
||||
switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA);
|
||||
|
||||
|
||||
while(fsk_data_parse(&pvt->fsk_data, &type, &sp, &mlen) == SWITCH_STATUS_SUCCESS) {
|
||||
char *varname = NULL, *val, *p;
|
||||
|
||||
|
||||
switch_copy_string(str, sp, mlen+1);
|
||||
*(str+mlen) = '\0';
|
||||
switch_clean_string(str);
|
||||
@@ -258,7 +258,7 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat
|
||||
|
||||
if (varname && val) {
|
||||
total++;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s setting FSK var [%s][%s]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s setting FSK var [%s][%s]\n",
|
||||
switch_channel_get_name(channel), varname, val);
|
||||
switch_channel_set_variable(channel, varname, val);
|
||||
if (event) {
|
||||
@@ -272,21 +272,21 @@ static switch_bool_t fsk_detect_callback(switch_media_bug_t *bug, void *user_dat
|
||||
switch_event_destroy(&event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (total && (app_var = switch_channel_get_variable(channel, "execute_on_fsk"))) {
|
||||
char *app_arg;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s processing execute_on_fsk [%s]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "%s processing execute_on_fsk [%s]\n",
|
||||
switch_channel_get_name(channel), app_var);
|
||||
if ((app_arg = strchr(app_var, ' '))) {
|
||||
*app_arg++ = '\0';
|
||||
}
|
||||
switch_core_session_execute_application(pvt->session, app_var, app_arg);
|
||||
}
|
||||
|
||||
|
||||
pvt->skip = 10;
|
||||
}
|
||||
|
||||
|
||||
memset(rframe->data, 255, rframe->datalen);
|
||||
|
||||
if (type == SWITCH_ABC_TYPE_READ_REPLACE) {
|
||||
@@ -359,12 +359,12 @@ switch_status_t fsk_detect_session(switch_core_session_t *session, const char *f
|
||||
}
|
||||
|
||||
|
||||
SWITCH_STANDARD_APP(fsk_recv_function)
|
||||
SWITCH_STANDARD_APP(fsk_recv_function)
|
||||
{
|
||||
fsk_detect_session(session, data);
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(fsk_display_function)
|
||||
SWITCH_STANDARD_APP(fsk_display_function)
|
||||
{
|
||||
/* expected to be called via 'execute_on_fsk' -- passes display update over FSK */
|
||||
|
||||
@@ -380,7 +380,7 @@ SWITCH_STANDARD_APP(fsk_display_function)
|
||||
if (zstr(cid_name)) {
|
||||
cid_name = cid_num;
|
||||
}
|
||||
|
||||
|
||||
if (zstr(cid_num)) {
|
||||
return;
|
||||
}
|
||||
@@ -409,13 +409,13 @@ SWITCH_STANDARD_APP(fsk_display_function)
|
||||
}
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(fsk_simplify_function)
|
||||
SWITCH_STANDARD_APP(fsk_simplify_function)
|
||||
{
|
||||
/* expected to be called via 'execute_on_fsk' -- redirects call to point-to-point and eliminates legs in the middle */
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *sip_uri, *fsk_simplify_profile, *fsk_simplify_context;
|
||||
char *bridgeto;
|
||||
|
||||
|
||||
if (!(sip_uri = switch_channel_get_variable(channel, "fsk_uri"))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Missing URI field!\n", switch_channel_get_name(channel));
|
||||
}
|
||||
@@ -431,21 +431,21 @@ SWITCH_STANDARD_APP(fsk_simplify_function)
|
||||
switch_channel_t *pchannel;
|
||||
|
||||
bridgeto = switch_core_session_sprintf(session, "bridge:sofia/%s/sip:%s", fsk_simplify_profile, sip_uri);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s transfering to [%s]\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s transfering to [%s]\n",
|
||||
switch_channel_get_name(channel), bridgeto);
|
||||
|
||||
|
||||
|
||||
if (switch_core_session_get_partner(session, &psession) == SWITCH_STATUS_SUCCESS) {
|
||||
pchannel = switch_core_session_get_channel(psession);
|
||||
switch_channel_set_flag(pchannel, CF_REDIRECT);
|
||||
switch_channel_set_flag(pchannel, CF_TRANSFER);
|
||||
}
|
||||
|
||||
|
||||
switch_ivr_session_transfer(session, bridgeto, "inline", fsk_simplify_context);
|
||||
|
||||
if (psession) {
|
||||
switch_ivr_session_transfer(psession, "sleep:5000", "inline", NULL);
|
||||
switch_core_session_rwunlock(psession);
|
||||
switch_core_session_rwunlock(psession);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Seven Du <dujinfang@gmail.com>
|
||||
*
|
||||
@@ -124,14 +124,14 @@ SWITCH_STANDARD_APP(record_fsv_function)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s waiting for video.\n", switch_channel_get_name(channel));
|
||||
count = 100;
|
||||
if (!--sanity) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
|
||||
switch_channel_get_name(channel));
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "Got timeout while waiting for video");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!switch_channel_ready(channel)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s not ready.\n", switch_channel_get_name(channel));
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "Channel not ready");
|
||||
@@ -241,7 +241,7 @@ SWITCH_STANDARD_APP(record_fsv_function)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (mutex) {
|
||||
switch_mutex_unlock(mutex);
|
||||
}
|
||||
@@ -442,7 +442,7 @@ SWITCH_STANDARD_APP(play_fsv_function)
|
||||
if (terminators && !strcasecmp(terminators, "none"))
|
||||
{
|
||||
terminators = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (terminators && strchr(terminators, dtmf.digit)) {
|
||||
|
||||
@@ -452,7 +452,7 @@ SWITCH_STANDARD_APP(play_fsv_function)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch_core_thread_session_end(session);
|
||||
@@ -625,7 +625,7 @@ SWITCH_STANDARD_APP(play_yuv_function)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (read_frame) {
|
||||
memset(read_frame->data, 0, read_frame->datalen);
|
||||
switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
@@ -699,7 +699,7 @@ static void decode_video_thread(switch_core_session_t *session, void *obj)
|
||||
switch_core_session_request_video_refresh(session);
|
||||
count = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (frame && frame->datalen > 0) {
|
||||
switch_core_session_write_video_frame(session, frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Ken Rice <krice at suspicious dot org
|
||||
* Mathieu Rene <mathieu.rene@gmail.com>
|
||||
@@ -98,18 +98,18 @@ typedef struct {
|
||||
const char *username;
|
||||
const char *password;
|
||||
int port;
|
||||
|
||||
|
||||
int interval;
|
||||
|
||||
|
||||
esl_handle_t handle;
|
||||
|
||||
switch_hash_t *index;
|
||||
switch_thread_rwlock_t *rwlock;
|
||||
switch_memory_pool_t *pool;
|
||||
|
||||
|
||||
switch_bool_t running;
|
||||
switch_thread_t *thread;
|
||||
|
||||
|
||||
limit_remote_state_t state;
|
||||
} limit_remote_t;
|
||||
|
||||
@@ -232,24 +232,24 @@ SWITCH_HASH_DELETE_FUNC(limit_hash_cleanup_delete_callback) {
|
||||
if (item->total_usage == 0 && item->rate_usage == 0) {
|
||||
/* Noone is using this item anymore */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Freeing limit item: %s\n", (const char *) key);
|
||||
|
||||
|
||||
free(item);
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_HASH_DELETE_FUNC(limit_hash_remote_cleanup_callback)
|
||||
SWITCH_HASH_DELETE_FUNC(limit_hash_remote_cleanup_callback)
|
||||
{
|
||||
limit_hash_item_t *item = (limit_hash_item_t *) val;
|
||||
switch_time_t now = (switch_time_t)(intptr_t)pData;
|
||||
|
||||
|
||||
if (item->last_update != now) {
|
||||
free(item);
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ SWITCH_STANDARD_SCHED_FUNC(limit_hash_cleanup_callback)
|
||||
}
|
||||
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
|
||||
|
||||
if (globals.limit_hash) {
|
||||
if (globals.limit_hash) {
|
||||
task->runtime = switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL;
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,7 @@ SWITCH_LIMIT_RELEASE(limit_release_hash)
|
||||
}
|
||||
|
||||
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ SWITCH_LIMIT_USAGE(limit_usage_hash)
|
||||
|
||||
hash_key = switch_mprintf("%s_%s", realm, resource);
|
||||
remote_usage = get_remote_usage(hash_key);
|
||||
|
||||
|
||||
count = remote_usage.total_usage;
|
||||
*rcount = remote_usage.rate_usage;
|
||||
|
||||
@@ -382,15 +382,15 @@ SWITCH_LIMIT_STATUS(limit_status_hash)
|
||||
switch_hash_index_t *hi = NULL;
|
||||
int count = 0;
|
||||
char *ret = NULL;
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(globals.limit_hash_rwlock);
|
||||
|
||||
|
||||
for (hi = switch_core_hash_first(globals.limit_hash); hi; switch_core_hash_next(hi)) {
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
|
||||
|
||||
|
||||
ret = switch_mprintf("There are %d elements being tracked.", count);
|
||||
return ret;
|
||||
*/
|
||||
@@ -577,7 +577,7 @@ SWITCH_STANDARD_API(hash_api_function)
|
||||
}
|
||||
|
||||
#define HASH_DUMP_SYNTAX "all|limit|db [<realm>]"
|
||||
SWITCH_STANDARD_API(hash_dump_function)
|
||||
SWITCH_STANDARD_API(hash_dump_function)
|
||||
{
|
||||
int mode;
|
||||
switch_hash_index_t *hi;
|
||||
@@ -586,7 +586,7 @@ SWITCH_STANDARD_API(hash_dump_function)
|
||||
char *mydata = NULL;
|
||||
int realm = 0;
|
||||
char *realmvalue = NULL;
|
||||
|
||||
|
||||
if (zstr(cmd)) {
|
||||
stream->write_function(stream, "Usage: "HASH_DUMP_SYNTAX"\n");
|
||||
goto done;
|
||||
@@ -600,8 +600,8 @@ SWITCH_STANDARD_API(hash_dump_function)
|
||||
if (argc == 2) {
|
||||
realm = 1;
|
||||
realmvalue = switch_mprintf("%s_", argv[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "all")) {
|
||||
mode = 3;
|
||||
} else if (!strcmp(cmd, "limit")) {
|
||||
@@ -612,7 +612,7 @@ SWITCH_STANDARD_API(hash_dump_function)
|
||||
stream->write_function(stream, "Usage: "HASH_DUMP_SYNTAX"\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
if (mode & 1) {
|
||||
switch_thread_rwlock_rdlock(globals.limit_hash_rwlock);
|
||||
for (hi = switch_core_hash_first(globals.limit_hash); hi; hi = switch_core_hash_next(&hi)) {
|
||||
@@ -621,14 +621,14 @@ SWITCH_STANDARD_API(hash_dump_function)
|
||||
switch_ssize_t keylen;
|
||||
limit_hash_item_t *item;
|
||||
switch_core_hash_this(hi, &key, &keylen, &val);
|
||||
|
||||
|
||||
item = (limit_hash_item_t *)val;
|
||||
|
||||
stream->write_function(stream, "L/%s/%d/%d/%d/%d\n", key, item->total_usage, item->rate_usage, item->interval, item->last_check);
|
||||
}
|
||||
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
|
||||
}
|
||||
|
||||
|
||||
if (mode & 2) {
|
||||
switch_thread_rwlock_rdlock(globals.db_hash_rwlock);
|
||||
for (hi = switch_core_hash_first(globals.db_hash); hi; hi = switch_core_hash_next(&hi)) {
|
||||
@@ -646,7 +646,7 @@ SWITCH_STANDARD_API(hash_dump_function)
|
||||
}
|
||||
switch_thread_rwlock_unlock(globals.db_hash_rwlock);
|
||||
}
|
||||
|
||||
|
||||
done:
|
||||
switch_safe_free(mydata);
|
||||
switch_safe_free(realmvalue);
|
||||
@@ -655,38 +655,38 @@ SWITCH_STANDARD_API(hash_dump_function)
|
||||
}
|
||||
|
||||
#define HASH_REMOTE_SYNTAX "list|kill [name]|rescan"
|
||||
SWITCH_STANDARD_API(hash_remote_function)
|
||||
SWITCH_STANDARD_API(hash_remote_function)
|
||||
{
|
||||
//int argc;
|
||||
char *argv[10];
|
||||
char *dup = NULL;
|
||||
|
||||
|
||||
if (zstr(cmd)) {
|
||||
stream->write_function(stream, "-ERR Usage: "HASH_REMOTE_SYNTAX"\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
dup = strdup(cmd);
|
||||
|
||||
|
||||
switch_split(dup, ' ', argv);
|
||||
if (argv[0] && !strcmp(argv[0], "list")) {
|
||||
switch_hash_index_t *hi;
|
||||
stream->write_function(stream, "Remote connections:\nName\t\t\tState\n");
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
|
||||
for (hi = switch_core_hash_first(globals.remote_hash); hi; hi = switch_core_hash_next(&hi)) {
|
||||
void *val;
|
||||
void *val;
|
||||
const void *key;
|
||||
switch_ssize_t keylen;
|
||||
limit_remote_t *item;
|
||||
switch_core_hash_this(hi, &key, &keylen, &val);
|
||||
|
||||
|
||||
item = (limit_remote_t *)val;
|
||||
stream->write_function(stream, "%s\t\t\t%s\n", item->name, state_str(item->state));
|
||||
stream->write_function(stream, "%s\t\t\t%s\n", item->name, state_str(item->state));
|
||||
}
|
||||
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
|
||||
|
||||
} else if (argv[0] && !strcmp(argv[0], "kill")) {
|
||||
const char *name = argv[1];
|
||||
limit_remote_t *remote;
|
||||
@@ -697,15 +697,15 @@ SWITCH_STANDARD_API(hash_remote_function)
|
||||
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
|
||||
remote = switch_core_hash_find(globals.remote_hash, name);
|
||||
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
|
||||
|
||||
|
||||
if (remote) {
|
||||
limit_remote_destroy(&remote);
|
||||
|
||||
switch_thread_rwlock_wrlock(globals.remote_hash_rwlock);
|
||||
switch_core_hash_delete(globals.remote_hash, name);
|
||||
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
|
||||
|
||||
stream->write_function(stream, "+OK\n");
|
||||
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such remote instance %s\n", name);
|
||||
}
|
||||
@@ -714,9 +714,9 @@ SWITCH_STANDARD_API(hash_remote_function)
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR Usage: "HASH_REMOTE_SYNTAX"\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
done:
|
||||
|
||||
switch_safe_free(dup);
|
||||
@@ -724,11 +724,11 @@ done:
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
limit_remote_t *limit_remote_create(const char *name, const char *host, uint16_t port, const char *username, const char *password, int interval)
|
||||
limit_remote_t *limit_remote_create(const char *name, const char *host, uint16_t port, const char *username, const char *password, int interval)
|
||||
{
|
||||
limit_remote_t *r;
|
||||
switch_memory_pool_t *pool;
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
|
||||
if (switch_core_hash_find(globals.remote_hash, name)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Already have a remote instance named %s\n", name);
|
||||
@@ -736,11 +736,11 @@ limit_remote_t *limit_remote_create(const char *name, const char *host, uint16_t
|
||||
return NULL;
|
||||
}
|
||||
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
|
||||
|
||||
|
||||
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
r = switch_core_alloc(pool, sizeof(limit_remote_t));
|
||||
r->pool = pool;
|
||||
r->name = switch_core_strdup(r->pool, name);
|
||||
@@ -749,10 +749,10 @@ limit_remote_t *limit_remote_create(const char *name, const char *host, uint16_t
|
||||
r->username = switch_core_strdup(r->pool, username);
|
||||
r->password = switch_core_strdup(r->pool, password);
|
||||
r->interval = interval;
|
||||
|
||||
|
||||
switch_thread_rwlock_create(&r->rwlock, pool);
|
||||
switch_core_hash_init(&r->index);
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
|
||||
switch_core_hash_insert(globals.remote_hash, name, r);
|
||||
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
|
||||
@@ -776,17 +776,17 @@ void limit_remote_destroy(limit_remote_t **r)
|
||||
|
||||
/* Free hashtable data */
|
||||
for (hi = switch_core_hash_first((*r)->index); hi; hi = switch_core_hash_next(&hi)) {
|
||||
void *val;
|
||||
void *val;
|
||||
const void *key;
|
||||
switch_ssize_t keylen;
|
||||
switch_core_hash_this(hi, &key, &keylen, &val);
|
||||
|
||||
free(val);
|
||||
}
|
||||
|
||||
|
||||
switch_thread_rwlock_unlock((*r)->rwlock);
|
||||
switch_thread_rwlock_destroy((*r)->rwlock);
|
||||
|
||||
|
||||
switch_core_destroy_memory_pool(&((*r)->pool));
|
||||
*r = NULL;
|
||||
}
|
||||
@@ -796,21 +796,21 @@ void limit_remote_destroy(limit_remote_t **r)
|
||||
static limit_hash_item_t get_remote_usage(const char *key) {
|
||||
limit_hash_item_t usage = { 0 };
|
||||
switch_hash_index_t *hi;
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
|
||||
for (hi = switch_core_hash_first(globals.remote_hash); hi; hi = switch_core_hash_next(&hi)) {
|
||||
void *val;
|
||||
void *val;
|
||||
const void *hashkey;
|
||||
switch_ssize_t keylen;
|
||||
limit_remote_t *remote;
|
||||
limit_hash_item_t *item;
|
||||
switch_core_hash_this(hi, &hashkey, &keylen, &val);
|
||||
|
||||
|
||||
remote = (limit_remote_t *)val;
|
||||
if (remote->state != REMOTE_UP) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(remote->rwlock);
|
||||
if ((item = switch_core_hash_find(remote->index, key))) {
|
||||
usage.total_usage += item->total_usage;
|
||||
@@ -821,9 +821,9 @@ static limit_hash_item_t get_remote_usage(const char *key) {
|
||||
}
|
||||
switch_thread_rwlock_unlock(remote->rwlock);
|
||||
}
|
||||
|
||||
|
||||
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
|
||||
|
||||
|
||||
return usage;
|
||||
}
|
||||
|
||||
@@ -835,7 +835,7 @@ static void *SWITCH_THREAD_FUNC limit_remote_thread(switch_thread_t *thread, voi
|
||||
if (esl_connect_timeout(&remote->handle, remote->host, (esl_port_t)remote->port, remote->username, remote->password, 5000) == ESL_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected to remote FreeSWITCH (%s) at %s:%d\n",
|
||||
remote->name, remote->host, remote->port);
|
||||
|
||||
|
||||
remote->state = REMOTE_UP;
|
||||
} else {
|
||||
esl_disconnect(&remote->handle);
|
||||
@@ -860,20 +860,20 @@ static void *SWITCH_THREAD_FUNC limit_remote_thread(switch_thread_t *thread, voi
|
||||
switch_time_t now = switch_epoch_time_now(NULL);
|
||||
while (p && *p) {
|
||||
/* We are getting the limit data as:
|
||||
L/key/usage/rate/interval/last_checked
|
||||
L/key/usage/rate/interval/last_checked
|
||||
*/
|
||||
if ((p2 = strchr(p, '\n'))) {
|
||||
*p2++ = '\0';
|
||||
}
|
||||
|
||||
/* Now p points at the beginning of the current line,
|
||||
|
||||
/* Now p points at the beginning of the current line,
|
||||
p2 at the start of the next one */
|
||||
if (*p == 'L') { /* Limit data */
|
||||
char *argv[5];
|
||||
char *argv[5];
|
||||
int argc = switch_split(p+2, '/', argv);
|
||||
|
||||
|
||||
if (argc < 5) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "[%s] Protocol error: missing argument in line: %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "[%s] Protocol error: missing argument in line: %s\n",
|
||||
remote->name, p);
|
||||
} else {
|
||||
limit_hash_item_t *item;
|
||||
@@ -890,11 +890,11 @@ static void *SWITCH_THREAD_FUNC limit_remote_thread(switch_thread_t *thread, voi
|
||||
switch_thread_rwlock_unlock(remote->rwlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
p = p2;
|
||||
}
|
||||
free(data);
|
||||
|
||||
|
||||
/* Now free up anything that wasn't in this update since it means their usage is 0 */
|
||||
switch_thread_rwlock_wrlock(remote->rwlock);
|
||||
switch_core_hash_delete_multi(remote->index, limit_hash_remote_cleanup_callback, (void*)(intptr_t)now);
|
||||
@@ -902,12 +902,12 @@ static void *SWITCH_THREAD_FUNC limit_remote_thread(switch_thread_t *thread, voi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_yield(remote->interval * 1000);
|
||||
}
|
||||
|
||||
|
||||
remote->thread = NULL;
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -927,7 +927,7 @@ static void do_config(switch_bool_t reload)
|
||||
int interval = 0;
|
||||
limit_remote_t *remote;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
|
||||
|
||||
if (reload) {
|
||||
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
|
||||
if (switch_core_hash_find(globals.remote_hash, name)) {
|
||||
@@ -940,15 +940,15 @@ static void do_config(switch_bool_t reload)
|
||||
if (!zstr(szport)) {
|
||||
port = (uint16_t)atoi(szport);
|
||||
}
|
||||
|
||||
|
||||
if (!zstr(szinterval)) {
|
||||
interval = atoi(szinterval);
|
||||
}
|
||||
|
||||
|
||||
remote = limit_remote_create(name, host, port, username, password, interval);
|
||||
|
||||
remote->state = REMOTE_DOWN;
|
||||
|
||||
|
||||
remote->state = REMOTE_DOWN;
|
||||
|
||||
switch_threadattr_create(&thd_attr, remote->pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&remote->thread, thd_attr, limit_remote_thread, remote, remote->pool);
|
||||
@@ -990,24 +990,24 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_hash_load)
|
||||
|
||||
switch_scheduler_add_task(switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL, limit_hash_cleanup_callback, "limit_hash_cleanup", "mod_hash", 0, NULL,
|
||||
SSHF_NONE);
|
||||
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "hash", "Insert into the hashtable", HASH_DESC, hash_function, HASH_USAGE, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC)
|
||||
SWITCH_ADD_API(commands_api_interface, "hash", "hash get/set", hash_api_function, "[insert|delete|select]/<realm>/<key>/<value>");
|
||||
SWITCH_ADD_API(commands_api_interface, "hash_dump", "dump hash/limit_hash data (used for synchronization)", hash_dump_function, HASH_DUMP_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "hash_remote", "hash remote", hash_remote_function, HASH_REMOTE_SYNTAX);
|
||||
|
||||
|
||||
switch_console_set_complete("add hash insert");
|
||||
switch_console_set_complete("add hash delete");
|
||||
switch_console_set_complete("add hash select");
|
||||
|
||||
|
||||
switch_console_set_complete("add hash_remote list");
|
||||
switch_console_set_complete("add hash_remote kill");
|
||||
switch_console_set_complete("add hash_remote rescan");
|
||||
|
||||
|
||||
do_config(SWITCH_FALSE);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1015,25 +1015,25 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
|
||||
{
|
||||
switch_hash_index_t *hi = NULL;
|
||||
switch_bool_t remote_clean = SWITCH_TRUE;
|
||||
|
||||
|
||||
switch_scheduler_del_task_group("mod_hash");
|
||||
|
||||
/* Kill remote connections, destroy needs a wrlock so we unlock after finding a pointer */
|
||||
while(remote_clean) {
|
||||
void *val;
|
||||
void *val;
|
||||
const void *key = NULL;
|
||||
switch_ssize_t keylen;
|
||||
limit_remote_t *item = NULL;
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(globals.remote_hash_rwlock);
|
||||
if ((hi = switch_core_hash_first(globals.remote_hash))) {
|
||||
switch_core_hash_this(hi, &key, &keylen, &val);
|
||||
item = (limit_remote_t *)val;
|
||||
}
|
||||
switch_thread_rwlock_unlock(globals.remote_hash_rwlock);
|
||||
|
||||
if (!item) {
|
||||
remote_clean = SWITCH_FALSE;
|
||||
|
||||
if (!item) {
|
||||
remote_clean = SWITCH_FALSE;
|
||||
} else {
|
||||
limit_remote_destroy(&item);
|
||||
switch_thread_rwlock_wrlock(globals.remote_hash_rwlock);
|
||||
@@ -1044,7 +1044,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
|
||||
|
||||
switch_thread_rwlock_wrlock(globals.limit_hash_rwlock);
|
||||
switch_thread_rwlock_wrlock(globals.db_hash_rwlock);
|
||||
|
||||
|
||||
while ((hi = switch_core_hash_first_iter( globals.limit_hash, hi))) {
|
||||
void *val = NULL;
|
||||
const void *key;
|
||||
@@ -1053,7 +1053,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
|
||||
free(val);
|
||||
switch_core_hash_delete(globals.limit_hash, key);
|
||||
}
|
||||
|
||||
|
||||
while ((hi = switch_core_hash_first_iter( globals.db_hash, hi))) {
|
||||
void *val = NULL;
|
||||
const void *key;
|
||||
@@ -1064,7 +1064,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
|
||||
}
|
||||
|
||||
switch_core_hash_destroy(&globals.limit_hash);
|
||||
switch_core_hash_destroy(&globals.db_hash);
|
||||
switch_core_hash_destroy(&globals.db_hash);
|
||||
switch_core_hash_destroy(&globals.remote_hash);
|
||||
|
||||
switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
|
||||
|
||||
@@ -119,7 +119,7 @@ switch_status_t hiredis_profile_create(hiredis_profile_t **new_profile, char *na
|
||||
{
|
||||
hiredis_profile_t *profile = NULL;
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
|
||||
profile = switch_core_alloc(pool, sizeof(hiredis_profile_t));
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <mod_hiredis.h>
|
||||
|
||||
switch_status_t mod_hiredis_do_config()
|
||||
switch_status_t mod_hiredis_do_config()
|
||||
{
|
||||
char *conf = "hiredis.conf";
|
||||
switch_xml_t xml, cfg, profiles, profile, connections, connection, params, param;
|
||||
@@ -43,7 +43,7 @@ switch_status_t mod_hiredis_do_config()
|
||||
}
|
||||
|
||||
if ( (profiles = switch_xml_child(cfg, "profiles")) != NULL) {
|
||||
for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) {
|
||||
for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) {
|
||||
hiredis_profile_t *new_profile = NULL;
|
||||
uint8_t ignore_connect_fail = 0;
|
||||
uint8_t ignore_error = 0;
|
||||
@@ -79,10 +79,10 @@ switch_status_t mod_hiredis_do_config()
|
||||
|
||||
/* Add connection to profile */
|
||||
if ( (connections = switch_xml_child(profile, "connections")) != NULL) {
|
||||
for (connection = switch_xml_child(connections, "connection"); connection; connection = connection->next) {
|
||||
for (connection = switch_xml_child(connections, "connection"); connection; connection = connection->next) {
|
||||
char *host = NULL, *password = NULL;
|
||||
uint32_t port = 0, timeout_ms = 0, max_connections = 0;
|
||||
|
||||
|
||||
for (param = switch_xml_child(connection, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
if ( !strncmp(var, "hostname", 8) ) {
|
||||
@@ -114,9 +114,9 @@ switch_status_t mod_hiredis_do_config()
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profiles config is missing\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
||||
err:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Configuration failed\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
|
||||
@@ -457,7 +457,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hiredis_shutdown)
|
||||
}
|
||||
|
||||
switch_core_hash_destroy(&(mod_hiredis_globals.profiles));
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,20 +29,20 @@
|
||||
<permission name="set-vars" value="false">
|
||||
<!-- default to "deny" or "allow" -->
|
||||
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
|
||||
<!--
|
||||
<!--
|
||||
<variable-list default="deny">
|
||||
<variable name="caller_id_name"/>
|
||||
<variable name="hangup"/>
|
||||
<variable name="hangup"/>
|
||||
</variable-list>
|
||||
-->
|
||||
</permission>
|
||||
<permission name="get-vars" value="false">
|
||||
<!-- default to "deny" or "allow" -->
|
||||
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
|
||||
<!--
|
||||
<!--
|
||||
<variable-list default="deny">
|
||||
<variable name="caller_id_name"/>
|
||||
<variable name="hangup"/>
|
||||
<variable name="hangup"/>
|
||||
</variable-list>
|
||||
-->
|
||||
</permission>
|
||||
@@ -58,15 +58,15 @@
|
||||
<permission name="expand-vars" value="false">
|
||||
<!-- default to "deny" or "allow" -->
|
||||
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
|
||||
<!--
|
||||
<!--
|
||||
<variable-list default="deny">
|
||||
<variable name="caller_id_name"/>
|
||||
<variable name="hangup"/>
|
||||
<variable name="hangup"/>
|
||||
</variable-list>
|
||||
|
||||
<api-list default="deny">
|
||||
<api name="expr"/>
|
||||
<api name="lua"/>
|
||||
<api name="lua"/>
|
||||
</api-list>
|
||||
-->
|
||||
</permission>
|
||||
@@ -79,11 +79,11 @@
|
||||
<permission name="conference" value="true"/>
|
||||
<permission name="conference-set-profile" value="false"/>
|
||||
</permissions>
|
||||
|
||||
|
||||
<params>
|
||||
<!-- default url can be overridden by app data -->
|
||||
<param name="gateway-url" value="http://www.freeswitch.org/api/index.cgi" />
|
||||
|
||||
|
||||
<!-- set this to provide authentication credentials to the server -->
|
||||
<!--<param name="gateway-credentials" value="muser:mypass"/>-->
|
||||
<!--<param name="auth-scheme" value="basic"/>-->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Raymond Chandler <intralanman@freeswitch.org>
|
||||
* Seven Du <dujinfang@gmail.com>
|
||||
@@ -238,7 +238,7 @@ SWITCH_STANDARD_API(httapi_api_function)
|
||||
static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match)
|
||||
{
|
||||
action_binding_t *action_binding = (action_binding_t *) match->user_data;
|
||||
|
||||
|
||||
action_binding->client->matching_action_binding = action_binding;
|
||||
action_binding->match_digits = switch_core_strdup(action_binding->client->pool, match->match_digits);
|
||||
|
||||
@@ -250,7 +250,7 @@ static switch_status_t digit_nomatch_action_callback(switch_ivr_dmachine_match_t
|
||||
action_binding_t *action_binding = (action_binding_t *) match->user_data;
|
||||
|
||||
action_binding->client->no_matching_action_binding = action_binding;
|
||||
|
||||
|
||||
return SWITCH_STATUS_BREAK;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ static switch_status_t parse_get_var(const char *tag_name, client_t *client, swi
|
||||
}
|
||||
|
||||
|
||||
if (client->profile->perms.get_vars &&
|
||||
if (client->profile->perms.get_vars &&
|
||||
(!client->profile->var_params.get_var_list || switch_event_check_permission_list(client->profile->var_params.get_var_list, var))) {
|
||||
const char *vval = switch_channel_get_variable(client->channel, var);
|
||||
if (vval) {
|
||||
@@ -351,12 +351,12 @@ static switch_status_t parse_get_var(const char *tag_name, client_t *client, swi
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static switch_status_t parse_continue(const char *tag_name, client_t *client, switch_xml_t tag, const char *body)
|
||||
{
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ static switch_status_t parse_log(const char *tag_name, client_t *client, switch_
|
||||
{
|
||||
const char *level = switch_xml_attr(tag, "level");
|
||||
const char *clean = switch_xml_attr(tag, "clean");
|
||||
|
||||
|
||||
if (switch_true(clean)) {
|
||||
console_clean_log(level, body);
|
||||
} else {
|
||||
@@ -414,7 +414,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
say_method = switch_xml_attr(tag, "method");
|
||||
say_gender = switch_xml_attr(tag, "gender");
|
||||
text = switch_xml_attr(tag, "text");
|
||||
|
||||
|
||||
if (zstr(text)) {
|
||||
if (!zstr(file)) {
|
||||
text = file;
|
||||
@@ -427,9 +427,9 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "speak: missing required attributes or text! (language) (type) (method) \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
say = 1;
|
||||
|
||||
|
||||
} else if (!strcasecmp(tag_name, "speak")) {
|
||||
tts_engine = switch_xml_attr(tag, "engine");
|
||||
tts_voice = switch_xml_attr(tag, "voice");
|
||||
@@ -470,7 +470,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
char *p;
|
||||
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
|
||||
cmd = switch_mprintf("%s|name_path", id);
|
||||
|
||||
switch_api_execute("vm_prefs", cmd, NULL, &stream);
|
||||
@@ -501,7 +501,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
|
||||
text = free_string;
|
||||
switch_ivr_play_file(client->session, NULL, "voicemail/vm-person.wav", &nullargs);
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch_safe_free(resp);
|
||||
@@ -527,7 +527,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid digit timeout [%s]\n", digit_timeout_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (input_timeout_) {
|
||||
tmp = atol(input_timeout_);
|
||||
|
||||
@@ -541,7 +541,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
if ((bind = switch_xml_child(tag, "bind"))) {
|
||||
action_binding_t *action_binding;
|
||||
const char *realm = "default";
|
||||
|
||||
|
||||
|
||||
input++;
|
||||
|
||||
@@ -550,9 +550,9 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
top_action_binding->action = (char *) action;
|
||||
top_action_binding->error_file = (char *)error_file;
|
||||
|
||||
switch_ivr_dmachine_create(&dmachine, "HTTAPI", NULL, digit_timeout, 0,
|
||||
switch_ivr_dmachine_create(&dmachine, "HTTAPI", NULL, digit_timeout, 0,
|
||||
NULL, digit_nomatch_action_callback, top_action_binding);
|
||||
|
||||
|
||||
while(bind) {
|
||||
action_binding = switch_core_session_alloc(client->session, sizeof(*action_binding));
|
||||
action_binding->realm = (char *) realm;
|
||||
@@ -562,11 +562,11 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
action_binding->strip = (char *) switch_xml_attr(bind, "strip");
|
||||
action_binding->error_file = (char *) error_file;
|
||||
action_binding->parent = top_action_binding;
|
||||
|
||||
|
||||
switch_ivr_dmachine_bind(dmachine, action_binding->realm, action_binding->input, 0, 0, digit_action_callback, action_binding);
|
||||
bind = bind->next;
|
||||
}
|
||||
|
||||
|
||||
switch_ivr_dmachine_set_realm(dmachine, realm);
|
||||
if (!zstr(terminators)) {
|
||||
switch_ivr_dmachine_set_terminators(dmachine, terminators);
|
||||
@@ -597,7 +597,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
char *result = NULL;
|
||||
|
||||
status = switch_ivr_play_and_detect_speech(client->session, file, sp_engine, sp_grammar, &result, input_timeout, args);
|
||||
|
||||
|
||||
if (!zstr(result)) {
|
||||
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, name, result);
|
||||
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "input_type", "detected_speech");
|
||||
@@ -642,7 +642,7 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
break;
|
||||
}
|
||||
} while (loops-- > 0);
|
||||
|
||||
|
||||
|
||||
if (submit) {
|
||||
if (client->matching_action_binding) {
|
||||
@@ -660,26 +660,26 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, name, client->matching_action_binding->match_digits);
|
||||
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "input_type", "dtmf");
|
||||
}
|
||||
|
||||
|
||||
if (client->matching_action_binding->action) {
|
||||
sub_action = client->matching_action_binding->action;
|
||||
} else if (client->matching_action_binding->parent && client->matching_action_binding->parent->action) {
|
||||
sub_action = client->matching_action_binding->parent->action;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!sub_action && top_action_binding && top_action_binding->action) {
|
||||
sub_action = top_action_binding->action;
|
||||
}
|
||||
|
||||
|
||||
if (sub_action && client->matching_action_binding && client->matching_action_binding->match_digits) {
|
||||
if (!strncasecmp(sub_action, "dial:", 5)) {
|
||||
char *context = NULL;
|
||||
char *dp = NULL;
|
||||
|
||||
|
||||
if (client->profile->perms.dial.set_context) {
|
||||
context = switch_core_session_strdup(client->session, sub_action + 5);
|
||||
|
||||
|
||||
if ((dp = strchr(context, ':'))) {
|
||||
*dp++ = '\0';
|
||||
if (!client->profile->perms.dial.set_dp) {
|
||||
@@ -690,19 +690,19 @@ static switch_status_t parse_playback(const char *tag_name, client_t *client, sw
|
||||
|
||||
switch_ivr_session_transfer(client->session, client->matching_action_binding->match_digits, dp, context);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
|
||||
|
||||
} else {
|
||||
switch_event_add_header_string(client->params, SWITCH_STACK_BOTTOM, "url", sub_action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (dmachine) {
|
||||
switch_ivr_dmachine_destroy(&dmachine);
|
||||
}
|
||||
|
||||
switch_safe_free(free_string);
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ static switch_status_t parse_conference(const char *tag_name, client_t *client,
|
||||
const char *profile_name = switch_xml_attr(tag, "profile");
|
||||
const char *pin = switch_xml_attr(tag, "pin");
|
||||
const char *flags = switch_xml_attr(tag, "flags");
|
||||
|
||||
|
||||
if (!client->profile->perms.conference.enabled) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Permission Denied!\n");
|
||||
switch_channel_hangup(client->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
@@ -742,7 +742,7 @@ static switch_status_t parse_conference(const char *tag_name, client_t *client,
|
||||
|
||||
static switch_status_t parse_dial(const char *tag_name, client_t *client, switch_xml_t tag, const char *body)
|
||||
{
|
||||
const char *context = NULL;
|
||||
const char *context = NULL;
|
||||
const char *dp = NULL;
|
||||
const char *cid_name = NULL;
|
||||
const char *cid_number = NULL;
|
||||
@@ -779,7 +779,7 @@ static switch_status_t parse_dial(const char *tag_name, client_t *client, switch
|
||||
cid_number = switch_channel_get_variable(client->channel, "caller_id_number");
|
||||
}
|
||||
|
||||
str = switch_core_session_sprintf(client->session,
|
||||
str = switch_core_session_sprintf(client->session,
|
||||
"{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s", cid_name, cid_number, body);
|
||||
|
||||
switch_core_session_execute_application(client->session, "bridge", str);
|
||||
@@ -812,7 +812,7 @@ static switch_status_t parse_sms(const char *tag_name, client_t *client, switch_
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", switch_channel_get_variable(client->channel, "caller_id_number"));
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", to);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
|
||||
|
||||
|
||||
if (body) {
|
||||
switch_event_add_body(event, "%s", body);
|
||||
}
|
||||
@@ -856,7 +856,7 @@ static switch_status_t parse_execute(const char *tag_name, client_t *client, swi
|
||||
|
||||
if (!client->profile->perms.expand_vars) {
|
||||
const char *p;
|
||||
|
||||
|
||||
for(p = data; p && *p; p++) {
|
||||
if (*p == '$') {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Expand Variables: Permission Denied!\n");
|
||||
@@ -929,16 +929,16 @@ static switch_status_t parse_record_call(const char *tag_name, client_t *client,
|
||||
} else {
|
||||
client->record.action = (char *) action;
|
||||
client->record.name = (char *)name;
|
||||
client->record.file = switch_core_session_sprintf(client->session, "%s%s%s.wav",
|
||||
client->record.file = switch_core_session_sprintf(client->session, "%s%s%s.wav",
|
||||
SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(client->session));
|
||||
record_file = client->record.file;
|
||||
}
|
||||
|
||||
|
||||
if (limit_) {
|
||||
limit = atoi(limit_);
|
||||
if (limit < 0) limit = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_ivr_record_session(client->session, (char *)record_file, limit, NULL);
|
||||
|
||||
@@ -982,7 +982,7 @@ static switch_status_t parse_record(const char *tag_name, client_t *client, swit
|
||||
if (zstr(file)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
fname = switch_core_strdup(client->pool, file);
|
||||
|
||||
for(p = fname; p && *p; p++) {
|
||||
@@ -1006,7 +1006,7 @@ static switch_status_t parse_record(const char *tag_name, client_t *client, swit
|
||||
tmp_record_path = fname;
|
||||
http = 1;
|
||||
} else {
|
||||
tmp_record_path = switch_core_sprintf(client->pool, "%s%s%s_%s.%s",
|
||||
tmp_record_path = switch_core_sprintf(client->pool, "%s%s%s_%s.%s",
|
||||
SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str, fname, ext);
|
||||
}
|
||||
|
||||
@@ -1045,19 +1045,19 @@ static switch_status_t parse_record(const char *tag_name, client_t *client, swit
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid digit timeout [%s]\n", digit_timeout_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((bind = switch_xml_child(tag, "bind"))) {
|
||||
action_binding_t *action_binding;
|
||||
const char *realm = "default";
|
||||
|
||||
|
||||
top_action_binding = switch_core_session_alloc(client->session, sizeof(*action_binding));
|
||||
top_action_binding->client = client;
|
||||
top_action_binding->action = (char *) action;
|
||||
top_action_binding->error_file = (char *)error_file;
|
||||
|
||||
switch_ivr_dmachine_create(&dmachine, "HTTAPI", NULL, digit_timeout, 0,
|
||||
switch_ivr_dmachine_create(&dmachine, "HTTAPI", NULL, digit_timeout, 0,
|
||||
NULL, digit_nomatch_action_callback, top_action_binding);
|
||||
|
||||
|
||||
while(bind) {
|
||||
action_binding = switch_core_session_alloc(client->session, sizeof(*action_binding));
|
||||
action_binding->realm = (char *) realm;
|
||||
@@ -1066,11 +1066,11 @@ static switch_status_t parse_record(const char *tag_name, client_t *client, swit
|
||||
action_binding->action = (char *) switch_xml_attr(bind, "action");
|
||||
action_binding->error_file = (char *) error_file;
|
||||
action_binding->parent = top_action_binding;
|
||||
|
||||
|
||||
switch_ivr_dmachine_bind(dmachine, action_binding->realm, action_binding->input, 0, 0, digit_action_callback, action_binding);
|
||||
bind = bind->next;
|
||||
}
|
||||
|
||||
|
||||
switch_ivr_dmachine_set_realm(dmachine, realm);
|
||||
if (!zstr(terminators)) {
|
||||
switch_ivr_dmachine_set_terminators(dmachine, terminators);
|
||||
@@ -1092,7 +1092,7 @@ static switch_status_t parse_record(const char *tag_name, client_t *client, swit
|
||||
switch_file_handle_t fh = { 0 };
|
||||
fh.thresh = thresh;
|
||||
fh.silence_hits = silence_hits;
|
||||
|
||||
|
||||
status = switch_ivr_record_file(client->session, &fh, tmp_record_path, args, record_limit);
|
||||
}
|
||||
|
||||
@@ -1142,7 +1142,7 @@ static switch_status_t parse_common(const char *tag_name, client_t *client, swit
|
||||
if (tmp_action) {
|
||||
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "url", tmp_action);
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1155,7 +1155,7 @@ static switch_status_t parse_xml(client_t *client)
|
||||
|
||||
if ((len = switch_buffer_peek_zerocopy(client->buffer, &bdata)) && switch_buffer_len(client->buffer) > len) {
|
||||
switch_xml_t xml, tag, category;
|
||||
|
||||
|
||||
if (globals.debug) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Debugging Return Data:\n%s\n", (char *)bdata);
|
||||
}
|
||||
@@ -1165,7 +1165,7 @@ static switch_status_t parse_xml(client_t *client)
|
||||
if (client->profile->perms.set_params) {
|
||||
if ((category = switch_xml_child(xml, "params"))) {
|
||||
tag = category->child;
|
||||
|
||||
|
||||
while(tag) {
|
||||
if (!zstr(tag->name)) {
|
||||
char *val = tag->txt;
|
||||
@@ -1182,7 +1182,7 @@ static switch_status_t parse_xml(client_t *client)
|
||||
if (client->profile->perms.set_vars) {
|
||||
if ((category = switch_xml_child(xml, "variables"))) {
|
||||
tag = category->child;
|
||||
|
||||
|
||||
while(tag) {
|
||||
if (!zstr(tag->name)) {
|
||||
char *val = tag->txt;
|
||||
@@ -1190,8 +1190,8 @@ static switch_status_t parse_xml(client_t *client)
|
||||
val = NULL;
|
||||
}
|
||||
|
||||
if (client->profile->perms.set_vars &&
|
||||
(!client->profile->var_params.set_var_list ||
|
||||
if (client->profile->perms.set_vars &&
|
||||
(!client->profile->var_params.set_var_list ||
|
||||
switch_event_check_permission_list(client->profile->var_params.set_var_list, tag->name))) {
|
||||
switch_channel_set_variable(client->channel, tag->name, val);
|
||||
} else {
|
||||
@@ -1204,7 +1204,7 @@ static switch_status_t parse_xml(client_t *client)
|
||||
}
|
||||
|
||||
if ((category = switch_xml_child(xml, "work"))) {
|
||||
|
||||
|
||||
tag = category->child;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -1219,18 +1219,18 @@ static switch_status_t parse_xml(client_t *client)
|
||||
if (tag->txt && client->profile->perms.expand_vars) {
|
||||
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,
|
||||
expanded = switch_event_expand_headers_check(templ_data, tag->txt,
|
||||
client->profile->var_params.expand_var_list,
|
||||
client->profile->var_params.api_list, 0);
|
||||
switch_event_destroy(&templ_data);
|
||||
}
|
||||
|
||||
runs++;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Process Tag: [%s]\n", tag->name);
|
||||
|
||||
|
||||
parse_common(tag->name, client, tag, expanded);
|
||||
status = handler(tag->name, client, tag, expanded);
|
||||
|
||||
|
||||
if (expanded && expanded != tag->txt) {
|
||||
free(expanded);
|
||||
}
|
||||
@@ -1249,15 +1249,15 @@ static switch_status_t parse_xml(client_t *client)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No instructions found in result!\n");
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static size_t get_header_callback(void *ptr, size_t size, size_t nmemb, void *userdata)
|
||||
{
|
||||
@@ -1285,7 +1285,7 @@ static size_t get_header_callback(void *ptr, size_t size, size_t nmemb, void *us
|
||||
|
||||
switch_event_add_header_string(client->headers, SWITCH_STACK_BOTTOM, header, val);
|
||||
}
|
||||
|
||||
|
||||
switch_safe_free(header);
|
||||
return realsize;
|
||||
}
|
||||
@@ -1305,7 +1305,7 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
}
|
||||
|
||||
switch_buffer_write(client->buffer, ptr, realsize);
|
||||
|
||||
|
||||
return realsize;
|
||||
}
|
||||
|
||||
@@ -1313,7 +1313,7 @@ static void client_destroy(client_t **client)
|
||||
{
|
||||
if (client && *client) {
|
||||
switch_memory_pool_t *pool;
|
||||
|
||||
|
||||
switch_event_destroy(&(*client)->headers);
|
||||
switch_event_destroy(&(*client)->params);
|
||||
switch_event_destroy(&(*client)->one_time_params);
|
||||
@@ -1333,7 +1333,7 @@ static void client_reset(client_t *client)
|
||||
switch_event_destroy(&client->one_time_params);
|
||||
switch_event_create(&client->one_time_params, SWITCH_EVENT_CLONE);
|
||||
client->one_time_params->flags |= EF_UNIQ_HEADERS;
|
||||
|
||||
|
||||
switch_event_create(&client->headers, SWITCH_EVENT_CLONE);
|
||||
|
||||
|
||||
@@ -1367,13 +1367,13 @@ static client_t *client_create(switch_core_session_t *session, const char *profi
|
||||
client->pool = pool;
|
||||
|
||||
switch_event_create(&client->headers, SWITCH_EVENT_CLONE);
|
||||
|
||||
|
||||
if (session) {
|
||||
client->session = session;
|
||||
client->channel = switch_core_session_get_channel(session);
|
||||
}
|
||||
|
||||
|
||||
|
||||
client->profile = profile;
|
||||
|
||||
client->max_bytes = HTTAPI_MAX_API_BYTES;
|
||||
@@ -1406,7 +1406,7 @@ static void cleanup_attachments(client_t *client)
|
||||
if (switch_file_exists(hp->value, client->pool) == SWITCH_STATUS_SUCCESS) {
|
||||
unlink(hp->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1416,7 +1416,7 @@ size_t put_file_read( void *ptr, size_t size, size_t nmemb, void *userdata)
|
||||
}
|
||||
|
||||
static switch_status_t httapi_sync(client_t *client)
|
||||
|
||||
|
||||
{
|
||||
switch_CURL *curl_handle = NULL;
|
||||
char *data = NULL;
|
||||
@@ -1433,7 +1433,7 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
FILE *fd = NULL;
|
||||
char *creds, *dup_creds = NULL, *ua = NULL;
|
||||
|
||||
|
||||
|
||||
if (client->one_time_params && client->one_time_params->headers) {
|
||||
save_params = client->params;
|
||||
switch_event_dup(&client->params, save_params);
|
||||
@@ -1449,7 +1449,7 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
if (zstr(ua)) {
|
||||
ua = client->profile->ua;
|
||||
}
|
||||
|
||||
|
||||
if (!(session_id = switch_event_get_header(client->params, "HTTAPI_SESSION_ID"))) {
|
||||
if (client->channel && !(session_id = switch_channel_get_variable(client->channel, "HTTAPI_SESSION_ID"))) {
|
||||
session_id = switch_core_session_get_uuid(client->session);
|
||||
@@ -1471,7 +1471,7 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
}
|
||||
|
||||
get_style_method = method ? strcasecmp(method, "post") : 1;
|
||||
|
||||
|
||||
switch_event_add_header_string(client->params, SWITCH_STACK_TOP, "session_id", session_id);
|
||||
|
||||
dynamic_url = switch_event_expand_headers(client->params, url);
|
||||
@@ -1484,7 +1484,7 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
}
|
||||
|
||||
if (!put_file) {
|
||||
switch_curl_process_form_post_params(client->params, curl_handle, &formpost);
|
||||
switch_curl_process_form_post_params(client->params, curl_handle, &formpost);
|
||||
}
|
||||
|
||||
if (formpost) {
|
||||
@@ -1495,11 +1495,11 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
|
||||
if (get_style_method) {
|
||||
char *tmp = switch_mprintf("%s%c%s", dynamic_url, strchr(dynamic_url, '?') != NULL ? '&' : '?', data);
|
||||
|
||||
|
||||
if (dynamic_url != url) {
|
||||
free(dynamic_url);
|
||||
}
|
||||
|
||||
|
||||
dynamic_url = tmp;
|
||||
}
|
||||
}
|
||||
@@ -1525,7 +1525,7 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
if ((p = strstr(q, "://"))) {
|
||||
*(p+3) = '\0';
|
||||
}
|
||||
|
||||
|
||||
p = switch_mprintf("%s%s", q, r);
|
||||
if (p) {
|
||||
free(dynamic_url);
|
||||
@@ -1546,9 +1546,9 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
*p = '\0';
|
||||
|
||||
if ((q = strchr(dup_creds, '@'))) *q = '\0';
|
||||
|
||||
|
||||
creds = dup_creds;
|
||||
|
||||
|
||||
p = switch_mprintf("%s%s", p, use_url);
|
||||
free(dynamic_url);
|
||||
dynamic_url = p;
|
||||
@@ -1593,7 +1593,7 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_READDATA, fd);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, put_file_read);
|
||||
|
||||
|
||||
} else if (formpost) {
|
||||
curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, formpost);
|
||||
} else {
|
||||
@@ -1646,7 +1646,7 @@ static switch_status_t httapi_sync(client_t *client)
|
||||
} else {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (client->profile->ssl_cacert_file) {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_CAINFO, client->profile->ssl_cacert_file);
|
||||
@@ -1891,7 +1891,7 @@ static switch_status_t do_config(void)
|
||||
profile->perms.set_params = 1;
|
||||
profile->perms.conference.enabled = 1;
|
||||
profile->perms.dial.enabled = 1;
|
||||
|
||||
|
||||
|
||||
if ((tag = switch_xml_child(profile_tag, "conference"))) {
|
||||
for (param = switch_xml_child(tag, "param"); param; param = param->next) {
|
||||
@@ -1937,7 +1937,7 @@ static switch_status_t do_config(void)
|
||||
switch_xml_t x_list, x_var;
|
||||
if ((x_list = switch_xml_child(param, "variable-list"))) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "default");
|
||||
|
||||
|
||||
profile->var_params.default_allow = (var && !strcasecmp(var, "allow"));
|
||||
switch_event_create(&profile->var_params.set_var_list, SWITCH_EVENT_CLONE);
|
||||
profile->var_params.set_var_list->flags |= EF_UNIQ_HEADERS;
|
||||
@@ -1965,7 +1965,7 @@ static switch_status_t do_config(void)
|
||||
switch_xml_t x_list, x_var;
|
||||
if ((x_list = switch_xml_child(param, "variable-list"))) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "default");
|
||||
|
||||
|
||||
profile->var_params.default_allow = (var && !strcasecmp(var, "allow"));
|
||||
switch_event_create(&profile->var_params.get_var_list, SWITCH_EVENT_CLONE);
|
||||
profile->var_params.get_var_list->flags |= EF_UNIQ_HEADERS;
|
||||
@@ -1990,12 +1990,12 @@ static switch_status_t do_config(void)
|
||||
profile->perms.extended_data = switch_true_byte(val);
|
||||
} else if (!strcasecmp(var, "execute-apps")) {
|
||||
profile->perms.execute_apps = switch_true_byte(val);
|
||||
|
||||
|
||||
if (profile->perms.execute_apps) {
|
||||
switch_xml_t x_list, x_app;
|
||||
if ((x_list = switch_xml_child(param, "application-list"))) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "default");
|
||||
|
||||
|
||||
profile->dial_params.default_allow = (var && !strcasecmp(var, "allow"));
|
||||
switch_event_create(&profile->dial_params.app_list, SWITCH_EVENT_CLONE);
|
||||
profile->dial_params.app_list->flags |= EF_UNIQ_HEADERS;
|
||||
@@ -2016,7 +2016,7 @@ static switch_status_t do_config(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else if (!strcasecmp(var, "expand-vars")) {
|
||||
profile->perms.expand_vars = switch_true_byte(val);
|
||||
|
||||
@@ -2024,7 +2024,7 @@ static switch_status_t do_config(void)
|
||||
switch_xml_t x_list, x_var, x_api;
|
||||
if ((x_list = switch_xml_child(param, "variable-list"))) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "default");
|
||||
|
||||
|
||||
profile->var_params.default_allow = (var && !strcasecmp(var, "allow"));
|
||||
switch_event_create(&profile->var_params.expand_var_list, SWITCH_EVENT_CLONE);
|
||||
profile->var_params.expand_var_list->flags |= EF_UNIQ_HEADERS;
|
||||
@@ -2047,7 +2047,7 @@ static switch_status_t do_config(void)
|
||||
|
||||
if ((x_list = switch_xml_child(param, "api-list"))) {
|
||||
char *api = (char *) switch_xml_attr_soft(param, "default");
|
||||
|
||||
|
||||
profile->var_params.default_allow = (api && !strcasecmp(api, "allow"));
|
||||
switch_event_create(&profile->var_params.api_list, SWITCH_EVENT_CLONE);
|
||||
profile->var_params.api_list->flags |= EF_UNIQ_HEADERS;
|
||||
@@ -2202,7 +2202,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
}
|
||||
|
||||
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "exiting", "true");
|
||||
|
||||
|
||||
if (client->record.file) {
|
||||
char *key = switch_core_sprintf(client->pool, "attach_file:%s:%s.wav", client->record.name, switch_core_session_get_uuid(session));
|
||||
switch_ivr_stop_record_session(client->session, client->record.file);
|
||||
@@ -2221,7 +2221,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
|
||||
switch_event_add_header_string(client->one_time_params, SWITCH_STACK_BOTTOM, "exiting", "true");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
httapi_sync(client);
|
||||
|
||||
client_destroy(&client);
|
||||
@@ -2264,7 +2264,7 @@ SWITCH_STANDARD_APP(httapi_function)
|
||||
} else {
|
||||
url = data;
|
||||
}
|
||||
|
||||
|
||||
if (!zstr(url) && switch_stristr("://", url)) {
|
||||
if (!params) {
|
||||
switch_event_create(¶ms, SWITCH_EVENT_CLONE);
|
||||
@@ -2288,7 +2288,7 @@ SWITCH_STANDARD_APP(httapi_function)
|
||||
if (zstr(profile_name) && !(profile_name = switch_channel_get_variable(channel, "httapi_profile"))) {
|
||||
profile_name = "default";
|
||||
}
|
||||
|
||||
|
||||
if ((client = client_create(session, profile_name, ¶ms))) {
|
||||
switch_channel_set_private(channel, "_HTTAPI_CLIENT_", client);
|
||||
switch_channel_add_state_handler(channel, &state_handlers);
|
||||
@@ -2346,7 +2346,7 @@ SWITCH_STANDARD_APP(httapi_function)
|
||||
|
||||
|
||||
switch_safe_free(parsed);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2355,7 +2355,7 @@ SWITCH_STANDARD_APP(httapi_function)
|
||||
static const char *find_ext(const char *in)
|
||||
{
|
||||
const char *p = in + (strlen(in) - 1);
|
||||
|
||||
|
||||
while(p >= in && *p) {
|
||||
if (*p == '/') return NULL;
|
||||
if (*p == '.') return (p+1);
|
||||
@@ -2379,11 +2379,11 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
|
||||
if (context->url_params) {
|
||||
ext = switch_event_get_header(context->url_params, "ext");
|
||||
}
|
||||
|
||||
|
||||
if (zstr(ext)) {
|
||||
ext = find_ext(url);
|
||||
}
|
||||
|
||||
|
||||
if (ext && (p = strchr(ext, '?'))) {
|
||||
dext = strdup(ext);
|
||||
if ((p = strchr(dext, '?'))) {
|
||||
@@ -2432,7 +2432,7 @@ static size_t save_file_callback(void *ptr, size_t size, size_t nmemb, void *dat
|
||||
unsigned char *buffer = (unsigned char *) ptr;
|
||||
|
||||
client->bytes += realsize;
|
||||
|
||||
|
||||
if (client->bytes > client->max_bytes) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) client->bytes);
|
||||
client->err = 1;
|
||||
@@ -2468,14 +2468,14 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char
|
||||
const char *profile_name = NULL;
|
||||
int tries = 10;
|
||||
|
||||
if (context->url_params) {
|
||||
if (context->url_params) {
|
||||
profile_name = switch_event_get_header(context->url_params, "profile_name");
|
||||
}
|
||||
|
||||
if (zstr(profile_name)) {
|
||||
if (globals.profile) profile_name = globals.profile->name;
|
||||
}
|
||||
|
||||
|
||||
if (zstr(profile_name)) {
|
||||
profile_name = "default";
|
||||
}
|
||||
@@ -2500,7 +2500,7 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char
|
||||
if (context->url_params) {
|
||||
ua = switch_event_get_header(context->url_params, "user_agent");
|
||||
}
|
||||
|
||||
|
||||
if (zstr(ua)) {
|
||||
ua = "mod_httapi/1.0";
|
||||
}
|
||||
@@ -2520,7 +2520,7 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char
|
||||
if ((p = strstr(q, "://"))) {
|
||||
*(p+3) = '\0';
|
||||
}
|
||||
|
||||
|
||||
p = switch_mprintf("%s%s", q, r);
|
||||
dynamic_url = p;
|
||||
free(q);
|
||||
@@ -2617,12 +2617,12 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_USERPWD, dup_creds);
|
||||
}
|
||||
|
||||
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, ua);
|
||||
switch_curl_easy_perform(curl_handle);
|
||||
switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &code);
|
||||
switch_curl_easy_cleanup(curl_handle);
|
||||
|
||||
|
||||
if (client->fd > -1) {
|
||||
close(client->fd);
|
||||
client->fd = -1;
|
||||
@@ -2645,7 +2645,7 @@ static switch_status_t fetch_cache_data(http_file_context_t *context, const char
|
||||
case 404:
|
||||
status = SWITCH_STATUS_NOTFOUND;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
break;
|
||||
@@ -2695,7 +2695,7 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char
|
||||
} else if (headers && (cc = switch_event_get_header(headers, "Cache-Control"))) {
|
||||
if ((p = switch_stristr("max-age=", cc))) {
|
||||
p += 8;
|
||||
|
||||
|
||||
if (!zstr(p)) {
|
||||
x = atoi(p);
|
||||
|
||||
@@ -2710,11 +2710,11 @@ static switch_status_t write_meta_file(http_file_context_t *context, const char
|
||||
}
|
||||
}
|
||||
|
||||
switch_snprintf(write_data, sizeof(write_data),
|
||||
switch_snprintf(write_data, sizeof(write_data),
|
||||
"%" TIME_T_FMT ":%s",
|
||||
switch_epoch_time_now(NULL) + ttl,
|
||||
data);
|
||||
|
||||
|
||||
|
||||
status = write(fd, write_data, (int)strlen(write_data) + 1) > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -2737,7 +2737,7 @@ static void lock_file(http_file_context_t *context, switch_bool_t lock)
|
||||
switch_yield(100000);
|
||||
}
|
||||
} while(x);
|
||||
|
||||
|
||||
switch_core_hash_insert(globals.request_hash, context->dest_url, (void *)1);
|
||||
switch_mutex_unlock(globals.request_mutex);
|
||||
} else {
|
||||
@@ -2768,7 +2768,7 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
|
||||
if (context->url_params) {
|
||||
ext = switch_event_get_header(context->url_params, "ext");
|
||||
}
|
||||
|
||||
|
||||
if (zstr(ext)) {
|
||||
ext = find_ext(context->cache_file);
|
||||
}
|
||||
@@ -2787,7 +2787,7 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
|
||||
unreachable = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (zstr(ext) && headers && (ct = switch_event_get_header(headers, "content-type"))) {
|
||||
newext = switch_core_mime_type2ext(ct);
|
||||
}
|
||||
@@ -2803,7 +2803,7 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
|
||||
status = SWITCH_STATUS_NOTFOUND;
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (!unreachable && !zstr(context->metadata)) {
|
||||
metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s:%s",
|
||||
url,
|
||||
@@ -2818,7 +2818,7 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
|
||||
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_event_destroy(&headers);
|
||||
}
|
||||
|
||||
@@ -2836,9 +2836,9 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
|
||||
switch_event_get_header_nil(headers, "content-length"),
|
||||
ext
|
||||
);
|
||||
|
||||
|
||||
write_meta_file(context, metadata, headers);
|
||||
|
||||
|
||||
if (switch_file_exists(context->cache_file, context->pool) == SWITCH_STATUS_SUCCESS) {
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -2851,7 +2851,7 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
|
||||
}
|
||||
|
||||
switch_event_destroy(&headers);
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2916,21 +2916,21 @@ static switch_status_t file_open(switch_file_handle_t *handle, const char *path,
|
||||
context->fh.samples = handle->samples;
|
||||
context->fh.samplerate = handle->samplerate;
|
||||
context->fh.prefix = handle->prefix;
|
||||
|
||||
|
||||
|
||||
|
||||
if (context->url_params) {
|
||||
context->write.file_name = switch_event_get_header(context->url_params, "file");
|
||||
context->write.profile_name = switch_event_get_header(context->url_params, "profile");
|
||||
context->write.method = switch_event_get_header(context->url_params, "method");
|
||||
context->write.name = switch_event_get_header(context->url_params, "name");
|
||||
}
|
||||
|
||||
|
||||
if (!context->write.file_name) {
|
||||
char *p;
|
||||
if ((p = strrchr(context->dest_url, '/'))) {
|
||||
p++;
|
||||
context->write.file_name = switch_core_strdup(context->pool, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!context->write.file_name) {
|
||||
@@ -2943,16 +2943,16 @@ static switch_status_t file_open(switch_file_handle_t *handle, const char *path,
|
||||
} else {
|
||||
ext = "wav";
|
||||
}
|
||||
|
||||
|
||||
if (!context->write.profile_name) context->write.profile_name = "default";
|
||||
if (!context->write.method) context->write.method = !strcasecmp(ext, "cgi") ? "post" : "put";
|
||||
if (!context->write.name) context->write.name = "recorded_file";
|
||||
|
||||
switch_uuid_str(context->write.uuid_str, sizeof(context->write.uuid_str));
|
||||
|
||||
|
||||
context->write.file = switch_core_sprintf(context->pool, "%s%s%s_%s",
|
||||
SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, context->write.uuid_str, context->write.file_name);
|
||||
|
||||
|
||||
|
||||
if (switch_core_file_open(&context->fh, context->write.file, handle->channels, handle->samplerate, handle->flags, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_GENERR;
|
||||
@@ -2971,11 +2971,11 @@ static switch_status_t file_open(switch_file_handle_t *handle, const char *path,
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
if ((status = switch_core_file_open(&context->fh,
|
||||
context->cache_file,
|
||||
handle->channels,
|
||||
handle->samplerate,
|
||||
context->cache_file,
|
||||
handle->channels,
|
||||
handle->samplerate,
|
||||
handle->flags, NULL)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid cache file %s opening url %s Discarding file.\n", context->cache_file, path);
|
||||
unlink(context->cache_file);
|
||||
@@ -3051,12 +3051,12 @@ static switch_status_t http_file_file_close(switch_file_handle_t *handle)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find suitable profile\n");
|
||||
switch_event_destroy(¶ms);
|
||||
}
|
||||
|
||||
|
||||
unlink(context->write.file);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (context->del_on_close) {
|
||||
if (context->cache_file) {
|
||||
unlink(context->cache_file);
|
||||
@@ -3075,7 +3075,7 @@ static switch_status_t http_file_file_close(switch_file_handle_t *handle)
|
||||
static switch_status_t http_file_read_video(switch_file_handle_t *handle, switch_frame_t *frame, switch_video_read_flag_t flags)
|
||||
{
|
||||
http_file_context_t *context = handle->private_info;
|
||||
|
||||
|
||||
return switch_core_file_read_video(&context->fh, frame, flags);
|
||||
}
|
||||
|
||||
@@ -3089,7 +3089,7 @@ static switch_status_t http_file_write_video(switch_file_handle_t *handle, switc
|
||||
static switch_status_t http_file_write(switch_file_handle_t *handle, void *data, size_t *len)
|
||||
{
|
||||
http_file_context_t *context = handle->private_info;
|
||||
|
||||
|
||||
return switch_core_file_write(&context->fh, data, len);
|
||||
}
|
||||
|
||||
@@ -3127,7 +3127,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_httapi_load)
|
||||
switch_application_interface_t *app_interface;
|
||||
switch_file_interface_t *http_file_interface;
|
||||
switch_file_interface_t *https_file_interface;
|
||||
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
@@ -3165,11 +3165,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_httapi_load)
|
||||
https_file_interface->file_seek = http_file_file_seek;
|
||||
https_file_interface->file_read_video = http_file_read_video;
|
||||
https_file_interface->file_write_video = http_file_write_video;
|
||||
|
||||
|
||||
switch_snprintf(globals.cache_path, sizeof(globals.cache_path), "%s%shttp_file_cache", SWITCH_GLOBAL_dirs.storage_dir, SWITCH_PATH_SEPARATOR);
|
||||
switch_dir_make_recursive(globals.cache_path, SWITCH_DEFAULT_DIR_PERMS, pool);
|
||||
|
||||
|
||||
|
||||
switch_core_hash_init(&globals.profile_hash);
|
||||
switch_core_hash_init(&globals.request_hash);
|
||||
switch_core_hash_init_case(&globals.parse_hash, SWITCH_FALSE);
|
||||
@@ -3198,14 +3198,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_httapi_load)
|
||||
if (do_config() != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_ADD_API(httapi_api_interface, "httapi",
|
||||
"HT-TAPI Hypertext Telephony API", httapi_api_function, HTTAPI_SYNTAX);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "httapi",
|
||||
"HT-TAPI Hypertext Telephony API",
|
||||
SWITCH_ADD_APP(app_interface, "httapi",
|
||||
"HT-TAPI Hypertext Telephony API",
|
||||
"HT-TAPI Hypertext Telephony API", httapi_function, "{<param1>=<val1>}", SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
|
||||
|
||||
|
||||
switch_console_set_complete("add httapi debug_on");
|
||||
@@ -3233,9 +3233,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_httapi_shutdown)
|
||||
}
|
||||
|
||||
|
||||
switch_core_hash_destroy(&globals.profile_hash);
|
||||
switch_core_hash_destroy(&globals.parse_hash);
|
||||
|
||||
switch_core_hash_destroy(&globals.profile_hash);
|
||||
switch_core_hash_destroy(&globals.parse_hash);
|
||||
|
||||
while (globals.hash_root) {
|
||||
ptr = globals.hash_root;
|
||||
switch_core_hash_destroy(&ptr->hash);
|
||||
|
||||
@@ -359,7 +359,7 @@ static switch_status_t http_put(url_cache_t *cache, http_profile_t *profile, swi
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, full_url);
|
||||
|
||||
/* we want to use our own read function so we can send a portion of the file */
|
||||
/* we want to use our own read function so we can send a portion of the file */
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback);
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_READDATA, &block_info);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ static void test_parse_url(void)
|
||||
parse_url(strdup("https://my-bucket-with-dash.s3-us-west-2.amazonaws.com/greeting/file/1002/Lumino.mp3"), NULL, "s3", &bucket, &object);
|
||||
ASSERT_STRING_EQUALS("my-bucket-with-dash", bucket);
|
||||
ASSERT_STRING_EQUALS("greeting/file/1002/Lumino.mp3", object);
|
||||
|
||||
|
||||
parse_url(strdup("http://quotes.s3.foo.bar.s3.amazonaws.com/greeting/file/1002/Lumino.mp3"), NULL, "s3", &bucket, &object);
|
||||
ASSERT_STRING_EQUALS("quotes.s3.foo.bar", bucket);
|
||||
ASSERT_STRING_EQUALS("greeting/file/1002/Lumino.mp3", object);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<include>
|
||||
|
||||
|
||||
<X-PRE-PROCESS cmd="set" data="AT_EPENT1=0 0 0 -1 -1 0 -1 0 -1 -1 0 -1"/>
|
||||
<X-PRE-PROCESS cmd="set" data="AT_EPENT2=1 1 1 -1 -1 1 -1 1 -1 -1 1 -1"/>
|
||||
<X-PRE-PROCESS cmd="set" data="AT_CPENT1=0 -1 -1 0 -1 0 0 0 -1 -1 0 -1"/>
|
||||
@@ -8,9 +8,9 @@
|
||||
<X-PRE-PROCESS cmd="set" data="AT_CMAJ2=1 -1 1 1 -1 1 -1 1 1 -1 1 -1"/>
|
||||
<X-PRE-PROCESS cmd="set" data="AT_BBLUES=1 -1 1 -1 -1 1 -1 1 1 1 -1 -1"/>
|
||||
<X-PRE-PROCESS cmd="set" data="ATGPENT2=-1 1 -1 1 -1 1 -1 -1 1 -1 1 -1"/>
|
||||
|
||||
<extension name="101">
|
||||
<condition field="destination_number" expression="^101$">
|
||||
|
||||
<extension name="101">
|
||||
<condition field="destination_number" expression="^101$">
|
||||
<!-- AUTOTALENT DEFAULTS -->
|
||||
|
||||
<!--
|
||||
@@ -65,13 +65,13 @@
|
||||
|
||||
|
||||
<action application="set"><![CDATA[ladspa_params=${AT_TUNE} ${AT_FIXED} ${AT_PULL} ${AT_EPENT2} ${AT_AMOUNT} ${AT_SMOOTH} ${AT_SHIFT} ${AT_OUTSCALE} ${AT_LFODEPTH} ${AT_LFORATE} ${AT_LFOSHAPE} ${AT_LFOSYMM} ${AT_LFOQUANT} ${AT_FCORR} ${AT_FWARP} ${AT_MIX}]]></action>
|
||||
|
||||
|
||||
<action application="ladspa_run" data="r|autotalent||${ladspa_params}"/>
|
||||
<action application="ladspa_run" data="r|tap_chorusflanger||"/>
|
||||
<action application="ladspa_run" data="r|phasers_1217.so|autoPhaser|"/>
|
||||
<action application="bridge" data="sofia/internal/888@conference.freeswitch.org"/>
|
||||
|
||||
</condition>
|
||||
</extension>
|
||||
</condition>
|
||||
</extension>
|
||||
|
||||
</include>
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,10 +22,10 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_ladspa.c -- LADSPA
|
||||
* mod_ladspa.c -- LADSPA
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
@@ -37,7 +37,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_ladspa_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_ladspa_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_ladspa_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_ladspa, mod_ladspa_load, mod_ladspa_shutdown, NULL);
|
||||
@@ -68,9 +68,9 @@ typedef struct {
|
||||
|
||||
int check_range(const LADSPA_Descriptor *ldesc, int i, LADSPA_Data val)
|
||||
{
|
||||
if (ldesc->PortRangeHints[i].LowerBound && ldesc->PortRangeHints[i].UpperBound &&
|
||||
if (ldesc->PortRangeHints[i].LowerBound && ldesc->PortRangeHints[i].UpperBound &&
|
||||
(val < ldesc->PortRangeHints[i].LowerBound || val > ldesc->PortRangeHints[i].UpperBound)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Param %f out of bounds %f-%f\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "Param %f out of bounds %f-%f\n",
|
||||
val, ldesc->PortRangeHints[i].LowerBound, ldesc->PortRangeHints[i].UpperBound);
|
||||
return 0;
|
||||
}
|
||||
@@ -79,13 +79,13 @@ int check_range(const LADSPA_Descriptor *ldesc, int i, LADSPA_Data val)
|
||||
}
|
||||
|
||||
int find_default(const LADSPA_Descriptor *ldesc, int i, LADSPA_Data *ptr)
|
||||
|
||||
|
||||
{
|
||||
LADSPA_Data dftval = 0;
|
||||
int fail = 0;
|
||||
|
||||
LADSPA_PortRangeHintDescriptor port_hint = ldesc->PortRangeHints[i].HintDescriptor;
|
||||
|
||||
|
||||
switch (port_hint & LADSPA_HINT_DEFAULT_MASK) {
|
||||
case LADSPA_HINT_DEFAULT_NONE:
|
||||
break;
|
||||
@@ -235,15 +235,15 @@ static void dump_info(const LADSPA_Descriptor *ldesc)
|
||||
|
||||
if (LADSPA_IS_PORT_CONTROL(ldesc->PortDescriptors[i])) {
|
||||
if (found) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n RANGE: %f-%f DEFAULT: %f\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n RANGE: %f-%f DEFAULT: %f\n",
|
||||
ldesc->PortRangeHints[i].LowerBound, ldesc->PortRangeHints[i].UpperBound, dft);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n RANGE: %f-%f DEFAULT: none.\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "\n RANGE: %f-%f DEFAULT: none.\n",
|
||||
ldesc->PortRangeHints[i].LowerBound, ldesc->PortRangeHints[i].UpperBound);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -261,18 +261,18 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
|
||||
|
||||
switch (type) {
|
||||
case SWITCH_ABC_TYPE_INIT:
|
||||
case SWITCH_ABC_TYPE_INIT:
|
||||
{
|
||||
switch_codec_implementation_t read_impl = { 0 };
|
||||
LADSPA_PortDescriptor port_desc;
|
||||
int i = 0, j = 0, k = 0, str_idx = 0;
|
||||
|
||||
|
||||
switch_core_session_get_read_impl(pvt->session, &read_impl);
|
||||
|
||||
if (!(pvt->library_handle = loadLADSPAPluginLibrary(pvt->plugin_name))) {
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (!(pvt->ldesc = findLADSPAPluginDescriptor(pvt->library_handle, pvt->plugin_name, pvt->label_name))) {
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
@@ -281,15 +281,15 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
pvt->handle = pvt->ldesc->instantiate(pvt->ldesc, read_impl.actual_samples_per_second);
|
||||
|
||||
dump_info(pvt->ldesc);
|
||||
|
||||
|
||||
|
||||
for (i = 0; i < pvt->ldesc->PortCount; i++) {
|
||||
port_desc = pvt->ldesc->PortDescriptors[i];
|
||||
|
||||
|
||||
if (LADSPA_IS_PORT_CONTROL(port_desc) && LADSPA_IS_PORT_INPUT(port_desc)) {
|
||||
LADSPA_Data dft = 0.0f;
|
||||
int found = find_default(pvt->ldesc, i, &dft);
|
||||
|
||||
|
||||
if (found && !pvt->has_config[j]) {
|
||||
pvt->config[j] = dft;
|
||||
pvt->has_config[j] = 1;
|
||||
@@ -298,14 +298,14 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
if (pvt->has_config[j]) {
|
||||
if (!check_range(pvt->ldesc, i, pvt->config[j])) {
|
||||
pvt->config[j] = dft;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_WARNING, "FALLING TO DEFAULT PARAM %d [%s] (%f)\n",
|
||||
j+1,
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_WARNING, "FALLING TO DEFAULT PARAM %d [%s] (%f)\n",
|
||||
j+1,
|
||||
pvt->ldesc->PortNames[i],
|
||||
pvt->config[j]);
|
||||
pvt->config[j]);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "ADDING PARAM %d [%s] (%f)\n",
|
||||
j+1,
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "ADDING PARAM %d [%s] (%f)\n",
|
||||
j+1,
|
||||
pvt->ldesc->PortNames[i],
|
||||
pvt->config[j]);
|
||||
pvt->ldesc->connect_port(pvt->handle, i, &pvt->config[j++]);
|
||||
@@ -319,7 +319,7 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
if (pvt->str_idx && !zstr(pvt->str_config[str_idx])) {
|
||||
|
||||
if (!strcasecmp(pvt->str_config[str_idx], "none")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT NOTHING to port: %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT NOTHING to port: %s\n",
|
||||
pvt->ldesc->PortNames[i]
|
||||
);
|
||||
mapped = 1;
|
||||
@@ -327,20 +327,20 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
char *file = pvt->str_config[str_idx] + 5;
|
||||
|
||||
if (switch_test_flag((&pvt->fh), SWITCH_FILE_OPEN)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session),
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session),
|
||||
SWITCH_LOG_ERROR, "CAN'T CONNECT FILE [%s] File already mapped\n", file);
|
||||
} else {
|
||||
if (switch_core_file_open(&pvt->fh,
|
||||
file,
|
||||
read_impl.number_of_channels,
|
||||
read_impl.actual_samples_per_second,
|
||||
read_impl.actual_samples_per_second,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_ERROR, "Cannot open file: %s\n", file);
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT FILE [%s] to port: %s\n",
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT FILE [%s] to port: %s\n",
|
||||
file,
|
||||
pvt->ldesc->PortNames[i]
|
||||
);
|
||||
@@ -355,7 +355,7 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
|
||||
if (!mapped) {
|
||||
pvt->ldesc->connect_port(pvt->handle, i, pvt->in_buf);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT CHANNEL AUDIO to port: %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_DEBUG, "CONNECT CHANNEL AUDIO to port: %s\n",
|
||||
pvt->ldesc->PortNames[i]
|
||||
);
|
||||
}
|
||||
@@ -373,7 +373,7 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case SWITCH_ABC_TYPE_CLOSE:
|
||||
{
|
||||
|
||||
@@ -387,7 +387,7 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
|
||||
if (pvt->library_handle) {
|
||||
unloadLADSPAPluginLibrary(pvt->library_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -406,7 +406,7 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
}
|
||||
|
||||
slin = rframe->data;
|
||||
|
||||
|
||||
if (switch_channel_media_ready(channel)) {
|
||||
switch_short_to_float(slin, pvt->in_buf, rframe->samples);
|
||||
|
||||
@@ -418,15 +418,15 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
switch_core_session_get_read_impl(pvt->session, &read_impl);
|
||||
|
||||
switch_core_file_close(&pvt->fh);
|
||||
|
||||
|
||||
if (switch_core_file_open(&pvt->fh,
|
||||
file,
|
||||
read_impl.number_of_channels,
|
||||
read_impl.actual_samples_per_second,
|
||||
read_impl.actual_samples_per_second,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pvt->session), SWITCH_LOG_ERROR, "Cannot open file: %s\n", file);
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
olen = rframe->samples;
|
||||
if (switch_core_file_read(&pvt->fh, abuf, &olen) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -434,7 +434,7 @@ static switch_bool_t ladspa_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_short_to_float(abuf, pvt->file_buf, olen);
|
||||
}
|
||||
|
||||
@@ -498,12 +498,12 @@ switch_status_t ladspa_session(switch_core_session_t *session, const char *flags
|
||||
if (zstr(flags)) {
|
||||
flags = "r";
|
||||
}
|
||||
|
||||
|
||||
if (strchr(flags, 'w')) {
|
||||
bflags = SMBF_WRITE_REPLACE;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "FLAGS: %s PLUGIN: %s LABEL: %s PARAMS: %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "FLAGS: %s PLUGIN: %s LABEL: %s PARAMS: %s\n",
|
||||
flags, plugin_name, label, params);
|
||||
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
@@ -526,7 +526,7 @@ switch_status_t ladspa_session(switch_core_session_t *session, const char *flags
|
||||
} else {
|
||||
pvt->plugin_name = switch_core_session_sprintf(session, "%s.so", plugin_name);
|
||||
}
|
||||
|
||||
|
||||
dparams = switch_core_session_strdup(session, params);
|
||||
|
||||
argc = switch_split(dparams, ' ', argv);
|
||||
@@ -576,7 +576,7 @@ static void ladspa_parse(switch_core_session_t *session, const char *data)
|
||||
}
|
||||
|
||||
#define APP_SYNTAX "<flags>|<plugin>|<label>|<params>"
|
||||
SWITCH_STANDARD_APP(ladspa_run_function)
|
||||
SWITCH_STANDARD_APP(ladspa_run_function)
|
||||
{
|
||||
ladspa_parse(session, data);
|
||||
}
|
||||
@@ -604,11 +604,11 @@ SWITCH_STANDARD_API(ladspa_api)
|
||||
|
||||
if (!(ksession = switch_core_session_locate(uuid))) {
|
||||
stream->write_function(stream, "-ERR non-existant UUID\n");
|
||||
goto done;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((action = strstr(cmd, "stop"))) {
|
||||
stop_ladspa_session(ksession);
|
||||
stop_ladspa_session(ksession);
|
||||
switch_core_session_rwunlock(ksession);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
goto done;
|
||||
@@ -623,7 +623,7 @@ SWITCH_STANDARD_API(ladspa_api)
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR Usage %s\n", API_SYNTAX);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ findLADSPAPluginDescriptor(void * pvLADSPAPluginLibrary,
|
||||
style) and a LADSPA_DescriptorFunction (from which
|
||||
LADSPA_Descriptors can be acquired). */
|
||||
typedef void LADSPAPluginSearchCallbackFunction
|
||||
(const char * pcFullFilename,
|
||||
(const char * pcFullFilename,
|
||||
void * pvPluginHandle,
|
||||
LADSPA_Descriptor_Function fDescriptorFunction);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<param name="id" value="2"/>
|
||||
<param name="order_by" value="reliability,quality"/>
|
||||
</profile>
|
||||
<!--
|
||||
<!--
|
||||
Some samples of how to do custom SQL:
|
||||
|
||||
=============================================================
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<include>
|
||||
<include>
|
||||
<extension name="Outbound to PSTN 11 Digits">
|
||||
<condition field="destination_number" expression="^(1[2-9][0-9]{2}[2-9]{7})$">
|
||||
<action application="lcr" data="$1"/>
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
<condition>
|
||||
<action application="limit" data="db $${domain} ${sip_auth_username} ${max_calls}"/>
|
||||
</condition>
|
||||
</extension>
|
||||
</extension>
|
||||
</include>
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Rupa Schomaker <rupa@rupa.com>
|
||||
*
|
||||
@@ -45,7 +45,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_limit_load)
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Loading mod_limit - a shim for backwards compatability with the new limit system. This is deprecated, remove mod_limit and instead load mod_hash and mod_db!\n");
|
||||
|
||||
|
||||
/* try to load mod_hash if it isn't loaded */
|
||||
if (switch_loadable_module_exists("mod_hash") != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "mod_hash not loaded, trying to load...!\n");
|
||||
@@ -53,7 +53,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_limit_load)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load mod_hash (%s)!\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* try to load mod_db if it isn't loaded */
|
||||
if (switch_loadable_module_exists("mod_db") != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "mod_db not loaded, trying to load...!\n");
|
||||
@@ -61,7 +61,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_limit_load)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to load mod_db (%s)!\n", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* set compat flag */
|
||||
switch_core_set_variable("switch_limit_backwards_compat_flag", "true");
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Rupa Schomaker <rupa@rupa.com>
|
||||
*
|
||||
* mod_memcache.c -- API for memcache
|
||||
@@ -37,7 +37,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_memcache_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_memcache_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_memcache_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_memcache, mod_memcache_load, mod_memcache_shutdown, NULL);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -146,13 +146,13 @@ SWITCH_STANDARD_APP(record_mp4_function)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s waiting for video.\n", switch_channel_get_name(channel));
|
||||
count = 100;
|
||||
if (!--sanity) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s timeout waiting for video.\n",
|
||||
switch_channel_get_name(channel));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!switch_channel_ready(channel)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s not ready.\n", switch_channel_get_name(channel));
|
||||
return;
|
||||
@@ -312,7 +312,7 @@ static void *SWITCH_THREAD_FUNC play_video_function(switch_thread_t *thread, voi
|
||||
sent = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(pt->session), SWITCH_LOG_DEBUG, "Video thread ended\n");
|
||||
pt->done = true;
|
||||
@@ -330,7 +330,7 @@ static void *SWITCH_THREAD_FUNC play_audio_function(switch_thread_t *thread, voi
|
||||
switch_dtmf_t dtmf = {0};
|
||||
pt->done = false;
|
||||
switch_frame_t * read_frame;
|
||||
|
||||
|
||||
while (!*pt->quit && switch_channel_ready(pt->channel)) {
|
||||
// event processing.
|
||||
// -- SEE switch_ivr_play_say.c:1231 && mod_dptools.c:1428 && mod_dptools.c:1919
|
||||
@@ -354,7 +354,7 @@ static void *SWITCH_THREAD_FUNC play_audio_function(switch_thread_t *thread, voi
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(pt->mutex);
|
||||
pt->frame->datalen = pt->frame->buflen;
|
||||
ok = pt->vc->getAudioPacket(pt->frame->data, pt->frame->datalen, next);
|
||||
@@ -404,13 +404,13 @@ SWITCH_STANDARD_APP(play_mp4_function)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error opening file %s\n", (char *) data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!vc.isSupported())
|
||||
{
|
||||
char msgbuf[1024];
|
||||
sprintf(msgbuf, "PLAYBACK ERROR (%s): UNSUPPORTED FORMAT OR FILE NOT HINTED.", (char*) data);
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, msgbuf);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
|
||||
"Error reading track info. Maybe this file is not hinted.\n");
|
||||
throw 1;
|
||||
}
|
||||
@@ -478,7 +478,7 @@ SWITCH_STANDARD_APP(play_mp4_function)
|
||||
vpt.vc = &vc;
|
||||
switch_mutex_init(&vpt.mutex, SWITCH_MUTEX_DEFAULT, switch_core_session_get_pool(session));
|
||||
vpt.quit = &done;
|
||||
|
||||
|
||||
switch_threadattr_t * thd_attr;
|
||||
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
@@ -503,7 +503,7 @@ SWITCH_STANDARD_APP(play_mp4_function)
|
||||
}
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE PLAYED");
|
||||
} catch(const std::exception & e)
|
||||
} catch(const std::exception & e)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s\n", e.what());
|
||||
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE,
|
||||
|
||||
@@ -12,7 +12,7 @@ under the License.
|
||||
|
||||
The Original Code is MP4 Helper Library to the Freeswitch MP4 Module.
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
The Initial Developer of the Original Code is
|
||||
Paulo Rogério Panhoto <paulo@voicetechnology.com.br>.
|
||||
Portions created by the Initial Developer are Copyright (C)
|
||||
the Initial Developer. All Rights Reserved.
|
||||
@@ -27,13 +27,13 @@ Contributors:
|
||||
|
||||
namespace MP4
|
||||
{
|
||||
|
||||
|
||||
Context::Context(const char * file, bool newFile)
|
||||
{
|
||||
if(newFile) create(file);
|
||||
else open(file);
|
||||
}
|
||||
|
||||
|
||||
Context::~Context()
|
||||
{
|
||||
close();
|
||||
@@ -45,7 +45,7 @@ namespace MP4
|
||||
if (fh == MP4_INVALID_FILE_HANDLE) throw Exception(file, "Open failed");
|
||||
getTracks(file);
|
||||
}
|
||||
|
||||
|
||||
void Context::create(const char * file)
|
||||
{
|
||||
fh = MP4Create(file);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -33,12 +33,12 @@
|
||||
* mod_nibblebill.c - Nibble Billing
|
||||
* Purpose is to allow real-time debiting of credit or cash from a database while calls are in progress. I had the following goals:
|
||||
*
|
||||
* Debit credit/cash from accounts real-time
|
||||
* Allow for billing at different rates during a single call
|
||||
* Allow for warning callers when their balance is low (via audio, in-channel)
|
||||
* Allow for disconnecting or re-routing calls when balance is depleted
|
||||
* Allow for billing to function as listed above with multiple concurrent calls
|
||||
*
|
||||
* Debit credit/cash from accounts real-time
|
||||
* Allow for billing at different rates during a single call
|
||||
* Allow for warning callers when their balance is low (via audio, in-channel)
|
||||
* Allow for disconnecting or re-routing calls when balance is depleted
|
||||
* Allow for billing to function as listed above with multiple concurrent calls
|
||||
*
|
||||
* Thanks go to bandwidth.com for funding this work.
|
||||
*
|
||||
*
|
||||
@@ -139,7 +139,7 @@ static switch_cache_db_handle_t *nibblebill_get_db_handle(void)
|
||||
{
|
||||
switch_cache_db_handle_t *dbh = NULL;
|
||||
char *dsn;
|
||||
|
||||
|
||||
if (!zstr(globals.odbc_dsn)) {
|
||||
dsn = globals.odbc_dsn;
|
||||
} else {
|
||||
@@ -149,7 +149,7 @@ static switch_cache_db_handle_t *nibblebill_get_db_handle(void)
|
||||
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
|
||||
dbh = NULL;
|
||||
}
|
||||
|
||||
|
||||
return dbh;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ static int nibblebill_callback(void *pArg, int argc, char **argv, char **columnN
|
||||
cbt->balance = atof(argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ static switch_bool_t nibblebill_execute_sql_callback(char *sql, switch_core_db_c
|
||||
{
|
||||
switch_bool_t retval = SWITCH_FALSE;
|
||||
switch_cache_db_handle_t *dbh = NULL;
|
||||
|
||||
|
||||
if (globals.odbc_dsn && (dbh = nibblebill_get_db_handle())) {
|
||||
if (switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
retval = SWITCH_FALSE;
|
||||
@@ -219,7 +219,7 @@ static switch_status_t nibblebill_load_config(void)
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
|
||||
if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "odbc_dsn is %s\n", val);
|
||||
switch_safe_free(globals.odbc_dsn);
|
||||
@@ -260,7 +260,7 @@ static switch_status_t nibblebill_load_config(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Set defaults for any variables still not set */
|
||||
setdefaults:
|
||||
@@ -389,7 +389,7 @@ static switch_bool_t bill_event(double billamount, const char *billaccount, swit
|
||||
} else {
|
||||
sql = dsql = switch_mprintf("UPDATE %q SET %q=%q- %f WHERE %q='%q'", globals.db_table, globals.db_column_cash,
|
||||
globals.db_column_cash, billamount, globals.db_column_account, billaccount);
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
|
||||
@@ -415,7 +415,7 @@ static double get_balance(const char *billaccount, switch_channel_t *channel)
|
||||
sql = globals.custom_sql_lookup;
|
||||
}
|
||||
} else {
|
||||
sql = dsql = switch_mprintf("SELECT %q AS nibble_balance FROM %q WHERE %q='%q'",
|
||||
sql = dsql = switch_mprintf("SELECT %q AS nibble_balance FROM %q WHERE %q='%q'",
|
||||
globals.db_column_cash, globals.db_table, globals.db_column_account, billaccount);
|
||||
}
|
||||
|
||||
@@ -429,12 +429,12 @@ static double get_balance(const char *billaccount, switch_channel_t *channel)
|
||||
balance = pdata.balance;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Retrieved current balance for account %s (balance = %f)\n", billaccount, balance);
|
||||
}
|
||||
|
||||
|
||||
switch_safe_free(dsql);
|
||||
return balance;
|
||||
}
|
||||
|
||||
/* This is where we actually charge the guy
|
||||
/* This is where we actually charge the guy
|
||||
This can be called anytime a call is in progress or at the end of a call before the session is destroyed */
|
||||
static switch_status_t do_billing(switch_core_session_t *session)
|
||||
{
|
||||
@@ -483,11 +483,11 @@ static switch_status_t do_billing(switch_core_session_t *session)
|
||||
if (!zstr(switch_channel_get_variable(channel, "nobal_amt"))) {
|
||||
nobal_amt = atof(switch_channel_get_variable(channel, "nobal_amt"));
|
||||
}
|
||||
|
||||
|
||||
if (!zstr(switch_channel_get_variable(channel, "lowbal_amt"))) {
|
||||
lowbal_amt = atof(switch_channel_get_variable(channel, "lowbal_amt"));
|
||||
}
|
||||
|
||||
|
||||
if (!zstr(switch_channel_get_variable(channel, "nibble_rounding"))) {
|
||||
rounding_factor = pow(10, atof(switch_channel_get_variable(channel, "nibble_rounding")));
|
||||
}
|
||||
@@ -580,7 +580,7 @@ static switch_status_t do_billing(switch_core_session_t *session)
|
||||
billamount = (atof(billrate) / 1000000 / 60) * chargedunits - nibble_data->bill_adjustments;
|
||||
/* Account for the prepaid amount */
|
||||
nibble_data->lastts += chargedunits;
|
||||
} else {
|
||||
} else {
|
||||
/* Convert billrate into microseconds and multiply by # of microseconds that have passed since last *successful* bill */
|
||||
billamount = (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts)) - nibble_data->bill_adjustments;
|
||||
/* Update the last time we billed */
|
||||
@@ -637,9 +637,9 @@ static switch_status_t do_billing(switch_core_session_t *session)
|
||||
|
||||
/* don't verify balance and transfer to nobal if we're done with call */
|
||||
if (switch_channel_get_state(channel) != CS_REPORTING && switch_channel_get_state(channel) != CS_HANGUP) {
|
||||
|
||||
|
||||
balance = get_balance(billaccount, channel);
|
||||
|
||||
|
||||
/* See if we've achieved low balance */
|
||||
if (!nibble_data->lowbal_action_executed && balance <= lowbal_amt) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below low balance amount of %f! (Account %s)\n",
|
||||
@@ -961,10 +961,10 @@ SWITCH_STANDARD_API(nibblebill_api_function)
|
||||
static switch_status_t sched_billing(switch_core_session_t *session)
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
|
||||
|
||||
const char *billrate = NULL;
|
||||
const char *billaccount = NULL;
|
||||
|
||||
|
||||
if (!(channel = switch_core_session_get_channel(session))) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -993,7 +993,7 @@ static switch_status_t process_hangup(switch_core_session_t *session)
|
||||
switch_channel_t *channel = NULL;
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
|
||||
|
||||
/* Resume any paused billings, just in case */
|
||||
/* nibblebill_resume(session); */
|
||||
|
||||
@@ -1026,7 +1026,7 @@ switch_state_handler_table_t nibble_state_handler = {
|
||||
/* on_hibernate */ NULL,
|
||||
/* on_reset */ NULL,
|
||||
/* on_park */ NULL,
|
||||
/* on_reporting */ NULL,
|
||||
/* on_reporting */ NULL,
|
||||
/* on_destroy */ NULL
|
||||
};
|
||||
|
||||
@@ -1072,7 +1072,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_nibblebill_shutdown)
|
||||
switch_event_unbind(&globals.node);
|
||||
switch_core_remove_state_handler(&nibble_state_handler);
|
||||
switch_odbc_handle_disconnect(globals.master_odbc);
|
||||
|
||||
|
||||
switch_safe_free(globals.dbname);
|
||||
switch_safe_free(globals.odbc_dsn);
|
||||
switch_safe_free(globals.db_table);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -87,7 +87,7 @@ static int oreka_write_udp(oreka_session_t *oreka, switch_stream_handle_t *udp)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_DEBUG, "Oreka SIP Packet:\n%s", (const char *)udp->data);
|
||||
switch_socket_sendto(globals.sip_socket, globals.sip_server_addr, 0, (void *)udp->data, &udplen);
|
||||
if (udplen != udp->data_len) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_ERROR, "Failed to write SIP Packet of len %zd (wrote=%zd)",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oreka->session), SWITCH_LOG_ERROR, "Failed to write SIP Packet of len %zd (wrote=%zd)",
|
||||
udp->data_len, udplen);
|
||||
}
|
||||
return 0;
|
||||
@@ -142,20 +142,20 @@ static int oreka_setup_rtp(oreka_session_t *oreka, oreka_stream_type_t type)
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated %s port %d for local IP %s, destination IP %s\n", type_str,
|
||||
rtp_port, globals.local_ipv4_str, globals.sip_server_ipv4_str);
|
||||
rtp_stream = switch_rtp_new(globals.local_ipv4_str, rtp_port,
|
||||
rtp_stream = switch_rtp_new(globals.local_ipv4_str, rtp_port,
|
||||
globals.sip_server_ipv4_str, rtp_port,
|
||||
0, /* PCMU IANA*/
|
||||
codec_impl->samples_per_packet,
|
||||
codec_impl->microseconds_per_packet,
|
||||
flags, NULL, &err, switch_core_session_get_pool(oreka->session));
|
||||
if (!rtp_stream) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create %s RTP stream at %s:%d: %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create %s RTP stream at %s:%d: %s\n",
|
||||
type_str, globals.local_ipv4_str, rtp_port, err);
|
||||
res = -1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch_rtp_intentional_bugs(rtp_stream, RTP_BUG_SEND_LINEAR_TIMESTAMPS);
|
||||
switch_rtp_intentional_bugs(rtp_stream, RTP_BUG_SEND_LINEAR_TIMESTAMPS);
|
||||
|
||||
|
||||
done:
|
||||
@@ -175,7 +175,7 @@ done:
|
||||
oreka->write_rtp_port = rtp_port;
|
||||
}
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Successfully created %s RTP stream at %s:%d at %dms@%dHz\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Successfully created %s RTP stream at %s:%d at %dms@%dHz\n",
|
||||
type_str, globals.local_ipv4_str, rtp_port, codec_impl->microseconds_per_packet/1000, codec_impl->samples_per_second);
|
||||
return res;
|
||||
}
|
||||
@@ -272,7 +272,7 @@ static int oreka_send_sip_message(oreka_session_t *oreka, oreka_recording_status
|
||||
|
||||
/* Get caller meta data */
|
||||
caller_id_number = switch_caller_get_field_by_name(caller_profile, "caller_id_number");
|
||||
|
||||
|
||||
caller_id_name = switch_caller_get_field_by_name(caller_profile, "caller_id_name");
|
||||
if (zstr(caller_id_name)) {
|
||||
caller_id_name = caller_id_number;
|
||||
@@ -308,7 +308,7 @@ static int oreka_send_sip_message(oreka_session_t *oreka, oreka_recording_status
|
||||
sdp.write_function(&sdp, "s=Phone Recording (%s)\r\n", type == FS_OREKA_READ ? "RX" : "TX");
|
||||
sdp.write_function(&sdp, "i=FreeSWITCH Oreka Recorder (pid=%d)\r\n", globals.our_pid);
|
||||
sdp.write_function(&sdp, "m=audio %d RTP/AVP 0\r\n", type == FS_OREKA_READ ? oreka->read_rtp_port : oreka->write_rtp_port);
|
||||
sdp.write_function(&sdp, "a=rtpmap:0 PCMU/%d\r\n", type == FS_OREKA_READ
|
||||
sdp.write_function(&sdp, "a=rtpmap:0 PCMU/%d\r\n", type == FS_OREKA_READ
|
||||
? oreka->read_impl.samples_per_second : oreka->write_impl.samples_per_second);
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ static int oreka_send_sip_message(oreka_session_t *oreka, oreka_recording_status
|
||||
sip_header.write_function(&sip_header, "Max-Forwards: 70\r\n", method);
|
||||
|
||||
/* Subject */
|
||||
sip_header.write_function(&sip_header, "Subject: %s %s recording of %s\r\n",
|
||||
sip_header.write_function(&sip_header, "Subject: %s %s recording of %s\r\n",
|
||||
status == FS_OREKA_START ? "BEGIN": "END",
|
||||
type == FS_OREKA_READ ? "RX" : "TX", caller_id_name);
|
||||
|
||||
@@ -400,7 +400,7 @@ static switch_bool_t oreka_audio_callback(switch_media_bug_t *bug, void *user_da
|
||||
uint32_t i = 0;
|
||||
int16_t *linear_samples = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
if (type == SWITCH_ABC_TYPE_READ_REPLACE || type == SWITCH_ABC_TYPE_WRITE_REPLACE || type == SWITCH_ABC_TYPE_READ_PING) {
|
||||
int16_t *data;
|
||||
@@ -476,7 +476,7 @@ static switch_bool_t oreka_audio_callback(switch_media_bug_t *bug, void *user_da
|
||||
switch_resample_create(&oreka->write_resampler,
|
||||
read_impl.actual_samples_per_second,
|
||||
8000,
|
||||
320, SWITCH_RESAMPLE_QUALITY, 1);
|
||||
320, SWITCH_RESAMPLE_QUALITY, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -510,7 +510,7 @@ static switch_bool_t oreka_audio_callback(switch_media_bug_t *bug, void *user_da
|
||||
linear_samples = linear_frame->data;
|
||||
linear_len = linear_frame->datalen;
|
||||
}
|
||||
|
||||
|
||||
memset(&pcmu_frame, 0, sizeof(pcmu_frame));
|
||||
for (i = 0; i < linear_len / sizeof(int16_t); i++) {
|
||||
pcmu_data[i] = linear_to_ulaw(linear_samples[i]);
|
||||
@@ -629,9 +629,9 @@ SWITCH_STANDARD_APP(oreka_start_function)
|
||||
} else {
|
||||
flags = SMBF_READ_REPLACE | SMBF_WRITE_REPLACE | SMBF_ANSWER_REQ;
|
||||
}
|
||||
|
||||
|
||||
status = switch_core_media_bug_add(session, OREKA_BUG_NAME_READ, NULL, oreka_audio_callback, oreka, 0, flags, &bug);
|
||||
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to attach oreka to media stream!\n");
|
||||
return;
|
||||
@@ -719,8 +719,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_oreka_load)
|
||||
switch_get_addr(globals.sip_server_ipv4_str, sizeof(globals.sip_server_ipv4_str), globals.sip_server_addr);
|
||||
globals.our_pid = getpid();
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
"Loading mod_oreka, sip_server_addr=%s, sip_server_ipv4_str=%s, sip_server_port=%d, local_ipv4_str=%s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
"Loading mod_oreka, sip_server_addr=%s, sip_server_ipv4_str=%s, sip_server_port=%d, local_ipv4_str=%s\n",
|
||||
globals.sip_server_addr_str, globals.sip_server_ipv4_str, globals.sip_server_port, globals.local_ipv4_str);
|
||||
|
||||
#if 0
|
||||
@@ -765,8 +765,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_oreka_load)
|
||||
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "oreka_record", "Send media to Oreka recording server", "Send media to Oreka recording server",
|
||||
oreka_start_function, "[stop]", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "oreka_record", "Send media to Oreka recording server", "Send media to Oreka recording server",
|
||||
oreka_start_function, "[stop]", SAF_NONE);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ struct config_vsas
|
||||
int pec;
|
||||
int expr;
|
||||
int direction;
|
||||
|
||||
|
||||
struct config_vsas *pNext;
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ struct config_client
|
||||
{
|
||||
char* name;
|
||||
char* value;
|
||||
|
||||
|
||||
struct config_client *pNext;
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ void free_radius_auth_value_pair(VALUE_PAIR *send, VALUE_PAIR *received, rc_hand
|
||||
|
||||
if (received)
|
||||
rc_avpair_free(received);
|
||||
|
||||
|
||||
if (rh)
|
||||
rc_destroy(rh);
|
||||
rh = NULL;
|
||||
@@ -136,17 +136,17 @@ char* extract_out_variable(char* outvar)
|
||||
CONFIG_VSAS* GetVSAS(char* key)
|
||||
{
|
||||
CONFIG_VSAS* PCONFIGVSAS = CONFIGVSAS;
|
||||
|
||||
|
||||
while(PCONFIGVSAS)
|
||||
{
|
||||
if (strcmp(key, PCONFIGVSAS->name) == 0)
|
||||
{
|
||||
return PCONFIGVSAS;
|
||||
}
|
||||
|
||||
|
||||
PCONFIGVSAS = PCONFIGVSAS->pNext;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -157,13 +157,13 @@ char* GetValue(switch_channel_t *channel, CONFIG_VSAS* VSAS, char* value)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal Error : VSAS is null object.\n");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
if (VSAS->value == NULL)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal Error : VSAS->value is null object.\n");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
if (VSAS->expr == 1)
|
||||
{
|
||||
const char* v = switch_channel_get_variable(channel, VSAS->value);
|
||||
@@ -278,30 +278,30 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
|
||||
memset(msg, 0, STR_LENGTH * 10);
|
||||
memset(username_realm, 0, STR_LENGTH);
|
||||
|
||||
|
||||
send = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
|
||||
#if EMBENDED_CONFIG
|
||||
|
||||
CONFIG_CLIENT* PCONFIGCLIENT = CONFIGCLIENT;
|
||||
|
||||
|
||||
rh = rc_new();
|
||||
if (rh == NULL)
|
||||
if (rh == NULL)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Failed to allocate initial structure.\n");
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "allocate initial structure.\n");
|
||||
|
||||
|
||||
/* Initialize the config structure */
|
||||
|
||||
|
||||
rh = rc_config_init(rh);
|
||||
if (rh == NULL)
|
||||
{
|
||||
@@ -309,47 +309,47 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"initialzed configuration.\n");
|
||||
|
||||
|
||||
while(PCONFIGCLIENT)
|
||||
{
|
||||
//if (rc_add_config(rh, "auth_order", "radius", "config", 0) != 0)
|
||||
//if (rc_add_config(rh, "auth_order", "radius", "config", 0) != 0)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "set %s := %s.\n", PCONFIGCLIENT->name, PCONFIGCLIENT->value);
|
||||
if (rc_add_config(rh, PCONFIGCLIENT->name, PCONFIGCLIENT->value, "config", 0) != 0)
|
||||
if (rc_add_config(rh, PCONFIGCLIENT->name, PCONFIGCLIENT->value, "config", 0) != 0)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Unable to set %s := %s.\n", PCONFIGCLIENT->name, PCONFIGCLIENT->value);
|
||||
|
||||
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
PCONFIGCLIENT = PCONFIGCLIENT->pNext;
|
||||
}
|
||||
|
||||
|
||||
if (result == ERROR_RC)
|
||||
break;
|
||||
|
||||
|
||||
|
||||
#else
|
||||
if ((rh = rc_read_config(!rc_config_file ? RC_CONFIG_FILE : rc_config_file)) == NULL)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading radius config file\n");
|
||||
|
||||
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading radius dictionary\n");
|
||||
|
||||
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default_realm = rc_conf_str(rh, "default_realm");
|
||||
if (default_realm == NULL)
|
||||
{
|
||||
@@ -357,7 +357,7 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
strncpy(username_realm, username, sizeof(username_realm));
|
||||
|
||||
if ((strchr(username_realm, '@') == NULL) && default_realm &&
|
||||
@@ -366,8 +366,8 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
strncat(username_realm, "@", sizeof(username_realm)-strlen(username_realm)-1);
|
||||
strncat(username_realm, default_realm, sizeof(username_realm)-strlen(username_realm)-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"... radius: User-Name: %s\n", username);
|
||||
if (rc_avpair_add(rh, &send, PW_USER_NAME, username_realm, -1, 0)== NULL)
|
||||
@@ -376,7 +376,7 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"... radius: User-Password: %s\n", password);
|
||||
if (rc_avpair_add(rh, &send, PW_USER_PASSWORD, password, -1, 0) == NULL)
|
||||
@@ -385,7 +385,7 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!called_number || strcmp(called_number, "") == 0)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
@@ -403,41 +403,41 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PCONFIGVSAS = CONFIGVSAS;
|
||||
|
||||
|
||||
while(PCONFIGVSAS)
|
||||
{
|
||||
if (PCONFIGVSAS->direction == 1)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle attribute: %s\n", PCONFIGVSAS->name );
|
||||
|
||||
|
||||
memset(value, 0, STR_LENGTH);
|
||||
GetValue(channel, PCONFIGVSAS, value);
|
||||
|
||||
|
||||
if (PCONFIGVSAS->pec != 0)
|
||||
attrid = PCONFIGVSAS->id | (PCONFIGVSAS->pec << 16);
|
||||
else
|
||||
attrid = PCONFIGVSAS->id ;
|
||||
|
||||
|
||||
pda = rc_dict_getattr(rh, attrid);
|
||||
|
||||
|
||||
if (pda == NULL)
|
||||
{
|
||||
result = ERROR_RC;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown attribute: key:%s, not found in dictionary\n", PCONFIGVSAS->name);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (PCONFIGVSAS->pec != 0 && rc_dict_getvend(rh, PCONFIGVSAS->pec) == NULL)
|
||||
{
|
||||
result = ERROR_RC;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown vendor specific id: key:%s, id:%dnot found in dictionary\n", PCONFIGVSAS->name, PCONFIGVSAS->pec);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... dictionary data: id:%d, vendor id:%d, attr type:%d, attr name:%s (%d)\n", PCONFIGVSAS->id, PCONFIGVSAS->pec, pda->type, pda->name, attrid);
|
||||
|
||||
|
||||
switch(pda->type)
|
||||
{
|
||||
case PW_TYPE_STRING:
|
||||
@@ -449,13 +449,13 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
//case PW_TYPE_DATE:
|
||||
case PW_TYPE_INTEGER:
|
||||
integer = atoi(value);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... radius: key:%s, value:%s (%d) as integer\n", PCONFIGVSAS->name, PCONFIGVSAS->value, integer);
|
||||
|
||||
|
||||
|
||||
|
||||
if (rc_avpair_add(rh, &send, PCONFIGVSAS->id, &integer, -1, PCONFIGVSAS->pec) == NULL)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : %s\n", PCONFIGVSAS->name);
|
||||
@@ -466,52 +466,52 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
case PW_TYPE_IPADDR:
|
||||
integer = rc_get_ipaddr(value);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... radius: key:%s, value:%s (%d) as ipaddr\n", PCONFIGVSAS->name, PCONFIGVSAS->value, integer);
|
||||
|
||||
|
||||
|
||||
|
||||
if (rc_avpair_add(rh, &send, PCONFIGVSAS->id, &integer, -1, PCONFIGVSAS->pec) == NULL)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : %s\n", PCONFIGVSAS->name);
|
||||
result = ERROR_RC;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown attribute type: key:%s, type %d\n", PCONFIGVSAS->name, pda->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PCONFIGVSAS = PCONFIGVSAS->pNext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (result != ERROR_RC)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending radius packet ...\n" );
|
||||
result = rc_auth(rh, 0, send, &received, msg);
|
||||
|
||||
|
||||
|
||||
|
||||
if (result == OK_RC)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"RADIUS Authentication OK\n");
|
||||
|
||||
|
||||
strcpy(auth_result, "OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
" RADIUS Authentication failure (RC=%d)\n",
|
||||
" RADIUS Authentication failure (RC=%d)\n",
|
||||
result);
|
||||
|
||||
|
||||
strcpy(auth_result, "NOK");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PCONFIGVSAS = CONFIGVSAS;
|
||||
|
||||
|
||||
while(PCONFIGVSAS)
|
||||
{
|
||||
if (PCONFIGVSAS->direction == 0)
|
||||
@@ -521,7 +521,7 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tattribute (%s) found in radius packet\n", PCONFIGVSAS->name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tset variable %s := %s\n", PCONFIGVSAS->value, service_vp->strvalue);
|
||||
|
||||
|
||||
switch_channel_set_variable(channel, PCONFIGVSAS->value, service_vp->strvalue);
|
||||
}
|
||||
else
|
||||
@@ -529,7 +529,7 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tNo found out attribute id: %d, pec:%d, (%s)\n", PCONFIGVSAS->id, PCONFIGVSAS->pec, PCONFIGVSAS->name );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PCONFIGVSAS = PCONFIGVSAS->pNext;
|
||||
}
|
||||
}
|
||||
@@ -538,18 +538,18 @@ int radius_auth(switch_channel_t *channel, char* called_number, char* username,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "abort sending radius packet.\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
} while(1 == 0);
|
||||
|
||||
if (result == ERROR_RC)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"An error occured during RADIUS Authentication(RC=%d)\n",
|
||||
"An error occured during RADIUS Authentication(RC=%d)\n",
|
||||
result);
|
||||
}
|
||||
|
||||
|
||||
free_radius_auth_value_pair(send, received, rh);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -558,23 +558,23 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
char* in_called_number = NULL;
|
||||
char *in_username = NULL;
|
||||
char *in_password = NULL;
|
||||
|
||||
|
||||
char *out_auth_result = NULL;
|
||||
/*char *out_biling_model = NULL;
|
||||
char *out_credit_amount = NULL;
|
||||
char *out_currency = NULL;
|
||||
char *out_preffered_lang = NULL;*/
|
||||
|
||||
|
||||
char auth_result[STR_LENGTH + 1];
|
||||
/*char biling_model[STR_LENGTH + 1];
|
||||
/*char biling_model[STR_LENGTH + 1];
|
||||
char credit_amount[STR_LENGTH + 1];
|
||||
char currency[STR_LENGTH + 1];
|
||||
char preffered_lang[STR_LENGTH + 1];*/
|
||||
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
|
||||
memset(auth_result, 0, STR_LENGTH);
|
||||
/*memset(biling_model, 0, STR_LENGTH);
|
||||
/*memset(biling_model, 0, STR_LENGTH);
|
||||
memset(credit_amount, 0, STR_LENGTH);
|
||||
memset(currency, 0, STR_LENGTH);
|
||||
memset(preffered_lang, 0, STR_LENGTH);*/
|
||||
@@ -586,14 +586,14 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
char *in_called_number_expanded = NULL;
|
||||
char *in_username_expanded = NULL;
|
||||
char *in_password_expanded = NULL;
|
||||
|
||||
|
||||
in_called_number = switch_core_session_strdup(session, data);
|
||||
|
||||
|
||||
in_username = strchr(in_called_number, ',');
|
||||
|
||||
if (in_username)
|
||||
@@ -604,7 +604,7 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
in_username = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
in_password = strchr(in_username, ',');
|
||||
|
||||
if (in_password)
|
||||
@@ -626,7 +626,7 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
out_auth_result = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*out_biling_model = strchr(out_auth_result, ',');
|
||||
|
||||
if (out_biling_model)
|
||||
@@ -637,7 +637,7 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
out_biling_model = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out_credit_amount = strchr(out_biling_model, ',');
|
||||
|
||||
if (out_credit_amount)
|
||||
@@ -648,7 +648,7 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
out_credit_amount = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out_currency = strchr(out_credit_amount, ',');
|
||||
|
||||
if (out_currency)
|
||||
@@ -659,7 +659,7 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
out_currency = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out_preffered_lang = strchr(out_currency, ',');
|
||||
|
||||
if (out_preffered_lang)
|
||||
@@ -673,7 +673,7 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
|
||||
if (in_called_number)
|
||||
in_called_number = extract_in_variable(in_called_number);
|
||||
|
||||
|
||||
in_username = extract_in_variable(in_username);
|
||||
in_password = extract_in_variable(in_password);
|
||||
out_auth_result = extract_out_variable(out_auth_result);
|
||||
@@ -691,7 +691,7 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
|
||||
if (in_called_number)
|
||||
in_called_number_expanded = switch_channel_expand_variables(channel, in_called_number);
|
||||
|
||||
|
||||
in_username_expanded = switch_channel_expand_variables(channel, in_username);
|
||||
in_password_expanded = switch_channel_expand_variables(channel, in_password);
|
||||
|
||||
@@ -701,20 +701,20 @@ SWITCH_STANDARD_APP(auth_function)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "An error occured during radius authorization.\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_channel_set_variable(channel, out_auth_result, auth_result);
|
||||
|
||||
|
||||
/*switch_channel_set_variable(channel, out_biling_model, biling_model);
|
||||
switch_channel_set_variable(channel, out_credit_amount, credit_amount);
|
||||
switch_channel_set_variable(channel, out_currency, currency);
|
||||
switch_channel_set_variable(channel, out_preffered_lang, preffered_lang);*/
|
||||
|
||||
|
||||
if (in_called_number && in_called_number_expanded && in_called_number_expanded != in_called_number)
|
||||
{
|
||||
switch_safe_free(in_called_number_expanded);
|
||||
}
|
||||
|
||||
|
||||
if (in_username_expanded && in_username_expanded != in_username)
|
||||
{
|
||||
switch_safe_free(in_username_expanded);
|
||||
@@ -739,14 +739,14 @@ switch_status_t load_config()
|
||||
switch_xml_t cfg, xml, settings, param;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_event_t *params = NULL;
|
||||
|
||||
|
||||
char *name;
|
||||
char *id;
|
||||
char *value;
|
||||
char *pec;
|
||||
char *expr;
|
||||
char* direction;
|
||||
|
||||
|
||||
CONFIGVSAS = NULL;
|
||||
CONFIGCLIENT = NULL;
|
||||
|
||||
@@ -756,7 +756,7 @@ switch_status_t load_config()
|
||||
"profile_rad_auth");
|
||||
|
||||
//vsas
|
||||
|
||||
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, params)))
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
@@ -764,7 +764,7 @@ switch_status_t load_config()
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "settings")))
|
||||
{
|
||||
for (param = switch_xml_child(settings, "param"); param; param
|
||||
@@ -772,18 +772,18 @@ switch_status_t load_config()
|
||||
{
|
||||
name = (char *) switch_xml_attr_soft(param, "name");
|
||||
value = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
|
||||
if (strcmp(name, "radius_config") == 0)
|
||||
{
|
||||
if (rc_config_file == NULL)
|
||||
rc_config_file = malloc(STR_LENGTH + 1);
|
||||
strcpy(rc_config_file, value);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "radius config: %s\n", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "vsas")))
|
||||
{
|
||||
for (param = switch_xml_child(settings, "param"); param; param
|
||||
@@ -799,19 +799,19 @@ switch_status_t load_config()
|
||||
PCONFIGVSAS->pNext = malloc(sizeof(CONFIG_VSAS));
|
||||
PCONFIGVSAS = PCONFIGVSAS->pNext;
|
||||
}
|
||||
|
||||
|
||||
name = (char *) switch_xml_attr_soft(param, "name");
|
||||
id = (char *) switch_xml_attr_soft(param, "id");
|
||||
value = (char *) switch_xml_attr_soft(param, "value");
|
||||
pec = (char *) switch_xml_attr_soft(param, "pec");
|
||||
expr = (char *) switch_xml_attr_soft(param, "expr");
|
||||
direction = (char *) switch_xml_attr_soft(param, "direction");
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "config attr: %s, %s, %s, %s, %s, %s\n", name, id, value, pec, expr, direction);
|
||||
|
||||
|
||||
PCONFIGVSAS->name = (char*) malloc(STR_LENGTH + 1);
|
||||
PCONFIGVSAS->value = (char*) malloc(STR_LENGTH + 1);
|
||||
|
||||
|
||||
strncpy(PCONFIGVSAS->name, name, STR_LENGTH);
|
||||
strncpy(PCONFIGVSAS->value, value, STR_LENGTH);
|
||||
PCONFIGVSAS->id = atoi(id);
|
||||
@@ -824,8 +824,8 @@ switch_status_t load_config()
|
||||
PCONFIGVSAS->pNext = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "client")))
|
||||
{
|
||||
for (param = switch_xml_child(settings, "param"); param; param
|
||||
@@ -841,15 +841,15 @@ switch_status_t load_config()
|
||||
PCONFIGCLIENT->pNext = malloc(sizeof(CONFIG_CLIENT));
|
||||
PCONFIGCLIENT = PCONFIGCLIENT->pNext;
|
||||
}
|
||||
|
||||
|
||||
name = (char *) switch_xml_attr_soft(param, "name");
|
||||
value = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "config client: %s, %s\n", name, value);
|
||||
|
||||
|
||||
PCONFIGCLIENT->name = (char*) malloc(STR_LENGTH + 1);
|
||||
PCONFIGCLIENT->value = (char*) malloc(STR_LENGTH + 1);
|
||||
|
||||
|
||||
strncpy(PCONFIGCLIENT->name, name, STR_LENGTH);
|
||||
strncpy(PCONFIGCLIENT->value, value, STR_LENGTH);
|
||||
|
||||
@@ -869,11 +869,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rad_authload)
|
||||
switch_application_interface_t *app_interface;
|
||||
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "auth_function", NULL, NULL, auth_function, "in <USERNAME>, in <PASSWORD>, out <AUTH_RESULT>, out <BILING_MODEL>, out <CREDIT_AMOUNT>, out <CURRENCY>, out <PREFFERED_LANG>", SAF_SUPPORT_NOMEDIA);
|
||||
|
||||
load_config();
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"mod rad_auth services is loaded.\n");
|
||||
|
||||
@@ -885,51 +885,51 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_rad_authruntime)
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rad_authshutdown)
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rad_authshutdown)
|
||||
{
|
||||
CONFIG_VSAS* PCONFIGVSAS = CONFIGVSAS;
|
||||
CONFIG_CLIENT* PCONFIGCLIENT = CONFIGCLIENT;
|
||||
|
||||
|
||||
CONFIG_VSAS* tmpVSAS = NULL;
|
||||
CONFIG_CLIENT* tmpCLIENT = NULL;
|
||||
|
||||
|
||||
while(PCONFIGVSAS)
|
||||
{
|
||||
if (PCONFIGVSAS->name)
|
||||
free(PCONFIGVSAS->name);
|
||||
PCONFIGVSAS->name = NULL;
|
||||
|
||||
|
||||
if (PCONFIGVSAS->value)
|
||||
free(PCONFIGVSAS->value);
|
||||
PCONFIGVSAS->value = NULL;
|
||||
|
||||
PCONFIGVSAS->value = NULL;
|
||||
|
||||
tmpVSAS = PCONFIGVSAS;
|
||||
PCONFIGVSAS = PCONFIGVSAS->pNext;
|
||||
|
||||
|
||||
free(tmpVSAS);
|
||||
}
|
||||
|
||||
|
||||
CONFIGVSAS = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
while(PCONFIGCLIENT)
|
||||
{
|
||||
if (PCONFIGCLIENT->name)
|
||||
free(PCONFIGCLIENT->name);
|
||||
PCONFIGCLIENT->name = NULL;
|
||||
|
||||
|
||||
if (PCONFIGCLIENT->value)
|
||||
free(PCONFIGCLIENT->value);
|
||||
PCONFIGCLIENT->value = NULL;
|
||||
|
||||
PCONFIGCLIENT->value = NULL;
|
||||
|
||||
tmpCLIENT = PCONFIGCLIENT;
|
||||
PCONFIGCLIENT = PCONFIGCLIENT->pNext;
|
||||
|
||||
|
||||
free(tmpCLIENT);
|
||||
}
|
||||
|
||||
|
||||
CONFIGCLIENT = NULL;
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Neal Horman <neal at wanlink dot com>
|
||||
*
|
||||
@@ -174,7 +174,7 @@ static void event_handler(switch_event_t *event)
|
||||
char *buf;
|
||||
|
||||
if (switch_event_serialize(event, &buf, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
||||
random_add_entropy(rfd, buf, strlen(buf));
|
||||
random_add_entropy(rfd, buf, strlen(buf));
|
||||
free(buf);
|
||||
}
|
||||
|
||||
@@ -184,23 +184,23 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_random_runtime)
|
||||
{
|
||||
|
||||
unsigned char data[1024] = {0};
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread starting using random_device_file %s\n", modname, random_device_file);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread starting using random_device_file %s\n", modname, random_device_file);
|
||||
|
||||
if ((rfd = open(random_device_file, O_RDWR)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Error opening random_device_file %s\n", modname, random_device_file);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Error opening random_device_file %s\n", modname, random_device_file);
|
||||
RUNNING = 0;
|
||||
}
|
||||
|
||||
rng_read(rfd, data, 4);
|
||||
|
||||
|
||||
while(RUNNING) {
|
||||
int16_t data[64];
|
||||
int i = 0;
|
||||
int len = sizeof(data) / 2;
|
||||
|
||||
switch_generate_sln_silence(data, len, 1, 1);
|
||||
random_add_entropy(rfd, data, len);
|
||||
random_add_entropy(rfd, data, len);
|
||||
|
||||
while(i < len && !data[i]) i++;
|
||||
|
||||
@@ -214,7 +214,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_random_runtime)
|
||||
close(rfd);
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread ending\n", modname);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Thread ending\n", modname);
|
||||
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
@@ -97,11 +97,11 @@ typedef struct _cr_buffer {
|
||||
int size;
|
||||
} cr_buffer;
|
||||
|
||||
typedef struct _cr_multibulk {
|
||||
char **bulks;
|
||||
typedef struct _cr_multibulk {
|
||||
char **bulks;
|
||||
int *idxs;
|
||||
int size;
|
||||
int len;
|
||||
int len;
|
||||
} cr_multibulk;
|
||||
|
||||
typedef struct _cr_reply {
|
||||
@@ -157,12 +157,12 @@ static int cr_moremem(cr_buffer *buf, int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate at least `size' more multibulk storage, keeping content of
|
||||
/* Allocate at least `size' more multibulk storage, keeping content of
|
||||
* previously allocated memory untouched.
|
||||
* Returns:
|
||||
* 0 on success
|
||||
* -1 on error, i.e. more memory not available */
|
||||
static int cr_morebulk(cr_multibulk *mb, int size)
|
||||
static int cr_morebulk(cr_multibulk *mb, int size)
|
||||
{
|
||||
char **cptr;
|
||||
int *iptr;
|
||||
@@ -171,7 +171,7 @@ static int cr_morebulk(cr_multibulk *mb, int size)
|
||||
n = (size / CR_MULTIBULK_SIZE + 1) * CR_MULTIBULK_SIZE;
|
||||
total = mb->size + n;
|
||||
|
||||
DEBUG("allocate %d x CR_MULTIBULK_SIZE, total %d (%lu bytes)",
|
||||
DEBUG("allocate %d x CR_MULTIBULK_SIZE, total %d (%lu bytes)",
|
||||
n, total, total * ((sizeof(char *)+sizeof(int))));
|
||||
cptr = realloc(mb->bulks, total * sizeof(char *));
|
||||
|
||||
@@ -209,7 +209,7 @@ static int cr_appendstr(cr_buffer *buf, const char *str, int space)
|
||||
DEBUG("truncated, get more memory and try again");
|
||||
if (cr_moremem(buf, rc - avail + 1))
|
||||
return CREDIS_ERR_NOMEM;
|
||||
|
||||
|
||||
avail = buf->size - buf->len;
|
||||
rc = snprintf(buf->data + buf->len, avail, format, str);
|
||||
}
|
||||
@@ -218,8 +218,8 @@ static int cr_appendstr(cr_buffer *buf, const char *str, int space)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Appends an array of strings `strv' to the end of buffer `buf', each
|
||||
* separated with a space. If `newline' is not 0 "\r\n" is added last
|
||||
/* Appends an array of strings `strv' to the end of buffer `buf', each
|
||||
* separated with a space. If `newline' is not 0 "\r\n" is added last
|
||||
* to buffer.
|
||||
* Returns:
|
||||
* 0 on success
|
||||
@@ -241,7 +241,7 @@ int cr_appendstrarray(cr_buffer *buf, int strc, const char **strv, int newline)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Receives at most `size' bytes from socket `fd' to `buf'. Times out after
|
||||
/* Receives at most `size' bytes from socket `fd' to `buf'. Times out after
|
||||
* `msecs' milliseconds if no data has yet arrived.
|
||||
* Returns:
|
||||
* >0 number of read bytes on success
|
||||
@@ -267,11 +267,11 @@ static int cr_receivedata(int fd, unsigned int msecs, char *buf, int size)
|
||||
else if (rc == 0)
|
||||
return -2;
|
||||
else
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Sends `size' bytes from `buf' to socket `fd' and times out after `msecs'
|
||||
* milliseconds if not all data has been sent.
|
||||
/* Sends `size' bytes from `buf' to socket `fd' and times out after `msecs'
|
||||
* milliseconds if not all data has been sent.
|
||||
* Returns:
|
||||
* >0 number of bytes sent; if less than `size' it means that timeout occurred
|
||||
* -1 on error */
|
||||
@@ -280,8 +280,8 @@ static int cr_senddata(int fd, unsigned int msecs, char *buf, int size)
|
||||
fd_set fds;
|
||||
struct timeval tv;
|
||||
int rc, sent=0;
|
||||
|
||||
/* NOTE: On Linux, select() modifies timeout to reflect the amount
|
||||
|
||||
/* NOTE: On Linux, select() modifies timeout to reflect the amount
|
||||
* of time not slept, on other systems it is likely not the same */
|
||||
tv.tv_sec = msecs/1000;
|
||||
tv.tv_usec = (msecs%1000)*1000;
|
||||
@@ -301,13 +301,13 @@ static int cr_senddata(int fd, unsigned int msecs, char *buf, int size)
|
||||
else if (rc == 0) /* timeout */
|
||||
break;
|
||||
else
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
/* Buffered read line, returns pointer to zero-terminated string
|
||||
/* Buffered read line, returns pointer to zero-terminated string
|
||||
* and length of that string. `start' specifies from which byte
|
||||
* to start looking for "\r\n".
|
||||
* Returns:
|
||||
@@ -325,8 +325,8 @@ static int cr_readln(REDIS rhnd, int start, char **line, int *idx)
|
||||
/* do we need more data before we expect to find "\r\n"? */
|
||||
if ((more = buf->idx + start + 2 - buf->len) < 0)
|
||||
more = 0;
|
||||
|
||||
while (more > 0 ||
|
||||
|
||||
while (more > 0 ||
|
||||
(nl = cr_findnl(buf->data + buf->idx + start, buf->len - (buf->idx + start))) == NULL) {
|
||||
avail = buf->size - buf->len;
|
||||
if (avail < CR_BUFFER_WATERMARK || avail < more) {
|
||||
@@ -344,7 +344,7 @@ static int cr_readln(REDIS rhnd, int start, char **line, int *idx)
|
||||
}
|
||||
else if (rc == 0)
|
||||
return 0; /* EOF reached, connection terminated */
|
||||
else
|
||||
else
|
||||
return -1; /* error */
|
||||
|
||||
/* do we need more data before we expect to find "\r\n"? */
|
||||
@@ -360,13 +360,13 @@ static int cr_readln(REDIS rhnd, int start, char **line, int *idx)
|
||||
len = (int)(nl - *line);
|
||||
buf->idx = (int)((nl - buf->data) + 2); /* skip "\r\n" */
|
||||
|
||||
DEBUG("size=%d, len=%d, idx=%d, start=%d, line=%s",
|
||||
DEBUG("size=%d, len=%d, idx=%d, start=%d, line=%s",
|
||||
buf->size, buf->len, buf->idx, start, *line);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int cr_receivemultibulk(REDIS rhnd, char *line)
|
||||
static int cr_receivemultibulk(REDIS rhnd, char *line)
|
||||
{
|
||||
int bnum, blen, i, rc=0, idx;
|
||||
|
||||
@@ -385,7 +385,7 @@ static int cr_receivemultibulk(REDIS rhnd, char *line)
|
||||
for (i = 0; bnum > 0 && (rc = cr_readln(rhnd, 0, &line, NULL)) > 0; i++, bnum--) {
|
||||
if (*(line++) != CR_BULK)
|
||||
return CREDIS_ERR_PROTOCOL;
|
||||
|
||||
|
||||
blen = atoi(line);
|
||||
if (blen == -1)
|
||||
rhnd->reply.multibulk.idxs[i] = -1;
|
||||
@@ -396,7 +396,7 @@ static int cr_receivemultibulk(REDIS rhnd, char *line)
|
||||
rhnd->reply.multibulk.idxs[i] = idx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (bnum != 0) {
|
||||
DEBUG("bnum != 0, bnum=%d, rc=%d", bnum, rc);
|
||||
return CREDIS_ERR_PROTOCOL;
|
||||
@@ -413,7 +413,7 @@ static int cr_receivemultibulk(REDIS rhnd, char *line)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cr_receivebulk(REDIS rhnd, char *line)
|
||||
static int cr_receivebulk(REDIS rhnd, char *line)
|
||||
{
|
||||
int blen;
|
||||
|
||||
@@ -430,25 +430,25 @@ static int cr_receivebulk(REDIS rhnd, char *line)
|
||||
return CREDIS_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
static int cr_receiveinline(REDIS rhnd, char *line)
|
||||
static int cr_receiveinline(REDIS rhnd, char *line)
|
||||
{
|
||||
rhnd->reply.line = line;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cr_receiveint(REDIS rhnd, char *line)
|
||||
static int cr_receiveint(REDIS rhnd, char *line)
|
||||
{
|
||||
rhnd->reply.integer = atoi(line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cr_receiveerror(REDIS rhnd, char *line)
|
||||
static int cr_receiveerror(REDIS rhnd, char *line)
|
||||
{
|
||||
rhnd->reply.line = line;
|
||||
return CREDIS_ERR_PROTOCOL;
|
||||
}
|
||||
|
||||
static int cr_receivereply(REDIS rhnd, char recvtype)
|
||||
static int cr_receivereply(REDIS rhnd, char recvtype)
|
||||
{
|
||||
char *line, prefix=0;
|
||||
|
||||
@@ -458,7 +458,7 @@ static int cr_receivereply(REDIS rhnd, char recvtype)
|
||||
|
||||
if (cr_readln(rhnd, 0, &line, NULL) > 0) {
|
||||
prefix = *(line++);
|
||||
|
||||
|
||||
if (prefix != recvtype && prefix != CR_ERROR)
|
||||
return CREDIS_ERR_PROTOCOL;
|
||||
|
||||
@@ -473,13 +473,13 @@ static int cr_receivereply(REDIS rhnd, char recvtype)
|
||||
return cr_receivebulk(rhnd, line);
|
||||
case CR_MULTIBULK:
|
||||
return cr_receivemultibulk(rhnd, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CREDIS_ERR_RECV;
|
||||
}
|
||||
|
||||
static void cr_delete(REDIS rhnd)
|
||||
static void cr_delete(REDIS rhnd)
|
||||
{
|
||||
if (rhnd->reply.multibulk.bulks != NULL)
|
||||
free(rhnd->reply.multibulk.bulks);
|
||||
@@ -493,7 +493,7 @@ static void cr_delete(REDIS rhnd)
|
||||
free(rhnd);
|
||||
}
|
||||
|
||||
REDIS cr_new(void)
|
||||
REDIS cr_new(void)
|
||||
{
|
||||
REDIS rhnd;
|
||||
|
||||
@@ -503,7 +503,7 @@ REDIS cr_new(void)
|
||||
(rhnd->reply.multibulk.bulks = malloc(sizeof(char *)*CR_MULTIBULK_SIZE)) == NULL ||
|
||||
(rhnd->reply.multibulk.idxs = malloc(sizeof(int)*CR_MULTIBULK_SIZE)) == NULL) {
|
||||
cr_delete(rhnd);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rhnd->buf.size = CR_BUFFER_SIZE;
|
||||
@@ -575,7 +575,7 @@ REDIS credis_connect(const char *host, int port, int timeout)
|
||||
{
|
||||
credis_socket_t fd = CREDIS_SOCK_INVALID;
|
||||
int yes = 1;
|
||||
struct sockaddr_in sa;
|
||||
struct sockaddr_in sa;
|
||||
REDIS rhnd;
|
||||
int valid = 0;
|
||||
|
||||
@@ -617,7 +617,7 @@ REDIS credis_connect(const char *host, int port, int timeout)
|
||||
rhnd->port = port;
|
||||
rhnd->fd = fd;
|
||||
rhnd->timeout = timeout;
|
||||
|
||||
|
||||
return rhnd;
|
||||
|
||||
error:
|
||||
@@ -627,7 +627,7 @@ REDIS credis_connect(const char *host, int port, int timeout)
|
||||
|
||||
int credis_set(REDIS rhnd, const char *key, const char *val)
|
||||
{
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "SET %s %d\r\n%s\r\n",
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "SET %s %d\r\n%s\r\n",
|
||||
key, strlen(val), val);
|
||||
}
|
||||
|
||||
@@ -644,7 +644,7 @@ int credis_get(REDIS rhnd, const char *key, char **val)
|
||||
|
||||
int credis_getset(REDIS rhnd, const char *key, const char *set_val, char **get_val)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_BULK, "GETSET %s %d\r\n%s\r\n",
|
||||
int rc = cr_sendfandreceive(rhnd, CR_BULK, "GETSET %s %d\r\n%s\r\n",
|
||||
key, strlen(set_val), set_val);
|
||||
|
||||
if (rc == 0)
|
||||
@@ -654,7 +654,7 @@ int credis_getset(REDIS rhnd, const char *key, const char *set_val, char **get_v
|
||||
return rc;
|
||||
}
|
||||
|
||||
int credis_ping(REDIS rhnd)
|
||||
int credis_ping(REDIS rhnd)
|
||||
{
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "PING\r\n");
|
||||
}
|
||||
@@ -664,7 +664,7 @@ int credis_auth(REDIS rhnd, const char *password)
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "AUTH %s\r\n", password);
|
||||
}
|
||||
|
||||
int cr_multikeybulkcommand(REDIS rhnd, const char *cmd, int keyc,
|
||||
int cr_multikeybulkcommand(REDIS rhnd, const char *cmd, int keyc,
|
||||
const char **keyv, char ***valv)
|
||||
{
|
||||
cr_buffer *buf = &(rhnd->buf);
|
||||
@@ -683,7 +683,7 @@ int cr_multikeybulkcommand(REDIS rhnd, const char *cmd, int keyc,
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cr_multikeystorecommand(REDIS rhnd, const char *cmd, const char *destkey,
|
||||
int cr_multikeystorecommand(REDIS rhnd, const char *cmd, const char *destkey,
|
||||
int keyc, const char **keyv)
|
||||
{
|
||||
cr_buffer *buf = &(rhnd->buf);
|
||||
@@ -707,7 +707,7 @@ int credis_mget(REDIS rhnd, int keyc, const char **keyv, char ***valv)
|
||||
|
||||
int credis_setnx(REDIS rhnd, const char *key, const char *val)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "SETNX %s %d\r\n%s\r\n",
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "SETNX %s %d\r\n%s\r\n",
|
||||
key, strlen(val), val);
|
||||
|
||||
if (rc == 0)
|
||||
@@ -722,10 +722,10 @@ static int cr_incr(REDIS rhnd, int incr, int decr, const char *key, int *new_val
|
||||
int rc = 0;
|
||||
|
||||
if (incr == 1 || decr == 1)
|
||||
rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s\r\n",
|
||||
rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s\r\n",
|
||||
incr>0?"INCR":"DECR", key);
|
||||
else if (incr > 1 || decr > 1)
|
||||
rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s %d\r\n",
|
||||
rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s %d\r\n",
|
||||
incr>0?"INCRBY":"DECRBY", key, incr>0?incr:decr);
|
||||
|
||||
if (rc == 0 && new_val != NULL)
|
||||
@@ -822,7 +822,7 @@ int credis_randomkey(REDIS rhnd, char **key)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INLINE, "RANDOMKEY\r\n");
|
||||
|
||||
if (rc == 0)
|
||||
if (rc == 0)
|
||||
*key = rhnd->reply.line;
|
||||
|
||||
return rc;
|
||||
@@ -830,13 +830,13 @@ int credis_randomkey(REDIS rhnd, char **key)
|
||||
|
||||
int credis_rename(REDIS rhnd, const char *key, const char *new_key_name)
|
||||
{
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "RENAME %s %s\r\n",
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "RENAME %s %s\r\n",
|
||||
key, new_key_name);
|
||||
}
|
||||
|
||||
int credis_renamenx(REDIS rhnd, const char *key, const char *new_key_name)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "RENAMENX %s %s\r\n",
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "RENAMENX %s %s\r\n",
|
||||
key, new_key_name);
|
||||
|
||||
if (rc == 0)
|
||||
@@ -850,14 +850,14 @@ int credis_dbsize(REDIS rhnd)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "DBSIZE\r\n");
|
||||
|
||||
if (rc == 0)
|
||||
if (rc == 0)
|
||||
rc = rhnd->reply.integer;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int credis_expire(REDIS rhnd, const char *key, int secs)
|
||||
{
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "EXPIRE %s %d\r\n", key, secs);
|
||||
|
||||
if (rc == 0)
|
||||
@@ -879,7 +879,7 @@ int credis_ttl(REDIS rhnd, const char *key)
|
||||
|
||||
int cr_push(REDIS rhnd, int left, const char *key, const char *val)
|
||||
{
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "%s %s %d\r\n%s\r\n",
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "%s %s %d\r\n%s\r\n",
|
||||
left==1?"LPUSH":"RPUSH", key, strlen(val), val);
|
||||
}
|
||||
|
||||
@@ -897,7 +897,7 @@ int credis_llen(REDIS rhnd, const char *key)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "LLEN %s\r\n", key);
|
||||
|
||||
if (rc == 0)
|
||||
if (rc == 0)
|
||||
rc = rhnd->reply.integer;
|
||||
|
||||
return rc;
|
||||
@@ -907,7 +907,7 @@ int credis_lrange(REDIS rhnd, const char *key, int start, int end, char ***valv)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if ((rc = cr_sendfandreceive(rhnd, CR_MULTIBULK, "LRANGE %s %d %d\r\n",
|
||||
if ((rc = cr_sendfandreceive(rhnd, CR_MULTIBULK, "LRANGE %s %d %d\r\n",
|
||||
key, start, end)) == 0) {
|
||||
*valv = rhnd->reply.multibulk.bulks;
|
||||
rc = rhnd->reply.multibulk.len;
|
||||
@@ -918,7 +918,7 @@ int credis_lrange(REDIS rhnd, const char *key, int start, int end, char ***valv)
|
||||
|
||||
int credis_ltrim(REDIS rhnd, const char *key, int start, int end)
|
||||
{
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "LTRIM %s %d %d\r\n",
|
||||
return cr_sendfandreceive(rhnd, CR_INLINE, "LTRIM %s %d %d\r\n",
|
||||
key, start, end);
|
||||
}
|
||||
|
||||
@@ -945,7 +945,7 @@ int credis_lrem(REDIS rhnd, const char *key, int count, const char *val)
|
||||
|
||||
static int cr_pop(REDIS rhnd, int left, const char *key, char **val)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_BULK, "%s %s\r\n",
|
||||
int rc = cr_sendfandreceive(rhnd, CR_BULK, "%s %s\r\n",
|
||||
left==1?"LPOP":"RPOP", key);
|
||||
|
||||
if (rc == 0)
|
||||
@@ -1061,13 +1061,13 @@ int credis_info(REDIS rhnd, REDIS_INFO *info)
|
||||
&(info->total_connections_received),
|
||||
&(info->total_commands_processed),
|
||||
role);
|
||||
|
||||
|
||||
if (items != CR_NUMBER_OF_ITEMS)
|
||||
return CREDIS_ERR_PROTOCOL; /* not enough input items returned */
|
||||
|
||||
|
||||
info->role = ((role[0]=='m')?CREDIS_SERVER_MASTER:CREDIS_SERVER_SLAVE);
|
||||
}
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1086,7 +1086,7 @@ int credis_slaveof(REDIS rhnd, const char *host, int port)
|
||||
|
||||
static int cr_setaddrem(REDIS rhnd, const char *cmd, const char *key, const char *member)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s %d\r\n%s\r\n",
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "%s %s %d\r\n%s\r\n",
|
||||
cmd, key, strlen(member), member);
|
||||
|
||||
if (rc == 0)
|
||||
@@ -1117,10 +1117,10 @@ int credis_spop(REDIS rhnd, const char *key, char **member)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
|
||||
int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
|
||||
const char *member)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "SMOVE %s %s %s\r\n",
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "SMOVE %s %s %s\r\n",
|
||||
sourcekey, destkey, member);
|
||||
|
||||
if (rc == 0)
|
||||
@@ -1130,7 +1130,7 @@ int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
|
||||
return rc;
|
||||
}
|
||||
|
||||
int credis_scard(REDIS rhnd, const char *key)
|
||||
int credis_scard(REDIS rhnd, const char *key)
|
||||
{
|
||||
int rc = cr_sendfandreceive(rhnd, CR_INT, "SCARD %s\r\n", key);
|
||||
|
||||
|
||||
@@ -35,31 +35,31 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Functions below should map quite nicely to Redis 1.02 command set.
|
||||
* Refer to the official Redis documentation for further explanation of
|
||||
/* Functions below should map quite nicely to Redis 1.02 command set.
|
||||
* Refer to the official Redis documentation for further explanation of
|
||||
* each command. See credis examples that show how functions can be used.
|
||||
* Here is a brief example that connects to a Redis server and sets value
|
||||
* of key `fruit' to `banana':
|
||||
* Here is a brief example that connects to a Redis server and sets value
|
||||
* of key `fruit' to `banana':
|
||||
*
|
||||
* REDIS rh = credis_connect("localhost", 6789, 2000);
|
||||
* credis_set(rh, "fruit", "banana");
|
||||
* credis_close(rh);
|
||||
*
|
||||
* In general, functions return 0 on success or a negative value on
|
||||
* error. Refer to CREDIS_ERR_* codes. The return code -1 is typically
|
||||
* used when for instance a key is not found.
|
||||
* error. Refer to CREDIS_ERR_* codes. The return code -1 is typically
|
||||
* used when for instance a key is not found.
|
||||
*
|
||||
* IMPORTANT! Memory buffers are allocated, used and managed by credis
|
||||
* internally. Subsequent calls to credis functions _will_ destroy the
|
||||
* data to which returned values reference to. If for instance the
|
||||
* returned value by a call to credis_get() is to be used later in the
|
||||
* program, a strdup() is highly recommended. However, each `REDIS'
|
||||
* handle has its own state and manages its own memory buffer
|
||||
* IMPORTANT! Memory buffers are allocated, used and managed by credis
|
||||
* internally. Subsequent calls to credis functions _will_ destroy the
|
||||
* data to which returned values reference to. If for instance the
|
||||
* returned value by a call to credis_get() is to be used later in the
|
||||
* program, a strdup() is highly recommended. However, each `REDIS'
|
||||
* handle has its own state and manages its own memory buffer
|
||||
* independently. That means that one of two handles can be destroyed
|
||||
* while the other keeps its connection and data.
|
||||
*
|
||||
*
|
||||
* TODO
|
||||
* - Currently only support for zero-terminated strings, not for storing
|
||||
* - Currently only support for zero-terminated strings, not for storing
|
||||
* abritary binary data as bulk data. Basically an API issue since it
|
||||
* is partially supported internally.
|
||||
* - Support for Redis >= 1.1 protocol
|
||||
@@ -108,7 +108,7 @@ typedef struct _cr_info {
|
||||
* Connection handling
|
||||
*/
|
||||
|
||||
/* setting host to NULL will use "localhost". setting port to 0 will use
|
||||
/* setting host to NULL will use "localhost". setting port to 0 will use
|
||||
* default port 6379 */
|
||||
REDIS credis_connect(const char *host, int port, int timeout);
|
||||
|
||||
@@ -120,8 +120,8 @@ int credis_auth(REDIS rhnd, const char *password);
|
||||
|
||||
int credis_ping(REDIS rhnd);
|
||||
|
||||
/*
|
||||
* Commands operating on string values
|
||||
/*
|
||||
* Commands operating on string values
|
||||
*/
|
||||
|
||||
int credis_set(REDIS rhnd, const char *key, const char *val);
|
||||
@@ -156,14 +156,14 @@ int credis_del(REDIS rhnd, const char *key);
|
||||
/* returns type, refer to CREDIS_TYPE_* defines */
|
||||
int credis_type(REDIS rhnd, const char *key);
|
||||
|
||||
/* TODO for Redis >= 1.1
|
||||
/* TODO for Redis >= 1.1
|
||||
* MSET key1 value1 key2 value2 ... keyN valueN set a multiple keys to multiple values in a single atomic operation
|
||||
* MSETNX key1 value1 key2 value2 ... keyN valueN set a multiple keys to multiple values in a single atomic operation if none of
|
||||
* DEL key1 key2 ... keyN remove multiple keys
|
||||
* DEL key1 key2 ... keyN remove multiple keys
|
||||
*/
|
||||
|
||||
/*
|
||||
* Commands operating on key space
|
||||
* Commands operating on key space
|
||||
*/
|
||||
|
||||
int credis_keys(REDIS rhnd, const char *pattern, char **keyv, int len);
|
||||
@@ -178,16 +178,16 @@ int credis_renamenx(REDIS rhnd, const char *key, const char *new_key_name);
|
||||
/* returns size of db */
|
||||
int credis_dbsize(REDIS rhnd);
|
||||
|
||||
/* returns -1 if the timeout was not set; either due to key already has
|
||||
/* returns -1 if the timeout was not set; either due to key already has
|
||||
an associated timeout or key does not exist */
|
||||
int credis_expire(REDIS rhnd, const char *key, int secs);
|
||||
|
||||
/* returns time to live seconds or -1 if key does not exists or does not
|
||||
/* returns time to live seconds or -1 if key does not exists or does not
|
||||
* have expire set */
|
||||
int credis_ttl(REDIS rhnd, const char *key);
|
||||
|
||||
/*
|
||||
* Commands operating on lists
|
||||
* Commands operating on lists
|
||||
*/
|
||||
|
||||
int credis_rpush(REDIS rhnd, const char *key, const char *element);
|
||||
@@ -216,8 +216,8 @@ int credis_lpop(REDIS rhnd, const char *key, char **val);
|
||||
/* returns -1 if the key doesn't exists */
|
||||
int credis_rpop(REDIS rhnd, const char *key, char **val);
|
||||
|
||||
/* TODO for Redis >= 1.1
|
||||
* RPOPLPUSH srckey dstkey
|
||||
/* TODO for Redis >= 1.1
|
||||
* RPOPLPUSH srckey dstkey
|
||||
*
|
||||
* TODO for Redis >= 1.3.1
|
||||
* BLPOP key1 key2 ... keyN timeout
|
||||
@@ -225,7 +225,7 @@ int credis_rpop(REDIS rhnd, const char *key, char **val);
|
||||
*/
|
||||
|
||||
/*
|
||||
* Commands operating on sets
|
||||
* Commands operating on sets
|
||||
*/
|
||||
|
||||
/* returns -1 if the given member was already a member of the set */
|
||||
@@ -241,7 +241,7 @@ int credis_sismember(REDIS rhnd, const char *key, const char *member);
|
||||
int credis_spop(REDIS rhnd, const char *key, char **member);
|
||||
|
||||
/* returns -1 if the member doesn't exists in the source set */
|
||||
int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
|
||||
int credis_smove(REDIS rhnd, const char *sourcekey, const char *destkey,
|
||||
const char *member);
|
||||
|
||||
/* returns cardinality (number of members) or 0 if the given key doesn't exists */
|
||||
@@ -276,12 +276,12 @@ int credis_smembers(REDIS rhnd, const char *key, char ***members);
|
||||
*/
|
||||
|
||||
/*
|
||||
* Multiple databases handling commands
|
||||
* Multiple databases handling commands
|
||||
*/
|
||||
|
||||
int credis_select(REDIS rhnd, int index);
|
||||
|
||||
/* returns -1 if the key was not moved; already present at target
|
||||
/* returns -1 if the key was not moved; already present at target
|
||||
* or not found on current db */
|
||||
int credis_move(REDIS rhnd, const char *key, int index);
|
||||
|
||||
@@ -290,14 +290,14 @@ int credis_flushdb(REDIS rhnd);
|
||||
int credis_flushall(REDIS rhnd);
|
||||
|
||||
/*
|
||||
* Sorting
|
||||
* Sorting
|
||||
*/
|
||||
|
||||
/* returns number of elements returned in vector `elementv' */
|
||||
int credis_sort(REDIS rhnd, const char *query, char ***elementv);
|
||||
|
||||
/*
|
||||
* Persistence control commands
|
||||
/*
|
||||
* Persistence control commands
|
||||
*/
|
||||
|
||||
int credis_save(REDIS rhnd);
|
||||
@@ -310,7 +310,7 @@ int credis_lastsave(REDIS rhnd);
|
||||
int credis_shutdown(REDIS rhnd);
|
||||
|
||||
/*
|
||||
* Remote server control commands
|
||||
* Remote server control commands
|
||||
*/
|
||||
|
||||
int credis_info(REDIS rhnd, REDIS_INFO *info);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Kevin Morizur <kmorizur@avgs.ca>
|
||||
* Kevin Morizur <kmorizur@avgs.ca>
|
||||
* Mathieu Rene <mrene@avgs.ca>
|
||||
*
|
||||
* mod_redis.c -- Redis limit backend
|
||||
@@ -45,7 +45,7 @@ static struct{
|
||||
|
||||
static switch_xml_config_item_t instructions[] = {
|
||||
/* parameter name type reloadable pointer default value options structure */
|
||||
SWITCH_CONFIG_ITEM_STRING_STRDUP("host", CONFIG_RELOAD, &globals.host, NULL, "localhost", "Hostname for redis server"),
|
||||
SWITCH_CONFIG_ITEM_STRING_STRDUP("host", CONFIG_RELOAD, &globals.host, NULL, "localhost", "Hostname for redis server"),
|
||||
SWITCH_CONFIG_ITEM("port", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.port, (void *) 6379, NULL,NULL, NULL),
|
||||
SWITCH_CONFIG_ITEM("timeout", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.timeout, (void *) 10000, NULL,NULL, NULL),
|
||||
SWITCH_CONFIG_ITEM("ignore_connect_fail", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.ignore_connect_fail, SWITCH_FALSE, NULL, "true|false", "Set to true in order to continue when redis is not contactable"),
|
||||
@@ -58,10 +58,10 @@ typedef struct {
|
||||
switch_mutex_t *mutex;
|
||||
} limit_redis_private_t;
|
||||
|
||||
static switch_status_t redis_factory(REDIS *redis)
|
||||
static switch_status_t redis_factory(REDIS *redis)
|
||||
{
|
||||
if (!((*redis) = credis_connect(globals.host, globals.port, globals.timeout))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't connect to redis server at %s:%d timeout:%d\n", globals.host, globals.port, globals.timeout);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't connect to redis server at %s:%d timeout:%d\n", globals.host, globals.port, globals.timeout);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -83,7 +83,7 @@ SWITCH_LIMIT_INCR(limit_incr_redis)
|
||||
char *rediskey = NULL;
|
||||
char *uuid_rediskey = NULL;
|
||||
uint8_t increment = 1;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
REDIS redis;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "mod_redis is deprecated and will be removed in FS 1.8. Check out mod_hiredis.\n");
|
||||
@@ -110,11 +110,11 @@ SWITCH_LIMIT_INCR(limit_incr_redis)
|
||||
switch_mutex_init(&pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||
switch_channel_set_private(channel, "limit_redis", pvt);
|
||||
}
|
||||
|
||||
|
||||
if (!(switch_core_hash_find_locked(pvt->hash, rediskey, pvt->mutex))) {
|
||||
switch_core_hash_insert_locked(pvt->hash, rediskey, rediskey, pvt->mutex);
|
||||
}
|
||||
|
||||
|
||||
if (increment) {
|
||||
if (credis_incr(redis, rediskey, &val) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't increment value corresponding to %s\n", rediskey);
|
||||
@@ -127,7 +127,7 @@ SWITCH_LIMIT_INCR(limit_incr_redis)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", rediskey);
|
||||
switch_goto_status(SWITCH_STATUS_GENERR, end);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s exceeds maximum rate of %d\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s exceeds maximum rate of %d\n",
|
||||
rediskey, max);
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ SWITCH_LIMIT_INCR(limit_incr_redis)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't increment value corresponding to %s\n", uuid_rediskey);
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (credis_incr(redis, uuid_rediskey, &uuid_val) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't increment value corresponding to %s\n", uuid_rediskey);
|
||||
@@ -154,7 +154,7 @@ end:
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* !\brief Releases usage of a limit_redis-controlled ressource */
|
||||
SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
{
|
||||
@@ -165,12 +165,12 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
char *uuid_rediskey = NULL;
|
||||
int status = SWITCH_STATUS_SUCCESS;
|
||||
REDIS redis;
|
||||
|
||||
|
||||
if (!pvt || !pvt->hash) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No hashtable for channel %s\n", switch_channel_get_name(channel));
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if (redis_factory(&redis) != SWITCH_STATUS_SUCCESS) {
|
||||
if ( globals.ignore_connect_fail ) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ignore_connect_fail=true, so ignoring the fact that redis was not contactabl and continuing with the call\n" );
|
||||
@@ -192,9 +192,9 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
const void *p_key;
|
||||
char *p_uuid_key = NULL;
|
||||
switch_ssize_t keylen;
|
||||
|
||||
|
||||
switch_core_hash_this(hi, &p_key, &keylen, &p_val);
|
||||
|
||||
|
||||
if (credis_decr(redis, (const char*)p_key, &val) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", (char *)p_key);
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
@@ -210,8 +210,8 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "Limit incr redis : uuid_rediskey : %s uuid_val : %d\n",
|
||||
p_uuid_key, uuid_val);*/
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
} else {
|
||||
rediskey = switch_core_session_sprintf(session, "%s_%s", realm, resource);
|
||||
uuid_rediskey = switch_core_session_sprintf(session, "%s_%s_%s", switch_core_get_switchname(), realm, resource);
|
||||
switch_core_hash_delete(pvt->hash, (const char *) rediskey);
|
||||
@@ -224,7 +224,7 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Couldn't decrement value corresponding to %s\n", uuid_rediskey);
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Limit release redis : rediskey : %s val : %d\n", rediskey,val);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Limit incr redis : uuid_rediskey : %s uuid_val : %d\n", uuid_rediskey,uuid_val);
|
||||
@@ -244,23 +244,23 @@ SWITCH_LIMIT_USAGE(limit_usage_redis)
|
||||
char *str;
|
||||
REDIS redis;
|
||||
int usage;
|
||||
|
||||
|
||||
if (redis_factory(&redis) != SWITCH_STATUS_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
redis_key = switch_mprintf("%s_%s", realm, resource);
|
||||
|
||||
|
||||
if (credis_get(redis, redis_key, &str) != 0){
|
||||
usage = 0;
|
||||
} else {
|
||||
usage = atoi(str);
|
||||
usage = atoi(str);
|
||||
}
|
||||
|
||||
|
||||
if (redis) {
|
||||
credis_close(redis);
|
||||
}
|
||||
|
||||
|
||||
switch_safe_free(redis_key);
|
||||
return usage;
|
||||
}
|
||||
@@ -272,23 +272,23 @@ SWITCH_LIMIT_RESET(limit_reset_redis)
|
||||
char *rediskey = switch_mprintf("%s_*", switch_core_get_switchname());
|
||||
int dec = 0, val = 0, keyc;
|
||||
char *uuids[2000];
|
||||
|
||||
|
||||
if ((keyc = credis_keys(redis, rediskey, uuids, switch_arraylen(uuids))) > 0) {
|
||||
int i = 0;
|
||||
int hostnamelen = (int)strlen(switch_core_get_switchname())+1;
|
||||
|
||||
|
||||
for (i = 0; i < keyc && uuids[i]; i++){
|
||||
const char *key = uuids[i] + hostnamelen;
|
||||
char *value;
|
||||
|
||||
|
||||
if ((int)strlen(uuids[i]) <= hostnamelen) {
|
||||
continue; /* Sanity check */
|
||||
}
|
||||
|
||||
|
||||
credis_get(redis, key, &value);
|
||||
dec = atoi(value);
|
||||
credis_decrby(redis, key, dec, &val);
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DECR %s by %d. value is now %d\n", key, dec, val);
|
||||
}
|
||||
}
|
||||
@@ -312,7 +312,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_redis_load)
|
||||
switch_limit_interface_t *limit_interface = NULL;
|
||||
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
|
||||
if (switch_xml_config_parse_module_settings("redis.conf", SWITCH_FALSE, instructions) != SWITCH_STATUS_SUCCESS) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -321,9 +321,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_redis_load)
|
||||
|
||||
/* If FreeSWITCH was restarted and we still have active calls, decrement them so our global count stays valid */
|
||||
limit_reset_redis();
|
||||
|
||||
|
||||
SWITCH_ADD_LIMIT(limit_interface, "redis", limit_incr_redis, limit_release_redis, limit_usage_redis, limit_reset_redis, limit_status_redis, NULL);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Bret McDanel <trixter AT 0xdecafbad.com>
|
||||
*
|
||||
@@ -84,7 +84,7 @@ static uint32_t match_count(char *str, uint32_t max)
|
||||
|
||||
|
||||
/*
|
||||
dtmf handler function you can hook up to be executed when a digit is dialed during playback
|
||||
dtmf handler function you can hook up to be executed when a digit is dialed during playback
|
||||
if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
|
||||
*/
|
||||
static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
|
||||
@@ -351,8 +351,8 @@ SWITCH_STANDARD_APP(rss_function)
|
||||
if ((p = strchr(cmd, '#'))) {
|
||||
*p = '\0';
|
||||
#ifdef MATCH_COUNT
|
||||
/* Hmmm... I know there are no more matches so I don't *need* them to press pound but
|
||||
I already told them to press it. Will this confuse people or not? Let's make em press
|
||||
/* Hmmm... I know there are no more matches so I don't *need* them to press pound but
|
||||
I already told them to press it. Will this confuse people or not? Let's make em press
|
||||
pound unless this define is enabled for now.
|
||||
*/
|
||||
} else if (match_count(cmd, feed_index) > 1) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Neal Horman <neal at wanlink dot com>
|
||||
*
|
||||
@@ -37,7 +37,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skel_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_skel_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_skel_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_skel, mod_skel_load, mod_skel_shutdown, NULL);
|
||||
@@ -65,7 +65,7 @@ static switch_status_t config_callback_siptrace(switch_xml_config_item_t *data,
|
||||
/*
|
||||
if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) && changed) {
|
||||
nua_set_params(((sofia_profile_t*)data->functiondata)->nua, TPTAG_LOG(value), TAG_END());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -188,7 +188,7 @@ SWITCH_STANDARD_API(skel_function)
|
||||
switch_snprintf(name, sizeof(name), "test-header-%d", x);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, name, "value-%d", x);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Nothing up my sleeve, here is the event */
|
||||
|
||||
@@ -218,8 +218,8 @@ static void mycb(switch_core_session_t *session, switch_channel_callstate_t call
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT,
|
||||
"%s device: %s\nState: %s Dev State: %s/%s Total:%u Offhook:%u Active:%u Held:%u Hungup:%u Dur: %u %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT,
|
||||
"%s device: %s\nState: %s Dev State: %s/%s Total:%u Offhook:%u Active:%u Held:%u Hungup:%u Dur: %u %s\n",
|
||||
switch_channel_get_name(channel),
|
||||
drec->device_id,
|
||||
switch_channel_callstate2str(callstate),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,11 +22,11 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Raymond Chandler <intralanman@freeswitch.org>
|
||||
*
|
||||
* mod_sms.c -- Abstract SMS
|
||||
* mod_sms.c -- Abstract SMS
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
@@ -70,7 +70,7 @@ static void send_report(switch_event_t *event, const char * Status) {
|
||||
}
|
||||
}
|
||||
|
||||
static void event_handler(switch_event_t *event)
|
||||
static void event_handler(switch_event_t *event)
|
||||
{
|
||||
const char *dest_proto = switch_event_get_header(event, "dest_proto");
|
||||
const char *check_failure = switch_event_get_header(event, "Delivery-Failure");
|
||||
@@ -115,7 +115,7 @@ typedef enum {
|
||||
} else { \
|
||||
tzoff = NULL; \
|
||||
} \
|
||||
} while(tzoff)
|
||||
} while(tzoff)
|
||||
|
||||
static int parse_exten(switch_event_t *event, switch_xml_t xexten, switch_event_t **extension)
|
||||
{
|
||||
@@ -400,7 +400,7 @@ static switch_event_t *chatplan_hunt(switch_event_t *event)
|
||||
}
|
||||
|
||||
xexten = switch_xml_child(xcontext, "extension");
|
||||
|
||||
|
||||
while (xexten) {
|
||||
int proceed = 0;
|
||||
const char *cont = switch_xml_attr(xexten, "continue");
|
||||
@@ -415,7 +415,7 @@ static switch_event_t *chatplan_hunt(switch_event_t *event)
|
||||
to, context, exten_name, cont ? cont : "false");
|
||||
|
||||
proceed = parse_exten(event, xexten, &extension);
|
||||
|
||||
|
||||
if (proceed && !switch_true(cont)) {
|
||||
break;
|
||||
}
|
||||
@@ -445,7 +445,7 @@ static switch_status_t chat_send(switch_event_t *message_event)
|
||||
forwards = 70;
|
||||
} else {
|
||||
forwards = atoi(var);
|
||||
|
||||
|
||||
if (forwards) {
|
||||
forwards--;
|
||||
}
|
||||
@@ -463,11 +463,11 @@ static switch_status_t chat_send(switch_event_t *message_event)
|
||||
|
||||
if ((exten = chatplan_hunt(message_event))) {
|
||||
switch_event_header_t *hp;
|
||||
|
||||
|
||||
for (hp = exten->headers; hp; hp = hp->next) {
|
||||
status = switch_core_execute_chat_app(message_event, hp->name, hp->value);
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -542,7 +542,7 @@ SWITCH_STANDARD_CHAT_APP(set_function)
|
||||
if ((val = strchr(var, '='))) {
|
||||
*val++ = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (zstr(val)) {
|
||||
switch_event_del_header(message, var);
|
||||
} else {
|
||||
@@ -618,7 +618,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sms_load)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
@@ -632,7 +632,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sms_load)
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "send", "send the message as-is", "send the message as-is", send_function, "", SCAF_NONE);
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "fire", "fire the message", "fire the message", fire_function, "", SCAF_NONE);
|
||||
SWITCH_ADD_CHAT_APP(chat_app_interface, "system", "execute a system command", "execute a sytem command", system_function, "", SCAF_NONE);
|
||||
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -645,7 +645,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sms_shutdown)
|
||||
switch_event_unbind_callback(event_handler);
|
||||
|
||||
switch_event_free_subclass(MY_EVENT_DELIVERY_REPORT);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +96,11 @@ static void *SWITCH_THREAD_FUNC mod_sms_flowroute_profile_event_thread(switch_th
|
||||
fprintf(stderr, "Unable to listen on socket [%d]\n", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sock = h2o_evloop_socket_create(profile->h2o_context.loop, fd, H2O_SOCKET_FLAG_DONT_READ);
|
||||
sock->data = (void *) profile;
|
||||
h2o_socket_read_start(sock, on_accept);
|
||||
|
||||
|
||||
while ( profile->running ) {
|
||||
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile[%s] event thread loop\n", profile->name);
|
||||
h2o_timeout_init(profile->h2o_context.loop, &timeout, 1000); /* 1 second loop */
|
||||
@@ -115,7 +115,7 @@ static void *SWITCH_THREAD_FUNC mod_sms_flowroute_profile_event_thread(switch_th
|
||||
h2o_socket_close(sock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
switch_status_t mod_sms_flowroute_profile_destroy(mod_sms_flowroute_profile_t **old_profile)
|
||||
{
|
||||
mod_sms_flowroute_profile_t *profile = NULL;
|
||||
@@ -124,9 +124,9 @@ switch_status_t mod_sms_flowroute_profile_destroy(mod_sms_flowroute_profile_t **
|
||||
if ( !old_profile || !*old_profile ) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
profile = *old_profile;
|
||||
|
||||
|
||||
switch_core_hash_delete(mod_sms_flowroute_globals.profile_hash, profile->name);
|
||||
|
||||
profile->running = 0;
|
||||
@@ -139,7 +139,7 @@ switch_status_t mod_sms_flowroute_profile_destroy(mod_sms_flowroute_profile_t **
|
||||
switch_safe_free(profile->h2o_context.loop);
|
||||
h2o_context_dispose(&(profile->h2o_context));
|
||||
h2o_config_dispose(&(profile->h2o_globalconf));
|
||||
|
||||
|
||||
switch_core_destroy_memory_pool(&(profile->pool));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile[%s] destroyed\n", profile->name);
|
||||
|
||||
@@ -162,14 +162,14 @@ static int mod_sms_flowroute_profile_request_handler(h2o_handler_t *handler, h2o
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid request received[%.*s]", (int) request->entity.len, request->entity.base);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
switch_event_create(&evt, SWITCH_EVENT_MESSAGE);
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "to", cJSON_GetObjectCstr(parsed, "to"));
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "body", cJSON_GetObjectCstr(parsed, "body"));
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "from", cJSON_GetObjectCstr(parsed, "from"));
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "record_id", cJSON_GetObjectCstr(parsed, "id"));
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "context", "default");
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "proto", "sms_flowroute");
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "to", cJSON_GetObjectCstr(parsed, "to"));
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "body", cJSON_GetObjectCstr(parsed, "body"));
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "from", cJSON_GetObjectCstr(parsed, "from"));
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "record_id", cJSON_GetObjectCstr(parsed, "id"));
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "context", "default");
|
||||
switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "proto", "sms_flowroute");
|
||||
|
||||
switch_core_chat_send("GLOBAL_SMS", evt);
|
||||
switch_event_destroy(&evt);
|
||||
@@ -181,7 +181,7 @@ static int mod_sms_flowroute_profile_request_handler(h2o_handler_t *handler, h2o
|
||||
h2o_send(request, &body, 1, 1);
|
||||
|
||||
done:
|
||||
|
||||
|
||||
cJSON_Delete(parsed);
|
||||
switch_safe_free(content);
|
||||
return 0;
|
||||
@@ -191,11 +191,11 @@ switch_status_t mod_sms_flowroute_profile_create(mod_sms_flowroute_profile_t **n
|
||||
char *access_key, char *secret_key, char *host)
|
||||
{
|
||||
mod_sms_flowroute_profile_t *profile = NULL;
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
switch_memory_pool_t *pool = NULL;
|
||||
switch_threadattr_t *thd_attr;
|
||||
char auth[256] = {0};
|
||||
unsigned int auth_size = 0;
|
||||
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
|
||||
profile = switch_core_alloc(pool, sizeof(mod_sms_flowroute_profile_t));
|
||||
@@ -217,7 +217,7 @@ switch_status_t mod_sms_flowroute_profile_create(mod_sms_flowroute_profile_t **n
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile[%s] error processing url[%s]\n", profile->name, profile->host);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
h2o_config_init(&(profile->h2o_globalconf));
|
||||
profile->h2o_hostconf = h2o_config_register_host(&(profile->h2o_globalconf), h2o_iovec_init(H2O_STRLIT("mod_sms_flowroute")), 2048);
|
||||
|
||||
@@ -225,7 +225,7 @@ switch_status_t mod_sms_flowroute_profile_create(mod_sms_flowroute_profile_t **n
|
||||
profile->h2o_pathconf = h2o_config_register_path(profile->h2o_hostconf, "/", 0);
|
||||
profile->h2o_handler = h2o_create_handler(profile->h2o_pathconf, sizeof(h2o_handler_t));
|
||||
profile->h2o_handler->on_req = mod_sms_flowroute_profile_request_handler;
|
||||
|
||||
|
||||
h2o_context_init(&(profile->h2o_context), h2o_evloop_create(), &(profile->h2o_globalconf));
|
||||
|
||||
profile->queue = h2o_multithread_create_queue(profile->h2o_context.loop);
|
||||
@@ -237,7 +237,7 @@ switch_status_t mod_sms_flowroute_profile_create(mod_sms_flowroute_profile_t **n
|
||||
switch_threadattr_create(&thd_attr, pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&(profile->profile_thread), thd_attr, mod_sms_flowroute_profile_event_thread, (void *) profile, pool);
|
||||
|
||||
|
||||
switch_core_hash_insert(mod_sms_flowroute_globals.profile_hash, name, (void *) profile);
|
||||
*new_profile = profile;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Profile[%s] created\n", profile->name);
|
||||
@@ -366,12 +366,12 @@ switch_status_t mod_sms_flowroute_profile_send_message(mod_sms_flowroute_profile
|
||||
if ( !to ) {
|
||||
to = switch_event_get_header(event, "destination_addr");
|
||||
}
|
||||
|
||||
|
||||
from = switch_event_get_header(event, "from");
|
||||
if ( !from ) {
|
||||
from = switch_event_get_header(event, "source_addr");
|
||||
}
|
||||
|
||||
|
||||
cJSON_AddItemToObject(body, "to", cJSON_CreateString(to));
|
||||
cJSON_AddItemToObject(body, "from", cJSON_CreateString(from));
|
||||
cJSON_AddItemToObject(body, "body", cJSON_CreateString((const char *) switch_event_get_body(event)));
|
||||
@@ -390,7 +390,7 @@ switch_status_t mod_sms_flowroute_profile_send_message(mod_sms_flowroute_profile
|
||||
profile->auth_b64_size, profile->auth_b64,
|
||||
(int) profile->url_parsed.authority.len, profile->url_parsed.authority.base,
|
||||
(int)strlen(text), text);
|
||||
|
||||
|
||||
if ( profile->debug ) {
|
||||
char *msg_txt = NULL;
|
||||
switch_event_serialize(event, &msg_txt, SWITCH_FALSE);
|
||||
@@ -417,7 +417,7 @@ switch_status_t mod_sms_flowroute_profile_send_message(mod_sms_flowroute_profile
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile[%s] send_message resulted in failure status %d\n", profile->name, msg->status);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
h2o_timeout_dispose(msg->ctx.loop, msg->ctx.io_timeout);
|
||||
switch_mutex_destroy(msg->mutex);
|
||||
switch_safe_free(msg->req.base);
|
||||
@@ -427,10 +427,10 @@ switch_status_t mod_sms_flowroute_profile_send_message(mod_sms_flowroute_profile
|
||||
err:
|
||||
if ( msg && msg->mutex ) {
|
||||
switch_mutex_destroy(msg->mutex);
|
||||
}
|
||||
}
|
||||
h2o_timeout_dispose(msg->ctx.loop, msg->ctx.io_timeout);
|
||||
switch_safe_free(msg->req.base);
|
||||
switch_safe_free(msg);
|
||||
switch_safe_free(msg);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ switch_status_t mod_sms_flowroute_interface_chat_send(switch_event_t *event)
|
||||
if (zstr(profile_name)) {
|
||||
profile_name = "default";
|
||||
}
|
||||
|
||||
|
||||
profile = switch_core_hash_find(mod_sms_flowroute_globals.profile_hash, profile_name);
|
||||
|
||||
if (!profile) {
|
||||
@@ -481,7 +481,7 @@ SWITCH_STANDARD_APP(mod_sms_flowroute_app_send_function)
|
||||
if (switch_event_create(&message, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Copy over recognized channel vars. Then call the chat send function */
|
||||
/* Cycle through all of the channel headers, and ones with 'sms_flowroute_' prefix copy over without the prefix */
|
||||
for ( chan_var = switch_channel_variable_first(channel); chan_var; chan_var = chan_var->next) {
|
||||
@@ -489,7 +489,7 @@ SWITCH_STANDARD_APP(mod_sms_flowroute_app_send_function)
|
||||
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, chan_var->name + 14, chan_var->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Unlock the channel variables */
|
||||
switch_channel_variable_last(channel);
|
||||
mod_sms_flowroute_chat_send_function(message, data);
|
||||
@@ -530,7 +530,7 @@ SWITCH_STANDARD_API(mod_sms_flowroute_send_api)
|
||||
if (switch_event_create(&message, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_goto_status(SWITCH_STATUS_GENERR, done);
|
||||
}
|
||||
|
||||
|
||||
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, "destination_addr", argv[1]);
|
||||
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, "source_addr", argv[2]);
|
||||
switch_event_set_body(message, argv[3]);
|
||||
@@ -542,10 +542,10 @@ SWITCH_STANDARD_API(mod_sms_flowroute_send_api)
|
||||
done:
|
||||
switch_safe_free(cmd_dup);
|
||||
return status;
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch_status_t mod_sms_flowroute_do_config()
|
||||
switch_status_t mod_sms_flowroute_do_config()
|
||||
{
|
||||
char *conf = "sms_flowroute.conf";
|
||||
switch_xml_t xml, cfg, profiles, profile, params, param;
|
||||
@@ -556,7 +556,7 @@ switch_status_t mod_sms_flowroute_do_config()
|
||||
}
|
||||
|
||||
if ( (profiles = switch_xml_child(cfg, "profiles")) != NULL) {
|
||||
for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) {
|
||||
for (profile = switch_xml_child(profiles, "profile"); profile; profile = profile->next) {
|
||||
mod_sms_flowroute_profile_t *new_profile = NULL;
|
||||
int debug = 0, port = 0;
|
||||
char *access_key = NULL, *secret_key = NULL, *host = NULL;
|
||||
@@ -594,7 +594,7 @@ switch_status_t mod_sms_flowroute_do_config()
|
||||
|
||||
switch_xml_free(xml);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
||||
err:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Configuration failed\n");
|
||||
if(xml){
|
||||
@@ -613,12 +613,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sms_flowroute_load)
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
|
||||
memset(&mod_sms_flowroute_globals, 0, sizeof(mod_sms_flowroute_globals_t));
|
||||
mod_sms_flowroute_globals.pool = pool;
|
||||
mod_sms_flowroute_globals.debug = 0;
|
||||
switch_core_hash_init(&(mod_sms_flowroute_globals.profile_hash));
|
||||
|
||||
|
||||
if ( mod_sms_flowroute_do_config() != SWITCH_STATUS_SUCCESS ) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load due to bad configs\n");
|
||||
return SWITCH_STATUS_TERM;
|
||||
@@ -627,14 +627,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sms_flowroute_load)
|
||||
/* SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();*/
|
||||
|
||||
|
||||
|
||||
SWITCH_ADD_CHAT(mod_sms_flowroute_chat_interface, "sms_flowroute", mod_sms_flowroute_interface_chat_send);
|
||||
SWITCH_ADD_API(mod_sms_flowroute_api_interface, "sms_flowroute_send", "mod_sms_flowroute send", mod_sms_flowroute_send_api, NULL);
|
||||
SWITCH_ADD_API(mod_sms_flowroute_api_interface, "sms_flowroute_debug", "mod_sms_flowroute toggle debug", mod_sms_flowroute_debug_api, NULL);
|
||||
SWITCH_ADD_CHAT_APP(mod_sms_flowroute_chat_app_interface, "sms_flowroute_send", "send message to profile", "send message to profile",
|
||||
SWITCH_ADD_CHAT_APP(mod_sms_flowroute_chat_app_interface, "sms_flowroute_send", "send message to profile", "send message to profile",
|
||||
mod_sms_flowroute_chat_send_function, "", SCAF_NONE);
|
||||
SWITCH_ADD_APP(mod_sms_flowroute_app_interface, "sms_flowroute_send", NULL, NULL, mod_sms_flowroute_app_send_function,
|
||||
SWITCH_ADD_APP(mod_sms_flowroute_app_interface, "sms_flowroute_send", NULL, NULL, mod_sms_flowroute_app_send_function,
|
||||
"sms_flowroute_send", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
|
||||
@@ -54,7 +54,7 @@ typedef struct {
|
||||
|
||||
unsigned char auth_b64[512];
|
||||
int auth_b64_size;
|
||||
|
||||
|
||||
h2o_url_t url_parsed;
|
||||
h2o_socketpool_t *sockpool;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
*
|
||||
@@ -35,7 +35,7 @@
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_snapshot_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_snapshot_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_snapshot, mod_snapshot_load, NULL, NULL);
|
||||
@@ -193,7 +193,7 @@ static switch_status_t do_snap(switch_core_session_t *session)
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Bug is not attached.\n", switch_channel_get_name(channel));
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#define SNAP_SYNTAX "start <sec> <read|write>"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<include>
|
||||
<include>
|
||||
<extension name="snom-demo-1">
|
||||
<condition field="destination_number" expression="^9000$">
|
||||
<!-- <key> <light> <label> <user> <host> <profile> <action_name> <action> -->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_snom.c -- SNOM Specific Features
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,13 +22,13 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* William King <william.king@quentustech.com>
|
||||
* Seven Du <dujinfang@gmail.com>
|
||||
*
|
||||
* mod_sonar.c -- Sonar ping timer
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -54,7 +54,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sonar_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_sonar_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_sonar_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_sonar, mod_sonar_load, mod_sonar_shutdown, NULL);
|
||||
@@ -95,7 +95,7 @@ switch_bool_t sonar_ping_callback(switch_core_session_t *session, const char *ap
|
||||
ph->max = MAX(ph->max, diff);
|
||||
ph->min = MIN(ph->min, diff);
|
||||
ph->samples[ph->received++] = diff;
|
||||
|
||||
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
@@ -123,16 +123,16 @@ SWITCH_STANDARD_APP(sonar_app)
|
||||
} else if (loops > 1024) {
|
||||
loops = 1024;
|
||||
}
|
||||
|
||||
|
||||
switch_channel_answer(channel);
|
||||
switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL);
|
||||
switch_channel_set_private(channel, "__sonar_ping__", &ph);
|
||||
|
||||
switch_ivr_tone_detect_session(session,
|
||||
switch_ivr_tone_detect_session(session,
|
||||
"soar_ping", "1004",
|
||||
"r", 0,
|
||||
"r", 0,
|
||||
1, NULL, NULL, sonar_ping_callback);
|
||||
|
||||
|
||||
switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL);
|
||||
|
||||
ph.min = 999999;
|
||||
@@ -147,7 +147,7 @@ SWITCH_STANDARD_APP(sonar_app)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost sonar ping\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL);
|
||||
switch_ivr_stop_tone_detect_session(session);
|
||||
|
||||
@@ -223,7 +223,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sonar_load)
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
@@ -240,7 +240,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sonar_shutdown)
|
||||
{
|
||||
|
||||
switch_event_free_subclass("sonar::ping");
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_soundtouch.cpp -- Example of writeable media bugs
|
||||
@@ -293,7 +293,7 @@ SWITCH_STANDARD_APP(soundtouch_start_function)
|
||||
n++;
|
||||
} else if (strchr(argv[x], 's')) {
|
||||
/*12.0f taken from soundtouch conversion to octaves*/
|
||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
|
||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
|
||||
n++;
|
||||
} else if (strchr(argv[x], 't')) {
|
||||
sth->tempo = normalize_soundtouch_value('t', atof(argv[x]));
|
||||
@@ -405,7 +405,7 @@ SWITCH_STANDARD_API(soundtouch_api_function)
|
||||
n++;
|
||||
} else if (strchr(argv[x], 's')) {
|
||||
/*12.0f taken from soundtouch conversion to octaves*/
|
||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
|
||||
sth->pitch = normalize_soundtouch_value('p', compute_pitch_from_octaves(atof(argv[x]) / 12.0f) );
|
||||
n++;
|
||||
} else if (strchr(argv[x], 't')) {
|
||||
sth->tempo = normalize_soundtouch_value('t', atof(argv[x]));
|
||||
@@ -450,9 +450,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_soundtouch_load)
|
||||
switch_api_interface_t *api_interface;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "soundtouch", "Alter the audio stream", "Alter the audio stream pitch/rate/tempo",
|
||||
SWITCH_ADD_APP(app_interface, "soundtouch", "Alter the audio stream", "Alter the audio stream pitch/rate/tempo",
|
||||
soundtouch_start_function, "[send_leg] [hook_dtmf] [-]<X>s [-]<X>o <X>p <X>r <X>t", SAF_NONE);
|
||||
|
||||
SWITCH_ADD_API(api_interface, "soundtouch", "soundtouch", soundtouch_api_function, SOUNDTOUCH_API_SYNTAX);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<configuration name="spandsp.conf" description="SpanDSP config">
|
||||
<modem-settings>
|
||||
<!--
|
||||
total-modems set to N will create that many soft-modems.
|
||||
total-modems set to N will create that many soft-modems.
|
||||
If you use them with Hylafax you need the following for each one numbered 0..N:
|
||||
|
||||
1) A line like this in /etc/inittab:
|
||||
|
||||
@@ -222,7 +222,7 @@ SWITCH_STANDARD_APP(t38_gateway_function)
|
||||
}
|
||||
|
||||
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
|
||||
|
||||
|
||||
if (zstr(direction) || strcasecmp(direction, "self")) {
|
||||
direction = "peer";
|
||||
}
|
||||
@@ -809,7 +809,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SPANDSP_EVENT_RXFAXRESULT);
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
||||
|
||||
memset(&spandsp_globals, 0, sizeof(spandsp_globals));
|
||||
spandsp_globals.pool = pool;
|
||||
|
||||
@@ -900,7 +900,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spandsp_shutdown)
|
||||
switch_event_free_subclass(SPANDSP_EVENT_RXFAXPAGERESULT);
|
||||
switch_event_free_subclass(SPANDSP_EVENT_TXFAXRESULT);
|
||||
switch_event_free_subclass(SPANDSP_EVENT_RXFAXRESULT);
|
||||
|
||||
|
||||
mod_spandsp_fax_shutdown();
|
||||
mod_spandsp_dsp_shutdown();
|
||||
#if defined(MODEM_SUPPORT)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
|
||||
@@ -402,7 +402,7 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
|
||||
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
|
||||
switch_codec_implementation_t read_impl = { 0 };
|
||||
|
||||
|
||||
|
||||
switch (type) {
|
||||
case SWITCH_ABC_TYPE_INIT: {
|
||||
pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL);
|
||||
@@ -432,7 +432,7 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
|
||||
int samples = frame->samples;
|
||||
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
|
||||
if (read_impl.number_of_channels != 1 || read_impl.actual_samples_per_second != 8000) {
|
||||
memcpy(data, frame->data, frame->datalen);
|
||||
dp = data;
|
||||
@@ -452,14 +452,14 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
|
||||
read_impl.actual_samples_per_second,
|
||||
8000,
|
||||
8 * (read_impl.microseconds_per_packet / 1000) * 2,
|
||||
SWITCH_RESAMPLE_QUALITY,
|
||||
SWITCH_RESAMPLE_QUALITY,
|
||||
1) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n");
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
switch_resample_process(pvt->resampler, dp, (int) datalen / 2 / 1);
|
||||
memcpy(dp, pvt->resampler->to, pvt->resampler->to_len * 2 * 1);
|
||||
|
||||
@@ -1362,7 +1362,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
|
||||
switch_channel_var_true(channel, "fax_enable_t38_insist")) {
|
||||
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
|
||||
}
|
||||
|
||||
|
||||
pvt = pvt_init(session, app_mode);
|
||||
switch_channel_set_private(channel, "_fax_pvt", pvt);
|
||||
|
||||
@@ -1618,7 +1618,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
|
||||
spanfax_destroy(pvt);
|
||||
|
||||
switch_channel_clear_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
|
||||
|
||||
|
||||
/* restore the original codecs over the channel */
|
||||
|
||||
switch_core_session_set_read_codec(session, NULL);
|
||||
@@ -2093,7 +2093,7 @@ switch_bool_t t38_gateway_start(switch_core_session_t *session, const char *app,
|
||||
|
||||
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
|
||||
switch_channel_set_app_flag_key("T38", other_channel, CF_APP_T38_POSSIBLE);
|
||||
|
||||
|
||||
switch_channel_set_flag(channel, CF_REDIRECT);
|
||||
switch_channel_set_state(channel, CS_RESET);
|
||||
|
||||
@@ -2291,7 +2291,7 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session,
|
||||
switch_codec_implementation_t read_impl = { 0 };
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
|
||||
|
||||
if (timeout) {
|
||||
to = switch_epoch_time_now(NULL) + timeout;
|
||||
}
|
||||
@@ -2306,7 +2306,7 @@ switch_status_t spandsp_fax_detect_session(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
switch_channel_set_app_flag_key("T38", channel, CF_APP_T38_POSSIBLE);
|
||||
|
||||
|
||||
if (app) {
|
||||
cont->app = switch_core_session_strdup(session, app);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -27,7 +27,7 @@
|
||||
* Brian West <brian@freeswitch.org>
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Steve Underwood <steveu@coppice.org>
|
||||
* mod_spandsp_modem.c -- t31 Soft Modem
|
||||
* mod_spandsp_modem.c -- t31 Soft Modem
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -106,7 +106,7 @@ static int t31_at_tx_handler(void *user_data, const uint8_t *buf, size_t len)
|
||||
#endif
|
||||
|
||||
if (wrote != len) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to pass the full buffer onto the device file. "
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to pass the full buffer onto the device file. "
|
||||
"%"SWITCH_SSIZE_T_FMT " bytes of " "%"SWITCH_SIZE_T_FMT " written: %s\n", wrote, len, strerror(errno));
|
||||
|
||||
if (wrote == -1) wrote = 0;
|
||||
@@ -138,7 +138,7 @@ static int t31_call_control_handler(t31_state_t *s, void *user_data, int op, con
|
||||
return ret;
|
||||
}
|
||||
|
||||
static modem_state_t modem_get_state(modem_t *modem)
|
||||
static modem_state_t modem_get_state(modem_t *modem)
|
||||
{
|
||||
modem_state_t state;
|
||||
|
||||
@@ -149,18 +149,18 @@ static modem_state_t modem_get_state(modem_t *modem)
|
||||
return state;
|
||||
}
|
||||
|
||||
static void _modem_set_state(modem_t *modem, modem_state_t state, const char *file, const char *func, int line)
|
||||
static void _modem_set_state(modem_t *modem, modem_state_t state, const char *file, const char *func, int line)
|
||||
{
|
||||
|
||||
switch_mutex_lock(modem->mutex);
|
||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG,"Modem %s [%s] - Changing state to %s\n", modem->devlink,
|
||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG,"Modem %s [%s] - Changing state to %s\n", modem->devlink,
|
||||
modem_state2name(modem->state), modem_state2name(state));
|
||||
modem->state = state;
|
||||
switch_mutex_unlock(modem->mutex);
|
||||
}
|
||||
#define modem_set_state(_modem, _state) _modem_set_state(_modem, _state, __FILE__, __SWITCH_FUNC__, __LINE__)
|
||||
|
||||
char *modem_state2name(int state)
|
||||
char *modem_state2name(int state)
|
||||
{
|
||||
if (state > MODEM_STATE_LAST || state < 0) {
|
||||
state = MODEM_STATE_LAST;
|
||||
@@ -169,7 +169,7 @@ char *modem_state2name(int state)
|
||||
return MODEM_STATE[state].name;
|
||||
}
|
||||
|
||||
int modem_close(modem_t *modem)
|
||||
int modem_close(modem_t *modem)
|
||||
{
|
||||
int r = 0;
|
||||
switch_status_t was_running = switch_test_flag(modem, MODEM_FLAG_RUNNING);
|
||||
@@ -295,7 +295,7 @@ switch_status_t modem_init(modem_t *modem, modem_control_handler_t control_handl
|
||||
|
||||
#ifndef WIN32
|
||||
snprintf(modem->devlink, sizeof(modem->devlink), "%s/FS%d", spandsp_globals.modem_directory, modem->slot);
|
||||
|
||||
|
||||
unlink(modem->devlink);
|
||||
|
||||
if (symlink(modem->stty, modem->devlink)) {
|
||||
@@ -329,7 +329,7 @@ switch_status_t modem_init(modem_t *modem, modem_control_handler_t control_handl
|
||||
}
|
||||
modem->threadAbort = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
#endif
|
||||
|
||||
|
||||
if (!(modem->t31_state = t31_init(NULL, t31_at_tx_handler, modem, t31_call_control_handler, modem, t38_tx_packet_handler, modem))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot initialize the T.31 modem\n");
|
||||
modem_close(modem);
|
||||
@@ -414,8 +414,8 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
|
||||
|
||||
|
||||
/*
|
||||
State methods they get called when the state changes to the specific state
|
||||
/*
|
||||
State methods they get called when the state changes to the specific state
|
||||
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
|
||||
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
|
||||
*/
|
||||
@@ -471,11 +471,11 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
||||
t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_ALERTING);
|
||||
rt = ring_ticks;
|
||||
}
|
||||
|
||||
|
||||
switch_yield(rest);
|
||||
to_ticks--;
|
||||
}
|
||||
|
||||
|
||||
if (to_ticks < 1 || modem_get_state(tech_pvt->modem) != MODEM_STATE_ANSWERED) {
|
||||
t31_call_event(tech_pvt->modem->t31_state, AT_CALL_EVENT_NO_ANSWER);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NO_ANSWER);
|
||||
@@ -487,7 +487,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
|
||||
}
|
||||
|
||||
switch_channel_set_state(channel, CS_ROUTING);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
|
||||
|
||||
//channel = switch_core_session_get_channel(session);
|
||||
//switch_assert(channel != NULL);
|
||||
|
||||
|
||||
if ((tech_pvt = switch_core_session_get_private(session))) {
|
||||
|
||||
switch_core_timer_destroy(&tech_pvt->timer);
|
||||
@@ -675,7 +675,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
|
||||
tech_pvt->read_frame.flags = SFF_NONE;
|
||||
switch_core_timer_next(&tech_pvt->timer);
|
||||
|
||||
|
||||
do {
|
||||
r = t31_tx(tech_pvt->modem->t31_state, data + samples_read, samples_wanted - samples_read);
|
||||
if (r < 0) break;
|
||||
@@ -715,7 +715,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
if (t31_rx(tech_pvt->modem->t31_state, frame->data, frame->datalen / 2)) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -862,7 +862,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_ERROR, "Cannot find a modem.\n");
|
||||
cause = SWITCH_CAUSE_USER_BUSY; goto fail;
|
||||
}
|
||||
|
||||
|
||||
switch_core_session_add_stream(*new_session, NULL);
|
||||
|
||||
if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
|
||||
@@ -944,7 +944,7 @@ static switch_status_t create_session(switch_core_session_t **new_session, modem
|
||||
char name[1024];
|
||||
switch_caller_profile_t *caller_profile;
|
||||
char *ani = NULL, *p, *digits = NULL;
|
||||
|
||||
|
||||
if (!(session = switch_core_session_request(modem_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure.\n");
|
||||
goto end;
|
||||
@@ -953,7 +953,7 @@ static switch_status_t create_session(switch_core_session_t **new_session, modem
|
||||
switch_core_session_add_stream(session, NULL);
|
||||
channel = switch_core_session_get_channel(session);
|
||||
tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(*tech_pvt));
|
||||
|
||||
|
||||
p = switch_core_session_strdup(session, modem->digits);
|
||||
|
||||
if (*p == '*') {
|
||||
@@ -964,7 +964,7 @@ static switch_status_t create_session(switch_core_session_t **new_session, modem
|
||||
ani = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (zstr(digits)) {
|
||||
digits = p;
|
||||
}
|
||||
@@ -985,14 +985,14 @@ static switch_status_t create_session(switch_core_session_t **new_session, modem
|
||||
caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
|
||||
modem->devlink,
|
||||
spandsp_globals.modem_dialplan,
|
||||
"FSModem",
|
||||
"FSModem",
|
||||
ani,
|
||||
NULL,
|
||||
NULL,
|
||||
ani,
|
||||
NULL,
|
||||
NULL,
|
||||
"mod_spandsp",
|
||||
spandsp_globals.modem_context,
|
||||
NULL,
|
||||
NULL,
|
||||
"mod_spandsp",
|
||||
spandsp_globals.modem_context,
|
||||
digits);
|
||||
|
||||
caller_profile->source = switch_core_strdup(caller_profile->pool, "mod_spandsp");
|
||||
@@ -1027,7 +1027,7 @@ static int control_handler(modem_t *modem, const char *num, int op)
|
||||
{
|
||||
switch_core_session_t *session = NULL;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Control Handler op:%d state:[%s] %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Control Handler op:%d state:[%s] %s\n",
|
||||
op, modem_state2name(modem_get_state(modem)), modem->devlink);
|
||||
|
||||
switch (op) {
|
||||
@@ -1045,7 +1045,7 @@ static int control_handler(modem_t *modem, const char *num, int op)
|
||||
wake_modem_thread(modem);
|
||||
|
||||
switch_set_string(modem->digits, num);
|
||||
|
||||
|
||||
if (create_session(&session, modem) != SWITCH_STATUS_SUCCESS) {
|
||||
t31_call_event(modem->t31_state, AT_CALL_EVENT_HANGUP);
|
||||
} else {
|
||||
@@ -1059,11 +1059,11 @@ static int control_handler(modem_t *modem, const char *num, int op)
|
||||
modem_set_state(modem, MODEM_STATE_OFFHOOK);
|
||||
break;
|
||||
case AT_MODEM_CONTROL_ONHOOK:
|
||||
case AT_MODEM_CONTROL_HANGUP:
|
||||
case AT_MODEM_CONTROL_HANGUP:
|
||||
{
|
||||
if (modem_get_state(modem) != MODEM_STATE_RINGING) {
|
||||
int set_state = 1;
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
|
||||
"Modem %s [%s] - Hanging up\n", modem->devlink, modem_state2name(modem_get_state(modem)));
|
||||
switch_clear_flag(modem, MODEM_FLAG_XOFF);
|
||||
@@ -1073,10 +1073,10 @@ static int control_handler(modem_t *modem, const char *num, int op)
|
||||
|
||||
if (!zstr(modem->uuid_str)) {
|
||||
switch_core_session_t *session;
|
||||
|
||||
|
||||
if ((session = switch_core_session_force_locate(modem->uuid_str))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
|
||||
if (switch_channel_up(channel)) {
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
|
||||
set_state = 0;
|
||||
@@ -1148,7 +1148,7 @@ static int modem_wait_sock(int sock, uint32_t ms, modem_poll_t flags)
|
||||
{
|
||||
struct pollfd pfds[2] = { { 0 } };
|
||||
int s = 0, r = 0;
|
||||
|
||||
|
||||
pfds[0].fd = sock;
|
||||
|
||||
if ((flags & MODEM_POLL_READ)) {
|
||||
@@ -1162,7 +1162,7 @@ static int modem_wait_sock(int sock, uint32_t ms, modem_poll_t flags)
|
||||
if ((flags & MODEM_POLL_ERROR)) {
|
||||
pfds[0].events |= POLLERR;
|
||||
}
|
||||
|
||||
|
||||
s = poll(pfds, 1, ms);
|
||||
|
||||
if (s < 0) {
|
||||
@@ -1208,7 +1208,7 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
|
||||
if (result == 0)
|
||||
{
|
||||
if (GetLastError() != ERROR_IO_PENDING) {
|
||||
/* something went horribly wrong with WaitCommEvent(), so
|
||||
/* something went horribly wrong with WaitCommEvent(), so
|
||||
clear all errors and try again */
|
||||
DWORD comerrors;
|
||||
ClearCommError(modem->master, &comerrors, 0);
|
||||
@@ -1278,7 +1278,7 @@ static void *SWITCH_THREAD_FUNC modem_thread(switch_thread_t *thread, void *obj)
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef WIN32
|
||||
r = read(modem->master, buf, avail);
|
||||
#else
|
||||
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
@@ -1318,7 +1318,7 @@ static void *SWITCH_THREAD_FUNC modem_thread(switch_thread_t *thread, void *obj)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void launch_modem_thread(modem_t *modem)
|
||||
static void launch_modem_thread(modem_t *modem)
|
||||
{
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
@@ -1350,7 +1350,7 @@ static void deactivate_modems(void)
|
||||
{
|
||||
int max = globals.SOFT_MAX_MODEMS;
|
||||
int x;
|
||||
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
|
||||
for (x = 0; x < max; x++) {
|
||||
@@ -1409,7 +1409,7 @@ switch_status_t modem_global_init(switch_loadable_module_interface_t **module_in
|
||||
globals.pool = pool;
|
||||
|
||||
globals.SOFT_MAX_MODEMS = spandsp_globals.modem_count;
|
||||
|
||||
|
||||
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, pool);
|
||||
|
||||
modem_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -101,9 +101,9 @@
|
||||
|
||||
|
||||
typedef enum {
|
||||
MODEM_STATE_INIT,
|
||||
MODEM_STATE_ONHOOK,
|
||||
MODEM_STATE_OFFHOOK,
|
||||
MODEM_STATE_INIT,
|
||||
MODEM_STATE_ONHOOK,
|
||||
MODEM_STATE_OFFHOOK,
|
||||
MODEM_STATE_ACQUIRED,
|
||||
MODEM_STATE_RINGING,
|
||||
MODEM_STATE_ANSWERED,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//#define UDPTL_DEBUG
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2009, Steve Underwood <steveu@coppice.org>
|
||||
*
|
||||
@@ -16,7 +16,7 @@
|
||||
* License.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Steve Underwood <steveu@coppice.org>
|
||||
*
|
||||
* udptl.c -- UDPTL handling for T.38
|
||||
@@ -252,7 +252,7 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
|
||||
FEC mode after sending some redundant packets, and this may then be important. */
|
||||
x = (seq_no - i) & UDPTL_BUF_MASK;
|
||||
if (lengths[i - 1] > 0)
|
||||
memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]);
|
||||
memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]);
|
||||
s->rx[x].buf_len = lengths[i - 1];
|
||||
s->rx[x].fec_len[0] = 0;
|
||||
s->rx[x].fec_span = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2009, Steve Underwood <steveu@coppice.org>
|
||||
*
|
||||
@@ -15,7 +15,7 @@
|
||||
* License.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Steve Underwood <steveu@coppice.org>
|
||||
*
|
||||
* udptl.h -- UDPTL handling for T.38
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,10 +22,10 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Csaba Zelei <csaba.zelei@eworldcom.net>
|
||||
*
|
||||
* Thanks for eWorld Com Ltd. for funding the module.
|
||||
* Thanks for eWorld Com Ltd. for funding the module.
|
||||
*
|
||||
* mod_spy.c -- UserSpy Module
|
||||
*
|
||||
@@ -83,7 +83,7 @@ static switch_status_t spy_on_hangup(switch_core_session_t *session)
|
||||
switch_core_hash_insert(globals.spy_hash, data, spy);
|
||||
|
||||
switch_thread_rwlock_unlock(globals.spy_hash_lock);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -213,16 +213,16 @@ static switch_status_t process_event(switch_event_t *event)
|
||||
while (spy) {
|
||||
if ((session = switch_core_session_locate(spy->uuid))) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
|
||||
my_uuid = switch_event_get_header(event, "Unique-ID");
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "UserSpy retrieved uuid %s for key %s, activating eavesdrop\n", my_uuid, key);
|
||||
|
||||
|
||||
switch_channel_set_variable(channel, "spy_uuid", my_uuid);
|
||||
found++;
|
||||
|
||||
|
||||
switch_channel_set_state(channel, CS_EXCHANGE_MEDIA);
|
||||
switch_channel_set_flag(channel, CF_BREAK);
|
||||
|
||||
|
||||
switch_core_session_rwunlock(session);
|
||||
}
|
||||
spy = spy->next;
|
||||
@@ -238,8 +238,8 @@ static switch_status_t process_event(switch_event_t *event)
|
||||
if (!found) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
done:
|
||||
switch_thread_rwlock_unlock(globals.spy_hash_lock);
|
||||
return status;
|
||||
@@ -254,7 +254,7 @@ static void event_handler(switch_event_t *event)
|
||||
switch_core_session_t *peer_session = NULL;
|
||||
switch_channel_t *peer_channel = NULL;
|
||||
switch_event_t *peer_event = NULL;
|
||||
|
||||
|
||||
if (!peer_uuid) {
|
||||
return;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ static void event_handler(switch_event_t *event)
|
||||
}
|
||||
|
||||
peer_channel = switch_core_session_get_channel(peer_session);
|
||||
|
||||
|
||||
if (switch_event_create(&peer_event, SWITCH_EVENT_CHANNEL_BRIDGE) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't create bridge event for peer channel %s\n", peer_uuid);
|
||||
goto end;
|
||||
|
||||
@@ -136,7 +136,7 @@ void FFTReal::do_fft (flt_t f [], const flt_t x []) const
|
||||
|
||||
df2 [0] = sf_0 + sf_2;
|
||||
df2 [2] = sf_0 - sf_2;
|
||||
|
||||
|
||||
coef_index += 4;
|
||||
}
|
||||
while (coef_index < _length);
|
||||
@@ -236,7 +236,7 @@ void FFTReal::do_fft (flt_t f [], const flt_t x []) const
|
||||
|
||||
const flt_t b_0 = x [0] + x [2];
|
||||
const flt_t b_2 = x [1] + x [3];
|
||||
|
||||
|
||||
f [0] = b_0 + b_2;
|
||||
f [2] = b_0 - b_2;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* mod_stress.cpp -- Detect Voice Stress
|
||||
@@ -81,19 +81,19 @@ static switch_bool_t stress_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
} else {
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
|
||||
sth->data = (float *) switch_core_session_alloc(sth->session, sizeof(*sth->data) * sth->frame_size);
|
||||
sth->result = (float *) switch_core_session_alloc(sth->session, sizeof(*sth->result) * sth->frame_size);
|
||||
sth->pow_spectrum = (float *) switch_core_session_alloc(sth->session, sizeof(*sth->pow_spectrum) * sth->frame_size);
|
||||
sth->audio = (int16_t *) switch_core_session_alloc(sth->session, sizeof(*sth->audio) * sth->frame_size);
|
||||
|
||||
|
||||
sth->fft = new FFTReal (sth->frame_size);
|
||||
switch_buffer_create_dynamic(&sth->audio_buffer, sth->frame_size, sth->frame_size * 3, 0);
|
||||
|
||||
sth->bind = (float) sth->rate / sth->frame_size;
|
||||
sth->start = (int) (8.0 / sth->bind);
|
||||
sth->end = (int) (14.0 / sth->bind);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case SWITCH_ABC_TYPE_CLOSE:
|
||||
@@ -109,7 +109,7 @@ static switch_bool_t stress_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
case SWITCH_ABC_TYPE_WRITE_REPLACE:
|
||||
{
|
||||
switch_frame_t *frame;
|
||||
|
||||
|
||||
if (sth->read) {
|
||||
frame = switch_core_media_bug_get_read_replace_frame(bug);
|
||||
} else {
|
||||
@@ -119,7 +119,7 @@ static switch_bool_t stress_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
if (!switch_test_flag(frame, SFF_CNG)) {
|
||||
switch_buffer_write(sth->audio_buffer, frame->data, frame->datalen);
|
||||
}
|
||||
|
||||
|
||||
sth->stress = 0.0;
|
||||
|
||||
if (switch_buffer_inuse(sth->audio_buffer) >= sth->frame_size * sizeof(int16_t)) {
|
||||
@@ -129,7 +129,7 @@ static switch_bool_t stress_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
|
||||
bytes = switch_buffer_read(sth->audio_buffer, sth->audio, sth->frame_size * sizeof(int16_t));
|
||||
samples = bytes / sizeof(int16_t);
|
||||
|
||||
|
||||
switch_short_to_float(sth->audio, sth->data, samples);
|
||||
sth->fft->do_fft(sth->result, sth->data);
|
||||
|
||||
@@ -140,7 +140,7 @@ static switch_bool_t stress_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
sth->avg_tremor_pwr = 0.0;
|
||||
sth->avg_total_pwr = 0.0;
|
||||
sth->total_pwr = 0.0;
|
||||
|
||||
|
||||
for (i = sth->start; i <= sth->end; ++i) {
|
||||
sth->avg_tremor_pwr += sth->pow_spectrum[i];
|
||||
}
|
||||
@@ -150,7 +150,7 @@ static switch_bool_t stress_callback(switch_media_bug_t *bug, void *user_data, s
|
||||
sth->total_pwr += sth->pow_spectrum[i];
|
||||
}
|
||||
sth->avg_total_pwr = sth->total_pwr / samples;
|
||||
|
||||
|
||||
if (sth->total_pwr < threshold) {
|
||||
sth->tremor_ratio = 0.0;
|
||||
} else {
|
||||
@@ -227,7 +227,7 @@ SWITCH_STANDARD_APP(stress_start_function)
|
||||
}
|
||||
|
||||
sth->session = session;
|
||||
|
||||
|
||||
if ((status = switch_core_media_bug_add(session, "stress", NULL, stress_callback, sth, 0,
|
||||
sth->read ? SMBF_READ_REPLACE : SMBF_WRITE_REPLACE, &bug)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure!\n");
|
||||
@@ -244,7 +244,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_stress_load)
|
||||
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
SWITCH_ADD_APP(app_interface, "stress", "Analyze the stream for voice stress", "Analyze the stream for voice stress",
|
||||
SWITCH_ADD_APP(app_interface, "stress", "Analyze the stream for voice stress", "Analyze the stream for voice stress",
|
||||
stress_start_function, "[read|write|stop]", SAF_NONE);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
|
||||
@@ -143,7 +143,7 @@ static void translate_number(char *number, char *profile, char **translated, swi
|
||||
goto end;
|
||||
}
|
||||
memset(substituted, 0, len);
|
||||
|
||||
|
||||
switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector);
|
||||
|
||||
if ((switch_string_var_check_const(substituted) || switch_string_has_escaped_data(substituted))) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* William King <william.king@quentustech.com>
|
||||
* Emmanuel Schmidbauer <eschmidbauer@gmail.com>
|
||||
@@ -38,7 +38,7 @@
|
||||
/* Prototypes */
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_valet_parking, mod_valet_parking_load, NULL, NULL);
|
||||
@@ -135,7 +135,7 @@ static void check_timeouts(void)
|
||||
switch_mutex_lock(lot->mutex);
|
||||
|
||||
top:
|
||||
|
||||
|
||||
for (i_hi = switch_core_hash_first_iter( lot->hash, i_hi); i_hi; i_hi = switch_core_hash_next(&i_hi)) {
|
||||
switch_core_hash_this(i_hi, &i_var, NULL, &i_val);
|
||||
i_ext = (char *) i_var;
|
||||
@@ -175,7 +175,7 @@ static int find_longest(valet_lot_t *lot, int min, int max)
|
||||
token = (valet_token_t *) i_val;
|
||||
cur = (now - token->start_time);
|
||||
i = atoi(token->ext);
|
||||
|
||||
|
||||
if (cur > longest && i >= min && i <= max) {
|
||||
longest = cur;
|
||||
longest_ext = i;
|
||||
@@ -247,7 +247,7 @@ static valet_token_t *next_id(switch_core_session_t *session, valet_lot_t *lot,
|
||||
return token;
|
||||
}
|
||||
|
||||
static int valet_lot_count(valet_lot_t *lot)
|
||||
static int valet_lot_count(valet_lot_t *lot)
|
||||
{
|
||||
switch_hash_index_t *i_hi;
|
||||
const void *i_var;
|
||||
@@ -266,7 +266,7 @@ static int valet_lot_count(valet_lot_t *lot)
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
|
||||
return count;
|
||||
@@ -281,19 +281,19 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
|
||||
switch_event_t *event;
|
||||
int count;
|
||||
|
||||
|
||||
|
||||
dup_lot_name = strdup(lot_name);
|
||||
lot_name = dup_lot_name;
|
||||
|
||||
if ((domain_name = strchr(dup_lot_name, '@'))) {
|
||||
*domain_name++ = '\0';
|
||||
}
|
||||
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
dup_domain_name = switch_core_get_domain(SWITCH_TRUE);
|
||||
domain_name = dup_domain_name;
|
||||
}
|
||||
|
||||
|
||||
if (zstr(domain_name)) {
|
||||
domain_name = "cluecon.com";
|
||||
}
|
||||
@@ -306,7 +306,7 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
|
||||
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%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");
|
||||
@@ -324,7 +324,7 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||
|
||||
|
||||
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||
@@ -335,9 +335,9 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (in) {
|
||||
@@ -371,12 +371,12 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch_safe_free(dup_domain_name);
|
||||
switch_safe_free(dup_lot_name);
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct read_frame_data {
|
||||
@@ -394,7 +394,7 @@ static switch_status_t read_frame_callback(switch_core_session_t *session, switc
|
||||
rf->to = -1;
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -529,10 +529,10 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
|
||||
if (token && !token->bridged) {
|
||||
switch_core_session_t *b_session;
|
||||
|
||||
|
||||
if (token->timeout) {
|
||||
const char *var = switch_channel_get_variable(channel, "valet_ticket");
|
||||
|
||||
|
||||
if (!zstr(var)) {
|
||||
if (!strcmp(var, token->uuid)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Valet ticket %s accepted.\n", var);
|
||||
@@ -557,7 +557,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
switch_core_session_rwunlock(b_session);
|
||||
token->timeout = 0;
|
||||
token->bridged = 1;
|
||||
|
||||
|
||||
switch_ivr_uuid_bridge(token->uuid, switch_core_session_get_uuid(session));
|
||||
|
||||
return;
|
||||
@@ -592,7 +592,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
if (!strcasecmp(music, "silence")) {
|
||||
music = "silence_stream://-1";
|
||||
}
|
||||
|
||||
|
||||
if ((orbit_exten = switch_channel_get_variable(channel, "valet_parking_orbit_exten"))) {
|
||||
orbit_exten_str = switch_core_session_sprintf(session, "set:valet_parking_orbit_exten=%s,", orbit_exten);
|
||||
}
|
||||
@@ -606,11 +606,11 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
}
|
||||
|
||||
if ((timeout = switch_channel_get_variable(channel, "valet_parking_timeout"))) {
|
||||
timeout_str = switch_core_session_sprintf(session, "set:valet_parking_timeout=%s,", timeout);
|
||||
timeout_str = switch_core_session_sprintf(session, "set:valet_parking_timeout=%s,", timeout);
|
||||
}
|
||||
|
||||
dest = switch_core_session_sprintf(session, "%s%s%s%s"
|
||||
"set:valet_ticket=%s,set:valet_hold_music='%s',sleep:1000,valet_park:%s %s",
|
||||
"set:valet_ticket=%s,set:valet_hold_music='%s',sleep:1000,valet_park:%s %s",
|
||||
timeout_str,
|
||||
orbit_exten_str,
|
||||
orbit_dialplan_str,
|
||||
@@ -626,7 +626,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
switch_core_session_t *b_session;
|
||||
|
||||
if ((b_session = switch_core_session_locate(uuid))) {
|
||||
token->timeout = switch_epoch_time_now(NULL) + TOKEN_FREQ;
|
||||
token->timeout = switch_epoch_time_now(NULL) + TOKEN_FREQ;
|
||||
if (play_announce) {
|
||||
switch_ivr_sleep(session, 1500, SWITCH_TRUE, NULL);
|
||||
switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
|
||||
@@ -668,11 +668,11 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||
to_val = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (to_val) {
|
||||
switch_codec_implementation_t read_impl;
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
|
||||
rf.to = (1000 / (read_impl.microseconds_per_packet / 1000)) * to_val;
|
||||
rf.dp = switch_channel_get_variable(channel, "valet_parking_orbit_dialplan");
|
||||
rf.context = switch_channel_get_variable(channel, "valet_parking_orbit_context");
|
||||
@@ -786,7 +786,7 @@ static void pres_event_handler(switch_event_t *event)
|
||||
char *dup_to = NULL, *lot_name, *dup_lot_name = NULL, *domain_name;
|
||||
valet_lot_t *lot;
|
||||
int found = 0;
|
||||
|
||||
|
||||
if (!to || strncasecmp(to, "park+", 5) || !strchr(to, '@')) {
|
||||
return;
|
||||
}
|
||||
@@ -839,7 +839,7 @@ static void pres_event_handler(switch_event_t *event)
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "presence-call-direction", "inbound");
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch_console_callback_match_t *matches = NULL;
|
||||
@@ -858,18 +858,18 @@ static void pres_event_handler(switch_event_t *event)
|
||||
switch_console_push_match(&matches, nvar);
|
||||
}
|
||||
}
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
if (matches) {
|
||||
valet_token_t *token;
|
||||
|
||||
|
||||
for (m = matches->head; !found && m; m = m->next) {
|
||||
lot = valet_find_lot(m->val, SWITCH_FALSE);
|
||||
switch_mutex_lock(lot->mutex);
|
||||
|
||||
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, lot_name)) && !token->timeout) {
|
||||
found++;
|
||||
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2008, Eric des Courtis <eric.des.courtis@benbria.com>
|
||||
*
|
||||
@@ -18,7 +18,7 @@
|
||||
* Copyright (C) Benbria. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Eric des Courtis <eric.des.courtis@benbria.com>
|
||||
*
|
||||
* Special thanks to the following companies for their help:
|
||||
@@ -35,7 +35,7 @@
|
||||
* mod_vmd.c -- Voicemail Detection Module
|
||||
*
|
||||
* This module detects voicemail beeps at any frequency in O(1) time.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
@@ -86,17 +86,17 @@
|
||||
|
||||
/*! \brief Conversion of frequency to Hz
|
||||
*
|
||||
* \f$F = \frac{f}{{2}{\pi}}\f$
|
||||
* \f$F = \frac{f}{{2}{\pi}}\f$
|
||||
*/
|
||||
#define TO_HZ(f) ((F * f) / (2.0 * M_PI))
|
||||
|
||||
/* Number of points in discreet energy separation. */
|
||||
#define P (5)
|
||||
|
||||
/* Maximum signed value of int16_t
|
||||
/* Maximum signed value of int16_t
|
||||
* DEPRECATED */
|
||||
#define ADJUST (32768)
|
||||
/* Same as above times two
|
||||
/* Same as above times two
|
||||
* DEPRECATED */
|
||||
#define ADJUST_MAX (65536)
|
||||
|
||||
@@ -179,7 +179,7 @@ static double median(double *m, int n);
|
||||
#define PRINT2(a, b) do{ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, a, b); }while(0)
|
||||
*/
|
||||
|
||||
/*! \brief The callback function that is called when new audio data becomes available
|
||||
/*! \brief The callback function that is called when new audio data becomes available
|
||||
*
|
||||
* @author Eric des Courtis
|
||||
* @param bug A reference to the media bug.
|
||||
@@ -217,7 +217,7 @@ static switch_bool_t vmd_callback(switch_media_bug_t *bug, void *user_data, swit
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
/*! \brief Process and convert data to be used by the find_beep() function
|
||||
/*! \brief Process and convert data to be used by the find_beep() function
|
||||
*
|
||||
* @author Eric des Courtis
|
||||
* @param vmd_info The session information associated with the call.
|
||||
@@ -247,17 +247,17 @@ static switch_bool_t process_data(vmd_session_info_t *vmd_info, switch_frame_t *
|
||||
if (vmd_info->data != NULL) free(vmd_info->data);
|
||||
vmd_info->data = (int16_t *)malloc(len);
|
||||
if (vmd_info->data == NULL) return SWITCH_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
(void)memcpy(vmd_info->data, data, len);
|
||||
for(i = 2; i < frame->samples; i++){
|
||||
vmd_info->data[i] =
|
||||
0.0947997 * data[i]
|
||||
-
|
||||
0.0947997 * data[i - 2]
|
||||
-
|
||||
1.4083405 * vmd_info->data[i - 1]
|
||||
+
|
||||
vmd_info->data[i] =
|
||||
0.0947997 * data[i]
|
||||
-
|
||||
0.0947997 * data[i - 2]
|
||||
-
|
||||
1.4083405 * vmd_info->data[i - 1]
|
||||
+
|
||||
0.8104005 * vmd_info->data[i - 2];
|
||||
}
|
||||
*/
|
||||
@@ -274,7 +274,7 @@ static switch_bool_t process_data(vmd_session_info_t *vmd_info, switch_frame_t *
|
||||
return SWITCH_TRUE;
|
||||
}
|
||||
|
||||
/*! \brief Find voicemail beep in the audio stream
|
||||
/*! \brief Find voicemail beep in the audio stream
|
||||
*
|
||||
* @author Eric des Courtis
|
||||
* @param vmd_info The session information associated with the call.
|
||||
@@ -373,7 +373,7 @@ static void find_beep(vmd_session_info_t *vmd_info, switch_frame_t *frame)
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief Find the median of an array of doubles
|
||||
/*! \brief Find the median of an array of doubles
|
||||
*
|
||||
* @param m Array of frequency samples.
|
||||
* @param n Number of samples in the array.
|
||||
@@ -442,7 +442,7 @@ static double median(double *m, int n)
|
||||
return mingtguess;
|
||||
}
|
||||
|
||||
/*! \brief Convert many points for Signed L16 to relative floating point
|
||||
/*! \brief Convert many points for Signed L16 to relative floating point
|
||||
*
|
||||
* @author Eric des Courtis
|
||||
* @param i_pts Array of P 16 bit integer audio samples.
|
||||
@@ -460,9 +460,9 @@ static void convert_pts(int16_t *i_pts, double *d_pts, int16_t max)
|
||||
}
|
||||
|
||||
/*! \brief Amplitude estimator for DESA-2
|
||||
*
|
||||
*
|
||||
* The function is defined as \f$A = \sqrt{\frac{\psi{(x)}}{\sin{\Omega^2}}}\f$
|
||||
*
|
||||
*
|
||||
* @author Eric des Courtis
|
||||
* @param x An array of 5 evenly spaced audio samples \f$x_0, x_1, x_2, x_3, x_4\f$.
|
||||
* @return The estimated amplitude.
|
||||
@@ -477,11 +477,11 @@ double ampl_estimator(double *x)
|
||||
return sqrt(PSI(x) / sin(freq_sq));
|
||||
}
|
||||
|
||||
/*! \brief The DESA-2 algorithm
|
||||
/*! \brief The DESA-2 algorithm
|
||||
*
|
||||
* The function is defined as \f$f = \frac{1}{2}\arccos{\frac{{{x^2_2} -
|
||||
* {x_0}{x_4}} - {{x^2_1} -
|
||||
* {x_0}{x_2}} - {{x^2_3} -
|
||||
* The function is defined as \f$f = \frac{1}{2}\arccos{\frac{{{x^2_2} -
|
||||
* {x_0}{x_4}} - {{x^2_1} -
|
||||
* {x_0}{x_2}} - {{x^2_3} -
|
||||
* {x_2}{x_4}}}
|
||||
* {{2}({x^2_2} - {x_1}{x_3})}}\f$
|
||||
*
|
||||
@@ -499,7 +499,7 @@ double freq_estimator(double *x)
|
||||
);
|
||||
}
|
||||
|
||||
/*! \brief FreeSWITCH module loading function
|
||||
/*! \brief FreeSWITCH module loading function
|
||||
*
|
||||
* @author Eric des Courtis
|
||||
* @return Load success or failure.
|
||||
@@ -644,7 +644,7 @@ SWITCH_STANDARD_API(vmd_api_main)
|
||||
/* Separate the arguments */
|
||||
argc = switch_separate_string(ccmd, ' ', argv, VMD_PARAMS);
|
||||
|
||||
/* If we don't have the expected number of parameters
|
||||
/* If we don't have the expected number of parameters
|
||||
* display usage */
|
||||
if (argc != VMD_PARAMS) {
|
||||
stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
|
||||
@@ -710,7 +710,7 @@ SWITCH_STANDARD_API(vmd_api_main)
|
||||
vmd_info->points[i].ampl = 0.0;
|
||||
}
|
||||
|
||||
/* Add a media bug that allows me to intercept the
|
||||
/* Add a media bug that allows me to intercept the
|
||||
* reading leg of the audio stream */
|
||||
status = switch_core_media_bug_add(vmd_session, "vmd", NULL, vmd_callback, vmd_info, 0, SMBF_READ_REPLACE, &bug);
|
||||
|
||||
|
||||
@@ -71,4 +71,4 @@
|
||||
<!--<param name="record-copyright" value="Your Copyright"/>-->
|
||||
</profile>
|
||||
</profiles>
|
||||
</configuration>
|
||||
</configuration>
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Bret McDanel <trixter AT 0xdecafbad.com>
|
||||
* John Wehle (john@feith.com)
|
||||
@@ -211,7 +211,7 @@ switch_cache_db_handle_t *vm_get_db_handle(vm_profile_t *profile)
|
||||
|
||||
switch_cache_db_handle_t *dbh = NULL;
|
||||
char *dsn;
|
||||
|
||||
|
||||
if (!zstr(profile->odbc_dsn)) {
|
||||
dsn = profile->odbc_dsn;
|
||||
} else {
|
||||
@@ -221,7 +221,7 @@ switch_cache_db_handle_t *vm_get_db_handle(vm_profile_t *profile)
|
||||
if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {
|
||||
dbh = NULL;
|
||||
}
|
||||
|
||||
|
||||
return dbh;
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ static switch_status_t vm_config_validate_samplerate(switch_xml_config_item_t *i
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the profile's configuration instructions
|
||||
* \brief Sets the profile's configuration instructions
|
||||
*/
|
||||
vm_profile_t *profile_set_config(vm_profile_t *profile)
|
||||
{
|
||||
@@ -546,7 +546,7 @@ vm_profile_t *profile_set_config(vm_profile_t *profile)
|
||||
profile->config_str_pool.pool = profile->pool;
|
||||
|
||||
/*
|
||||
SWITCH _CONFIG_SET_ITEM(item, "key", type, flags,
|
||||
SWITCH _CONFIG_SET_ITEM(item, "key", type, flags,
|
||||
pointer, default, options, help_syntax, help_description)
|
||||
*/
|
||||
|
||||
@@ -689,7 +689,7 @@ vm_profile_t *profile_set_config(vm_profile_t *profile)
|
||||
&profile->db_password_override, SWITCH_FALSE, NULL, NULL, NULL);
|
||||
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "allow-empty-password-auth", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE,
|
||||
&profile->allow_empty_password_auth, SWITCH_TRUE, NULL, NULL, NULL);
|
||||
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "auto-playback-recordings", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->auto_playback_recordings, SWITCH_FALSE, NULL, NULL, NULL);
|
||||
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "auto-playback-recordings", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->auto_playback_recordings, SWITCH_FALSE, NULL, NULL, NULL);
|
||||
SWITCH_CONFIG_SET_ITEM(profile->config[i++], "send-full-vm-header", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &profile->send_full_vm_header, SWITCH_FALSE, NULL, NULL, NULL);
|
||||
|
||||
switch_assert(i < VM_PROFILE_CONFIGITEM_COUNT);
|
||||
@@ -917,7 +917,7 @@ static switch_status_t control_playback(switch_core_session_t *session, void *in
|
||||
|
||||
if (!cc->noexit
|
||||
&& (dtmf->digit == *cc->profile->delete_file_key || dtmf->digit == *cc->profile->save_file_key
|
||||
|| dtmf->digit == *cc->profile->prev_msg_key || dtmf->digit == *cc->profile->next_msg_key
|
||||
|| dtmf->digit == *cc->profile->prev_msg_key || dtmf->digit == *cc->profile->next_msg_key
|
||||
|| dtmf->digit == *cc->profile->repeat_msg_key
|
||||
|| dtmf->digit == *cc->profile->terminator_key || dtmf->digit == *cc->profile->skip_info_key
|
||||
|| dtmf->digit == *cc->profile->forward_key)) {
|
||||
@@ -1601,16 +1601,16 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
|
||||
msg.string_arg = cid_buf;
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sending display update [%s] to %s\n",
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sending display update [%s] to %s\n",
|
||||
cid_buf, switch_channel_get_name(channel));
|
||||
switch_core_session_receive_message(session, &msg);
|
||||
|
||||
|
||||
if (!zstr(cbt->cid_number) && (switch_true(switch_channel_get_variable(channel, "vm_announce_cid")))) {
|
||||
TRY_CODE(switch_ivr_phrase_macro(session, VM_SAY_PHONE_NUMBER_MACRO, cbt->cid_number, NULL, NULL));
|
||||
}
|
||||
|
||||
|
||||
args.input_callback = cancel_on_dtmf;
|
||||
|
||||
|
||||
switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s:%s%s%s", profile->repeat_msg_key, profile->save_file_key,
|
||||
profile->delete_file_key, profile->email_key, profile->callback_key,
|
||||
profile->forward_key, cbt->email ? ":" : "", cbt->email ? cbt->email : "");
|
||||
@@ -1726,7 +1726,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
|
||||
TRY_CODE(switch_ivr_read
|
||||
(session, 0, sizeof(vm_cc), macro_buf, NULL, vm_cc, sizeof(vm_cc), profile->digit_timeout, profile->terminator_key, 0));
|
||||
|
||||
cmd = switch_core_session_sprintf(session, "%s@%s@%s %s %s '%s'", vm_cc, cbt->domain, profile->name,
|
||||
cmd = switch_core_session_sprintf(session, "%s@%s@%s %s %s '%s'", vm_cc, cbt->domain, profile->name,
|
||||
new_file_path, cbt->cid_number, cbt->cid_name);
|
||||
|
||||
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
@@ -1734,9 +1734,9 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
|
||||
|
||||
status = switch_xml_locate_user_merged("id:number-alias", vm_cc, cbt->domain, NULL, &x_user, my_params);
|
||||
switch_event_destroy(&my_params);
|
||||
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
|
||||
"Failed to forward message - Cannot locate user %s@%s\n", vm_cc, cbt->domain);
|
||||
TRY_CODE(switch_ivr_phrase_macro(session, VM_INVALID_EXTENSION_MACRO, vm_cc, NULL, NULL));
|
||||
continue;
|
||||
@@ -1914,7 +1914,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
|
||||
static void update_mwi(vm_profile_t *profile, const char *id, const char *domain_name, const char *myfolder, mwi_reason_t reason)
|
||||
{
|
||||
const char *yn = "no";
|
||||
const char *update_reason = mwi_reason2str(reason);
|
||||
const char *update_reason = mwi_reason2str(reason);
|
||||
int total_new_messages = 0;
|
||||
int total_saved_messages = 0;
|
||||
int total_new_urgent_messages = 0;
|
||||
@@ -2043,7 +2043,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
||||
if (vm_auto_play && !switch_true(vm_auto_play)) {
|
||||
auto_play = 0;
|
||||
}
|
||||
|
||||
|
||||
folder_args.input_callback = cancel_on_dtmf;
|
||||
folder_args.buf = &global_buf;
|
||||
folder_args.buflen = sizeof(global_buf);
|
||||
@@ -2084,7 +2084,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (auto_play && !heard_auto_new && total_new_messages + total_new_urgent_messages > 0) {
|
||||
heard_auto_new = 1;
|
||||
play_msg_type = MSG_NEW;
|
||||
@@ -2158,7 +2158,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
||||
} else if (cbt.move == VM_MOVE_SAME) {
|
||||
cur_message -= 1;
|
||||
}
|
||||
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||
break;
|
||||
}
|
||||
@@ -2280,7 +2280,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
||||
|
||||
TRY_CODE(create_file(session, profile, VM_RECORD_GREETING_MACRO, file_path, &message_len, SWITCH_TRUE, NULL, NULL));
|
||||
switch_file_rename(tmp_file_path, file_path, switch_core_session_get_pool(session));
|
||||
|
||||
|
||||
sql =
|
||||
switch_mprintf("update voicemail_prefs set greeting_path='%q' where username='%q' and domain='%q'", file_path, myid,
|
||||
domain_name);
|
||||
@@ -2311,7 +2311,7 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
||||
fail = 0;
|
||||
switch_snprintf(macro, sizeof(macro), "phrase:%s:%s", VM_ENTER_PASS_MACRO, profile->terminator_key);
|
||||
TRY_CODE(switch_ivr_read(session, 0, 255, macro, NULL, buf, sizeof(buf), 10000, profile->terminator_key, 0));
|
||||
|
||||
|
||||
|
||||
switch_event_create_subclass(¶ms, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Action", "change-password");
|
||||
@@ -2319,23 +2319,23 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-User", myid);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Domain", domain_name);
|
||||
switch_channel_event_set_data(channel, params);
|
||||
|
||||
|
||||
if (zstr(buf) && !profile->allow_empty_password_auth) {
|
||||
fail = 1;
|
||||
}
|
||||
if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
|
||||
&xx_domain_root, &xx_domain, &xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_xml_t x_result;
|
||||
|
||||
|
||||
if ((x_result = switch_xml_child(xx_user, "result"))) {
|
||||
if (!switch_true(switch_xml_attr_soft(x_result, "success"))) {
|
||||
fail = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_xml_free(xx_domain_root);
|
||||
}
|
||||
|
||||
|
||||
if (fail) {
|
||||
/* add feedback for user - let him/her know that the password they tried to change to is not allowed */
|
||||
switch_ivr_phrase_macro(session, VM_CHANGE_PASS_FAIL_MACRO, NULL, NULL, NULL);
|
||||
@@ -2718,9 +2718,9 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
|
||||
const char *read_flags,
|
||||
switch_event_t *params,
|
||||
switch_memory_pool_t *pool,
|
||||
const char *caller_id_name,
|
||||
const char *caller_id_number,
|
||||
const char *forwarded_by,
|
||||
const char *caller_id_name,
|
||||
const char *caller_id_number,
|
||||
const char *forwarded_by,
|
||||
switch_bool_t copy, const char *use_uuid, switch_core_session_t *session)
|
||||
{
|
||||
char *file_path = NULL, *dir_path = NULL;
|
||||
@@ -2964,7 +2964,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_account", myid);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_domain", domain_name);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_caller_id_number", caller_id_number);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_formatted_caller_id_number", formatted_cid_num);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_formatted_caller_id_number", formatted_cid_num);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_caller_id_name", caller_id_name);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_file_path", file_path);
|
||||
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_read_flags", read_flags);
|
||||
@@ -3055,7 +3055,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
|
||||
if (zstr(vm_notify_email)) {
|
||||
vm_notify_email = vm_email;
|
||||
}
|
||||
|
||||
|
||||
if (zstr(profile->notify_email_headers)) {
|
||||
headers = switch_mprintf("From: FreeSWITCH mod_voicemail <%s@%s>\n"
|
||||
"Subject: Voicemail from %s %s\nX-Priority: %d", myid, domain_name, caller_id_name, caller_id_number, priority);
|
||||
@@ -3172,7 +3172,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
|
||||
char *forwarded_by = NULL;
|
||||
char *read_flags = NORMAL_FLAG_STRING;
|
||||
char *dup_domain = NULL;
|
||||
|
||||
|
||||
if (zstr(data)) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto end;
|
||||
@@ -3302,8 +3302,8 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
|
||||
|
||||
switch_xml_merge_user(ut, x_domain, group);
|
||||
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
status = deliver_vm(profile, ut, domain, path, 0, read_flags,
|
||||
my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE,
|
||||
status = deliver_vm(profile, ut, domain, path, 0, read_flags,
|
||||
my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE,
|
||||
session ? switch_core_session_get_uuid(session) : NULL, session);
|
||||
switch_event_destroy(&my_params);
|
||||
}
|
||||
@@ -3326,7 +3326,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
|
||||
|
||||
switch_xml_merge_user(ut, x_domain, group);
|
||||
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
status = deliver_vm(profile, ut, domain, path, 0, read_flags,
|
||||
status = deliver_vm(profile, ut, domain, path, 0, read_flags,
|
||||
my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE,
|
||||
session ? switch_core_session_get_uuid(session) : NULL, session);
|
||||
switch_event_destroy(&my_params);
|
||||
@@ -3341,7 +3341,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t
|
||||
if ((status = switch_xml_locate_user_in_domain(user, x_domain, &ut, &x_group)) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_xml_merge_user(ut, x_domain, x_group);
|
||||
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
status = deliver_vm(profile, ut, domain, path, 0, read_flags,
|
||||
status = deliver_vm(profile, ut, domain, path, 0, read_flags,
|
||||
my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE,
|
||||
session ? switch_core_session_get_uuid(session) : NULL, session);
|
||||
switch_event_destroy(&my_params);
|
||||
@@ -3370,7 +3370,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
|
||||
char sql[256];
|
||||
prefs_callback_t cbt;
|
||||
switch_uuid_t tmp_uuid;
|
||||
char tmp_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
char tmp_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
char *file_path = NULL;
|
||||
char *dir_path = NULL;
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
@@ -3582,7 +3582,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
|
||||
int argc;
|
||||
char *argv[4];
|
||||
char *mycmd;
|
||||
|
||||
|
||||
if ((!zstr(operator_ext) && (mycmd = switch_core_session_strdup(session, operator_ext))) ||
|
||||
(!zstr(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext)))) {
|
||||
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
@@ -4026,7 +4026,7 @@ static void actual_message_query_handler(switch_event_t *event)
|
||||
if ((profile = (vm_profile_t *) switch_core_hash_find(globals.profile_hash, domain))) {
|
||||
parse_profile();
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"Cound not find a profile for domain: [%s] Returning 0 messages\nWhen message-query-exact-match is enabled you must have a dedicated vm profile per distinct domain name you wish to use.\n", domain);
|
||||
}
|
||||
} else {
|
||||
@@ -4358,7 +4358,7 @@ static int web_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
holder->stream->write_function(holder->stream, "<font face=tahoma><div class=title><b>Message from %s %s</b></div><hr noshade size=1>\n",
|
||||
argv[5], argv[6]);
|
||||
holder->stream->write_function(holder->stream, "Priority: %s<br>\n" "Created: %s<br>\n" "Last Heard: %s<br>\n" "Duration: %s<br>\n",
|
||||
//"<a href=%s>Delete This Message</a><br><hr noshade size=1>",
|
||||
//"<a href=%s>Delete This Message</a><br><hr noshade size=1>",
|
||||
strcmp(argv[10], URGENT_FLAG_STRING) ? "normal" : "urgent", create_date, heard, duration_str);
|
||||
|
||||
switch_snprintf(title_b4, sizeof(title_b4), "%s <%s> %s", argv[5], argv[6], rss_date);
|
||||
@@ -4616,7 +4616,7 @@ static int api_del_callback(void *pArg, int argc, char **argv, char **columnName
|
||||
{
|
||||
|
||||
unlink(argv[3]);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4635,7 +4635,7 @@ SWITCH_STANDARD_API(voicemail_delete_api_function)
|
||||
}
|
||||
|
||||
id = strdup(cmd);
|
||||
|
||||
|
||||
if (!id) {
|
||||
stream->write_function(stream, "Allocation Error\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -4658,16 +4658,16 @@ SWITCH_STANDARD_API(voicemail_delete_api_function)
|
||||
|
||||
|
||||
if (domain && profile_name && (profile = get_profile(profile_name))) {
|
||||
|
||||
|
||||
if (uuid) {
|
||||
sql = switch_mprintf("select username, domain, in_folder, file_path from voicemail_msgs where uuid='%q'", uuid);
|
||||
} else {
|
||||
sql = switch_mprintf("select username, domain, in_folder, file_path from voicemail_msgs where username='%q' and domain='%q'", id, domain);
|
||||
}
|
||||
|
||||
|
||||
vm_execute_sql_callback(profile, profile->mutex, sql, api_del_callback, profile);
|
||||
switch_safe_free(sql);
|
||||
|
||||
|
||||
if (uuid) {
|
||||
sql = switch_mprintf("delete from voicemail_msgs where uuid='%q'", uuid);
|
||||
} else {
|
||||
@@ -4676,9 +4676,9 @@ SWITCH_STANDARD_API(voicemail_delete_api_function)
|
||||
|
||||
vm_execute_sql(profile, sql, profile->mutex);
|
||||
switch_safe_free(sql);
|
||||
|
||||
|
||||
update_mwi(profile, id, domain, "inbox", MWI_REASON_DELETE);
|
||||
|
||||
|
||||
stream->write_function(stream, "%s", "+OK\n");
|
||||
profile_rwunlock(profile);
|
||||
} else {
|
||||
@@ -4713,7 +4713,7 @@ SWITCH_STANDARD_API(voicemail_read_api_function)
|
||||
stream->write_function(stream, "Allocation failure\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
if ((p = strchr(id, '@'))) {
|
||||
*p++ = '\0';
|
||||
domain = e = p;
|
||||
@@ -4746,7 +4746,7 @@ SWITCH_STANDARD_API(voicemail_read_api_function)
|
||||
|
||||
|
||||
if (mread > -1 && domain && profile_name && (profile = get_profile(profile_name))) {
|
||||
|
||||
|
||||
if (mread) {
|
||||
if (uuid) {
|
||||
sql = switch_mprintf("update voicemail_msgs set read_epoch=%ld where uuid='%q'", (long) switch_epoch_time_now(NULL), uuid);
|
||||
@@ -4763,9 +4763,9 @@ SWITCH_STANDARD_API(voicemail_read_api_function)
|
||||
|
||||
vm_execute_sql(profile, sql, profile->mutex);
|
||||
switch_safe_free(sql);
|
||||
|
||||
|
||||
update_mwi(profile, id, domain, "inbox", MWI_REASON_READ);
|
||||
|
||||
|
||||
stream->write_function(stream, "%s", "+OK\n");
|
||||
|
||||
profile_rwunlock(profile);
|
||||
@@ -4800,7 +4800,7 @@ static int api_list_callback(void *pArg, int argc, char **argv, char **columnNam
|
||||
} else {
|
||||
stream->write_function(stream, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n", argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4819,7 +4819,7 @@ SWITCH_STANDARD_API(voicemail_list_api_function)
|
||||
}
|
||||
|
||||
id = strdup(cmd);
|
||||
|
||||
|
||||
if (!id) {
|
||||
stream->write_function(stream, "Allocation Error\n");
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -4848,11 +4848,11 @@ SWITCH_STANDARD_API(voicemail_list_api_function)
|
||||
if (domain && profile_name && (profile = get_profile(profile_name))) {
|
||||
if (uuid) {
|
||||
sql = switch_mprintf("select created_epoch, read_epoch, username, domain, in_folder, file_path, uuid, cid_name, cid_number, message_len, "
|
||||
"'%q' from voicemail_msgs where username='%q' and domain='%q' and uuid='%q'",
|
||||
"'%q' from voicemail_msgs where username='%q' and domain='%q' and uuid='%q'",
|
||||
format, id, domain, uuid);
|
||||
} else {
|
||||
sql = switch_mprintf("select created_epoch, read_epoch, username, domain, in_folder, file_path, uuid, cid_name, cid_number, message_len, "
|
||||
"'%q' from voicemail_msgs where username='%q' and domain='%q'",
|
||||
"'%q' from voicemail_msgs where username='%q' and domain='%q'",
|
||||
format, id, domain);
|
||||
}
|
||||
|
||||
@@ -4862,7 +4862,7 @@ SWITCH_STANDARD_API(voicemail_list_api_function)
|
||||
|
||||
vm_execute_sql_callback(profile, profile->mutex, sql, api_list_callback, stream);
|
||||
switch_safe_free(sql);
|
||||
|
||||
|
||||
if (!strcasecmp(format, "xml")) {
|
||||
stream->write_function(stream, "</voicemail>\n");
|
||||
}
|
||||
@@ -5234,10 +5234,10 @@ not implemented yet
|
||||
|
||||
profile_rwunlock(profile);
|
||||
|
||||
/* TODO If no slot requested, returned currently selected and figure out the slot number from the file name.
|
||||
/* TODO If no slot requested, returned currently selected and figure out the slot number from the file name.
|
||||
* IF slot provided, check if file exist, check if it currently selected */
|
||||
if (zstr(res)) {
|
||||
stream->write_function(stream, "-ERR No greeting found\n");
|
||||
stream->write_function(stream, "-ERR No greeting found\n");
|
||||
} else {
|
||||
switch_event_t *my_params = NULL;
|
||||
char *ebuf = NULL;
|
||||
@@ -5682,7 +5682,7 @@ SWITCH_STANDARD_API(vm_fsdb_msg_undelete_function)
|
||||
sql = switch_mprintf("UPDATE voicemail_msgs SET flags='' WHERE username='%q' AND domain='%q' AND uuid = '%q'", id, domain, uuid);
|
||||
vm_execute_sql(profile, sql, profile->mutex);
|
||||
profile_rwunlock(profile);
|
||||
|
||||
|
||||
stream->write_function(stream, "-OK\n");
|
||||
done:
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
@@ -5754,10 +5754,10 @@ SWITCH_STANDARD_API(vm_fsdb_auth_login_function)
|
||||
|
||||
if (!strcasecmp(var, "vm-enabled")) {
|
||||
vm_enabled = !switch_false(val);
|
||||
}
|
||||
}
|
||||
if (!strcasecmp(var, "vm-password")) {
|
||||
user_xml_password = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sql = switch_mprintf("SELECT password FROM voicemail_prefs WHERE username = '%q' AND domain = '%q'", id, domain);
|
||||
@@ -5865,7 +5865,7 @@ SWITCH_STANDARD_API(vm_fsdb_msg_forward_function)
|
||||
switch_uuid_format(tmp_uuid_str, &tmp_uuid);
|
||||
|
||||
new_file_path = switch_core_sprintf(pool, "%s%smsg_%s.wav", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, tmp_uuid_str);
|
||||
|
||||
|
||||
if (vm_merge_media_files(test, new_file_path) != SWITCH_STATUS_SUCCESS) {
|
||||
stream->write_function(stream, "-ERR Error Merging the file\n");
|
||||
switch_event_destroy(&cbt.my_params);
|
||||
@@ -6099,7 +6099,7 @@ SWITCH_STANDARD_API(vm_fsdb_msg_email_function)
|
||||
if (zstr(profile->email_headers)) {
|
||||
headers = switch_core_sprintf(pool,
|
||||
"From: FreeSWITCH mod_voicemail <%s@%s>\nSubject: Voicemail from %s %s\nX-Priority: %d",
|
||||
id, domain, switch_event_get_header(cbt.my_params, "VM-Message-Caller-Name"),
|
||||
id, domain, switch_event_get_header(cbt.my_params, "VM-Message-Caller-Name"),
|
||||
switch_event_get_header(cbt.my_params, "VM-Message-Caller-Number"), priority);
|
||||
} else {
|
||||
headers = switch_event_expand_headers(cbt.my_params, profile->email_headers);
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
<key dtmf="4" action="rerecord" variable="VM-Key-ReRecord-File" />
|
||||
<key dtmf="#" action="skip_instruction" />
|
||||
</keys>
|
||||
</menu>
|
||||
</menu>
|
||||
|
||||
<menu name="std_forward_ask_prepend">
|
||||
<phrases>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Marc Olivier Chouinard <mochouinard@moctel.com>
|
||||
*
|
||||
*
|
||||
@@ -60,7 +60,7 @@ void menu_init(vmivr_profile_t *profile, vmivr_menu_t *menu) {
|
||||
switch_event_merge(menu_default, menu->event_settings);
|
||||
switch_event_destroy(&menu->event_settings);
|
||||
}
|
||||
|
||||
|
||||
switch_event_create(&menu->event_settings, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
switch_event_merge(menu->event_settings, profile->event_settings);
|
||||
switch_event_merge(menu->event_settings, menu_default);
|
||||
@@ -188,7 +188,7 @@ vmivr_profile_t *get_profile(switch_core_session_t *session, const char *profile
|
||||
if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile_name))) {
|
||||
if (!(profile = switch_core_session_alloc(session, sizeof(vmivr_profile_t)))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n");
|
||||
goto end;
|
||||
goto end;
|
||||
}
|
||||
|
||||
profile->name = profile_name;
|
||||
|
||||
Loaded 100 of 455 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user