StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
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 * 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
46
47#include <cstddef>
48#include <cstdint>
49#include <memory>
50#include <optional>
51#include <string>
52#include <utility>
53#include <vector>
54
56 class Transcoder;
57}
58
66 class Decoder;
67 class Demuxer;
68 class Route;
69
103 friend class Decoder;
104 friend class Demuxer;
105 friend class Filter::FFmpeg;
107 friend class StormByte::Multimedia::Backend::Pipeline::Transcoder;
108
109 public:
110 class Handle;
111
115 Filters() noexcept;
116
120 Filters(const Filters&) = delete;
121
125 Filters(Filters&&) noexcept = delete;
126
130 ~Filters() noexcept;
131
135 Filters& operator=(const Filters&) = delete;
136
140 Filters& operator=(Filters&&) noexcept = delete;
141
151 Handle Between(std::shared_ptr<Step> origin,
152 std::shared_ptr<Step> destination) noexcept;
153
162 Filters& Add(std::shared_ptr<Filter::FFmpeg> filter) noexcept;
163
171 template<typename T, typename... Args>
172 Filters& Add(Args&&... args) noexcept {
173 return Add(std::shared_ptr<Filter::FFmpeg>(
174 std::make_shared<T>(std::forward<Args>(args)...)));
175 }
176
187 void Close() noexcept;
188
193 bool Idle() const noexcept;
194
199 std::vector<std::pair<std::string, Filter::Report>> Reports() const noexcept;
200
206 public:
214 Handle& Add(std::shared_ptr<Filter::FFmpeg> filter) noexcept;
215
223 template<typename T, typename... Args>
224 Handle& Add(Args&&... args) noexcept {
225 return Add(std::shared_ptr<Filter::FFmpeg>(
226 std::make_shared<T>(std::forward<Args>(args)...)));
227 }
228
229 private:
230 friend class Filters;
231
237 Handle(Filters& owner, std::size_t index) noexcept;
238
239 Filters* m_owner;
240 std::size_t m_index;
241 };
242
243 private:
248 bool Measuring() const noexcept;
249
256 bool MeasureReadyToFinish() const noexcept;
257
265 void CloseMeasureSource() noexcept;
266
274 void OnMeasureDrained(int track) noexcept;
275
282 void OnMeasureFilterDrained() noexcept;
283
290 void MaybeFinishMeasure() noexcept;
291
300 void FinishMeasure() noexcept;
301
305 void BindClock() noexcept;
306
312 void ClockAnalytics() noexcept;
313
320 void NoteAnalytics(std::int64_t ns) noexcept;
321
328 void NoteMeasure(std::int64_t ns) noexcept;
329
333 struct Stretch {
334 std::shared_ptr<Step> Origin;
335 std::shared_ptr<Step> Destination;
336 int Track = -1;
337 std::unique_ptr<Route> Lane;
338 std::optional<int> Scope;
339 };
340
344 struct Attached {
345 std::shared_ptr<Filter::FFmpeg> Filter;
346 std::optional<int> Track;
347 };
348
349 std::vector<Stretch> m_stretches;
350 std::vector<Attached> m_globals;
351 std::vector<Attached> m_reports;
352 std::vector<int> m_measureTracks;
353 std::vector<int> m_measureDrained;
354 std::size_t m_measureFilterCount = 0;
355 std::size_t m_measureFiltersDrained = 0;
356 bool m_measuring = false;
357 bool m_hasAnalytics = false;
358 std::shared_ptr<class Progress> m_progress;
359 };
360}
Decodes packets of one origin track into frames.
Definition decoder.hxx:150
Reads interleaved packets from a File origin.
Definition demuxer.hxx:142
Abstract base for every StormByte Multimedia filter.
Definition ffmpeg.hxx:253
Process that measures the origin before it rewrites.
Definition ffmpeg.hxx:811
Per-stretch Add returned by Between.
Definition filters.hxx:205
Handle & Add(std::shared_ptr< Filter::FFmpeg > filter) noexcept
Mounts a leaf on this stretch only.
Handle & Add(Args &&... args) noexcept
Constructs a leaf and mounts it on this stretch.
Definition filters.hxx:224
friend class Filters
Definition filters.hxx:230
Filters & Add(std::shared_ptr< Filter::FFmpeg > filter) noexcept
Global analytics.
std::vector< std::pair< std::string, Filter::Report > > Reports() const noexcept
Reports from attached leaves, in mount order.
friend class Decoder
Definition filters.hxx:103
void Close() noexcept
Wires every stretch.
bool Idle() const noexcept
Whether every mounted leaf is idle.
friend class Demuxer
Definition filters.hxx:104
friend class Filter::FFmpeg
Definition filters.hxx:105
Handle Between(std::shared_ptr< Step > origin, std::shared_ptr< Step > destination) noexcept
Stretch from origin to destination.
One stage with a Backend::Pipeline::Pipe (in / out).
Definition step.hxx:114
One source stream that enters the tube.
Definition track.hxx:74
Frame and packet steps attached to a job or a raw pipeline.
Multimedia-owned pipeline stages and unit holders.
Definition AVFormatContext.hxx:52
Demux / decode / filter / encode / mux types.
@ Route
Route
Definition typedefs.hxx:110
#define STORMBYTE_MULTIMEDIA_PUBLIC
Imported symbol.
Definition visibility.h:47