StormByte-Multimedia 3.3.2
C++26 multimedia processing module of the StormByte suite
Loading...
Searching...
No Matches
file.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/buffer/io/buffered_location_reader.hxx>
61#include <StormByte/safe/function.hxx>
62#include <StormByte/safe/optional.hxx>
63#include <StormByte/safe/pointers.hxx>
64#include <StormByte/safe/string.hxx>
65#include <StormByte/safe/unordered_map.hxx>
66#include <StormByte/safe/vector.hxx>
67
68#include <cstdint>
69
77 class Demuxer;
78}
79
84namespace StormByte {
89 namespace Multimedia {
94 namespace FFmpeg {
98 class AVFormatContext;
99 }
100 }
101}
102
107namespace StormByte {
112 namespace Multimedia {
136 public:
140 friend class StormByte::Multimedia::Backend::Pipeline::Demuxer;
141
149
153 File(const File&) = delete;
154
159 File(File&& other) noexcept;
160
164 ~File() noexcept;
165
171 File& operator=(const File& other) = delete;
172
178 File& operator=(File&& other) = delete;
179
184 StormByte::Safe::String Path() const;
185
190 const class Container& Container() const noexcept { return m_container; }
191
196 const StormByte::Safe::Vector<Stream>& Streams() const noexcept { return m_streams; }
197
203
211 const Metadata::File& Metadata() const noexcept { return m_metadata; }
212
221 const StormByte::Safe::Optional<Property::Duration>& DurationHint() const noexcept { return m_duration; }
222
236
248
257
266
267 private:
270 const class Container& m_container;
271 mutable StormByte::Safe::Vector<Stream> m_streams;
273 Metadata::File m_metadata;
275 mutable bool m_durationResolved;
277
290 const class Container& container,
292 Metadata::File metadata,
293 StormByte::Safe::Optional<Property::Duration> duration, bool durationResolved) noexcept;
294
307
312 void ResolveDuration(const DurationProgress* progress) const;
313
322 static bool ScanWithReader(StormByte::Buffer::IO::BufferedLocationReader& reader,
324 StormByte::Safe::Optional<Property::Duration>& duration, const DurationProgress* progress);
325
330 static void MarkHdr10Plus(Stream& stream);
331
338 static bool DetectHdr10Plus(FFmpeg::AVFormatContext& ctx, StormByte::Safe::Vector<Stream>& streams) noexcept;
339
350 static bool ScanDurations(FFmpeg::AVFormatContext& ctx, StormByte::Safe::Vector<Stream>& streams,
353 const DurationProgress* progress, double& percent);
354 };
355 }
356}
357
STORMBYTE_DECLARE_MAYBE_SAFE(StormByte::Buffer::Bridge)
Private metadata probe.
Immutable container identity owned by StormByte::Multimedia::Registry.
Definition container.hxx:84
Read-only consultation snapshot of a media source.
Definition file.hxx:135
StormByte::Safe::String Path() const
Path label: stored path, or reader.Path() if borrowed.
static ExpectedFile Open(StormByte::Buffer::IO::BufferedLocationReader &reader, StormByte::Safe::Optional< std::int64_t > duration={})
Opens and probes reader with AVIO only.
StormByte::Safe::Function< void(double)> DurationProgress
Provider-owned observer receiving monotone scan percentages.
Definition file.hxx:148
File(const File &)=delete
Copy construction is unavailable for source snapshots.
File(File &&other) noexcept
Move constructor.
static ExpectedFile Open(const StormByte::Safe::String &path, StormByte::Safe::Optional< std::int64_t > duration={})
Opens and probes path.
const class Container & Container() const noexcept
Detected container.
Definition file.hxx:190
const StormByte::Safe::Vector< Stream > & Streams() const noexcept
Real streams in container order.
Definition file.hxx:196
const StormByte::Safe::Optional< Property::Duration > & DurationHint() const noexcept
Best available duration without scanning the source.
Definition file.hxx:221
const StormByte::Safe::Optional< Property::Duration > & Duration() const
Container duration.
const Metadata::File & Metadata() const noexcept
File tags captured at Open.
Definition file.hxx:211
const StormByte::Safe::Vector< Attachment > & Attachments() const noexcept
Container attachments (covers, fonts).
~File() noexcept
Destructor.
const StormByte::Safe::Optional< Property::Duration > & Duration(const DurationProgress &progress) const
Resolve duration while reporting packet scan progress.
File tags and header fields captured at Open.
Definition file.hxx:120
Public media stream snapshot.
Definition stream.hxx:86
Incomplete FFmpeg types for RAII headers.
Multimedia-owned pipeline stages and unit holders.
Private RAII wrappers over libav*.
@ Demuxer
Container reader; owns the demux pending queues.
Definition telemetry.hxx:393
Multimedia module of the StormByte suite.
StormByte::Expected< File, FileOpenException > ExpectedFile
Result of OpenFile.
Definition typedefs.hxx:298
Root namespace of the StormByte C++ suite.
#define STORMBYTE_MULTIMEDIA_PUBLIC
Definition visibility.h:61