demux: use talloc for sh_* structs and "lang" field
[mplayer.git] / libmpdemux / demux_edl.c
blob4c864cfe425bdb0cea21e4963df8509e473c6455
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <stdlib.h>
20 #include <stdbool.h>
21 #include <string.h>
23 #include "demuxer.h"
24 #include "stream/stream.h"
26 static int try_open_file(struct demuxer *demuxer)
28 struct stream *s = demuxer->stream;
29 const char header[] = "mplayer EDL file";
30 const int len = sizeof(header) - 1;
31 char buf[len];
32 if (stream_read(s, buf, len) < len)
33 return 0;
34 if (strncmp(buf, header, len))
35 return 0;
36 stream_seek(s, 0);
37 demuxer->file_contents = stream_read_complete(s, demuxer, 1000000, 0);
38 if (demuxer->file_contents.start == NULL)
39 return 0;
40 return DEMUXER_TYPE_EDL;
43 static int dummy_fill_buffer(struct demuxer *demuxer, struct demux_stream *ds)
45 return 0;
48 const struct demuxer_desc demuxer_desc_edl = {
49 .info = "EDL file demuxer",
50 .name = "edl",
51 .shortdesc = "EDL",
52 .author = "Uoti Urpala",
53 .comment = "",
54 .type = DEMUXER_TYPE_EDL,
55 .safe_check = true,
56 .check_file = try_open_file, // no separate .open
57 .fill_buffer = dummy_fill_buffer,