]> git.sesse.net Git - vlc/commitdiff
* Implemented basic stream navigation function, and bound Jump forward
authorChristophe Massiot <massiot@videolan.org>
Thu, 8 Feb 2001 13:52:35 +0000 (13:52 +0000)
committerChristophe Massiot <massiot@videolan.org>
Thu, 8 Feb 2001 13:52:35 +0000 (13:52 +0000)
  and jump Backward in the SDL intf. Enjoy !

14 files changed:
include/input.h
include/input_ext-dec.h
include/input_ext-intf.h
include/modules.h
include/stream_control.h
plugins/mpeg/input_ps.c
plugins/sdl/intf_sdl.c
src/input/input.c
src/input/input_clock.c
src/input/input_dec.c
src/input/input_ext-dec.c
src/input/input_ext-intf.c
src/input/input_programs.c
src/input/mpeg_system.c

index 9646996944fb46dab4fff37555c2e6eee10e4121..48fc829a2ed9d003352f7f8cb02d9deab5105943 100644 (file)
@@ -2,9 +2,9 @@
  * input.h: structures of the input not exported to other modules
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input.h,v 1.26 2001/02/08 04:43:27 sam Exp $
+ * $Id: input.h,v 1.27 2001/02/08 13:52:34 massiot Exp $
  *
- * Authors:
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -32,6 +32,8 @@
                                  * packets. Have a nice day and merry Xmas.  */
 #define PADDING_PACKET_SIZE 188 /* Size of the NULL packet inserted in case
                                  * of data loss (this should be < 188).      */
+#define PADDING_PACKET_NUMBER 10 /* Number of padding packets top insert to
+                                  * escape a decoder.                        */
 
 /*****************************************************************************
  * Prototypes from input_ext-dec.c
@@ -69,14 +71,14 @@ int  input_SelectES  ( struct input_thread_s *, struct es_descriptor_s * );
 vlc_thread_t input_RunDecoder( struct decoder_capabilities_s *, void * );
 void input_EndDecoder( struct input_thread_s *, struct es_descriptor_s * );
 void input_DecodePES ( struct decoder_fifo_s *, struct pes_packet_s * );
+void input_EscapeDiscontinuity( struct input_thread_s *,
+                                struct pgrm_descriptor_s * );
+void input_EscapeAudioDiscontinuity( struct input_thread_s *,
+                                     struct pgrm_descriptor_s * );
 
 /*****************************************************************************
  * Prototypes from input_clock.c
  *****************************************************************************/
-void input_ClockNewRef( struct input_thread_s *,
-                        struct pgrm_descriptor_s *, mtime_t, mtime_t );
-void input_EscapeDiscontinuity( struct input_thread_s *,
-                                struct pgrm_descriptor_s * );
 void input_ClockInit( struct pgrm_descriptor_s * );
 void input_ClockManageRef( struct input_thread_s *,
                            struct pgrm_descriptor_s *, mtime_t );
index 898eb50660b83dc8a3776959034fda637b8e3060..bb070e13908700d50ececa60ec8d2031ddd22d5e 100644 (file)
@@ -2,9 +2,10 @@
  * input_ext-dec.h: structures exported to the VideoLAN decoders
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-dec.h,v 1.20 2001/01/24 19:05:55 massiot Exp $
+ * $Id: input_ext-dec.h,v 1.21 2001/02/08 13:52:34 massiot Exp $
  *
- * Authors:
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ *          Michel Kaempf <maxx@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index eb0fcc19726e2938888bbad480dadda787154c3d..d4571e8bfb4776ad8f8d767a23955a86785b6627 100644 (file)
@@ -4,9 +4,9 @@
  * control the pace of reading. 
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-intf.h,v 1.16 2001/02/08 13:08:02 massiot Exp $
+ * $Id: input_ext-intf.h,v 1.17 2001/02/08 13:52:34 massiot Exp $
  *
- * Authors:
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -241,7 +241,7 @@ typedef struct input_thread_s
     int                  (* pf_rewind)( struct input_thread_s * );
                                            /* NULL if we don't support going *
                                             * backwards (it's gonna be fun)  */
