TMediaInfoT

primo::avblocks::modern::TMediaInfoT

template<typename CharT = char>
class TMediaInfoT

Fluent wrapper for primo::avblocks::MediaInfo, which analyzes a file or a stream and reports its type and properties.

Configure the input socket (see file() and inputs()), call open(), then read the detected streams from outputs() and the metadata from the sockets. In push mode, feed data with push() until isReady().

auto info = TMediaInfo().file("in.mp4").open();
int32_t pins = info.outputs(0).pins().count();

Template Parameters:

CharT – char for UTF-8 std::string paths, wchar_t for std::wstring paths. Use the aliases TMediaInfo and TMediaInfoW. Owns the raw object through a primo::ref. Not copyable, movable.

Unnamed Group

TMediaInfoT(TMediaInfoT&&) = default
TMediaInfoT &operator=(TMediaInfoT&&) = default

Move construction/assignment transfers ownership of the underlying object. The moved-from object no longer wraps anything.

Unnamed Group

inline TMediaInfoT &&file(const string_type &path) &&
inline TMediaInfoT &file(const string_type &path) &

Sets the file of the first input socket, so a probe can be written as TMediaInfo().file(“in.mp4”).open().

Parameters:

path – File name.

Returns:

This object, for chaining. On a temporary the rvalue overload returns the object by rvalue reference, so the chain can be returned or moved.

Unnamed Group

inline TMediaInfoT &open() &
inline TMediaInfoT &&open() &&

Analyzes the input.

If it succeeds, the detected streams and metadata can be read from the object. On a temporary, auto info = TMediaInfo().file(f).open(); moves the opened object into info.

Throws:

TAVBlocksException – if the input cannot be analyzed.

Returns:

This object, for chaining.

Public Types

using string_type = typename string_traits<CharT>::string_type

The string type for paths: std::string for char, std::wstring for wchar_t.

Public Functions

inline TMediaInfoT()

Creates a media info object with one default input socket.

TMediaInfoT(const TMediaInfoT&) = delete
TMediaInfoT &operator=(const TMediaInfoT&) = delete
inline bool tryOpen()

Opens the MediaInfo. Returns true on success, false on failure.

inline bool isReady()

Returns true when stream info and metadata have been fully parsed in push mode.

inline bool push(int32_t inputIndex, TMediaSample &sample)

Pushes a chunk of input data for the socket at inputIndex.

Returns true on success.

inline bool pushEos(int32_t inputIndex)

Signals end-of-stream on the input socket at inputIndex.

Equivalent to pushing a null (empty) sample.

inline TErrorInfo error() const

Returns the error information for the last operation.

inline TMediaSocketList inputs() const

Returns a non-owning view of the input socket list.

inline TMediaSocketT<CharT> inputs(int32_t index) const

Returns the input socket at index, wrapping the existing (non-owned) pointer.

inline TMediaSocketList outputs() const

Returns a non-owning view of the output socket list.

inline TMediaSocketT<CharT> outputs(int32_t index) const

Returns the output socket at index, wrapping the existing (non-owned) pointer.

inline primo::avblocks::MediaInfo *get() const

Returns the raw underlying pointer. For interop with the core API only.