libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
mediaiodescription.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <promeki/namespace.h>
14#include <promeki/datastream.h>
15#include <promeki/error.h>
16#include <promeki/framecount.h>
17#include <promeki/framerate.h>
18#include <promeki/json.h>
19#include <promeki/list.h>
20#include <promeki/mediadesc.h>
21#include <promeki/metadata.h>
22#include <promeki/sharedptr.h>
23#include <promeki/string.h>
24#include <promeki/stringlist.h>
25
26PROMEKI_NAMESPACE_BEGIN
27
37struct MediaIOPortDescription {
39 enum Role {
40 Source = 0,
41 Sink
42 };
43
45 using List = ::promeki::List<MediaIOPortDescription>;
46
48 String name;
49
51 int index = -1;
52
54 Role role = Source;
55
63 int portGroupIndex = -1;
64
75 MediaDesc::List producibleFormats;
76
87 MediaDesc::List acceptableFormats;
88
90 MediaDesc preferredFormat;
91};
92
103struct MediaIOPortGroupDescription {
105 using List = ::promeki::List<MediaIOPortGroupDescription>;
106
108 String name;
109
111 FrameRate frameRate;
112
114 FrameCount frameCount;
115
117 bool canSeek = false;
118
128 String clockDescription;
129};
130
163class MediaIODescription {
164 PROMEKI_SHARED_FINAL(MediaIODescription)
165 public:
167 using Ptr = SharedPtr<MediaIODescription>;
168
170 using List = ::promeki::List<MediaIODescription>;
171
173 using PtrList = ::promeki::List<Ptr>;
174
181 static constexpr FrameCount FrameCountUnknown = FrameCount::unknown();
182
184 static constexpr FrameCount FrameCountInfinite = FrameCount::infinity();
185
187 MediaIODescription() = default;
188
189 // ------------------------------------------------------------
190 // Backend identity
191 // ------------------------------------------------------------
192
194 const String &backendName() const { return _backendName; }
195
197 void setBackendName(const String &val) { _backendName = val; }
198
200 const String &backendDescription() const { return _backendDescription; }
201
203 void setBackendDescription(const String &val) { _backendDescription = val; }
204
205 // ------------------------------------------------------------
206 // Instance identity
207 // ------------------------------------------------------------
208
210 const String &name() const { return _name; }
211
213 void setName(const String &val) { _name = val; }
214
215 // ------------------------------------------------------------
216 // Role flags
217 // ------------------------------------------------------------
218
220 bool canBeSource() const { return _canBeSource; }
221
223 void setCanBeSource(bool val) { _canBeSource = val; }
224
226 bool canBeSink() const { return _canBeSink; }
227
229 void setCanBeSink(bool val) { _canBeSink = val; }
230
232 bool canBeTransform() const { return _canBeTransform; }
233
235 void setCanBeTransform(bool val) { _canBeTransform = val; }
236
237 // ------------------------------------------------------------
238 // Format landscape
239 // ------------------------------------------------------------
240
249 const MediaDesc::List &producibleFormats() const { return _producibleFormats; }
250
252 MediaDesc::List &producibleFormats() { return _producibleFormats; }
253
255 void setProducibleFormats(const MediaDesc::List &val) { _producibleFormats = val; }
256
264 const MediaDesc::List &acceptableFormats() const { return _acceptableFormats; }
265
267 MediaDesc::List &acceptableFormats() { return _acceptableFormats; }
268
270 void setAcceptableFormats(const MediaDesc::List &val) { _acceptableFormats = val; }
271
281 const MediaDesc &preferredFormat() const { return _preferredFormat; }
282
284 void setPreferredFormat(const MediaDesc &val) { _preferredFormat = val; }
285
286 // ------------------------------------------------------------
287 // Capabilities
288 // ------------------------------------------------------------
289
291 bool canSeek() const { return _canSeek; }
292
294 void setCanSeek(bool val) { _canSeek = val; }
295
303 const FrameCount &frameCount() const { return _frameCount; }
304
306 void setFrameCount(const FrameCount &val) { _frameCount = val; }
307
309 const FrameRate &frameRate() const { return _frameRate; }
310
312 void setFrameRate(const FrameRate &val) { _frameRate = val; }
313
315 const Metadata &containerMetadata() const { return _containerMetadata; }
316
318 Metadata &containerMetadata() { return _containerMetadata; }
319
321 void setContainerMetadata(const Metadata &val) { _containerMetadata = val; }
322
323 // ------------------------------------------------------------
324 // Diagnostics
325 // ------------------------------------------------------------
326
337 Error probeStatus() const { return _probeStatus; }
338
340 void setProbeStatus(Error val) { _probeStatus = val; }
341
343 const String &probeMessage() const { return _probeMessage; }
344
346 void setProbeMessage(const String &val) { _probeMessage = val; }
347
348 // ------------------------------------------------------------
349 // Per-port snapshots (multi-port refactor, Phase 6)
350 // ------------------------------------------------------------
351
353 const MediaIOPortDescription::List &sources() const { return _sources; }
354
356 MediaIOPortDescription::List &sources() { return _sources; }
357
359 void setSources(const MediaIOPortDescription::List &val) { _sources = val; }
360
362 const MediaIOPortDescription::List &sinks() const { return _sinks; }
363
365 MediaIOPortDescription::List &sinks() { return _sinks; }
366
368 void setSinks(const MediaIOPortDescription::List &val) { _sinks = val; }
369
371 const MediaIOPortGroupDescription::List &portGroups() const { return _portGroups; }
372
374 MediaIOPortGroupDescription::List &portGroups() { return _portGroups; }
375
377 void setPortGroups(const MediaIOPortGroupDescription::List &val) { _portGroups = val; }
378
379 // ------------------------------------------------------------
380 // Convenience
381 // ------------------------------------------------------------
382
393 StringList summary() const;
394
402 JsonObject toJson() const;
403
434 static MediaIODescription fromJson(const JsonObject &obj, Error *err = nullptr);
435
437 bool operator==(const MediaIODescription &other) const;
438 bool operator!=(const MediaIODescription &other) const { return !(*this == other); }
439
440 private:
441 String _backendName;
442 String _backendDescription;
443
444 String _name;
445
446 bool _canBeSource = false;
447 bool _canBeSink = false;
448 bool _canBeTransform = false;
449
450 MediaDesc::List _producibleFormats;
451 MediaDesc::List _acceptableFormats;
452 MediaDesc _preferredFormat;
453
454 bool _canSeek = false;
455 FrameCount _frameCount;
456 FrameRate _frameRate;
457 Metadata _containerMetadata;
458
459 Error _probeStatus = Error::Ok;
460 String _probeMessage;
461
462 MediaIOPortDescription::List _sources;
463 MediaIOPortDescription::List _sinks;
464 MediaIOPortGroupDescription::List _portGroups;
465};
466
468DataStream &operator<<(DataStream &stream, const MediaIODescription &d);
469
471DataStream &operator>>(DataStream &stream, MediaIODescription &d);
472
473PROMEKI_NAMESPACE_END
474
475#endif // PROMEKI_ENABLE_PROAV