1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 02:48:11 +00:00
serenity/Userland/Libraries/LibVideo/MatroskaDemuxer.h
Zaggy1024 0a4def1208 LibVideo: Abstract media container format demuxing
This creates an abstract Demuxer class to allow multiple container
container formats to be easily used by video playback systems.
2022-10-31 14:47:13 +01:00

51 lines
1.3 KiB
C++

/*
* Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include "Demuxer.h"
#include "MatroskaReader.h"
namespace Video {
class MatroskaDemuxer final : public Demuxer {
public:
// FIXME: We should instead accept some abstract data streaming type so that the demuxer
// can work with non-contiguous data.
static DecoderErrorOr<NonnullOwnPtr<MatroskaDemuxer>> from_file(StringView filename);
static DecoderErrorOr<NonnullOwnPtr<MatroskaDemuxer>> from_data(Span<u8 const> data);
MatroskaDemuxer(NonnullOwnPtr<MatroskaDocument>& document)
: m_document(move(document))
{
}
Vector<Track> get_tracks_for_type(TrackType type) override;
DecoderErrorOr<void> seek_to_most_recent_keyframe(Track track, size_t timestamp) override;
Time duration() override;
protected:
DecoderErrorOr<NonnullOwnPtr<Sample>> get_next_sample_for_track(Track track) override;
private:
struct TrackStatus {
size_t m_cluster_index { 0 };
size_t m_block_index { 0 };
size_t m_frame_index { 0 };
};
ErrorOr<TrackStatus*> get_track_status(Track track);
NonnullOwnPtr<MatroskaDocument> m_document;
HashMap<Track, TrackStatus> m_track_statuses;
};
}