formats cleanup

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7384 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2008-01-27 03:14:27 +00:00
parent ab3b855841
commit 4156b6c88f
4 changed files with 4 additions and 46 deletions

View File

@ -56,6 +56,7 @@ struct local_stream_context {
int line; int line;
struct local_stream_context *next; struct local_stream_context *next;
}; };
typedef struct local_stream_context local_stream_context_t; typedef struct local_stream_context local_stream_context_t;
struct local_stream_source { struct local_stream_source {
@ -74,6 +75,7 @@ struct local_stream_source {
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
int shuffle; int shuffle;
}; };
typedef struct local_stream_source local_stream_source_t; typedef struct local_stream_source local_stream_source_t;
static unsigned int S = 0; static unsigned int S = 0;

View File

@ -69,8 +69,6 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, const
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
handle->samples = 0; handle->samples = 0;
handle->samplerate = 8000; handle->samplerate = 8000;
handle->channels = 1; handle->channels = 1;
@ -82,7 +80,6 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, const
handle->flags |= SWITCH_FILE_NATIVE; handle->flags |= SWITCH_FILE_NATIVE;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -105,7 +102,6 @@ static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsig
switch_file_seek(context->fd, whence, &samples); switch_file_seek(context->fd, whence, &samples);
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
static switch_status_t native_file_file_read(switch_file_handle_t *handle, void *data, size_t *len) static switch_status_t native_file_file_read(switch_file_handle_t *handle, void *data, size_t *len)
@ -138,7 +134,6 @@ static switch_status_t native_file_file_get_string(switch_file_handle_t *handle,
static char *supported_formats[SWITCH_MAX_CODECS] = { 0 }; static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
SWITCH_MODULE_LOAD_FUNCTION(mod_native_file_load) SWITCH_MODULE_LOAD_FUNCTION(mod_native_file_load)
{ {
switch_file_interface_t *file_interface; switch_file_interface_t *file_interface;

View File

@ -70,7 +70,6 @@ struct shout_context {
typedef struct shout_context shout_context_t; typedef struct shout_context shout_context_t;
static size_t decode_fd(shout_context_t * context, void *data, size_t bytes); static size_t decode_fd(shout_context_t * context, void *data, size_t bytes);
static inline void free_context(shout_context_t * context) static inline void free_context(shout_context_t * context)
@ -128,7 +127,6 @@ static inline void free_context(shout_context_t * context)
} }
} }
static void log_error(char const *fmt, va_list ap) static void log_error(char const *fmt, va_list ap)
{ {
char *data = NULL; char *data = NULL;
@ -287,7 +285,6 @@ static size_t decode_fd(shout_context_t * context, void *data, size_t bytes)
} while (decode_status != MP3_NEED_MORE); } while (decode_status != MP3_NEED_MORE);
if (context->audio_buffer) { if (context->audio_buffer) {
switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen); switch_buffer_write(context->audio_buffer, context->decode_buf, usedlen);
} else { } else {
@ -311,7 +308,6 @@ static size_t decode_fd(shout_context_t * context, void *data, size_t bytes)
context->err++; context->err++;
switch_mutex_unlock(context->audio_mutex); switch_mutex_unlock(context->audio_mutex);
return 0; return 0;
} }
#define error_check() if (context->err) goto error; #define error_check() if (context->err) goto error;
@ -424,7 +420,6 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data)
context->err++; context->err++;
switch_mutex_unlock(context->audio_mutex); switch_mutex_unlock(context->audio_mutex);
return 0; return 0;
} }
@ -804,7 +799,6 @@ static switch_status_t shout_file_write(switch_file_handle_t *handle, void *data
int16_t *audio = data; int16_t *audio = data;
int nsamples = *len; int nsamples = *len;
if (context->shout && !context->shout_init) { if (context->shout && !context->shout_init) {
context->shout_init++; context->shout_init++;
if (shout_open(context->shout) != SHOUTERR_SUCCESS) { if (shout_open(context->shout) != SHOUTERR_SUCCESS) {
@ -941,7 +935,6 @@ static switch_status_t shout_file_get_string(switch_file_handle_t *handle, switc
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
static switch_bool_t telecast_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type) static switch_bool_t telecast_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
{ {
switch_buffer_t *buffer = (switch_buffer_t *) user_data; switch_buffer_t *buffer = (switch_buffer_t *) user_data;
@ -993,7 +986,6 @@ static int web_callback(void *pArg, int argc, char **argv, char **columnNames)
char title_aft[128*3] = ""; char title_aft[128*3] = "";
char *mp3, *m3u; char *mp3, *m3u;
/* /*
0 uuid VARCHAR(255), 0 uuid VARCHAR(255),
1 created VARCHAR(255), 1 created VARCHAR(255),
@ -1011,8 +1003,6 @@ static int web_callback(void *pArg, int argc, char **argv, char **columnNames)
13 write_rate VARCHAR(255) 13 write_rate VARCHAR(255)
*/ */
holder->stream->write_function(holder->stream, holder->stream->write_function(holder->stream,
"<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>", "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>",
argv[1], argv[4], argv[5], argv[7], argv[8] ? argv[8] : "N/A", argv[9] ? argv[9] : "N/A", argv[10], argv[11]); argv[1], argv[4], argv[5], argv[7], argv[8] ? argv[8] : "N/A", argv[9] ? argv[9] : "N/A", argv[10], argv[11]);
@ -1031,7 +1021,6 @@ static int web_callback(void *pArg, int argc, char **argv, char **columnNames)
return 0; return 0;
} }
void do_telecast(switch_stream_handle_t *stream) void do_telecast(switch_stream_handle_t *stream)
{ {
char *path_info = switch_event_get_header(stream->event, "http-path-info"); char *path_info = switch_event_get_header(stream->event, "http-path-info");
@ -1047,7 +1036,6 @@ void do_telecast(switch_stream_handle_t *stream)
char *ref = switch_event_get_header(stream->event, "http-referer"); char *ref = switch_event_get_header(stream->event, "http-referer");
stream->write_function(stream,"Content-type: text/html\r\n\r\n<h2>Not Found!</h2>\n" stream->write_function(stream,"Content-type: text/html\r\n\r\n<h2>Not Found!</h2>\n"
"<META http-equiv=\"refresh\" content=\"1;URL=%s\">", ref); "<META http-equiv=\"refresh\" content=\"1;URL=%s\">", ref);
} else { } else {
switch_media_bug_t *bug = NULL; switch_media_bug_t *bug = NULL;
switch_buffer_t *buffer; switch_buffer_t *buffer;
@ -1056,7 +1044,6 @@ void do_telecast(switch_stream_handle_t *stream)
lame_global_flags *gfp = NULL; lame_global_flags *gfp = NULL;
switch_codec_t *read_codec; switch_codec_t *read_codec;
if (!(gfp = lame_init())) { if (!(gfp = lame_init())) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate lame\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate lame\n");
goto end; goto end;
@ -1108,7 +1095,6 @@ void do_telecast(switch_stream_handle_t *stream)
memset(buf, 0, bytes); memset(buf, 0, bytes);
} }
if ((rlen = lame_encode_buffer(gfp, (void *)buf, NULL, bytes / 2, mp3buf, sizeof(mp3buf))) < 0) { if ((rlen = lame_encode_buffer(gfp, (void *)buf, NULL, bytes / 2, mp3buf, sizeof(mp3buf))) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
goto end; goto end;
@ -1122,7 +1108,6 @@ void do_telecast(switch_stream_handle_t *stream)
} }
} }
end: end:
switch_safe_free(uuid); switch_safe_free(uuid);
@ -1142,10 +1127,8 @@ void do_telecast(switch_stream_handle_t *stream)
switch_core_session_rwunlock(tsession); switch_core_session_rwunlock(tsession);
} }
} }
void do_broadcast(switch_stream_handle_t *stream) void do_broadcast(switch_stream_handle_t *stream)
{ {
char *path_info = switch_event_get_header(stream->event, "http-path-info"); char *path_info = switch_event_get_header(stream->event, "http-path-info");
@ -1204,7 +1187,6 @@ void do_broadcast(switch_stream_handle_t *stream)
"Content-Disposition: inline; filename=\"%s.mp3\"\r\n\r\n", "Content-Disposition: inline; filename=\"%s.mp3\"\r\n\r\n",
path_info + 7); path_info + 7);
if (fh.interval) { if (fh.interval) {
interval = fh.interval * 1000; interval = fh.interval * 1000;
} }
@ -1233,11 +1215,8 @@ void do_broadcast(switch_stream_handle_t *stream)
goto end; goto end;
} }
} }
} }
while ((rlen = lame_encode_flush(gfp, mp3buf, sizeof(mp3buf))) > 0) { while ((rlen = lame_encode_flush(gfp, mp3buf, sizeof(mp3buf))) > 0) {
if (stream->raw_write_function(stream, mp3buf, rlen)) { if (stream->raw_write_function(stream, mp3buf, rlen)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Disconnected\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Disconnected\n");
@ -1245,7 +1224,6 @@ void do_broadcast(switch_stream_handle_t *stream)
} }
} }
end: end:
if (fh.channels) { if (fh.channels) {
@ -1258,10 +1236,8 @@ void do_broadcast(switch_stream_handle_t *stream)
lame_close(gfp); lame_close(gfp);
gfp = NULL; gfp = NULL;
} }
} }
void do_index(switch_stream_handle_t *stream) void do_index(switch_stream_handle_t *stream)
{ {
switch_core_db_t *db = switch_core_db_handle(); switch_core_db_t *db = switch_core_db_handle();
@ -1275,8 +1251,6 @@ void do_index(switch_stream_handle_t *stream)
holder.stream = stream; holder.stream = stream;
stream->write_function(stream, "Content-type: text/html\r\n\r\n"); stream->write_function(stream, "Content-type: text/html\r\n\r\n");
stream->write_function(stream, stream->write_function(stream,
"<table align=center border=1 cellpadding=6 cellspacing=0>" "<table align=center border=1 cellpadding=6 cellspacing=0>"
"<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
@ -1295,13 +1269,11 @@ void do_index(switch_stream_handle_t *stream)
} }
#define TELECAST_SYNTAX "" #define TELECAST_SYNTAX ""
SWITCH_STANDARD_API(telecast_api_function) SWITCH_STANDARD_API(telecast_api_function)
{ {
char *host = NULL, *port = NULL, *uri = NULL, *path_info = NULL; char *host = NULL, *port = NULL, *uri = NULL, *path_info = NULL;
if (session) {
if (session) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
@ -1369,8 +1341,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load)
file_interface->file_set_string = shout_file_set_string; file_interface->file_set_string = shout_file_set_string;
file_interface->file_get_string = shout_file_get_string; file_interface->file_get_string = shout_file_get_string;
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */
//*module_interface = &shout_module_interface; //*module_interface = &shout_module_interface;
@ -1383,7 +1353,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_shout_shutdown) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_shout_shutdown)
{ {
curl_global_cleanup(); curl_global_cleanup();

View File

@ -71,7 +71,6 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
} }
ext++; ext++;
if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) { if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {
mode += SFM_READ; mode += SFM_READ;
} }
@ -178,13 +177,11 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
handle->speed = 0; handle->speed = 0;
handle->private_info = context; handle->private_info = context;
end: end:
switch_safe_free(alt_path); switch_safe_free(alt_path);
switch_safe_free(ldup); switch_safe_free(ldup);
return status; return status;
} }
@ -210,7 +207,6 @@ static switch_status_t sndfile_file_seek(switch_file_handle_t *handle, unsigned
handle->pos = *cur_sample; handle->pos = *cur_sample;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status_t sndfile_file_read(switch_file_handle_t *handle, void *data, size_t *len) static switch_status_t sndfile_file_read(switch_file_handle_t *handle, void *data, size_t *len)
@ -302,7 +298,6 @@ static switch_status_t setup_formats(void)
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "\nLibSndFile Version : %s Supported Formats\n", buffer); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "\nLibSndFile Version : %s Supported Formats\n", buffer);
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "================================================================================\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO, "================================================================================\n");
sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof(int)); sf_command(NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof(int));
@ -355,14 +350,11 @@ static switch_status_t setup_formats(void)
} }
*/ */
} }
} }
for (m = 0; m < exlen; m++) { for (m = 0; m < exlen; m++) {
supported_formats[len++] = extras[m]; supported_formats[len++] = extras[m];
} }
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_NOTICE, "================================================================================\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_NOTICE, "================================================================================\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;