StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
frame.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Multimedia.
5 *
6 * StormByte-Multimedia original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Multimedia source in this
20 * file. Third-party components — including FFmpeg and embedded trained data —
21 * remain under their own licenses and are not covered by the commercial grant.
22 *
23 * Neither license grants any patent rights. Any patent licenses required
24 * to use this software or third-party components must be obtained separately
25 * from the patent holders.
26 *
27 * StormByte-Multimedia is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 *
32 * You should have received a copy of the GNU Lesser General Public License
33 * version 3 along with StormByte-Multimedia. If not, see
34 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
35 *
36 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
37 */
38
39#pragma once
40
41#include <StormByte/buffer/fifo.hxx>
48
49#include <cstdint>
50#include <memory>
51#include <optional>
52#include <string>
53#include <vector>
54
82 friend class Backend::Pipeline::Frame;
83 friend class Decoder;
84 friend class Encoder;
85 friend class Filter::FFmpeg;
86 friend Decoder& operator>>(Decoder& decoder, Frame& frame) noexcept;
87 friend Frame& operator>>(Frame& frame, Encoder& encoder) noexcept;
88
89 public:
90 using PointerType = std::shared_ptr<Frame>;
91
96
103 Frame() noexcept;
104
122 Frame(int track, enum StormByte::Multimedia::Type type, enum Producer producer,
123 StormByte::Buffer::FIFO payload,
124 std::optional<Property::Duration> pts,
125 std::optional<Property::Duration> duration,
126 std::optional<Property::Video> video,
127 std::vector<class SideData> attachments,
128 std::optional<Property::Audio> audio,
129 std::uint64_t serial,
130 std::uint64_t part) noexcept;
131
141 Frame(const Frame& other) noexcept;
142
151 Frame(Frame&& other) noexcept;
152
156 ~Frame() noexcept override;
157
163 Frame& operator=(const Frame& other) noexcept;
164
172 Frame& operator=(Frame&& other) noexcept;
173
177
182
187 inline const std::optional<Property::Duration>& Pts() const noexcept {
188 return m_pts;
189 }
190
201 inline const std::optional<Property::Duration>& Dts() const noexcept {
202 return m_dts;
203 }
204
209 inline const std::optional<Property::Duration>& Duration() const noexcept {
210 return m_duration;
211 }
212
217 inline const std::optional<std::string>& Language() const noexcept {
218 return m_language;
219 }
220
225 inline const std::optional<std::string>& Title() const noexcept {
226 return m_title;
227 }
228
232
237
247 inline const std::optional<std::uint64_t>& Serial() const noexcept {
248 return m_serial;
249 }
250
257 inline std::uint64_t Part() const noexcept {
258 return m_part;
259 }
260
264
269
274 inline const std::optional<Property::Video>& Video() const noexcept {
275 return m_video;
276 }
277
282 inline const std::optional<Property::Audio>& Audio() const noexcept {
283 return m_audio;
284 }
285
291 inline const std::vector<class SideData>& Attachments() const noexcept {
292 return m_attachments;
293 }
294
298
303
311 StormByte::Buffer::FIFO& Payload() noexcept;
312
317 inline const StormByte::Buffer::FIFO& Payload() const noexcept {
318 return m_payload;
319 }
320
324
325 private:
330 void Bind(std::unique_ptr<Backend::Pipeline::Frame> backend) noexcept;
331
338 void BecomeEmpty() noexcept;
339
347 Item::PointerType Clone() const override;
348
356 Item::PointerType Move() override;
357
358 StormByte::Buffer::FIFO m_payload;
359 std::optional<Property::Duration> m_pts;
360 std::optional<Property::Duration> m_dts;
361 std::optional<Property::Duration> m_duration;
362 std::optional<Property::Video> m_video;
363 std::optional<Property::Audio> m_audio;
364 std::optional<std::string> m_language;
365 std::optional<std::string> m_title;
366 std::vector<class SideData> m_attachments;
367 std::optional<std::uint64_t> m_serial;
368 std::uint64_t m_part;
369 std::unique_ptr<Backend::Pipeline::Frame> m_backend;
370 };
371}
Abstract base for every StormByte Multimedia filter.
Definition ffmpeg.hxx:253
One decoded access unit.
Definition frame.hxx:81
const std::optional< Property::Duration > & Duration() const noexcept
Frame duration on the stream clock.
Definition frame.hxx:209
const std::vector< class SideData > & Attachments() const noexcept
Raw side data captured at receive.
Definition frame.hxx:291
const std::optional< std::string > & Language() const noexcept
Stream language tag copied from File metadata.
Definition frame.hxx:217
friend Decoder & operator>>(Decoder &decoder, Frame &frame) noexcept
friend class Backend::Pipeline::Frame
Definition frame.hxx:82
const std::optional< std::uint64_t > & Serial() const noexcept
Monotonic lineage id assigned when the unit enters the pipe.
Definition frame.hxx:247
std::shared_ptr< Frame > PointerType
Definition frame.hxx:90
friend class Decoder
Definition frame.hxx:83
const std::optional< Property::Duration > & Pts() const noexcept
Presentation timestamp on the stream clock.
Definition frame.hxx:187
friend class Encoder
Definition frame.hxx:84
StormByte::Buffer::FIFO & Payload() noexcept
Payload.
const std::optional< std::string > & Title() const noexcept
Stream title tag copied from File metadata.
Definition frame.hxx:225
const std::optional< Property::Duration > & Dts() const noexcept
Decode timestamp on the stream clock.
Definition frame.hxx:201
friend Frame & operator>>(Frame &frame, Encoder &encoder) noexcept
const std::optional< Property::Video > & Video() const noexcept
Video properties (includes HDR10 when set).
Definition frame.hxx:274
const std::optional< Property::Audio > & Audio() const noexcept
Audio properties (layout, rate, channels).
Definition frame.hxx:282
std::uint64_t Part() const noexcept
Sub-id inside Serial when one demuxed unit yields several frames.
Definition frame.hxx:257
Facade shared by Frame and Packet.
Definition item.hxx:96
enum Producer Producer() const noexcept
Stage that created this unit.
Definition item.hxx:159
enum StormByte::Multimedia::Type Type() const noexcept
Media of this access unit.
Definition item.hxx:143
Item(const Item &other) noexcept=default
Copy constructor.
One side-data blob attached to a Frame or Packet.
Definition side_data.hxx:90
Hopper and Sink live in StormByte-Buffer.
Definition AVFormatContext.hxx:52
Demux / decode / filter / encode / mux types.
Media property value types.
Public multimedia types: codecs, containers, streams and files.
#define STORMBYTE_MULTIMEDIA_PUBLIC
Imported symbol.
Definition visibility.h:47