StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
packet.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>
47
48#include <cstdint>
49#include <memory>
50#include <optional>
51#include <vector>
52
77 friend class Backend::Pipeline::Packet;
78 friend class Decoder;
79 friend class Demuxer;
80 friend class Encoder;
81 friend class Filter::FFmpeg;
82 friend class Muxer;
83
84 public:
85 using PointerType = std::shared_ptr<Packet>;
86
95 Packet() noexcept;
96
115 Packet(int track, enum Type type, enum Producer producer,
116 StormByte::Buffer::FIFO payload,
117 std::optional<Property::Duration> pts,
118 std::optional<Property::Duration> dts,
119 std::optional<Property::Duration> duration,
120 bool key_frame,
121 std::vector<SideData> attachments,
122 const StormByte::Multimedia::Codec* codec,
123 std::uint64_t serial,
124 std::uint64_t part) noexcept;
125
132 Packet(Packet&& other) noexcept;
133
137 ~Packet() noexcept override;
138
146 Packet& operator=(Packet&& other) noexcept;
147
161 inline const std::optional<Property::Duration>& Pts() const noexcept {
162 return m_pts;
163 }
164
169 inline const std::optional<Property::Duration>& Dts() const noexcept {
170 return m_dts;
171 }
172
177 inline const std::optional<Property::Duration>& Duration() const noexcept {
178 return m_duration;
179 }
180
185 inline bool KeyFrame() const noexcept {
186 return m_keyFrame;
187 }
188
207 inline const std::optional<std::uint64_t>& Serial() const noexcept {
208 return m_serial;
209 }
210
217 inline std::uint64_t Part() const noexcept {
218 return m_part;
219 }
220
234 inline const StormByte::Multimedia::Codec* Codec() const noexcept {
235 return m_codec;
236 }
237
251 inline const StormByte::Buffer::FIFO& Payload() const noexcept {
252 return m_payload;
253 }
254
259 inline StormByte::Buffer::FIFO& Payload() noexcept {
260 return m_payload;
261 }
262
267 inline const std::vector<SideData>& Attachments() const noexcept {
268 return m_attachments;
269 }
270
275 inline std::vector<SideData>& Attachments() noexcept {
276 return m_attachments;
277 }
278
283 private:
296 Packet(const Packet& other) noexcept;
297
303 Packet& operator=(const Packet& other) noexcept;
304
313 void Bind(std::unique_ptr<Backend::Pipeline::Packet> backend) noexcept;
314
318 void BecomeEmpty() noexcept;
319
326 Item::PointerType Clone() const override;
327
335 Item::PointerType Move() override;
336
337 StormByte::Buffer::FIFO m_payload;
338 std::optional<Property::Duration> m_pts;
339 std::optional<Property::Duration> m_dts;
340 std::optional<Property::Duration> m_duration;
341 bool m_keyFrame;
342 std::vector<SideData> m_attachments;
343 const StormByte::Multimedia::Codec* m_codec;
344 std::optional<std::uint64_t> m_serial;
345 std::uint64_t m_part;
346 std::unique_ptr<Backend::Pipeline::Packet> m_backend;
347 };
348}
Immutable codec identity owned by Registry.
Definition codec.hxx:58
Decodes packets of one origin track into frames.
Definition decoder.hxx:141
Reads interleaved packets from a File origin.
Definition demuxer.hxx:121
Encodes frames of one output track into packets.
Definition encoder.hxx:103
Abstract base for every StormByte Multimedia filter.
Definition ffmpeg.hxx:226
Facade shared by Frame and Packet.
Definition item.hxx:91
Writes interleaved packets to a destination container.
Definition muxer.hxx:150
One compressed access unit.
Definition packet.hxx:76
const std::vector< SideData > & Attachments() const noexcept
Side-data blobs bound to this access unit.
Definition packet.hxx:267
const std::optional< std::uint64_t > & Serial() const noexcept
Monotonic lineage id assigned when the unit enters the pipe.
Definition packet.hxx:207
std::uint64_t Part() const noexcept
Sub-id inside Serial when one demuxed unit yields several frames.
Definition packet.hxx:217
const std::optional< Property::Duration > & Duration() const noexcept
Packet duration on the stream clock.
Definition packet.hxx:177
const std::optional< Property::Duration > & Dts() const noexcept
Decode timestamp on the stream clock.
Definition packet.hxx:169
std::vector< SideData > & Attachments() noexcept
Side-data blobs bound to this access unit (mutable).
Definition packet.hxx:275
StormByte::Buffer::FIFO & Payload() noexcept
Owned compressed payload (mutable).
Definition packet.hxx:259
std::shared_ptr< Packet > PointerType
Definition packet.hxx:85
const StormByte::Buffer::FIFO & Payload() const noexcept
Owned compressed payload.
Definition packet.hxx:251
bool KeyFrame() const noexcept
Whether this is a key frame / key packet.
Definition packet.hxx:185
Packet() noexcept
Empty packet (no payload, track -1, type Unknown).
const StormByte::Multimedia::Codec * Codec() const noexcept
Registry codec of this access unit.
Definition packet.hxx:234
One side-data blob attached to a Frame or Packet.
Definition side_data.hxx:90
Demux / decode / filter / encode / mux types.
Producer
Definition typedefs.hxx:105
Type
Kind of media stream or codec.
Definition type.hxx:55
#define STORMBYTE_MULTIMEDIA_PUBLIC
Imported symbol.
Definition visibility.h:47