gstreamermm
1.10.0
|
Data-passing buffer type. More...
#include <gstreamermm/buffer.h>
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... | |
![]() | |
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) |
![]() | |
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... | |
![]() | |
Glib::RefPtr< Gst::MiniObject > | wrap (GstMiniObject* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
Additional Inherited Members | |
![]() | |
typedef sigc::slot< void > | SlotFinalizer |
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).
|
delete |
|
delete |
Glib::RefPtr<Gst::Buffer> Gst::Buffer::append | ( | Glib::RefPtr< Gst::Buffer >&& | buf | ) |
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.
mem | A Gst::Memory. |
Glib::RefPtr<Gst::Buffer> Gst::Buffer::append_region | ( | Glib::RefPtr< Gst::Buffer >&& | buf, |
gssize | offset, | ||
gssize | size | ||
) |
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.
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.
|
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.
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. |
true
if the copying succeeded, false
otherwise. 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.
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. |
nullptr
if the arguments were invalid.
|
static |
|
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.
gsize Gst::Buffer::extract | ( | gsize | offset, |
gpointer | dest, | ||
gsize | size | ||
) |
Copy size bytes starting from offset in buffer to dest.
offset | The offset to extract. |
dest | The destination address. |
size | The size to extract. |
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.
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. |
gsize Gst::Buffer::fill | ( | gsize | offset, |
gconstpointer | src, | ||
gsize | size | ||
) |
Copy size bytes from src to buffer at offset.
offset | The offset to fill. |
src | The source address. |
size | The size to fill. |
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.
offset | An offset. |
size | A size. |
idx | Pointer to index. |
length | Pointer to length. |
skip | Pointer to skip. |
true
when size bytes starting from offset could be found in buffer and idx, length and skip will be filled. 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.
ClockTime Gst::Buffer::get_dts | ( | ) | const |
ClockTime Gst::Buffer::get_duration | ( | ) | const |
Get duration of this buffer.
Glib::RefPtr<Gst::Memory> Gst::Buffer::get_memory | ( | guint | idx | ) | const |
Get the memory block at index idx in buffer.
idx | An index. |
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.
idx | An index. |
length | A length. |
guint64 Gst::Buffer::get_offset | ( | ) | const |
Get the offset of this buffer.
guint64 Gst::Buffer::get_offset_end | ( | ) | const |
Get the offset 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.
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().
offset | A pointer to the offset. |
max_size | A pointer to the maxsize. |
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().
idx | An index. |
length | A length. |
offset | A pointer to the offset. |
max_size | A pointer to the maxsize. |
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.
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.
idx | The index to add the memory at, or -1 to append it to the end. |
mem | A Gst::Memory. |
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.
true
if all memory blocks in buffer are 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.
idx | An index. |
length | A length should not be 0. |
true
if the memory range is writable. 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.
info | Info about the mapping. |
flags | Flags for the mapping. |
true
if the map succeeded and info contains valid data. 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.
idx | An index. |
length | A length. |
info | Info about the mapping. |
flags | Flags for the mapping. |
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.
offset | The offset in buffer. |
mem | The memory to compare. |
size | The size to compare. |
gsize Gst::Buffer::memset | ( | gsize | offset, |
guint8 | val, | ||
gsize | size | ||
) |
Fill buf with size bytes with val starting from offset.
offset | The offset in buffer. |
val | The value to set. |
size | The size to set. |
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.
|
static |
Constant for no-offset return results.
|
protected |
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.
idx | An index. |
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.
mem | A Gst::Memory. |
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.
idx | An index. |
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.
idx | An index. |
length | A length. |
void Gst::Buffer::replace_all_memory | ( | Glib::RefPtr< Gst::Memory >&& | mem | ) |
Replaces all memory in buffer with mem.
mem | A Gst::Memory. |
void Gst::Buffer::replace_memory | ( | guint | idx, |
Glib::RefPtr< Gst::Memory >&& | mem | ||
) |
Replaces the memory block at index idx in buffer with mem.
idx | An index. |
mem | A 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.
idx | An index. |
length | A length should not be 0. |
mem | A Gst::Memory. |
void Gst::Buffer::resize | ( | gssize | offset, |
gssize | size | ||
) |
Set the offset and total size of the memory blocks in buffer.
offset | The offset adjustment. |
size | The new size or -1 to just adjust the offset. |
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.
idx | An index. |
length | A length. |
offset | The offset adjustment. |
size | The new size or -1 to just adjust the offset. |
true
if resizing succeeded, false
otherwise. 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::set_size | ( | gssize | size | ) |
Set the total size of the memory blocks in buffer.
size | The new size. |
void Gst::Buffer::unmap | ( | Gst::MapInfo& | info | ) |
Release the memory previously mapped with map().
info | A 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.
|
related |
A Glib::wrap() method for this object.
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. |