2022-10-08 20:36:57 -03:00
|
|
|
/*
|
2026-01-20 23:10:33 -03:00
|
|
|
* Copyright (c) 2022-2026, Gregory Bertilson <gregory@ladybird.org>
|
2022-10-08 20:36:57 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2026-05-05 06:29:14 -03:00
|
|
|
#include <AK/AtomicRefCounted.h>
|
2026-05-20 10:01:36 -03:00
|
|
|
#include <AK/Error.h>
|
2026-05-05 06:38:50 -03:00
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2026-05-20 10:01:36 -03:00
|
|
|
#include <AK/NonnullRefPtr.h>
|
2024-06-19 20:29:12 -03:00
|
|
|
#include <AK/Time.h>
|
2026-05-05 06:38:50 -03:00
|
|
|
#include <LibGfx/ColorSpace.h>
|
2026-01-20 23:10:33 -03:00
|
|
|
#include <LibGfx/Forward.h>
|
2022-10-08 20:36:57 -03:00
|
|
|
#include <LibGfx/Size.h>
|
2026-05-20 10:01:36 -03:00
|
|
|
#include <LibIPC/Forward.h>
|
2026-01-20 23:10:33 -03:00
|
|
|
#include <LibMedia/Export.h>
|
2024-06-10 17:04:03 -03:00
|
|
|
|
|
|
|
|
namespace Media {
|
2022-10-08 20:36:57 -03:00
|
|
|
|
2026-05-05 06:29:14 -03:00
|
|
|
class MEDIA_API VideoFrame final : public AtomicRefCounted<VideoFrame> {
|
2022-10-08 20:36:57 -03:00
|
|
|
|
|
|
|
|
public:
|
2026-02-17 21:50:23 -03:00
|
|
|
VideoFrame(
|
|
|
|
|
AK::Duration timestamp,
|
|
|
|
|
AK::Duration duration,
|
2026-01-20 23:10:33 -03:00
|
|
|
Gfx::Size<u32> size,
|
2026-02-17 21:50:23 -03:00
|
|
|
u8 bit_depth,
|
2026-05-05 06:38:50 -03:00
|
|
|
Gfx::ColorSpace color_space,
|
|
|
|
|
NonnullOwnPtr<Gfx::YUVData> yuv_data);
|
2026-01-20 23:10:33 -03:00
|
|
|
~VideoFrame();
|
2022-10-08 20:36:57 -03:00
|
|
|
|
2025-11-26 20:26:29 -03:00
|
|
|
AK::Duration timestamp() const { return m_timestamp; }
|
2025-11-26 20:29:28 -03:00
|
|
|
AK::Duration duration() const { return m_duration; }
|
2024-06-19 20:29:12 -03:00
|
|
|
|
2025-11-26 20:26:29 -03:00
|
|
|
Gfx::Size<u32> size() const { return m_size; }
|
|
|
|
|
u32 width() const { return size().width(); }
|
|
|
|
|
u32 height() const { return size().height(); }
|
2022-10-08 20:36:57 -03:00
|
|
|
|
2025-11-26 20:26:29 -03:00
|
|
|
u8 bit_depth() const { return m_bit_depth; }
|
2022-10-08 20:36:57 -03:00
|
|
|
|
2026-05-05 06:38:50 -03:00
|
|
|
Gfx::ColorSpace const& color_space() const { return m_color_space; }
|
|
|
|
|
Gfx::YUVData const& yuv_data() const { return *m_yuv_data; }
|
|
|
|
|
|
2026-01-20 23:10:33 -03:00
|
|
|
private:
|
2024-07-17 02:44:30 -03:00
|
|
|
AK::Duration m_timestamp;
|
2025-11-26 20:29:28 -03:00
|
|
|
AK::Duration m_duration;
|
2023-04-16 09:43:31 -03:00
|
|
|
Gfx::Size<u32> m_size;
|
2022-10-08 20:36:57 -03:00
|
|
|
u8 m_bit_depth;
|
2026-05-05 06:38:50 -03:00
|
|
|
Gfx::ColorSpace m_color_space;
|
|
|
|
|
NonnullOwnPtr<Gfx::YUVData> m_yuv_data;
|
2022-10-08 20:36:57 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
2026-05-20 10:01:36 -03:00
|
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
MEDIA_API ErrorOr<void> encode(Encoder&, Media::VideoFrame const&);
|
|
|
|
|
template<>
|
|
|
|
|
MEDIA_API ErrorOr<void> encode(Encoder&, NonnullRefPtr<Media::VideoFrame const> const&);
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
MEDIA_API ErrorOr<NonnullRefPtr<Media::VideoFrame const>> decode(Decoder&);
|
|
|
|
|
|
|
|
|
|
}
|