diff options
author | wm4 <wm4@nowhere> | 2014-11-16 18:51:11 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-16 18:51:56 +0100 |
commit | 4cf1843664e1b5cf2b233668fb830e5ecaac7388 (patch) | |
tree | 3f809aabebdae74307e9bb07a6f011fb37c96d79 /demux | |
parent | 78cbbb4c49c76558eea3397d7fd0f90978248210 (diff) | |
download | mpv-4cf1843664e1b5cf2b233668fb830e5ecaac7388.tar.bz2 mpv-4cf1843664e1b5cf2b233668fb830e5ecaac7388.tar.xz |
demux_mkv: check file type without actually reading data
Do a minimal check on data read with stream_peek(). This could help with
probing from unseekable streams in some situations. (We could check the
entire EBML and Matroska headers, but probably not worth the trouble. We
could also seek back to the start, which demux.c doesn't do, but which
would work usually - also not worth the trouble.)
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux_mkv.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 100447d1f7..36ca0277ba 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1757,6 +1757,13 @@ static int demux_mkv_open(demuxer_t *demuxer, enum demux_check check) int64_t start_pos; int64_t end_pos; + bstr start = stream_peek(s, 4); + uint32_t start_id; + for (int n = 0; n < start.len; n++) + start_id = (start_id << 8) | start.start[n]; + if (start_id != EBML_ID_EBML) + return -1; + if (!read_ebml_header(demuxer)) return -1; MP_VERBOSE(demuxer, "Found the head...\n"); |