diff options
-rw-r--r-- | stream/stream_bluray.c | 37 |
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; |