mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-19 01:22:54 +00:00
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.
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/NonnullOwnPtr.h>
|
|
#include <LibCore/Object.h>
|
|
#include <LibVideo/DecoderError.h>
|
|
#include <LibVideo/Sample.h>
|
|
#include <LibVideo/Track.h>
|
|
|
|
namespace Video {
|
|
|
|
class Demuxer {
|
|
public:
|
|
virtual ~Demuxer() = default;
|
|
|
|
virtual DecoderErrorOr<Vector<Track>> get_tracks_for_type(TrackType type) = 0;
|
|
|
|
DecoderErrorOr<NonnullOwnPtr<VideoSample>> get_next_video_sample_for_track(Track track)
|
|
{
|
|
VERIFY(track.type() == TrackType::Video);
|
|
auto sample = TRY(get_next_sample_for_track(track));
|
|
VERIFY(sample->is_video_sample());
|
|
return sample.release_nonnull<VideoSample>();
|
|
}
|
|
|
|
// Returns the timestamp of the keyframe that was seeked to.
|
|
// 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;
|
|
|
|
protected:
|
|
virtual DecoderErrorOr<NonnullOwnPtr<Sample>> get_next_sample_for_track(Track track) = 0;
|
|
};
|
|
|
|
}
|