]> git.sesse.net Git - vlc/commitdiff
* src/input/input_dec.c: use VLC_OBJECT_PACKETIZER for packetizers.
authorGildas Bazin <gbazin@videolan.org>
Fri, 10 Oct 2003 17:09:42 +0000 (17:09 +0000)
committerGildas Bazin <gbazin@videolan.org>
Fri, 10 Oct 2003 17:09:42 +0000 (17:09 +0000)
* modules/mux/ogg.c: win32 fix for ogg muxing with several elementary streams.

modules/mux/ogg.c
src/input/input_dec.c

index 93349048a0a78ffb117baf2c32d1203fd68aa4bd..015c5a9c235cd338a5078e921755c1640a38a052 100644 (file)
@@ -2,7 +2,7 @@
  * ogg.c: ogg muxer module for vlc
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: ogg.c,v 1.17 2003/10/09 19:31:38 gbazin Exp $
+ * $Id: ogg.c,v 1.18 2003/10/10 17:09:42 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
  *****************************************************************************/
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
+
+#ifdef HAVE_TIME_H
+#   include <time.h>
+#endif
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
@@ -226,6 +229,7 @@ struct sout_mux_sys_t
     int     i_streams;
 
     mtime_t i_start_dts;
+    int     i_next_serial_no;
 
     /* number of logical streams pending to be added */
     int i_add_streams;
@@ -262,6 +266,12 @@ static int Open( vlc_object_t *p_this )
     p_mux->pf_mux       = Mux;
     p_mux->i_preheader  = 1;
 
+    /* First serial number is random.
+     * (Done like this because on win32 you need to seed the random number
+     *  generator once per thread). */
+    srand( (unsigned int)time( NULL ) );
+    p_sys->i_next_serial_no = rand();
+
     return VLC_SUCCESS;
 }
 
@@ -330,7 +340,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
 
     p_stream->i_cat       = p_input->p_fmt->i_cat;
     p_stream->i_fourcc    = p_input->p_fmt->i_fourcc;
-    p_stream->i_serial_no = rand();
+    p_stream->i_serial_no = p_sys->i_next_serial_no++;
     p_stream->i_packet_no = 0;
 
     p_stream->i_sout_headers = 0;
