* 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>
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;
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;
}
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;
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
* 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>
*
#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 * );
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 )
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.",
* 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" );
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;