/*****************************************************************************
* demux.c: demuxer using ffmpeg (libavformat).
*****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004-2007 the VideoLAN team
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include <vlc/vlc.h>
#include <vlc_demux.h>
#include <vlc_stream.h>
-#include "vlc_meta.h"
+#include <vlc_meta.h>
/* ffmpeg header */
#ifdef HAVE_FFMPEG_AVFORMAT_H
AVProbeData pd;
AVInputFormat *fmt;
int i;
+ vlc_bool_t b_avfmt_nofile;
/* Init Probe data */
pd.filename = p_demux->psz_path;
init_put_byte( &p_sys->io, p_sys->io_buffer, p_sys->io_buffer_size,
0, &p_sys->url, IORead, NULL, IOSeek );
+ b_avfmt_nofile = p_sys->fmt->flags & AVFMT_NOFILE;
p_sys->fmt->flags |= AVFMT_NOFILE; /* libavformat must not fopen/fclose */
/* Open it */
p_sys->fmt, NULL ) )
{
msg_Err( p_demux, "av_open_input_stream failed" );
+ if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
E_(CloseDemux)( p_this );
return VLC_EGENERIC;
}
if( av_find_stream_info( p_sys->ic ) < 0 )
{
msg_Err( p_demux, "av_find_stream_info failed" );
+ if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
E_(CloseDemux)( p_this );
return VLC_EGENERIC;
}
+ if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
for( i = 0; i < p_sys->ic->nb_streams; i++ )
{
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
+ vlc_bool_t b_avfmt_nofile;
FREENULL( p_sys->tk );
+
+ b_avfmt_nofile = p_sys->fmt->flags & AVFMT_NOFILE;
+ p_sys->fmt->flags |= AVFMT_NOFILE; /* libavformat must not fopen/fclose */
if( p_sys->ic ) av_close_input_file( p_sys->ic );
+ if( !b_avfmt_nofile ) p_sys->fmt->flags ^= AVFMT_NOFILE;
+
if( p_sys->io_buffer ) free( p_sys->io_buffer );
free( p_sys );
}
return stream_Tell( p_demux->s );
}
-#else /* HAVE_FFMPEG_AVFORMAT_H */
-
-int E_(OpenDemux)( vlc_object_t *p_this )
-{
- return VLC_EGENERIC;
-}
-
-void E_(CloseDemux)( vlc_object_t *p_this )
-{
-}
-
#endif /* HAVE_FFMPEG_AVFORMAT_H */