@@ -883,7 +893,7 @@ static int Mux( sout_mux_t *p_mux )
             if( p_stream->i_fourcc == VLC_FOURCC( 't', 'h', 'e', 'o' ) )
             {
                 /* FIXME, we assume only keyframes and 25fps */
-               op.granulepos = ( ( i_dts - p_sys->i_start_dts ) * I64C(25)
+                op.granulepos = ( ( i_dts - p_sys->i_start_dts ) * I64C(25)
                     / I64C(1000000) ) << p_stream->i_keyframe_granule_shift;
             }
             else
index aa419077cf0a6763fa82da25a79d45bdb029cc0d..d39978b6c19ab6a0430505c9807b374c8639c9f9 100644 (file)
@@ -2,7 +2,7 @@
  * input_dec.c: Functions for the management of decoders
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: input_dec.c,v 1.64 2003/10/08 21:01:07 gbazin Exp $
+ * $Id: input_dec.c,v 1.65 2003/10/10 17:09:42 gbazin Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -33,7 +33,7 @@
 #include "input_ext-intf.h"
 #include "input_ext-plugins.h"
 
-static decoder_t * CreateDecoder( input_thread_t *, es_descriptor_t * );
+static decoder_t * CreateDecoder( input_thread_t *, es_descriptor_t *, int );
 static int         DecoderThread( decoder_t * );
 static void        DeleteDecoder( decoder_t * );
 
@@ -44,19 +44,9 @@ decoder_fifo_t * input_RunDecoder( input_thread_t * p_input,
                                    es_descriptor_t * p_es )
 {
     vlc_value_t    val;
-    decoder_t      *p_dec;
+    decoder_t      *p_dec = NULL;
     int            i_priority;
 
-    /* Create the decoder configuration structure */
-    p_dec = CreateDecoder( p_input, p_es );
-    if( p_dec == NULL )
-    {
-        msg_Err( p_input, "could not create decoder" );
-        return NULL;
-    }
-
-    p_dec->p_module = NULL;
-
     /* If we are in sout mode, search for packetizer module */
     var_Get( p_input, "sout", &val );
     if( !p_es->b_force_decoder && val.psz_string && *val.psz_string )
@@ -75,19 +65,35 @@ decoder_fifo_t * input_RunDecoder( input_thread_t * p_input,
 
         if( val.b_bool )
         {
+            /* Create the decoder configuration structure */
+            p_dec = CreateDecoder( p_input, p_es, VLC_OBJECT_PACKETIZER );
+            if( p_dec == NULL )
+            {
+                msg_Err( p_input, "could not create packetizer" );
+                return NULL;
+            }
+
             p_dec->p_module =
                 module_Need( p_dec, "packetizer", "$packetizer" );
         }
     }
     else
     {
+        /* Create the decoder configuration structure */
+        p_dec = CreateDecoder( p_input, p_es, VLC_OBJECT_DECODER );
+        if( p_dec == NULL )
+        {
+            msg_Err( p_input, "could not create decoder" );
+            return NULL;
+        }
+
         /* default Get a suitable decoder module */
         p_dec->p_module = module_Need( p_dec, "decoder", "$codec" );
 
         if( val.psz_string ) free( val.psz_string );
     }
 
-    if( p_dec->p_module == NULL )
+    if( !p_dec || !p_dec->p_module )
     {
         msg_Err( p_dec, "no suitable decoder module for fourcc `%4.4s'.\n"
                  "VLC probably does not support this sound or video format.",
@@ -278,11 +284,11 @@ void input_EscapeAudioDiscontinuity( input_thread_t * p_input )
  * CreateDecoderFifo: create a decoder_fifo_t
  *****************************************************************************/
 static decoder_t * CreateDecoder( input_thread_t * p_input,
-                                  es_descriptor_t * p_es )
+                                  es_descriptor_t * p_es, int i_object_type )
 {
     decoder_t * p_dec;
 
-    p_dec = vlc_object_create( p_input, VLC_OBJECT_DECODER );
+    p_dec = vlc_object_create( p_input, i_object_type );
     if( p_dec == NULL )
     {
         msg_Err( p_input, "out of memory" );
@@ -372,21 +378,21 @@ static int DecoderThread( decoder_t * p_dec )
             break;
         }
 
-       for( i_size = 0, p_data = p_pes->p_first;
-            p_data != NULL; p_data = p_data->p_next )
-       {
-           i_size += p_data->p_payload_end - p_data->p_payload_start;
-       }
-       p_block = block_New( p_dec, i_size );
-       for( i_size = 0, p_data = p_pes->p_first;
-            p_data != NULL; p_data = p_data->p_next )
-       {
+        for( i_size = 0, p_data = p_pes->p_first;
+             p_data != NULL; p_data = p_data->p_next )
+        {
+            i_size += p_data->p_payload_end - p_data->p_payload_start;
+        }
+        p_block = block_New( p_dec, i_size );
+        for( i_size = 0, p_data = p_pes->p_first;
+             p_data != NULL; p_data = p_data->p_next )
+        {
             if( p_data->p_payload_end == p_data->p_payload_start )
                 continue;
             memcpy( p_block->p_buffer + i_size, p_data->p_payload_start,
-                   p_data->p_payload_end - p_data->p_payload_start );
+                    p_data->p_payload_end - p_data->p_payload_start );
             i_size += p_data->p_payload_end - p_data->p_payload_start;
-       }
+        }
 
         p_block->i_pts = p_pes->i_pts;
         p_block->i_dts = p_pes->i_dts;