mirror of
https://github.com/mpv-player/mpv
synced 2025-01-24 19:37:30 +01:00
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.
This commit is contained in:
parent
2dde1af88d
commit
729430387c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user