#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_sout.h>
-#include <vlc_codecs.h>
#include <vlc_block.h>
#include "bits.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int MuxGetStream ( sout_mux_t *, int *, mtime_t * );
static void MuxWritePackHeader ( sout_mux_t *, block_t **, mtime_t );
static void MuxWriteSystemHeader( sout_mux_t *, block_t **, mtime_t );
/* Init this new stream */
switch( p_input->p_fmt->i_codec )
{
- case VLC_CODEC_MP1V:
- p_stream->i_stream_id =
- StreamIdGet( p_sys->stream_id_mpgv, 0xe0, 0xef );
- p_stream->i_stream_type = 0x01; /* ISO/IEC 11172 Video */
- break;
- case VLC_CODEC_MP2V:
case VLC_CODEC_MPGV:
p_stream->i_stream_id =
StreamIdGet( p_sys->stream_id_mpgv, 0xe0, 0xef );
block_t *p_ps, *p_data;
mtime_t i_dts;
- int i_stream;
/* Choose which stream to mux */
- if( MuxGetStream( p_mux, &i_stream, &i_dts ) )
+ int i_stream = sout_MuxGetStream( p_mux, 1, &i_dts );
+ if( i_stream < 0 )
{
return VLC_SUCCESS;
}
block_ChainAppend( p_buf, p_hdr );
}
-
-/*
- * Find stream to be muxed.
- */
-static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
-{
- mtime_t i_dts;
- int i_stream, i;
-
- for( i = 0, i_dts = 0, i_stream = -1; i < p_mux->i_nb_inputs; i++ )
- {
- sout_input_t *p_input = p_mux->pp_inputs[i];
- block_t *p_data;
-
- if( block_FifoCount( p_input->p_fifo ) <= 0 )
- {
- if( p_input->p_fmt->i_cat == AUDIO_ES ||
- p_input->p_fmt->i_cat == VIDEO_ES )
- {
- /* We need that audio+video fifo contain at least 1 packet */
- return VLC_EGENERIC;
- }
-
- /* SPU */
- continue;
- }
-
- p_data = block_FifoShow( p_input->p_fifo );
- if( i_stream == -1 || p_data->i_dts < i_dts )
- {
- i_stream = i;
- i_dts = p_data->i_dts;
- }
- }
-
- *pi_stream = i_stream;
- *pi_dts = i_dts;
-
- return VLC_SUCCESS;
-}