summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-05 19:02:10 +0200
committerwm4 <wm4@nowhere>2013-05-09 01:16:04 +0200
commit729430387cfaf18e50ec22b8124e151a22110876 (patch)
tree5a1886a5ae5add22fa0b9d0f394c6789f30cdbe2 /stream
parent2dde1af88d9628fac33fd4f3439afbdaa6eba974 (diff)
downloadmpv-729430387cfaf18e50ec22b8124e151a22110876.tar.bz2
mpv-729430387cfaf18e50ec22b8124e151a22110876.tar.xz
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.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_bluray.c37
1 files changed, 37 insertions, 0 deletions
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;