From 729430387cfaf18e50ec22b8124e151a22110876 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 5 May 2013 19:02:10 +0200 Subject: stream_bluray: general timeline support Uses the same mechanisms as stream_dvd to report the virtual playback time as known by libdvdread/libbluray, instead of the raw demuxer output. This should solve many problems with BD playback, like correct display of playback time and duration. On the other hand, this causes some new problems. For example, the reported stream time has a rather low resolution (1-2 seconds), so doing precise seeking on it is near impossible. --- stream/stream_bluray.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'stream/stream_bluray.c') diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index f0fd37b7b7..27ae5355a3 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -48,6 +48,11 @@ #define BLURAY_DEFAULT_CHAPTER 0 #define BLURAY_DEFAULT_TITLE 0 +// 90khz ticks +#define BD_TIMEBASE (90000) +#define BD_TIME_TO_MP(x) ((x) / (double)(BD_TIMEBASE)) +#define BD_TIME_FROM_MP(x) ((uint64_t)(x * BD_TIMEBASE)) + char *bluray_device = NULL; int bluray_angle = 0; @@ -159,6 +164,31 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg) return r ? 1 : STREAM_UNSUPPORTED; } + case STREAM_CTRL_GET_TIME_LENGTH: { + BLURAY_TITLE_INFO *ti; + + ti = bd_get_title_info(b->bd, b->current_title, b->current_angle); + if (!ti) + return STREAM_UNSUPPORTED; + + *((double *) arg) = BD_TIME_TO_MP(ti->duration); + return STREAM_OK; + } + + case STREAM_CTRL_GET_CURRENT_TIME: { + *((double *) arg) = BD_TIME_TO_MP(bd_tell_time(b->bd)); + return STREAM_OK; + } + + case STREAM_CTRL_SEEK_TO_TIME: { + double pts = *((double *) arg); + bd_seek_time(b->bd, BD_TIME_FROM_MP(pts)); + // Reset mpv internal stream position. + stream_seek(s, bd_tell(b->bd)); + // API makes it hard to determine seeking success + return STREAM_OK; + } + case STREAM_CTRL_GET_NUM_ANGLES: { BLURAY_TITLE_INFO *ti; @@ -225,6 +255,13 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg) bd_free_title_info(ti); return STREAM_ERROR; } + case STREAM_CTRL_GET_START_TIME: + { + *((double *)arg) = 0; + return STREAM_OK; + } + case STREAM_CTRL_MANAGES_TIMELINE: + return STREAM_OK; default: break; -- cgit v1.2.3