AVBlocks for C++  1.13
Audio and Video Software Development Kit
MediaBuffer Class Referenceabstract

A buffer for media data. More...

Inherits Reference.

Public Member Functions

virtual bool_t setData (int32_t dataOffset, int32_t dataSize)=0
 Sets the offset at which valid data starts in the buffer block and the data size in bytes. More...
 
virtual int32_t dataOffset () const =0
 Returns the offset at which valid data starts in the buffer. More...
 
virtual int32_t dataSize () const =0
 Returns the size of the valid data that in the buffer. More...
 
virtual uint8_t * data () const =0
 Returns a pointer to the first byte of data. More...
 
virtual uint8_t * start () const =0
 Returns a pointer to the start of the buffer. More...
 
virtual int32_t capacity () const =0
 Returns the size of the buffer in bytes. More...
 
- Public Member Functions inherited from Reference
virtual int32_t retain () const =0
 Retains the instance. More...
 
virtual int32_t release () const =0
 Releases the instance. More...
 
virtual int32_t retainCount () const =0
 Returns the current reference count. More...
 

Protected Member Functions

 ~MediaBuffer ()
 This object can be destroyed only by its implementation. More...
 

Detailed Description

A buffer for media data.

MediaBuffer has a capacity which is the size of the buffer and data size which is the size of the actual data in the buffer. The buffer is a continuous block of memory. The valid data is also a continuous block. The data can start at any offset in the buffer.

Constructor & Destructor Documentation

~MediaBuffer ( )
protected

This object can be destroyed only by its implementation.

The caller must use Reference::release.

See Also
Object Management

Member Function Documentation

virtual int32_t capacity ( ) const
pure virtual

Returns the size of the buffer in bytes.

Returns
Buffer capacity. Can be zero.

Referenced by Buffer::freeLinearSpace().

virtual uint8_t* data ( ) const
pure virtual

Returns a pointer to the first byte of data.

This is effectively the same as start() + dataOffset().

Returns
A pointer to the data start.

Referenced by Buffer::normalize(), and Buffer::push().

virtual int32_t dataOffset ( ) const
pure virtual

Returns the offset at which valid data starts in the buffer.

Returns
An offset that can range from 0 to capacity()-1.

Referenced by Buffer::freeLinearSpace(), Buffer::normalize(), Buffer::pop(), and Buffer::push().

virtual int32_t dataSize ( ) const
pure virtual

Returns the size of the valid data that in the buffer.

Returns
The data size in bytes. It ranges from 0 to capacity().

Referenced by Buffer::freeLinearSpace(), Buffer::normalize(), Buffer::pop(), and Buffer::push().

virtual bool_t setData ( int32_t  dataOffset,
int32_t  dataSize 
)
pure virtual

Sets the offset at which valid data starts in the buffer block and the data size in bytes.

The data offset and size are validated so that they are always within the buffer.

Parameters
dataOffsetThe offset at which valid data starts in the buffer. Allowed values range from 0 to capacity()-1.
dataSizeThe size of the valid data in the buffer. Allowed values range from 0 to capacity().
Returns
TRUE The data offset and size are successfully changed. FALSE The supplied data offset and size are not valid.

Referenced by Buffer::clear(), Buffer::normalize(), Buffer::pop(), and Buffer::push().

virtual uint8_t* start ( ) const
pure virtual

Returns a pointer to the start of the buffer.

Returns
A pointer to the buffer start. It is guaranteed that the pointer is valid only when capacity() is greater than 0.

Referenced by Buffer::normalize().