Commit da897185 authored by François Cartegnie's avatar François Cartegnie 🤞

mux: mp4: split stream muxing

parent d92bb2cc
...@@ -583,18 +583,10 @@ static inline mtime_t dts_fb_pts( const block_t *p_data ) ...@@ -583,18 +583,10 @@ static inline mtime_t dts_fb_pts( const block_t *p_data )
return p_data->i_dts > VLC_TS_INVALID ? p_data->i_dts: p_data->i_pts; return p_data->i_dts > VLC_TS_INVALID ? p_data->i_dts: p_data->i_pts;
} }
static int Mux(sout_mux_t *p_mux) static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_stream)
{ {
sout_mux_sys_t *p_sys = p_mux->p_sys; sout_mux_sys_t *p_sys = p_mux->p_sys;
for (;;) {
int i_stream = sout_MuxGetStream(p_mux, 2, NULL);
if (i_stream < 0)
return(VLC_SUCCESS);
sout_input_t *p_input = p_mux->pp_inputs[i_stream];
mp4_stream_t *p_stream = (mp4_stream_t*)p_input->p_sys;
block_t *p_data = BlockDequeue(p_input, p_stream); block_t *p_data = BlockDequeue(p_input, p_stream);
if(!p_data) if(!p_data)
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -632,9 +624,11 @@ static int Mux(sout_mux_t *p_mux) ...@@ -632,9 +624,11 @@ static int Mux(sout_mux_t *p_mux)
p_sys->i_start_dts = p_stream->i_first_dts; p_sys->i_start_dts = p_stream->i_first_dts;
} }
if (p_stream->mux.fmt.i_cat != SPU_ES) { if (p_stream->mux.fmt.i_cat != SPU_ES)
{
/* Fix length of the sample */ /* Fix length of the sample */
if (block_FifoCount(p_input->p_fifo) > 0) { if (block_FifoCount(p_input->p_fifo) > 0)
{
block_t *p_next = block_FifoShow(p_input->p_fifo); block_t *p_next = block_FifoShow(p_input->p_fifo);
if ( p_next->i_flags & BLOCK_FLAG_DISCONTINUITY ) if ( p_next->i_flags & BLOCK_FLAG_DISCONTINUITY )
{ /* we have no way to know real length except by decoding */ { /* we have no way to know real length except by decoding */
...@@ -682,9 +676,9 @@ static int Mux(sout_mux_t *p_mux) ...@@ -682,9 +676,9 @@ static int Mux(sout_mux_t *p_mux)
p_stream->i_length_neg += i_recover; p_stream->i_length_neg += i_recover;
} }
} }
else /* SPU_ES */
if (p_stream->mux.fmt.i_cat == SPU_ES && {
p_stream->mux.i_entry_count > 0 && if (p_stream->mux.i_entry_count > 0 &&
p_stream->mux.entry[p_stream->mux.i_entry_count-1].i_length == 0) p_stream->mux.entry[p_stream->mux.i_entry_count-1].i_length == 0)
{ {
/* length of previous spu, stored in spu clearer */ /* length of previous spu, stored in spu clearer */
...@@ -695,6 +689,7 @@ static int Mux(sout_mux_t *p_mux) ...@@ -695,6 +689,7 @@ static int Mux(sout_mux_t *p_mux)
p_stream->mux.entry[p_stream->mux.i_entry_count-1].i_length = i_length; p_stream->mux.entry[p_stream->mux.i_entry_count-1].i_length = i_length;
p_stream->mux.i_read_duration += i_length; p_stream->mux.i_read_duration += i_length;
} }
}
/* Update (Not earlier for SPU!) */ /* Update (Not earlier for SPU!) */
p_stream->i_last_dts = dts_fb_pts( p_data ); p_stream->i_last_dts = dts_fb_pts( p_data );
...@@ -726,13 +721,13 @@ static int Mux(sout_mux_t *p_mux) ...@@ -726,13 +721,13 @@ static int Mux(sout_mux_t *p_mux)
sout_AccessOutWrite(p_mux->p_access, p_data); sout_AccessOutWrite(p_mux->p_access, p_data);
/* Add SPU clearing tag (duration tb fixed on next SPU or stream end )*/ /* Add SPU clearing tag (duration tb fixed on next SPU or stream end )*/
if (p_stream->mux.fmt.i_cat == SPU_ES) if (p_stream->mux.fmt.i_cat == SPU_ES )
{ {
block_t *p_empty = NULL; block_t *p_empty = NULL;
if(p_stream->mux.fmt.i_codec == VLC_CODEC_SUBT) if(p_stream->mux.fmt.i_codec == VLC_CODEC_SUBT)
{ {
p_empty = block_Alloc(3); p_empty = block_Alloc(3);
if (p_empty) if(p_empty)
{ {
/* point to start of our empty */ /* point to start of our empty */
p_stream->i_last_dts += e->i_length; p_stream->i_last_dts += e->i_length;
...@@ -763,9 +758,27 @@ static int Mux(sout_mux_t *p_mux) ...@@ -763,9 +758,27 @@ static int Mux(sout_mux_t *p_mux)
/* Update the global segment/media duration */ /* Update the global segment/media duration */
if( p_stream->mux.i_read_duration > p_sys->i_read_duration ) if( p_stream->mux.i_read_duration > p_sys->i_read_duration )
p_sys->i_read_duration = p_stream->mux.i_read_duration; p_sys->i_read_duration = p_stream->mux.i_read_duration;
}
return(VLC_SUCCESS); return VLC_SUCCESS;
}
static int Mux(sout_mux_t *p_mux)
{
int i_ret = VLC_SUCCESS;
do
{
int i_stream = sout_MuxGetStream(p_mux, 2, NULL);
if (i_stream < 0)
break;
sout_input_t *p_input = p_mux->pp_inputs[i_stream];
mp4_stream_t *p_stream = (mp4_stream_t*)p_input->p_sys;
i_ret = MuxStream(p_mux, p_input, p_stream);
} while( i_ret == VLC_SUCCESS );
return i_ret;
} }
/***************************************************************************** /*****************************************************************************
......
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