Commit 1e8a2b5c authored by Rafaël Carré's avatar Rafaël Carré

TS Mux: split Mux()

parent 8917116d
...@@ -1247,29 +1247,12 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -1247,29 +1247,12 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/***************************************************************************** /* returns true if needs more data */
* Mux: Call each time there is new data for at least one stream static bool MuxStreams(sout_mux_t *p_mux )
*****************************************************************************
*
*****************************************************************************/
static int Mux( sout_mux_t *p_mux )
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
ts_stream_t *p_pcr_stream; ts_stream_t *p_pcr_stream = (ts_stream_t*)p_sys->p_pcr_input->p_sys;
if( p_sys->i_pcr_pid == 0x1fff )
{
for (int i = 0; i < p_mux->i_nb_inputs; i++ )
{
block_FifoEmpty( p_mux->pp_inputs[i]->p_fifo );
}
msg_Dbg( p_mux, "waiting for PCR streams" );
return VLC_SUCCESS;
}
p_pcr_stream = (ts_stream_t*)p_sys->p_pcr_input->p_sys;
for (;;)
{
sout_buffer_chain_t chain_ts; sout_buffer_chain_t chain_ts;
mtime_t i_shaping_delay = p_pcr_stream->b_key_frame mtime_t i_shaping_delay = p_pcr_stream->b_key_frame
? p_pcr_stream->i_pes_length ? p_pcr_stream->i_pes_length
...@@ -1299,11 +1282,12 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -1299,11 +1282,12 @@ static int Mux( sout_mux_t *p_mux )
p_input = p_mux->pp_inputs[i]; p_input = p_mux->pp_inputs[i];
p_stream = (ts_stream_t*)p_input->p_sys; p_stream = (ts_stream_t*)p_input->p_sys;
if( ( ( p_stream == p_pcr_stream ) && if( ( p_stream != p_pcr_stream ||
( p_stream->i_pes_length < i_shaping_delay ) ) || p_stream->i_pes_length >= i_shaping_delay ) &&
( p_stream->i_pes_dts + p_stream->i_pes_length < p_stream->i_pes_dts + p_stream->i_pes_length >=
p_pcr_stream->i_pes_dts + p_pcr_stream->i_pes_length ) ) p_pcr_stream->i_pes_dts + p_pcr_stream->i_pes_length )
{ continue;
/* Need more data */ /* Need more data */
if( block_FifoCount( p_input->p_fifo ) <= 1 ) if( block_FifoCount( p_input->p_fifo ) <= 1 )
{ {
...@@ -1311,7 +1295,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -1311,7 +1295,7 @@ static int Mux( sout_mux_t *p_mux )
( p_input->p_fmt->i_cat == VIDEO_ES ) ) ( p_input->p_fmt->i_cat == VIDEO_ES ) )
{ {
/* We need more data */ /* We need more data */
return VLC_SUCCESS; return true;
} }
else if( block_FifoCount( p_input->p_fifo ) <= 0 ) else if( block_FifoCount( p_input->p_fifo ) <= 0 )
{ {
...@@ -1504,11 +1488,10 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -1504,11 +1488,10 @@ static int Mux( sout_mux_t *p_mux )
} }
} }
} }
}
/* save */ /* save */
mtime_t i_pcr_dts = p_pcr_stream->i_pes_dts; const mtime_t i_pcr_dts = p_pcr_stream->i_pes_dts;
mtime_t i_pcr_length = p_pcr_stream->i_pes_length; const mtime_t i_pcr_length = p_pcr_stream->i_pes_length;
p_pcr_stream->b_key_frame = 0; p_pcr_stream->b_key_frame = 0;
/* msg_Dbg( p_mux, "starting muxing %lldms", i_pcr_length / 1000 ); */ /* msg_Dbg( p_mux, "starting muxing %lldms", i_pcr_length / 1000 ); */
...@@ -1610,7 +1593,31 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -1610,7 +1593,31 @@ static int Mux( sout_mux_t *p_mux )
/* 4: date and send */ /* 4: date and send */
TSSchedule( p_mux, &chain_ts, i_pcr_length, i_pcr_dts ); TSSchedule( p_mux, &chain_ts, i_pcr_length, i_pcr_dts );
return false;
}
/*****************************************************************************
* Mux: Call each time there is new data for at least one stream
*****************************************************************************
*
*****************************************************************************/
static int Mux( sout_mux_t *p_mux )
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
if( p_sys->i_pcr_pid == 0x1fff )
{
for (int i = 0; i < p_mux->i_nb_inputs; i++ )
{
block_FifoEmpty( p_mux->pp_inputs[i]->p_fifo );
} }
msg_Dbg( p_mux, "waiting for PCR streams" );
return VLC_SUCCESS;
}
while (!MuxStreams(p_mux))
;
return VLC_SUCCESS;
} }
#define STD_PES_PAYLOAD 170 #define STD_PES_PAYLOAD 170
......
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