gstreamermm  1.0.10
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gst::Buffer Class Reference

A data-passing buffer type, supporting sub-buffers. More...

Inheritance diagram for Gst::Buffer:
Inheritance graph
[legend]
Collaboration diagram for Gst::Buffer:
Collaboration graph
[legend]

Public Member Functions

void reference () const
 Increment the reference count for this object. More...
 
void unreference () const
 Decrement the reference count for this object. More...
 
GstBuffer* gobj ()
 Provides access to the underlying C instance. More...
 
const GstBuffer* gobj () const
 Provides access to the underlying C instance. More...
 
GstBuffer* gobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
Glib::RefPtr< Gst::Buffercopy () const
 Create a copy of the given buffer. More...
 
void copy_into (Glib::RefPtr< Gst::Buffer > source_buffer, BufferCopyFlags flags, gsize offset, gsize size)
 Copies the information from src into dest. More...
 
Glib::RefPtr< Gst::Buffercreate_writable ()
 Makes a writable buffer from the given buffer. More...
 
Glib::RefPtr< Gst::Memoryget_memory (guint idx) const
 Get the memory block at index idx in buffer. More...
 
gsize get_size () const
 Get the total size of the memory blocks in buffer. More...
 
Glib::RefPtr< Gst::Memoryget_all_memory () const
 Get all the memory block in buffer. More...
 
gsize fill (gsize offset, gconstpointer src, gsize size)
 Copy size bytes from src to buffer at offset. More...
 
Glib::RefPtr< Gst::Bufferappend (const Glib::RefPtr< Gst::Buffer >& buf) const
 Append all the memory from buf2 to buf1. More...
 
Glib::RefPtr< Gst::Bufferappend_region (const Glib::RefPtr< Gst::Buffer >& buf, gssize offset, gssize size) const
 Append size bytes at offset from buf2 to buf1. More...
 
void replace_memory_range (guint idx, gint length, Glib::RefPtr< Gst::Memory > mem)
 Replaces length memory blocks in buffer starting at idx with mem. More...
 
void remove_memory (guint idx)
 Remove the memory block in b at index i. More...
 
void remove_all_memory ()
 Remove all the memory blocks in buffer. More...
 
gsize memset (gsize offset, guint8 val, gsize size)
 Fill buf with size bytes with val starting from offset. More...
 
void replace_memory (guint idx, Glib::RefPtr< Gst::Memory > mem)
 Replaces the memory block at index idx in buffer with mem. More...
 
gsize extract (gsize offset, gpointer dest, gsize size)
 Copy size bytes starting from offset in buffer to dest. More...
 
int memcmp (gsize offset, gconstpointer mem, gsize size)
 Compare size bytes starting from offset in buffer with the memory in mem. More...
 
ClockTime get_pts () const
 
void set_pts (const ClockTime& value)
 
ClockTime get_dts () const
 
void set_dts (const ClockTime& value)
 
ClockTime get_duration () const
 Get duration of this buffer. More...
 
void set_duration (const ClockTime& value)
 
bool map (const Glib::RefPtr< Gst::MapInfo >& info, MapFlags flags)
 This function fills info with the Gst::MapInfo of all merged memory blocks in buffer. More...
 
void unmap (const Glib::RefPtr< Gst::MapInfo >& info)
 Release the memory previously mapped with gst_buffer_map(). More...
 
guint64 get_offset () const
 Get the offset of this buffer. More...
 
guint64 get_offset_end () const
 Get the offset end of this buffer. More...
 
- Public Member Functions inherited from Gst::MiniObject
void reference () const
 Increment the reference count for this object. More...
 
void unreference () const
 Decrement the reference count for this object. More...
 
GstMiniObject* gobj ()
 Provides access to the underlying C instance. More...
 
const GstMiniObject* gobj () const
 Provides access to the underlying C instance. More...
 
GstMiniObject* gobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
 ~MiniObject ()
 
guint get_flags () const
 
void set_flags (const guint& value)
 
bool lock (LockFlags flags)
 Lock the mini-object with the specified access mode in flags. More...
 
void unlock (LockFlags flags)
 Unlock the mini-object with the specified access mode in flags. More...
 
bool is_writable () const
 If mini_object has the LOCKABLE flag set, check if the current EXCLUSIVE lock on object is the only one, this means that changes to the object will not be visible to any other object. More...
 
