2022-10-29 17:02:43 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/NonnullOwnPtr.h>
|
|
|
|
#include <LibCore/Object.h>
|
2022-11-09 19:47:56 -06:00
|
|
|
#include <LibVideo/DecoderError.h>
|
|
|
|
#include <LibVideo/Sample.h>
|
|
|
|
#include <LibVideo/Track.h>
|
2022-10-29 17:02:43 -05:00
|
|
|
|
|
|
|
namespace Video {
|
|
|
|
|
|
|
|
class Demuxer {
|
|
|
|
public:
|
|
|
|
virtual ~Demuxer() = default;
|
|
|
|
|
2022-11-11 17:14:27 -06:00
|
|
|
virtual DecoderErrorOr<Vector<Track>> get_tracks_for_type(TrackType type) = 0;
|
2022-10-29 17:02:43 -05:00
|
|
|
|
|
|
|
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>();
|
|
|
|
}
|
|
|
|
|
2022-11-13 20:33:23 -06:00
|
|
|
// Returns the timestamp of the keyframe that was seeked to.
|
|
|
|
virtual DecoderErrorOr<Time> seek_to_most_recent_keyframe(Track track, Time timestamp) = 0;
|
2022-10-29 17:02:43 -05:00
|
|
|
|
2022-11-11 17:14:27 -06:00
|
|
|
virtual DecoderErrorOr<Time> duration() = 0;
|
2022-10-29 17:02:43 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual DecoderErrorOr<NonnullOwnPtr<Sample>> get_next_sample_for_track(Track track) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|