StormByte-Multimedia 3.3.2
C++26 multimedia processing module of the StormByte suite
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 * A written StormByte commercial agreement may license this original source
24 * on terms other than the LGPL, including specific use, distribution or
25 * linking arrangements such as static linking, as stated in that agreement.
26 * It does not grant rights to dependencies or waive their license conditions.
27 * Enabling WITH_GPL or WITH_NONFREE may include components with separate
28 * obligations for modification, linking (static or dynamic), redistribution
29 * or works that incorporate them. The person modifying, linking, packaging or
30 * distributing the resulting work is responsible for determining and meeting
31 * all applicable requirements, including any needed patent permissions.
32 * A StormByte commercial agreement does not provide those rights for GPL or
33 * nonfree components.
34 *
35 * Neither license grants any patent rights. Any patent licenses required
36 * to use this software or third-party components must be obtained separately
37 * from the patent holders.
38 *
39 * StormByte-Multimedia is distributed in the hope that it will be useful,
40 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 * GNU Lesser General Public License for more details.
43 *
44 * You should have received a copy of the GNU Lesser General Public License
45 * version 3 along with StormByte-Multimedia. If not, see
46 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
47 *
48 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
49 */
50
51#pragma once
52
53#include <StormByte/buffer/fifo.hxx>
60#include <StormByte/safe/optional.hxx>
61#include <StormByte/safe/string.hxx>
62#include <StormByte/safe/vector.hxx>
63
64#include <cstdint>
65#include <memory>
66
71namespace StormByte {
76 namespace Multimedia {
83 namespace Pipeline {
104 public:
109
114
123
142 Frame(int track, enum StormByte::Multimedia::Type type, enum Producer producer,
149 std::uint64_t serial,
150 std::uint64_t part);
151
163 Frame(const Frame& other);
164
173 Frame(Frame&& other) noexcept;
174
178 ~Frame() noexcept override;
179
188 Frame& operator=(const Frame& other);
189
197 Frame& operator=(Frame&& other) noexcept;
198
202
207
212 inline const StormByte::Safe::Optional<Property::Duration>& Pts() const noexcept {
213 return m_pts;
214 }
215
226 inline const StormByte::Safe::Optional<Property::Duration>& Dts() const noexcept {
227 return m_dts;
228 }
229
235 return m_duration;
236 }
237
243 return m_language;
244 }
245
251 return m_title;
252 }
253
257
262
272 inline const StormByte::Safe::Optional<std::uint64_t>& Serial() const noexcept {
273 return m_serial;
274 }
275
282 inline std::uint64_t Part() const noexcept {
283 return m_part;
284 }
285
289
294
299 inline const StormByte::Safe::Optional<Property::Video>& Video() const noexcept {
300 return m_video;
301 }
302
307 inline const StormByte::Safe::Optional<Property::Audio>& Audio() const noexcept {
308 return m_audio;
309 }
310
317 return m_attachments;
318 }
319
323
328
337
342 inline const StormByte::Buffer::FIFO& Payload() const noexcept {
343 return m_payload;
344 }
345
354
358
359 private:
363 friend class Backend::Pipeline::Frame;
364
368 friend class Decoder;
369
373 friend class Encoder;
374
378 friend class Filter::FFmpeg;
379
386 friend Decoder& operator>>(Decoder& decoder, Frame& frame) noexcept;
387
394 friend Frame& operator>>(Frame& frame, Encoder& encoder) noexcept;
395
400 void Bind(StormByte::Safe::Unique<Backend::Pipeline::Frame> backend) noexcept;
401
410 void BecomeEmpty() noexcept;
411
419 Item::PointerType Clone() const override;
420
428 Item::PointerType Move() override;
429
430 StormByte::Buffer::FIFO m_payload;
431 StormByte::Safe::Optional<Property::Duration> m_pts;
432 StormByte::Safe::Optional<Property::Duration> m_dts;
433 StormByte::Safe::Optional<Property::Duration> m_duration;
434 StormByte::Safe::Optional<Property::Video> m_video;
435 StormByte::Safe::Optional<Property::Audio> m_audio;
436 StormByte::Safe::Optional<StormByte::Safe::String> m_language;
437 StormByte::Safe::Optional<StormByte::Safe::String> m_title;
438 StormByte::Safe::Vector<class SideData> m_attachments;
439 StormByte::Safe::Optional<std::uint64_t> m_serial;
440 std::uint64_t m_part;
441 std::uint32_t m_pass = 0;
442 StormByte::Safe::Unique<Backend::Pipeline::Frame> m_backend;
443 };
444 }
445 }
446}
447
STORMBYTE_DECLARE_MAYBE_SAFE(StormByte::Buffer::Bridge)
const StormByte::Safe::Optional< StormByte::Safe::String > & Title() const noexcept
Stream title tag copied from File metadata.
Definition frame.hxx:250
const StormByte::Safe::Vector< class SideData > & Attachments() const noexcept
Raw side data captured at receive.
Definition frame.hxx:316
~Frame() noexcept override
Destructor.
const StormByte::Safe::Optional< StormByte::Safe::String > & Language() const noexcept
Stream language tag copied from File metadata.
Definition frame.hxx:242
const StormByte::Safe::Optional< Property::Video > & Video() const noexcept
Video properties (includes HDR10 when set).
Definition frame.hxx:299
const StormByte::Safe::Optional< std::uint64_t > & Serial() const noexcept
Monotonic lineage id assigned when the unit enters the pipe.
Definition frame.hxx:272
friend class Backend::Pipeline::Frame
Allows the backend holder to access the frame's media storage.
Definition frame.hxx:363
const StormByte::Safe::Optional< Property::Duration > & Duration() const noexcept
Frame duration on the stream clock.
Definition frame.hxx:234
StormByte::Safe::Shared< Frame > PointerType
Base-heap shared owner of a frame; keep its providers loaded.
Definition frame.hxx:108
friend class Decoder
Allows the decoder to populate decoded media and metadata.
Definition frame.hxx:368
Frame(const Frame &other)
Copy.
friend class Encoder
Allows the encoder to access the backend frame.
Definition frame.hxx:373
StormByte::Buffer::FIFO & Payload() noexcept
Payload.
StormByte::ByteSize BufferingWeight() const noexcept
Estimates the retained media payload weight for queue accounting.
const StormByte::Safe::Optional< Property::Duration > & Pts() const noexcept
Presentation timestamp on the stream clock.
Definition frame.hxx:212
Frame(int track, enum StormByte::Multimedia::Type type, enum Producer producer, StormByte::Buffer::FIFO payload, StormByte::Safe::Optional< Property::Duration > pts, StormByte::Safe::Optional< Property::Duration > duration, StormByte::Safe::Optional< Property::Video > video, StormByte::Safe::Vector< class SideData > attachments, StormByte::Safe::Optional< Property::Audio > audio, std::uint64_t serial, std::uint64_t part)
Builds a frame from supplied media bytes and properties.
friend class Filter::FFmpeg
Allows FFmpeg filters to update decoded media and metadata.
Definition frame.hxx:378
Frame(Frame &&other) noexcept
Move constructor.
const StormByte::Safe::Optional< Property::Audio > & Audio() const noexcept
Audio properties (layout, rate, channels).
Definition frame.hxx:307
const StormByte::Safe::Optional< Property::Duration > & Dts() const noexcept
Decode timestamp on the stream clock.
Definition frame.hxx:226
std::uint64_t Part() const noexcept
Sub-id inside Serial when one demuxed unit yields several frames.
Definition frame.hxx:282
enum Producer Producer() const noexcept
Stage that created this unit.
Definition item.hxx:213
Item(const Item &other) noexcept=default
Copy constructor.
One side-data blob attached to a Frame or Packet.
Definition side_data.hxx:114
Multimedia module of the StormByte suite.
Pipeline Demux / decode / filter / encode / mux types.
Media property value types.
Typed item queues provided by StormByte-Buffer.
Frame and packet steps attached to a job or a raw pipeline.
Demux / decode / filter / encode / mux types.
Multimedia module of the StormByte suite.
Type
Kind of media stream or codec.
Definition type.hxx:72
Root namespace of the StormByte C++ suite.
STL namespace.
#define STORMBYTE_MULTIMEDIA_PUBLIC
Definition visibility.h:61