gst/gstvalue.c: add comparison function for buffers
authorBenjamin Otte <otte@gnome.org>
Fri, 23 Apr 2004 01:20:59 +0000 (01:20 +0000)
committerBenjamin Otte <otte@gnome.org>
Fri, 23 Apr 2004 01:20:59 +0000 (01:20 +0000)
Original commit message from CVS:
* gst/gstvalue.c: (gst_value_compare_buffer),
(_gst_value_initialize):
add comparison function for buffers

ChangeLog
gst/gstvalue.c

index d52cb98..8be6947 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-04-23  Benjamin Otte  <otte@gnome.org>
+
+       * gst/gstvalue.c: (gst_value_compare_buffer),
+       (_gst_value_initialize):
+         add comparison function for buffers
+
 2004-04-22  Ronald Bultje  <rbultje@ronald.bitfreak.net>
 
        * docs/pwg/pwg.xml:
index 05ae31a..bff7c86 100644 (file)
@@ -788,6 +788,25 @@ gst_value_get_caps (const GValue * value)
 /*************************************/
 /* GstBuffer */
 
+static int
+gst_value_compare_buffer (const GValue * value1, const GValue * value2)
+{
+  GstBuffer *buf1 = g_value_get_boxed (value1);
+  GstBuffer *buf2 = g_value_get_boxed (value2);
+
+  if (GST_BUFFER_SIZE (buf1) != GST_BUFFER_SIZE (buf2))
+    return GST_VALUE_UNORDERED;
+  if (GST_BUFFER_SIZE (buf1) == 0)
+    return GST_VALUE_EQUAL;
+  g_assert (GST_BUFFER_DATA (buf1));
+  g_assert (GST_BUFFER_DATA (buf2));
+  if (memcmp (GST_BUFFER_DATA (buf1), GST_BUFFER_DATA (buf2),
+          GST_BUFFER_SIZE (buf1)) == 0)
+    return GST_VALUE_EQUAL;
+
+  return GST_VALUE_UNORDERED;
+}
+
 static char *
 gst_value_serialize_buffer (const GValue * value)
 {
@@ -2119,7 +2138,7 @@ _gst_value_initialize (void)
 #endif
     static GstValueTable gst_value = {
       0,
-      NULL,                     /*gst_value_compare_buffer, */
+      gst_value_compare_buffer,
       gst_value_serialize_buffer,
       gst_value_deserialize_buffer,
     };