mirror of
https://github.com/mpv-player/mpv
synced 2024-12-10 08:56:04 +00:00
55560d62ee
Playing a .cue file directly will now parse the .cue file, and load and play the file(s) referenced in the cue. If multiple files are referenced, a timeline including all files will be created to create the impression of a single, flat audio file containing all the tracks. For each track, a chapter is created. The chapter navigation commands can be used to jump between tracks. The chapter titles will use the string provided by the track's TITLE cue command. (The -identify command can be used to print all chapters in a not so user friendly way.) Other than the chapter names, there is no attempt at displaying or exposing any other meta data contained in the cue files yet. The handling (or lack of thereof) of gaps (track pregaps and postgaps) is probably not correct yet. In general, mplayer's mapping of tracks to the source audio files can be verified by examining the timeline, which will be printed when passing the -v switch. Note that this has nothing to do with the old cue:// support. The old code isn't touched, and is still only able to play .cue/.bin pairs. Prefixing a .cue file with cue:// will always invoke the old code, while playing a .cue file directly (i.e. "mplayer file.cue") will always use the new code. Playing audio images (.cue/.bin pairs of files) doesn't work yet.
66 lines
1.9 KiB
C
66 lines
1.9 KiB
C
/*
|
|
* This file is part of MPlayer.
|
|
*
|
|
* 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>
|
|
|
|
#include "bstr.h"
|
|
#include "demuxer.h"
|
|
#include "stream/stream.h"
|
|
|
|
// timeline/tl_cue.c
|
|
bool mp_probe_cue(struct bstr s);
|
|
|
|
#define PROBE_SIZE 512
|
|
|
|
static int try_open_file(struct demuxer *demuxer)
|
|
{
|
|
struct stream *s = demuxer->stream;
|
|
char buf[PROBE_SIZE];
|
|
int len = stream_read(s, buf, sizeof(buf));
|
|
if (len <= 0)
|
|
return 0;
|
|
if (!mp_probe_cue((struct bstr) { buf, len }))
|
|
return 0;
|
|
stream_seek(s, 0);
|
|
demuxer->file_contents = stream_read_complete(s, demuxer, 1000000, 0);
|
|
if (demuxer->file_contents.start == NULL)
|
|
return 0;
|
|
if (!mp_probe_cue((struct bstr) { buf, len }))
|
|
return 0;
|
|
return DEMUXER_TYPE_CUE;
|
|
}
|
|
|
|
static int dummy_fill_buffer(struct demuxer *demuxer, struct demux_stream *ds)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
const struct demuxer_desc demuxer_desc_cue = {
|
|
.info = "CUE file demuxer",
|
|
.name = "cue",
|
|
.shortdesc = "CUE",
|
|
.author = "Uoti Urpala",
|
|
.comment = "",
|
|
.type = DEMUXER_TYPE_CUE,
|
|
.safe_check = true,
|
|
.check_file = try_open_file, // no separate .open
|
|
.fill_buffer = dummy_fill_buffer,
|
|
};
|