[vlc-commits] input: handle relative seek (or jump)

Thomas Guillem git at videolan.org
Wed Sep 5 09:47:49 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Sep  5 09:41:50 2018 +0200| [4be7fdc4f47a8f83dfaecf59cd94d52932d14a1b] | committer: Thomas Guillem

input: handle relative seek (or jump)

Add relative seek support, via position (float) or by time (tick). This will be
used by the future vlc_player.

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

 src/input/input.c          | 19 +++++++++++++------
 src/input/input_internal.h |  2 ++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index caad9f0b1a..2f6bb5f8ee 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -237,6 +237,7 @@ void input_SetTime( input_thread_t *p_input, vlc_tick_t i_time, bool b_fast )
 
     param.time.i_val = i_time;
     param.time.b_fast_seek = b_fast;
+    param.time.b_absolute = true;
     input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &param );
 }
 
@@ -246,6 +247,7 @@ void input_SetPosition( input_thread_t *p_input, float f_position, bool b_fast )
 
     param.pos.f_val = f_position;
     param.pos.b_fast_seek = b_fast;
+    param.pos.b_absolute = true;
     input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &param );
 }
 
@@ -1835,6 +1837,7 @@ static void ControlInsertDemuxFilter( input_thread_t* p_input, const char* psz_d
         msg_Dbg(p_input, "Failed to create demux filter %s", psz_demux_chain);
 }
 
+
 static bool Control( input_thread_t *p_input,
                      int i_type, input_control_param_t param )
 {
@@ -1856,10 +1859,12 @@ static bool Control( input_thread_t *p_input,
             /* Reset the decoders states and clock sync (before calling the demuxer */
             es_out_Control( priv->p_es_out, ES_OUT_RESET_PCR );
             if( demux_SetPosition( priv->master->p_demux, (double)param.pos.f_val,
-                                   !param.pos.b_fast_seek, true ) )
+                                   !param.pos.b_fast_seek, param.pos.b_absolute ) )
             {
                 msg_Err( p_input, "INPUT_CONTROL_SET_POSITION "
-                         "%2.1f%% failed", param.pos.f_val * 100.f );
+                         "%s%2.1f%% failed",
+                         param.pos.b_absolute ? "@" : param.pos.f_val >= 0 ? "+" : "",
+                         param.pos.f_val * 100.f );
             }
             else
             {
@@ -1886,7 +1891,7 @@ static bool Control( input_thread_t *p_input,
 
             i_ret = demux_SetTime( priv->master->p_demux, param.time.i_val,
                                    !param.time.b_fast_seek,
-                                   true );
+                                   param.time.b_absolute );
             if( i_ret )
             {
                 int64_t i_length;
@@ -1898,13 +1903,15 @@ static bool Control( input_thread_t *p_input,
                     double f_pos = (double)param.time.i_val / (double)i_length;
                     i_ret = demux_SetPosition( priv->master->p_demux, f_pos,
                                                !param.time.b_fast_seek,
-                                               true );
+                                               param.time.b_absolute );
                 }
             }
             if( i_ret )
             {
-                msg_Warn( p_input, "INPUT_CONTROL_SET_TIME %"PRId64
-                         " failed or not possible", param.time.i_val );
+                msg_Warn( p_input, "INPUT_CONTROL_SET_TIME %s%"PRId64
+                         " failed or not possible",
+                         param.time.b_absolute ? "@" : param.time.i_val >= 0 ? "+" : "",
+                         param.time.i_val );
             }
             else
             {
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 1a69cc47f9..e2b65cd3a3 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -84,10 +84,12 @@ typedef union
     vlc_viewpoint_t viewpoint;
     struct {
         bool b_fast_seek;
+        bool b_absolute;
         vlc_tick_t i_val;
     } time;
     struct {
         bool b_fast_seek;
+        bool b_absolute;
         float f_val;
     } pos;
 } input_control_param_t;



More information about the vlc-commits mailing list