StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
track.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/clonable.hxx>
42#include <StormByte/iterable.hxx>
46
47#include <memory>
48#include <vector>
49
74 public StormByte::Clonable<Track, std::unique_ptr<Track>> {
75 public:
86 Track(int in, enum StormByte::Multimedia::Type type) noexcept;
87
93 Track(int in, const Config::Base& config) noexcept;
94
100 Track(int in, Config::Base&& config) noexcept;
101
106 Track(const Track& other);
107
112 Track(Track&& other) noexcept = default;
113
117 virtual ~Track() noexcept override = default;
118
124 Track& operator=(const Track& other);
125
131 Track& operator=(Track&& other) noexcept = default;
132
141 inline PointerType Clone() const override {
142 return MakePointer<Track>(*this);
143 }
144
149 inline PointerType Move() override {
150 return MakePointer<Track>(std::move(*this));
151 }
152
162 inline enum StormByte::Multimedia::Type Type() const noexcept {
163 return m_type;
164 }
165
170 inline int In() const noexcept {
171 return m_in;
172 }
173
178 inline const Config::Base* Config() const noexcept {
179 return m_config.get();
180 }
181
186 private:
187 int m_in;
188 enum StormByte::Multimedia::Type m_type;
189 std::unique_ptr<Config::Base> m_config;
190 };
191
203 protected StormByte::Iterable<std::vector<std::unique_ptr<Track>>> {
204 public:
205 using size_type = StormByte::Iterable<std::vector<std::unique_ptr<Track>>>::size_type;
206 using const_iterator = StormByte::Iterable<std::vector<std::unique_ptr<Track>>>::const_iterator;
207
216 Tracks() noexcept = default;
217
222 Tracks(const Tracks& other);
223
228 Tracks(Tracks&& other) noexcept = default;
229
233 virtual ~Tracks() noexcept = default;
234
240 Tracks& operator=(const Tracks& other);
241
247 Tracks& operator=(Tracks&& other) noexcept = default;
248
262 inline const_iterator begin() const noexcept {
263 return Iterable::begin();
264 }
265
270 inline const_iterator end() const noexcept {
271 return Iterable::end();
272 }
273
278 inline const_iterator cbegin() const noexcept {
279 return Iterable::cbegin();
280 }
281
286 inline const_iterator cend() const noexcept {
287 return Iterable::cend();
288 }
289
295 inline const Track& operator[](size_type i) const {
296 return *Iterable::operator[](i);
297 }
298
303 inline size_type size() const noexcept {
304 return Iterable::size();
305 }
306
311 inline bool empty() const noexcept {
312 return Iterable::empty();
313 }
314
319 inline void add(const Track& track) {
320 Iterable::add(track.Clone());
321 }
322
327 inline void add(Track&& track) {
328 Iterable::add(track.Move());
329 }
330
334 };
335}
Common destination-stream identity.
Definition base.hxx:90
One source stream that enters the tube.
Definition track.hxx:74
enum StormByte::Multimedia::Type Type() const noexcept
Media stamped at construction.
Definition track.hxx:162
int In() const noexcept
Origin stream index.
Definition track.hxx:170
Track(int in, enum StormByte::Multimedia::Type type) noexcept
Track without a config leaf.
Track(int in, Config::Base &&config) noexcept
Builds a track; moves config and copies its type.
PointerType Move() override
Move into a new pointer.
Definition track.hxx:149
Track(Track &&other) noexcept=default
Move constructor.
virtual ~Track() noexcept override=default
Destructor.
Track(int in, const Config::Base &config) noexcept
Builds a track; clones config and copies its type.
const Config::Base * Config() const noexcept
Track config leaf, if any.
Definition track.hxx:178
Track(const Track &other)
Copy constructor.
PointerType Clone() const override
Deep copy.
Definition track.hxx:141
Ordered tube tracks.
Definition track.hxx:203
void add(Track &&track)
Appends track via Track::Move.
Definition track.hxx:327
StormByte::Iterable< std::vector< std::unique_ptr< Track > > >::size_type size_type
Count type.
Definition track.hxx:205
const_iterator cend() const noexcept
Const end.
Definition track.hxx:286
const_iterator end() const noexcept
Const end.
Definition track.hxx:270
const Track & operator[](size_type i) const
Track at mux slot i.
Definition track.hxx:295
size_type size() const noexcept
Element count.
Definition track.hxx:303
void add(const Track &track)
Appends a clone of track.
Definition track.hxx:319
Tracks() noexcept=default
Empty list.
bool empty() const noexcept
Whether there are no tracks.
Definition track.hxx:311
const_iterator cbegin() const noexcept
Const begin.
Definition track.hxx:278
StormByte::Iterable< std::vector< std::unique_ptr< Track > > >::const_iterator const_iterator
Const iterator.
Definition track.hxx:206
Demux / decode / filter / encode / mux types.
Type
Kind of media stream or codec.
Definition type.hxx:55
#define STORMBYTE_MULTIMEDIA_PUBLIC
Imported symbol.
Definition visibility.h:47