1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:07:44 +00:00

LibVideo: Add a fast seeking mode to seek only to keyframes

Now that we're able to find the nearest keyframe, we can have a fast
seeking mode that only seeks to keyframes, so that it doesn't have to
also decode inter frames until it reaches the timestamp.

The default is still accurate seeking, so that the entire seeking
implementation can be tested.
This commit is contained in:
Zaggy1024 2022-11-13 20:33:23 -06:00 committed by Andreas Kling
parent eef8867d9e
commit fd3ffd88ce
5 changed files with 22 additions and 6 deletions

View file

@ -94,6 +94,13 @@ using VideoFrameQueue = Queue<FrameQueueItem, FRAME_BUFFER_COUNT>;
class PlaybackManager {
public:
enum class SeekMode {
Accurate,
Fast,
};
static constexpr SeekMode DEFAULT_SEEK_MODE = SeekMode::Accurate;
static DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> from_file(Core::Object& event_handler, StringView file);
static DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> from_data(Core::Object& event_handler, Span<u8> data);
@ -108,6 +115,9 @@ public:
bool is_buffering() const { return m_status == PlaybackStatus::Buffering; }
bool is_stopped() const { return m_status == PlaybackStatus::Stopped || m_status == PlaybackStatus::Corrupted; }
SeekMode seek_mode() { return m_seek_mode; }
void set_seek_mode(SeekMode mode) { m_seek_mode = mode; }
u64 number_of_skipped_frames() const { return m_skipped_frames; }
void on_decoder_error(DecoderError error);
@ -136,6 +146,7 @@ private:
Time m_last_present_in_real_time = Time::zero();
Time m_seek_to_media_time = Time::min();
SeekMode m_seek_mode = DEFAULT_SEEK_MODE;
NonnullOwnPtr<Demuxer> m_demuxer;
Track m_selected_video_track;