diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2023-02-06 01:25:02 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-08 21:52:42 +0100 |
commit | 3bfef8bfe0d6f196c809d50140c31d4f10a6b533 (patch) | |
tree | 2abf08599869000d35cf72daa7831bf539696eef /Userland/Libraries/LibVideo/Containers/Demuxer.h | |
parent | 275d57eb6f46416dbfacb31ae2867905f50eefa5 (diff) | |
download | serenity-3bfef8bfe0d6f196c809d50140c31d4f10a6b533.zip |
LibVideo: Pass the current sample to demuxers to lazily seek better
In cases where the PlaybackManager's earliest buffered or displayed
sample is closer to the seek target than the demuxer's chosen keyframe,
we don't want to seek at all. To enable this, demuxers now receive an
optional parameter with the earliest timestamp that the caller can
still access.
The demuxer in turn returns an optional to indicate when a seek was not
needed, which allows PlaybackManager to avoid clearing its queue and
re-decoding frames.
Diffstat (limited to 'Userland/Libraries/LibVideo/Containers/Demuxer.h')
-rw-r--r-- | Userland/Libraries/LibVideo/Containers/Demuxer.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibVideo/Containers/Demuxer.h b/Userland/Libraries/LibVideo/Containers/Demuxer.h index 1a2d2355d2..0915b8685e 100644 --- a/Userland/Libraries/LibVideo/Containers/Demuxer.h +++ b/Userland/Libraries/LibVideo/Containers/Demuxer.h @@ -29,7 +29,9 @@ public: } // Returns the timestamp of the keyframe that was seeked to. - virtual DecoderErrorOr<Time> seek_to_most_recent_keyframe(Track track, Time timestamp) = 0; + // The value is `Optional` to allow the demuxer to decide not to seek so that it can keep its position + // in the case that the timestamp is closer to the current time than the nearest keyframe. + virtual DecoderErrorOr<Optional<Time>> seek_to_most_recent_keyframe(Track track, Time timestamp, Optional<Time> earliest_available_sample = OptionalNone()) = 0; virtual DecoderErrorOr<Time> duration() = 0; |