gstreamermm 1.8.0

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

Data-passing buffer type. More...

`#include <gstreamermm/buffer.h>`

Inheritance diagram for Gst::Buffer:
[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...
| Buffer ()=delete
| Buffer (const Buffer&)=delete
Buffer& | operator= (const Buffer&)=delete
Glib::RefPtr< Gst::Buffer > | copy () const
| Create a copy of the given buffer. More...
Glib::RefPtr< Gst::Buffer > | copy_deep () const
| Create a copy of the given buffer. More...
Glib::RefPtr< Gst::Buffer > | copy_region (Gst::BufferCopyFlags flags, gsize offset, gsize size)
| Creates a sub-buffer from parent at offset and size. More...
Glib::RefPtr< Gst::Buffer > | create_writable ()
| Makes a writable buffer from the given buffer. More...
Glib::RefPtr< Gst::Memory > | get_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...
gsize | get_sizes (gsize& offset, gsize& max_size) const
| Get the total size of the memory blocks in b. More...
gsize | get_sizes_range (guint idx, gint length, gsize& offset, gsize& max_size) const
| Get the total size of length memory blocks stating from idx in buffer. More...
bool | resize_range (guint idx, gint length, gssize offset, gssize size)
| Set the total size of the length memory blocks starting at idx in buffer. More...
void | resize (gssize offset, gssize size)
| Set the offset and total size of the memory blocks in buffer. More...
void | set_size (gssize size)
| Set the total size of the memory blocks in buffer. More...
Glib::RefPtr< Gst::Memory > | peek_memory (guint idx)
| Get the memory block at idx in buffer. More...
guint | n_memory () const
| Get the amount of memory blocks that this buffer has. More...
void | insert_memory (gint idx, Glib::RefPtr< Gst::Memory >&& mem)
| Insert the memory block mem to buffer at idx. More...
Glib::RefPtr< Gst::Memory > | get_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...
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...
Glib::RefPtr< Gst::Memory > | get_memory_range (guint idx, gint length)
| Get length memory blocks in buffer starting at idx. More...
void | remove_memory_range (guint idx, gint length)
| Remove length memory blocks in buffer starting from idx. More...
bool | find_memory (gsize offset, gsize size, guint& idx, guint& length, gsize& skip)
| Find the memory blocks that span size bytes starting from offset in buffer. More...
void | prepend_memory (Glib::RefPtr< Gst::Memory >&& mem)
| Prepend the memory block mem to buffer. More...
void | append_memory (Glib::RefPtr< Gst::Memory >&& mem)
| Append the memory block mem to buffer. 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...
void | replace_all_memory (Glib::RefPtr< Gst::Memory >&& mem)
| Replaces all memory in buffer with mem. More...
gsize | extract (gsize offset, gpointer dest, gsize size)
| Copy size bytes starting from offset in buffer to dest. More...
void | extract_dup (gsize offset, gsize size, gpointer& dest, gsize& dest_size)
| Extracts a copy of at most size bytes the data at offset into newly-allocated memory. More...
int | memcmp (gsize offset, gconstpointer mem, gsize size)
| Compare size bytes starting from offset in buffer with the memory in mem. More...
bool | is_all_memory_writable () const
| Check if all memory blocks in buffer are writable. More...
bool | is_memory_range_writable (guint idx, gint length) const
| Check if length memory blocks in buffer starting from idx are writable. More...
bool | map (Gst::MapInfo& info, Gst::MapFlags flags)
| This function fills info with the Gst::MapInfo of all merged memory blocks in buffer. More...
bool | map_range (guint idx, gint length, Gst::MapInfo& info, MapFlags flags)
| This function fills info with the Gst::MapInfo of length merged memory blocks starting at idx in buffer. More...
void | unmap (Gst::MapInfo& info)
| Release the memory previously mapped with map(). More...
Glib::RefPtr< Gst::Buffer > | append_region (Glib::RefPtr< Gst::Buffer >&& buf, gssize offset, gssize size)
Glib::RefPtr< Gst::Buffer > | append (Glib::RefPtr< Gst::Buffer >&& buf)
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)
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 ()=delete
| MiniObject (const MiniObject&)=delete
MiniObject& | operator= (const MiniObject&)=delete
| ~MiniObject ()
guint | get_flags () const
void | set_flags (const guint& value)
gint | get_refcount () const
gint | get_lockstate () const
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< MiniObject > | create_writable ()
| Checks if a mini-object is writable. More...
void | set_qdata (GQuark quark, QuarkData* data)
| This sets an opaque, named pointer on a miniobject. More...
QuarkData* | get_qdata (GQuark quark) const
| This function gets back user data pointers stored via set_qdata(). More...
QuarkData* | steal_qdata (GQuark quark)
| This function gets back user data pointers stored via set_qdata() and removes the data from object without invoking its destroy() function (if any was set). More...
void | add_finalize_notifier (const SlotFinalizer& slot)
| Adds notifier when mini object is finalized. More...
void | remove_finalize_notifier ()
| Remove finalize notifier. More...

