[vlc-devel] [PATCH] demux: avformat: handle fast seeking

Zhao Zhili quinkblack at foxmail.com
Tue Jun 26 12:01:14 CEST 2018


---
 modules/demux/avformat/demux.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 4a66706..d8aa093 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -1029,7 +1029,9 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_SUCCESS;
 
         case DEMUX_SET_POSITION:
+        {
             f = va_arg( args, double );
+            bool precise = va_arg( args, int );
             i64 = p_sys->ic->duration * f + i_start_time;
 
             msg_Warn( p_demux, "DEMUX_SET_POSITION: %"PRId64, i64 );
@@ -1050,9 +1052,13 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             }
             else
             {
-                ResetTime( p_demux, i64 - i_start_time );
+                if( precise )
+                    ResetTime( p_demux, i64 - i_start_time );
+                else
+                    ResetTime( p_demux, -1 );
             }
             return VLC_SUCCESS;
+        }
 
         case DEMUX_GET_LENGTH:
             pi64 = va_arg( args, int64_t * );
@@ -1070,6 +1076,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         case DEMUX_SET_TIME:
         {
             i64 = va_arg( args, int64_t );
+            bool precise = va_arg( args, int );
             i64 = i64 * AV_TIME_BASE / CLOCK_FREQ + i_start_time;
 
             msg_Warn( p_demux, "DEMUX_SET_TIME: %"PRId64, i64 );
@@ -1078,7 +1085,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             {
                 return VLC_EGENERIC;
             }
-            ResetTime( p_demux, i64 - i_start_time );
+            if( precise )
+                ResetTime( p_demux, i64 - i_start_time );
+            else
+                ResetTime( p_demux, -1 );
             return VLC_SUCCESS;
         }
 
-- 
2.9.5





More information about the vlc-devel mailing list