summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVideo/Containers/Demuxer.h
diff options
context:
space:
mode:
authorZaggy1024 <zaggy1024@gmail.com>2023-02-06 01:25:02 -0600
committerAndreas Kling <kling@serenityos.org>2023-02-08 21:52:42 +0100
commit3bfef8bfe0d6f196c809d50140c31d4f10a6b533 (patch)
tree2abf08599869000d35cf72daa7831bf539696eef /Userland/Libraries/LibVideo/Containers/Demuxer.h
parent275d57eb6f46416dbfacb31ae2867905f50eefa5 (diff)
downloadserenity-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.h4
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;