mpga.c: check/hack to make duration available after preparse

parent c2d4afc4
......@@ -72,6 +72,7 @@ struct demux_sys_t
int i_xing_bytes;
int i_xing_bitrate_avg;
int i_xing_frame_samples;
block_t *p_block_in, *p_block_out;
};
static int HeaderCheck( uint32_t h )
......@@ -114,12 +115,13 @@ static int Open( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
vlc_bool_t b_forced = VLC_FALSE;
vlc_bool_t b_forced = VLC_FALSE;
uint32_t header;
uint8_t *p_peek;
module_t *p_id3;
vlc_meta_t *p_meta = NULL;
block_t *p_block_in, *p_block_out;
if( p_demux->psz_path )
{
......@@ -266,6 +268,30 @@ static int Open( vlc_object_t * p_this )
}
}
if( ( p_block_in = stream_Block( p_demux->s, MPGA_PACKET_SIZE ) ) == NULL )
{
return VLC_EGENERIC;
}
p_block_in->i_pts = p_block_in->i_dts = 1;
p_block_out = p_sys->p_packetizer->pf_packetize(
p_sys->p_packetizer, &p_block_in );
p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
p_sys->p_es = es_out_Add( p_demux->out,
&p_sys->p_packetizer->fmt_out);
p_sys->i_bitrate_avg = p_sys->p_packetizer->fmt_out.i_bitrate;
if( p_sys->i_xing_bytes && p_sys->i_xing_frames &&
p_sys->i_xing_frame_samples )
{
p_sys->i_bitrate_avg = p_sys->i_xing_bytes * I64C(8) *
p_sys->p_packetizer->fmt_out.audio.i_rate /
p_sys->i_xing_frames / p_sys->i_xing_frame_samples;
}
p_sys->p_block_in = p_block_in;
p_sys->p_block_out = p_block_out;
return VLC_SUCCESS;
}
......@@ -278,39 +304,31 @@ static int Demux( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_block_in, *p_block_out;
if( ( p_block_in = stream_Block( p_demux->s, MPGA_PACKET_SIZE ) ) == NULL )
if( p_sys->b_start )
{
return 0;
p_sys->b_start = VLC_FALSE;
p_block_in = p_sys->p_block_in;
p_block_out = p_sys->p_block_out;
}
else
{
if( ( p_block_in = stream_Block( p_demux->s, MPGA_PACKET_SIZE ) )
== NULL )
{
return 0;
}
p_block_in->i_pts = p_block_in->i_dts = 0;
p_block_out = p_sys->p_packetizer->pf_packetize(
p_sys->p_packetizer, &p_block_in );
}
p_block_in->i_pts = p_block_in->i_dts = p_sys->b_start ? 1 : 0;
p_sys->b_start = VLC_FALSE;
while( (p_block_out = p_sys->p_packetizer->pf_packetize(
p_sys->p_packetizer, &p_block_in )) )
while( p_block_out )
{
while( p_block_out )
{
block_t *p_next = p_block_out->p_next;
if( p_sys->p_es == NULL )
{
p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
p_sys->p_es = es_out_Add( p_demux->out,
&p_sys->p_packetizer->fmt_out);
p_sys->i_bitrate_avg = p_sys->p_packetizer->fmt_out.i_bitrate;
if( p_sys->i_xing_bytes && p_sys->i_xing_frames &&
p_sys->i_xing_frame_samples )
{
p_sys->i_bitrate_avg = p_sys->i_xing_bytes * I64C(8) *
p_sys->p_packetizer->fmt_out.audio.i_rate /
p_sys->i_xing_frames / p_sys->i_xing_frame_samples;
}
}
es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts );
p_block_out->p_next = NULL;
......@@ -319,6 +337,8 @@ static int Demux( demux_t *p_demux )
p_block_out = p_next;
}
p_block_out = p_sys->p_packetizer->pf_packetize(
p_sys->p_packetizer, &p_block_in );
}
return 1;
}
......
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