-    int                  (* pf_seek)( struct input_thread_s *, off_t );
+    void                 (* pf_seek)( struct input_thread_s *, off_t );
 
     i_p_config_t            i_p_config;              /* plugin configuration */
     char *                  p_source;
@@ -305,3 +305,4 @@ void input_DestroyThread( struct input_thread_s *, int *pi_status );
 void input_Play   ( struct input_thread_s * );
 void input_Pause  ( struct input_thread_s * );
 void input_Forward( struct input_thread_s *, int );
+void input_Seek   ( struct input_thread_s *, off_t );
index e47a1c803b1da7e19a0e60702bb93cbcc8aa86e7..ee7d6024bdfebf6c782e44606cf052817415a58e 100644 (file)
@@ -85,7 +85,7 @@ typedef struct function_list_s
             void ( * pf_delete_pes )     ( void *, struct pes_packet_s * );
 
             int  ( * pf_rewind ) ( struct input_thread_s * );
-            int  ( * pf_seek )   ( struct input_thread_s *, off_t );
+            void ( * pf_seek )   ( struct input_thread_s *, off_t );
         } input;
 
         /* Audio output plugin */
index 44154346a0fc4cd1c2cecc441cf9be886307282f..ab4fcdfbfa894b738bbeb57838bb3bbe48ec78cc 100644 (file)
@@ -1,3 +1,28 @@
+/*****************************************************************************
+ * stream_control.h: structures of the input exported verywhere
+ * This header provides a structure so that everybody knows the state
+ * of the reading.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ * $Id: stream_control.h,v 1.5 2001/02/08 13:52:34 massiot Exp $
+ *
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
 /* Structures exported to interface, input and decoders */
 
 /*****************************************************************************
index fbe68804fe2db970bb4d8835178045a87410629e..fb5a841a9e9ff42f9a44fbe7a6753189bce6a934 100644 (file)
@@ -2,9 +2,9 @@
  * input_ps.c: PS demux and packet management
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ps.c,v 1.2 2001/02/08 07:24:25 sam Exp $
+ * $Id: input_ps.c,v 1.3 2001/02/08 13:52:35 massiot Exp $
  *
- * Authors: 
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -61,7 +61,8 @@ static int  PSRead      ( struct input_thread_s *,
                           data_packet_t * p_packets[INPUT_READ_ONCE] );
 static void PSInit      ( struct input_thread_s * );
 static void PSEnd       ( struct input_thread_s * );
-static struct pes_packet_s *  NewPES    ( void * p_garbage );
+static void PSSeek      ( struct input_thread_s *, off_t );
+static struct pes_packet_s *  NewPES    ( void * );
 static struct data_packet_s * NewPacket ( void *, size_t );
 static void DeletePacket( void *, struct data_packet_s * );
 static void DeletePES   ( void *, struct pes_packet_s * );
@@ -85,7 +86,7 @@ void input_getfunctions( function_list_t * p_function_list )
     input.pf_delete_packet    = DeletePacket;
     input.pf_delete_pes       = DeletePES;
     input.pf_rewind           = NULL;
-    input.pf_seek             = NULL;
+    input.pf_seek             = PSSeek;
 #undef input
 }
 
@@ -428,6 +429,20 @@ static int PSRead( input_thread_t * p_input,
     return( 0 );
 }
 
+/*****************************************************************************
+ * PSSeek: changes the stream position indicator
+ *****************************************************************************/
+static void PSSeek( input_thread_t * p_input, off_t i_position )
+{
+    thread_ps_data_t *  p_method;
+
+    p_method = (thread_ps_data_t *)p_input->p_plugin_data;
+
+    /* A little bourrin but should work for a while --Meuuh */
+    fseek( p_method->stream, i_position, SEEK_SET );
+
+    p_input->stream.i_tell = i_position;
+}
 
 /*
  * Packet management utilities
index d157ca82eaec5c22f663a2b3ba101c6df9a0fbd1..71c9921335d74826d3bcd240bd561a675e56a266 100644 (file)
@@ -2,7 +2,7 @@
  * intf_sdl.c: SDL interface plugin
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: intf_sdl.c,v 1.31 2001/02/08 13:08:02 massiot Exp $
+ * $Id: intf_sdl.c,v 1.32 2001/02/08 13:52:35 massiot Exp $
  *
  * Authors:
  *
@@ -174,6 +174,21 @@ void intf_SDLManage( intf_thread_t *p_intf )
                 }
                 break;
 
+            case SDLK_j:
+                /* Jump forwards */
+                input_Seek( p_intf->p_input,
+                            p_intf->p_input->stream.i_tell
+                             + p_intf->p_input->stream.i_size / 20 );
+                                                           /* gabuzomeu */
+                break;
+
+            case SDLK_b:
+                /* Jump backwards */
+                input_Seek( p_intf->p_input,
+                            p_intf->p_input->stream.i_tell
+                             - p_intf->p_input->stream.i_size / 20 );
+                break;
+
             default:
                 if( intf_ProcessKey( p_intf, (char )i_key ) )
                 {
index 3d15f429c109806f32612a7265729cad626d92b6..02b8429225e9afd2bf141c1523880a33dfafbc2f 100644 (file)
@@ -4,9 +4,9 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.77 2001/02/08 13:08:02 massiot Exp $
+ * $Id: input.c,v 1.78 2001/02/08 13:52:35 massiot Exp $
  *
- * Authors: 
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -197,14 +197,28 @@ static void RunThread( input_thread_t *p_input )
         p_input->c_loops++;
 #endif
 
-        vlc_mutex_lock( &p_input->stream.control.control_lock );
-        if( p_input->stream.control.i_status == BACKWARD_S
-             && p_input->pf_rewind != NULL )
+        vlc_mutex_lock( &p_input->stream.stream_lock );
+        if( p_input->stream.i_seek )
         {
-            p_input->pf_rewind( p_input );
-            /* FIXME: probably don't do it every loop, but when ? */
+            if( p_input->stream.b_seekable && p_input->pf_seek != NULL )
+            {
+                p_input->pf_seek( p_input, p_input->stream.i_seek );
+
+                for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
+                {
+                    pgrm_descriptor_t * p_pgrm
+                                            = p_input->stream.pp_programs[i];
+                    /* Escape all decoders for the stream discontinuity they
+                     * will encounter. */
+                    input_EscapeDiscontinuity( p_input, p_pgrm );
+
+                    /* Reinitialize synchro. */
+                    p_pgrm->i_synchro_state = SYNCHRO_REINIT;
+                }
+            }
+            p_input->stream.i_seek = 0;
         }
-        vlc_mutex_unlock( &p_input->stream.control.control_lock );
+        vlc_mutex_unlock( &p_input->stream.stream_lock );
 
         i_error = p_input->pf_read( p_input, pp_packets );
 
index f603ccd252634ea0d81b8725f2f2fd9be43bfdf3..72f3a21707990b8b91cbb37ccb6923117a0e39e4 100644 (file)
@@ -2,7 +2,7 @@
  * input_clock.c: Clock/System date convertions, stream management
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_clock.c,v 1.5 2001/02/08 13:08:03 massiot Exp $
+ * $Id: input_clock.c,v 1.6 2001/02/08 13:52:35 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -114,10 +114,10 @@ static mtime_t ClockCurrent( input_thread_t * p_input,
 }
 
 /*****************************************************************************
- * input_ClockNewRef: writes a new clock reference
+ * ClockNewRef: writes a new clock reference
  *****************************************************************************/
-void input_ClockNewRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
-                        mtime_t i_clock, mtime_t i_sysdate )
+static void ClockNewRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
+                         mtime_t i_clock, mtime_t i_sysdate )
 {
     intf_WarnMsg( 1, "Old ref: %lld/%lld, New ref: %lld/%lld", p_pgrm->cr_ref,
               p_pgrm->sysdate_ref, i_clock, i_sysdate );
@@ -125,44 +125,6 @@ void input_ClockNewRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
     p_pgrm->sysdate_ref = i_sysdate;
 }
 
