FS-9924: Removed extra space in source files

This commit is contained in:
Sergey Safarov committed 2017-02-09 23:59:49 -05:00
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):
*
*
* Anthony Minessale II <anthm@freeswitch.org>
* Cesar Cepeda <cesar@auronix.com>
* Emmanuel Schmidbauer <e.schmidbauer@gmail.com>
@@ -159,7 +159,7 @@ switch_status_t list_streams_full(const char *line, const char *cursor, switch_c
const void *vvar;
switch_console_callback_match_t *my_matches = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
switch_mutex_lock(globals.mutex);
for (hi = switch_core_hash_first(globals.source_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, &vvar, NULL, &val);
@@ -172,12 +172,12 @@ switch_status_t list_streams_full(const char *line, const char *cursor, switch_c
switch_console_push_match(&my_matches, (const char *) vvar);
}
switch_mutex_unlock(globals.mutex);
if (my_matches) {
*matches = my_matches;
status = SWITCH_STATUS_SUCCESS;
}
return status;
}
@@ -269,7 +269,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
while (RUNNING && !source->stopped && source->ready) {
const char *fname;
if (source->dir_handle) {
switch_dir_close(source->dir_handle);
source->dir_handle = NULL;
@@ -373,7 +373,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
if ((p = strrchr(tmp_buf, '/'))) {
*p++ = '\0';
switch_snprintf(png_buf, sizeof(png_buf), "%s/art/%s.png", tmp_buf, p);
switch_snprintf(png_buf, sizeof(png_buf), "%s/art/%s.png", tmp_buf, p);
if (switch_file_exists(png_buf, temp_pool) == SWITCH_STATUS_SUCCESS) {
source->cover_art = switch_img_read_png(png_buf, SWITCH_IMG_FMT_I420);
}
@@ -382,24 +382,24 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
source->serno++;
switch_safe_free(source->banner_txt);
title = artist = NULL;
switch_core_file_get_string(&fh, SWITCH_AUDIO_COL_STR_ARTIST, &artist);
switch_core_file_get_string(&fh, SWITCH_AUDIO_COL_STR_TITLE, &title);
if (!title && !artist) {
char *e, *p, *args[3];
int argc;
switch_set_string(tmp_space, path_buf);
p = tmp_space;
while((e = strchr(p, '/'))) {
*e = '\0';
p = e+1;
}
argc = switch_split(p, '-', args);
if (argc > 0) {
while(*args[0] == ' ') {
args[0]++;
@@ -408,7 +408,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
while(end_of(args[0]) == ' ') {
end_of(args[0]) = '\0';
}
artist = args[0];
if (argc > 1) {
@@ -430,17 +430,17 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
artist = NULL;
}
}
if (title && (source->cover_art || switch_core_file_has_video(&fh, SWITCH_TRUE))) {
const char *format = "#cccccc:#333333:FreeSans.ttf:3%:";
if (artist) {
source->banner_txt = switch_mprintf("%s%s (%s)", format, title, artist);
} else {
source->banner_txt = switch_mprintf("%s%s", format, title);
}
}
while (RUNNING && !source->stopped) {
int is_open;
@@ -448,13 +448,13 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
switch_core_timer_next(&source->timer);
olen = source->samples;
if (source->chime_total) {
if (source->chime_counter > 0) {
source->chime_counter -= (int32_t)source->samples;
}
if (!switch_test_flag((&source->chime_fh), SWITCH_FILE_OPEN) && source->chime_counter <= 0) {
char *val;
@@ -497,19 +497,19 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
source->hup = 0;
if (is_open) {
is_open = 0;
switch_core_file_close(use_fh);
flush_video_queue(source->video_q);
switch_buffer_zero(audio_buffer);
if (use_fh == &source->chime_fh) {
source->chime_counter = source->rate * source->chime_freq;
switch_core_file_close(&fh);
use_fh = &fh;
use_fh = &fh;
}
goto retry;
}
}
if (is_open) {
int svr = 0;
@@ -548,7 +548,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
switch_core_file_read(&fh, source->abuf, &olen);
olen = source->samples;
}
switch_assert(source->abuflen >= olen * 2 * source->channels);
if (switch_core_file_read(use_fh, source->abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) {
@@ -573,7 +573,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
goto retry;
}
}
if (source->total) {
if (source->energy_avg && source->agc) {
@@ -602,17 +602,17 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
void *pop;
uint32_t bused = 0;
local_stream_context_t *cp = NULL;
switch_assert(source->abuflen <= source->prebuf);
used = switch_buffer_read(audio_buffer, dist_buf, source->abuflen);
switch_mutex_lock(source->mutex);
for (cp = source->context_list; cp && RUNNING; cp = cp->next) {
if (!cp->ready) {
continue;
}
switch_mutex_lock(cp->audio_mutex);
if (switch_test_flag(cp->handle, SWITCH_FILE_OPEN)) {
@@ -625,7 +625,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
bused = (uint32_t)switch_buffer_inuse(cp->audio_buffer);
if (bused > source->samples * 768) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Flushing Stream Handle Buffer [%s() %s:%d] size: %u samples: %ld\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Flushing Stream Handle Buffer [%s() %s:%d] size: %u samples: %ld\n",
cp->func, cp->file, cp->line, bused, (long)source->samples);
switch_buffer_zero(cp->audio_buffer);
} else {
@@ -635,7 +635,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
}
switch_mutex_unlock(source->mutex);
while (switch_queue_trypop(source->video_q, &pop) == SWITCH_STATUS_SUCCESS) {
switch_image_t *img;
switch_image_t *imgcp = NULL;
@@ -681,7 +681,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
}
}
}
}
}
switch_img_free(&img);
}
}
@@ -782,7 +782,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
}
switch_safe_free(source->banner_txt);
if (switch_test_flag((&fh), SWITCH_FILE_OPEN)) {
switch_core_file_close(&fh);
}
@@ -875,7 +875,7 @@ static switch_status_t local_stream_file_open(switch_file_handle_t *handle, cons
//}
pool = handle->memory_pool;
if ((context = switch_core_alloc(pool, sizeof(*context))) == 0) {
abort();
}
@@ -902,7 +902,7 @@ static switch_status_t local_stream_file_open(switch_file_handle_t *handle, cons
goto end;
}
if (!switch_core_has_video() ||
if (!switch_core_has_video() ||
(switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) && !source->has_video && !source->blank_img && !source->cover_art && !source->banner_txt)) {
switch_clear_flag_locked(handle, SWITCH_FILE_FLAG_VIDEO);
}
@@ -949,21 +949,21 @@ static switch_status_t local_stream_file_close(switch_file_handle_t *handle)
last->next = cp->next;
} else {
source->context_list = cp->next;
}
}
break;
}
last = cp;
}
switch_mutex_lock(context->audio_mutex);
if (source->has_video) {
flush_video_queue(context->video_q);
switch_queue_trypush(context->video_q, NULL);
switch_queue_interrupt_all(context->video_q);
flush_video_queue(context->video_q);
}
source->total--;
switch_img_free(&context->banner_img);
@@ -1004,7 +1004,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
if (src_img) {
switch_image_t *img = NULL;
if (context->sent_png && --context->sent_png > 0) {
return SWITCH_STATUS_BREAK;
}
@@ -1042,7 +1042,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
if (!(context->ready && context->source->ready)) {
return SWITCH_STATUS_FALSE;
}
while (!(flags & SVR_BLOCK) && switch_queue_size(context->video_q) < buf_qsize) {
return SWITCH_STATUS_BREAK;
}
@@ -1078,7 +1078,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
switch_img_fill(frame->img, 0, 0, frame->img->d_w, frame->img->d_h, &bgcolor);
context->pop_count--;
}
now = switch_micro_time_now();
if (context->banner_img) {
@@ -1093,7 +1093,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
context->serno = context->source->serno;
context->pop_count = 5;
}
if (context->source->banner_txt) {
if ((!context->banner_timeout || context->banner_timeout >= now)) {
if (context->newres) {
@@ -1116,12 +1116,12 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
switch_img_overlay(frame->img, context->banner_img, 0, frame->img->d_h - context->banner_img->d_h, context->source->text_opacity);
}
if (frame->img && context->source->logo_img &&
if (frame->img && context->source->logo_img &&
(context->source->logo_always || context->banner_img) && frame->img->d_w >= context->source->logo_img->d_w) {
int x = 0, y = 0;
switch_img_find_position(context->source->logo_pos,
frame->img->d_w, frame->img->d_h,
frame->img->d_w, frame->img->d_h,
context->source->logo_img->d_w, context->source->logo_img->d_h,
&x, &y);
@@ -1145,7 +1145,7 @@ static switch_status_t local_stream_file_read(switch_file_handle_t *handle, void
*len = 0;
return SWITCH_STATUS_FALSE;
}
if (context->source->has_video) {
if (!switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
switch_set_flag_locked(handle, SWITCH_FILE_FLAG_VIDEO);
@@ -1163,7 +1163,7 @@ static switch_status_t local_stream_file_read(switch_file_handle_t *handle, void
*len = bytes / 2 / context->source->channels;
} else {
size_t blank;
switch_assert(handle->samplerate <= 48000);
switch_assert(handle->real_channels <= 2);
@@ -1443,7 +1443,7 @@ SWITCH_STANDARD_API(local_stream_function)
stream->write_function(stream, "+OK stream: %s", local_stream_name);
}
}
} else if (!strcasecmp(argv[0], "show")) {
switch_hash_index_t *hi;
const void *var;
@@ -1500,12 +1500,12 @@ SWITCH_STANDARD_API(local_stream_function)
}
}
}
goto done;
usage:
stream->write_function(stream, "-USAGE: %s\n", LOCAL_STREAM_SYNTAX);
done:
switch_safe_free(mycmd);
@@ -1526,7 +1526,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load)
if (!launch_streams(NULL)) {
return SWITCH_STATUS_GENERR;
}
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
file_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE);
file_interface->interface_name = modname;
@@ -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>
*
*
+6 -6
View File
@@ -1,4 +1,4 @@
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
@@ -67,7 +67,7 @@ static switch_status_t png_file_open(switch_file_handle_t *handle, const char *p
return SWITCH_STATUS_GENERR;
}
ext++;
if ((context = (png_file_context_t *)switch_core_alloc(handle->memory_pool, sizeof(png_file_context_t))) == 0) {
return SWITCH_STATUS_MEMERR;
}
@@ -190,7 +190,7 @@ static switch_status_t png_file_read(switch_file_handle_t *handle, void *data, s
status = SWITCH_STATUS_FALSE;
switch_goto_status(status, end);
}
memset(data, 0, *len * 2 * handle->channels);
end:
@@ -295,7 +295,7 @@ static switch_bool_t write_png_bug_callback(switch_media_bug_t *bug, void *user_
switch_img_write_png(frame->img, data->path);
return SWITCH_FALSE;
}
if (!data->write_img) {
switch_img_copy(frame->img, &data->write_img);
}
@@ -352,7 +352,7 @@ SWITCH_STANDARD_API(uuid_write_png_function)
stream->write_function(stream, "-USAGE: <uuid> <path> [concat | split <other_path>]\n");
goto end;
}
uuid = argv[0];
if (!(session_ = switch_core_session_locate(uuid))) {
@@ -448,7 +448,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_png_load)
SWITCH_ADD_API(api_interface, "uuid_write_png", "grab an image from a call",uuid_write_png_function, "");
switch_console_set_complete("add uuid_write_png ::console::list_uuid");
/* 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):
*
*
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_shell_stream.c -- Local Streaming Audio
@@ -176,7 +176,7 @@ static switch_status_t shell_stream_file_close(switch_file_handle_t *handle)
if (context->thread) {
switch_thread_join(&st, context->thread);
}
if (context->audio_buffer) {
switch_buffer_destroy(&context->audio_buffer);
}
+8 -8
View File
@@ -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>
* John Wehle <john@feith.com>
@@ -478,7 +478,7 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
switch_mutex_lock(context->audio_mutex);
context->curlfd = curlfd;
switch_mutex_unlock(context->audio_mutex);
return 0;
}
@@ -752,16 +752,16 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char
}
context->channels = handle->channels;
if (globals.brate) {
lame_set_brate(context->gfp, globals.brate);
} else {
lame_set_brate(context->gfp, 16 * (handle->samplerate / 8000) * handle->channels);
}
lame_set_num_channels(context->gfp, handle->channels);
lame_set_in_samplerate(context->gfp, handle->samplerate);
if (globals.resample) {
lame_set_out_samplerate(context->gfp, globals.resample);
} else {
@@ -880,7 +880,7 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char
} else {
const char *mask = "wb+";
if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
mask = "ab+";
}
@@ -979,7 +979,7 @@ static switch_status_t shout_file_read(switch_file_handle_t *handle, void *data,
if (newbytes < bytes) {
bytes = newbytes;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Padding mp3 stream with %ds of empty audio. (%s)\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Padding mp3 stream with %ds of empty audio. (%s)\n",
context->buffer_seconds, context->stream_url);
memset(data, 255, bytes);
+7 -7
View File
@@ -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>
*
*
@@ -225,7 +225,7 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
handle->pos = sf_seek(context->handle, frames, SEEK_END);
} else if (switch_test_flag(handle, SWITCH_FILE_WRITE_OVER)) {
handle->pos = sf_seek(context->handle, frames, SEEK_SET);
} else {
} else {
sf_command(context->handle, SFC_FILE_TRUNCATE, &frames, sizeof(frames));
}
@@ -279,7 +279,7 @@ static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned
sndfile_context *context = handle->private_info;
sf_count_t count;
switch_status_t r = SWITCH_STATUS_SUCCESS;
if (!handle->seekable) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File is not seekable\n");
return SWITCH_STATUS_NOTIMPL;
@@ -289,10 +289,10 @@ static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned
r = SWITCH_STATUS_BREAK;
count = sf_seek(context->handle, -1, SEEK_END);
}
*cur_sample = (unsigned int) count;
handle->pos = *cur_sample;
handle->pos = *cur_sample;
return r;
}
@@ -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>
*
*
@@ -56,7 +56,7 @@ static switch_status_t silence_stream_file_open(switch_file_handle_t *handle, co
}
sh = switch_core_alloc(handle->memory_pool, sizeof(*sh));
if (ms > 0) {
sh->samples = (handle->samplerate / 1000) * ms;
} else {
@@ -151,7 +151,7 @@ static switch_status_t tone_stream_file_open(switch_file_handle_t *handle, const
if (handle->params) {
if ((tmp = switch_event_get_header(handle->params, "loops"))) {
loops = atoi(tmp);
switch_buffer_set_loops(audio_buffer, loops);
switch_buffer_set_loops(audio_buffer, loops);
}
}
+95 -95
View File
@@ -41,7 +41,7 @@
* To playback a video file
* play_video /tmp/test.mp4
*
* Notes:
* Notes:
*
* Audio Requires at least libvlc version 1.2
* Video Requires at least libvlc 2.0.2
@@ -182,7 +182,7 @@ void log_cb(void *data, int level, const libvlc_log_t *ctx, const char *fmt, va_
ret = switch_vasprintf(&ldata, fmt, args);
if (ret == -1) return;
if (end_of(ldata) == '\n') {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, fslevel, "VLC: %s", ldata);
} else {
@@ -191,7 +191,7 @@ void log_cb(void *data, int level, const libvlc_log_t *ctx, const char *fmt, va_
switch_safe_free(ldata);
}
void yuyv_to_i420(uint8_t *pixels, void *out_buffer, int src_width, int src_height)
@@ -254,7 +254,7 @@ static libvlc_media_t *get_list_media(vlc_video_context_t *vcontext)
libvlc_media_list_t *ml = libvlc_media_subitems(vcontext->m);
if (ml) {
int i, count = libvlc_media_list_count(ml);
for (i = 0; i < count; i++) {
libvlc_media_t *media = libvlc_media_list_item_at_index(ml, i);
if (media) return media;
@@ -426,7 +426,7 @@ static void vlc_video_unlock_callback(void *data, void *id, void *const *p_pixel
switch_assert(context->img);
yuyv_to_i420(*p_pixels, context->img->img_data, context->width, context->height);
switch_mutex_unlock(context->video_mutex);
}
@@ -440,7 +440,7 @@ static void vlc_video_channel_unlock_callback(void *data, void *id, void *const
if (context->channel && !switch_channel_test_flag(context->channel, CF_VIDEO)) return;
if (!context->img) context->img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, context->width, context->height, 0); switch_assert(context->img);
yuyv_to_i420(*p_pixels, context->img->img_data, context->width, context->height);
switch_mutex_unlock(context->video_mutex);
@@ -541,13 +541,13 @@ static int vlc_imem_get_callback(void *data, const char *cookie, int64_t *dts, i
vlc_file_context_t *context = (vlc_file_context_t *) data;
//int samples = 0;
int bytes = 0, bread = 0, blen = 0;
if (context->playing == 0) return -1;
switch_mutex_lock(context->audio_mutex);
blen = switch_buffer_inuse(context->audio_buffer);
if (!(bytes = blen)) {
*size = 0;
*output = NULL;
@@ -566,7 +566,7 @@ static int vlc_imem_get_callback(void *data, const char *cookie, int64_t *dts, i
bread = switch_buffer_read(context->audio_buffer, *output, bytes);
switch_mutex_unlock(context->audio_mutex);
*size = (size_t) bread;
return 0;
@@ -578,7 +578,7 @@ void vlc_imem_release_callback(void *data, const char *cookie, size_t size, void
//free(unknown);
}
static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image_t *img)
static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image_t *img)
{
switch_memory_pool_t *pool;
char *imem_main, *imem_slave;
@@ -623,7 +623,7 @@ static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image
switch_mutex_init(&vcontext->video_mutex, SWITCH_MUTEX_NESTED, vcontext->pool);
switch_thread_cond_create(&vcontext->cond, vcontext->pool);
switch_thread_cond_create(&acontext->cond, acontext->pool);
switch_core_timer_init(&vcontext->timer, "soft", 1, 1000, vcontext->pool);
vcontext->timer.start -= 60000000;
switch_core_timer_sync(&vcontext->timer);
@@ -655,25 +655,25 @@ static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image
"samplerate=%d:"
"channels=%d:"
"id=1:"
"caching=0",
"caching=0",
vcontext->samplerate, vcontext->channels);
vcontext->m = libvlc_media_new_location(acontext->vlc_handle, imem_main);
libvlc_media_add_option_flag( vcontext->m, imem_slave, libvlc_media_option_trusted );
libvlc_media_add_option_flag( vcontext->m, imem_slave, libvlc_media_option_trusted );
if (vcontext->m == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error opening %s for writing\n", acontext->path);
return SWITCH_STATUS_FALSE;
}
vcontext->mp = libvlc_media_player_new_from_media(vcontext->m);
vcontext->samples = 0;
vcontext->pts = 0;
acontext->vcontext = vcontext;
return SWITCH_STATUS_SUCCESS;
}
@@ -719,7 +719,7 @@ static switch_status_t vlc_file_av_open(switch_file_handle_t *handle, const char
vcontext->playing = 0;
vcontext->err = 0;
vcontext->mp = libvlc_media_player_new_from_media(vcontext->m);
if (!handle->samplerate) {
@@ -741,7 +741,7 @@ static switch_status_t vlc_file_av_open(switch_file_handle_t *handle, const char
vcontext->channels = handle->channels;
libvlc_audio_set_format(vcontext->mp, "S16N", vcontext->samplerate, handle->channels);
m_event_manager = libvlc_media_event_manager(vcontext->m);
libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_av_state_callback, (void *) acontext);
@@ -806,8 +806,8 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p
if (handle->mm.fps > 0.0f) {
handle->mm.keyint = (int) 2.0f * handle->mm.fps;
}
path = switch_core_sprintf(context->pool,
path = switch_core_sprintf(context->pool,
"#transcode{"
"venc=x264{keyint=%d},"
"vcodec=h264,"
@@ -821,7 +821,7 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p
"access=avio,"
"mux=flv,"
"dst=rtmp://%s"
"}",
"}",
handle->mm.keyint, handle->mm.ab, handle->mm.vb, handle->mm.channels, handle->mm.samplerate, path);
}
@@ -829,7 +829,7 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p
context->path = switch_core_strdup(context->pool, path);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC attempt to open %s %s %s %s\n",
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VLC attempt to open %s %s %s %s\n",
context->path, switch_test_flag(handle, SWITCH_FILE_FLAG_READ) ? "read" : "",
switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE) ? "write" : "",
switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) ? "video" : ""
@@ -893,13 +893,13 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p
context->channels = handle->channels;
libvlc_audio_set_format(context->mp, "S16N", context->samplerate, handle->channels);
m_event_manager = libvlc_media_event_manager(context->m);
libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_state_callback, (void *) context);
mp_event_manager = libvlc_media_player_event_manager(context->mp);
libvlc_event_attach(mp_event_manager, libvlc_MediaPlayerEncounteredError, vlc_mediaplayer_error_callback, (void *) context);
libvlc_audio_set_callbacks(context->mp, vlc_auto_play_callback, NULL,NULL,NULL,NULL, (void *) context);
libvlc_media_player_play(context->mp);
@@ -910,10 +910,10 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p
switch_core_sprintf(context->pool, "--sout=%s", path)
};
int opts_count = 2;
if ( !handle->samplerate)
handle->samplerate = 16000;
context->samplerate = handle->samplerate;
context->channels = handle->channels;
@@ -944,14 +944,14 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p
}
if (!is_stream && switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
if (switch_file_open(&fd, realpath, SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE,
if (switch_file_open(&fd, realpath, SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE,
SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, handle->memory_pool) == SWITCH_STATUS_SUCCESS) {
switch_file_close(fd);
} else {
return SWITCH_STATUS_GENERR;
}
}
return SWITCH_STATUS_SUCCESS;
}
@@ -979,19 +979,19 @@ static switch_status_t vlc_file_av_read(switch_file_handle_t *handle, void *data
}
status = libvlc_media_get_state(vcontext->m);
if (status == libvlc_Error) {
vcontext->err = acontext->err = 1;
return SWITCH_STATUS_GENERR;
}
while (!vcontext->err && vcontext->playing == 0) {
libvlc_media_t *newmedia;
switch_mutex_lock(acontext->cond_mutex);
switch_thread_cond_wait(acontext->cond, acontext->cond_mutex);
switch_mutex_unlock(acontext->cond_mutex);
switch_mutex_lock(acontext->cond_mutex);
switch_thread_cond_wait(acontext->cond, acontext->cond_mutex);
switch_mutex_unlock(acontext->cond_mutex);
//switch_yield(50000);
@@ -1000,16 +1000,16 @@ static switch_status_t vlc_file_av_read(switch_file_handle_t *handle, void *data
if (status == 6) {
int done = 1;
newmedia = get_list_media(vcontext);
if (newmedia) {
libvlc_event_manager_t *m_event_manager;
libvlc_media_player_set_media(vcontext->mp, newmedia);
libvlc_media_release(vcontext->m);
vcontext->m = newmedia;
m_event_manager = libvlc_media_event_manager(vcontext->m);
libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_av_state_callback, (void *) acontext);
libvlc_event_attach(m_event_manager, libvlc_MediaStateChanged, vlc_media_av_state_callback, (void *) acontext);
if (libvlc_media_player_play(vcontext->mp) != -1) {
done = 0;
@@ -1040,7 +1040,7 @@ static switch_status_t vlc_file_av_read(switch_file_handle_t *handle, void *data
switch_mutex_lock(vcontext->audio_mutex);
read = switch_buffer_read(vcontext->audio_buffer, data, bytes);
switch_mutex_unlock(vcontext->audio_mutex);
status = libvlc_media_get_state(vcontext->m);
if (!read && (status == libvlc_Stopped || status == libvlc_Ended || status == libvlc_Error)) {
@@ -1078,27 +1078,27 @@ static switch_status_t vlc_file_read(switch_file_handle_t *handle, void *data, s
}
status = libvlc_media_get_state(context->m);
if (status == libvlc_Error) {
return SWITCH_STATUS_GENERR;
}
switch_mutex_lock(context->cond_mutex);
switch_mutex_lock(context->cond_mutex);
while (context->playing == 0 && status != libvlc_Ended && status != libvlc_Error) {
switch_thread_cond_wait(context->cond, context->cond_mutex);
switch_thread_cond_wait(context->cond, context->cond_mutex);
status = libvlc_media_get_state(context->m);
}
switch_mutex_lock(context->cond_mutex);
switch_mutex_lock(context->cond_mutex);
if (context->err == 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error\n");
return SWITCH_STATUS_FALSE;
}
switch_mutex_lock(context->audio_mutex);
switch_mutex_lock(context->audio_mutex);
read = switch_buffer_read(context->audio_buffer, data, bytes);
switch_mutex_unlock(context->audio_mutex);
status = libvlc_media_get_state(context->m);
if (!read && (status == libvlc_Stopped || status == libvlc_Ended || status == libvlc_Error)) {
@@ -1131,7 +1131,7 @@ static switch_status_t vlc_file_read_video(switch_file_handle_t *handle, switch_
if (vcontext->err) {
return SWITCH_STATUS_FALSE;
}
if ((flags & SVR_CHECK)) {
return SWITCH_STATUS_BREAK;
}
@@ -1146,7 +1146,7 @@ static switch_status_t vlc_file_read_video(switch_file_handle_t *handle, switch_
if (vcontext->err) {
return SWITCH_STATUS_FALSE;
}
if ((flags & SVR_BLOCK)) {
status = switch_queue_pop(vcontext->video_queue, &pop);
} else {
@@ -1196,7 +1196,7 @@ static switch_status_t vlc_file_write_video(switch_file_handle_t *handle, switch
if (frame->img) {
switch_image_t *img_copy = NULL;
vlc_frame_data_t *fdata = NULL;
switch_img_copy(frame->img, &img_copy);
switch_zmalloc(fdata, sizeof(*fdata));
@@ -1226,7 +1226,7 @@ static switch_status_t vlc_file_av_write(switch_file_handle_t *handle, void *dat
if (!vcontext) {
return SWITCH_STATUS_SUCCESS;
}
}
if (!vcontext->vid_ready) {
return SWITCH_STATUS_SUCCESS;
@@ -1249,7 +1249,7 @@ static switch_status_t vlc_file_av_write(switch_file_handle_t *handle, void *dat
if (!vcontext->playing) {
vcontext->playing = 1;
vcontext->playing = 1;
libvlc_media_player_play(vcontext->mp);
}
@@ -1268,10 +1268,10 @@ static switch_status_t vlc_file_write(switch_file_handle_t *handle, void *data,
switch_mutex_lock(context->audio_mutex);
context->samples += *len;
switch_buffer_write(context->audio_buffer, data, bytes);
switch_mutex_unlock(context->audio_mutex);
switch_mutex_unlock(context->audio_mutex);
if (!context->playing) {
context->playing = 1;
context->playing = 1;
libvlc_media_player_play(context->mp);
}
@@ -1288,13 +1288,13 @@ static switch_status_t vlc_file_av_close(switch_file_handle_t *handle)
return SWITCH_STATUS_FALSE;
}
}
vcontext->ending = 1;
if (vcontext && vcontext->video_queue) {
switch_queue_push(vcontext->video_queue, NULL);
}
if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE) && switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
if (vcontext->cond && switch_mutex_trylock(vcontext->cond_mutex) == SWITCH_STATUS_SUCCESS) {
@@ -1309,7 +1309,7 @@ static switch_status_t vlc_file_av_close(switch_file_handle_t *handle)
while((vcontext->audio_buffer && switch_buffer_inuse(vcontext->audio_buffer)) || switch_queue_size(vcontext->video_queue)) {
libvlc_state_t status = libvlc_media_get_state(vcontext->m);
if (status == libvlc_Ended || status == libvlc_Error || status == libvlc_Stopped ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "VLC done. status = %d\n", status);
break;
@@ -1346,9 +1346,9 @@ static switch_status_t vlc_file_command(switch_file_handle_t *handle, switch_fil
switch(command) {
case SCFC_FLUSH_AUDIO:
switch_mutex_lock(context->audio_mutex);
switch_mutex_lock(context->audio_mutex);
switch_buffer_zero(context->audio_buffer);
switch_mutex_unlock(context->audio_mutex);
switch_mutex_unlock(context->audio_mutex);
break;
default:
break;
@@ -1366,7 +1366,7 @@ static switch_status_t vlc_file_close(switch_file_handle_t *handle)
if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
return vlc_file_av_close(handle);
}
context->playing = 0;
libvlc_media_player_stop(context->mp);
@@ -1378,7 +1378,7 @@ static switch_status_t vlc_file_close(switch_file_handle_t *handle)
switch_mutex_unlock(context->audio_mutex);
if (context->m) libvlc_media_release(context->m);
if (context->vlc_handle) libvlc_release(context->vlc_handle);
return SWITCH_STATUS_SUCCESS;
@@ -1590,7 +1590,7 @@ SWITCH_STANDARD_APP(play_video_function)
if( context->mp ) libvlc_media_player_stop(context->mp);
if( context->m ) libvlc_media_release(context->m);
context->playing = 0;
switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "OK");
@@ -1623,30 +1623,30 @@ int vlc_write_video_imem_get_callback(void *data, const char *cookie, int64_t *
int r = 0;
if (!context->ending) {
switch_mutex_lock(context->cond_mutex);
switch_mutex_lock(context->cond_mutex);
//while (!switch_queue_size(context->video_queue)) {
// switch_yield(20000);
//}
//if (!switch_queue_size(context->video_queue)) {
// switch_thread_cond_wait(context->cond, context->cond_mutex);
// switch_thread_cond_wait(context->cond, context->cond_mutex);
//}
switch_mutex_unlock(context->cond_mutex);
switch_mutex_unlock(context->cond_mutex);
}
if (*cookie == 'v') {
switch_image_t *img = NULL;
vlc_frame_data_t *fdata = NULL;
void *pop;
if (switch_queue_trypop(context->video_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
img = (switch_image_t *) pop;
} else {
goto nada;
}
fdata = (vlc_frame_data_t *) img->user_priv;
*dts = *pts = fdata->pts;
*size = img->d_w * img->d_h * 2;
@@ -1657,7 +1657,7 @@ int vlc_write_video_imem_get_callback(void *data, const char *cookie, int64_t *
context->video_frame_buffer_len = *size;
context->video_frame_buffer = switch_core_alloc(context->pool, context->video_frame_buffer_len);
}
*output = context->video_frame_buffer;
switch_img_to_raw(img, *output, 0, SWITCH_IMG_FMT_YUY2);
switch_img_free(&img);
@@ -1667,12 +1667,12 @@ int vlc_write_video_imem_get_callback(void *data, const char *cookie, int64_t *
switch_mutex_lock(context->audio_mutex);
if (context->sync_offset < 0 && !context->sync_ready) {
uint32_t need = (context->samplerate / 1000) * abs(context->sync_offset / 1000) * context->channels * 2;
if (context->audio_frame_buffer_len < need) {
context->audio_frame_buffer_len = need;
context->audio_frame_buffer = switch_core_alloc(context->pool, context->audio_frame_buffer_len);
}
memset(context->audio_frame_buffer, 0, need);
*pts = *dts = context->pts;
*size = need;
@@ -1682,7 +1682,7 @@ int vlc_write_video_imem_get_callback(void *data, const char *cookie, int64_t *
switch_mutex_unlock(context->audio_mutex);
return 0;
}
if ((blen = switch_buffer_inuse(context->audio_buffer))) {
uint32_t read_bytes = 0;
int64_t lpts;
@@ -1751,7 +1751,7 @@ int vlc_write_video_imem_get_callback(void *data, const char *cookie, int64_t *
void vlc_write_video_imem_release_callback(void *data, const char *cookie, size_t size, void *unknown)
{
}
static switch_status_t video_read_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
@@ -1768,7 +1768,7 @@ static switch_status_t video_read_callback(switch_core_session_t *session, switc
switch_core_timer_sync(&context->timer);
fdata->pts = context->timer.samplecount;
switch_mutex_unlock(context->audio_mutex);
img_copy->user_priv = (void *) fdata;
switch_queue_push(context->video_queue, img_copy);
@@ -1847,7 +1847,7 @@ SWITCH_STANDARD_APP(capture_video_function)
switch_core_timer_init(&context->timer, "soft", 1, 1000, context->pool);
switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
switch_channel_set_flag(channel, CF_VIDEO_DECODED_READ);
switch_core_media_get_vid_params(session, &vid_params);
switch_channel_set_flag(channel, CF_VIDEO_ECHO);
switch_core_session_raw_read(session);
@@ -1878,19 +1878,19 @@ SWITCH_STANDARD_APP(capture_video_function)
"samplerate=%d:"
"channels=%d:"
"id=1:"
"caching=0",
"caching=0",
context->samplerate, context->channels);
context->m = libvlc_media_new_location(vlc_handle, imem_main);
libvlc_media_add_option_flag( context->m, imem_slave, libvlc_media_option_trusted );
libvlc_media_add_option_flag( context->m, imem_slave, libvlc_media_option_trusted );
if ( context->m == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error opening %s for writing\n", data);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return ;
}
context->mp = libvlc_media_player_new_from_media(context->m);
context->samples = 0;
@@ -1904,7 +1904,7 @@ SWITCH_STANDARD_APP(capture_video_function)
switch_channel_audio_sync(channel);
if (offset) {
context->sync_offset = offset * 1000;
}
@@ -1916,7 +1916,7 @@ SWITCH_STANDARD_APP(capture_video_function)
if (!SWITCH_READ_ACCEPTABLE(status)) {
break;
}
if (switch_test_flag(read_frame, SFF_CNG)) {
audio_data = audio_data_buf;
audio_datalen = read_impl.decoded_bytes_per_packet;
@@ -1956,18 +1956,18 @@ SWITCH_STANDARD_APP(capture_video_function)
break;
}
}
vlc_status = libvlc_media_get_state(context->m);
if (vlc_status == libvlc_Ended || vlc_status == libvlc_Error || vlc_status == libvlc_Stopped ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "VLC done. status = %d\n", vlc_status);
break;
}
}
}
switch_core_session_set_video_read_callback(session, NULL, NULL);
context->ending = 1;
if (switch_mutex_trylock(context->cond_mutex) == SWITCH_STATUS_SUCCESS) {
switch_thread_cond_signal(context->cond);
switch_mutex_unlock(context->cond_mutex);
@@ -2089,7 +2089,7 @@ static switch_status_t setup_tech_pvt(switch_core_session_t *osession, switch_co
tech_pvt->audio_datalen = SWITCH_RECOMMENDED_BUFFER_SIZE;
tech_pvt->audio_data = switch_core_session_alloc(session, tech_pvt->audio_datalen);
if (osession) {
switch_core_session_get_read_impl(osession, &tech_pvt->read_impl);
} else {
@@ -2102,7 +2102,7 @@ static switch_status_t setup_tech_pvt(switch_core_session_t *osession, switch_co
if (val) tmp = atoi(val);
if (tmp == 0) tmp = 20;
tech_pvt->read_impl.microseconds_per_packet = tmp * 1000;
tech_pvt->read_impl.iananame = "L16";
tmp = 0;
@@ -2204,7 +2204,7 @@ static switch_status_t setup_tech_pvt(switch_core_session_t *osession, switch_co
libvlc_audio_set_format(context->mp, "S16N", tech_pvt->read_impl.actual_samples_per_second, tech_pvt->read_impl.number_of_channels);
libvlc_audio_set_callbacks(context->mp, vlc_play_audio_callback, NULL,NULL,NULL,NULL, (void *) context);
libvlc_video_set_format_callbacks(context->mp, video_format_setup_callback, video_format_clean_callback);
libvlc_video_set_callbacks(context->mp, vlc_video_lock_callback, vlc_video_channel_unlock_callback, vlc_video_display_callback, context);
@@ -2280,7 +2280,7 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
void *pop;
while (switch_queue_trypop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
switch_image_t *img = (switch_image_t *) pop;
switch_image_t *img = (switch_image_t *) pop;
switch_img_free(&img);
}
}
@@ -2503,7 +2503,7 @@ static switch_status_t vlc_read_video_frame(switch_core_session_t *session, swit
switch_channel_t *channel;
vlc_private_t *tech_pvt;
void *pop;
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
@@ -2511,12 +2511,12 @@ static switch_status_t vlc_read_video_frame(switch_core_session_t *session, swit
switch_assert(tech_pvt != NULL);
switch_assert(tech_pvt->context);
switch_img_free(&tech_pvt->read_video_frame.img);
if (tech_pvt->context->video_queue) {
while(switch_queue_size(tech_pvt->context->video_queue) > 1) {
if (switch_queue_trypop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
if (switch_queue_trypop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_image_t *img = (switch_image_t *) pop;
switch_img_free(&img);
} else {
@@ -2524,9 +2524,9 @@ static switch_status_t vlc_read_video_frame(switch_core_session_t *session, swit
}
}
if (switch_queue_pop(tech_pvt->context->video_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_image_t *img = (switch_image_t *) pop;
switch_image_t *img = (switch_image_t *) pop;
if (!img) return SWITCH_STATUS_FALSE;
tech_pvt->read_video_frame.img = img;
*frame = &tech_pvt->read_video_frame;
switch_set_flag(*frame, SFF_RAW_RTP);
@@ -2612,7 +2612,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_vlc_load)
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
vlc_file_supported_formats[argc++] = "vlc";
vlc_file_supported_formats[argc++] = "mp4"; /* maybe add config for this mod to enable or disable these */
vlc_file_supported_formats[argc++] = "mov";
+5 -5
View File
@@ -1,4 +1,4 @@
/*
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
*
@@ -309,7 +309,7 @@ static switch_status_t webm_file_write(switch_file_handle_t *handle, void *data,
buf, &size, &encoded_rate, NULL);
}
if (size > 0) {
// timecode still need to figure out for sync
@@ -391,7 +391,7 @@ static switch_status_t do_write_video(switch_file_handle_t *handle, switch_frame
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%02x %02x %02x | len:%d m:%d st:%d i:%d\n", hdr[0], hdr[1], hdr[2], datalen, frame->m, start_bit, is_iframe);
if (!context->video) {
context->video_track_id = context->segment->AddVideoTrack(frame->img->d_w, frame->img->d_h, 0);
@@ -411,7 +411,7 @@ static switch_status_t do_write_video(switch_file_handle_t *handle, switch_frame
const void *data;
int duration = 0;
switch_buffer_peek_zerocopy(context->buf, &data);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VID samplecount: %u\n", context->timer.samplecount);
@@ -430,7 +430,7 @@ static switch_status_t do_write_video(switch_file_handle_t *handle, switch_frame
}
end:
return status;
}