mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-16 11:52:01 +00:00
add url syntax for playback
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4501 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
df90a1d211
commit
9263ef1f72
@ -105,6 +105,8 @@ SWITCH_BEGIN_EXTERN_C
|
|||||||
#define SWITCH_PATH_SEPARATOR "/"
|
#define SWITCH_PATH_SEPARATOR "/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SWITCH_URL_SEPARATOR "://"
|
||||||
|
|
||||||
#ifndef SWITCH_PREFIX_DIR
|
#ifndef SWITCH_PREFIX_DIR
|
||||||
#define SWITCH_PREFIX_DIR "."
|
#define SWITCH_PREFIX_DIR "."
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,9 +54,9 @@ SWITCH_BEGIN_EXTERN_C
|
|||||||
codec->implementation->microseconds_per_frame / 1000)
|
codec->implementation->microseconds_per_frame / 1000)
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define switch_is_file_path(file) (*(file +1) == ':' || *file == '/')
|
#define switch_is_file_path(file) (*(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))
|
||||||
#else
|
#else
|
||||||
#define switch_is_file_path(file) (*file == '/')
|
#define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -1019,12 +1019,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
|
|||||||
{
|
{
|
||||||
char *ext;
|
char *ext;
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
|
char stream_name[128] = "";
|
||||||
|
char *rhs = NULL;
|
||||||
|
|
||||||
if ((ext = strrchr(file_path, '.')) == 0) {
|
if ((rhs = strstr(file_path, SWITCH_URL_SEPARATOR))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
|
switch_copy_string(stream_name, file_path, (rhs+1) - file_path);
|
||||||
return SWITCH_STATUS_FALSE;
|
ext = stream_name;
|
||||||
|
file_path = rhs + 3;
|
||||||
|
} else {
|
||||||
|
if ((ext = strrchr(file_path, '.')) == 0) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
ext++;
|
||||||
}
|
}
|
||||||
ext++;
|
|
||||||
|
|
||||||
if ((fh->file_interface = switch_loadable_module_get_file_interface(ext)) == 0) {
|
if ((fh->file_interface = switch_loadable_module_get_file_interface(ext)) == 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid file format [%s]!\n", ext);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid file format [%s]!\n", ext);
|
||||||
|
@ -1112,15 +1112,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
prefix = switch_channel_get_variable(channel, "sound_prefix");
|
prefix = switch_channel_get_variable(channel, "sound_prefix");
|
||||||
timer_name = switch_channel_get_variable(channel, "timer_name");
|
timer_name = switch_channel_get_variable(channel, "timer_name");
|
||||||
|
|
||||||
if (file) {
|
if (!file) {
|
||||||
if (prefix && *file != '/' && *file != '\\' && *(file+1) != ':') {
|
return SWITCH_STATUS_FALSE;
|
||||||
char *new_file;
|
}
|
||||||
uint32_t len;
|
|
||||||
len = (uint32_t)strlen(file) + (uint32_t)strlen(prefix) + 10;
|
if (!strstr(file, SWITCH_URL_SEPARATOR)) {
|
||||||
new_file = switch_core_session_alloc(session, len);
|
if (prefix && *file != '/' && *file != '\\' && *(file+1) != ':') {
|
||||||
snprintf(new_file, len, "%s/%s", prefix, file);
|
char *new_file;
|
||||||
file = new_file;
|
uint32_t len;
|
||||||
}
|
len = (uint32_t)strlen(file) + (uint32_t)strlen(prefix) + 10;
|
||||||
|
new_file = switch_core_session_alloc(session, len);
|
||||||
|
snprintf(new_file, len, "%s/%s", prefix, file);
|
||||||
|
file = new_file;
|
||||||
|
}
|
||||||
|
|
||||||
if ((ext = strrchr(file, '.'))) {
|
if ((ext = strrchr(file, '.'))) {
|
||||||
ext++;
|
ext++;
|
||||||
@ -1136,6 +1140,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!fh) {
|
if (!fh) {
|
||||||
fh = &lfh;
|
fh = &lfh;
|
||||||
memset(fh, 0, sizeof(lfh));
|
memset(fh, 0, sizeof(lfh));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user