[vlc-devel] [PATCH] mpeg es demux: call es_out_Add() in Open callback
Rafaël Carré
rafael.carre at gmail.com
Thu Oct 21 17:01:19 CEST 2010
Fix libvlc_get_tracks_info() for mp3 files
---
modules/demux/mpeg/es.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 0103e14..ec2dc64 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -104,6 +104,7 @@ struct demux_sys_t
bool b_big_endian;
bool b_estimate_bitrate;
+ bool b_bitrate_estimated;
int i_bitrate_avg; /* extracted from Xing header */
bool b_initial_sync_failed;
@@ -170,11 +171,11 @@ static int OpenCommon( demux_t *p_demux,
DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
memset( p_sys, 0, sizeof( demux_sys_t ) );
p_sys->codec = *p_codec;
- p_sys->p_es = NULL;
p_sys->b_start = true;
p_sys->i_stream_offset = i_bs_offset;
p_sys->b_estimate_bitrate = true;
p_sys->i_bitrate_avg = 0;
+ p_sys->b_bitrate_estimated = false;
p_sys->b_big_endian = false;
p_sys->f_fps = var_InheritFloat( p_demux, "es-fps" );
@@ -200,6 +201,10 @@ static int OpenCommon( demux_t *p_demux,
free( p_sys );
return VLC_EGENERIC;
}
+
+ p_sys->p_packetizer->fmt_out.b_packetized = true;
+ p_sys->p_es = es_out_Add( p_demux->out, &p_sys->p_packetizer->fmt_out);
+
return VLC_SUCCESS;
}
static int OpenAudio( vlc_object_t *p_this )
@@ -273,13 +278,8 @@ static int Demux( demux_t *p_demux )
{
block_t *p_next = p_block_out->p_next;
- if( !p_sys->p_es )
+ if( !p_sys->b_bitrate_estimated )
{
- p_sys->p_packetizer->fmt_out.b_packetized = true;
- p_sys->p_es = es_out_Add( p_demux->out,
- &p_sys->p_packetizer->fmt_out);
-
-
/* Try the xing header */
if( p_sys->xing.i_bytes && p_sys->xing.i_frames &&
p_sys->xing.i_frame_samples )
@@ -294,6 +294,7 @@ static int Demux( demux_t *p_demux )
/* Use the bitrate as initual value */
if( p_sys->b_estimate_bitrate )
p_sys->i_bitrate_avg = p_sys->p_packetizer->fmt_out.i_bitrate;
+ p_sys->b_bitrate_estimated = true;
}
if( p_sys->p_packetizer->fmt_out.i_cat == VIDEO_ES )
{
--
1.7.3.1
More information about the vlc-devel
mailing list