StormByte-Multimedia 3.3.2
C++26 multimedia processing module of the StormByte suite
Loading...
Searching...
No Matches
progress.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
54#include <StormByte/safe/mutex.hxx>
55#include <StormByte/safe/optional.hxx>
56#include <StormByte/safe/pointers.hxx>
57#include <StormByte/safe/string.hxx>
58#include <StormByte/thread_lock.hxx>
59#include <StormByte/type_traits/safe.hxx>
60
61#include <cstdint>
62#include <string>
63
72 class Transcoder;
73}
74
79namespace StormByte {
84 namespace Multimedia {
91 namespace Pipeline {
95 class Demuxer;
96
100 class Filters;
101
105 class Muxer;
106
110 class Transcoder;
111
151 public:
161
178
183 Values Snapshot() const noexcept;
184
189 StormByte::Safe::Optional<double> DurationCalculation() const noexcept;
190
195 bool CalculatingDuration() const noexcept;
196
208 double Main() const noexcept;
209
214 bool MainComplete() const noexcept;
215
219 using Pointer = StormByte::Safe::Shared<const Progress>;
220
224 Progress() noexcept;
225
230 Progress(const Progress& other) = delete;
231
236 Progress(Progress&& other) noexcept = delete;
237
241 ~Progress() noexcept;
242
248 Progress& operator=(const Progress& other) = delete;
249
255 Progress& operator=(Progress&& other) noexcept = delete;
256
261 StormByte::Safe::Optional<double> Measure() const noexcept;
262
267 StormByte::Safe::Optional<double> Analytics() const noexcept;
268
273 bool HasMeasure() const noexcept;
274
279 bool HasAnalytics() const noexcept;
280
285 bool MeasureComplete() const noexcept;
286
291 bool AnalyticsComplete() const noexcept;
292
308 double All() const noexcept;
309
321 operator StormByte::Safe::String() const;
322
323 private:
327 friend class Demuxer;
328
332 friend class Filters;
333
337 friend class Muxer;
338
342 friend class Transcoder;
343
348
352 void BeginDurationCalculation() noexcept;
353
358 void SetDurationCalculation(StormByte::Safe::Optional<double> percent) noexcept;
359
360 mutable StormByte::ThreadLock m_reentrantLock;
361 mutable StormByte::Safe::Mutex m_lock;
362 mutable std::uint32_t m_lockDepth = 0;
363 bool m_calculatingDuration = false;
364 mutable char m_durationIndicator = '|';
365 StormByte::Safe::Optional<double> m_durationCalculation;
366
371 void HasMeasure(bool on) noexcept;
372
377 void HasAnalytics(bool on) noexcept;
378
383 void SetDurationNs(std::int64_t ns) noexcept;
384
389 void SetMeasureNs(std::int64_t ns) noexcept;
390
395 void SetPassNs(std::int64_t ns) noexcept;
396
401 void SetAnalyticsNs(std::int64_t ns) noexcept;
402
406 void MeasureDone() noexcept;
407
411 void MuxDone() noexcept;
412
416 void AnalyticsDone() noexcept;
417
424 static double Axis(std::int64_t pos, std::int64_t dur) noexcept;
425
426 bool m_hasMeasure = false;
427 bool m_hasAnalytics = false;
428 bool m_measureDone = false;
429 bool m_muxDone = false;
430 bool m_analyticsDone = false;
431 std::int64_t m_durationNs = 0;
432 std::int64_t m_measureNs = 0;
433 std::int64_t m_passNs = 0;
434 std::int64_t m_analyticsNs = 0;
435 mutable double m_all = 0.0;
436 };
437 }
438 }
439}
440
STORMBYTE_DECLARE_MAYBE_SAFE(StormByte::Buffer::Bridge)
Reads interleaved compressed packets from the Plan reader.
Definition demuxer.hxx:148
Optional facade: Between stretches, Add filters, Close.
Definition filters.hxx:194
Writes interleaved packets to the Plan writer.
Definition muxer.hxx:217
bool CalculatingDuration() const noexcept
Whether the duration scan owns the status line.
StormByte::Safe::Optional< double > DurationCalculation() const noexcept
Duration scan percent.
bool AnalyticsComplete() const noexcept
Whether analytics is finished.
bool HasMeasure() const noexcept
Whether this tube mounted a measure pass.
double Main() const noexcept
Main job percent: how much of the destination is written.
StormByte::Safe::Optional< double > Analytics() const noexcept
Dest-look percent, if analytics taps exist.
double All() const noexcept
Combined job percent.
StormByte::Safe::Shared< const Progress > Pointer
User-facing handle.
Definition progress.hxx:219
friend class Filters
Allows the filter coordinator to update progress.
Definition progress.hxx:332
operator StormByte::Safe::String() const
One CR-safe line: live axes plus All.
Phase
Exclusive phase currently presented to the user.
Definition progress.hxx:155
friend class Demuxer
Allows the source stage to update progress.
Definition progress.hxx:327
Values Snapshot() const noexcept
Capture phase and values atomically.
bool MainComplete() const noexcept
Whether the main job finished writing the destination.
bool MeasureComplete() const noexcept
Whether the measure pass is finished.
StormByte::Safe::Optional< double > Measure() const noexcept
First-pass percent, if the tube mounted 2-pass.
friend class Muxer
Allows the destination stage to update progress.
Definition progress.hxx:337
bool HasAnalytics() const noexcept
Whether this tube mounted analytics taps.
friend class Transcoder
Allows the public job coordinator to update progress.
Definition progress.hxx:342
Facade that maps tracks and runs one reader-to-writer job.
Definition transcoder.hxx:315
Multimedia module of the StormByte suite.
Pipeline Demux / decode / filter / encode / mux types.
Multimedia-owned pipeline stages and unit holders.
Demux / decode / filter / encode / mux types.
@ Processing
Executing Process, excluding instrumented waits.
Definition activity.hxx:82
Multimedia module of the StormByte suite.
Root namespace of the StormByte C++ suite.
STL namespace.
Consistent values captured under one clock lock.
Definition progress.hxx:167
double All
Weighted job percent; only reaches 100 once every axis is closed.
Definition progress.hxx:173
bool MainComplete
Whether the destination trailer has been written.
Definition progress.hxx:176
StormByte::Safe::Optional< double > Measure
Mounted measure percent, hidden during duration.
Definition progress.hxx:170
bool AnalyticsComplete
Whether the optional analytics axis is closed.
Definition progress.hxx:175
StormByte::Safe::Optional< double > Duration
Duration scan percent; empty during CPU-only preparation.
Definition progress.hxx:169
bool MeasureComplete
Whether the optional measure axis is closed.
Definition progress.hxx:174
StormByte::Safe::Optional< double > Analytics
Mounted analytics percent, hidden during duration.
Definition progress.hxx:171
Phase Current
Exclusive display phase.
Definition progress.hxx:168
double Main
Main job percent (written output), without measure or analytics.
Definition progress.hxx:172
#define STORMBYTE_MULTIMEDIA_PUBLIC
Definition visibility.h:61