summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-10-03 00:22:18 +0200
committerwm4 <wm4@nowhere>2019-10-03 00:22:18 +0200
commit1c63869d0ae01fd8e720353719e4c8b8da12e0b5 (patch)
tree942771789b91389636d2d65baa1238ab9b992a86 /demux/demux.c
parent8c58375dbd968fff22c9ef5a473c456657c5fc78 (diff)
downloadmpv-1c63869d0ae01fd8e720353719e4c8b8da12e0b5.tar.bz2
mpv-1c63869d0ae01fd8e720353719e4c8b8da12e0b5.tar.xz
demux: restore some of the DVD/BD/CDDA interaction layers
This partially reverts commit a9d83eac40c94f44d19fab7b6955331f10efe301 ("Remove optical disc fancification layers"). Mostly due to the timestamp crap, this was never really going to work. The playback layer is sensitive to timestamps, and derives the playback time directly from the low level packet timestamps. DVD/BD works differently, and libdvdnav/libbluray do not make it easy at all to compensate for this. Which is why it never worked well, but not doing it at all is even more awful. demux_disc.c tried this and rewrote packet timestamps from low level TS to playback time. So restore demux_disc.c, which should bring behavior back to the old often non-working but slightly better state. I did not revert anything that affects components above the demuxer layer. For example, the properties for switching DVD angles or listing disc titles are still gone. (Disc titles could be reimplemented as editions. But not by me.) This commit modifies the reverted code a bit; this can't be avoided, because the internal API changed quite a bit. The old seek resync in demux_lavf.c (which was a hack) is replaced with a hack. SEEK_FORCE and demux_params.external_stream are new additions. Some of this could/should be further cleaned up. If you don't want "proper" DVD/BD support to disappear, you should probably volunteer. Now why am I wasting my time for this? Just because some idiot users are too lazy to rip their ever-wearing out shitty physical discs? Then why should I not be lazy and drop support completely? They won't even be thankful for me maintaining this horrible garbage for no compensation.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 3d3c1d0f19..01f15de496 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -58,12 +58,14 @@ extern const demuxer_desc_t demuxer_desc_mf;
extern const demuxer_desc_t demuxer_desc_matroska;
extern const demuxer_desc_t demuxer_desc_lavf;
extern const demuxer_desc_t demuxer_desc_playlist;
+extern const demuxer_desc_t demuxer_desc_disc;
extern const demuxer_desc_t demuxer_desc_rar;
extern const demuxer_desc_t demuxer_desc_libarchive;
extern const demuxer_desc_t demuxer_desc_null;
extern const demuxer_desc_t demuxer_desc_timeline;
static const demuxer_desc_t *const demuxer_list[] = {
+ &demuxer_desc_disc,
&demuxer_desc_edl,
&demuxer_desc_cue,
&demuxer_desc_rawaudio,
@@ -263,6 +265,8 @@ struct demux_internal {
struct mp_recorder *dumper;
int dumper_status;
+ bool owns_stream;
+
// -- Access from demuxer thread only
bool enable_recording;
struct mp_recorder *recorder;
@@ -1084,7 +1088,8 @@ static void demux_shutdown(struct demux_internal *in)
talloc_free(in->cache);
in->cache = NULL;
- free_stream(demuxer->stream);
+ if (in->owns_stream)
+ free_stream(demuxer->stream);
demuxer->stream = NULL;
}
@@ -3105,7 +3110,7 @@ void demux_close_stream(struct demuxer *demuxer)
struct demux_internal *in = demuxer->in;
assert(!in->threading && demuxer == in->d_thread);
- if (!demuxer->stream)
+ if (!demuxer->stream || !in->owns_stream)
return;
MP_VERBOSE(demuxer, "demuxer read all data; closing stream\n");
@@ -3197,6 +3202,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
.highest_av_pts = MP_NOPTS_VALUE,
.seeking_in_progress = MP_NOPTS_VALUE,
.demux_ts = MP_NOPTS_VALUE,
+ .owns_stream = !params->external_stream,
};
pthread_mutex_init(&in->lock, NULL);
pthread_cond_init(&in->wakeup, NULL);
@@ -3369,11 +3375,14 @@ struct demuxer *demux_open_url(const char *url,
struct mp_cancel *priv_cancel = mp_cancel_new(NULL);
if (cancel)
mp_cancel_set_parent(priv_cancel, cancel);
- struct stream *s = stream_create(url, STREAM_READ | params->stream_flags,
- priv_cancel, global);
- if (s && params->init_fragment.len) {
- s = create_webshit_concat_stream(global, priv_cancel,
- params->init_fragment, s);
+ struct stream *s = params->external_stream;
+ if (!s) {
+ s = stream_create(url, STREAM_READ | params->stream_flags,
+ priv_cancel, global);
+ if (s && params->init_fragment.len) {
+ s = create_webshit_concat_stream(global, priv_cancel,
+ params->init_fragment, s);
+ }
}
if (!s) {
talloc_free(priv_cancel);
@@ -3385,7 +3394,8 @@ struct demuxer *demux_open_url(const char *url,
assert(d->cancel);
} else {
params->demuxer_failed = true;
- free_stream(s);
+ if (!params->external_stream)
+ free_stream(s);
talloc_free(priv_cancel);
}
return d;
@@ -3694,6 +3704,9 @@ static bool queue_seek(struct demux_internal *in, double seek_pts, int flags,
bool set_backwards = flags & SEEK_SATAN;
flags &= ~(unsigned)SEEK_SATAN;
+ bool force_seek = flags & SEEK_FORCE;
+ flags &= ~(unsigned)SEEK_FORCE;
+
struct demux_cached_range *cache_target =
find_cache_seek_range(in, seek_pts, flags);
@@ -3702,7 +3715,7 @@ static bool queue_seek(struct demux_internal *in, double seek_pts, int flags,
MP_VERBOSE(in, "Cached seek not possible.\n");
return false;
}
- if (!in->d_thread->seekable) {
+ if (!in->d_thread->seekable && !force_seek) {
MP_WARN(in, "Cannot seek in this file.\n");
return false;
}