mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-30 07:04:17 +00:00
FS-7505: clean up and support multiple formats to same extensions {modname=mod_vlc}rtmp://foo.com/flvplayback also move [/tmp]file to be {spool_path=/tmp}
This commit is contained in:
1 parent
13e60c420d
commit
52d15f6398
9 files changed
+292
-173
No files matched your search
+73
-25
@@ -80,22 +80,83 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
||||
switch_set_flag(fh, SWITCH_FILE_FLAG_FREE_POOL);
|
||||
}
|
||||
|
||||
fh->mm.samplerate = 44100;
|
||||
fh->mm.channels = 1;
|
||||
fh->mm.keyint = 60;
|
||||
fh->mm.ab = 128;
|
||||
|
||||
if (*file_path == '{') {
|
||||
char *timeout;
|
||||
char *new_fp;
|
||||
char *modname;
|
||||
const char *val;
|
||||
int tmp;
|
||||
|
||||
fp = switch_core_strdup(fh->memory_pool, file_path);
|
||||
|
||||
if (switch_event_create_brackets(fp, '{', '}', ',', &fh->params, &new_fp, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((timeout = switch_event_get_header(fh->params, "timeout"))) {
|
||||
if ((to = atoi(timeout)) < 1) {
|
||||
to = 0;
|
||||
}
|
||||
while (*fp == '{') {
|
||||
char *parsed = NULL;
|
||||
|
||||
if (switch_event_create_brackets(fp, '{', '}', ',', &fh->params, &parsed, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS || !parsed) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
new_fp = fp;
|
||||
|
||||
fp = parsed;
|
||||
}
|
||||
|
||||
file_path = new_fp;
|
||||
file_path = fp;
|
||||
|
||||
if ((timeout = switch_event_get_header(fh->params, "timeout"))) {
|
||||
if ((to = atoi(timeout)) < 1) {
|
||||
to = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((modname = switch_event_get_header(fh->params, "modname"))) {
|
||||
fh->modname = switch_core_strdup(fh->memory_pool, modname);
|
||||
}
|
||||
|
||||
if ((val = switch_event_get_header(fh->params, "samplerate"))) {
|
||||
tmp = atoi(val);
|
||||
if (tmp > 8000) {
|
||||
fh->mm.samplerate = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if ((val = switch_event_get_header(fh->params, "channels"))) {
|
||||
tmp = atoi(val);
|
||||
if (tmp == 1 || tmp == 2) {
|
||||
fh->mm.channels = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if ((val = switch_event_get_header(fh->params, "ab"))) {
|
||||
tmp = atoi(val);
|
||||
if (tmp > 16) {
|
||||
fh->mm.ab = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if ((val = switch_event_get_header(fh->params, "vw"))) {
|
||||
tmp = atoi(val);
|
||||
if (tmp > 0) {
|
||||
fh->mm.vw = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if ((val = switch_event_get_header(fh->params, "vh"))) {
|
||||
tmp = atoi(val);
|
||||
if (tmp > 0) {
|
||||
fh->mm.vh = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if ((val = switch_event_get_header(fh->params, "fps"))) {
|
||||
float ftmp = atof(val);
|
||||
if (ftmp > 0.0f) {
|
||||
fh->mm.fps = ftmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_directory_exists(file_path, fh->memory_pool) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -114,26 +175,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
||||
} else {
|
||||
if ((flags & SWITCH_FILE_FLAG_WRITE)) {
|
||||
|
||||
char *p, *e;
|
||||
|
||||
fh->file_path = switch_core_strdup(fh->memory_pool, file_path);
|
||||
p = fh->file_path;
|
||||
|
||||
if (*p == '[' && *(p + 1) == *SWITCH_PATH_SEPARATOR) {
|
||||
e = switch_find_end_paren(p, '[', ']');
|
||||
|
||||
if (e) {
|
||||
*e = '\0';
|
||||
spool_path = p + 1;
|
||||
fh->file_path = e + 1;
|
||||
}
|
||||
if (fh->params) {
|
||||
spool_path = switch_event_get_header(fh->params, "spool_path");
|
||||
}
|
||||
|
||||
if (!spool_path) {
|
||||
spool_path = switch_core_get_variable_pdup(SWITCH_AUDIO_SPOOL_PATH_VARIABLE, fh->memory_pool);
|
||||
}
|
||||
|
||||
file_path = fh->file_path;
|
||||
}
|
||||
|
||||
if ((ext = strrchr(file_path, '.')) == 0) {
|
||||
@@ -146,7 +194,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
||||
|
||||
|
||||
|
||||
if ((fh->file_interface = switch_loadable_module_get_file_interface(ext)) == 0) {
|
||||
if ((fh->file_interface = switch_loadable_module_get_file_interface(ext, fh->modname)) == 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid file format [%s] for [%s]!\n", ext, file_path);
|
||||
switch_goto_status(SWITCH_STATUS_GENERR, fail);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user