]> git.sesse.net Git - vlc/commitdiff
input.c, vlc_demux.h: allow seeking back in the same chapter
authorSteve Lhomme <robux@videolan.org>
Sat, 5 Mar 2005 12:55:02 +0000 (12:55 +0000)
committerSteve Lhomme <robux@videolan.org>
Sat, 5 Mar 2005 12:55:02 +0000 (12:55 +0000)
mkv.cpp: handle the new DEMUX_GET_SEEKPOINT_TIME

include/vlc_demux.h
modules/demux/mkv.cpp
src/input/input.c

index 7c4385ba9b32198a4c269d74f750636f25b31acd..2eefcb8cf855c78b707760e3a4eb406827552711 100644 (file)
@@ -82,6 +82,7 @@ enum demux_query_e
     /* TITLE/SEEKPOINT, only when TITLE_INFO succeed */
     DEMUX_SET_TITLE,            /* arg1= int            can fail */
     DEMUX_SET_SEEKPOINT,        /* arg1= int            can fail */
+    DEMUX_GET_SEEKPOINT_TIME,   /* arg1= int arg2 = mtime_t *  res = can fail   */
 
     /* DEMUX_SET_GROUP only a hit for demuxer (mainly DVB) to allow not
      * reading everything (you should not use this to call es_out_Control)
index 45db1d56e49d2ccdc3a6503643ee8966c8bd2e96..438a0f0853e956380d7e777c19329cfaf2a7ed0a 100644 (file)
@@ -1130,6 +1130,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     int64_t     *pi64;
     double      *pf, f;
     int         i_skp;
+    mtime_t     *i_sk_time;
 
     vlc_meta_t **pp_meta;
 
@@ -1206,6 +1207,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             }
             return VLC_EGENERIC;
 
+        case DEMUX_GET_SEEKPOINT_TIME:
+            i_skp = (int)va_arg( args, int );
+            i_sk_time = (mtime_t *)va_arg( args, mtime_t * );
+            if( p_sys->title && i_skp < p_sys->title->i_seekpoint)
+            {
+                *i_sk_time = p_sys->title->seekpoint[i_skp]->i_time_offset;
+                return VLC_SUCCESS;
+            }
+            return VLC_EGENERIC;
 
         case DEMUX_SET_TIME:
         case DEMUX_GET_FPS:
@@ -1420,7 +1430,7 @@ static void BlockDecode( demux_t *p_demux, KaxBlock *block, mtime_t i_pts,
         }
 #endif
 
-               // TODO implement correct timestamping when B frames are used
+        // TODO implement correct timestamping when B frames are used
         if( tk.fmt.i_cat != VIDEO_ES )
         {
             p_block->i_dts = p_block->i_pts = i_pts;
index 436bff791161cc3d07082a9a6e1454df5f33ff33..bcefedca5229a824bebec05090b97cfd39eef0e0 100644 (file)
@@ -1493,9 +1493,21 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type,
             {
                 demux_t *p_demux = p_input->input.p_demux;
                 int i_seekpoint;
+                mtime_t i_input_time;
+                mtime_t i_seekpoint_time; 
 
                 if( i_type == INPUT_CONTROL_SET_SEEKPOINT_PREV )
-                    i_seekpoint = p_demux->info.i_seekpoint - 1;
+                {
+                    i_seekpoint = p_demux->info.i_seekpoint;
+                    if (demux2_Control( p_demux, DEMUX_GET_SEEKPOINT_TIME, p_demux->info.i_seekpoint, &i_seekpoint_time) == VLC_SUCCESS)
+                    {
+                        demux2_Control( p_demux, INPUT_GET_TIME, &i_input_time );
+                        if ( i_input_time < i_seekpoint_time + 3000000 )
+                            i_seekpoint--;
+                    }
+                    else
+                        i_seekpoint--;
+                }
                 else if( i_type == INPUT_CONTROL_SET_SEEKPOINT_NEXT )
                     i_seekpoint = p_demux->info.i_seekpoint + 1;
                 else