* ts.c: MPEG-II TS Muxer
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: ts.c,v 1.36 2003/11/20 18:26:44 fenrir Exp $
+ * $Id: ts.c,v 1.41 2003/11/27 22:44:50 massiot Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
int i_pcr_pid;
sout_input_t *p_pcr_input;
- int i_stream_id_mpga;
- int i_stream_id_mpgv;
-
int i_audio_bound;
int i_video_bound;
srand( (uint32_t)mdate() );
- p_sys->i_stream_id_mpga = 0xc0;
- p_sys->i_stream_id_mpgv = 0xe0;
-
p_sys->i_audio_bound = 0;
p_sys->i_video_bound = 0;
sout_mux_sys_t *p_sys = p_mux->p_sys;
ts_stream_t *p_stream;
- msg_Dbg( p_mux, "adding input codec=%4.4s", (char*)&p_input->p_fmt->i_fourcc );
-
p_input->p_sys = (void*)p_stream = malloc( sizeof( ts_stream_t ) );
/* Init this new stream */
p_stream->i_decoder_specific_info = 0;
p_stream->p_decoder_specific_info = NULL;
+ msg_Dbg( p_mux, "adding input codec=%4.4s pid=%d", (char*)&p_input->p_fmt->i_codec, p_stream->i_pid );
+
/* All others fields depand on codec */
switch( p_input->p_fmt->i_cat )
{
case VIDEO_ES:
- switch( p_input->p_fmt->i_fourcc )
+ switch( p_input->p_fmt->i_codec )
{
case VLC_FOURCC( 'm', 'p','g', 'v' ):
/* TODO: do we need to check MPEG-I/II ? */
p_stream->i_stream_type = 0x02;
- p_stream->i_stream_id = p_sys->i_stream_id_mpgv;
- p_sys->i_stream_id_mpgv++;
+ p_stream->i_stream_id = 0xe0;
break;
case VLC_FOURCC( 'm', 'p','4', 'v' ):
p_stream->i_stream_type = 0x10;
case VLC_FOURCC( 'M', 'J', 'P', 'G' ):
p_stream->i_stream_type = 0xa0; // private
p_stream->i_stream_id = 0xa0; // beurk
- p_stream->i_bih_codec = p_input->p_fmt->i_fourcc;
- p_stream->i_bih_width = p_input->p_fmt->i_width;
- p_stream->i_bih_height = p_input->p_fmt->i_height;
+ p_stream->i_bih_codec = p_input->p_fmt->i_codec;
+ p_stream->i_bih_width = p_input->p_fmt->video.i_width;
+ p_stream->i_bih_height = p_input->p_fmt->video.i_height;
break;
default:
free( p_stream );
break;
case AUDIO_ES:
- switch( p_input->p_fmt->i_fourcc )
+ switch( p_input->p_fmt->i_codec )
{
case VLC_FOURCC( 'm', 'p','g', 'a' ):
- p_stream->i_stream_type = p_input->p_fmt->i_sample_rate >= 32000 ? 0x03 : 0x04;
- p_stream->i_stream_id = p_sys->i_stream_id_mpga;
- p_sys->i_stream_id_mpga++;
+ p_stream->i_stream_type = p_input->p_fmt->audio.i_rate >= 32000 ? 0x03 : 0x04;
+ p_stream->i_stream_id = 0xc0;
break;
case VLC_FOURCC( 'a', '5','2', ' ' ):
p_stream->i_stream_type = 0x81;
p_stream->i_stream_id = 0xbd;
break;
+ case VLC_FOURCC( 'l', 'p','c', 'm' ):
+ p_stream->i_stream_type = 0x83;
+ p_stream->i_stream_id = 0xbd;
+ break;
+ case VLC_FOURCC( 'd', 't','s', ' ' ):
+ p_stream->i_stream_type = 0x85;
+ p_stream->i_stream_id = 0xbd;
+ break;
+
case VLC_FOURCC( 'm', 'p','4', 'a' ):
p_stream->i_stream_type = 0x11;
p_stream->i_stream_id = 0xfa;
break;
case SPU_ES:
- switch( p_input->p_fmt->i_fourcc )
+ switch( p_input->p_fmt->i_codec )
{
case VLC_FOURCC( 's', 'p','u', ' ' ):
p_stream->i_stream_type = 0x82;
- p_stream->i_stream_id = 0x82;
+ p_stream->i_stream_id = 0xbd;
break;
default:
free( p_stream );
}
/* Copy extra data (VOL for MPEG-4 and extra BitMapInfoHeader for VFW */
- p_stream->i_decoder_specific_info = p_input->p_fmt->i_extra_data;
+ p_stream->i_decoder_specific_info = p_input->p_fmt->i_extra;
if( p_stream->i_decoder_specific_info > 0 )
{
p_stream->p_decoder_specific_info =
malloc( p_stream->i_decoder_specific_info );
memcpy( p_stream->p_decoder_specific_info,
- p_input->p_fmt->p_extra_data,
- p_input->p_fmt->i_extra_data );
+ p_input->p_fmt->p_extra,
+ p_input->p_fmt->i_extra );
}
/* Init pes chain */
}
p_sys->i_pcr_pid = p_stream->i_pid;
p_sys->p_pcr_input = p_input;
+
+ msg_Dbg( p_mux, "new PCR PID is %d", p_sys->i_pcr_pid );
}
return VLC_SUCCESS;
ts_stream_t *p_stream;
char *val;
- msg_Dbg( p_mux, "removing input" );
p_stream = (ts_stream_t*)p_input->p_sys;
+ msg_Dbg( p_mux, "removing input pid=%d", p_stream->i_pid );
if( p_sys->i_pcr_pid == p_stream->i_pid )
{
/* Empty TS buffer */
/* FIXME */
}
+ msg_Dbg( p_mux, "new PCR PID is %d", p_sys->i_pcr_pid );
}
/* Empty all data in chain_pes */
if ( i_pid_video == p_stream->i_pid )
{
p_sys->i_pid_video = i_pid_video;
+ msg_Dbg( p_mux, "freeing video PID %d", i_pid_video );
}
}
if( ( val = sout_cfg_find_value( p_mux->p_cfg, "pid-audio" ) ) )
if ( i_pid_audio == p_stream->i_pid )
{
p_sys->i_pid_audio = i_pid_audio;
+ msg_Dbg( p_mux, "freeing audio PID %d", i_pid_audio );
}
}
free( p_stream );
sout_input_t *p_input = p_mux->pp_inputs[i];
ts_stream_t *p_stream = (ts_stream_t*)p_input->p_sys;
- if( p_stream->i_pes_length <= p_sys->i_caching_delay ||
+ if( ( p_stream == p_pcr_stream && p_stream->i_pes_length <= p_sys->i_caching_delay ) ||
p_stream->i_pes_dts + p_stream->i_pes_length < p_pcr_stream->i_pes_dts + p_pcr_stream->i_pes_length )
{
/* Need more data */
b_ok = VLC_FALSE;
p_data = sout_FifoGet( p_input->p_fifo );
+ if( p_input->p_fifo->i_depth > 0 )
+ {
+ sout_buffer_t *p_next = sout_FifoShow( p_input->p_fifo );
+
+ p_data->i_length = p_next->i_dts - p_data->i_dts;
+ }
if( ( p_pcr_stream->i_pes_dts > 0 && p_data->i_dts - 2000000 > p_pcr_stream->i_pes_dts + p_pcr_stream->i_pes_length ) ||
p_data->i_dts < p_stream->i_pes_dts ||