[vlc-devel] commit: Allow to select fast seeking with --input-fast-seeking. ( Laurent Aimar )

git version control git at videolan.org
Sat Jan 24 15:12:04 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Jan 24 12:14:10 2009 +0100| [1374daaa71c4210f2ddab92617cc296f6cbc6542] | committer: Laurent Aimar 

Allow to select fast seeking with --input-fast-seeking.

No functionnality changes yet as the demuxers need to honor it.

 I have add an extra bool to  DEMUX_SET_POSITION/TIME to ask for precise
seeking to the demuxer.
(You cannot have precision and speed when seeking with non intra only codec).

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

 include/vlc_demux.h        |    4 ++--
 src/input/input.c          |   13 ++++++++-----
 src/input/input_internal.h |    1 +
 src/input/var.c            |    1 +
 src/libvlc-module.c        |    8 ++++++++
 5 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index bc6caff..31ab555 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -88,12 +88,12 @@ enum demux_query_e
     /* I. Common queries to access_demux and demux */
     /* POSITION double between 0.0 and 1.0 */
     DEMUX_GET_POSITION,         /* arg1= double *       res=    */
-    DEMUX_SET_POSITION,         /* arg1= double         res=can fail    */
+    DEMUX_SET_POSITION,         /* arg1= double arg2= bool b_precise    res=can fail    */
 
     /* LENGTH/TIME in microsecond, 0 if unknown */
     DEMUX_GET_LENGTH,           /* arg1= int64_t *      res=    */
     DEMUX_GET_TIME,             /* arg1= int64_t *      res=    */
-    DEMUX_SET_TIME,             /* arg1= int64_t        res=can fail    */
+    DEMUX_SET_TIME,             /* arg1= int64_t arg2= bool b_precise   res=can fail    */
 
     /* TITLE_INFO only if more than 1 title or 1 chapter */
     DEMUX_GET_TITLE_INFO,       /* arg1=input_title_t*** arg2=int*
diff --git a/src/input/input.c b/src/input/input.c
index 804e9f9..ea4cb75 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -948,6 +948,7 @@ static void StartTitle( input_thread_t * p_input )
         msg_Warn( p_input, "invalid stop-time ignored" );
         p_input->p->i_stop = 0;
     }
+    p_input->p->b_fast_seek = var_GetBool( p_input, "input-fast-seek" );
 }
 
 static void LoadSubtitles( input_thread_t *p_input )
@@ -1585,7 +1586,7 @@ static bool Control( input_thread_t *p_input, int i_type,
             /* Reset the decoders states and clock sync (before calling the demuxer */
             es_out_SetTime( p_input->p->p_es_out, -1 );
             if( demux_Control( p_input->p->input.p_demux, DEMUX_SET_POSITION,
-                                f_pos ) )
+                                f_pos, !p_input->p->b_fast_seek ) )
             {
                 msg_Err( p_input, "INPUT_CONTROL_SET_POSITION(_OFFSET) "
                          "%2.1f%% failed", f_pos * 100 );
@@ -1624,7 +1625,8 @@ static bool Control( input_thread_t *p_input, int i_type,
             es_out_SetTime( p_input->p->p_es_out, -1 );
 
             i_ret = demux_Control( p_input->p->input.p_demux,
-                                    DEMUX_SET_TIME, i_time );
+                                   DEMUX_SET_TIME, i_time,
+                                   !p_input->p->b_fast_seek );
             if( i_ret )
             {
                 int64_t i_length;
@@ -1636,7 +1638,8 @@ static bool Control( input_thread_t *p_input, int i_type,
                 {
                     double f_pos = (double)i_time / (double)i_length;
                     i_ret = demux_Control( p_input->p->input.p_demux,
-                                            DEMUX_SET_POSITION, f_pos );
+                                            DEMUX_SET_POSITION, f_pos,
+                                            !p_input->p->b_fast_seek );
                 }
             }
             if( i_ret )
@@ -2014,7 +2017,7 @@ static bool Control( input_thread_t *p_input, int i_type,
                         break;
                     }
                     if( demux_Control( slave->p_demux,
-                                       DEMUX_SET_TIME, i_time ) )
+                                       DEMUX_SET_TIME, i_time, true ) )
                     {
                         msg_Err( p_input, "seek failed for new slave" );
                         InputSourceClean( slave );
@@ -2760,7 +2763,7 @@ static void SlaveSeek( input_thread_t *p_input )
     {
         input_source_t *in = p_input->p->slave[i];
 
-        if( demux_Control( in->p_demux, DEMUX_SET_TIME, i_time ) )
+        if( demux_Control( in->p_demux, DEMUX_SET_TIME, i_time, true ) )
         {
             if( !in->b_eof )
                 msg_Err( p_input, "seek failed for slave %d -> EOF", i );
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 2cc03e7..bb49f44 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -94,6 +94,7 @@ struct input_thread_private_t
     int64_t     i_stop;     /* :stop-time, 0 if none */
     int64_t     i_run;      /* :run-time, 0 if none */
     int64_t     i_time;     /* Current time */
+    bool        b_fast_seek;/* :input-fast-seek */
 
     /* Title infos FIXME multi-input (not easy) ? */
     int          i_title;
diff --git a/src/input/var.c b/src/input/var.c
index 7d5438d..dcac122 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -446,6 +446,7 @@ void input_ConfigVarInit ( input_thread_t *p_input )
         var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
         var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
         var_Create( p_input, "run-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+        var_Create( p_input, "input-fast-seek", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
 
         var_Create( p_input, "input-slave",
                     VLC_VAR_STRING | VLC_VAR_DOINHERIT );
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index c5ee5ef..fa8071c 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -678,6 +678,10 @@ static const char *const ppsz_clock_descriptions[] =
 #define RUN_TIME_LONGTEXT N_( \
     "The stream will run this duration (in seconds)." )
 
+#define INPUT_FAST_SEEK_TEXT N_("Fast seek")
+#define INPUT_FAST_SEEK_LONGTEXT N_( \
+    "Favor speed over precision while seeking" )
+
 #define INPUT_LIST_TEXT N_("Input list")
 #define INPUT_LIST_LONGTEXT N_( \
     "You can give a comma-separated list " \
@@ -1702,6 +1706,10 @@ vlc_module_begin ()
     add_integer( "run-time", 0, NULL,
                  RUN_TIME_TEXT, RUN_TIME_LONGTEXT, true );
         change_safe ()
+    add_bool( "input-fast-seek", false, NULL,
+              INPUT_FAST_SEEK_TEXT, INPUT_FAST_SEEK_LONGTEXT, false );
+        change_safe ()
+
     add_string( "input-list", NULL, NULL,
                  INPUT_LIST_TEXT, INPUT_LIST_LONGTEXT, true );
     add_string( "input-slave", NULL, NULL,




More information about the vlc-devel mailing list