#include "gstbuffer.h"
#include "gstbufferpool.h"
#include "gstinfo.h"
+#include "gstmeta.h"
#include "gstutils.h"
#include "gstversion.h"
}
if (flags & GST_BUFFER_COPY_META) {
+ gboolean deep;
+
+ deep = (flags & GST_BUFFER_COPY_DEEP) != 0;
+
/* NOTE: GstGLSyncMeta copying relies on the meta
* being copied now, after the buffer data,
* so this has to happen last */
GST_CAT_DEBUG (GST_CAT_BUFFER,
"don't copy memory meta %p of API type %s", meta,
g_type_name (info->api));
+ } else if (deep && gst_meta_api_type_has_tag (info->api,
+ _gst_meta_tag_memory_reference)) {
+ GST_CAT_DEBUG (GST_CAT_BUFFER,
+ "don't copy memory reference meta %p of API type %s", meta,
+ g_type_name (info->api));
} else if (info->transform_func) {
GstMetaTransformCopy copy_data;
* Creates a copy of the given buffer. This will make a newly allocated
* copy of the data the source buffer contains.
*
- * Returns: (transfer full): a new copy of @buf.
+ * Returns: (transfer full) (nullable): a new copy of @buf if the copy succeeded, %NULL otherwise.
*
* Since: 1.6
*/
g_return_if_fail (GST_IS_BUFFER (buffer));
g_return_if_fail (info != NULL);
- /* we need to check for NULL, it is possible that we tried to map a buffer
- * without memory and we should be able to unmap that fine */
- if (G_LIKELY (info->memory)) {
- gst_memory_unmap (info->memory, info);
- gst_memory_unref (info->memory);
- }
+ _gst_buffer_map_info_clear ((GstBufferMapInfo *) info);
}
/**
* duration and offset end fields are also copied. If not they will be set
* to #GST_CLOCK_TIME_NONE and #GST_BUFFER_OFFSET_NONE.
*
- * Returns: (transfer full): the new #GstBuffer or %NULL if the arguments were
- * invalid.
+ * Returns: (transfer full) (nullable): the new #GstBuffer or %NULL if copying
+ * failed.
*/
GstBuffer *
gst_buffer_copy_region (GstBuffer * buffer, GstBufferCopyFlags flags,
gst_parent_buffer_meta_api_get_type (void)
{
static GType type = 0;
- static const gchar *tags[] = { NULL };
+ static const gchar *tags[] = { GST_META_TAG_MEMORY_REFERENCE_STR, NULL };
if (g_once_init_enter (&type)) {
GType _type = gst_meta_api_type_register ("GstParentBufferMetaAPI", tags);
* Check gst_buffer_copy_deep() if you want to force the data
* to be copied to newly allocated memory.
*
- * Returns: (transfer full): a new copy of @buf.
+ * Returns: (transfer full) (nullable): a new copy of @buf if the copy succeeded, %NULL otherwise.
*/
GstBuffer *
gst_buffer_copy (const GstBuffer * buf)