mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-06 06:22:29 +00:00
segment: Replaced gst_segment_to_position with gst_segment_position_from_running_time
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.
This commit is contained in:
parent
572c7c6b9a
commit
44ba1565d9
6 changed files with 58 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue