TMediaSample¶
primo::avblocks::modern::TMediaSample
-
class TMediaSample¶
Fluent wrapper for
primo::codecs::MediaSample, one or more samples of audio or video data.Holds compressed or uncompressed data in a
TMediaBuffertogether with timing and stream information. Owns the raw object through aprimo::ref. Not copyable, movable.Unnamed Group
-
TMediaSample(TMediaSample&&) = default¶
-
TMediaSample &operator=(TMediaSample&&) = default¶
Move construction/assignment transfers ownership of the underlying object. The moved-from object no longer wraps anything.
Unnamed Group
-
inline TMediaSample &&buffer(TMediaBuffer &&buf) &&¶
-
inline TMediaSample &buffer(TMediaBuffer &&buf) &¶
Sets the buffer of the sample.
The sample retains the buffer and releases the previous one.
- Parameters:
buf – The new buffer.
- Returns:
This object, for chaining.
Public Functions
-
inline TMediaSample()¶
Creates an empty media sample.
-
inline explicit TMediaSample(primo::ref<primo::codecs::MediaSample> sample)¶
Takes ownership of an existing
MediaSamplereference.
-
TMediaSample(const TMediaSample&) = delete¶
-
TMediaSample &operator=(const TMediaSample&) = delete¶
-
inline TMediaSample &buffer(std::nullptr_t)¶
Removes the buffer from the sample. Returns this object, for chaining.
-
inline TMediaBuffer buffer() const¶
Returns the buffer of the sample. The returned wrapper is invalid if the sample has no buffer.
-
inline double startTime() const¶
Returns the presentation timestamp (PTS) of the sample in seconds.
-
inline double endTime() const¶
Returns the end time of the sample in seconds. It is optional and valid only if greater than the start time.
-
inline int32_t flags() const¶
Returns the sample flags, a combination of
primo::codecs::MediaSampleFlags::Enumvalues.
-
inline int32_t streamNumber() const¶
Returns the zero-based index of the elementary stream in the container to which the sample belongs.
-
inline primo::codecs::PictureType::Enum pictureType() const¶
Returns the picture type (I/P/B/etc.) of a demuxed, decoded or encoded frame. Currently set only by the MPEG-2 encoder.
-
inline primo::codecs::FrameType::Enum frameType() const¶
Returns the frame type of a demuxed, decoded or encoded frame. Currently used only by the G.711 a-law and u-law codecs.
-
inline int32_t videoBufferSizeInBytes(int32_t width, int32_t height, primo::codecs::ColorFormat::Enum colorFormat) const¶
Calculates the exact number of bytes needed for a video frame with the given properties.
- Parameters:
width – Frame width in pixels.
height – Frame height in pixels.
colorFormat – How colors are coded in the frame.
- Returns:
The size in bytes, or 0 if it cannot be calculated.
-
inline TMediaSample &startTime(double time)¶
Sets the presentation timestamp (PTS) of the sample.
- Parameters:
time – Time in seconds.
- Returns:
This object, for chaining.
-
inline TMediaSample &endTime(double time)¶
Sets the end time of the sample.
It is optional and valid only if greater than the start time.
- Parameters:
time – Time in seconds.
- Returns:
This object, for chaining.
-
inline TMediaSample &flags(int32_t f)¶
Sets the sample flags.
- Parameters:
f – A combination of
primo::codecs::MediaSampleFlags::Enumvalues.- Returns:
This object, for chaining.
-
inline TMediaSample &streamNumber(int32_t n)¶
Sets the elementary stream to which the sample belongs.
- Parameters:
n – Zero-based index of the elementary stream in the container.
- Returns:
This object, for chaining.
-
inline TMediaSample &pictureType(primo::codecs::PictureType::Enum pt)¶
Sets the required picture type (I/P/B/etc.).
Currently ignored by all encoders.
- Returns:
This object, for chaining.
-
inline TMediaSample &frameType(primo::codecs::FrameType::Enum ft)¶
Sets the frame type.
Currently used only by the G.711 a-law and u-law codecs.
- Returns:
This object, for chaining.
-
inline TMediaSample &reset()¶
Resets the sample to its default values and clears the data in its buffer. Returns this object, for chaining.
-
inline TMediaSample clone() const¶
Creates a deep copy of the sample.
-
inline primo::codecs::MediaSample *get() const¶
Returns the raw underlying pointer. For interop with the core API only.
-
TMediaSample(TMediaSample&&) = default¶