2012-01-01 16:45:24 +00:00
|
|
|
/*
|
2013-07-12 20:12:02 +00:00
|
|
|
* Original author: Uoti Urpala
|
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2012-01-01 16:45:24 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2012-01-01 16:45:24 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2012-01-01 16:45:24 +00:00
|
|
|
*
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2012-01-01 16:45:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
2015-02-17 22:48:03 +00:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
2017-04-04 15:45:19 +00:00
|
|
|
#include "osdep/io.h"
|
|
|
|
|
2016-01-11 18:03:40 +00:00
|
|
|
#include "mpv_talloc.h"
|
2012-01-01 16:45:24 +00:00
|
|
|
|
2014-08-29 10:09:04 +00:00
|
|
|
#include "misc/bstr.h"
|
2015-02-17 22:48:03 +00:00
|
|
|
#include "common/msg.h"
|
|
|
|
#include "demux/demux.h"
|
|
|
|
#include "options/path.h"
|
|
|
|
#include "common/common.h"
|
2012-01-01 16:45:24 +00:00
|
|
|
#include "stream/stream.h"
|
2015-02-17 22:48:07 +00:00
|
|
|
#include "timeline.h"
|
2012-01-01 16:45:24 +00:00
|
|
|
|
2015-05-19 19:36:21 +00:00
|
|
|
#include "cue.h"
|
2015-02-17 22:48:03 +00:00
|
|
|
|
2015-05-19 19:36:21 +00:00
|
|
|
#define PROBE_SIZE 512
|
2015-02-17 22:48:03 +00:00
|
|
|
|
2015-02-17 22:49:38 +00:00
|
|
|
struct priv {
|
2015-10-01 19:57:35 +00:00
|
|
|
struct cue_file *f;
|
2015-02-17 22:49:38 +00:00
|
|
|
};
|
|
|
|
|
2015-02-17 22:48:07 +00:00
|
|
|
static void add_source(struct timeline *tl, struct demuxer *d)
|
2015-02-17 22:48:03 +00:00
|
|
|
{
|
2015-02-17 22:48:07 +00:00
|
|
|
MP_TARRAY_APPEND(tl, tl->sources, tl->num_sources, d);
|
2015-02-17 22:48:03 +00:00
|
|
|
}
|
|
|
|
|
2015-02-17 22:48:07 +00:00
|
|
|
static bool try_open(struct timeline *tl, char *filename)
|
2015-02-17 22:48:03 +00:00
|
|
|
{
|
|
|
|
struct bstr bfilename = bstr0(filename);
|
|
|
|
// Avoid trying to open itself or another .cue file. Best would be
|
|
|
|
// to check the result of demuxer auto-detection, but the demuxer
|
|
|
|
// API doesn't allow this without opening a full demuxer.
|
|
|
|
if (bstr_case_endswith(bfilename, bstr0(".cue"))
|
2015-02-17 22:48:07 +00:00
|
|
|
|| bstrcasecmp(bstr0(tl->demuxer->filename), bfilename) == 0)
|
2015-02-17 22:48:03 +00:00
|
|
|
return false;
|
|
|
|
|
2015-06-24 19:26:06 +00:00
|
|
|
struct demuxer *d = demux_open_url(filename, NULL, tl->cancel, tl->global);
|
2015-02-17 22:48:03 +00:00
|
|
|
// Since .bin files are raw PCM data with no headers, we have to explicitly
|
|
|
|
// open them. Also, try to avoid to open files that are most likely not .bin
|
|
|
|
// files, as that would only play noise. Checking the file extension is
|
|
|
|
// fragile, but it's about the only way we have.
|
|
|
|
// TODO: maybe also could check if the .bin file is a multiple of the Audio
|
|
|
|
// CD sector size (2352 bytes)
|
|
|
|
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
|
2015-02-17 22:48:07 +00:00
|
|
|
MP_WARN(tl, "CUE: Opening as BIN file!\n");
|
2015-02-20 20:21:14 +00:00
|
|
|
struct demuxer_params p = {.force_format = "rawaudio"};
|
2015-06-24 19:26:06 +00:00
|
|
|
d = demux_open_url(filename, &p, tl->cancel, tl->global);
|
2015-02-17 22:48:03 +00:00
|
|
|
}
|
|
|
|
if (d) {
|
2015-02-17 22:48:07 +00:00
|
|
|
add_source(tl, d);
|
2015-02-17 22:48:03 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-02-17 22:48:07 +00:00
|
|
|
MP_ERR(tl, "Could not open source '%s'!\n", filename);
|
2015-02-17 22:48:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-24 12:18:51 +00:00
|
|
|
static bool open_source(struct timeline *tl, char *filename)
|
2015-02-17 22:48:03 +00:00
|
|
|
{
|
|
|
|
void *ctx = talloc_new(NULL);
|
|
|
|
bool res = false;
|
|
|
|
|
2015-02-17 22:48:07 +00:00
|
|
|
struct bstr dirname = mp_dirname(tl->demuxer->filename);
|
2015-02-17 22:48:03 +00:00
|
|
|
|
2015-06-24 12:18:51 +00:00
|
|
|
struct bstr base_filename = bstr0(mp_basename(filename));
|
2015-02-17 22:48:03 +00:00
|
|
|
if (!base_filename.len) {
|
2015-02-17 22:48:07 +00:00
|
|
|
MP_WARN(tl, "CUE: Invalid audio filename in .cue file!\n");
|
2015-02-17 22:48:03 +00:00
|
|
|
} else {
|
2015-05-09 13:26:47 +00:00
|
|
|
char *fullname = mp_path_join_bstr(ctx, dirname, base_filename);
|
2015-02-17 22:48:07 +00:00
|
|
|
if (try_open(tl, fullname)) {
|
2015-02-17 22:48:03 +00:00
|
|
|
res = true;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try an audio file with the same name as the .cue file (but different
|
|
|
|
// extension).
|
|
|
|
// Rationale: this situation happens easily if the audio file or both files
|
|
|
|
// are renamed.
|
|
|
|
|
|
|
|
struct bstr cuefile =
|
2015-02-17 22:48:07 +00:00
|
|
|
bstr_strip_ext(bstr0(mp_basename(tl->demuxer->filename)));
|
2015-02-17 22:48:03 +00:00
|
|
|
|
|
|
|
DIR *d = opendir(bstrdup0(ctx, dirname));
|
|
|
|
if (!d)
|
|
|
|
goto out;
|
|
|
|
struct dirent *de;
|
|
|
|
while ((de = readdir(d))) {
|
|
|
|
char *dename0 = de->d_name;
|
|
|
|
struct bstr dename = bstr0(dename0);
|
|
|
|
if (bstr_case_startswith(dename, cuefile)) {
|
2015-02-17 22:48:07 +00:00
|
|
|
MP_WARN(tl, "CUE: No useful audio filename "
|
2015-02-17 22:48:03 +00:00
|
|
|
"in .cue file found, trying with '%s' instead!\n",
|
|
|
|
dename0);
|
2015-05-09 13:26:47 +00:00
|
|
|
if (try_open(tl, mp_path_join_bstr(ctx, dirname, dename))) {
|
2015-02-17 22:48:03 +00:00
|
|
|
res = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(d);
|
|
|
|
|
|
|
|
out:
|
|
|
|
talloc_free(ctx);
|
|
|
|
if (!res)
|
2015-02-17 22:48:07 +00:00
|
|
|
MP_ERR(tl, "CUE: Could not open audio file!\n");
|
2015-02-17 22:48:03 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-02-17 22:48:07 +00:00
|
|
|
static void build_timeline(struct timeline *tl)
|
2015-02-17 22:48:03 +00:00
|
|
|
{
|
2015-02-17 22:49:38 +00:00
|
|
|
struct priv *p = tl->demuxer->priv;
|
|
|
|
|
2015-02-17 22:48:03 +00:00
|
|
|
void *ctx = talloc_new(NULL);
|
|
|
|
|
2015-02-17 22:48:07 +00:00
|
|
|
add_source(tl, tl->demuxer);
|
|
|
|
|
2015-12-17 07:40:21 +00:00
|
|
|
struct cue_track *tracks = NULL;
|
|
|
|
size_t track_count = 0;
|
|
|
|
|
|
|
|
for (size_t n = 0; n < p->f->num_tracks; n++) {
|
|
|
|
struct cue_track *track = &p->f->tracks[n];
|
|
|
|
if (track->filename) {
|
|
|
|
MP_TARRAY_APPEND(ctx, tracks, track_count, *track);
|
|
|
|
} else {
|
|
|
|
MP_WARN(tl->demuxer, "No file specified for track entry %zd. "
|
|
|
|
"It will be removed\n", n + 1);
|
|
|
|
}
|
|
|
|
}
|
2015-02-17 22:48:03 +00:00
|
|
|
|
|
|
|
if (track_count == 0) {
|
2015-02-17 22:48:07 +00:00
|
|
|
MP_ERR(tl, "CUE: no tracks found!\n");
|
2015-02-17 22:48:03 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove duplicate file entries. This might be too sophisticated, since
|
|
|
|
// CUE files usually use either separate files for every single track, or
|
|
|
|
// only one file for all tracks.
|
|
|
|
|
2015-06-24 12:18:51 +00:00
|
|
|
char **files = 0;
|
2015-02-17 22:48:03 +00:00
|
|
|
size_t file_count = 0;
|
|
|
|
|
|
|
|
for (size_t n = 0; n < track_count; n++) {
|
|
|
|
struct cue_track *track = &tracks[n];
|
|
|
|
track->source = -1;
|
|
|
|
for (size_t file = 0; file < file_count; file++) {
|
2015-06-24 12:18:51 +00:00
|
|
|
if (strcmp(files[file], track->filename) == 0) {
|
2015-02-17 22:48:03 +00:00
|
|
|
track->source = file;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (track->source == -1) {
|
|
|
|
file_count++;
|
2015-06-24 12:18:51 +00:00
|
|
|
files = talloc_realloc(ctx, files, char *, file_count);
|
2015-02-17 22:48:03 +00:00
|
|
|
files[file_count - 1] = track->filename;
|
|
|
|
track->source = file_count - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < file_count; i++) {
|
2015-02-17 22:48:07 +00:00
|
|
|
if (!open_source(tl, files[i]))
|
2015-02-17 22:48:03 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2015-02-17 22:48:07 +00:00
|
|
|
struct timeline_part *timeline = talloc_array_ptrtype(tl, timeline,
|
2015-02-17 22:48:03 +00:00
|
|
|
track_count + 1);
|
2015-02-17 22:48:07 +00:00
|
|
|
struct demux_chapter *chapters = talloc_array_ptrtype(tl, chapters,
|
2015-02-17 22:48:03 +00:00
|
|
|
track_count);
|
|
|
|
double starttime = 0;
|
|
|
|
for (int i = 0; i < track_count; i++) {
|
2015-02-17 22:48:07 +00:00
|
|
|
struct demuxer *source = tl->sources[1 + tracks[i].source];
|
2015-02-17 22:48:03 +00:00
|
|
|
double duration;
|
|
|
|
if (i + 1 < track_count && tracks[i].source == tracks[i + 1].source) {
|
|
|
|
duration = tracks[i + 1].start - tracks[i].start;
|
|
|
|
} else {
|
2017-06-20 11:57:58 +00:00
|
|
|
duration = source->duration;
|
2015-02-17 22:48:03 +00:00
|
|
|
// Two cases: 1) last track of a single-file cue, or 2) any track of
|
|
|
|
// a multi-file cue. We need to do this for 1) only because the
|
|
|
|
// timeline needs to be terminated with the length of the last
|
|
|
|
// track.
|
|
|
|
duration -= tracks[i].start;
|
|
|
|
}
|
|
|
|
if (duration < 0) {
|
2015-02-17 22:48:07 +00:00
|
|
|
MP_WARN(tl, "CUE: Can't get duration of source file!\n");
|
2015-02-17 22:48:03 +00:00
|
|
|
// xxx: do something more reasonable
|
|
|
|
duration = 0.0;
|
|
|
|
}
|
|
|
|
timeline[i] = (struct timeline_part) {
|
|
|
|
.start = starttime,
|
demux_edl, cue, mkv: clean up timeline stuff slightly
Remove the singly linked list hack, replace it with a slightly more
proper data structure. This probably gets rid of a few minor bugs along
the way, caused by the awkward nonsensical sharing/duplication of some
fields.
Another change (because I'm touching everything related to timeline
anyway) is that I'm removing the special semantics for parts[num_parts].
This is now strictly out of bounds, and instead of using the start time
of the next/beyond-last part, there is an end time field now.
Unfortunately, this also requires touching the code for cue and mkv
ordered chapters. From some superficial testing, they still seem to
mostly work.
One observable change is that the "no_chapters" header is per-stream
now, which is arguably more correct, and getting the old behavior would
require adding code to handle it as special-case, so just adjust
ytdl_hook.lua to the new behavior.
2019-01-11 12:52:29 +00:00
|
|
|
.end = starttime + duration,
|
2015-02-17 22:48:03 +00:00
|
|
|
.source_start = tracks[i].start,
|
|
|
|
.source = source,
|
|
|
|
};
|
|
|
|
chapters[i] = (struct demux_chapter) {
|
|
|
|
.pts = timeline[i].start,
|
2015-10-01 19:57:35 +00:00
|
|
|
.metadata = mp_tags_dup(tl, tracks[i].tags),
|
2015-02-17 22:48:03 +00:00
|
|
|
};
|
demux_edl, cue, mkv: clean up timeline stuff slightly
Remove the singly linked list hack, replace it with a slightly more
proper data structure. This probably gets rid of a few minor bugs along
the way, caused by the awkward nonsensical sharing/duplication of some
fields.
Another change (because I'm touching everything related to timeline
anyway) is that I'm removing the special semantics for parts[num_parts].
This is now strictly out of bounds, and instead of using the start time
of the next/beyond-last part, there is an end time field now.
Unfortunately, this also requires touching the code for cue and mkv
ordered chapters. From some superficial testing, they still seem to
mostly work.
One observable change is that the "no_chapters" header is per-stream
now, which is arguably more correct, and getting the old behavior would
require adding code to handle it as special-case, so just adjust
ytdl_hook.lua to the new behavior.
2019-01-11 12:52:29 +00:00
|
|
|
starttime = timeline[i].end;
|
2015-02-17 22:48:03 +00:00
|
|
|
}
|
|
|
|
|
demux_edl, cue, mkv: clean up timeline stuff slightly
Remove the singly linked list hack, replace it with a slightly more
proper data structure. This probably gets rid of a few minor bugs along
the way, caused by the awkward nonsensical sharing/duplication of some
fields.
Another change (because I'm touching everything related to timeline
anyway) is that I'm removing the special semantics for parts[num_parts].
This is now strictly out of bounds, and instead of using the start time
of the next/beyond-last part, there is an end time field now.
Unfortunately, this also requires touching the code for cue and mkv
ordered chapters. From some superficial testing, they still seem to
mostly work.
One observable change is that the "no_chapters" header is per-stream
now, which is arguably more correct, and getting the old behavior would
require adding code to handle it as special-case, so just adjust
ytdl_hook.lua to the new behavior.
2019-01-11 12:52:29 +00:00
|
|
|
struct timeline_par *par = talloc_ptrtype(tl, par);
|
|
|
|
*par = (struct timeline_par){
|
|
|
|
.parts = timeline,
|
|
|
|
.num_parts = track_count,
|
|
|
|
.track_layout = timeline[0].source,
|
2015-02-17 22:48:03 +00:00
|
|
|
};
|
|
|
|
|
2015-02-17 22:48:07 +00:00
|
|
|
tl->chapters = chapters;
|
|
|
|
tl->num_chapters = track_count;
|
demux_edl, cue, mkv: clean up timeline stuff slightly
Remove the singly linked list hack, replace it with a slightly more
proper data structure. This probably gets rid of a few minor bugs along
the way, caused by the awkward nonsensical sharing/duplication of some
fields.
Another change (because I'm touching everything related to timeline
anyway) is that I'm removing the special semantics for parts[num_parts].
This is now strictly out of bounds, and instead of using the start time
of the next/beyond-last part, there is an end time field now.
Unfortunately, this also requires touching the code for cue and mkv
ordered chapters. From some superficial testing, they still seem to
mostly work.
One observable change is that the "no_chapters" header is per-stream
now, which is arguably more correct, and getting the old behavior would
require adding code to handle it as special-case, so just adjust
ytdl_hook.lua to the new behavior.
2019-01-11 12:52:29 +00:00
|
|
|
MP_TARRAY_APPEND(tl, tl->pars, tl->num_pars, par);
|
|
|
|
tl->meta = par->track_layout;
|
2019-01-11 13:10:41 +00:00
|
|
|
tl->format = "cue";
|
2015-02-17 22:48:03 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
talloc_free(ctx);
|
|
|
|
}
|
2012-01-01 16:45:24 +00:00
|
|
|
|
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
|
|
|
{
|
2016-12-04 22:15:31 +00:00
|
|
|
if (!demuxer->access_references)
|
|
|
|
return -1;
|
|
|
|
|
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) {
|
2014-11-16 17:13:41 +00:00
|
|
|
bstr d = stream_peek(s, PROBE_SIZE);
|
|
|
|
if (d.len < 1 || !mp_probe_cue(d))
|
2013-07-12 19:58:11 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2015-02-17 22:49:38 +00:00
|
|
|
struct priv *p = talloc_zero(demuxer, struct priv);
|
|
|
|
demuxer->priv = p;
|
2015-02-18 20:10:43 +00:00
|
|
|
demuxer->fully_read = true;
|
2015-10-01 19:57:35 +00:00
|
|
|
|
|
|
|
bstr data = stream_read_complete(s, p, 1000000);
|
|
|
|
if (data.start == NULL)
|
2013-07-11 18:08:12 +00:00
|
|
|
return -1;
|
2015-10-01 19:57:35 +00:00
|
|
|
p->f = mp_parse_cue(data);
|
|
|
|
talloc_steal(p, p->f);
|
|
|
|
if (!p->f) {
|
|
|
|
MP_ERR(demuxer, "error parsing input file!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
demux: change hack for closing subtitle files early
Subtitles (and a few other file types, like playlists) are not streamed,
but fully read on opening. This means keeping the file handle or network
socket open is a waste of resources and could cause other weird
behavior. This is why there's a hack to close them after opening.
Change this hack to make the demuxer itself do this, which is less
weird. (Until recently, demuxer->stream ownership was more complex,
which is why it was done this way.)
There is some evil shit due to a huge ownership/lifetime mess of various
objects. Especially EDL (the currently only nested demuxer case)
requires being careful about mp_cancel and passing down stream pointers.
As one defensive programming measure, stop accessing the "stream"
variable in open_given_type(), even where it would still work. This
includes removing a redundant line of code, and removing the peak call,
which should not be needed anymore, as the remaining demuxers do this
mostly correctly.
2018-09-07 21:02:36 +00:00
|
|
|
demux_close_stream(demuxer);
|
|
|
|
|
2015-10-01 19:57:35 +00:00
|
|
|
mp_tags_merge(demuxer->metadata, p->f->tags);
|
2013-07-11 18:08:12 +00:00
|
|
|
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",
|
2013-07-12 19:58:11 +00:00
|
|
|
.open = try_open_file,
|
2015-02-17 22:48:07 +00:00
|
|
|
.load_timeline = build_timeline,
|
2012-01-01 16:45:24 +00:00
|
|
|
};
|