summaryrefslogtreecommitdiffstats
path: root/demux/demux_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-12 21:58:11 +0200
committerwm4 <wm4@nowhere>2013-07-12 22:16:26 +0200
commit3269bd178020c5d821e8b2d1fd807a38d63e93ce (patch)
tree474e0f7a712cc7002984ec1bdda7d445b5fd8c77 /demux/demux_lavf.c
parent311d2f199a7b1f4d819cfb799a0f0f571596b91e (diff)
downloadmpv-3269bd178020c5d821e8b2d1fd807a38d63e93ce.tar.bz2
mpv-3269bd178020c5d821e8b2d1fd807a38d63e93ce.tar.xz
demux: rewrite probing and demuxer initialization
Get rid of the strange and messy reliance on DEMUXER_TYPE_ constants. Instead of having two open functions for the demuxer callbacks (which somehow are both optional, but you can also decide to implement both...), just have one function. This function takes a parameter that tells the demuxer how strictly it should check for the file headers. This is a nice simplification and allows more flexibility. Remove the file extension code. This literally did nothing (anymore). Change demux_lavf so that we check our other builtin demuxers first before libavformat tries to guess by file extension.
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r--demux/demux_lavf.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 0e7690f606..88587f8ce0 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -185,7 +185,7 @@ static char *remove_prefix(char *s, const char **prefixes)
static const char *prefixes[] =
{"ffmpeg://", "lavf://", "avdevice://", "av://", NULL};
-static int lavf_check_file(demuxer_t *demuxer)
+static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
{
struct MPOpts *opts = demuxer->opts;
struct lavfdopts *lavfdopts = &opts->lavfdopts;
@@ -258,7 +258,8 @@ static int lavf_check_file(demuxer_t *demuxer)
min_probe = lavfdopts->probescore;
AVProbeData avpd = {
- .filename = priv->filename,
+ // Disable file-extension matching with normal checks
+ .filename = check <= DEMUX_CHECK_REQUEST ? priv->filename : NULL,
.buf_size = 0,
.buf = av_mallocz(PROBE_BUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE),
};
@@ -493,18 +494,20 @@ static void add_metadata(demuxer_t *demuxer, AVDictionary *metadata)
demux_info_add(demuxer, t->key, t->value);
}
-static int demux_open_lavf(demuxer_t *demuxer)
+static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
{
struct MPOpts *opts = demuxer->opts;
struct lavfdopts *lavfdopts = &opts->lavfdopts;
AVFormatContext *avfc;
AVDictionaryEntry *t = NULL;
- lavf_priv_t *priv = demuxer->priv;
float analyze_duration = 0;
int i;
- // do not allow forcing the demuxer
- if (!priv->avif)
+ if (lavf_check_file(demuxer, check) < 0)
+ return -1;
+
+ lavf_priv_t *priv = demuxer->priv;
+ if (!priv)
return -1;
stream_seek(demuxer->stream, 0);
@@ -904,9 +907,6 @@ const demuxer_desc_t demuxer_desc_lavf = {
.shortdesc = "libavformat",
.author = "Michael Niedermayer",
.comment = "supports many formats, requires libavformat",
- .type = DEMUXER_TYPE_LAVF,
- .safe_check = 1,
- .check_file = lavf_check_file,
.fill_buffer = demux_lavf_fill_buffer,
.open = demux_open_lavf,
.close = demux_close_lavf,