win32: add new symbol
[platform/upstream/gstreamer.git] / gst / gstsegment.c
index b7c31f2..5248c05 100644 (file)
@@ -28,6 +28,7 @@
 
 /**
  * SECTION:gstsegment
+ * @title: GstSegment
  * @short_description: Structure describing the configured region of interest
  *                     in a media file.
  * @see_also: #GstEvent
  * interest in a media file, called a segment.
  *
  * The structure can be used for two purposes:
- * <itemizedlist>
- *   <listitem><para>performing seeks (handling seek events)</para></listitem>
- *   <listitem><para>tracking playback regions (handling newsegment events)</para></listitem>
- * </itemizedlist>
+ *
+ *   * performing seeks (handling seek events)
+ *   * tracking playback regions (handling newsegment events)
  *
  * The segment is usually configured by the application with a seek event which
  * is propagated upstream and eventually handled by an element that performs the seek.
  * info to stream time (which is always between 0 and the duration of the stream).
  */
 
+/* FIXME 2.0: remove unused format parameter.
+ * Most of the methods in gstsegment.c take and extra GstFormat format, just to
+ * verify segment->format == format.
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=788979
+ */
+
 /**
  * gst_segment_copy:
  * @segment: (transfer none): a #GstSegment
@@ -190,7 +196,7 @@ gst_segment_init (GstSegment * segment, GstFormat format)
  * @start: the seek start value
  * @stop_type: the seek method
  * @stop: the seek stop value
- * @update: boolean holding whether position was updated.
+ * @update: (out) (allow-none): boolean holding whether position was updated.
  *
  * Update the segment structure with the field values of a seek event (see
  * gst_event_new_seek()).
@@ -379,7 +385,7 @@ gst_segment_do_seek (GstSegment * segment, gdouble rate,
  * @segment: a #GstSegment structure.
  * @format: the format of the segment.
  * @position: the position in the segment
- * @stream_time: result stream-time
+ * @stream_time: (out): result stream-time
  *
  * Translate @position to the total stream time using the currently configured
  * segment. Compared to gst_segment_to_stream_time() this function can return
@@ -529,7 +535,7 @@ gst_segment_to_stream_time (const GstSegment * segment, GstFormat format,
   if (gst_segment_to_stream_time_full (segment, format, position, &result) == 1)
     return result;
 
-  return 0;
+  return -1;
 }
 
 /**
@@ -537,7 +543,7 @@ gst_segment_to_stream_time (const GstSegment * segment, GstFormat format,
  * @segment: a #GstSegment structure.
  * @format: the format of the segment.
  * @stream_time: the stream-time
- * @position: the resulting position in the segment
+ * @position: (out): the resulting position in the segment
  *
  * Translate @stream_time to the segment position using the currently configured
  * segment. Compared to gst_segment_position_from_stream_time() this function can
@@ -696,7 +702,7 @@ gst_segment_position_from_stream_time (const GstSegment * segment,
  * @segment: a #GstSegment structure.
  * @format: the format of the segment.
  * @position: the position in the segment
- * @running_time: result running-time
+ * @running_time: (out) (allow-none): result running-time
  *
  * Translate @position to the total running time using the currently configured
  * segment. Compared to gst_segment_to_running_time() this function can return
@@ -884,8 +890,11 @@ gst_segment_clip (const GstSegment * segment, GstFormat format, guint64 start,
   g_return_val_if_fail (segment->format == format, FALSE);
 
   /* if we have a stop position and a valid start and start is bigger,
-   * we're outside of the segment */
-  if (G_UNLIKELY (segment->stop != -1 && start != -1 && start >= segment->stop))
+   * we're outside of the segment. (Special case) segment start and
+   * segment stop can be identical. In this case, if start is also identical,
+   * it's inside of segment */
+  if (G_UNLIKELY (segment->stop != -1 && start != -1 && (start > segment->stop
+              || (segment->start != segment->stop && start == segment->stop))))
     return FALSE;
 
   /* if a stop position is given and is before the segment start,
@@ -943,13 +952,8 @@ gst_segment_position_from_running_time (const GstSegment * segment,
       gst_segment_position_from_running_time_full (segment, format,
       running_time, &position);
 
-  if (res != 1) {
-    g_print
-        ("here with start %lu stop %lu base %lu rate %f offset %lu running_time %lu position %lu\n",
-        segment->start, segment->stop, segment->base, segment->rate,
-        segment->offset, running_time, position);
+  if (res != 1)
     return -1;
-  }
 
   /* before the segment boundary */
   if (G_UNLIKELY (position < segment->start)) {
@@ -973,7 +977,7 @@ gst_segment_position_from_running_time (const GstSegment * segment,
  * @segment: a #GstSegment structure.
  * @format: the format of the segment.
  * @running_time: the running-time
- * @position: the resulting position in the segment
+ * @position: (out): the resulting position in the segment
  *
  * Translate @running_time to the segment position using the currently configured
  * segment. Compared to gst_segment_position_from_running_time() this function can
@@ -1080,13 +1084,9 @@ gst_segment_position_from_running_time_full (const GstSegment * segment,
  * 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.
+ * 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)