StormByte-Multimedia 3.3.2
C++26 multimedia processing module of the StormByte suite
Loading...
Searching...
No Matches
filters.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/size.hxx>
60#include <StormByte/safe/atomic.hxx>
61#include <StormByte/safe/optional.hxx>
62#include <StormByte/safe/pair.hxx>
63#include <StormByte/safe/pointers.hxx>
64#include <StormByte/safe/string.hxx>
65#include <StormByte/safe/vector.hxx>
66
67#include <cstddef>
68#include <cstdint>
69#include <string>
70#include <utility>
71
82 class Transcoder;
83
87 class TopologyAccess;
88}
89
94namespace StormByte {
99 namespace Multimedia {
106 namespace Pipeline {
110 class Decoder;
111
115 class Demuxer;
116
120 class Route;
121 }
122 }
123}
124
141
150}
151
154
159namespace StormByte {
164 namespace Multimedia {
171 namespace Pipeline {
195 public:
199 class Handle;
200
204 Filters() noexcept;
205
209 Filters(const Filters&) = delete;
210
214 Filters(Filters&&) noexcept = delete;
215
219 ~Filters() noexcept;
220
224 Filters& operator=(const Filters&) = delete;
225
229 Filters& operator=(Filters&&) noexcept = delete;
230
240 Handle Between(StormByte::Safe::Shared<Step> origin,
241 StormByte::Safe::Shared<Step> destination);
242
251 Filters& Add(StormByte::Safe::Shared<Filter::FFmpeg> filter);
252
260 template<typename T, typename... Args>
261 Filters& Add(Args&&... args) {
263 std::forward<Args>(args)...));
264 }
265
276 void Close() noexcept;
277
282 bool Idle() const noexcept;
283
288 StormByte::Safe::Vector<StormByte::Safe::Pair<StormByte::Safe::String, Filter::Report>>
289 Reports() const;
290
298
307 public:
316
324 template<typename T, typename... Args>
325 Handle& Add(Args&&... args) {
327 std::forward<Args>(args)...));
328 }
329
330 private:
334 friend class Filters;
335
341 Handle(Filters& owner, StormByte::Size index) noexcept;
342
343 Filters* m_owner;
344 StormByte::Size m_index;
345 };
346
347 private:
351 friend class Decoder;
352
356 friend class Demuxer;
357
361 friend class Filter::FFmpeg;
362
367
371 friend class StormByte::Multimedia::Backend::Pipeline::Transcoder;
372
376 friend class StormByte::Multimedia::Backend::Pipeline::TopologyAccess;
377
381 void Halt() noexcept;
382
387 using Stretch = Detail::FiltersStretch;
388
393 using Attached = Detail::FiltersAttached;
394
403 static bool Matches(const Filter::FFmpeg& filter, const Step& origin,
404 Producer destination, int track);
405
410 bool Measuring() const noexcept;
411
419 void CloseMeasureSource() noexcept;
420
427 void OnMeasureDrained() noexcept;
428
438 void FinishMeasure() noexcept;
439
443 void BindClock() noexcept;
444
449 void BindPlan(StormByte::Safe::Shared<const class Plan> plan) noexcept;
450
456 void ClockAnalytics() noexcept;
457
464 void NoteAnalytics(std::int64_t ns) noexcept;
465
472 void NoteMeasure(std::int64_t ns) noexcept;
473
474 StormByte::Safe::Vector<Stretch> m_stretches;
475 StormByte::Safe::Vector<Attached> m_globals;
476 StormByte::Safe::Vector<Attached> m_reports;
477 StormByte::Safe::Vector<int> m_measureTracks;
478 std::uint64_t m_measureSources = 0;
479 StormByte::Safe::Atomic<std::uint64_t> m_measureDrained{0};
480 bool m_measuring = false;
481 bool m_hasAnalytics = false;
483 };
484 }
485 }
486}
487
STORMBYTE_DECLARE_MAYBE_SAFE(StormByte::Buffer::Bridge)
Decodes packets of one origin track into frames.
Definition decoder.hxx:148
Reads interleaved compressed packets from the Plan reader.
Definition demuxer.hxx:148
Abstract base for every StormByte Multimedia filter.
Definition ffmpeg.hxx:261
Process that measures the origin before it rewrites.
Definition ffmpeg.hxx:902
Per-stretch Add returned by Between.
Definition filters.hxx:306
Handle & Add(Args &&... args)
Constructs a leaf and mounts it on this stretch.
Definition filters.hxx:325
friend class Filters
Allows the facade to construct handles for its stretches.
Definition filters.hxx:334
Handle & Add(StormByte::Safe::Shared< Filter::FFmpeg > filter)
Mounts a leaf on this stretch only.
Optional facade: Between stretches, Add filters, Close.
Definition filters.hxx:194
StormByte::Safe::Vector< TelemetryStage > StageTelemetries() const
Telemetry handles for every attached filter.
friend class Decoder
Allows the decoder to report measurement and analytics progress.
Definition filters.hxx:351
void Close() noexcept
Wires every stretch.
StormByte::Safe::Vector< StormByte::Safe::Pair< StormByte::Safe::String, Filter::Report > > Reports() const
Reports from attached leaves, in mount order.
bool Idle() const noexcept
Whether every mounted leaf is idle.
friend class Demuxer
Allows the demuxer to notify the facade of measure-source completion.
Definition filters.hxx:356
friend class Filter::FFmpeg
Allows filter workers to coordinate measurement completion.
Definition filters.hxx:361
Handle Between(StormByte::Safe::Shared< Step > origin, StormByte::Safe::Shared< Step > destination)
Stretch from origin to destination.
Filters & Add(StormByte::Safe::Shared< Filter::FFmpeg > filter)
Global analytics.
Closed job intention: owned location reader, writer and tracks.
Definition plan.hxx:206
A pipeline stage that receives and emits media items.
Definition step.hxx:196
static Shared< T > MakePointer(Args &&... args)
Producer
Named stage of the tube.
Definition typedefs.hxx:136
@ Route
A configured connection between pipeline stages.
Definition typedefs.hxx:141
Multimedia module of the StormByte suite.
Pipeline Demux / decode / filter / encode / mux types.
Multimedia-owned pipeline stages and unit holders.
Internal route and filter binding records.
Frame and packet steps attached to a job or a raw pipeline.
Demux / decode / filter / encode / mux types.
Multimedia module of the StormByte suite.
Root namespace of the StormByte C++ suite.
STL namespace.
Provider-owned filter and optional track binding.
Definition filters.hxx:146
StormByte::Safe::Shared< StormByte::Multimedia::Pipeline::Filter::FFmpeg > Filter
Leaf.
Definition filters.hxx:147
StormByte::Safe::Optional< int > Track
Stretch track, or none if global.
Definition filters.hxx:148
Provider-owned route binding stored by the Filters facade.
Definition filters.hxx:134
int Track
Hopper key.
Definition filters.hxx:137
StormByte::Safe::Shared< StormByte::Multimedia::Pipeline::Step > Destination
Encoder / Remuxer / Muxer.
Definition filters.hxx:136
StormByte::Safe::Optional< int > Scope
Optional track scope.
Definition filters.hxx:139
StormByte::Safe::Shared< StormByte::Multimedia::Pipeline::Step > Origin
Decoder / Demuxer / Encoder.
Definition filters.hxx:135
StormByte::Safe::Shared< StormByte::Multimedia::Pipeline::Route > Lane
Wired chain.
Definition filters.hxx:138
Named stage telemetry retained past worker teardown.
Definition telemetry.hxx:382
#define STORMBYTE_MULTIMEDIA_PUBLIC
Definition visibility.h:61