]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add url syntax for playback
authorBrian West <brian@freeswitch.org>
Sat, 10 Mar 2007 02:36:55 +0000 (02:36 +0000)
committerBrian West <brian@freeswitch.org>
Sat, 10 Mar 2007 02:36:55 +0000 (02:36 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4501 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/include/switch_utils.h
src/switch_core.c
src/switch_ivr.c

index 0ad18ed7afbef2d90527be2c018cdeea069f7f71..4d5e2c404772427a8992ef6c08b960650fd711a9 100644 (file)
@@ -105,6 +105,8 @@ SWITCH_BEGIN_EXTERN_C
 #define SWITCH_PATH_SEPARATOR "/"
 #endif
 
+#define SWITCH_URL_SEPARATOR "://"
+
 #ifndef SWITCH_PREFIX_DIR
 #define SWITCH_PREFIX_DIR "."
 #endif
index ab58c80bb0f945ed6069b6482c058a1c6a3c10b9..8584b41c7d148d126a6abd3157a9b82129e318cb 100644 (file)
@@ -54,9 +54,9 @@ SWITCH_BEGIN_EXTERN_C
                                                  codec->implementation->microseconds_per_frame / 1000)
 
 #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
-#define switch_is_file_path(file) (*file == '/')
+#define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
 #endif
 
 /*!
index 5634d0c644258c1d392e292e9ac99a747328715b..7f55ee5e210dc6f583757d9950b4ca2c9ed561fb 100644 (file)
@@ -1019,12 +1019,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
 {
        char *ext;
        switch_status_t status;
+       char stream_name[128] = "";
+       char *rhs = NULL;
 
-       if ((ext = strrchr(file_path, '.')) == 0) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Format\n");
-               return SWITCH_STATUS_FALSE;
+       if ((rhs = strstr(file_path, SWITCH_URL_SEPARATOR))) {
+               switch_copy_string(stream_name, file_path, (rhs+1) - file_path);
+               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) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid file format [%s]!\n", ext);
index 7dbf35d57e3f6a6c2894168ba0abd102455b0b57..3e3fc121f7bacf12ef781c63c6e391a55c00f73d 100644 (file)
@@ -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");
     timer_name = switch_channel_get_variable(channel, "timer_name");
        
-       if (file) {
-        if (prefix && *file != '/' && *file != '\\' && *(file+1) != ':') {
-            char *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 (!file) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       if (!strstr(file, SWITCH_URL_SEPARATOR)) {
+               if (prefix && *file != '/' && *file != '\\' && *(file+1) != ':') {
+                       char *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, '.'))) {
                        ext++;
@@ -1135,6 +1139,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                        asis = 1;
                }
        }
+       
 
        if (!fh) {
                fh = &lfh;
@@ -1146,7 +1151,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                sample_start = fh->samples;
                fh->samples = 0;
        }
-
+       
        if (switch_core_file_open(fh,
                                                          file,
                                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,