-/*****************************************************************************
- * EscapeDiscontinuity: send a NULL packet to the decoders
- *****************************************************************************/
-static void EscapeDiscontinuity( input_thread_t * p_input,
-                                 pgrm_descriptor_t * p_pgrm )
-{
-    int     i_es;
-
-    for( i_es = 0; i_es < p_pgrm->i_es_number; i_es++ )
-    {
-        es_descriptor_t * p_es = p_pgrm->pp_es[i_es];
-
-        if( p_es->p_decoder_fifo != NULL )
-        {
-            input_NullPacket( p_input, p_es );
-        }
-    }
-}
-
-/*****************************************************************************
- * EscapeAudioDiscontinuity: send a NULL packet to the audio decoders
- *****************************************************************************/
-static void EscapeAudioDiscontinuity( input_thread_t * p_input,
-                                      pgrm_descriptor_t * p_pgrm )
-{
-    int     i_es;
-
-    for( i_es = 0; i_es < p_pgrm->i_es_number; i_es++ )
-    {
-        es_descriptor_t * p_es = p_pgrm->pp_es[i_es];
-
-        if( p_es->p_decoder_fifo != NULL && p_es->b_audio )
-        {
-            input_NullPacket( p_input, p_es );
-        }
-    }
-}
-
 /*****************************************************************************
  * input_ClockInit: reinitializes the clock reference after a stream
  *                  discontinuity
@@ -185,7 +147,7 @@ void input_ClockManageRef( input_thread_t * p_input,
     if( p_pgrm->i_synchro_state != SYNCHRO_OK )
     {
         /* Feed synchro with a new reference point. */
