#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
-#include <vlc/input.h>
-#include "vlc_codec.h"
-#include "vlc_meta.h"
+#include <vlc_demux.h>
+#include <vlc_codec.h>
+#include <vlc_meta.h>
#define MPGA_PACKET_SIZE 1024
p_sys->p_block_out = p_block_out;
/* Parse possible id3 header */
- if( ( p_id3 = module_Need( p_demux, "id3", NULL, 0 ) ) )
+ if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
p_sys->meta = (vlc_meta_t *)p_demux->p_private;
p_demux->p_private = NULL;
{
p_sys->b_start = VLC_FALSE;
p_block_in = p_sys->p_block_in;
+ p_sys->p_block_in = NULL;
p_block_out = p_sys->p_block_out;
+ p_sys->p_block_out = NULL;
}
else
{
DESTROY_PACKETIZER( p_sys->p_packetizer );
if( p_sys->meta ) vlc_meta_Delete( p_sys->meta );
+ if( p_sys->p_block_out ) block_Release( p_sys->p_block_out );
free( p_sys );
}
i_ret = demux2_vaControlHelper( p_demux->s, 0, -1,
p_sys->i_bitrate_avg, 1, i_query,
args );
+ /* No bitrate, we can't have it precisely, but we can compute
+ * a raw approximation with time/position */
+ if( i_ret && i_query == DEMUX_GET_LENGTH &&!p_sys->i_bitrate_avg )
+ {
+ float f_pos = (double)( stream_Tell( p_demux->s ) ) /
+ (double)( stream_Size( p_demux->s ) );
+ /* The first few seconds are guaranteed to be very whacky,
+ * don't bother trying ... Too bad */
+ if( f_pos < 0.01 ||
+ (p_sys->i_pts + p_sys->i_time_offset) < 8000000 )
+ return VLC_EGENERIC;
+
+ pi64 = (int64_t *)va_arg( args, int64_t * );
+ *pi64 = (p_sys->i_pts + p_sys->i_time_offset) / f_pos;
+ return VLC_SUCCESS;
+ }
if( !i_ret && p_sys->i_bitrate_avg > 0 &&
(i_query == DEMUX_SET_POSITION || i_query == DEMUX_SET_TIME) )
{