## Static Public Member Functions
static Glib::RefPtr< Buffer > | create ()
static void | copy_into (const Glib::RefPtr< Gst::Buffer >& destination_buffer, const Glib::RefPtr< Gst::Buffer >& source_buffer, BufferCopyFlags flags, gsize offset, gsize size)
| Copies the information from source_buffer into dest. More...
static Glib::RefPtr< Gst::Buffer > | create (guint size)
static guint64 | offset_none ()
| Constant for no-offset return results. More...

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

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gst::Buffer > | wrap (GstBuffer* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Gst::MiniObject
Glib::RefPtr< Gst::MiniObject > | wrap (GstMiniObject* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Additional Inherited Members
Public Types inherited from Gst::MiniObject
typedef sigc::slot< void > | SlotFinalizer

## Detailed Description

Data-passing buffer type.

See also: Pad, MiniObject, Memory, Meta, BufferPool

Buffers are the basic unit of data transfer in GStreamer. They contain the timing and offset along with other arbitrary metadata that is associated with the #GstMemory blocks that the buffer contains.

Buffers are usually created with Gst::Buffer::create. After a buffer has been created one will typically allocate memory for it and add it to the buffer. The following example creates a buffer that can hold a given video frame with a given width, height and bits per plane.

Buffers can contain a list of Gst::Memory objects. You can retrieve how many memory objects with n_memory() and you can get a pointer to memory with peek_memory()

A buffer will usually have timestamps, and a duration, but neither of these are guaranteed (they may be set to #GST_CLOCK_TIME_NONE). Whenever a meaningful value can be given for these, they should be set. The timestamps and duration are measured in nanoseconds (they are Gst::ClockTime values).

The buffer DTS refers to the timestamp when the buffer should be decoded and is usually monotonically increasing. The buffer PTS refers to the timestamp when the buffer content should be presented to the user and is not always monotonically increasing.

A buffer can also have one or both of a start and an end offset. These are media-type specific. For video buffers, the start offset will generally be the frame number. For audio buffers, it will be the number of samples produced so far. For compressed data, it could be the byte offset in a source or destination file. Likewise, the end offset will be the offset of the end of the buffer. These can only be meaningfully interpreted if you know the media type of the buffer (the preceeding CAPS event). Either or both can be set to Gst::BUFFER_OFFSET_NONE.

To efficiently create a smaller buffer out of an existing one, you can use copy_region(). This method tries to share the memory objects between the two buffers.

If a plug-in wants to modify the buffer data or metadata in-place, it should first obtain a buffer that is safe to modify by using create_writable(). This function is optimized so that a copy will only be made when it is necessary.

Several flags of the buffer can be set and unset with the GST_BUFFER_FLAG_SET() and GST_BUFFER_FLAG_UNSET() macros. Use GST_BUFFER_FLAG_IS_SET() to test if a certain Gst::BufferFlag is set.

Buffers can be efficiently merged into a larger buffer with append(). Copying of memory will only be done when absolutely needed.

Arbitrary extra metadata can be set on a buffer with add_meta(). Metadata can be retrieved with get_meta(). See also Gst::Meta

An element should either unref the buffer or push it out on a src pad using Gst::Pad::push() (see Gst::Pad).

## Constructor & Destructor Documentation

## § Buffer() [1/2]

Gst::Buffer::Buffer | ( |  | ) |
| delete

## § Buffer() [2/2]

Gst::Buffer::Buffer | ( | const Buffer& |  | ) |
| delete

## Member Function Documentation

## § append()

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

## § append_memory()

void Gst::Buffer::append_memory | ( | Glib::RefPtr< Gst::Memory >&& | mem | ) |

Append the memory block mem to buffer.

This function takes ownership of mem and thus doesn't increase its refcount.

This function is identical to insert_memory() with an index of -1. See insert_memory() for more details.

Parameters

  mem | A Gst::Memory.

## § append_region()

Glib::RefPtr<Gst::Buffer> Gst::Buffer::append_region | ( | Glib::RefPtr< Gst::Buffer >&& | buf,
|  | gssize | offset,
|  | gssize | size
| ) |  |

## § copy()

Glib::RefPtr<Gst::Buffer> Gst::Buffer::copy | ( |  | ) | const

Create a copy of the given buffer.

This will only copy the buffer's data to a newly allocated memory if needed (if the type of memory requires it), otherwise the underlying data is just referenced. Check copy_deep() if you want to force the data to be copied to newly allocated memory.

Returns
  A new copy of buf.

## § copy_deep()

Glib::RefPtr<Gst::Buffer> Gst::Buffer::copy_deep | ( |  | ) | const

Create a copy of the given buffer.

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

Returns
  A new copy of buf.

## § copy_into()

static void Gst::Buffer::copy_into | ( | const Glib::RefPtr< Gst::Buffer >& | destination_buffer,
|  | const Glib::RefPtr< Gst::Buffer >& | source_buffer,
|  | BufferCopyFlags | flags,
|  | gsize | offset,
|  | gsize | size
| ) |  |
| static

Copies the information from source_buffer into dest.

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

flags indicate which fields will be copied.

Parameters

  dest | A destination Gst::Buffer.
  source_buffer | A source Gst::Buffer.
  flags | Flags indicating what metadata fields should be copied.
  offset | Offset to copy from.
  size | Total size to copy. If -1, all data is copied.

Returns
  `true` if the copying succeeded, `false` otherwise.

## § copy_region()

Glib::RefPtr<Gst::Buffer> Gst::Buffer::copy_region | ( | Gst::BufferCopyFlags | flags,
|  | gsize | offset,
|  | gsize | size
| ) |  |

Creates a sub-buffer from parent at offset and size.

This sub-buffer uses the actual memory space of the parent buffer. This function will copy the offset and timestamp fields when the offset is 0. If not, they will be set to Gst::CLOCK_TIME_NONE and Gst::BUFFER_OFFSET_NONE. If offset equals 0 and size equals the total size of buffer, the duration and offset end fields are also copied. If not they will be set to Gst::CLOCK_TIME_NONE and Gst::BUFFER_OFFSET_NONE.

MT safe.

Parameters

  flags | The Gst::BufferCopyFlags.
  offset | The offset into parent Gst::Buffer at which the new sub-buffer begins.
  size | The size of the new Gst::Buffer sub-buffer, in bytes. If -1, all data is copied.

Returns
  The new Gst::Buffer or `nullptr` if the arguments were invalid.

## § create() [1/2]

static Glib::RefPtr<Buffer> Gst::Buffer::create | ( |  | ) |
| static

## § create() [2/2]

static Glib::RefPtr<Gst::Buffer> Gst::Buffer::create | ( | guint | size | ) |
| static

## § create_writable()

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.

## § extract()

gsize Gst::Buffer::extract | ( | gsize | offset,
|  | gpointer | dest,
|  | gsize | size
| ) |  |

Copy size bytes starting from offset in buffer to dest.

Parameters

  offset | The offset to extract.
  dest | The destination address.
  size | The size to extract.

Returns
  The amount of bytes extracted. This value can be lower than size when buffer did not contain enough data.

## § extract_dup()

void Gst::Buffer::extract_dup | ( | gsize | offset,
|  | gsize | size,
|  | gpointer & | dest,
|  | gsize & | dest_size
| ) |  |

Extracts a copy of at most size bytes the data at offset into newly-allocated memory.

Parameters

  offset | The offset to extract.
  size | The size to extract.
  dest | A pointer where the destination array will be written.
  dest_size | A location where the size of dest can be written.

## § fill()

gsize Gst::Buffer::fill | ( | gsize | offset,
|  | gconstpointer | src,
|  | gsize | size
| ) |  |

Copy size bytes from src to buffer at offset.

Parameters

  offset | The offset to fill.
  src | The source address.
  size | The size to fill.

Returns
  The amount of bytes copied. This value can be lower than size when buffer did not contain enough data.

## § find_memory()

bool Gst::Buffer::find_memory | ( | gsize | offset,
|  | gsize | size,
|  | guint & | idx,
|  | guint & | length,
|  | gsize & | skip
| ) |  |

Find the memory blocks that span size bytes starting from offset in buffer.

When this function returns `true`, idx will contain the index of the first memory block where the byte for offset can be found and length contains the number of memory blocks containing the size remaining bytes. skip contains the number of bytes to skip in the memory block at idx to get to the byte for offset.

size can be -1 to get all the memory blocks after idx.

Parameters

  offset | An offset.
  size | A size.
  idx | Pointer to index.
  length | Pointer to length.
  skip | Pointer to skip.

Returns
  `true` when size bytes starting from offset could be found in buffer and idx, length and skip will be filled.

## § get_all_memory()

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.

## § get_dts()

ClockTime Gst::Buffer::get_dts | ( |  | ) | const

## § get_duration()

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.

## § get_memory()

Glib::RefPtr<Gst::Memory> Gst::Buffer::get_memory | ( | guint | idx | ) | const

Get the memory block at index idx in buffer.

Parameters

  idx | An index.

Returns
  A Gst::Memory that contains the data of the memory block at idx. Use Gst::Memory::unref() after usage.

## § get_memory_range()

Glib::RefPtr<Gst::Memory> Gst::Buffer::get_memory_range | ( | guint | idx,
|  | gint | length
| ) |  |

Get length memory blocks in buffer starting at idx.

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

If length is -1, all memory starting from idx is merged.

Parameters

  idx | An index.
  length | A length.

Returns
  A Gst::Memory that contains the merged data of length blocks starting at idx. Use Gst::Memory::unref() after usage.

## § get_offset()

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.

## § get_offset_end()

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.

## § get_pts()

ClockTime Gst::Buffer::get_pts | ( |  | ) | const

## § get_size()

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.

## § get_sizes()

gsize Gst::Buffer::get_sizes | ( | gsize & | offset,
|  | gsize & | max_size
| ) |  | const

Get the total size of the memory blocks in b.

When not `nullptr`, offset will contain the offset of the data in the first memory block in buffer and max_size will contain the sum of the size and offset and the amount of extra padding on the last memory block. offset and max_size can be used to resize the buffer memory blocks with resize().

Parameters

  offset | A pointer to the offset.
  max_size | A pointer to the maxsize.

Returns
  Total size of the memory blocks in buffer.

## § get_sizes_range()

gsize Gst::Buffer::get_sizes_range | ( | guint | idx,
|  | gint | length,
|  | gsize & | offset,
|  | gsize & | max_size
| ) |  | const

Get the total size of length memory blocks stating from idx in buffer.

When not `nullptr`, offset will contain the offset of the data in the memory block in buffer at idx and max_size will contain the sum of the size and offset and the amount of extra padding on the memory block at idx + length -1. offset and max_size can be used to resize the buffer memory blocks with resize_range().

Parameters

  idx | An index.
  length | A length.
  offset | A pointer to the offset.
  max_size | A pointer to the maxsize.

Returns
  Total size of length memory blocks starting at idx in buffer.

## § gobj() [1/2]

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

Provides access to the underlying C instance.

## § gobj() [2/2]

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

Provides access to the underlying C instance.

## § gobj_copy()

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.

## § insert_memory()

void Gst::Buffer::insert_memory | ( | gint | idx,
|  | Glib::RefPtr< Gst::Memory >&& | mem
| ) |  |

Insert the memory block mem to buffer at idx.

This function takes ownership of mem and thus doesn't increase its refcount.

Only get_max_memory() can be added to a buffer. If more memory is added, existing memory blocks will automatically be merged to make room for the new memory.

Parameters

  idx | The index to add the memory at, or -1 to append it to the end.
  mem | A Gst::Memory.

## § is_all_memory_writable()

bool Gst::Buffer::is_all_memory_writable | ( |  | ) | const

Check if all memory blocks in buffer are writable.

Note that this function does not check if buffer is writable, use gst_buffer_is_writable() to check that if needed.

Returns
  `true` if all memory blocks in buffer are writable.

## § is_memory_range_writable()

bool Gst::Buffer::is_memory_range_writable | ( | guint | idx,
|  | gint | length
| ) |  | const

Check if length memory blocks in buffer starting from idx are writable.

length can be -1 to check all the memory blocks after idx.

Note that this function does not check if buffer is writable, use gst_buffer_is_writable() to check that if needed.

Parameters

  idx | An index.
  length | A length should not be 0.

Returns
  `true` if the memory range is writable.

## § map()

bool Gst::Buffer::map | ( | Gst::MapInfo& | info,
|  | Gst::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 unmap() after usage.

Parameters

  info | Info about the mapping.
  flags | Flags for the mapping.

Returns
  `true` if the map succeeded and info contains valid data.

## § map_range()

bool Gst::Buffer::map_range | ( | guint | idx,
|  | gint | length,
|  | Gst::MapInfo& | info,
|  | MapFlags | flags
| ) |  |

This function fills info with the Gst::MapInfo of length merged memory blocks starting at idx in buffer.

When length is -1, all memory blocks starting from idx are merged and mapped.

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 unmap() after usage.

Parameters

  idx | An index.
  length | A length.
  info | Info about the mapping.
  flags | Flags for the mapping.

Returns
  `true` if the map succeeded and info contains valid data.

## § memcmp()

int Gst::Buffer::memcmp | ( | gsize | offset,
|  | gconstpointer | mem,
|  | gsize | size
| ) |  |

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

Parameters

  offset | The offset in buffer.
  mem | The memory to compare.
  size | The size to compare.

Returns
  0 if the memory is equal.

## § memset()

gsize Gst::Buffer::memset | ( | gsize | offset,
|  | guint8 | val,
|  | gsize | size
| ) |  |

Fill buf with size bytes with val starting from offset.

Parameters

  offset | The offset in buffer.
  val | The value to set.
  size | The size to set.

Returns
  The amount of bytes filled. This value can be lower than size when buffer did not contain enough data.

## § n_memory()

guint Gst::Buffer::n_memory | ( |  | ) | const

Get the amount of memory blocks that this buffer has.

This amount is never larger than what get_max_memory() returns.

Returns
  The amount of memory block in this buffer.

## § offset_none()

static guint64 Gst::Buffer::offset_none | ( |  | ) |
| static

Constant for no-offset return results.

## § operator delete()

void Gst::Buffer::operator delete | ( | void * | ,
|  | std::size_t |
| ) |  |
| protected

## § operator=()

Buffer& Gst::Buffer::operator= | ( | const Buffer& |  | ) |
| delete

## § peek_memory()

Glib::RefPtr<Gst::Memory> Gst::Buffer::peek_memory | ( | guint | idx | ) |

Get the memory block at idx in buffer.

The memory block stays valid until the memory block in buffer is removed, replaced or merged, typically with any call that modifies the memory in buffer.

Parameters

  idx | An index.

Returns
  The Gst::Memory at idx.

## § prepend_memory()

void Gst::Buffer::prepend_memory | ( | Glib::RefPtr< Gst::Memory >&& | mem | ) |

Prepend the memory block mem to buffer.

This function takes ownership of mem and thus doesn't increase its refcount.

This function is identical to insert_memory() with an index of 0. See insert_memory() for more details.

Parameters

  mem | A Gst::Memory.

## § reference()

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.

## § remove_all_memory()

void Gst::Buffer::remove_all_memory | ( |  | ) |

Remove all the memory blocks in buffer.

## § remove_memory()

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

Remove the memory block in b at index i.

Parameters

  idx | An index.

## § remove_memory_range()

void Gst::Buffer::remove_memory_range | ( | guint | idx,
|  | gint | length
| ) |  |

Remove length memory blocks in buffer starting from idx.

length can be -1, in which case all memory starting from idx is removed.

Parameters

  idx | An index.
  length | A length.

## § replace_all_memory()

void Gst::Buffer::replace_all_memory | ( | Glib::RefPtr< Gst::Memory >&& | mem | ) |

Replaces all memory in buffer with mem.

Parameters

  mem | A Gst::Memory.

## § replace_memory()

void Gst::Buffer::replace_memory | ( | guint | idx,
|  | Glib::RefPtr< Gst::Memory >&& | mem
| ) |  |

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

Parameters

  idx | An index.
  mem | A Gst::Memory.

## § replace_memory_range()

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

  idx | An index.
  length | A length should not be 0.
  mem | A Gst::Memory.

## § resize()

void Gst::Buffer::resize | ( | gssize | offset,
|  | gssize | size
| ) |  |

Set the offset and total size of the memory blocks in buffer.

Parameters

  offset | The offset adjustment.
  size | The new size or -1 to just adjust the offset.

## § resize_range()

bool Gst::Buffer::resize_range | ( | guint | idx,
|  | gint | length,
|  | gssize | offset,
|  | gssize | size
| ) |  |

Set the total size of the length memory blocks starting at idx in buffer.

Parameters

  idx | An index.
  length | A length.
  offset | The offset adjustment.
  size | The new size or -1 to just adjust the offset.

Returns
  `true` if resizing succeeded, `false` otherwise.

## § set_dts()

void Gst::Buffer::set_dts | ( | const ClockTime& | value | ) |

## § set_duration()

void Gst::Buffer::set_duration | ( | const ClockTime& | value | ) |

## § set_pts()

void Gst::Buffer::set_pts | ( | const ClockTime& | value | ) |

## § set_size()

void Gst::Buffer::set_size | ( | gssize | size | ) |

Set the total size of the memory blocks in buffer.

Parameters

  size | The new size.

## § unmap()

void Gst::Buffer::unmap | ( | Gst::MapInfo& | info | ) |

Release the memory previously mapped with map().

Parameters

  info | A Gst::MapInfo.

## § unreference()

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

## § wrap()

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

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

Parameters

  object | The C instance.
  take_copy | False 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.