ladybird/Userland/Libraries/LibVideo/Sample.h
Zaggy1024 393cfdd5c5 LibVideo: Read Matroska lazily so that large files can start quickly
The Demuxer class was changed to return errors for more functions so
that all of the underlying reading can be done lazily. Other than that,
the demuxer interface is unchanged, and only the underlying reader was
modified.

The MatroskaDocument class is no more, and MatroskaReader's getter
functions replace it. Every MatroskaReader getter beyond the Segment
element's position is parsed lazily from the file as needed. This means
that all getter functions can return DecoderErrors which must be
handled by callers.
2022-11-25 23:28:39 +01:00

45 lines
1.0 KiB
C++

/*
* Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Time.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
namespace Video {
class Sample {
public:
virtual ~Sample() = default;
virtual bool is_video_sample() const { return false; }
};
class VideoSample : public Sample {
public:
VideoSample(ReadonlyBytes data, CodingIndependentCodePoints container_cicp, Time timestamp)
: m_data(data)
, m_container_cicp(container_cicp)
, m_timestamp(timestamp)
{
}
bool is_video_sample() const override { return true; }
ReadonlyBytes const& data() const { return m_data; }
CodingIndependentCodePoints container_cicp() const { return m_container_cicp; }
Time timestamp() const { return m_timestamp; }
private:
ReadonlyBytes m_data;
CodingIndependentCodePoints m_container_cicp;
Time m_timestamp;
};
// FIXME: Add samples for audio, subtitles, etc.
}