segment: Replaced gst_segment_to_position with gst_segment_position_from_running_time
authorVivia Nikolaidou <vivia@ahiru.eu>
Wed, 2 Sep 2015 14:58:38 +0000 (17:58 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 25 Sep 2015 22:00:08 +0000 (00:00 +0200)
gst_segment_to_position might cause confusion, especially with the addition of
gst_segment_position_from_stream_time . Deprecated gst_segment_to_position
now, and replaced it with gst_segment_position_from_running_time.

Also added unit tests.

docs/gst/gstreamer-sections.txt
gst/gstsegment.c
gst/gstsegment.h
libs/gst/base/gstbasesink.c
tests/check/gst/gstsegment.c
win32/common/libgstreamer.def

index 4541101..e2aaf9d 100644 (file)
@@ -2569,6 +2569,7 @@ gst_segment_position_from_stream_time
 gst_segment_to_running_time
 gst_segment_to_running_time_full
 gst_segment_to_stream_time
+gst_segment_position_from_running_time
 gst_segment_to_position
 gst_segment_set_running_time
 gst_segment_copy_into
index d22bd9b..c8ebae8 100644 (file)
@@ -740,7 +740,7 @@ gst_segment_clip (const GstSegment * segment, GstFormat format, guint64 start,
 }
 
 /**
- * gst_segment_to_position:
+ * gst_segment_position_from_running_time:
  * @segment: a #GstSegment structure.
  * @format: the format of the segment.
  * @running_time: the running_time in the segment
@@ -750,10 +750,12 @@ gst_segment_clip (const GstSegment * segment, GstFormat format, guint64 start,
  *
  * Returns: the position in the segment for @running_time. This function returns
  * -1 when @running_time is -1 or when it is not inside @segment.
+ *
+ * Since: 1.8
  */
 guint64
-gst_segment_to_position (const GstSegment * segment, GstFormat format,
-    guint64 running_time)
+gst_segment_position_from_running_time (const GstSegment * segment,
+    GstFormat format, guint64 running_time)
 {
   guint64 result;
   guint64 start, stop, base;
@@ -802,6 +804,33 @@ gst_segment_to_position (const GstSegment * segment, GstFormat format,
 }
 
 /**
+ * gst_segment_to_position:
+ * @segment: a #GstSegment structure.
+ * @format: the format of the segment.
+ * @running_time: the running_time in the segment
+ *
+ * Convert @running_time into a position in the segment so that
+ * gst_segment_to_running_time() with that position returns @running_time.
+ *
+ * Returns: the position in the segment for @running_time. This function returns
+ * -1 when @running_time is -1 or when it is not inside @segment.
+ *
+ * Deprecated. Use gst_segment_position_from_running_time() instead.
+ */
+#ifndef GST_REMOVE_DEPRECATED
+#ifdef GST_DISABLE_DEPRECATED
+guint64 gst_segment_to_position (const GstSegment * segment, GstFormat format,
+    guint64 running_time);
+#endif
+guint64
+gst_segment_to_position (const GstSegment * segment, GstFormat format,
+    guint64 running_time)
+{
+  return gst_segment_position_from_running_time (segment, format, running_time);
+}
+#endif
+
+/**
  * gst_segment_set_running_time:
  * @segment: a #GstSegment structure.
  * @format: the format of the segment.
@@ -821,7 +850,8 @@ gst_segment_set_running_time (GstSegment * segment, GstFormat format,
   guint64 start, stop;
 
   /* start by bringing the running_time into the segment position */
-  position = gst_segment_to_position (segment, format, running_time);
+  position =
+      gst_segment_position_from_running_time (segment, format, running_time);
 
   /* we must have a valid position now */
   if (G_UNLIKELY (position == -1))
@@ -884,7 +914,8 @@ gst_segment_offset_running_time (GstSegment * segment, GstFormat format,
       /* subtract all from segment.base, remainder in offset */
       offset -= segment->base;
       segment->base = 0;
-      position = gst_segment_to_position (segment, format, offset);
+      position =
+          gst_segment_position_from_running_time (segment, format, offset);
       if (position == -1)
         return FALSE;
 
index 364d74c..6c4634a 100644 (file)
@@ -224,7 +224,10 @@ guint64      gst_segment_to_running_time     (const GstSegment *segment, GstForm
 
 gint         gst_segment_to_running_time_full (const GstSegment *segment, GstFormat format, guint64 position,
                                                guint64 * running_time);
+#ifndef GST_DISABLE_DEPRECATED
 guint64      gst_segment_to_position         (const GstSegment *segment, GstFormat format, guint64 running_time);
+#endif
+guint64      gst_segment_position_from_running_time (const GstSegment *segment, GstFormat format, guint64 running_time);
 
 gboolean     gst_segment_set_running_time    (GstSegment *segment, GstFormat format, guint64 running_time);
 
index f5fea82..34ccdac 100644 (file)
@@ -1659,7 +1659,9 @@ start_stepping (GstBaseSink * sink, GstSegment * segment,
       /* update the segment clipping regions for non-flushing seeks */
       if (segment->rate > 0.0) {
         if (end != -1)
-          position = gst_segment_to_position (segment, GST_FORMAT_TIME, end);
+          position =
+              gst_segment_position_from_running_time (segment, GST_FORMAT_TIME,
+              end);
         else
           position = segment->stop;
 
@@ -1667,7 +1669,9 @@ start_stepping (GstBaseSink * sink, GstSegment * segment,
         segment->position = position;
       } else {
         if (end != -1)
-          position = gst_segment_to_position (segment, GST_FORMAT_TIME, end);
+          position =
+              gst_segment_position_from_running_time (segment, GST_FORMAT_TIME,
+              end);
         else
           position = segment->start;
 
@@ -1803,10 +1807,14 @@ handle_stepping (GstBaseSink * sink, GstSegment * segment,
         step_end = TRUE;
         if (segment->rate > 0.0) {
           *rstart = end;
-          *cstart = gst_segment_to_position (segment, GST_FORMAT_TIME, end);
+          *cstart =
+              gst_segment_position_from_running_time (segment, GST_FORMAT_TIME,
+              end);
         } else {
           *rstop = end;
-          *cstop = gst_segment_to_position (segment, GST_FORMAT_TIME, end);
+          *cstop =
+              gst_segment_position_from_running_time (segment, GST_FORMAT_TIME,
+              end);
         }
       }
       GST_DEBUG_OBJECT (sink,
index 5e1b30e..4445693 100644 (file)
@@ -39,6 +39,11 @@ check_times (GstSegment * segment, guint64 position, guint64 stream_time,
     pos = gst_segment_position_from_stream_time (segment, segment->format, st);
     fail_unless_equals_int64 (pos, position);
   }
+
+  if (running_time != -1) {
+    pos = gst_segment_position_from_running_time (segment, segment->format, rt);
+    fail_unless_equals_int64 (pos, position);
+  }
 }
 
 /* mess with the segment structure in the bytes format */
index e794d21..e3a9347 100644 (file)
@@ -1154,6 +1154,7 @@ EXPORTS
        gst_segment_is_equal
        gst_segment_new
        gst_segment_offset_running_time
+       gst_segment_position_from_running_time
        gst_segment_position_from_stream_time
        gst_segment_set_running_time
        gst_segment_to_position