diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 454110176a..e2aaf9d468 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -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 diff --git a/gst/gstsegment.c b/gst/gstsegment.c index d22bd9b1fb..c8ebae8cd5 100644 --- a/gst/gstsegment.c +++ b/gst/gstsegment.c @@ -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; @@ -801,6 +803,33 @@ gst_segment_to_position (const GstSegment * segment, GstFormat format, return result; } +/** + * 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. @@ -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; diff --git a/gst/gstsegment.h b/gst/gstsegment.h index 364d74c614..6c4634a440 100644 --- a/gst/gstsegment.h +++ b/gst/gstsegment.h @@ -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); diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index f5fea82928..34ccdac9d6 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -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, diff --git a/tests/check/gst/gstsegment.c b/tests/check/gst/gstsegment.c index 5e1b30e012..4445693b82 100644 --- a/tests/check/gst/gstsegment.c +++ b/tests/check/gst/gstsegment.c @@ -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 */ diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index e794d2158d..e3a93475ab 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -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