segment: add gst_segment_is_equal
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 19 Mar 2015 10:45:56 +0000 (10:45 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Fri, 3 Apr 2015 11:10:33 +0000 (12:10 +0100)
It beats memcmp due to the 'reserved' fields.

API: gst_segment_is_equal()

Found via, but probably not directly linked to,
https://bugzilla.gnome.org/show_bug.cgi?id=738216

docs/gst/gstreamer-sections.txt
gst/gstsegment.c
gst/gstsegment.h
win32/common/libgstreamer.def

index 2929cb0..701e3ed 100644 (file)
@@ -2516,6 +2516,7 @@ gst_segment_to_position
 gst_segment_set_running_time
 gst_segment_copy_into
 gst_segment_offset_running_time
+gst_segment_is_equal
 <SUBSECTION Standard>
 GST_TYPE_SEGMENT
 GST_TYPE_SEGMENT_FLAGS
index 7cecf68..01b3005 100644 (file)
@@ -830,3 +830,43 @@ gst_segment_offset_running_time (GstSegment * segment, GstFormat format,
   }
   return TRUE;
 }
+
+/**
+ * gst_segment_is_equal:
+ * @s0: a #GstSegment structure.
+ * @s1: a #GstSegment structure.
+ *
+ * Checks for two segments being equal. Equality here is defined
+ * as perfect equality, including floating point values.
+ *
+ * Since: 1.6
+ *
+ * Returns: %TRUE if the segments are equal, %FALSE otherwise.
+ */
+gboolean
+gst_segment_is_equal (const GstSegment * s0, const GstSegment * s1)
+{
+  if (s0->flags != s1->flags)
+    return FALSE;
+  if (s0->rate != s1->rate)
+    return FALSE;
+  if (s0->applied_rate != s1->applied_rate)
+    return FALSE;
+  if (s0->format != s1->format)
+    return FALSE;
+  if (s0->base != s1->base)
+    return FALSE;
+  if (s0->offset != s1->offset)
+    return FALSE;
+  if (s0->start != s1->start)
+    return FALSE;
+  if (s0->stop != s1->stop)
+    return FALSE;
+  if (s0->time != s1->time)
+    return FALSE;
+  if (s0->position != s1->position)
+    return FALSE;
+  if (s0->duration != s1->duration)
+    return FALSE;
+  return TRUE;
+}
index d3c87c2..dfe6ace 100644 (file)
@@ -234,6 +234,7 @@ gboolean     gst_segment_do_seek             (GstSegment * segment, gdouble rate
                                               GstFormat format, GstSeekFlags flags,
                                               GstSeekType start_type, guint64 start,
                                               GstSeekType stop_type, guint64 stop, gboolean * update);
+gboolean     gst_segment_is_equal            (const GstSegment * s0, const GstSegment * s1);
 
 G_END_DECLS
 
index 6933676..feb7d2b 100644 (file)
@@ -1115,6 +1115,7 @@ EXPORTS
        gst_search_mode_get_type
        gst_seek_flags_get_type
        gst_seek_type_get_type
+       gst_segment_is_equal
        gst_segment_clip
        gst_segment_copy
        gst_segment_copy_into