]> git.sesse.net Git - vlc/commitdiff
demux: provide both URL and file path as with access
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 7 Jul 2010 18:52:10 +0000 (21:52 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 7 Jul 2010 18:58:31 +0000 (21:58 +0300)
This commit may eat your domestic pets.

27 files changed:
include/vlc_demux.h
modules/access/alsa.c
modules/access/bd/bd.c
modules/access/dc1394.c
modules/access/dvdnav.c
modules/access/dvdread.c
modules/access/imem.c
modules/access/jack.c
modules/access/oss.c
modules/access/rtp/rtp.c
modules/access/screen/xcb.c
modules/access/v4l.c
modules/access/v4l2.c
modules/demux/avformat/demux.c
modules/demux/gme.cpp
modules/demux/live555.cpp
modules/demux/mkv/mkv.cpp
modules/demux/mod.c
modules/demux/mp4/mp4.c
modules/demux/playlist/ifo.c
modules/demux/playlist/playlist.c
modules/demux/rawvid.c
modules/demux/vobsub.c
modules/meta_engine/taglib.cpp
modules/misc/dummy/input.c
modules/misc/lua/demux.c
src/input/demux.c

index 24b422ea6033abd4952316670597abe4d5e2a7b6..c3f32e599d33b2f3893443d032b3631ad3374d26 100644 (file)
@@ -48,7 +48,8 @@ struct demux_t
     /* eg informative but needed (we can have access+demux) */
     char        *psz_access;
     char        *psz_demux;
-    char        *psz_path;
+    char        *psz_location;
+    char        *psz_file;
 
     /* input stream */
     stream_t    *s;     /* NULL in case of a access+demux in one */
@@ -169,7 +170,10 @@ VLC_EXPORT( int,       demux_vaControlHelper, ( stream_t *, int64_t i_start, int
 LIBVLC_USED
 static inline bool demux_IsPathExtension( demux_t *p_demux, const char *psz_extension )
 {
-    const char *psz_ext = strrchr ( p_demux->psz_path, '.' );
+    if( !p_demux->psz_file )
+        return false;
+
+    const char *psz_ext = strrchr ( p_demux->psz_file, '.' );
     if( !psz_ext || strcasecmp( psz_ext, psz_extension ) )
         return false;
     return true;
index 08a661eb7c54c294f7062b9abb0f62a6ec8da716..54085ad6c2e3c7a1ccc16e7657f158a8b6978983 100644 (file)
@@ -255,14 +255,14 @@ static int DemuxOpen( vlc_object_t *p_this )
     p_sys->i_next_demux_date = -1;
 
     const char *psz_device = NULL;
-    if( p_demux->psz_path && *p_demux->psz_path )
-        psz_device = p_demux->psz_path;
+    if( p_demux->psz_location && *p_demux->psz_location )
+        psz_device = p_demux->psz_location;
     else
         ListAvailableDevices( p_demux, false );
 
     if( FindMainDevice( p_demux, psz_device ) != VLC_SUCCESS )
     {
-        if( p_demux->psz_path && *p_demux->psz_path )
+        if( p_demux->psz_location && *p_demux->psz_location )
             ListAvailableDevices( p_demux, false );
         DemuxClose( p_this );
         return VLC_EGENERIC;
index ec85e83244f56993270dce7d983a34f11ce37933..cdb169f4835eed79dd91d21a3bdc75f4a29c0e83 100644 (file)
@@ -152,6 +152,8 @@ static int Open( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
+    if( p_demux->psz_file == NULL )
+        return VLC_EGENERIC;
     if( *p_demux->psz_access &&
         strcmp( p_demux->psz_access, "bd" ) &&
         strcmp( p_demux->psz_access, "file" ) )
@@ -159,7 +161,7 @@ static int Open( vlc_object_t *p_this )
 
     /* */
     bool b_shortname;
-    char *psz_base = FindPathBase( p_demux->psz_path, &b_shortname );
+    char *psz_base = FindPathBase( p_demux->psz_file, &b_shortname );
     if( !psz_base )
         return VLC_EGENERIC;
 
index 0bf9a0eef49a6933edaffc98c104b2735e0f0321..853135346ead6c7a0270910db92b306115362022 100644 (file)
@@ -232,7 +232,7 @@ static int Open( vlc_object_t *p_this )
     {
         msg_Err( p_demux, "Bad MRL, please check the option line "
                           "(MRL was: %s)",
-                          p_demux->psz_path );
+                          p_demux->psz_location );
         free( p_sys );
         return VLC_EGENERIC;
     }
@@ -715,7 +715,7 @@ static int process_options( demux_t *p_demux )
     const char *in_fmt = NULL;
     float rate_f;
 
-    psz_dup = strdup( p_demux->psz_path );
+    psz_dup = strdup( p_demux->psz_location );
     psz_parser = psz_dup;
     for( token = strtok_r( psz_parser,":",&state); token;
          token = strtok_r( NULL, ":", &state ) )
index 91fffcd10be7b3aa0ae8cc973becd7e201500f50..4175e89ab36761e98a79bff32fd685498a5a932e 100644 (file)
@@ -189,7 +189,7 @@ static int Open( vlc_object_t *p_this )
     char        *psz_name;
     char        *psz_code;
 
-    if( !p_demux->psz_path || !*p_demux->psz_path )
+    if( !p_demux->psz_file || !*p_demux->psz_file )
     {
         /* Only when selected */
         if( !p_demux->psz_access || !*p_demux->psz_access )
@@ -202,7 +202,7 @@ static int Open( vlc_object_t *p_this )
         }
     }
     else
-        psz_name = ToLocaleDup( p_demux->psz_path );
+        psz_name = ToLocaleDup( p_demux->psz_file );
 
 #ifdef WIN32
     /* Remove trailing backslash, otherwise dvdnav_open will fail */
index 22919798fd9e2326eadb55f3033be405a64b4172..95e680129d468e2abc9d12de58d0a85c5d58acdb 100644 (file)
@@ -176,7 +176,7 @@ static int Open( vlc_object_t *p_this )
     dvd_reader_t *p_dvdread;
     ifo_handle_t *p_vmg_file;
 
-    if( !p_demux->psz_path || !*p_demux->psz_path )
+    if( !p_demux->psz_file || !*p_demux->psz_file )
     {
         /* Only when selected */
         if( !p_demux->psz_access || !*p_demux->psz_access )
@@ -189,7 +189,7 @@ static int Open( vlc_object_t *p_this )
         }
     }
     else
-        psz_name = ToLocaleDup( p_demux->psz_path );
+        psz_name = ToLocaleDup( p_demux->psz_file );
 
 #ifdef WIN32
     if( psz_name[0] && psz_name[1] == ':' &&
index e924097af37e290fb7f1b6bb7522f8440729fb34..962683177ff24fc2c3c8f0dace1b9fb9ca308fa0 100644 (file)
@@ -404,7 +404,7 @@ static int OpenDemux(vlc_object_t *object)
     demux_t    *demux = (demux_t *)object;
     imem_sys_t *sys;
 
-    if (OpenCommon(object, &sys, demux->psz_path))
+    if (OpenCommon(object, &sys, demux->psz_location))
         return VLC_EGENERIC;
 
     /* ES format */
index 963bbb72fa576fb458397bcb3d29a4ef7cb6e9e9..70c2c061a7744caadd6b00440620691ed81a6540 100644 (file)
@@ -562,7 +562,7 @@ static void Port_finder( demux_t *p_demux )
 static void Parse( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
-    char *psz_dup = strdup( p_demux->psz_path );
+    char *psz_dup = strdup( p_demux->psz_location );
     char *psz_parser = psz_dup;
 
     if( !strncmp( psz_parser, "channels=", strlen( "channels=" ) ) )
index 60af003ade2b8156a37d073648494924d284e9b4..3fe0b7c7ffc0bd688376e854933d1f6b5cc1cc3f 100644 (file)
@@ -178,8 +178,8 @@ static int DemuxOpen( vlc_object_t *p_this )
     p_sys->p_block = NULL;
     p_sys->i_next_demux_date = -1;
 
-    if( p_demux->psz_path && *p_demux->psz_path )
-        p_sys->psz_device = p_demux->psz_path;
+    if( p_demux->psz_location && *p_demux->psz_location )
+        p_sys->psz_device = p_demux->psz_location;
     else
         p_sys->psz_device = OSS_DEFAULT;
 
index cf848686dc476e52cd343e11128e9c1d73ad97a2..32e13b3c109fe04a8f036e480faebc457d284037 100644 (file)
@@ -165,7 +165,7 @@ static int Open (vlc_object_t *obj)
     else
         return VLC_EGENERIC;
 
-    char *tmp = strdup (demux->psz_path);
+    char *tmp = strdup (demux->psz_location);
     if (tmp == NULL)
         return VLC_ENOMEM;
 
index 1c76412cbc81642785fb93a483aa93e60dc389f9..6cc32afe0d7a461e36938e6e38657c0727992baa 100644 (file)
@@ -170,10 +170,10 @@ static int Open (vlc_object_t *obj)
     if (!strcmp (demux->psz_access, "window"))
     {
         char *end;
-        unsigned long ul = strtoul (demux->psz_path, &end, 0);
+        unsigned long ul = strtoul (demux->psz_location, &end, 0);
         if (*end || ul > 0xffffffff)
         {
-            msg_Err (obj, "bad X11 drawable %s", demux->psz_path);
+            msg_Err (obj, "bad X11 drawable %s", demux->psz_location);
             goto error;
         }
         p_sys->window = ul;
index 28c1a008425cd7a76b16905eab6fca362e6faa4a..995afc0b316c5ddc6eb71879630bd533b48cb4de 100644 (file)
@@ -488,7 +488,7 @@ static void ParseMRL( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    char *psz_dup = strdup( p_demux->psz_path );
+    char *psz_dup = strdup( p_demux->psz_location );
     char *psz_parser = psz_dup;
 
     while( *psz_parser && *psz_parser != ':' )
index 6412f5640044fc88115c2ef1a0f573c44d766a01..a20b79dc9f82b8089c8a03bf581a2ba412d21387 100644 (file)
@@ -681,7 +681,7 @@ static int DemuxOpen( vlc_object_t *p_this )
 
     GetV4L2Params(p_sys, (vlc_object_t *) p_demux);
 
-    ParseMRL( p_sys, p_demux->psz_path, (vlc_object_t *) p_demux );
+    ParseMRL( p_sys, p_demux->psz_location, (vlc_object_t *) p_demux );
 
 #ifdef HAVE_LIBV4L2
     if( !var_InheritBool( p_this, CFG_PREFIX "use-libv4l2" ) )
index 757f353d22d10ade42cd4188bff2b20447927d74..328cc423b25c7732b5bb8a99f2e6bbe272c84c74 100644 (file)
@@ -119,7 +119,7 @@ int OpenDemux( vlc_object_t *p_this )
     bool          b_can_seek;
 
     /* Init Probe data */
-    pd.filename = p_demux->psz_path;
+    pd.filename = p_demux->psz_file;
     if( ( pd.buf_size = stream_Peek( p_demux->s, &pd.buf, 2048 + 213 ) ) <= 0 )
     {
         msg_Warn( p_demux, "cannot peek" );
@@ -155,14 +155,14 @@ int OpenDemux( vlc_object_t *p_this )
     {
         int i_len;
 
-        if( !p_demux->psz_path ) return VLC_EGENERIC;
+        if( !p_demux->psz_file ) return VLC_EGENERIC;
 
-        i_len = strlen( p_demux->psz_path );
+        i_len = strlen( p_demux->psz_file );
         if( i_len < 4 ) return VLC_EGENERIC;
 
-        if( strcasecmp( &p_demux->psz_path[i_len - 4], ".str" ) &&
-            strcasecmp( &p_demux->psz_path[i_len - 4], ".xai" ) &&
-            strcasecmp( &p_demux->psz_path[i_len - 3], ".xa" ) )
+        if( strcasecmp( &p_demux->psz_file[i_len - 4], ".str" ) &&
+            strcasecmp( &p_demux->psz_file[i_len - 4], ".xai" ) &&
+            strcasecmp( &p_demux->psz_file[i_len - 3], ".xa" ) )
         {
             return VLC_EGENERIC;
         }
@@ -214,7 +214,7 @@ int OpenDemux( vlc_object_t *p_this )
 
 
     /* Open it */
-    if( av_open_input_stream( &p_sys->ic, &p_sys->io, p_demux->psz_path,
+    if( av_open_input_stream( &p_sys->ic, &p_sys->io, p_demux->psz_file,
                               p_sys->fmt, NULL ) )
     {
         msg_Err( p_demux, "av_open_input_stream failed" );
index f5efb043b1d72f98b0b9cd1abea1227c1f382374..dcd213f73ebece167e5aad257bb6798e2f89542a 100644 (file)
@@ -121,7 +121,8 @@ static int Open( vlc_object_t *p_this )
     /* We accept file based on extention match */
     if( !p_demux->b_force )
     {
-        if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL ||
+        if( p_demux->psz_file == NULL
+         || ( ext = strrchr( p_demux->psz_file, '.' ) ) == NULL ||
             stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC;
 
         ext++;  /* skip . */
index 79ac789846d8aeaa5881e45254930422b3dad346..e513f5da3667c4c73c27a26bf380011039ef1e2e 100644 (file)
@@ -297,7 +297,7 @@ static int  Open ( vlc_object_t *p_this )
     p_sys->b_timeout_call = false;
     p_sys->b_multicast = false;
     p_sys->b_real = false;
-    p_sys->psz_path = strdup( p_demux->psz_path );
+    p_sys->psz_path = strdup( p_demux->psz_location );
     p_sys->b_force_mcast = var_CreateGetBool( p_demux, "rtsp-mcast" );
     p_sys->b_get_param = false;
     p_sys->b_paused = false;
index b797feb90499cb3ca419b23fec42af5116105175..7dec8d7676d93adb7545c5f39216a63ee9642251 100644 (file)
@@ -141,11 +141,11 @@ static int Open( vlc_object_t * p_this )
     if (var_InheritBool( p_demux, "mkv-preload-local-dir" ))
     {
         /* get the files from the same dir from the same family (based on p_demux->psz_path) */
-        if (p_demux->psz_path[0] != '\0' && !strcmp(p_demux->psz_access, ""))
+        if (p_demux->psz_file && !strcmp(p_demux->psz_access, ""))
         {
             // assume it's a regular file
             // get the directory path
-            s_path = p_demux->psz_path;
+            s_path = p_demux->psz_file;
             if (s_path.at(s_path.length() - 1) == DIR_SEP_CHAR)
             {
                 s_path = s_path.substr(0,s_path.length()-1);
@@ -170,9 +170,9 @@ static int Open( vlc_object_t * p_this )
                         s_filename = s_path + DIR_SEP_CHAR + psz_file;
 
 #ifdef WIN32
-                        if (!strcasecmp(s_filename.c_str(), p_demux->psz_path))
+                        if (!strcasecmp(s_filename.c_str(), p_demux->psz_file))
 #else
-                        if (!s_filename.compare(p_demux->psz_path))
+                        if (!s_filename.compare(p_demux->psz_file))
 #endif
                         {
                             free (psz_file);
index 37deaa496a059b230b99705121868e255dc6d837..b7817a4f87cef1d9a5f33988c723fae7fc2f5ad1 100644 (file)
@@ -149,7 +149,9 @@ static int Open( vlc_object_t *p_this )
     /* We accept file based on extension match */
     if( !p_demux->b_force )
     {
-        const char *psz_ext = strrchr( p_demux->psz_path, '.' );
+        if( !p_demux->psz_file )
+            return VLC_EGENERIC;
+        const char *psz_ext = strrchr( p_demux->psz_file, '.' );
         int i;
 
         if( !psz_ext )
index bd84188f614060b086820dc62395289514741e2e..21d73d7752b67cad573efdb9073136bd70702fa9 100644 (file)
@@ -402,7 +402,7 @@ static int Open( vlc_object_t * p_this )
                 else
                 {
                     char *psz_absolute;
-                    char *psz_path = strdup( p_demux->psz_path );
+                    char *psz_path = strdup( p_demux->psz_location );
                     char *end = strrchr( psz_path, '/' );
                     if( end ) end[1] = '\0';
                     else *psz_path = '\0';
index 54d29db9dd48790dcde3259038a19b0f0a403eec..b62fcfd7250ee10da2bed90b1d36a1c767bdfb16 100644 (file)
@@ -47,9 +47,12 @@ int Import_IFO( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
-    size_t len = strlen( p_demux->psz_path );
+    if( !p_demux->psz_file )
+        return VLC_EGENERIC;
+
+    size_t len = strlen( p_demux->psz_file );
 
-    char *psz_file = p_demux->psz_path + len - strlen( "VIDEO_TS.IFO" );
+    char *psz_file = p_demux->psz_file + len - strlen( "VIDEO_TS.IFO" );
     /* Valid filenames are :
      *  - VIDEO_TS.IFO
      *  - VTS_XX_X.IFO where X are digits
@@ -69,7 +72,7 @@ int Import_IFO( vlc_object_t *p_this )
         p_demux->pf_demux = Demux;
     }
     /* Valid filename for DVD-VR is VR_MANGR.IFO */
-    else if( len >= 12 && !strcmp( &p_demux->psz_path[len-12], "VR_MANGR.IFO" ) )
+    else if( len >= 12 && !strcmp( &p_demux->psz_file[len-12], "VR_MANGR.IFO" ) )
     {
         int i_peek;
         const uint8_t *p_peek;
@@ -99,14 +102,14 @@ void Close_IFO( vlc_object_t *p_this )
 
 static int Demux( demux_t *p_demux )
 {
-    size_t len = strlen( "dvd://" ) + strlen( p_demux->psz_path )
+    size_t len = strlen( "dvd://" ) + strlen( p_demux->psz_file )
                - strlen( "VIDEO_TS.IFO" );
     char *psz_url;
 
     psz_url = malloc( len+1 );
     if( !psz_url )
         return 0;
-    snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_path );
+    snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_file );
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
     input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
@@ -121,7 +124,7 @@ static int Demux( demux_t *p_demux )
 
 static int DemuxDVD_VR( demux_t *p_demux )
 {
-    char *psz_url = strdup( p_demux->psz_path );
+    char *psz_url = strdup( p_demux->psz_file );
 
     if( !psz_url )
         return 0;
index 94536f3553946ce8ea70c217c553a5f3cd656818..55ae96f465fa2fca2ff655f4b5f9688a7ec5b362 100644 (file)
@@ -172,12 +172,12 @@ char *FindPrefix( demux_t *p_demux )
     char *psz_path;
     if( p_demux->psz_access )
     {
-        if( asprintf( &psz_path,"%s://%s", p_demux->psz_access, p_demux->psz_path ) == -1 )
+        if( asprintf( &psz_path,"%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
             return NULL;
     }
     else
     {
-        psz_path = strdup( p_demux->psz_path );
+        psz_path = strdup( p_demux->psz_location );
         if( psz_path == NULL )
             return NULL;
     }
index 120c9e391ab77d7cbf9652d127641460c9a2b882..fbc1bf40864584aa71a5b6c4880940b793bd2b1d 100644 (file)
@@ -130,13 +130,11 @@ static int Open( vlc_object_t * p_this )
     demux_sys_t *p_sys;
     int i_width=-1, i_height=-1;
     unsigned u_fps_num=0, u_fps_den=1;
-    char *psz_ext;
     vlc_fourcc_t i_chroma;
     unsigned int i_sar_num = 0;
     unsigned int i_sar_den = 0;
     const struct preset_t *p_preset = NULL;
     const uint8_t *p_peek;
-    bool b_valid = false;
     bool b_y4m = false;
 
     if( stream_Peek( p_demux->s, &p_peek, 9 ) == 9 )
@@ -144,29 +142,33 @@ static int Open( vlc_object_t * p_this )
         /* http://wiki.multimedia.cx/index.php?title=YUV4MPEG2 */
         if( !strncmp( (char *)p_peek, "YUV4MPEG2", 9 ) )
         {
-            b_valid = true;
             b_y4m = true;
+            goto valid;
         }
     }
 
-    /* guess preset based on file extension */
-    psz_ext = strrchr( p_demux->psz_path, '.' );
-    if( psz_ext )
+    if( !p_demux->b_force )
     {
+        /* guess preset based on file extension */
+        if( !p_demux->psz_file )
+            return VLC_EGENERIC;
+
+        const char *psz_ext = strrchr( p_demux->psz_file, '.' );
+        if( !psz_ext )
+            return VLC_EGENERIC;
         psz_ext++;
-        for( int i = 0; p_presets[i].psz_ext ; i++ )
+
+        for( unsigned i = 0; p_presets[i].psz_ext ; i++ )
         {
             if( !strcasecmp( psz_ext, p_presets[i].psz_ext ) )
             {
                 p_preset = &p_presets[i];
-                b_valid = true;
-                break;
+                goto valid;
             }
         }
-    }
-    if( !b_valid && !p_demux->b_force )
         return VLC_EGENERIC;
-
+    }
+valid:
     /* Set p_input field */
     p_demux->pf_demux   = Demux;
     p_demux->pf_control = Control;
index f8283db8d7854bc2c67f6f6aba3566274bf7b6cd..208284217b5f22acf404ce2dd61c3a34f2b7029f 100644 (file)
@@ -188,7 +188,8 @@ static int Open ( vlc_object_t *p_this )
         }
     }
 
-    if( asprintf( &psz_vobname, "%s://%s", p_demux->psz_access, p_demux->psz_path ) == -1 )
+    if( asprintf( &psz_vobname, "%s://%s", p_demux->psz_access,
+                  p_demux->psz_location ) == -1 )
     {
         free( p_sys );
         return VLC_EGENERIC;
index 4ededfdab235a1fa28a574a5c3342178e53044a7..973e42ef0a19d8b3011f84bbd2712c6c5a89500e 100644 (file)
@@ -356,14 +356,14 @@ static int ReadMeta( vlc_object_t* p_this)
     demux_t*        p_demux = p_demux_meta->p_demux;
     vlc_meta_t*     p_meta;
     FileRef f;
-    char *psz_path = decode_URI_duplicate( p_demux->psz_path );
 
     p_demux_meta->p_meta = NULL;
-    if( !psz_path )
-        return VLC_ENOMEM;
-    if( strncmp( p_demux->psz_access, "file", strlen("file") ) )
+    if( strcmp( p_demux->psz_access, "file" ) )
         return VLC_EGENERIC;
 
+    char *psz_path = decode_URI_duplicate( p_demux->psz_file );
+    if( !psz_path )
+        return VLC_ENOMEM;
 
 #if defined(WIN32) || defined (UNDER_CE)
     wchar_t wpath[MAX_PATH + 1];
index cb7b39129fb0ae2f7cc6687941e9b026676ccd12..4b745982b236873126fb0f86e56a0bf0a585ab1d 100644 (file)
@@ -125,7 +125,7 @@ static int ControlPause( demux_t *demux, int query, va_list args )
 int OpenDemux ( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t*)p_this;
-    char * psz_name = p_demux->psz_path;
+    char * psz_name = p_demux->psz_location;
 
     p_demux->p_sys = NULL;
 
index 05f5f6d1f6eec91a548d14c17fbb79dfd2c51003..222cc19af55fc16b53bb3603de780d4cf6246ed0 100644 (file)
@@ -142,7 +142,7 @@ static int probe_luascript( vlc_object_t *p_this, const char * psz_filename,
     luaopen_stream( L );
     luaopen_xml( L );
     luaopen_md5( L );
-    lua_pushstring( L, p_demux->psz_path );
+    lua_pushstring( L, p_demux->psz_location );
     lua_setfield( L, -2, "path" );
     lua_pushstring( L, p_demux->psz_access );
     lua_setfield( L, -2, "access" );
index 981799ff2d7da30693b11f4065824f186f64c405..675da9c1d5f57bf21d73f6e7acf6043e981a5e62 100644 (file)
 #include <libvlc.h>
 #include <vlc_codec.h>
 #include <vlc_meta.h>
+#include <vlc_url.h>
 
 static bool SkipID3Tag( demux_t * );
 static bool SkipAPETag( demux_t *p_demux );
 
+/* Decode URL (which has had its scheme stripped earlier) to a file path. */
+/* XXX: evil code duplication from access.c */
+static char *get_path(const char *location)
+{
+    char *url, *path;
+
+    /* Prepending "file://" is a bit hackish. But then again, we do not want
+     * to hard-code the list of schemes that use file paths in make_path().
+     */
+    if (asprintf(&url, "file://%s", location) == -1)
+        return NULL;
+
+    path = make_path (url);
+    free (url);
+    return path;
+}
+
+
 /*****************************************************************************
  * demux_New:
  *  if s is NULL then load a access_demux
  *****************************************************************************/
 demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
                        const char *psz_access, const char *psz_demux,
-                       const char *psz_path,
+                       const char *psz_location,
                        stream_t *s, es_out_t *out, bool b_quick )
 {
     static const char typename[] = "demux";
@@ -54,7 +73,8 @@ demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
     /* Parse URL */
     p_demux->psz_access = strdup( psz_access );
     p_demux->psz_demux  = strdup( psz_demux );
-    p_demux->psz_path   = strdup( psz_path );
+    p_demux->psz_location = strdup( psz_location );
+    p_demux->psz_file = get_path( psz_location );
 
     /* Take into account "demux" to be able to do :demux=dump */
     if( p_demux->psz_demux && *p_demux->psz_demux == '\0' )
@@ -66,10 +86,10 @@ demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
     }
 
     if( !b_quick )
-    {
-        msg_Dbg( p_obj, "creating demux: access='%s' demux='%s' path='%s'",
-                 p_demux->psz_access, p_demux->psz_demux, p_demux->psz_path );
-    }
+        msg_Dbg( p_obj, "creating demux: access='%s' demux='%s' "
+                 "location='%s' file='%s'",
+                 p_demux->psz_access, p_demux->psz_demux,
+                 p_demux->psz_location, p_demux->psz_file );
 
     p_demux->s          = s;
     p_demux->out        = out;
@@ -84,7 +104,11 @@ demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
     if( s ) psz_module = p_demux->psz_demux;
     else psz_module = p_demux->psz_access;
 
-    if( s && *psz_module == '\0' && strrchr( p_demux->psz_path, '.' ) )
+    const char *psz_ext;
+
+    if( s && *psz_module == '\0'
+     && p_demux->psz_file != NULL
+     && (psz_ext = strrchr( p_demux->psz_file, '.' )) )
     {
        /* XXX: add only file without any problem here and with strong detection.
         *  - no .mp3, .a52, ... (aac is added as it works only by file ext
@@ -126,12 +150,11 @@ demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
             { "", "" }
         };
 
-        const char *psz_ext = strrchr( p_demux->psz_path, '.' ) + 1;
-        int  i;
+        psz_ext++; // skip '.'
 
         if( !b_quick )
         {
-            for( i = 0; exttodemux[i].ext[0]; i++ )
+            for( unsigned i = 0; exttodemux[i].ext[0]; i++ )
             {
                 if( !strcasecmp( psz_ext, exttodemux[i].ext ) )
                 {
@@ -142,7 +165,7 @@ demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
         }
         else
         {
-            for( i = 0; exttodemux_quick[i].ext[0]; i++ )
+            for( unsigned i = 0; exttodemux_quick[i].ext[0]; i++ )
             {
                 if( !strcasecmp( psz_ext, exttodemux_quick[i].ext ) )
                 {
@@ -178,7 +201,8 @@ demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
 
     if( p_demux->p_module == NULL )
     {
-        free( p_demux->psz_path );
+        free( p_demux->psz_file );
+        free( p_demux->psz_location );
         free( p_demux->psz_demux );
         free( p_demux->psz_access );
         vlc_object_release( p_demux );
@@ -195,7 +219,8 @@ void demux_Delete( demux_t *p_demux )
 {
     module_unneed( p_demux, p_demux->p_module );
 
-    free( p_demux->psz_path );
+    free( p_demux->psz_file );
+    free( p_demux->psz_location );
     free( p_demux->psz_demux );
     free( p_demux->psz_access );