buffer: add copy flag for meta
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 1 Dec 2011 14:34:06 +0000 (15:34 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 1 Dec 2011 14:34:06 +0000 (15:34 +0100)
Add a flag to control if the meta should be copied or not instead of always
copying.

gst/gstbuffer.c
gst/gstbuffer.h

index 32099a2..f95a6a7 100644 (file)
@@ -323,12 +323,14 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
     }
   }
 
-  for (walk = GST_BUFFER_META (src); walk; walk = walk->next) {
-    GstMeta *meta = &walk->meta;
-    const GstMetaInfo *info = meta->info;
+  if (flags & GST_BUFFER_COPY_META) {
+    for (walk = GST_BUFFER_META (src); walk; walk = walk->next) {
+      GstMeta *meta = &walk->meta;
+      const GstMetaInfo *info = meta->info;
 
-    if (info->copy_func)
-      info->copy_func (dest, meta, src, offset, size);
+      if (info->copy_func)
+        info->copy_func (dest, meta, src, offset, size);
+    }
   }
 }
 
index 20caf8f..b9d35cf 100644 (file)
@@ -393,6 +393,8 @@ gst_buffer_copy (const GstBuffer * buf)
  * and appended to already existing memory
  * @GST_BUFFER_COPY_MERGE: flag indicating that buffer memory should be
  * merged
+ * @GST_BUFFER_COPY_META: flag indicating that buffer meta should be
+ * copied
  *
  * A set of flags that can be provided to the gst_buffer_copy_into()
  * function to specify which items should be copied.
@@ -401,8 +403,9 @@ typedef enum {
   GST_BUFFER_COPY_NONE           = 0,
   GST_BUFFER_COPY_FLAGS          = (1 << 0),
   GST_BUFFER_COPY_TIMESTAMPS     = (1 << 1),
-  GST_BUFFER_COPY_MEMORY         = (1 << 2),
-  GST_BUFFER_COPY_MERGE          = (1 << 3)
+  GST_BUFFER_COPY_META           = (1 << 2),
+  GST_BUFFER_COPY_MEMORY         = (1 << 3),
+  GST_BUFFER_COPY_MERGE          = (1 << 4)
 } GstBufferCopyFlags;
 
 /**
@@ -411,7 +414,8 @@ typedef enum {
  * Combination of all possible metadata fields that can be copied with
  * gst_buffer_copy_into().
  */
-#define GST_BUFFER_COPY_METADATA       (GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS)
+#define GST_BUFFER_COPY_METADATA       (GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS |\
+                                        GST_BUFFER_COPY_META)
 
 /**
  * GST_BUFFER_COPY_ALL: