[vlc-commits] demux: provide full URL instead of access name (refs #18504)

Rémi Denis-Courmont git at videolan.org
Sat Dec 2 22:26:50 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Dec  2 22:57:10 2017 +0200| [8f6ff46bec2b949525cd84fa8fe67f156dc91923] | committer: Rémi Denis-Courmont

demux: provide full URL instead of access name (refs #18504)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8f6ff46bec2b949525cd84fa8fe67f156dc91923
---

 include/vlc_demux.h                    |  4 ++--
 include/vlc_plugin.h                   |  4 ++--
 modules/access/bluray.c                |  4 ++--
 modules/access/dvdnav.c                |  2 +-
 modules/access/idummy.c                |  2 +-
 modules/access/live555.cpp             |  9 +--------
 modules/access/rtp/rtp.c               |  5 -----
 modules/demux/asf/asf.c                |  2 +-
 modules/demux/avformat/demux.c         | 30 ++++--------------------------
 modules/demux/dash/DASHManager.cpp     |  4 +---
 modules/demux/mkv/mkv.cpp              |  2 +-
 modules/demux/mp4/mp4.c                | 13 ++-----------
 modules/demux/mpeg/ts.c                |  4 ++--
 modules/demux/smooth/SmoothManager.cpp |  4 +---
 modules/demux/vobsub.c                 |  3 ++-
 src/input/demux.c                      | 32 +++++++++++++++++---------------
 16 files changed, 40 insertions(+), 84 deletions(-)

diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 1390257b1f..375f997b96 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -48,9 +48,9 @@ struct demux_t
     module_t    *p_module;
 
     /* eg informative but needed (we can have access+demux) */
-    char        *psz_access;
     char        *psz_demux;
-    char        *psz_location;
+    char        *psz_url;
+    const char  *psz_location;
     char        *psz_filepath;
 
     union {
diff --git a/include/vlc_plugin.h b/include/vlc_plugin.h
index ce28562726..e17c883977 100644
--- a/include/vlc_plugin.h
+++ b/include/vlc_plugin.h
@@ -188,8 +188,8 @@ enum vlc_module_properties
 /**
  * Current plugin ABI version
  */
-# define MODULE_SYMBOL 3_0_0f
-# define MODULE_SUFFIX "__3_0_0f"
+# define MODULE_SYMBOL 4_0_0
+# define MODULE_SUFFIX "__4_0_0"
 
 /*****************************************************************************
  * Add a few defines. You do not want to read this section. Really.
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index a209dc0434..010a169d44 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -630,10 +630,10 @@ static int blurayOpen(vlc_object_t *object)
     if (unlikely(!p_demux->p_input))
         return VLC_EGENERIC;
 
-    forced = !strcasecmp(p_demux->psz_access, "bluray");
+    forced = !strncasecmp(p_demux->psz_url, "bluray:", 7);
 
     if (p_demux->s) {
-        if (!strcasecmp(p_demux->psz_access, "file")) {
+        if (!strncasecmp(p_demux->psz_url, "file:", 5)) {
             /* use access_demux for local files */
             return VLC_EGENERIC;
         }
diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index 469d2a7125..b7135fcd69 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -344,7 +344,7 @@ static int AccessDemuxOpen ( vlc_object_t *p_this )
     int i_ret = VLC_EGENERIC;
     bool forced = false;
 
-    if( !strncmp(p_demux->psz_access, "dvd", 3) )
+    if( !strncasecmp(p_demux->psz_url, "dvd", 3) )
         forced = true;
 
     if( !p_demux->psz_filepath || !*p_demux->psz_filepath )
diff --git a/modules/access/idummy.c b/modules/access/idummy.c
index 6721df04c7..18ce6d4257 100644
--- a/modules/access/idummy.c
+++ b/modules/access/idummy.c
@@ -141,7 +141,7 @@ static int ControlPause( demux_t *demux, int query, va_list args )
 static int OpenDemux( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t*)p_this;
-    char * psz_name = p_demux->psz_location;
+    const char *psz_name = p_demux->psz_location;
 
     p_demux->p_sys = NULL;
 
diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index 943f7f9247..7f4ef5aa19 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -297,7 +297,6 @@ static int  Open ( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys = NULL;
 
-    char *psz_url;
     int i_return;
     int i_error = VLC_EGENERIC;
 
@@ -359,13 +358,7 @@ static int  Open ( vlc_object_t *p_this )
     vlc_mutex_init(&p_sys->timeout_mutex);
 
     /* parse URL for rtsp://[user:[passwd]@]serverip:port/options */
-    if( asprintf( &psz_url, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
-    {
-        i_error = VLC_ENOMEM;
-        goto error;
-    }
-    vlc_UrlParse( &p_sys->url, psz_url );
-    free( psz_url );
+    vlc_UrlParse( &p_sys->url, p_demux->psz_url );
 
     if( ( p_sys->psz_pl_url = passwordLessURL( &p_sys->url ) ) == NULL )
     {
diff --git a/modules/access/rtp/rtp.c b/modules/access/rtp/rtp.c
index 33b4f0c7ad..771437dc32 100644
--- a/modules/access/rtp/rtp.c
+++ b/modules/access/rtp/rtp.c
@@ -492,11 +492,6 @@ static void stream_decode (demux_t *demux, void *data, block_t *block)
     (void)demux;
 }
 
-static void *demux_init (demux_t *demux)
-{
-    return stream_init (demux, demux->psz_demux);
-}
-
 /*
  * Static payload types handler
  */
diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 70a0a07f15..793b6bb5e2 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -853,7 +853,7 @@ static int DemuxInit( demux_t *p_demux )
         ASF_fillup_es_bitrate_priorities_ex( p_sys, p_hdr_ext, &fmt_priorities_bitrate_ex );
     }
 
-    const bool b_mms = !strncmp( p_demux->psz_access, "mms", 3 );
+    const bool b_mms = !strncasecmp( p_demux->psz_url, "mms:", 4 );
     bool b_dvrms = false;
 
     if( b_mms )
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 5872ffb888..d45d3073f4 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -156,7 +156,7 @@ int avformat_OpenDemux( vlc_object_t *p_this )
     AVInputFormat *fmt = NULL;
     int64_t       i_start_time = -1;
     bool          b_can_seek;
-    char         *psz_url;
+    const char    *psz_url;
     const uint8_t *peek;
     int           error;
 
@@ -176,13 +176,9 @@ int avformat_OpenDemux( vlc_object_t *p_this )
     memset( pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE );
 
     if( p_demux->psz_filepath )
-        psz_url = strdup( p_demux->psz_filepath );
+        psz_url = p_demux->psz_filepath;
     else
-    {
-        if( asprintf( &psz_url, "%s://%s", p_demux->psz_access,
-                      p_demux->psz_location ) == -1)
-            psz_url = NULL;
-    }
+        psz_url = p_demux->psz_url;
 
     if( psz_url != NULL )
         msg_Dbg( p_demux, "trying url: %s", psz_url );
@@ -210,7 +206,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
     if( fmt == NULL )
     {
         msg_Dbg( p_demux, "couldn't guess format" );
-        free( psz_url );
         return VLC_EGENERIC;
     }
 
@@ -231,10 +226,7 @@ int avformat_OpenDemux( vlc_object_t *p_this )
         for( int i = 0; *ppsz_blacklist[i]; i++ )
         {
             if( !strcmp( fmt->name, ppsz_blacklist[i] ) )
-            {
-                free( psz_url );
                 return VLC_EGENERIC;
-            }
         }
     }
 
@@ -244,23 +236,16 @@ int avformat_OpenDemux( vlc_object_t *p_this )
         int i_len;
 
         if( !p_demux->psz_filepath )
-        {
-            free( psz_url );
             return VLC_EGENERIC;
-        }
 
         i_len = strlen( p_demux->psz_filepath );
         if( i_len < 4 )
-        {
-            free( psz_url );
             return VLC_EGENERIC;
-        }
 
         if( strcasecmp( &p_demux->psz_filepath[i_len - 4], ".str" ) &&
             strcasecmp( &p_demux->psz_filepath[i_len - 4], ".xai" ) &&
             strcasecmp( &p_demux->psz_filepath[i_len - 3], ".xa" ) )
         {
-            free( psz_url );
             return VLC_EGENERIC;
         }
     }
@@ -272,10 +257,8 @@ int avformat_OpenDemux( vlc_object_t *p_this )
     p_demux->pf_control = Control;
     p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
     if( !p_sys )
-    {
-        free( psz_url );
         return VLC_ENOMEM;
-    }
+
     p_sys->ic = 0;
     p_sys->fmt = fmt;
     p_sys->tracks = NULL;
@@ -287,7 +270,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
     unsigned char * p_io_buffer = av_malloc( AVFORMAT_IOBUFFER_SIZE );
     if( !p_io_buffer )
     {
-        free( psz_url );
         avformat_CloseDemux( p_this );
         return VLC_ENOMEM;
     }
@@ -296,7 +278,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
     if( !p_sys->ic )
     {
         av_free( p_io_buffer );
-        free( psz_url );
         avformat_CloseDemux( p_this );
         return VLC_ENOMEM;
     }
@@ -306,7 +287,6 @@ int avformat_OpenDemux( vlc_object_t *p_this )
     if( !pb )
     {
         av_free( p_io_buffer );
-        free( psz_url );
         avformat_CloseDemux( p_this );
         return VLC_ENOMEM;
     }
@@ -321,11 +301,9 @@ int avformat_OpenDemux( vlc_object_t *p_this )
         av_free( pb->buffer );
         av_free( pb );
         p_sys->ic = NULL;
-        free( psz_url );
         avformat_CloseDemux( p_this );
         return VLC_EGENERIC;
     }
-    free( psz_url );
 
     char *psz_opts = var_InheritString( p_demux, "avformat-options" );
     unsigned nb_streams = p_sys->ic->nb_streams;
diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp
index bd40c70e28..7670e61e57 100644
--- a/modules/demux/dash/DASHManager.cpp
+++ b/modules/demux/dash/DASHManager.cpp
@@ -101,9 +101,7 @@ bool DASHManager::updatePlaylist()
     /* do update */
     if(nextPlaylistupdate)
     {
-        std::string url(p_demux->psz_access);
-        url.append("://");
-        url.append(p_demux->psz_location);
+        std::string url(p_demux->psz_url);
 
         block_t *p_block = Retrieve::HTTP(VLC_OBJECT(p_demux), authStorage, url);
         if(!p_block)
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 1e668b6cc3..3a8a0baaae 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -157,7 +157,7 @@ static int Open( vlc_object_t * p_this )
     {
         msg_Dbg( p_demux, "Preloading local dir" );
         /* get the files from the same dir from the same family (based on p_demux->psz_path) */
-        if ( p_demux->psz_filepath && !strcmp( p_demux->psz_access, "file" ) )
+        if ( p_demux->psz_filepath && !strncasecmp( p_demux->psz_url, "file:", 5 ) )
         {
             // assume it's a regular file
             // get the directory path
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 8df0c3eeb1..b83157d098 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -803,17 +803,8 @@ static int Open( vlc_object_t * p_this )
                 }
                 else
                 {
-                    char *psz_url;
-                    if( asprintf( &psz_url, "%s://%s", p_demux->psz_access,
-                                  p_demux->psz_location ) < 0 )
-                    {
-                        free( psz_ref );
-                        input_item_node_Delete( p_subitems );
-                        return VLC_ENOMEM;
-                    }
-
-                    char *psz_absolute = vlc_uri_resolve( psz_url, psz_ref );
-                    free( psz_url );
+                    char *psz_absolute = vlc_uri_resolve( p_demux->psz_url,
+                                                          psz_ref );
                     free( psz_ref );
                     if( psz_absolute == NULL )
                     {
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index d0451896c9..282fc20738 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -501,8 +501,8 @@ static int Open( vlc_object_t *p_this )
     }
 
     if( p_sys->standard == TS_STANDARD_AUTO &&
-       ( !strcmp( p_demux->psz_access, "atsc" ) ||
-         !strcmp( p_demux->psz_access, "usdigital" ) ) )
+       ( !strncasecmp( p_demux->psz_url, "atsc", 4 ) ||
+         !strncasecmp( p_demux->psz_url, "usdigital", 9 ) ) )
     {
         TsChangeStandard( p_sys, TS_STANDARD_ATSC );
     }
diff --git a/modules/demux/smooth/SmoothManager.cpp b/modules/demux/smooth/SmoothManager.cpp
index 703eae1b8b..6510405727 100644
--- a/modules/demux/smooth/SmoothManager.cpp
+++ b/modules/demux/smooth/SmoothManager.cpp
@@ -54,9 +54,7 @@ SmoothManager::~SmoothManager()
 
 Manifest * SmoothManager::fetchManifest()
 {
-    std::string playlisturl(p_demux->psz_access);
-    playlisturl.append("://");
-    playlisturl.append(p_demux->psz_location);
+    std::string playlisturl(p_demux->psz_url);
 
     block_t *p_block = Retrieve::HTTP(VLC_OBJECT(p_demux), authStorage, playlisturl);
     if(!p_block)
diff --git a/modules/demux/vobsub.c b/modules/demux/vobsub.c
index 119233b26a..8a832ff3bd 100644
--- a/modules/demux/vobsub.c
+++ b/modules/demux/vobsub.c
@@ -179,7 +179,8 @@ static int Open ( vlc_object_t *p_this )
         }
     }
 
-    if( asprintf( &psz_vobname, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
+    psz_vobname = strdup( p_demux->psz_url );
+    if( psz_vobname == NULL )
         goto error;
 
     i_len = strlen( psz_vobname );
diff --git a/src/input/demux.c b/src/input/demux.c
index ed87df5ba4..9c610aab62 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -217,21 +217,23 @@ demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_parent_input,
         }
     }
 
+    size_t schemelen = strlen(psz_access);
+
     p_demux->p_input = p_parent_input;
-    p_demux->psz_access = strdup( psz_access );
     p_demux->psz_demux = strdup( psz_demux );
-    p_demux->psz_location = strdup( psz_location );
-    p_demux->psz_filepath = get_path( psz_location ); /* parse URL */
+    if (unlikely(p_demux->psz_demux == NULL))
+        goto error;
 
-    if( unlikely(p_demux->psz_access == NULL
-              || p_demux->psz_demux == NULL
-              || p_demux->psz_location == NULL) )
+    if (unlikely(asprintf(&p_demux->psz_url, "%s://%s", psz_access,
+                          psz_location) == -1))
         goto error;
 
+    p_demux->psz_location = p_demux->psz_url + schemelen + 3;
+    p_demux->psz_filepath = get_path( psz_location ); /* parse URL */
+
     if( !b_preparsing )
         msg_Dbg( p_obj, "creating demux: access='%s' demux='%s' "
-                 "location='%s' file='%s'",
-                 p_demux->psz_access, p_demux->psz_demux,
+                 "location='%s' file='%s'", psz_access, p_demux->psz_demux,
                  p_demux->psz_location, p_demux->psz_filepath );
 
     p_demux->s              = s;
@@ -267,18 +269,19 @@ demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_parent_input,
     else
     {
         p_demux->p_module =
-            module_need( p_demux, "access_demux", p_demux->psz_access, true );
+            module_need( p_demux, "access_demux", psz_access, true );
     }
 
     if( p_demux->p_module == NULL )
+    {
+        free( p_demux->psz_filepath );
+        free( p_demux->psz_url );
         goto error;
+    }
 
     return p_demux;
 error:
-    free( p_demux->psz_filepath );
-    free( p_demux->psz_location );
     free( p_demux->psz_demux );
-    free( p_demux->psz_access );
     vlc_object_release( p_demux );
     return NULL;
 }
@@ -294,9 +297,8 @@ void demux_Delete( demux_t *p_demux )
 
     priv->destroy(p_demux);
     free( p_demux->psz_filepath );
-    free( p_demux->psz_location );
+    free( p_demux->psz_url );
     free( p_demux->psz_demux );
-    free( p_demux->psz_access );
     vlc_object_release( p_demux );
 }
 
@@ -585,8 +587,8 @@ static demux_t *demux_FilterNew( demux_t *p_next, const char *p_name )
     p_demux->p_next       = p_next;
     p_demux->p_input      = NULL;
     p_demux->p_sys        = NULL;
-    p_demux->psz_access   = NULL;
     p_demux->psz_demux    = NULL;
+    p_demux->psz_url      = NULL;
     p_demux->psz_location = NULL;
     p_demux->psz_filepath = NULL;
     p_demux->out          = NULL;



More information about the vlc-commits mailing list