MediaSample¶
primo::codecs::MediaSample
-
class MediaSample : public primo::Reference¶
MediaSample represents one or more samples of audio or video data.
It is used for storing uncompressed or compressed data.
Public Functions
-
virtual MediaBuffer *buffer() = 0¶
Returns the buffer associated with this sample.
- Returns:
A pointer to a MediaBuffer object. Can be NULL.
-
virtual void setBuffer(MediaBuffer *buffer) = 0¶
Sets a new MediaBuffer object.
The old MediaBuffer object is released. The new one is retained.
- Parameters:
buffer – A pointer to the new MediaBuffer object. Can be NULL.
-
virtual void reset() = 0¶
Resets the sample to its default values and clears the data in the buffer.
-
virtual double startTime() const = 0¶
Returns the presentation timestamp (PTS) of the media sample.
- Returns:
time in seconds
-
virtual double endTime() const = 0¶
Returns the end time of the media sample.
Remark
The end time is optional and is valid only if it is greater than the start time.
- Returns:
The time when the sample should end. Time in seconds.
-
virtual void setStartTime(double time) = 0¶
Sets presentation timestamp (PTS) of the media sample.
- Parameters:
time – in seconds
-
virtual void setEndTime(double time) = 0¶
Sets the end time of the media sample.
Remark
The end time is optional and is valid only if it is greater than the start time.
- Parameters:
time – [in] The time when the sample should end. Time is in seconds.
-
virtual int32_t flags() const = 0¶
Returns the media sample flags.
- Returns:
A combination of flags defined in MediaSampleFlags::Enum.
-
virtual void setFlags(int32_t flags) = 0¶
Sets the media sample flags.
- Parameters:
flags – [in] A combination of flags defined in MediaSampleFlags::Enum.
-
virtual void setStreamNumber(int32_t streamNumber) = 0¶
Sets the elementary stream to which the sample belongs.
- Parameters:
streamNumber – [in] A zero-based index of the elementary stream in the container.
-
virtual int32_t streamNumber() const = 0¶
Returns the elementary stream to which the sample belongs.
- Returns:
A zero-based index of the elementary stream in the container.
-
virtual void setPictureType(PictureType::Enum pictureType) = 0¶
Sets the required picture type (I/P/B/etc.).
Note
Currently this is ignored by all encoders.
- Parameters:
pictureType – [in] A constant from the PictureType::Enum.
-
virtual PictureType::Enum pictureType() const = 0¶
Returns the picture type (I/P/B/etc.) of demuxed, decoded, or encoded frame.
Note
Currently this is returned only by the MPEG-2 encoder.
- Returns:
A constant from the PictureType::Enum.
-
virtual void setFrameType(FrameType::Enum frameType) = 0¶
Set the Frame Type object.
- Version
3.2
Note
Currently this is used only by G.711 a-law and u-law codecs.
- Parameters:
frameType – [in] A constant from the FrameType::Enum.
-
virtual FrameType::Enum frameType() const = 0¶
Returns the frame type of demuxed, decoded, or encoded frame.
- Version
3.2
Note
Currently this is used only by G.711 a-law and u-law codecs.
- Returns:
A constant from the FrameType::Enum.
-
virtual MediaSample *clone() const = 0¶
Creates a deep copy of this object.
See also
- Returns:
A new MediaSample object. The caller is responsible for releasing the new object when it’s not needed anymore.
- Returns:
NULL if the object cannot be cloned because there is not enough memory.
-
virtual int32_t videoBufferSizeInBytes(int32_t frameWidth, int32_t frameHeight, ColorFormat::Enum colorFormat) const = 0¶
Calculates the exact number of bytes that are needed for a video frame with the specified properties.
- Parameters:
frameWidth – [in] frame width in pixels.
frameHeight – [in] frame height in pixels.
colorFormat – [in] the color format represents how colors are coded in the video frame.
- Returns:
The number of bytes needed to store a video frame with the specified properties. Zero if it is not possible to calculate the video frame buffer size from the supplied arguments.
-
virtual MediaBuffer *buffer() = 0¶