-        input_ClockNewRef( p_input, p_pgrm, i_clock, mdate() );
+        ClockNewRef( p_input, p_pgrm, i_clock, mdate() );
         p_pgrm->i_synchro_state = SYNCHRO_OK;
     }
     else
@@ -200,7 +162,7 @@ void input_ClockManageRef( input_thread_t * p_input,
             intf_WarnMsg( 3, "Clock gap, unexpected stream discontinuity" );
             input_ClockInit( p_pgrm );
             p_pgrm->i_synchro_state = SYNCHRO_START;
-            EscapeDiscontinuity( p_input, p_pgrm );
+            input_EscapeDiscontinuity( p_input, p_pgrm );
         }
 
         p_pgrm->last_cr = i_clock;
@@ -221,11 +183,11 @@ void input_ClockManageRef( input_thread_t * p_input,
                 {
                     vlc_cond_wait( &p_input->stream.stream_wait,
                                    &p_input->stream.stream_lock );
-                    input_ClockNewRef( p_input, p_pgrm, i_clock, mdate() );
+                    ClockNewRef( p_input, p_pgrm, i_clock, mdate() );
                 }
                 else
                 {
-                    input_ClockNewRef( p_input, p_pgrm, i_clock,
+                    ClockNewRef( p_input, p_pgrm, i_clock,
                                ClockToSysdate( p_input, p_pgrm, i_clock ) );
                 }
 
@@ -240,7 +202,7 @@ void input_ClockManageRef( input_thread_t * p_input,
 
                     /* Feed the audio decoders with a NULL packet to avoid
                      * discontinuities. */
-                    EscapeAudioDiscontinuity( p_input, p_pgrm );
+                    input_EscapeAudioDiscontinuity( p_input, p_pgrm );
                 }
                 else
                 {
index f8fe914ce939027f3d6daace5edeaf3a6c7dd8b4..1ffb24e37587234abd2bdc108619e0a60661b2f0 100644 (file)
@@ -2,7 +2,7 @@
  * input_dec.c: Functions for the management of decoders
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_dec.c,v 1.7 2001/01/15 06:18:23 sam Exp $
+ * $Id: input_dec.c,v 1.8 2001/02/08 13:52:35 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -59,7 +59,7 @@ void input_EndDecoder( input_thread_t * p_input, es_descriptor_t * p_es )
 
     /* Make sure the thread leaves the NextDataPacket() function by
      * sending it a few null packets. */
-    for( i_dummy = 0; i_dummy < 10; i_dummy++ )
+    for( i_dummy = 0; i_dummy < PADDING_PACKET_NUMBER; i_dummy++ )
     {
         input_NullPacket( p_input, p_es );
     }
@@ -115,3 +115,48 @@ void input_DecodePES( decoder_fifo_t * p_decoder_fifo, pes_packet_t * p_pes )
     }
     vlc_mutex_unlock( &p_decoder_fifo->data_lock );
 }
+
+/*****************************************************************************
+ * input_EscapeDiscontinuity: send a NULL packet to the decoders
+ *****************************************************************************/
+void input_EscapeDiscontinuity( input_thread_t * p_input,
+                                pgrm_descriptor_t * p_pgrm )
+{
+    int     i_es, i;
+
+    for( i_es = 0; i_es < p_pgrm->i_es_number; i_es++ )
+    {
+        es_descriptor_t * p_es = p_pgrm->pp_es[i_es];
+
+        if( p_es->p_decoder_fifo != NULL )
+        {
+            for( i = 0; i < PADDING_PACKET_NUMBER; i++ )
+            {
+                input_NullPacket( p_input, p_es );
+            }
+        }
+    }
+}
+
+/*****************************************************************************
+ * input_EscapeAudioDiscontinuity: send a NULL packet to the audio decoders
+ *****************************************************************************/
+void input_EscapeAudioDiscontinuity( input_thread_t * p_input,
+                                     pgrm_descriptor_t * p_pgrm )
+{
+    int     i_es, i;
+
+    for( i_es = 0; i_es < p_pgrm->i_es_number; i_es++ )
+    {
+        es_descriptor_t * p_es = p_pgrm->pp_es[i_es];
+
+        if( p_es->p_decoder_fifo != NULL && p_es->b_audio )
+        {
+            for( i = 0; i < PADDING_PACKET_NUMBER; i++ )
+            {
+                input_NullPacket( p_input, p_es );
+            }
+        }
+    }
+}
+
index d06febc750abcd45fac0ff9b2879307292d8ed78..ced9bdd5b9676cb8c9a3ec26197576cfbd1c3863 100644 (file)
@@ -3,7 +3,7 @@
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
  *
- * Authors: 
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index dd56ed23c7a1560335a1dfc32f5f9aceba0dd666..81b70e6288c5fd55cf9931d9ee114d90e7d05fef 100644 (file)
@@ -3,7 +3,7 @@
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
  *
- * Authors: 
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -84,8 +84,23 @@ void input_Forward( input_thread_t * p_input, int i_rate )
  *****************************************************************************/
 void input_Pause( input_thread_t * p_input )
 {
+    intf_Msg( "input: paused" );
     vlc_mutex_lock( &p_input->stream.stream_lock );
     p_input->stream.i_new_status = PAUSE_S;
     vlc_cond_signal( &p_input->stream.stream_wait );
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 }
+
+/*****************************************************************************
+ * input_Seek: changes the stream postion
+ *****************************************************************************/
+void input_Seek( input_thread_t * p_input, off_t i_position )
+{
+    intf_Msg( "input: seeking position %d/%d", i_position,
+                                               p_input->stream.i_size );
+    vlc_mutex_lock( &p_input->stream.stream_lock );
+    p_input->stream.i_seek = i_position;
+    vlc_cond_signal( &p_input->stream.stream_wait );
+    vlc_mutex_unlock( &p_input->stream.stream_lock );
+}
+
index 631e426ede1ba36a60ce12cea2622b7af76eb06e..bb5547e5420cdf8e17ba00ee575bd3cd0ccfe078 100644 (file)
@@ -2,9 +2,9 @@
  * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_programs.c,v 1.29 2001/02/08 04:43:28 sam Exp $
+ * $Id: input_programs.c,v 1.30 2001/02/08 13:52:35 massiot Exp $
  *
- * Authors:
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index a669f16eb0e579b265a588f1f0a143471f4545b0..083005dcbae2ab7e8db12c685ca659f04f741eb2 100644 (file)
@@ -2,9 +2,12 @@
  * mpeg_system.c: TS, PS and PES management
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: mpeg_system.c,v 1.32 2001/02/08 04:43:28 sam Exp $
+ * $Id: mpeg_system.c,v 1.33 2001/02/08 13:52:35 massiot Exp $
  *
- * Authors: 
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ *          Michel Lespinasse <walken@via.ecp.fr>
+ *          BenoĆ®t Steiner <benny@via.ecp.fr>
+ *          Samuel Hocevar <sam@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by