mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 00:37:35 +00:00
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.
This commit is contained in:
parent
3a2f6c700d
commit
0a4def1208
8 changed files with 327 additions and 36 deletions
51
Userland/Libraries/LibVideo/MatroskaDemuxer.h
Normal file
51
Userland/Libraries/LibVideo/MatroskaDemuxer.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue