1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:37:35 +00:00

LibVideo: Reorganize demuxer file hierarchy and rename Matroska files

As new demuxers are added, this will get quite full of files, so it'll
be good to have a separate folder for these.

To avoid too many chained namespaces, the Containers subdirectory is
not also a namespace, but the Matroska folder is for the sake of
separating the multiple classes for parsed information entering the
Video namespace.
This commit is contained in:
Zaggy1024 2022-11-09 19:47:56 -06:00 committed by Andreas Kling
parent edec6bdc32
commit 9cf7e8c5aa
13 changed files with 56 additions and 58 deletions

View 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 <LibVideo/Containers/Demuxer.h>
#include "Reader.h"
namespace Video::Matroska {
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(ReadonlyBytes 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;
};
}