Commit 17b5ee09 authored by Rafaël Carré's avatar Rafaël Carré

move MuxGetStream() to libvlccore, bump plugin ABI

parent ced2f640
......@@ -120,8 +120,8 @@ enum vlc_module_properties
/**
* Current plugin ABI version
*/
# define MODULE_SYMBOL 1_1_0d
# define MODULE_SUFFIX "__1_1_0d"
# define MODULE_SYMBOL 1_1_0e
# define MODULE_SUFFIX "__1_1_0e"
/*****************************************************************************
* Add a few defines. You do not want to read this section. Really.
......
......@@ -183,6 +183,7 @@ VLC_EXPORT( sout_input_t *, sout_MuxAddStream, ( sout_mux_t *, es_format_t *
VLC_EXPORT( void, sout_MuxDeleteStream, ( sout_mux_t *, sout_input_t * ) );
VLC_EXPORT( void, sout_MuxDelete, ( sout_mux_t * ) );
VLC_EXPORT( void, sout_MuxSendBuffer, ( sout_mux_t *, sout_input_t *, block_t * ) );
VLC_EXPORT( int, sout_MuxGetStream, (sout_mux_t *, int , mtime_t *));
static inline int sout_MuxControl( sout_mux_t *p_mux, int i_query, ... )
{
......
......@@ -161,8 +161,6 @@ struct sout_mux_sys_t
char *psz_rating;
};
static int MuxGetStream( sout_mux_t *, int *pi_stream, mtime_t *pi_dts );
static block_t *asf_header_create( sout_mux_t *, bool );
static block_t *asf_packet_create( sout_mux_t *, asf_track_t *, block_t * );
static block_t *asf_stream_end_create( sout_mux_t *);
......@@ -695,12 +693,12 @@ static int Mux( sout_mux_t *p_mux )
{
sout_input_t *p_input;
asf_track_t *tk;
int i_stream;
mtime_t i_dts;
block_t *data;
block_t *pk;
if( MuxGetStream( p_mux, &i_stream, &i_dts ) )
int i_stream = sout_MuxGetStream( p_mux, 1, &i_dts );
if( i_stream < 0 )
{
/* not enough data */
return VLC_SUCCESS;
......@@ -747,43 +745,6 @@ static int Mux( sout_mux_t *p_mux )
return VLC_SUCCESS;
}
static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
{
mtime_t i_dts;
int i_stream;
int 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;
}
/****************************************************************************
* Asf header construction
****************************************************************************/
......
......@@ -452,44 +452,6 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
return VLC_SUCCESS;
}
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++ )
{
block_fifo_t *p_fifo = p_mux->pp_inputs[i]->p_fifo;
block_t *p_buf;
if( block_FifoCount( p_fifo ) <= 1 )
{
if( p_mux->pp_inputs[i]->p_fmt->i_cat != SPU_ES )
{
return -1; // wait that all fifo have at least 2 packets
}
/* For SPU, we wait only 1 packet */
continue;
}
p_buf = block_FifoShow( p_fifo );
if( i_stream < 0 || p_buf->i_dts < i_dts )
{
i_dts = p_buf->i_dts;
i_stream = i;
}
}
if( pi_stream )
{
*pi_stream = i_stream;
}
if( pi_dts )
{
*pi_dts = i_dts;
}
return i_stream;
}
/*****************************************************************************
* Mux:
*****************************************************************************/
......@@ -500,12 +462,12 @@ static int Mux( sout_mux_t *p_mux )
for( ;; )
{
sout_input_t *p_input;
int i_stream;
mp4_stream_t *p_stream;
block_t *p_data;
mtime_t i_dts;
if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
int i_stream = sout_MuxGetStream( p_mux, 2, &i_dts);
if( i_stream < 0 )
{
return( VLC_SUCCESS );
}
......
......@@ -89,7 +89,6 @@ static int Mux ( sout_mux_t * );
/*****************************************************************************
* 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 );
......@@ -457,10 +456,10 @@ static int Mux( sout_mux_t *p_mux )
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;
}
......@@ -799,43 +798,3 @@ static void MuxWritePSM( sout_mux_t *p_mux, block_t **p_buf, mtime_t i_dts )
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;
}
......@@ -127,43 +127,6 @@ typedef struct
} oggds_header_t;
/*
* TODO move this function to src/stream_output.c (used by nearly all muxers)
*/
static int MuxGetStream( sout_mux_t *p_mux, int *pi_stream, mtime_t *pi_dts )
{
mtime_t i_dts = 0;
int i_stream = -1;
for( int i = 0; i < p_mux->i_nb_inputs; i++ )
{
block_fifo_t *p_fifo;
p_fifo = p_mux->pp_inputs[i]->p_fifo;
/* We don't really need to have anything in the SPU fifo */
if( p_mux->pp_inputs[i]->p_fmt->i_cat == SPU_ES &&
block_FifoCount( p_fifo ) == 0 ) continue;
if( block_FifoCount( p_fifo ) )
{
block_t *p_buf;
p_buf = block_FifoShow( p_fifo );
if( i_stream < 0 || p_buf->i_dts < i_dts )
{
i_dts = p_buf->i_dts;
i_stream = i;
}
}
else return -1;
}
if( pi_stream ) *pi_stream = i_stream;
if( pi_dts ) *pi_dts = i_dts;
return i_stream;
}
/*****************************************************************************
* Definitions of structures and functions used by this plugins
*****************************************************************************/
......@@ -896,13 +859,12 @@ static int Mux( sout_mux_t *p_mux )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
block_t *p_og = NULL;
int i_stream;
mtime_t i_dts;
if( p_sys->i_add_streams || p_sys->i_del_streams )
{
/* Open new ogg stream */
if( MuxGetStream( p_mux, &i_stream, &i_dts) < 0 )
if( sout_MuxGetStream( p_mux, 1, &i_dts) < 0 )
{
msg_Dbg( p_mux, "waiting for data..." );
return VLC_SUCCESS;
......@@ -941,7 +903,9 @@ static int Mux( sout_mux_t *p_mux )
for( ;; )
{
if( MuxGetStream( p_mux, &i_stream, 0 ) < 0 ) return VLC_SUCCESS;
int i_stream = sout_MuxGetStream( p_mux, 1, NULL );
if( i_stream < 0 )
return VLC_SUCCESS;
MuxBlock( p_mux, p_mux->pp_inputs[i_stream] );
}
......
......@@ -615,6 +615,44 @@ void sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
p_mux->pf_mux( p_mux );
}
/*****************************************************************************
* sout_MuxGetStream: find stream to be muxed
*****************************************************************************/
int sout_MuxGetStream( sout_mux_t *p_mux, int i_blocks, mtime_t *pi_dts )
{
mtime_t i_dts = 0;
int i_stream = -1;
for( int i = 0; 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 ) < i_blocks )
{
if( p_input->p_fmt->i_cat != SPU_ES )
{
return -1;
}
/* FIXME: SPU muxing */
continue;
}
p_data = block_FifoShow( p_input->p_fifo );
if( i_stream < 0 || p_data->i_dts < i_dts )
{
i_stream = i;
i_dts = p_data->i_dts;
}
}
if( pi_dts ) *pi_dts = i_dts;
return i_stream;
}
/*****************************************************************************
*
*****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment