X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Fffmpeg%2Fdemux.c;h=1fc666aba5890130aa54a8226095a1cc2aa780f6;hb=244601ee1e5157c478bd818b49de6765bf393397;hp=fb35b9a7a1a444902e75a06202110c1ade86a61a;hpb=39b7c3aaa034f89c68e57e528a6f8d1b401c6ce6;p=vlc diff --git a/modules/codec/ffmpeg/demux.c b/modules/codec/ffmpeg/demux.c index fb35b9a7a1..1fc666aba5 100644 --- a/modules/codec/ffmpeg/demux.c +++ b/modules/codec/ffmpeg/demux.c @@ -1,7 +1,7 @@ /***************************************************************************** * demux.c: demuxer using ffmpeg (libavformat). ***************************************************************************** - * Copyright (C) 2004 the VideoLAN team + * Copyright (C) 2004-2007 the VideoLAN team * $Id$ * * Authors: Laurent Aimar @@ -25,14 +25,20 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include -#include -#include "vlc_meta.h" +#include +#include +#include /* ffmpeg header */ -#ifdef HAVE_FFMPEG_AVFORMAT_H +#if defined(HAVE_LIBAVFORMAT_AVFORMAT_H) +# include +#elif defined(HAVE_FFMPEG_AVFORMAT_H) # include #elif defined(HAVE_LIBAVFORMAT_TREE) # include @@ -43,7 +49,7 @@ //#define AVFORMAT_DEBUG 1 /* Version checking */ -#if (LIBAVFORMAT_BUILD >= 4629) && (defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE)) +#if defined(HAVE_FFMPEG_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_AVFORMAT_H) || defined(HAVE_LIBAVFORMAT_TREE) /***************************************************************************** * demux_sys_t: demux descriptor @@ -86,6 +92,7 @@ int E_(OpenDemux)( vlc_object_t *p_this ) AVProbeData pd; AVInputFormat *fmt; int i; + vlc_bool_t b_avfmt_nofile; /* Init Probe data */ pd.filename = p_demux->psz_path; @@ -165,6 +172,7 @@ int E_(OpenDemux)( vlc_object_t *p_this ) 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 */ @@ -172,6 +180,7 @@ int E_(OpenDemux)( vlc_object_t *p_this ) 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; } @@ -179,9 +188,11 @@ int E_(OpenDemux)( vlc_object_t *p_this ) 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++ ) { @@ -260,9 +271,15 @@ void E_(CloseDemux)( vlc_object_t *p_this ) { 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 ); } @@ -313,7 +330,7 @@ static int Demux( demux_t *p_demux ) if( pkt.dts > 0 && ( pkt.stream_index == p_sys->i_pcr_tk || p_sys->i_pcr_tk < 0 ) ) - { + { p_sys->i_pcr_tk = pkt.stream_index; p_sys->i_pcr = p_frame->i_dts; @@ -486,15 +503,4 @@ static offset_t IOSeek( void *opaque, offset_t offset, int whence ) return stream_Tell( p_demux->s ); } -#else /* LIBAVFORMAT_BUILD >= 4611 */ - -int E_(OpenDemux)( vlc_object_t *p_this ) -{ - return VLC_EGENERIC; -} - -void E_(CloseDemux)( vlc_object_t *p_this ) -{ -} - -#endif /* LIBAVFORMAT_BUILD >= 4629 */ +#endif /* HAVE_LIBAVFORMAT_AVFORMAT_H */