]> git.sesse.net Git - vlc/blobdiff - src/input/input.c
vlm: accept "ps" and "ts" as mux arguments
[vlc] / src / input / input.c
index 35da58bd31014e589b6593654d4653b3310b4210..8a0e0707df3ad87e441cd9c65a7498374a9c9130 100644 (file)
@@ -2380,8 +2380,6 @@ static int InputSourceInit( input_thread_t *p_input,
         /* Preparsing is only for file:// */
         if( *psz_demux )
             goto error;
-        if( !*psz_access ) /* path without scheme:// */
-            psz_access = "file";
         if( strcmp( psz_access, "file" ) )
             goto error;
         msg_Dbg( p_input, "trying to pre-parse %s",  psz_path );
@@ -2390,12 +2388,6 @@ static int InputSourceInit( input_thread_t *p_input,
     if( in->p_demux )
     {
         /* Get infos from access_demux */
-        int i_ret = demux_Control( in->p_demux,
-                                   DEMUX_GET_PTS_DELAY, &in->i_pts_delay );
-        assert( !i_ret );
-        in->i_pts_delay = __MAX( 0, __MIN( in->i_pts_delay, INPUT_PTS_DELAY_MAX ) );
-
-
         in->b_title_demux = true;
         if( demux_Control( in->p_demux, DEMUX_GET_TITLE_INFO,
                             &in->title, &in->i_title,
@@ -2456,9 +2448,6 @@ static int InputSourceInit( input_thread_t *p_input,
         if( !p_input->b_preparsing )
         {
             bool b_can_seek;
-            access_Control( in->p_access,
-                             ACCESS_GET_PTS_DELAY, &in->i_pts_delay );
-            in->i_pts_delay = __MAX( 0, __MIN( in->i_pts_delay, INPUT_PTS_DELAY_MAX ) );
 
             in->b_title_demux = false;
             if( access_Control( in->p_access, ACCESS_GET_TITLE_INFO,
@@ -2605,7 +2594,7 @@ static int InputSourceInit( input_thread_t *p_input,
 
     /* get attachment
      * FIXME improve for b_preparsing: move it after GET_META and check psz_arturl */
-    if( 1 || !p_input->b_preparsing )
+    if( !p_input->b_preparsing )
     {
         int i_attachment;
         input_attachment_t **attachment;
@@ -2617,7 +2606,24 @@ static int InputSourceInit( input_thread_t *p_input,
                               i_attachment, attachment );
             vlc_mutex_unlock( &p_input->p->p_item->lock );
         }
+
+        /* PTS delay: request from demux first. This is required for
+         * access_demux and some special cases like SDP demux. Otherwise,
+         * fallback to access */
+        if( demux_Control( in->p_demux, DEMUX_GET_PTS_DELAY,
+                           &in->i_pts_delay ) )
+        {
+            /* GET_PTS_DELAY is mandatory for access_demux */
+            assert( in->p_access );
+            access_Control( in->p_access,
+                            ACCESS_GET_PTS_DELAY, &in->i_pts_delay );
+        }
+        if( in->i_pts_delay > INPUT_PTS_DELAY_MAX )
+            in->i_pts_delay = INPUT_PTS_DELAY_MAX;
+        else if( in->i_pts_delay < 0 )
+            in->i_pts_delay = 0;
     }
+
     if( !demux_Control( in->p_demux, DEMUX_GET_FPS, &f_fps ) && f_fps > 0.0 )
     {
         vlc_mutex_lock( &p_input->p->p_item->lock );
@@ -2996,52 +3002,49 @@ static void input_ChangeState( input_thread_t *p_input, int i_state )
 void input_SplitMRL( const char **ppsz_access, const char **ppsz_demux,
                      char **ppsz_path, char *psz_dup )
 {
-    const char *psz_access;
-    const char *psz_demux = "";
-    char *psz_path;
+    char *p;
 
-    /* Either there is an access/demux specification before ://
-     * or we have a plain local file path. */
-    psz_path = strstr( psz_dup, "://" );
-    if( psz_path != NULL )
+    /* Separate <path> from <access>[/<demux>]:// */
+    p = strstr( psz_dup, "://" );
+    if( p != NULL )
     {
-        *psz_path = '\0';
-        psz_path += 3; /* skips "://" */
-
-        psz_access = psz_dup;
-        /* We really don't want module name substitution here! */
-        if( psz_access[0] == '$' )
-            psz_access++;
-
-        /* Separate access from demux (<access>/<demux>://<path>) */
-        char *p = strchr( psz_access, '/' );
-        if( p )
-        {
-            *p = '\0';
-            psz_demux = p + 1;
-            if( psz_demux[0] == '$' )
-                psz_demux++;
-        }
+        *p = '\0';
+        p += 3; /* skips "://" */
+        *ppsz_path = p;
 
         /* Remove HTML anchor if present (not supported).
          * The hash symbol itself should be URI-encoded. */
-        p = strchr( psz_path, '#' );
+        p = strchr( p, '#' );
         if( p )
             *p = '\0';
     }
     else
     {
 #ifndef NDEBUG
-        fprintf( stderr, "%s(\"%s\"): not a valid URI!\n", __func__,
+        fprintf( stderr, "%s(\"%s\") probably not a valid URI!\n", __func__,
                  psz_dup );
 #endif
-        psz_path = psz_dup;
-        psz_access = "";
+        /* Note: this is a valid non const pointer to "": */
+        *ppsz_path = psz_dup + strlen( psz_dup );
     }
 
-    *ppsz_access = psz_access;
-    *ppsz_demux = psz_demux;
-    *ppsz_path = psz_path;
+    /* Separate access from demux */
+    p = strchr( psz_dup, '/' );
+    if( p != NULL )
+    {
+        *(p++) = '\0';
+        if( p[0] == '$' )
+            p++;
+        *ppsz_demux = p;
+    }
+    else
+        *ppsz_demux = "";
+
+    /* We really don't want module name substitution here! */
+    p = psz_dup;
+    if( p[0] == '$' )
+        p++;
+    *ppsz_access = p;
 }
 
 static inline bool next(char ** src)