StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
demuxer.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>
42#include <StormByte/logger/log.hxx>
49
50#include <atomic>
51#include <condition_variable>
52#include <cstdint>
53#include <memory>
54#include <mutex>
55#include <optional>
56#include <unordered_map>
57
65 class Decoder;
66 class Demuxer;
67}
68
70 class Demux;
71}
72
77namespace StormByte::Multimedia {
78 class Origin;
79}
80
88 class Decoder;
89 class Demuxer;
90 class Muxer;
91 class Packet;
92 class Plan;
93 class Remuxer;
94
101 STORMBYTE_MULTIMEDIA_PUBLIC Decoder& operator>>(Demuxer& demuxer, Decoder& decoder) noexcept;
102
122 friend class Backend::Pipeline::Demuxer;
123 friend class Backend::Pipeline::Detail::Worker::Demux;
124 friend class Decoder;
125 friend class Muxer;
126 friend Decoder& operator>>(Demuxer& demuxer, Decoder& decoder) noexcept;
127 friend Demuxer& operator>>(class Plan&& plan, Demuxer& demuxer) noexcept;
128 friend Muxer& operator>>(Demuxer& demuxer, Muxer& muxer) noexcept;
129 friend Remuxer& operator>>(Demuxer& demuxer, Remuxer& remuxer) noexcept;
130
131 public:
141 explicit Demuxer(std::shared_ptr<StormByte::Logger::Log> log) noexcept;
142
147 Demuxer(const Demuxer& other) = delete;
148
153 Demuxer(Demuxer&& other) noexcept = delete;
154
158 ~Demuxer() noexcept override;
159
165 Demuxer& operator=(const Demuxer& other) = delete;
166
172 Demuxer& operator=(Demuxer&& other) noexcept = delete;
173
182 explicit operator bool() const noexcept;
183
193 bool Eof() const noexcept;
194
199 std::optional<Property::Duration> Position() const noexcept;
200
205 private:
206 using Step::Log;
207
211 void WaitForPlan() noexcept;
212
216 void ReachedEof() noexcept;
217
222 const File& OriginFile() const noexcept;
223
228 Origin& BoundOrigin() noexcept;
229
235 std::unique_ptr<Backend::Pipeline::Decoder> OpenDecoder(Decoder& decoder) noexcept;
236
260 Packet::PointerType Wrap(
261 int track,
262 Type type,
263 StormByte::Buffer::FIFO payload,
264 std::optional<Property::Duration> pts,
265 std::optional<Property::Duration> dts,
266 std::optional<Property::Duration> duration,
267 bool keyframe,
268 std::unique_ptr<Backend::Pipeline::Packet> backend) noexcept;
269
270 std::unique_ptr<Backend::Pipeline::Demuxer> m_backend;
271 bool m_eof;
272 std::mutex m_planMutex;
273 std::condition_variable m_planPresent;
274 std::atomic<std::int64_t> m_positionNs;
275 std::unordered_map<int, std::uint64_t> m_nextSerial;
276 Join m_join{*this};
277 };
278}
Snapshot of a media source: path or Consumer, container, streams and tags.
Definition file.hxx:84
Decodes packets of one origin track into frames.
Definition decoder.hxx:141
Reads interleaved packets from a File origin.
Definition demuxer.hxx:121
friend Muxer & operator>>(Demuxer &demuxer, Muxer &muxer) noexcept
Binds demuxer as remux origin and forwards its attachments.
~Demuxer() noexcept override
Destructor.
friend Remuxer & operator>>(Demuxer &demuxer, Remuxer &remuxer) noexcept
Binds origin track remuxer.In() from demuxer onto remuxer.
friend Demuxer & operator>>(class Plan &&plan, Demuxer &demuxer) noexcept
Hands plan to demuxer.
Demuxer(std::shared_ptr< StormByte::Logger::Log > log) noexcept
Demuxer.
friend Decoder & operator>>(Demuxer &demuxer, Decoder &decoder) noexcept
Binds one origin track of demuxer to decoder.
Demuxer(const Demuxer &other)=delete
Copy constructor.
Demuxer(Demuxer &&other) noexcept=delete
Move constructor.
Writes interleaved packets to a destination container.
Definition muxer.hxx:150
One compressed access unit.
Definition packet.hxx:76
Closed job intention: source File, destination container and tracks that enter the tube.
Definition plan.hxx:76
Forwards compressed packets of one origin track to the muxer.
Definition remuxer.hxx:88
Last data member of every most-derived Step.
Definition step.hxx:359
One stage with a Backend::Pipeline::Pipe (in / out).
Definition step.hxx:114
Multimedia-owned pipeline stages and unit holders.
Demux / decode / filter / encode / mux types.
Decoder & operator>>(Demuxer &demuxer, Decoder &decoder) noexcept
Binds one origin track of demuxer to decoder.
@ Packet
StormByte::Multimedia::Pipeline::Packet
Public multimedia types: codecs, containers, streams and files.
Type
Kind of media stream or codec.
Definition type.hxx:55
#define STORMBYTE_MULTIMEDIA_PUBLIC
Imported symbol.
Definition visibility.h:47