2012-01-01 16:45:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
2013-07-12 20:12:02 +00:00
|
|
|
* Original author: Uoti Urpala
|
|
|
|
*
|
2012-01-01 16:45:24 +00:00
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "bstr/bstr.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "demux.h"
|
2012-01-01 16:45:24 +00:00
|
|
|
#include "stream/stream.h"
|
|
|
|
|
|
|
|
// timeline/tl_cue.c
|
|
|
|
bool mp_probe_cue(struct bstr s);
|
|
|
|
|
|
|
|
#define PROBE_SIZE 512
|
|
|
|
|
2013-07-12 19:58:11 +00:00
|
|
|
static int try_open_file(struct demuxer *demuxer, enum demux_check check)
|
2012-01-01 16:45:24 +00:00
|
|
|
{
|
|
|
|
struct stream *s = demuxer->stream;
|
2013-07-12 19:58:11 +00:00
|
|
|
if (check >= DEMUX_CHECK_UNSAFE) {
|
|
|
|
char buf[PROBE_SIZE];
|
|
|
|
int len = stream_read(s, buf, sizeof(buf));
|
|
|
|
if (len <= 0)
|
|
|
|
return -1;
|
|
|
|
if (!mp_probe_cue((struct bstr) { buf, len }))
|
|
|
|
return -1;
|
|
|
|
stream_seek(s, 0);
|
|
|
|
}
|
2013-06-11 10:16:42 +00:00
|
|
|
demuxer->file_contents = stream_read_complete(s, demuxer, 1000000);
|
2012-01-01 16:45:24 +00:00
|
|
|
if (demuxer->file_contents.start == NULL)
|
2013-07-11 18:08:12 +00:00
|
|
|
return -1;
|
|
|
|
return 0;
|
2012-01-01 16:45:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct demuxer_desc demuxer_desc_cue = {
|
|
|
|
.name = "cue",
|
2013-07-12 20:12:02 +00:00
|
|
|
.desc = "CUE sheet",
|
2012-01-01 16:45:24 +00:00
|
|
|
.type = DEMUXER_TYPE_CUE,
|
2013-07-12 19:58:11 +00:00
|
|
|
.open = try_open_file,
|
2012-01-01 16:45:24 +00:00
|
|
|
};
|