]> git.sesse.net Git - vlc/commitdiff
Enhanced handling of stream discontinuities.
authorChristophe Massiot <massiot@videolan.org>
Fri, 15 Dec 2000 17:21:54 +0000 (17:21 +0000)
committerChristophe Massiot <massiot@videolan.org>
Fri, 15 Dec 2000 17:21:54 +0000 (17:21 +0000)
include/input_ext-intf.h
src/input/mpeg_system.c

index d5a3fd8127a82425967b1923a8deafa7791ed57b..e570531410a272fcad644ba1371fdf9de9c79540 100644 (file)
@@ -29,6 +29,7 @@ typedef struct es_descriptor_s
     struct pes_packet_s *   p_pes;                            /* Current PES */
     struct data_packet_s *  p_last;   /* The last packet gathered at present */
     int                     i_pes_real_size;   /* as indicated by the header */
+    boolean_t               b_discontinuity;               /* Stream changed */
 
     /* Decoder information */
     struct decoder_fifo_s * p_decoder_fifo;
index 09fad713d6f4b94d76da81319d0663a428742dbf..1ccfeec0dcd7783240fb0346327080755ade8d8f 100644 (file)
@@ -390,7 +390,7 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
  *****************************************************************************
  * Gather a PES packet.
  *****************************************************************************/
-void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data,
+void input_GatherPES( input_thread_t * p_input, data_packet_t * p_data,
                       es_descriptor_t * p_es,
                       boolean_t b_unit_start, boolean_t b_packet_lost )
 {
@@ -401,10 +401,12 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data,
     /* If we lost data, insert an NULL data packet (philosophy : 0 is quite
      * often an escape sequence in decoders, so that should make them wait
      * for the next start code). */
-    if( b_packet_lost && p_pes != NULL )
+    if( b_packet_lost || p_es->b_discontinuity )
     {
         data_packet_t *             p_pad_data;
-        if( (p_pad_data = p_input->p_plugin->pf_new_packet( p_input,
+
+        if( (p_pad_data = p_input->p_plugin->pf_new_packet(
+                                            p_input->p_method_data,
                                             PADDING_PACKET_SIZE )) == NULL )
         {
             intf_ErrMsg("Out of memory\n");
@@ -413,8 +415,28 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t *p_data,
         }
         memset( p_data->p_buffer, 0, PADDING_PACKET_SIZE );
         p_pad_data->b_discard_payload = 1;
-        p_pes->b_messed_up = 1;
-        input_GatherPES( p_input, p_pad_data, p_es, 0, 0 );
+
+        if( p_pes != NULL )
+        {
+            p_pes->b_messed_up = p_pes->b_discontinuity = 1;
+            input_GatherPES( p_input, p_pad_data, p_es, 0, 0 );
+        }
+        else
+        {
+            if( (p_pes = p_input->p_plugin->pf_new_pes(
+                                            p_input->p_method_data )) == NULL )
+            {
+                intf_ErrMsg("Out of memory\n");
+                p_input->b_error = 1;
+                return;
+            }
+
+            p_pes->p_first = p_pad_data;
+            p_pes->b_messed_up = p_pes->b_discontinuity = 1;
+            input_DecodePES( p_input, p_es );
+        }
+
+        p_es->b_discontinuity = 0;
     }
 
     if( b_unit_start && p_pes != NULL )
@@ -571,11 +593,19 @@ static void CRDecode( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
                   (    (p_pgrm->last_cr - cr_time) > CR_MAX_GAP
                     || (p_pgrm->last_cr - cr_time) < - CR_MAX_GAP ) ) )
         {
+            int i_es;
+
             /* Stream discontinuity. */
             intf_WarnMsg( 3, "CR re-initialiazed" );
             CRReInit( p_pgrm );
             p_pgrm->i_synchro_state = SYNCHRO_REINIT;
             p_pgrm->b_discontinuity = 0;
+
+            /* Warn all the elementary streams */
+            for( i_es = 0; i_es < p_pgrm->i_es_number; i_es++ )
+            {
+                p_pgrm->pp_es[i_es]->b_discontinuity = 1;
+            }
         }
         p_pgrm->last_cr = cr_time;