Glib::RefPtr< MiniObjectcreate_writable ()
 Checks if a mini-object is writable. More...
 

Static Public Member Functions

static Glib::RefPtr< Buffercreate ()
 
static Glib::RefPtr< Gst::Buffercreate (guint size)
 

Protected Member Functions

 Buffer ()
 
void operator delete (void*, std::size_t)
 
- Protected Member Functions inherited from Gst::MiniObject
 MiniObject ()
 
void operator delete (void*, std::size_t)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gst::Bufferwrap (GstBuffer* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

A data-passing buffer type, supporting sub-buffers.

Buffers are the basic unit of data transfer in GStreamer. The Gst::Buffer type provides all the state necessary to define a region of memory as part of a stream. Sub-buffers are also supported, allowing a smaller region of a buffer to become its own buffer, with mechanisms in place to ensure that neither memory space goes away prematurely.

Buffers are usually created with create(). After a buffer has been created one will typically allocate memory for it and set the size of the buffer data. The following example creates a buffer that can hold a given video frame with a given width, height and bits per plane.

Constructor & Destructor Documentation

Gst::Buffer::Buffer ( )
protected

Member Function Documentation

Glib::RefPtr<Gst::Buffer> Gst::Buffer::append ( const Glib::RefPtr< Gst::Buffer >&  buf) const

Append all the memory from buf2 to buf1.

The result buffer will contain a concatenation of the memory of buf1 and buf2.

Parameters
buf2The second source Gst::Buffer to append.
Returns
The new Gst::Buffer that contains the memory of the two source buffers.
Glib::RefPtr<Gst::Buffer> Gst::Buffer::append_region ( const Glib::RefPtr< Gst::Buffer >&  buf,
gssize  offset,
gssize  size 
) const

Append size bytes at offset from buf2 to buf1.

The result buffer will contain a concatenation of the memory of buf1 and the requested region of buf2.

Parameters
buf2The second source Gst::Buffer to append.
offsetThe offset in buf2.
sizeThe size or -1 of buf2.
Returns
The new Gst::Buffer that contains the memory of the two source buffers.
Glib::RefPtr<Gst::Buffer> Gst::Buffer::copy ( ) const

Create a copy of the given buffer.

This will also make a newly allocated copy of the data the source buffer contains.

Returns
The Gst::Buffer copy.
void Gst::Buffer::copy_into ( Glib::RefPtr< Gst::Buffer source_buffer,
BufferCopyFlags  flags,
gsize  offset,
gsize  size 
)

Copies the information from src into dest.

If dest already contains memory and flags contains GST_BUFFER_COPY_MEMORY, the memory from src will be appended to dest.

flags indicate which fields will be copied.

Parameters
srcA source Gst::Buffer.
flagsFlags indicating what metadata fields should be copied.
offsetOffset to copy from.
sizeTotal size to copy. If -1, all data is copied.
Returns
true if the copying succeeded, false otherwise.
static Glib::RefPtr<Buffer> Gst::Buffer::create ( )
static
static Glib::RefPtr<Gst::Buffer> Gst::Buffer::create ( guint  size)
static
Glib::RefPtr<Gst::Buffer> Gst::Buffer::create_writable ( )

Makes a writable buffer from the given buffer.

If the source buffer is already writable, this will simply return the same buffer. A copy will otherwise be made.

Returns
A buffer (possibly the same pointer) that is writable.
gsize Gst::Buffer::extract ( gsize  offset,
gpointer  dest,
gsize  size 
)

Copy size bytes starting from offset in buffer to dest.

Parameters
offsetThe offset to extract.
destThe destination address.
sizeThe size to extract.
Returns
The amount of bytes extracted. This value can be lower than size when buffer did not contain enough data.
gsize Gst::Buffer::fill ( gsize  offset,
gconstpointer  src,
gsize  size 
)

Copy size bytes from src to buffer at offset.

Parameters
offsetThe offset to fill.
srcThe source address.
sizeThe size to fill.
Returns
The amount of bytes copied. This value can be lower than size when buffer did not contain enough data.
Glib::RefPtr<Gst::Memory> Gst::Buffer::get_all_memory ( ) const

Get all the memory block in buffer.

The memory blocks will be merged into one large Gst::Memory.

Returns
A Gst::Memory that contains the merged memory. Use gst_memory_unref() after usage.
ClockTime Gst::Buffer::get_dts ( ) const
ClockTime Gst::Buffer::get_duration ( ) const

Get duration of this buffer.

Returns
he duration in nanoseconds (as a Gst::ClockTime) of the data in the buffer. Value will be Gst::CLOCK_TIME_NONE if the duration is unknown.
Glib::RefPtr<Gst::Memory> Gst::Buffer::get_memory ( guint  idx) const

Get the memory block at index idx in buffer.

Parameters
idxAn index.
Returns
A Gst::Memory that contains the data of the memory block at idx. Use gst_memory_unref() after usage.
guint64 Gst::Buffer::get_offset ( ) const

Get the offset of this buffer.

Returns
The offset in the source file of the beginning of this buffer.
guint64 Gst::Buffer::get_offset_end ( ) const

Get the offset end of this buffer.

Returns
The offset in the source file of the end of this buffer.
ClockTime Gst::Buffer::get_pts ( ) const
gsize Gst::Buffer::get_size ( ) const

Get the total size of the memory blocks in buffer.

Returns
Total size of the memory blocks in buffer.
GstBuffer* Gst::Buffer::gobj ( )

Provides access to the underlying C instance.

const GstBuffer* Gst::Buffer::gobj ( ) const

Provides access to the underlying C instance.

GstBuffer* Gst::Buffer::gobj_copy ( ) const

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gst::Buffer::map ( const Glib::RefPtr< Gst::MapInfo >&  info,
MapFlags  flags 
)

This function fills info with the Gst::MapInfo of all merged memory blocks in buffer.

flags describe the desired access of the memory. When flags is Gst::MAP_WRITE, buffer should be writable (as returned from gst_buffer_is_writable()).

When buffer is writable but the memory isn't, a writable copy will automatically be created and returned. The readonly copy of the buffer memory will then also be replaced with this writable copy.

The memory in info should be unmapped with gst_buffer_unmap() after usage.

Parameters
infoInfo about the mapping.
flagsFlags for the mapping.
Returns
true if the map succeeded and info contains valid data.
int Gst::Buffer::memcmp ( gsize  offset,
gconstpointer  mem,
gsize  size 
)

Compare size bytes starting from offset in buffer with the memory in mem.

Parameters
offsetThe offset in buffer.
memThe memory to compare.
sizeThe size to compare.
Returns
0 if the memory is equal.
gsize Gst::Buffer::memset ( gsize  offset,
guint8  val,
gsize  size 
)

Fill buf with size bytes with val starting from offset.

Parameters
offsetThe offset in buffer.
valThe value to set.
sizeThe size to set.
Returns
The amount of bytes filled. This value can be lower than size when buffer did not contain enough data.
void Gst::Buffer::operator delete ( void *  ,
std::size_t   
)
protected
void Gst::Buffer::reference ( ) const

Increment the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

void Gst::Buffer::remove_all_memory ( )

Remove all the memory blocks in buffer.

void Gst::Buffer::remove_memory ( guint  idx)

Remove the memory block in b at index i.

Parameters
idxAn index.
void Gst::Buffer::replace_memory ( guint  idx,
Glib::RefPtr< Gst::Memory mem 
)

Replaces the memory block at index idx in buffer with mem.

Parameters
idxAn index.
memA Gst::Memory.
void Gst::Buffer::replace_memory_range ( guint  idx,
gint  length,
Glib::RefPtr< Gst::Memory mem 
)

Replaces length memory blocks in buffer starting at idx with mem.

If length is -1, all memory starting from idx will be removed and replaced with mem.

buffer should be writable.

Parameters
idxAn index.
lengthA length should not be 0.
memA Gst::Memory.
void Gst::Buffer::set_dts ( const ClockTime value)
void Gst::Buffer::set_duration ( const ClockTime value)
void Gst::Buffer::set_pts ( const ClockTime value)
void Gst::Buffer::unmap ( const Glib::RefPtr< Gst::MapInfo >&  info)

Release the memory previously mapped with gst_buffer_map().

Parameters
infoA Gst::MapInfo.
void Gst::Buffer::unreference ( ) const

Decrement the reference count for this object.

You should never need to do this manually - use the object via a RefPtr instead.

Friends And Related Function Documentation

Glib::RefPtr< Gst::Buffer > wrap ( GstBuffer *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file: