mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
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.
This commit is contained in:
parent
275d57eb6f
commit
3bfef8bfe0
7 changed files with 61 additions and 42 deletions
|
@ -38,7 +38,7 @@ public:
|
|||
DecoderErrorOr<size_t> track_count();
|
||||
|
||||
DecoderErrorOr<SampleIterator> create_sample_iterator(u64 track_number);
|
||||
DecoderErrorOr<void> seek_to_random_access_point(SampleIterator&, Time);
|
||||
DecoderErrorOr<SampleIterator> seek_to_random_access_point(SampleIterator, Time);
|
||||
DecoderErrorOr<Optional<Vector<CuePoint> const&>> cue_points_for_track(u64 track_number);
|
||||
DecoderErrorOr<bool> has_cues_for_track(u64 track_number);
|
||||
|
||||
|
@ -83,7 +83,7 @@ class SampleIterator {
|
|||
public:
|
||||
DecoderErrorOr<Block> next_block();
|
||||
Cluster const& current_cluster() { return *m_current_cluster; }
|
||||
Time const& last_timestamp() { return m_last_timestamp; }
|
||||
Optional<Time> const& last_timestamp() { return m_last_timestamp; }
|
||||
|
||||
private:
|
||||
friend class Reader;
|
||||
|
@ -107,7 +107,7 @@ private:
|
|||
// Must always point to an element ID or the end of the stream.
|
||||
size_t m_position { 0 };
|
||||
|
||||
Time m_last_timestamp { Time::min() };
|
||||
Optional<Time> m_last_timestamp;
|
||||
|
||||
Optional<Cluster> m_current_cluster;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue