summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVideo/Demuxer.h
blob: 477f202f90d287cfd7abc833b9936146f504893d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * 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 "DecoderError.h"
#include "Sample.h"
#include "Track.h"

namespace Video {

class Demuxer {
public:
    virtual ~Demuxer() = default;

    virtual 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>();
    }

    virtual DecoderErrorOr<void> seek_to_most_recent_keyframe(Track track, size_t timestamp) = 0;

    virtual Time duration() = 0;

protected:
    virtual DecoderErrorOr<NonnullOwnPtr<Sample>> get_next_sample_for_track(Track track) = 0;
};

}