diff options
author | wm4 <wm4@nowhere> | 2013-07-12 21:58:11 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-12 22:16:26 +0200 |
commit | 3269bd178020c5d821e8b2d1fd807a38d63e93ce (patch) | |
tree | 474e0f7a712cc7002984ec1bdda7d445b5fd8c77 /demux/demux_edl.c | |
parent | 311d2f199a7b1f4d819cfb799a0f0f571596b91e (diff) | |
download | mpv-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_edl.c')
-rw-r--r-- | demux/demux_edl.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/demux/demux_edl.c b/demux/demux_edl.c index 44fa824193..0f4bf06dbf 100644 --- a/demux/demux_edl.c +++ b/demux/demux_edl.c @@ -23,17 +23,19 @@ #include "demux.h" #include "stream/stream.h" -static int try_open_file(struct demuxer *demuxer) +static int try_open_file(struct demuxer *demuxer, enum demux_check check) { struct stream *s = demuxer->stream; - const char header[] = "mplayer EDL file"; - const int len = sizeof(header) - 1; - char buf[len]; - if (stream_read(s, buf, len) < len) - return -1; - if (strncmp(buf, header, len)) - return -1; - stream_seek(s, 0); + if (check >= DEMUX_CHECK_UNSAFE) { + const char header[] = "mplayer EDL file"; + const int len = sizeof(header) - 1; + char buf[len]; + if (stream_read(s, buf, len) < len) + return -1; + if (strncmp(buf, header, len)) + return -1; + stream_seek(s, 0); + } demuxer->file_contents = stream_read_complete(s, demuxer, 1000000); if (demuxer->file_contents.start == NULL) return -1; @@ -47,6 +49,5 @@ const struct demuxer_desc demuxer_desc_edl = { .author = "Uoti Urpala", .comment = "", .type = DEMUXER_TYPE_EDL, - .safe_check = true, - .check_file = try_open_file, // no separate .open + .open = try_open_file, }; |