<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Single Segment</NICK>
-<BLURB>Timestamp buffers and eat newsegments so as to appear as one segment.</BLURB>
+<BLURB>Timestamp buffers and eat segments so as to appear as one segment.</BLURB>
<DEFAULT>FALSE</DEFAULT>
</ARG>
{GST_EVENT_FLUSH_STOP, "flush-stop", 0},
{GST_EVENT_EOS, "eos", 0},
{GST_EVENT_CAPS, "caps", 0},
- {GST_EVENT_NEWSEGMENT, "newsegment", 0},
+ {GST_EVENT_SEGMENT, "segment", 0},
{GST_EVENT_TAG, "tag", 0},
{GST_EVENT_BUFFERSIZE, "buffersize", 0},
{GST_EVENT_SINK_MESSAGE, "sink-message", 0},
* @caps: a #GstCaps
*
* Create a new CAPS event for @caps. The caps event can only travel downstream
- * synchronized with the buffer flow and contain the format of the buffers
+ * synchronized with the buffer flow and contains the format of the buffers
* that will follow after the event.
*
* Returns: (transfer full): the new CAPS event.
{
GstEvent *event;
- g_return_val_if_fail (caps != NULL && gst_caps_is_fixed (caps), NULL);
+ g_return_val_if_fail (caps != NULL, NULL);
+ g_return_val_if_fail (gst_caps_is_fixed (caps), NULL);
GST_CAT_INFO (GST_CAT_EVENT, "creating caps event %" GST_PTR_FORMAT, caps);
}
/**
- * gst_event_new_new_segment:
- * @update: Whether this segment is an update to a previous one
- * @rate: A new rate for playback
- * @applied_rate: The rate factor which has already been applied
- * @format: The format of the segment values
- * @start: The start value of the segment
- * @stop: The stop value of the segment
- * @time: the time value of the segment
+ * gst_event_new_segment:
+ * @segment: a #GstSegment
*
- * Allocate a new newsegment event with the given format/values triplets.
+ * Create a new SEGMENT event for @segment. The segment event can only travel
+ * downstream synchronized with the buffer flow and contains timing information
+ * and playback properties for the buffers that will follow.
*
* The newsegment event marks the range of buffers to be processed. All
* data not within the segment range is not to be processed. This can be
* values.
*
* The time value of the segment is used in conjunction with the start
- * value to convert the buffer timestamps into the stream time. This is
- * usually done in sinks to report the current stream_time.
- * @time represents the stream_time of a buffer carrying a timestamp of
+ * value to convert the buffer timestamps into the stream time. This is
+ * usually done in sinks to report the current stream_time.
+ * @time represents the stream_time of a buffer carrying a timestamp of
* @start. @time cannot be -1.
*
* @start cannot be -1, @stop can be -1. If there
- * is a valid @stop given, it must be greater or equal the @start, including
+ * is a valid @stop given, it must be greater or equal the @start, including
* when the indicated playback @rate is < 0.
*
* The @applied_rate value provides information about any rate adjustment that
- * has already been made to the timestamps and content on the buffers of the
- * stream. (@rate * @applied_rate) should always equal the rate that has been
- * requested for playback. For example, if an element has an input segment
- * with intended playback @rate of 2.0 and applied_rate of 1.0, it can adjust
- * incoming timestamps and buffer content by half and output a newsegment event
+ * has already been made to the timestamps and content on the buffers of the
+ * stream. (@rate * @applied_rate) should always equal the rate that has been
+ * requested for playback. For example, if an element has an input segment
+ * with intended playback @rate of 2.0 and applied_rate of 1.0, it can adjust
+ * incoming timestamps and buffer content by half and output a newsegment event
* with @rate of 1.0 and @applied_rate of 2.0
*
* After a newsegment event, the buffer stream time is calculated with:
*
* time + (TIMESTAMP(buf) - start) * ABS (rate * applied_rate)
*
- * Returns: (transfer full): a new newsegment event.
- *
- * Since: 0.10.6
+ * Returns: (transfer full): the new SEGMENT event.
*/
GstEvent *
-gst_event_new_new_segment (gboolean update, gdouble rate,
- gdouble applied_rate, GstFormat format, gint64 start, gint64 stop,
- gint64 time)
+gst_event_new_segment (GstSegment * segment)
{
GstEvent *event;
- GstStructure *structure;
-
- g_return_val_if_fail (rate != 0.0, NULL);
- g_return_val_if_fail (applied_rate != 0.0, NULL);
- if (format == GST_FORMAT_TIME) {
- GST_CAT_INFO (GST_CAT_EVENT,
- "creating newsegment update %d, rate %lf, format GST_FORMAT_TIME, "
- "start %" GST_TIME_FORMAT ", stop %" GST_TIME_FORMAT
- ", time %" GST_TIME_FORMAT,
- update, rate, GST_TIME_ARGS (start),
- GST_TIME_ARGS (stop), GST_TIME_ARGS (time));
- } else {
- GST_CAT_INFO (GST_CAT_EVENT,
- "creating newsegment update %d, rate %lf, format %s, "
- "start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT ", time %"
- G_GINT64_FORMAT, update, rate, gst_format_get_name (format), start,
- stop, time);
- }
+ g_return_val_if_fail (segment != NULL, NULL);
- g_return_val_if_fail (time != -1, NULL);
- g_return_val_if_fail (start != -1, NULL);
- if (stop != -1)
- g_return_val_if_fail (start <= stop, NULL);
+ GST_CAT_INFO (GST_CAT_EVENT, "creating segment event %" GST_PTR_FORMAT,
+ segment);
- structure = gst_structure_id_new (GST_QUARK (EVENT_NEWSEGMENT),
- GST_QUARK (UPDATE), G_TYPE_BOOLEAN, update,
- GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
- GST_QUARK (APPLIED_RATE), G_TYPE_DOUBLE, applied_rate,
- GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
- GST_QUARK (START), G_TYPE_INT64, start,
- GST_QUARK (STOP), G_TYPE_INT64, stop,
- GST_QUARK (TIME), G_TYPE_INT64, time, NULL);
- event = gst_event_new_custom (GST_EVENT_NEWSEGMENT, structure);
+ event = gst_event_new_custom (GST_EVENT_SEGMENT,
+ gst_structure_id_new (GST_QUARK (EVENT_SEGMENT),
+ GST_QUARK (SEGMENT), GST_TYPE_SEGMENT, segment, NULL));
return event;
}
/**
- * gst_event_parse_new_segment:
- * @event: The event to query
- * @update: (out): A pointer to the update flag of the segment
- * @rate: (out): A pointer to the rate of the segment
- * @applied_rate: (out): A pointer to the applied_rate of the segment
- * @format: (out): A pointer to the format of the newsegment values
- * @start: (out): A pointer to store the start value in
- * @stop: (out): A pointer to store the stop value in
- * @time: (out): A pointer to store the time value in
- *
- * Get the update, rate, applied_rate, format, start, stop and
- * time in the newsegment event. See gst_event_new_new_segment()
- * for a full description of the newsegment event.
- *
- * Since: 0.10.6
+ * gst_event_get_segment:
+ * @event: The event
+ *
+ * Get the segment from @event. The segment remains valid as long as @event remains
+ * valid.
+ *
+ * Returns: the #GstSegment. The segment stays valid for as long as @event is
+ * valid.
*/
-void
-gst_event_parse_new_segment (GstEvent * event, gboolean * update,
- gdouble * rate, gdouble * applied_rate, GstFormat * format,
- gint64 * start, gint64 * stop, gint64 * time)
+const GstSegment *
+gst_event_get_segment (GstEvent * event)
{
- const GstStructure *structure;
+ GstStructure *structure;
+ GstSegment *segment;
- g_return_if_fail (GST_IS_EVENT (event));
- g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT);
+ g_return_val_if_fail (GST_IS_EVENT (event), NULL);
+ g_return_val_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT, NULL);
structure = GST_EVENT_STRUCTURE (event);
- if (G_LIKELY (update))
- *update =
- g_value_get_boolean (gst_structure_id_get_value (structure,
- GST_QUARK (UPDATE)));
- if (G_LIKELY (rate))
- *rate =
- g_value_get_double (gst_structure_id_get_value (structure,
- GST_QUARK (RATE)));
- if (G_LIKELY (applied_rate))
- *applied_rate =
- g_value_get_double (gst_structure_id_get_value (structure,
- GST_QUARK (APPLIED_RATE)));
- if (G_LIKELY (format))
- *format =
- g_value_get_enum (gst_structure_id_get_value (structure,
- GST_QUARK (FORMAT)));
- if (G_LIKELY (start))
- *start =
- g_value_get_int64 (gst_structure_id_get_value (structure,
- GST_QUARK (START)));
- if (G_LIKELY (stop))
- *stop =
- g_value_get_int64 (gst_structure_id_get_value (structure,
- GST_QUARK (STOP)));
- if (G_LIKELY (time))
- *time =
- g_value_get_int64 (gst_structure_id_get_value (structure,
- GST_QUARK (TIME)));
+ segment = g_value_get_boxed (gst_structure_id_get_value (structure,
+ GST_QUARK (SEGMENT)));
+
+ return segment;
+}
+
+/**
+ * gst_event_parse_segment:
+ * @event: The event to parse
+ * @segment: a #GstSegment
+ *
+ * Copy the segment values from @event into @segment.
+ */
+void
+gst_event_parse_segment (GstEvent * event, GstSegment * segment)
+{
+ const GstSegment *src;
+
+ g_return_if_fail (segment != NULL);
+
+ src = gst_event_get_segment (event);
+ g_return_if_fail (src != NULL);
+
+ gst_segment_copy_into (src, segment);
}
/**
#include <gst/gstclock.h>
#include <gst/gststructure.h>
#include <gst/gsttaglist.h>
+#include <gst/gstsegment.h>
G_BEGIN_DECLS
* @GST_EVENT_FLUSH_STOP: Stop a flush operation. This event resets the
* running-time of the pipeline.
* @GST_EVENT_EOS: End-Of-Stream. No more data is to be expected to follow
- * without a NEWSEGMENT event.
- * @GST_EVENT_NEWSEGMENT: A new media segment follows in the dataflow. The
+ * without a SEGMENT event.
+ * @GST_EVENT_SEGMENT: A new media segment follows in the dataflow. The
* segment events contains information for clipping buffers and
* converting buffer timestamps to running-time and
* stream-time.
GST_EVENT_FLUSH_STOP = GST_EVENT_MAKE_TYPE (2, 0, FLAG(BOTH) | FLAG(SERIALIZED)),
/* downstream serialized events */
GST_EVENT_CAPS = GST_EVENT_MAKE_TYPE (5, 1, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
- GST_EVENT_NEWSEGMENT = GST_EVENT_MAKE_TYPE (6, 2, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
+ GST_EVENT_SEGMENT = GST_EVENT_MAKE_TYPE (6, 2, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_TAG = GST_EVENT_MAKE_TYPE (7, 3, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_BUFFERSIZE = GST_EVENT_MAKE_TYPE (8, 4, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_SINK_MESSAGE = GST_EVENT_MAKE_TYPE (9, 5, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_EOS = GST_EVENT_MAKE_TYPE (10, 6, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
+
/* upstream events */
GST_EVENT_QOS = GST_EVENT_MAKE_TYPE (15, 0, FLAG(UPSTREAM)),
GST_EVENT_SEEK = GST_EVENT_MAKE_TYPE (16, 0, FLAG(UPSTREAM)),
gst_mini_object_replace ((GstMiniObject **)(old_event), GST_MINI_OBJECT_CAST (new_event))
/**
- * GstSeekType:
- * @GST_SEEK_TYPE_NONE: no change in position is required
- * @GST_SEEK_TYPE_CUR: change relative to currently configured segment. This
- * can't be used to seek relative to the current playback position - do a
- * position query, calculate the desired position and then do an absolute
- * position seek instead if that's what you want to do.
- * @GST_SEEK_TYPE_SET: absolute position is requested
- * @GST_SEEK_TYPE_END: relative position to duration is requested
- *
- * The different types of seek events. When constructing a seek event with
- * gst_event_new_seek(), a format, a seek method and optional flags are to
- * be provided. The seek event is then inserted into the graph with
- * gst_pad_send_event() or gst_element_send_event().
- */
-typedef enum {
- /* one of these */
- GST_SEEK_TYPE_NONE = 0,
- GST_SEEK_TYPE_CUR = 1,
- GST_SEEK_TYPE_SET = 2,
- GST_SEEK_TYPE_END = 3
-} GstSeekType;
-
-/**
- * GstSeekFlags:
- * @GST_SEEK_FLAG_NONE: no flag
- * @GST_SEEK_FLAG_FLUSH: flush pipeline
- * @GST_SEEK_FLAG_ACCURATE: accurate position is requested, this might
- * be considerably slower for some formats.
- * @GST_SEEK_FLAG_KEY_UNIT: seek to the nearest keyframe. This might be
- * faster but less accurate.
- * @GST_SEEK_FLAG_SEGMENT: perform a segment seek.
- * @GST_SEEK_FLAG_SKIP: when doing fast foward or fast reverse playback, allow
- * elements to skip frames instead of generating all
- * frames. Since 0.10.22.
- *
- * Flags to be used with gst_element_seek() or gst_event_new_seek(). All flags
- * can be used together.
- *
- * A non flushing seek might take some time to perform as the currently
- * playing data in the pipeline will not be cleared.
- *
- * An accurate seek might be slower for formats that don't have any indexes
- * or timestamp markers in the stream. Specifying this flag might require a
- * complete scan of the file in those cases.
- *
- * When performing a segment seek: after the playback of the segment completes,
- * no EOS will be emmited by the element that performed the seek, but a
- * #GST_MESSAGE_SEGMENT_DONE message will be posted on the bus by the element.
- * When this message is posted, it is possible to send a new seek event to
- * continue playback. With this seek method it is possible to perform seemless
- * looping or simple linear editing.
- *
- * When doing fast forward (rate > 1.0) or fast reverse (rate < -1.0) trickmode
- * playback, the @GST_SEEK_FLAG_SKIP flag can be used to instruct decoders
- * and demuxers to adjust the playback rate by skipping frames. This can improve
- * performance and decrease CPU usage because not all frames need to be decoded.
- *
- * Also see part-seeking.txt in the GStreamer design documentation for more
- * details on the meaning of these flags and the behaviour expected of
- * elements that handle them.
- */
-typedef enum {
- GST_SEEK_FLAG_NONE = 0,
- GST_SEEK_FLAG_FLUSH = (1 << 0),
- GST_SEEK_FLAG_ACCURATE = (1 << 1),
- GST_SEEK_FLAG_KEY_UNIT = (1 << 2),
- GST_SEEK_FLAG_SEGMENT = (1 << 3),
- GST_SEEK_FLAG_SKIP = (1 << 4)
-} GstSeekFlags;
-
-/**
* GstQOSType:
* @GST_QOS_TYPE_OVERFLOW: The QoS event type that is produced when downstream
* elements are producing data too quickly and the element can't keep up
GstEvent * gst_event_new_caps (GstCaps *caps);
void gst_event_parse_caps (GstEvent *event, GstCaps **caps);
-/* newsegment events */
-GstEvent* gst_event_new_new_segment (gboolean update, gdouble rate,
- gdouble applied_rate,
- GstFormat format,
- gint64 start, gint64 stop,
- gint64 time);
-void gst_event_parse_new_segment (GstEvent *event,
- gboolean *update,
- gdouble *rate,
- gdouble *applied_rate,
- GstFormat *format,
- gint64 *start, gint64 *stop,
- gint64 *time);
+/* segment event */
+GstEvent* gst_event_new_segment (GstSegment *segment);
+const GstSegment *
+ gst_event_get_segment (GstEvent *event);
+void gst_event_parse_segment (GstEvent *event, GstSegment *segment);
/* tag event */
GstEvent* gst_event_new_tag (GstTagList *taglist);
GstSeekFlags *flags,
GstSeekType *start_type, gint64 *start,
GstSeekType *stop_type, gint64 *stop);
+
/* navigation event */
GstEvent* gst_event_new_navigation (GstStructure *structure);
}
case GST_FORMAT_TIME:{
return g_strdup_printf ("time segment start=%" GST_TIME_FORMAT
- ", stop=%" GST_TIME_FORMAT ", last_stop=%" GST_TIME_FORMAT
- ", duration=%" GST_TIME_FORMAT ", rate=%f, applied_rate=%f"
- ", flags=0x%02x, time=%" GST_TIME_FORMAT ", accum=%" GST_TIME_FORMAT,
+ ", stop=%" GST_TIME_FORMAT ", rate=%f, applied_rate=%f"
+ ", flags=0x%02x, time=%" GST_TIME_FORMAT ", base=%" GST_TIME_FORMAT,
GST_TIME_ARGS (segment->start), GST_TIME_ARGS (segment->stop),
- GST_TIME_ARGS (segment->last_stop), GST_TIME_ARGS (segment->duration),
segment->rate, segment->applied_rate, (guint) segment->flags,
- GST_TIME_ARGS (segment->time), GST_TIME_ARGS (segment->accum));
+ GST_TIME_ARGS (segment->time), GST_TIME_ARGS (segment->base));
}
default:{
const gchar *format_name;
if (G_UNLIKELY (format_name == NULL))
format_name = "(UNKNOWN FORMAT)";
return g_strdup_printf ("%s segment start=%" G_GINT64_FORMAT
- ", stop=%" G_GINT64_FORMAT ", last_stop=%" G_GINT64_FORMAT
- ", duration=%" G_GINT64_FORMAT ", rate=%f, applied_rate=%f"
- ", flags=0x%02x, time=%" GST_TIME_FORMAT ", accum=%" GST_TIME_FORMAT,
- format_name, segment->start, segment->stop, segment->last_stop,
- segment->duration, segment->rate, segment->applied_rate,
- (guint) segment->flags, GST_TIME_ARGS (segment->time),
- GST_TIME_ARGS (segment->accum));
+ ", stop=%" G_GINT64_FORMAT ", rate=%f, applied_rate=%f"
+ ", flags=0x%02x, time=%" GST_TIME_FORMAT ", base=%" GST_TIME_FORMAT,
+ format_name, segment->start, segment->stop, segment->rate,
+ segment->applied_rate, (guint) segment->flags,
+ GST_TIME_ARGS (segment->time), GST_TIME_ARGS (segment->base));
}
}
}
"max-latency", "busy", "type", "owner", "update", "applied-rate",
"start", "stop", "minsize", "maxsize", "async", "proportion",
"diff", "timestamp", "flags", "cur-type", "cur", "stop-type",
- "latency", "uri", "object", "taglist", "GstEventNewsegment",
+ "latency", "uri", "object", "taglist", "GstEventSegment",
"GstEventBufferSize", "GstEventQOS", "GstEventSeek", "GstEventLatency",
"GstMessageError", "GstMessageWarning", "GstMessageInfo",
"GstMessageBuffering", "GstMessageState", "GstMessageClockProvide",
"quality", "processed", "dropped", "buffering-ranges", "GstMessageProgress",
"code", "text", "percent", "timeout", "GstBufferPoolConfig", "caps", "size",
"min-buffers", "max-buffers", "prefix", "postfix", "align", "time",
- "GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps", "GstEventReconfigure"
+ "GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
+ "GstEventReconfigure",
+ "segment"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
GST_QUARK_URI = 51,
GST_QUARK_OBJECT = 52,
GST_QUARK_TAGLIST = 53,
- GST_QUARK_EVENT_NEWSEGMENT = 54,
+ GST_QUARK_EVENT_SEGMENT = 54,
GST_QUARK_EVENT_BUFFER_SIZE = 55,
GST_QUARK_EVENT_QOS = 56,
GST_QUARK_EVENT_SEEK = 57,
GST_QUARK_POOL = 118,
GST_QUARK_EVENT_CAPS = 119,
GST_QUARK_EVENT_RECONFIGURE = 120,
+ GST_QUARK_SEGMENT = 121,
- GST_QUARK_MAX = 121
+ GST_QUARK_MAX = 122
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
* @see_also: #GstEvent
*
* This helper structure holds the relevant values for tracking the region of
- * interest in a media file, called a segment.
+ * interest in a media file, called a segment.
*
* The structure can be used for two purposes:
* <itemizedlist>
* <listitem><para>tracking playback regions (handling newsegment events)</para></listitem>
* </itemizedlist>
*
- * The segment is usually configured by the application with a seek event which
+ * 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.
*
* The configured segment is then propagated back downstream with a newsegment event.
*
* If the segment is used for managing seeks, the segment duration should be set with
* gst_segment_set_duration(). The public duration field contains the duration of the
- * segment. When using the segment for seeking, the start and time members should
+ * segment. When using the segment for seeking, the start and time members should
* normally be left to their default 0 value. The stop position is left to -1 unless
* explicitly configured to a different value after a seek event.
*
* to the clock. This function takes into account all accumulated segments as well as
* any rate or applied_rate conversions.
*
- * For elements that need to perform operations on media data in stream_time,
+ * For elements that need to perform operations on media data in stream_time,
* gst_segment_to_stream_time() can be used to convert a timestamp and the segment
* info to stream time (which is always between 0 and the duration of the stream).
*
* Since: 0.10.20
*/
GstSegment *
-gst_segment_copy (GstSegment * segment)
+gst_segment_copy (const GstSegment * segment)
{
GstSegment *result = NULL;
return result;
}
+void
+gst_segment_copy_into (const GstSegment * src, GstSegment * dest)
+{
+ memcpy (dest, src, sizeof (GstSegment));
+}
+
GType
gst_segment_get_type (void)
{
/**
* gst_segment_new:
*
- * Allocate a new #GstSegment structure and initialize it using
+ * Allocate a new #GstSegment structure and initialize it using
* gst_segment_init().
*
* Free-function: gst_segment_free
{
g_return_if_fail (segment != NULL);
+ segment->flags = 0;
segment->rate = 1.0;
segment->applied_rate = 1.0;
segment->format = format;
- segment->flags = 0;
+ segment->base = 0;
segment->start = 0;
segment->stop = -1;
segment->time = 0;
- segment->accum = 0;
- segment->last_stop = 0;
+ segment->position = 0;
segment->duration = -1;
}
/**
- * gst_segment_set_duration:
- * @segment: a #GstSegment structure.
- * @format: the format of the segment.
- * @duration: the duration of the segment info or -1 if unknown.
- *
- * Set the duration of the segment to @duration. This function is mainly
- * used by elements that perform seeking and know the total duration of the
- * segment.
- *
- * This field should be set to allow seeking requests relative to the
- * duration.
- */
-void
-gst_segment_set_duration (GstSegment * segment, GstFormat format,
- gint64 duration)
-{
- g_return_if_fail (segment != NULL);
-
- if (G_UNLIKELY (segment->format == GST_FORMAT_UNDEFINED))
- segment->format = format;
- else
- g_return_if_fail (segment->format == format);
-
- segment->duration = duration;
-}
-
-/**
- * gst_segment_set_last_stop:
- * @segment: a #GstSegment structure.
- * @format: the format of the segment.
- * @position: the position
- *
- * Set the last observed stop position in the segment to @position.
- *
- * This field should be set to allow seeking requests relative to the
- * current playing position.
- */
-void
-gst_segment_set_last_stop (GstSegment * segment, GstFormat format,
- gint64 position)
-{
- g_return_if_fail (segment != NULL);
-
- if (G_UNLIKELY (segment->format == GST_FORMAT_UNDEFINED))
- segment->format = format;
- else
- g_return_if_fail (segment->format == format);
-
- segment->last_stop = MAX (segment->start, position);
-}
-
-/**
- * gst_segment_set_seek:
+ * gst_segment_do_seek:
* @segment: a #GstSegment structure.
* @rate: the rate of the segment.
* @format: the format of the segment.
- * @flags: the seek flags for the segment
+ * @flags: the segment flags for the segment
* @start_type: the seek method
* @start: the seek start value
* @stop_type: the seek method
* @stop: the seek stop value
- * @update: boolean holding whether last_stop was updated.
+ * @update: boolean holding whether position was updated.
*
* Update the segment structure with the field values of a seek event (see
* gst_event_new_seek()).
*
- * After calling this method, the segment field last_stop and time will
+ * After calling this method, the segment field position and time will
* contain the requested new position in the segment. The new requested
- * position in the segment depends on @rate and @start_type and @stop_type.
+ * position in the segment depends on @rate and @start_type and @stop_type.
*
* For positive @rate, the new position in the segment is the new @segment
* start field when it was updated with a @start_type different from
* #GST_SEEK_TYPE_NONE. If no update was performed on @segment start position
- * (#GST_SEEK_TYPE_NONE), @start is ignored and @segment last_stop is
+ * (#GST_SEEK_TYPE_NONE), @start is ignored and @segment position is
* unmodified.
*
* For negative @rate, the new position in the segment is the new @segment
* #GST_SEEK_TYPE_NONE. If no stop was previously configured in the segment, the
* duration of the segment will be used to update the stop position.
* If no update was performed on @segment stop position (#GST_SEEK_TYPE_NONE),
- * @stop is ignored and @segment last_stop is unmodified.
+ * @stop is ignored and @segment position is unmodified.
*
* The applied rate of the segment will be set to 1.0 by default.
* If the caller can apply a rate change, it should update @segment
* rate and applied_rate after calling this function.
*
- * @update will be set to TRUE if a seek should be performed to the segment
- * last_stop field. This field can be FALSE if, for example, only the @rate
+ * @update will be set to TRUE if a seek should be performed to the segment
+ * position field. This field can be FALSE if, for example, only the @rate
* has been changed but not the playback position.
+ *
+ * Returns: %TRUE if the seek could be performed.
*/
-void
-gst_segment_set_seek (GstSegment * segment, gdouble rate,
+gboolean
+gst_segment_do_seek (GstSegment * segment, gdouble rate,
GstFormat format, GstSeekFlags flags,
- GstSeekType start_type, gint64 start,
- GstSeekType stop_type, gint64 stop, gboolean * update)
+ GstSeekType start_type, guint64 start,
+ GstSeekType stop_type, guint64 stop, gboolean * update)
{
gboolean update_stop, update_start;
- gint64 last_stop;
-
- g_return_if_fail (rate != 0.0);
- g_return_if_fail (segment != NULL);
+ guint64 position, base;
- if (G_UNLIKELY (segment->format == GST_FORMAT_UNDEFINED))
- segment->format = format;
+ g_return_val_if_fail (rate != 0.0, FALSE);
+ g_return_val_if_fail (segment != NULL, FALSE);
+ g_return_val_if_fail (segment->format == format, FALSE);
update_start = update_stop = TRUE;
+ base = segment->base;
+ position = segment->position;
+
+ if (flags & GST_SEEK_FLAG_FLUSH) {
+ /* flush resets the running_time */
+ base = 0;
+ } else {
+ base = gst_segment_to_running_time (segment, format, position);
+ }
+
/* segment->start is never invalid */
switch (start_type) {
case GST_SEEK_TYPE_NONE:
if (start == -1)
start = 0;
/* start must be 0 or the formats must match */
- g_return_if_fail (start == 0 || segment->format == format);
break;
case GST_SEEK_TYPE_CUR:
- g_return_if_fail (start == 0 || segment->format == format);
/* add start to currently configured segment */
start = segment->start + start;
break;
case GST_SEEK_TYPE_END:
if (segment->duration != -1) {
- g_return_if_fail (start == 0 || segment->format == format);
/* add start to total length */
start = segment->duration + start;
} else {
case GST_SEEK_TYPE_SET:
/* stop holds required value, if it's not -1, it must be of the same
* format as the segment. */
- g_return_if_fail (stop == -1 || segment->format == format);
break;
case GST_SEEK_TYPE_CUR:
if (segment->stop != -1) {
/* only add compatible formats or 0 */
- g_return_if_fail (stop == 0 || segment->format == format);
stop = segment->stop + stop;
} else
stop = -1;
case GST_SEEK_TYPE_END:
if (segment->duration != -1) {
/* only add compatible formats or 0 */
- g_return_if_fail (stop == 0 || segment->format == format);
stop = segment->duration + stop;
} else {
stop = segment->stop;
}
/* we can't have stop before start */
- if (stop != -1)
- g_return_if_fail (start <= stop);
+ if (stop != -1) {
+ if (start > stop) {
+ g_return_val_if_fail (start <= stop, FALSE);
+ return FALSE;
+ }
+ }
segment->rate = rate;
segment->applied_rate = 1.0;
+ segment->base = base;
segment->flags = flags;
segment->start = start;
segment->stop = stop;
segment->time = start;
- last_stop = segment->last_stop;
if (update_start && rate > 0.0) {
- last_stop = start;
+ position = start;
}
if (update_stop && rate < 0.0) {
if (stop != -1)
- last_stop = stop;
+ position = stop;
else {
if (segment->duration != -1)
- last_stop = segment->duration;
+ position = segment->duration;
else
- last_stop = 0;
+ position = 0;
}
}
- /* set update arg to reflect update of last_stop */
+ /* set update arg to reflect update of position */
if (update)
- *update = last_stop != segment->last_stop;
+ *update = position != segment->position;
/* update new position */
- segment->last_stop = last_stop;
-}
-
-/**
- * gst_segment_set_newsegment:
- * @segment: a #GstSegment structure.
- * @update: flag indicating a new segment is started or updated
- * @rate: the rate of the segment.
- * @applied_rate: the applied rate of the segment.
- * @format: the format of the segment.
- * @start: the new start value
- * @stop: the new stop value
- * @time: the new stream time
- *
- * Update the segment structure with the field values of a new segment event.
- */
-void
-gst_segment_set_newsegment (GstSegment * segment, gboolean update,
- gdouble rate, gdouble applied_rate, GstFormat format, gint64 start,
- gint64 stop, gint64 time)
-{
- gint64 duration, last_stop;
- gdouble abs_rate;
-
- g_return_if_fail (rate != 0.0);
- g_return_if_fail (applied_rate != 0.0);
- g_return_if_fail (segment != NULL);
-
- GST_DEBUG ("configuring segment update %d, rate %lf, format %s, "
- "start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT ", position %"
- G_GINT64_FORMAT, update, rate, gst_format_get_name (format), start,
- stop, time);
- GST_DEBUG ("old segment was: %" GST_SEGMENT_FORMAT, segment);
-
- if (G_UNLIKELY (segment->format == GST_FORMAT_UNDEFINED))
- segment->format = format;
-
- /* any other format with 0 also gives time 0, the other values are
- * invalid in the format though. */
- if (format != segment->format && start == 0) {
- format = segment->format;
- if (stop != 0)
- stop = -1;
- if (time != 0)
- time = -1;
- }
-
- g_return_if_fail (segment->format == format);
-
- if (update) {
- if (G_LIKELY (segment->rate > 0.0)) {
- /* an update to the current segment is done, elapsed time is
- * difference between the old start and new start. */
- if (start > segment->start)
- duration = start - segment->start;
- else
- duration = 0;
- } else {
- /* for negative rates, the elapsed duration is the diff between the stop
- * positions */
- if (stop != -1 && stop < segment->stop)
- duration = segment->stop - stop;
- else
- duration = 0;
- }
- /* update last_stop to be a valid value in the updated segment */
- if (start > segment->last_stop)
- last_stop = start;
- else if (stop != -1 && stop < segment->last_stop)
- last_stop = stop;
- else
- last_stop = segment->last_stop;
- } else {
- /* the new segment has to be aligned with the old segment.
- * We first update the accumulated time of the previous
- * segment. the accumulated time is used when syncing to the
- * clock. */
- if (segment->stop != -1) {
- duration = segment->stop - segment->start;
- } else if (segment->last_stop != -1) {
- /* else use last seen timestamp as segment stop */
- duration = segment->last_stop - segment->start;
- } else {
- /* else we don't know and throw a warning.. really, this should
- * be fixed in the element. */
- g_warning ("closing segment of unknown duration, assuming duration of 0");
- duration = 0;
- }
- /* position the last_stop to the next expected position in the new segment,
- * which is the start or the stop of the segment */
- if (rate > 0.0)
- last_stop = start;
- else
- last_stop = stop;
- }
- /* use previous rate to calculate duration */
- abs_rate = ABS (segment->rate);
- if (G_LIKELY (abs_rate != 1.0))
- duration /= abs_rate;
-
- /* accumulate duration */
- segment->accum += duration;
+ segment->position = position;
- /* then update the current segment */
- segment->rate = rate;
- segment->applied_rate = applied_rate;
- segment->start = start;
- segment->last_stop = last_stop;
- segment->stop = stop;
- segment->time = time;
+ return TRUE;
}
/**
* @format: the format of the segment.
* @position: the position in the segment
*
- * Translate @position to stream time using the currently configured
+ * Translate @position to stream time using the currently configured
* segment. The @position value must be between @segment start and
- * stop value.
+ * stop value.
*
* This function is typically used by elements that need to operate on
* the stream time of the buffers it receives, such as effect plugins.
- * In those use cases, @position is typically the buffer timestamp or
+ * In those use cases, @position is typically the buffer timestamp or
* clock time that one wants to convert to the stream time.
- * The stream time is always between 0 and the total duration of the
- * media stream.
+ * The stream time is always between 0 and the total duration of the
+ * media stream.
*
* Returns: the position in stream_time or -1 when an invalid position
* was given.
*/
-gint64
-gst_segment_to_stream_time (GstSegment * segment, GstFormat format,
- gint64 position)
+guint64
+gst_segment_to_stream_time (const GstSegment * segment, GstFormat format,
+ guint64 position)
{
- gint64 result, start, stop, time;
+ guint64 result, start, stop, time;
gdouble abs_applied_rate;
/* format does not matter for -1 */
return -1;
g_return_val_if_fail (segment != NULL, -1);
-
- if (G_UNLIKELY (segment->format == GST_FORMAT_UNDEFINED))
- segment->format = format;
+ g_return_val_if_fail (segment->format == format, -1);
/* if we have the position for the same format as the segment, we can compare
* the start and stop values, otherwise we assume 0 and -1 */
* @format: the format of the segment.
* @position: the position in the segment
*
- * Translate @position to the total running time using the currently configured
+ * Translate @position to the total running time using the currently configured
* and previously accumulated segments. Position is a value between @segment
* start and stop time.
*
* Returns: the position as the total running time or -1 when an invalid position
* was given.
*/
-gint64
-gst_segment_to_running_time (GstSegment * segment, GstFormat format,
- gint64 position)
+guint64
+gst_segment_to_running_time (const GstSegment * segment, GstFormat format,
+ guint64 position)
{
- gint64 result;
- gint64 start, stop, accum;
+ guint64 result;
+ guint64 start, stop, base;
gdouble abs_rate;
if (G_UNLIKELY (position == -1))
return -1;
g_return_val_if_fail (segment != NULL, -1);
-
- if (G_UNLIKELY (segment->format == GST_FORMAT_UNDEFINED))
- segment->format = format;
+ g_return_val_if_fail (segment->format == format, -1);
/* if we have the position for the same format as the segment, we can compare
* the start and stop values, otherwise we assume 0 and -1 */
if (G_LIKELY (segment->format == format)) {
start = segment->start;
stop = segment->stop;
- accum = segment->accum;
+ base = segment->base;
} else {
start = 0;
stop = -1;
- accum = 0;
+ base = 0;
}
/* before the segment boundary */
result = stop - position;
}
- /* scale based on the rate, avoid division by and conversion to
+ /* scale based on the rate, avoid division by and conversion to
* float when not needed */
abs_rate = ABS (segment->rate);
if (G_UNLIKELY (abs_rate != 1.0))
result /= abs_rate;
- /* correct for accumulated segments */
- result += accum;
+ /* correct for base of the segment */
+ result += base;
return result;
}
* @clip_stop: (out) (allow-none): the clipped stop position in the segment
*
* Clip the given @start and @stop values to the segment boundaries given
- * in @segment. @start and @stop are compared and clipped to @segment
+ * in @segment. @start and @stop are compared and clipped to @segment
* start and stop values.
*
* If the function returns FALSE, @start and @stop are known to fall
* Note that when @stop is -1, @clip_stop will be set to the end of the
* segment. Depending on the use case, this may or may not be what you want.
*
- * Returns: TRUE if the given @start and @stop times fall partially or
- * completely in @segment, FALSE if the values are completely outside
+ * Returns: TRUE if the given @start and @stop times fall partially or
+ * completely in @segment, FALSE if the values are completely outside
* of the segment.
*/
gboolean
-gst_segment_clip (GstSegment * segment, GstFormat format, gint64 start,
- gint64 stop, gint64 * clip_start, gint64 * clip_stop)
+gst_segment_clip (const GstSegment * segment, GstFormat format, guint64 start,
+ guint64 stop, guint64 * clip_start, guint64 * clip_stop)
{
g_return_val_if_fail (segment != NULL, FALSE);
+ g_return_val_if_fail (segment->format == format, FALSE);
- if (G_UNLIKELY (segment->format == GST_FORMAT_UNDEFINED))
- segment->format = format;
- else
- g_return_val_if_fail (segment->format == format, FALSE);
-
- /* if we have a stop position and a valid start and start is bigger,
+ /* 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))
return FALSE;
if (stop == -1)
*clip_stop = segment->stop;
else if (segment->stop == -1)
- *clip_stop = MAX (-1, stop);
+ *clip_stop = stop;
else
*clip_stop = MIN (stop, segment->stop);
- if (segment->duration != -1)
+ if (segment->duration != -1 && *clip_stop != -1)
*clip_stop = MIN (*clip_stop, segment->duration);
}
*
* Since: 0.10.24
*/
-gint64
-gst_segment_to_position (GstSegment * segment, GstFormat format,
- gint64 running_time)
+guint64
+gst_segment_to_position (const GstSegment * segment, GstFormat format,
+ guint64 running_time)
{
- gint64 result;
- gint64 start, stop, accum;
+ guint64 result;
+ guint64 start, stop, base;
gdouble abs_rate;
- g_return_val_if_fail (segment != NULL, -1);
-
if (G_UNLIKELY (running_time == -1))
return -1;
- if (G_UNLIKELY (segment->format == GST_FORMAT_UNDEFINED))
- segment->format = format;
+ g_return_val_if_fail (segment != NULL, -1);
+ g_return_val_if_fail (segment->format == format, FALSE);
/* if we have the position for the same format as the segment, we can compare
* the start and stop values, otherwise we assume 0 and -1 */
if (G_LIKELY (segment->format == format)) {
start = segment->start;
stop = segment->stop;
- accum = segment->accum;
+ base = segment->base;
} else {
start = 0;
stop = -1;
- accum = 0;
+ base = 0;
}
/* this running_time was for a previous segment */
- if (running_time < accum)
+ if (running_time < base)
return -1;
- /* start by subtracting the accumulated time */
- result = running_time - accum;
+ /* start by subtracting the base time */
+ result = running_time - base;
/* move into the segment at the right rate */
abs_rate = ABS (segment->rate);
* @format: the format of the segment.
* @running_time: the running_time in the segment
*
- * Adjust the start/stop and accum values of @segment such that the next valid
+ * Adjust the start/stop and base values of @segment such that the next valid
* buffer will be one with @running_time.
*
* Returns: %TRUE if the segment could be updated successfully. If %FALSE is
*/
gboolean
gst_segment_set_running_time (GstSegment * segment, GstFormat format,
- gint64 running_time)
+ guint64 running_time)
{
- gint64 position;
- gint64 start, stop, last_stop;
+ guint64 position;
+ guint64 start, stop;
/* start by bringing the running_time into the segment position */
position = gst_segment_to_position (segment, format, running_time);
start = segment->start;
stop = segment->stop;
- last_stop = segment->last_stop;
if (G_LIKELY (segment->rate > 0.0)) {
- /* update the start/last_stop and time values */
+ /* update the start and time values */
start = position;
- if (last_stop < start)
- last_stop = start;
} else {
/* reverse, update stop */
stop = position;
- /* if we were past the position, go back */
- if (last_stop > stop)
- last_stop = stop;
}
- /* and accumulated time is exactly the running time */
+ /* and base time is exactly the running time */
segment->time = gst_segment_to_stream_time (segment, format, start);
segment->start = start;
segment->stop = stop;
- segment->last_stop = last_stop;
- segment->accum = running_time;
+ segment->base = running_time;
return TRUE;
}
#ifndef __GST_SEGMENT_H__
#define __GST_SEGMENT_H__
-#include <gst/gstevent.h>
#include <gst/gstformat.h>
G_BEGIN_DECLS
typedef struct _GstSegment GstSegment;
/**
+ * GstSeekType:
+ * @GST_SEEK_TYPE_NONE: no change in position is required
+ * @GST_SEEK_TYPE_CUR: change relative to currently configured segment. This
+ * can't be used to seek relative to the current playback position - do a
+ * position query, calculate the desired position and then do an absolute
+ * position seek instead if that's what you want to do.
+ * @GST_SEEK_TYPE_SET: absolute position is requested
+ * @GST_SEEK_TYPE_END: relative position to duration is requested
+ *
+ * The different types of seek events. When constructing a seek event with
+ * gst_event_new_seek() or when doing gst_segment_do_seek ().
+ */
+typedef enum {
+ /* one of these */
+ GST_SEEK_TYPE_NONE = 0,
+ GST_SEEK_TYPE_CUR = 1,
+ GST_SEEK_TYPE_SET = 2,
+ GST_SEEK_TYPE_END = 3
+} GstSeekType;
+
+/**
+ * GstSeekFlags:
+ * @GST_SEEK_FLAG_NONE: no flag
+ * @GST_SEEK_FLAG_FLUSH: flush pipeline
+ * @GST_SEEK_FLAG_ACCURATE: accurate position is requested, this might
+ * be considerably slower for some formats.
+ * @GST_SEEK_FLAG_KEY_UNIT: seek to the nearest keyframe. This might be
+ * faster but less accurate.
+ * @GST_SEEK_FLAG_SEGMENT: perform a segment seek.
+ * @GST_SEEK_FLAG_SKIP: when doing fast foward or fast reverse playback, allow
+ * elements to skip frames instead of generating all
+ * frames. Since 0.10.22.
+ *
+ * Flags to be used with gst_element_seek() or gst_event_new_seek(). All flags
+ * can be used together.
+ *
+ * A non flushing seek might take some time to perform as the currently
+ * playing data in the pipeline will not be cleared.
+ *
+ * An accurate seek might be slower for formats that don't have any indexes
+ * or timestamp markers in the stream. Specifying this flag might require a
+ * complete scan of the file in those cases.
+ *
+ * When performing a segment seek: after the playback of the segment completes,
+ * no EOS will be emmited by the element that performed the seek, but a
+ * #GST_MESSAGE_SEGMENT_DONE message will be posted on the bus by the element.
+ * When this message is posted, it is possible to send a new seek event to
+ * continue playback. With this seek method it is possible to perform seemless
+ * looping or simple linear editing.
+ *
+ * When doing fast forward (rate > 1.0) or fast reverse (rate < -1.0) trickmode
+ * playback, the @GST_SEEK_FLAG_SKIP flag can be used to instruct decoders
+ * and demuxers to adjust the playback rate by skipping frames. This can improve
+ * performance and decrease CPU usage because not all frames need to be decoded.
+ *
+ * Also see part-seeking.txt in the GStreamer design documentation for more
+ * details on the meaning of these flags and the behaviour expected of
+ * elements that handle them.
+ */
+typedef enum {
+ GST_SEEK_FLAG_NONE = 0,
+ GST_SEEK_FLAG_FLUSH = (1 << 0),
+ GST_SEEK_FLAG_ACCURATE = (1 << 1),
+ GST_SEEK_FLAG_KEY_UNIT = (1 << 2),
+ GST_SEEK_FLAG_SEGMENT = (1 << 3),
+ GST_SEEK_FLAG_SKIP = (1 << 4)
+} GstSeekFlags;
+
+/**
* GstSegment:
+ * @flags: flags for this segment
* @rate: the rate of the segment
* @applied_rate: the already applied rate to the segment
* @format: the format of the segment values
- * @flags: flags for this segment
+ * @base: the base time of the segment
* @start: the start of the segment
* @stop: the stop of the segment
* @time: the stream time of the segment
- * @accum: accumulated segment
- * @last_stop: last known stop time
- * @duration: total duration of segment
*
* A helper structure that holds the configured region of
* interest in a media file.
*/
struct _GstSegment {
/*< public >*/
- gdouble rate;
- gdouble applied_rate;
- GstFormat format;
- GstSeekFlags flags;
- gint64 start;
- gint64 stop;
- gint64 time;
- gint64 accum;
-
- gint64 last_stop;
- gint64 duration;
-
- /*< private >*/
- gpointer _gst_reserved[GST_PADDING];
+ GstSeekFlags flags;
+
+ gdouble rate;
+ gdouble applied_rate;
+
+ GstFormat format;
+ guint64 base;
+ guint64 start;
+ guint64 stop;
+ guint64 time;
+
+ guint64 position;
+ guint64 duration;
};
GType gst_segment_get_type (void);
GstSegment * gst_segment_new (void);
-GstSegment * gst_segment_copy (GstSegment *segment);
+GstSegment * gst_segment_copy (const GstSegment *segment);
+void gst_segment_copy_into (const GstSegment *src, GstSegment *dest);
void gst_segment_free (GstSegment *segment);
void gst_segment_init (GstSegment *segment, GstFormat format);
-void gst_segment_set_duration (GstSegment *segment, GstFormat format, gint64 duration);
-void gst_segment_set_last_stop (GstSegment *segment, GstFormat format, gint64 position);
-
-void gst_segment_set_seek (GstSegment *segment, gdouble rate,
- GstFormat format, GstSeekFlags flags,
- GstSeekType start_type, gint64 start,
- GstSeekType stop_type, gint64 stop,
- gboolean *update);
+guint64 gst_segment_to_stream_time (const GstSegment *segment, GstFormat format, guint64 position);
+guint64 gst_segment_to_running_time (const GstSegment *segment, GstFormat format, guint64 position);
+guint64 gst_segment_to_position (const GstSegment *segment, GstFormat format, guint64 running_time);
-void gst_segment_set_newsegment (GstSegment *segment, gboolean update, gdouble rate,
- gdouble applied_rate, GstFormat format, gint64 start,
- gint64 stop, gint64 time);
+gboolean gst_segment_set_running_time (GstSegment *segment, GstFormat format, guint64 running_time);
-gint64 gst_segment_to_stream_time (GstSegment *segment, GstFormat format, gint64 position);
-gint64 gst_segment_to_running_time (GstSegment *segment, GstFormat format, gint64 position);
-gint64 gst_segment_to_position (GstSegment *segment, GstFormat format, gint64 running_time);
+gboolean gst_segment_clip (const GstSegment *segment, GstFormat format, guint64 start,
+ guint64 stop, guint64 *clip_start, guint64 *clip_stop);
-gboolean gst_segment_clip (GstSegment *segment, GstFormat format, gint64 start,
- gint64 stop, gint64 *clip_start, gint64 *clip_stop);
-
-gboolean gst_segment_set_running_time (GstSegment *segment, GstFormat format, gint64 running_time);
+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);
G_END_DECLS
GST_DEBUG_OBJECT (parse, "handling event %d, %s", GST_EVENT_TYPE (event),
GST_EVENT_TYPE_NAME (event));
- /* Cache all events except EOS, NEWSEGMENT and FLUSH_STOP if we have a
+ /* Cache all events except EOS, SEGMENT and FLUSH_STOP if we have a
* pending segment */
if (parse->priv->pending_segment && GST_EVENT_TYPE (event) != GST_EVENT_EOS
- && GST_EVENT_TYPE (event) != GST_EVENT_NEWSEGMENT
+ && GST_EVENT_TYPE (event) != GST_EVENT_SEGMENT
&& GST_EVENT_TYPE (event) != GST_EVENT_FLUSH_START
&& GST_EVENT_TYPE (event) != GST_EVENT_FLUSH_STOP) {
GstEvent **eventp;
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
+ const GstSegment *in_segment;
+ GstSegment out_segment;
+ gint64 offset = 0, next_ts;
+
+#if 0
gdouble rate, applied_rate;
GstFormat format;
- gint64 start, stop, pos, next_ts, offset = 0;
+ gint64 start, stop, pos, next_ts;
gboolean update;
+#endif
- gst_event_parse_new_segment (event, &update, &rate, &applied_rate,
- &format, &start, &stop, &pos);
+ in_segment = gst_event_get_segment (event);
+ gst_segment_init (&out_segment, GST_FORMAT_TIME);
- GST_DEBUG_OBJECT (parse, "newseg rate %g, applied rate %g, "
- "format %d, start = %" GST_TIME_FORMAT ", stop = %" GST_TIME_FORMAT
- ", pos = %" GST_TIME_FORMAT, rate, applied_rate, format,
- GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (pos));
+ GST_DEBUG_OBJECT (parse, "segment %" GST_SEGMENT_FORMAT, in_segment);
- if (format == GST_FORMAT_BYTES) {
- GstClockTime seg_start, seg_stop;
+ if (in_segment->format == GST_FORMAT_BYTES) {
GstBaseParseSeek *seek = NULL;
GSList *node;
/* stop time is allowed to be open-ended, but not start & pos */
- seg_stop = GST_CLOCK_TIME_NONE;
- seg_start = 0;
- offset = pos;
+ offset = in_segment->time;
GST_OBJECT_LOCK (parse);
for (node = parse->priv->pending_seeks; node; node = node->next) {
GstBaseParseSeek *tmp = node->data;
- if (tmp->offset == pos) {
+ if (tmp->offset == offset) {
seek = tmp;
break;
}
GST_DEBUG_OBJECT (parse,
"Matched newsegment to%s seek: %" GST_SEGMENT_FORMAT,
seek->accurate ? " accurate" : "", &seek->segment);
- seg_start = seek->segment.start;
- seg_stop = seek->segment.stop;
+
+ out_segment.start = seek->segment.start;
+ out_segment.stop = seek->segment.stop;
+ out_segment.time = seek->segment.start;
+
next_ts = seek->start_ts;
parse->priv->exact_position = seek->accurate;
g_free (seek);
/* best attempt convert */
/* as these are only estimates, stop is kept open-ended to avoid
* premature cutting */
- gst_base_parse_convert (parse, GST_FORMAT_BYTES, start,
- GST_FORMAT_TIME, (gint64 *) & seg_start);
- parse->priv->exact_position = (start == 0);
- next_ts = seg_start;
+ gst_base_parse_convert (parse, GST_FORMAT_BYTES, in_segment->start,
+ GST_FORMAT_TIME, (gint64 *) & next_ts);
+
+ out_segment.start = next_ts;
+ out_segment.stop = GST_CLOCK_TIME_NONE;
+ out_segment.time = next_ts;
+
+ parse->priv->exact_position = (in_segment->start == 0);
}
gst_event_unref (event);
- event = gst_event_new_new_segment (update, rate, applied_rate,
- GST_FORMAT_TIME, seg_start, seg_stop, seg_start);
- format = GST_FORMAT_TIME;
- start = seg_start;
- stop = seg_stop;
+
+ event = gst_event_new_segment (&out_segment);
+
GST_DEBUG_OBJECT (parse, "Converted incoming segment to TIME. "
- "start = %" GST_TIME_FORMAT ", stop = %" GST_TIME_FORMAT,
- GST_TIME_ARGS (seg_start), GST_TIME_ARGS (seg_stop));
- } else if (format != GST_FORMAT_TIME) {
+ GST_SEGMENT_FORMAT, in_segment);
+
+ } else if (in_segment->format != GST_FORMAT_TIME) {
/* Unknown incoming segment format. Output a default open-ended
* TIME segment */
gst_event_unref (event);
- event = gst_event_new_new_segment (update, rate, applied_rate,
- GST_FORMAT_TIME, 0, GST_CLOCK_TIME_NONE, 0);
- format = GST_FORMAT_TIME;
- next_ts = start = 0;
- stop = GST_CLOCK_TIME_NONE;
+
+ out_segment.start = 0;
+ out_segment.stop = GST_CLOCK_TIME_NONE;;
+ out_segment.time = 0;;
+
+ event = gst_event_new_segment (&out_segment);
+
+ next_ts = 0;
} else {
/* not considered BYTE seekable if it is talking to us in TIME,
* whatever else it might claim */
parse->priv->upstream_seekable = FALSE;
- next_ts = start;
+ next_ts = in_segment->start;
}
- gst_segment_set_newsegment (&parse->segment, update, rate,
- applied_rate, format, start, stop, start);
+ memcpy (&parse->segment, &out_segment, sizeof (GstSegment));
+
+ /*
+ gst_segment_set_newsegment (&parse->segment, update, rate,
+ applied_rate, format, start, stop, start);
+ */
/* save the segment for later, right before we push a new buffer so that
* the caps are fixed and the next linked element can receive
/* but finish the current segment */
GST_DEBUG_OBJECT (parse, "draining current segment");
- if (parse->segment.rate > 0.0)
+ if (in_segment->rate > 0.0)
gst_base_parse_drain (parse);
else
gst_base_parse_process_fragment (parse, FALSE);
gst_adapter_clear (parse->priv->adapter);
+
parse->priv->offset = offset;
parse->priv->sync_offset = offset;
parse->priv->next_ts = next_ts;
gst_event_unref (parse->priv->pending_segment);
parse->segment.start =
MIN ((guint64) last_start, (guint64) parse->segment.stop);
+
GST_DEBUG_OBJECT (parse,
"adjusting pending segment start to %" GST_TIME_FORMAT,
GST_TIME_ARGS (parse->segment.start));
- parse->priv->pending_segment =
- gst_event_new_new_segment (FALSE, parse->segment.rate,
- parse->segment.applied_rate,
- parse->segment.format, parse->segment.start,
- parse->segment.stop, parse->segment.start);
+
+ parse->priv->pending_segment = gst_event_new_segment (&parse->segment);
}
/* handle gaps, e.g. non-zero start-time, in as much not handled by above */
- if (GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop) &&
+ if (GST_CLOCK_TIME_IS_VALID (parse->segment.position) &&
GST_CLOCK_TIME_IS_VALID (last_start)) {
GstClockTimeDiff diff;
/* only send newsegments with increasing start times,
* otherwise if these go back and forth downstream (sinks) increase
* accumulated time and running_time */
- diff = GST_CLOCK_DIFF (parse->segment.last_stop, last_start);
+ diff = GST_CLOCK_DIFF (parse->segment.position, last_start);
if (G_UNLIKELY (diff > 2 * GST_SECOND
&& last_start > parse->segment.start
&& (!GST_CLOCK_TIME_IS_VALID (parse->segment.stop)
|| last_start < parse->segment.stop))) {
+
GST_DEBUG_OBJECT (parse,
"Gap of %" G_GINT64_FORMAT " ns detected in stream " "(%"
GST_TIME_FORMAT " -> %" GST_TIME_FORMAT "). "
"Sending updated NEWSEGMENT events", diff,
- GST_TIME_ARGS (parse->segment.last_stop),
+ GST_TIME_ARGS (parse->segment.position),
GST_TIME_ARGS (last_start));
+
if (G_UNLIKELY (parse->priv->pending_segment)) {
gst_event_unref (parse->priv->pending_segment);
parse->segment.start = last_start;
+ parse->segment.time = last_start;
parse->priv->pending_segment =
- gst_event_new_new_segment (FALSE, parse->segment.rate,
- parse->segment.applied_rate,
- parse->segment.format, parse->segment.start,
- parse->segment.stop, parse->segment.start);
+ gst_event_new_segment (&parse->segment);
} else {
- /* send newsegment events such that the gap is not accounted in
- * accum time, hence running_time */
- /* close ahead of gap */
- gst_pad_push_event (parse->srcpad,
- gst_event_new_new_segment (TRUE, parse->segment.rate,
- parse->segment.applied_rate,
- parse->segment.format, parse->segment.last_stop,
- parse->segment.last_stop, parse->segment.last_stop));
- /* skip gap */
+ /* skip gap FIXME */
gst_pad_push_event (parse->srcpad,
- gst_event_new_new_segment (FALSE, parse->segment.rate,
- parse->segment.applied_rate,
- parse->segment.format, last_start,
- parse->segment.stop, last_start));
+ gst_event_new_segment (&parse->segment));
}
- /* align segment view with downstream,
- * prevents double-counting accum when closing segment */
- gst_segment_set_newsegment (&parse->segment, FALSE,
- parse->segment.rate, parse->segment.applied_rate,
- parse->segment.format, last_start, parse->segment.stop, last_start);
- parse->segment.last_stop = last_start;
+ parse->segment.position = last_start;
}
}
}
/* Update current running segment position */
if (ret == GST_FLOW_OK && last_stop != GST_CLOCK_TIME_NONE &&
- parse->segment.last_stop < last_stop)
- gst_segment_set_last_stop (&parse->segment, GST_FORMAT_TIME, last_stop);
+ parse->segment.position < last_stop)
+ parse->segment.position = last_stop;
gst_base_parse_frame_free (frame);
* ok if taken from subclass or upstream */
parse->priv->next_ts = GST_CLOCK_TIME_NONE;
/* prevent it hanging around stop all the time */
- parse->segment.last_stop = GST_CLOCK_TIME_NONE;
+ parse->segment.position = GST_CLOCK_TIME_NONE;
/* mark next run */
parse->priv->discont = TRUE;
/* eat expected eos signalling past segment in reverse playback */
if (parse->segment.rate < 0.0 && ret == GST_FLOW_UNEXPECTED &&
- parse->segment.last_stop >= parse->segment.stop) {
+ parse->segment.position >= parse->segment.stop) {
GST_DEBUG_OBJECT (parse, "downstream has reached end of segment");
/* push what was accumulated during loop run */
gst_base_parse_process_fragment (parse, TRUE);
if (result) {
if (active) {
- parse->priv->pending_segment = gst_event_new_new_segment (FALSE,
- parse->segment.rate, parse->segment.applied_rate,
- parse->segment.format, parse->segment.start, parse->segment.stop,
- parse->segment.last_stop);
+ parse->priv->pending_segment = gst_event_new_segment (&parse->segment);
result &=
gst_pad_start_task (sinkpad, (GstTaskFunction) gst_base_parse_loop,
sinkpad);
dest_value = parse->priv->offset;
res = TRUE;
} else if (format == parse->segment.format &&
- GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop)) {
- dest_value = parse->segment.last_stop;
+ GST_CLOCK_TIME_IS_VALID (parse->segment.position)) {
+ dest_value = parse->segment.position;
res = TRUE;
}
GST_OBJECT_UNLOCK (parse);
/* copy segment, we need this because we still need the old
* segment when we close the current segment. */
- memcpy (&seeksegment, &parse->segment, sizeof (GstSegment));
+ gst_segment_copy_into (&parse->segment, &seeksegment);
GST_DEBUG_OBJECT (parse, "configuring seek");
- gst_segment_set_seek (&seeksegment, rate, format, flags,
+ gst_segment_do_seek (&seeksegment, rate, format, flags,
cur_type, cur, stop_type, stop, &update);
/* accurate seeking implies seek tables are used to obtain position,
accurate = flags & GST_SEEK_FLAG_ACCURATE;
/* maybe we can be accurate for (almost) free */
- gst_base_parse_find_offset (parse, seeksegment.last_stop, TRUE, &start_ts);
- if (seeksegment.last_stop <= start_ts + TARGET_DIFFERENCE) {
+ gst_base_parse_find_offset (parse, seeksegment.position, TRUE, &start_ts);
+ if (seeksegment.position <= start_ts + TARGET_DIFFERENCE) {
GST_DEBUG_OBJECT (parse, "accurate seek possible");
accurate = TRUE;
}
if (accurate) {
- GstClockTime startpos = seeksegment.last_stop;
+ GstClockTime startpos = seeksegment.position;
/* accurate requested, so ... seek a bit before target */
if (startpos < parse->priv->lead_in_ts)
seekstop = gst_base_parse_find_offset (parse, seeksegment.stop, FALSE,
NULL);
} else {
- start_ts = seeksegment.last_stop;
+ start_ts = seeksegment.position;
dstformat = GST_FORMAT_BYTES;
- if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.last_stop,
+ if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.position,
&dstformat, &seekpos))
goto convert_failed;
if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.stop,
GST_PAD_STREAM_LOCK (parse->sinkpad);
/* save current position */
- last_stop = parse->segment.last_stop;
+ last_stop = parse->segment.position;
GST_DEBUG_OBJECT (parse, "stopped streaming at %" G_GINT64_FORMAT,
last_stop);
gst_pad_push_event (parse->sinkpad, gst_event_new_flush_stop ());
gst_base_parse_clear_queues (parse);
} else {
- if (parse->priv->close_segment)
- gst_event_unref (parse->priv->close_segment);
-
- parse->priv->close_segment = gst_event_new_new_segment (TRUE,
- parse->segment.rate, parse->segment.applied_rate,
- parse->segment.format, parse->segment.accum, parse->segment.last_stop,
- parse->segment.accum);
-
- /* keep track of our last_stop */
- seeksegment.accum = parse->segment.last_stop;
-
- GST_DEBUG_OBJECT (parse, "Created close seg format %d, "
- "start = %" GST_TIME_FORMAT ", stop = %" GST_TIME_FORMAT
- ", pos = %" GST_TIME_FORMAT, format,
- GST_TIME_ARGS (parse->segment.accum),
- GST_TIME_ARGS (parse->segment.last_stop),
- GST_TIME_ARGS (parse->segment.accum));
+ /* keep track of our position */
+ seeksegment.base = gst_segment_to_running_time (&seeksegment,
+ seeksegment.format, parse->segment.position);
}
memcpy (&parse->segment, &seeksegment, sizeof (GstSegment));
gst_event_unref (parse->priv->pending_segment);
/* This will be sent later in _loop() */
- parse->priv->pending_segment =
- gst_event_new_new_segment (FALSE, parse->segment.rate,
- parse->segment.applied_rate,
- parse->segment.format, parse->segment.start,
- parse->segment.stop, parse->segment.start);
+ parse->priv->pending_segment = gst_event_new_segment (&parse->segment);
GST_DEBUG_OBJECT (parse, "Created newseg format %d, "
"start = %" GST_TIME_FORMAT ", stop = %" GST_TIME_FORMAT
* maybe scan and subclass can find where to go */
if (!accurate) {
gint64 scanpos;
- GstClockTime ts = seeksegment.last_stop;
+ GstClockTime ts = seeksegment.position;
gst_base_parse_locate_time (parse, &ts, &scanpos);
if (scanpos >= 0) {
gst_base_sink_configure_segment (GstBaseSink * basesink, GstPad * pad,
GstEvent * event, GstSegment * segment)
{
- gboolean update;
- gdouble rate, arate;
- GstFormat format;
- gint64 start;
- gint64 stop;
- gint64 time;
-
- /* the newsegment event is needed to bring the buffer timestamps to the
- * stream time and to drop samples outside of the playback segment. */
- gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
- &start, &stop, &time);
-
/* The segment is protected with both the STREAM_LOCK and the OBJECT_LOCK.
* We protect with the OBJECT_LOCK so that we can use the values to
* safely answer a POSITION query. */
GST_OBJECT_LOCK (basesink);
- gst_segment_set_newsegment (segment, update, rate, arate, format, start,
- stop, time);
-
- if (format == GST_FORMAT_TIME) {
- GST_DEBUG_OBJECT (basesink,
- "configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
- "format GST_FORMAT_TIME, "
- "%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT
- ", time %" GST_TIME_FORMAT ", accum %" GST_TIME_FORMAT,
- update, rate, arate, GST_TIME_ARGS (segment->start),
- GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time),
- GST_TIME_ARGS (segment->accum));
- } else {
- GST_DEBUG_OBJECT (basesink,
- "configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
- "format %d, "
- "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
- G_GINT64_FORMAT ", accum %" G_GINT64_FORMAT, update, rate, arate,
- segment->format, segment->start, segment->stop, segment->time,
- segment->accum);
- }
+ /* the newsegment event is needed to bring the buffer timestamps to the
+ * stream time and to drop samples outside of the playback segment. */
+ gst_event_parse_segment (event, segment);
+ GST_DEBUG_OBJECT (basesink, "configured NEWSEGMENT %" GST_SEGMENT_FORMAT,
+ segment);
GST_OBJECT_UNLOCK (basesink);
}
/* update the segment clipping regions for non-flushing seeks */
if (segment->rate > 0.0) {
segment->stop = gst_segment_to_position (segment, GST_FORMAT_TIME, end);
- segment->last_stop = segment->stop;
+ segment->position = segment->stop;
} else {
gint64 position;
position = gst_segment_to_position (segment, GST_FORMAT_TIME, end);
segment->time = position;
segment->start = position;
- segment->last_stop = position;
+ segment->position = position;
}
}
}
- GST_DEBUG_OBJECT (sink,
- "segment now rate %lf, applied rate %lf, "
- "format GST_FORMAT_TIME, "
- "%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT
- ", time %" GST_TIME_FORMAT ", accum %" GST_TIME_FORMAT,
- segment->rate, segment->applied_rate, GST_TIME_ARGS (segment->start),
- GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time),
- GST_TIME_ARGS (segment->accum));
-
+ GST_DEBUG_OBJECT (sink, "segment now %" GST_SEGMENT_FORMAT, segment);
GST_DEBUG_OBJECT (sink, "step started at running_time %" GST_TIME_FORMAT,
GST_TIME_ARGS (current->start));
gst_segment_set_running_time (segment, GST_FORMAT_TIME, position);
if (current->flush) {
- /* and remove the accumulated time we flushed, start time did not change */
- segment->accum = current->start;
+ /* and remove the time we flushed, start time did not change */
+ segment->base = current->start;
} else {
/* start time is now the stepped position */
gst_element_set_start_time (GST_ELEMENT_CAST (sink), position);
segment->start = current->start_start;
/* the clip segment is used for position report in paused... */
- memcpy (sink->clip_segment, segment, sizeof (GstSegment));
+ gst_segment_copy_into (segment, sink->clip_segment);
/* post the step done when we know the stepped duration in TIME */
message =
static gboolean
handle_stepping (GstBaseSink * sink, GstSegment * segment,
- GstStepInfo * current, gint64 * cstart, gint64 * cstop, gint64 * rstart,
- gint64 * rstop)
+ GstStepInfo * current, guint64 * cstart, guint64 * cstop, guint64 * rstart,
+ guint64 * rstop)
{
gboolean step_end = FALSE;
case GST_FORMAT_TIME:
{
guint64 end;
- gint64 first, last;
+ guint64 first, last;
gdouble abs_rate;
if (segment->rate > 0.0) {
GstBaseSinkClass *bclass;
GstBuffer *buffer;
GstClockTime start, stop; /* raw start/stop timestamps */
- gint64 cstart, cstop; /* clipped raw timestamps */
- gint64 rstart, rstop; /* clipped timestamps converted to running time */
+ guint64 cstart, cstop; /* clipped raw timestamps */
+ guint64 rstart, rstop; /* clipped timestamps converted to running time */
GstClockTime sstart, sstop; /* clipped timestamps converted to stream time */
GstFormat format;
GstBaseSinkPrivate *priv;
}
default:
/* other events do not need syncing */
- /* FIXME, maybe NEWSEGMENT might need synchronisation
- * since the POSITION query depends on accumulated times and
- * we cannot accumulate the current segment before the previous
- * one completed.
- */
return FALSE;
}
}
/* clip, only when we know about time */
if (G_UNLIKELY (!gst_segment_clip (segment, GST_FORMAT_TIME,
- (gint64) start, (gint64) stop, &cstart, &cstop))) {
+ start, stop, &cstart, &cstop))) {
if (step->valid) {
GST_DEBUG_OBJECT (basesink, "step out of segment");
/* when we are stepping, pretend we're at the end of the segment */
/* set last stop position */
if (G_LIKELY (stop != GST_CLOCK_TIME_NONE && cstop != GST_CLOCK_TIME_NONE))
- gst_segment_set_last_stop (segment, GST_FORMAT_TIME, cstop);
+ segment->position = cstop;
else
- gst_segment_set_last_stop (segment, GST_FORMAT_TIME, cstart);
+ segment->position = cstart;
do_times:
rstart = gst_segment_to_running_time (segment, format, cstart);
GstClockReturn status, GstClockTimeDiff jitter)
{
gboolean late;
- gint64 max_lateness;
+ guint64 max_lateness;
GstBaseSinkPrivate *priv;
priv = basesink->priv;
gst_element_post_message (GST_ELEMENT_CAST (basesink), message);
break;
}
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
/* configure the segment */
gst_base_sink_configure_segment (basesink, pad, event,
&basesink->segment);
gst_event_unref (event);
break;
}
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
GstFlowReturn ret;
- gboolean update;
- GST_DEBUG_OBJECT (basesink, "newsegment %p", event);
+ GST_DEBUG_OBJECT (basesink, "segment %p", event);
GST_BASE_SINK_PREROLL_LOCK (basesink);
if (G_UNLIKELY (basesink->flushing))
goto flushing;
- gst_event_parse_new_segment (event, &update, NULL, NULL, NULL, NULL,
- NULL, NULL);
+ /* the new segment is a non prerollable item and does not block anything,
+ * we need to configure the current clipping segment and insert the event
+ * in the queue to serialize it with the buffers for rendering. */
+ gst_base_sink_configure_segment (basesink, pad, event,
+ basesink->clip_segment);
- if (G_UNLIKELY (basesink->priv->received_eos && !update)) {
- /* we can't accept anything when we are EOS */
+ ret =
+ gst_base_sink_queue_object_unlocked (basesink, pad,
+ _PR_IS_EVENT, GST_MINI_OBJECT_CAST (event), FALSE);
+ if (G_UNLIKELY (ret != GST_FLOW_OK))
result = FALSE;
- gst_event_unref (event);
- } else {
- /* the new segment is a non prerollable item and does not block anything,
- * we need to configure the current clipping segment and insert the event
- * in the queue to serialize it with the buffers for rendering. */
- gst_base_sink_configure_segment (basesink, pad, event,
- basesink->clip_segment);
-
- ret =
- gst_base_sink_queue_object_unlocked (basesink, pad,
- _PR_IS_EVENT, GST_MINI_OBJECT_CAST (event), FALSE);
- if (G_UNLIKELY (ret != GST_FLOW_OK))
- result = FALSE;
- else {
- GST_OBJECT_LOCK (basesink);
- basesink->have_newsegment = TRUE;
- GST_OBJECT_UNLOCK (basesink);
- }
+ else {
+ GST_OBJECT_LOCK (basesink);
+ basesink->have_newsegment = TRUE;
+ GST_OBJECT_UNLOCK (basesink);
}
GST_BASE_SINK_PREROLL_UNLOCK (basesink);
break;
if (GST_CLOCK_TIME_IS_VALID (start) &&
(clip_segment->format == GST_FORMAT_TIME)) {
if (G_UNLIKELY (!gst_segment_clip (clip_segment,
- GST_FORMAT_TIME, (gint64) start, (gint64) end, NULL, NULL)))
+ GST_FORMAT_TIME, start, end, NULL, NULL)))
goto out_of_segment;
}
dest_format = segment->format;
if (seek_format == dest_format) {
- gst_segment_set_seek (segment, rate, seek_format, flags,
+ gst_segment_do_seek (segment, rate, seek_format, flags,
cur_type, cur, stop_type, stop, &update);
return TRUE;
}
}
/* And finally, configure our output segment in the desired format */
- gst_segment_set_seek (segment, rate, dest_format, flags, cur_type, cur,
+ gst_segment_do_seek (segment, rate, dest_format, flags, cur_type, cur,
stop_type, stop, &update);
if (!res)
} else {
/* The seek format matches our processing format, no need to ask the
* the subclass to configure the segment. */
- gst_segment_set_seek (&seeksegment, rate, seek_format, flags,
+ gst_segment_do_seek (&seeksegment, rate, seek_format, flags,
cur_type, cur, stop_type, stop, &update);
}
}
if (res) {
GST_DEBUG_OBJECT (sink, "segment configured from %" G_GINT64_FORMAT
" to %" G_GINT64_FORMAT ", position %" G_GINT64_FORMAT,
- seeksegment.start, seeksegment.stop, seeksegment.last_stop);
+ seeksegment.start, seeksegment.stop, seeksegment.position);
- /* do the seek, segment.last_stop contains the new position. */
+ /* do the seek, segment.position contains the new position. */
res = gst_base_sink_default_do_seek (sink, &seeksegment);
}
gst_base_sink_flush_stop (sink, pad);
} else if (res && sink->running) {
/* we are running the current segment and doing a non-flushing seek,
- * close the segment first based on the last_stop. */
+ * close the segment first based on the position. */
GST_DEBUG_OBJECT (sink, "closing running segment %" G_GINT64_FORMAT
- " to %" G_GINT64_FORMAT, sink->segment.start, sink->segment.last_stop);
+ " to %" G_GINT64_FORMAT, sink->segment.start, sink->segment.position);
}
/* The subclass must have converted the segment to the processing format
/* if successfull seek, we update our real segment and push
* out the new segment. */
if (res) {
- memcpy (&sink->segment, &seeksegment, sizeof (GstSegment));
+ gst_segment_copy_into (&seeksegment, &sink->segment);
if (sink->segment.flags & GST_SEEK_FLAG_SEGMENT) {
gst_element_post_message (GST_ELEMENT (sink),
gst_message_new_segment_start (GST_OBJECT (sink),
- sink->segment.format, sink->segment.last_stop));
+ sink->segment.format, sink->segment.position));
}
}
if ((blocksize = basesink->priv->blocksize) == 0)
blocksize = -1;
- offset = basesink->segment.last_stop;
+ offset = basesink->segment.position;
GST_DEBUG_OBJECT (basesink, "pulling %" G_GUINT64_FORMAT ", %u",
offset, blocksize);
offset += gst_buffer_get_size (buf);
- gst_segment_set_last_stop (&basesink->segment, GST_FORMAT_BYTES, offset);
+ basesink->segment.position = offset;
GST_BASE_SINK_PREROLL_LOCK (basesink);
result = gst_base_sink_chain_unlocked (basesink, pad, _PR_IS_BUFFER, buf);
if (basesink->segment.flags & GST_SEEK_FLAG_SEGMENT) {
gst_element_post_message (GST_ELEMENT_CAST (basesink),
gst_message_new_segment_done (GST_OBJECT_CAST (basesink),
- basesink->segment.format, basesink->segment.last_stop));
+ basesink->segment.format, basesink->segment.position));
} else {
gst_base_sink_event (pad, gst_event_new_eos ());
}
if (result) {
GST_DEBUG_OBJECT (basesink,
"setting duration in bytes to %" G_GINT64_FORMAT, duration);
- gst_segment_set_duration (basesink->clip_segment, format, duration);
- gst_segment_set_duration (&basesink->segment, format, duration);
+ basesink->clip_segment->duration = duration;
+ basesink->segment.duration = duration;
} else {
GST_DEBUG_OBJECT (basesink, "unknown duration");
}
GstFormat oformat, tformat;
GstSegment *segment;
GstClockTime now, latency;
- GstClockTimeDiff base;
- gint64 time, accum, duration;
+ GstClockTimeDiff base_time;
+ gint64 time, base, duration;
gdouble rate;
gint64 last;
gboolean last_seen, with_clock, in_paused;
else
duration = 0;
- accum = segment->accum;
+ base = segment->base;
rate = segment->rate * segment->applied_rate;
latency = basesink->priv->latency;
}
} else {
/* convert last stop to stream time */
- last = gst_segment_to_stream_time (segment, oformat, segment->last_stop);
+ last = gst_segment_to_stream_time (segment, oformat, segment->position);
}
if (in_paused) {
/* in paused, use start_time */
- base = GST_ELEMENT_START_TIME (basesink);
+ base_time = GST_ELEMENT_START_TIME (basesink);
GST_DEBUG_OBJECT (basesink, "in paused, using start time %" GST_TIME_FORMAT,
- GST_TIME_ARGS (base));
+ GST_TIME_ARGS (base_time));
} else if (with_clock) {
/* else use clock when needed */
- base = GST_ELEMENT_CAST (basesink)->base_time;
+ base_time = GST_ELEMENT_CAST (basesink)->base_time;
GST_DEBUG_OBJECT (basesink, "using clock and base time %" GST_TIME_FORMAT,
- GST_TIME_ARGS (base));
+ GST_TIME_ARGS (base_time));
} else {
/* else, no sync or clock -> no base time */
GST_DEBUG_OBJECT (basesink, "no sync or no clock");
- base = -1;
+ base_time = -1;
}
- /* no base, we can't calculate running_time, use last seem timestamp to report
+ /* no base_time, we can't calculate running_time, use last seem timestamp to report
* time */
- if (base == -1)
+ if (base_time == -1)
last_seen = TRUE;
/* need to release the object lock before we can get the time,
*cur = last;
} else {
if (oformat != tformat) {
- /* convert accum, time and duration to time */
- if (!gst_pad_query_convert (basesink->sinkpad, oformat, accum, &tformat,
- &accum))
+ /* convert base, time and duration to time */
+ if (!gst_pad_query_convert (basesink->sinkpad, oformat, base, &tformat,
+ &base))
goto convert_failed;
if (!gst_pad_query_convert (basesink->sinkpad, oformat, duration,
&tformat, &duration))
if (!in_paused && with_clock) {
now = gst_clock_get_time (clock);
} else {
- now = base;
- base = 0;
+ now = base_time;
+ base_time = 0;
}
- /* subtract base time and accumulated time from the clock time.
+ /* subtract base time and base time from the clock time.
* Make sure we don't go negative. This is the current time in
* the segment which we need to scale with the combined
* rate and applied rate. */
- base += accum;
- base += latency;
- if (GST_CLOCK_DIFF (base, now) < 0)
- base = now;
+ base_time += base;
+ base_time += latency;
+ if (GST_CLOCK_DIFF (base_time, now) < 0)
+ base_time = now;
/* for negative rates we need to count back from the segment
* duration. */
if (rate < 0.0)
time += duration;
- *cur = time + gst_guint64_to_gdouble (now - base) * rate;
+ *cur = time + gst_guint64_to_gdouble (now - base_time) * rate;
if (in_paused) {
/* never report less than segment values in paused */
}
GST_DEBUG_OBJECT (basesink,
- "now %" GST_TIME_FORMAT " - base %" GST_TIME_FORMAT " - accum %"
+ "now %" GST_TIME_FORMAT " - base_time %" GST_TIME_FORMAT " - base %"
GST_TIME_FORMAT " + time %" GST_TIME_FORMAT " last %" GST_TIME_FORMAT,
- GST_TIME_ARGS (now), GST_TIME_ARGS (base), GST_TIME_ARGS (accum),
+ GST_TIME_ARGS (now), GST_TIME_ARGS (base_time), GST_TIME_ARGS (base),
GST_TIME_ARGS (time), GST_TIME_ARGS (last));
}
* should be done at a higher level. */
res = gst_pad_query_peer_duration (basesink->sinkpad, &uformat, &uduration);
if (res) {
- gst_segment_set_duration (&basesink->segment, uformat, uduration);
+ basesink->segment.duration = uduration;
if (format != uformat) {
/* convert to the requested format */
res = gst_pad_query_convert (basesink->sinkpad, uformat, uduration,
gboolean discont;
gboolean flushing;
- /* two segments to be sent in the streaming thread with STREAM_LOCK */
- GstEvent *close_segment;
- GstEvent *start_segment;
- gboolean newsegment_pending;
+ /* if segment should be sent */
+ gboolean segment_pending;
/* if EOS is pending (atomic) */
gint pending_eos;
GST_TIME_ARGS (stop), GST_TIME_ARGS (position));
GST_OBJECT_LOCK (src);
- if (src->running && !src->priv->newsegment_pending) {
- if (src->priv->close_segment)
- gst_event_unref (src->priv->close_segment);
- src->priv->close_segment =
- gst_event_new_new_segment (TRUE,
- src->segment.rate, src->segment.applied_rate, src->segment.format,
- src->segment.start, src->segment.last_stop, src->segment.time);
- }
-
- gst_segment_set_newsegment (&src->segment, FALSE, src->segment.rate,
- src->segment.applied_rate, src->segment.format, start, stop, position);
-
- if (src->priv->start_segment)
- gst_event_unref (src->priv->start_segment);
- if (src->segment.rate >= 0.0) {
- /* forward, we send data from last_stop to stop */
- src->priv->start_segment =
- gst_event_new_new_segment (FALSE,
- src->segment.rate, src->segment.applied_rate, src->segment.format,
- src->segment.last_stop, stop, src->segment.time);
- } else {
- /* reverse, we send data from last_stop to start */
- src->priv->start_segment =
- gst_event_new_new_segment (FALSE,
- src->segment.rate, src->segment.applied_rate, src->segment.format,
- src->segment.start, src->segment.last_stop, src->segment.time);
- }
+
+ src->segment.base = gst_segment_to_running_time (&src->segment,
+ src->segment.format, src->segment.position);
+ src->segment.start = start;
+ src->segment.stop = stop;
+ src->segment.position = position;
+
+ /* forward, we send data from position to stop */
+ src->priv->segment_pending = TRUE;
GST_OBJECT_UNLOCK (src);
src->priv->discont = TRUE;
gint64 duration;
GST_OBJECT_LOCK (src);
- position = src->segment.last_stop;
+ position = src->segment.position;
duration = src->segment.duration;
GST_OBJECT_UNLOCK (src);
GST_OBJECT_LOCK (src);
position =
gst_segment_to_stream_time (&src->segment, src->segment.format,
- src->segment.last_stop);
+ src->segment.position);
seg_format = src->segment.format;
GST_OBJECT_UNLOCK (src);
dest_format = segment->format;
if (seek_format == dest_format) {
- gst_segment_set_seek (segment, rate, seek_format, flags,
+ gst_segment_do_seek (segment, rate, seek_format, flags,
cur_type, cur, stop_type, stop, &update);
return TRUE;
}
}
/* And finally, configure our output segment in the desired format */
- gst_segment_set_seek (segment, rate, dest_format, flags, cur_type, cur,
+ gst_segment_do_seek (segment, rate, dest_format, flags, cur_type, cur,
stop_type, stop, &update);
if (!res)
} else {
/* The seek format matches our processing format, no need to ask the
* the subclass to configure the segment. */
- gst_segment_set_seek (&seeksegment, rate, seek_format, flags,
+ gst_segment_do_seek (&seeksegment, rate, seek_format, flags,
cur_type, cur, stop_type, stop, &update);
}
}
if (res) {
GST_DEBUG_OBJECT (src, "segment configured from %" G_GINT64_FORMAT
" to %" G_GINT64_FORMAT ", position %" G_GINT64_FORMAT,
- seeksegment.start, seeksegment.stop, seeksegment.last_stop);
+ seeksegment.start, seeksegment.stop, seeksegment.position);
- /* do the seek, segment.last_stop contains the new position. */
+ /* do the seek, segment.position contains the new position. */
res = gst_base_src_do_seek (src, &seeksegment);
}
/* send flush stop, peer will accept data and events again. We
* are not yet providing data as we still have the STREAM_LOCK. */
gst_pad_push_event (src->srcpad, tevent);
- } else if (res && src->running) {
- /* we are running the current segment and doing a non-flushing seek,
- * close the segment first based on the last_stop. */
- GST_DEBUG_OBJECT (src, "closing running segment %" G_GINT64_FORMAT
- " to %" G_GINT64_FORMAT, src->segment.start, src->segment.last_stop);
-
- /* queue the segment for sending in the stream thread */
- if (src->priv->close_segment)
- gst_event_unref (src->priv->close_segment);
- src->priv->close_segment =
- gst_event_new_new_segment (TRUE,
- src->segment.rate, src->segment.applied_rate, src->segment.format,
- src->segment.start, src->segment.last_stop, src->segment.time);
- gst_event_set_seqnum (src->priv->close_segment, seqnum);
}
/* The subclass must have converted the segment to the processing format
GstMessage *message;
message = gst_message_new_segment_start (GST_OBJECT (src),
- seeksegment.format, seeksegment.last_stop);
+ seeksegment.format, seeksegment.position);
gst_message_set_seqnum (message, seqnum);
gst_element_post_message (GST_ELEMENT (src), message);
if ((stop = seeksegment.stop) == -1)
stop = seeksegment.duration;
- GST_DEBUG_OBJECT (src, "Sending newsegment from %" G_GINT64_FORMAT
- " to %" G_GINT64_FORMAT, seeksegment.start, stop);
-
- /* now replace the old segment so that we send it in the stream thread the
- * next time it is scheduled. */
- if (src->priv->start_segment)
- gst_event_unref (src->priv->start_segment);
- if (seeksegment.rate >= 0.0) {
- /* forward, we send data from last_stop to stop */
- src->priv->start_segment =
- gst_event_new_new_segment (FALSE,
- seeksegment.rate, seeksegment.applied_rate, seeksegment.format,
- seeksegment.last_stop, stop, seeksegment.time);
- } else {
- /* reverse, we send data from last_stop to start */
- src->priv->start_segment =
- gst_event_new_new_segment (FALSE,
- seeksegment.rate, seeksegment.applied_rate, seeksegment.format,
- seeksegment.start, seeksegment.last_stop, seeksegment.time);
- }
- gst_event_set_seqnum (src->priv->start_segment, seqnum);
- src->priv->newsegment_pending = TRUE;
+ src->priv->segment_pending = TRUE;
}
src->priv->discont = TRUE;
result = TRUE;
break;
}
- case GST_EVENT_NEWSEGMENT:
- /* sending random NEWSEGMENT downstream can break sync. */
+ case GST_EVENT_SEGMENT:
+ /* sending random SEGMENT downstream can break sync. */
break;
case GST_EVENT_TAG:
case GST_EVENT_CUSTOM_DOWNSTREAM:
/* keep track of current position and update duration.
* segment is in bytes, we checked that above. */
GST_OBJECT_LOCK (src);
- gst_segment_set_duration (&src->segment, GST_FORMAT_BYTES, size);
- gst_segment_set_last_stop (&src->segment, GST_FORMAT_BYTES, offset);
+ src->segment.duration = size;
+ src->segment.position = offset;
GST_OBJECT_UNLOCK (src);
return TRUE;
/* if we operate in bytes, we can calculate an offset */
if (src->segment.format == GST_FORMAT_BYTES) {
- position = src->segment.last_stop;
+ position = src->segment.position;
/* for negative rates, start with subtracting the blocksize */
if (src->segment.rate < 0.0) {
/* we cannot go below segment.start */
goto null_buffer;
/* push events to close/start our segment before we push the buffer. */
- if (G_UNLIKELY (src->priv->close_segment)) {
- gst_pad_push_event (pad, src->priv->close_segment);
- src->priv->close_segment = NULL;
- }
- if (G_UNLIKELY (src->priv->start_segment)) {
- gst_pad_push_event (pad, src->priv->start_segment);
- src->priv->start_segment = NULL;
+ if (G_UNLIKELY (src->priv->segment_pending)) {
+ gst_pad_push_event (pad, gst_event_new_segment (&src->segment));
+ src->priv->segment_pending = FALSE;
}
- src->priv->newsegment_pending = FALSE;
if (g_atomic_int_get (&src->priv->have_events)) {
GST_OBJECT_LOCK (src);
if (GST_CLOCK_TIME_IS_VALID (start))
position = start;
else
- position = src->segment.last_stop;
+ position = src->segment.position;
if (GST_CLOCK_TIME_IS_VALID (duration)) {
if (src->segment.rate >= 0.0)
src->priv->discont = TRUE;
}
GST_OBJECT_LOCK (src);
- gst_segment_set_last_stop (&src->segment, src->segment.format, position);
+ src->segment.position = position;
GST_OBJECT_UNLOCK (src);
}
if (ret == GST_FLOW_UNEXPECTED) {
gboolean flag_segment;
GstFormat format;
- gint64 last_stop;
+ gint64 position;
/* perform EOS logic */
flag_segment = (src->segment.flags & GST_SEEK_FLAG_SEGMENT) != 0;
format = src->segment.format;
- last_stop = src->segment.last_stop;
+ position = src->segment.position;
if (flag_segment) {
GstMessage *message;
message = gst_message_new_segment_done (GST_OBJECT_CAST (src),
- format, last_stop);
+ format, position);
gst_message_set_seqnum (message, src->priv->seqnum);
gst_element_post_message (GST_ELEMENT_CAST (src), message);
} else {
GST_OBJECT_UNLOCK (basesrc);
basesrc->running = FALSE;
- basesrc->priv->newsegment_pending = FALSE;
+ basesrc->priv->segment_pending = FALSE;
bclass = GST_BASE_SRC_GET_CLASS (basesrc);
if (bclass->start)
/* only update the size when operating in bytes, subclass is supposed
* to set duration in the start method for other formats */
GST_OBJECT_LOCK (basesrc);
- gst_segment_set_duration (&basesrc->segment, GST_FORMAT_BYTES, size);
+ basesrc->segment.duration = size;
GST_OBJECT_UNLOCK (basesrc);
} else {
size = -1;
g_atomic_int_set (&basesrc->priv->pending_eos, FALSE);
event_p = &basesrc->pending_seek;
gst_event_replace (event_p, NULL);
- event_p = &basesrc->priv->close_segment;
- gst_event_replace (event_p, NULL);
- event_p = &basesrc->priv->start_segment;
- gst_event_replace (event_p, NULL);
break;
}
case GST_STATE_CHANGE_READY_TO_NULL:
guint64 processed;
guint64 dropped;
- GstClockTime last_stop_out;
+ GstClockTime position_out;
};
static GstElementClass *parent_class = NULL;
ret = TRUE;
if ((pad == trans->sinkpad)
- || (trans->priv->last_stop_out == GST_CLOCK_TIME_NONE)) {
+ || (trans->priv->position_out == GST_CLOCK_TIME_NONE)) {
pos =
gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
- trans->segment.last_stop);
+ trans->segment.position);
} else {
pos = gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
- trans->priv->last_stop_out);
+ trans->priv->position_out);
}
gst_query_set_position (*query, format, pos);
} else {
trans->priv->dropped = 0;
GST_OBJECT_UNLOCK (trans);
/* we need new segment info after the flush. */
- trans->have_newsegment = FALSE;
+ trans->have_segment = FALSE;
gst_segment_init (&trans->segment, GST_FORMAT_UNDEFINED);
- trans->priv->last_stop_out = GST_CLOCK_TIME_NONE;
+ trans->priv->position_out = GST_CLOCK_TIME_NONE;
break;
case GST_EVENT_EOS:
break;
forward = FALSE;
break;
}
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
- gboolean update;
-
- gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
- &start, &stop, &time);
-
- trans->have_newsegment = TRUE;
-
- gst_segment_set_newsegment (&trans->segment, update, rate, arate,
- format, start, stop, time);
-
- if (format == GST_FORMAT_TIME) {
- GST_DEBUG_OBJECT (trans, "received TIME NEW_SEGMENT %" GST_TIME_FORMAT
- " -- %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT
- ", accum %" GST_TIME_FORMAT,
- GST_TIME_ARGS (trans->segment.start),
- GST_TIME_ARGS (trans->segment.stop),
- GST_TIME_ARGS (trans->segment.time),
- GST_TIME_ARGS (trans->segment.accum));
- } else {
- GST_DEBUG_OBJECT (trans, "received NEW_SEGMENT %" G_GINT64_FORMAT
- " -- %" G_GINT64_FORMAT ", time %" G_GINT64_FORMAT
- ", accum %" G_GINT64_FORMAT,
- trans->segment.start, trans->segment.stop,
- trans->segment.time, trans->segment.accum);
- }
+ gst_event_parse_segment (event, &trans->segment);
+ trans->have_segment = TRUE;
+
+ GST_DEBUG_OBJECT (trans, "received SEGMENT %" GST_SEGMENT_FORMAT,
+ &trans->segment);
break;
}
default:
GstBaseTransform *trans;
GstBaseTransformClass *klass;
GstFlowReturn ret;
- GstClockTime last_stop = GST_CLOCK_TIME_NONE;
+ GstClockTime position = GST_CLOCK_TIME_NONE;
GstClockTime timestamp, duration;
GstBuffer *outbuf = NULL;
/* calculate end position of the incoming buffer */
if (timestamp != GST_CLOCK_TIME_NONE) {
if (duration != GST_CLOCK_TIME_NONE)
- last_stop = timestamp + duration;
+ position = timestamp + duration;
else
- last_stop = timestamp;
+ position = timestamp;
}
klass = GST_BASE_TRANSFORM_GET_CLASS (trans);
* GST_BASE_TRANSFORM_FLOW_DROPPED we will not push either. */
if (outbuf != NULL) {
if ((ret == GST_FLOW_OK)) {
- GstClockTime last_stop_out = GST_CLOCK_TIME_NONE;
+ GstClockTime position_out = GST_CLOCK_TIME_NONE;
/* Remember last stop position */
- if (last_stop != GST_CLOCK_TIME_NONE &&
+ if (position != GST_CLOCK_TIME_NONE &&
trans->segment.format == GST_FORMAT_TIME)
- gst_segment_set_last_stop (&trans->segment, GST_FORMAT_TIME, last_stop);
+ trans->segment.position = position;
if (GST_BUFFER_TIMESTAMP_IS_VALID (outbuf)) {
- last_stop_out = GST_BUFFER_TIMESTAMP (outbuf);
+ position_out = GST_BUFFER_TIMESTAMP (outbuf);
if (GST_BUFFER_DURATION_IS_VALID (outbuf))
- last_stop_out += GST_BUFFER_DURATION (outbuf);
- } else if (last_stop != GST_CLOCK_TIME_NONE) {
- last_stop_out = last_stop;
+ position_out += GST_BUFFER_DURATION (outbuf);
+ } else if (position != GST_CLOCK_TIME_NONE) {
+ position_out = position;
}
- if (last_stop_out != GST_CLOCK_TIME_NONE
+ if (position_out != GST_CLOCK_TIME_NONE
&& trans->segment.format == GST_FORMAT_TIME)
- trans->priv->last_stop_out = last_stop_out;
+ trans->priv->position_out = position_out;
/* apply DISCONT flag if the buffer is not yet marked as such */
if (trans->priv->discont) {
trans->have_same_caps = trans->passthrough;
GST_DEBUG_OBJECT (trans, "have_same_caps %d", trans->have_same_caps);
trans->negotiated = FALSE;
- trans->have_newsegment = FALSE;
+ trans->have_segment = FALSE;
gst_segment_init (&trans->segment, GST_FORMAT_UNDEFINED);
- trans->priv->last_stop_out = GST_CLOCK_TIME_NONE;
+ trans->priv->position_out = GST_CLOCK_TIME_NONE;
trans->priv->proportion = 1.0;
trans->priv->earliest_time = -1;
trans->priv->discont = FALSE;
gboolean pending_configure;
gboolean negotiated;
- gboolean have_newsegment;
+ gboolean have_segment;
/* MT-protected (with STREAM_LOCK) */
GstSegment segment;
gst_event_unref (event);
goto done;
}
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- gint64 start, stop, time;
- gdouble rate, arate;
- GstFormat format;
- gboolean update;
-
- gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
- &start, &stop, &time);
-
- GST_DEBUG_OBJECT (data->pad, "got newsegment, start %" GST_TIME_FORMAT
- ", stop %" GST_TIME_FORMAT, GST_TIME_ARGS (start),
- GST_TIME_ARGS (stop));
-
- gst_segment_set_newsegment (&data->segment, update, rate, arate,
- format, start, stop, time);
+ gst_event_parse_segment (event, &data->segment);
+ GST_DEBUG_OBJECT (data->pad, "got newsegment %" GST_SEGMENT_FORMAT,
+ &data->segment);
data->abidata.ABI.new_segment = TRUE;
/* we must not forward this event since multiple segments will be
GstClockTime timestamp = GST_BUFFER_TIMESTAMP (data->buffer);
if (GST_CLOCK_TIME_IS_VALID (timestamp))
- gst_segment_set_last_stop (&data->segment, GST_FORMAT_TIME, timestamp);
+ data->segment.position = timestamp;
}
/* While we have data queued on this pad try to collect stuff */
struct _GstStreamConsistency
{
gboolean flushing;
- gboolean newsegment;
+ gboolean segment;
gboolean eos;
gulong probeid;
GstPad *pad;
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (GST_BUFFER (data))));
/* If an EOS went through, a buffer would be invalid */
fail_if (consist->eos, "Buffer received after EOS");
- /* Buffers need to be preceded by a newsegment event */
- fail_unless (consist->newsegment, "Buffer received without newsegment");
+ /* Buffers need to be preceded by a segment event */
+ fail_unless (consist->segment, "Buffer received without segment");
} else if (GST_IS_EVENT (data)) {
GstEvent *event = (GstEvent *) data;
fail_if (consist->eos, "Received a FLUSH_STOP after an EOS");
consist->flushing = FALSE;
break;
- case GST_EVENT_NEWSEGMENT:
- consist->newsegment = TRUE;
+ case GST_EVENT_SEGMENT:
+ consist->segment = TRUE;
consist->eos = FALSE;
break;
case GST_EVENT_EOS:
/* FIXME : not 100% sure about whether two eos in a row is valid */
fail_if (consist->eos, "Received EOS just after another EOS");
consist->eos = TRUE;
- consist->newsegment = FALSE;
+ consist->segment = FALSE;
break;
case GST_EVENT_TAG:
GST_DEBUG_OBJECT (pad, "tag %" GST_PTR_FORMAT,
default:
if (GST_EVENT_IS_SERIALIZED (event) && GST_EVENT_IS_DOWNSTREAM (event)) {
fail_if (consist->eos, "Event received after EOS");
- fail_unless (consist->newsegment, "Event received before newsegment");
+ fail_unless (consist->segment, "Event received before segment");
}
/* FIXME : Figure out what to do for other events */
break;
{
consist->eos = FALSE;
consist->flushing = FALSE;
- consist->newsegment = FALSE;
+ consist->segment = FALSE;
}
/**
case GST_EVENT_EOS:
case GST_EVENT_FLUSH_START:
case GST_EVENT_FLUSH_STOP:
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
event = gst_event_new_custom (type, NULL);
GST_EVENT_TIMESTAMP (event) = GST_DP_HEADER_TIMESTAMP (header);
break;
type = GST_EVENT_TYPE (event);
switch (type) {
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- gint64 start, stop, pos;
- GstFormat format;
- gst_event_parse_new_segment (event, NULL, NULL, NULL, &format, &start,
- &stop, &pos);
+ GstSegment segment;
- if (format == GST_FORMAT_BYTES) {
+ gst_event_parse_segment (event, &segment);
+
+ if (segment.format == GST_FORMAT_BYTES) {
/* only try to seek and fail when we are going to a different
* position */
- if (fdsink->current_pos != start) {
+ if (fdsink->current_pos != segment.start) {
/* FIXME, the seek should be performed on the pos field, start/stop are
* just boundaries for valid bytes offsets. We should also fill the file
* with zeroes if the new position extends the current EOF (sparse streams
* and segment accumulation). */
- if (!gst_fd_sink_do_seek (fdsink, (guint64) start))
+ if (!gst_fd_sink_do_seek (fdsink, (guint64) segment.start))
goto seek_failed;
}
} else {
GST_DEBUG_OBJECT (fdsink,
- "Ignored NEWSEGMENT event of format %u (%s)", (guint) format,
- gst_format_get_name (format));
+ "Ignored SEGMENT event of format %u (%s)", (guint) segment.format,
+ gst_format_get_name (segment.format));
}
break;
}
if (G_UNLIKELY (res < 0 || res != offset))
goto seek_failed;
- segment->last_stop = segment->start;
+ segment->position = segment->start;
segment->time = segment->start;
return TRUE;
type = GST_EVENT_TYPE (event);
switch (type) {
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- gint64 start, stop, pos;
- GstFormat format;
+ GstSegment segment;
- gst_event_parse_new_segment (event, NULL, NULL, NULL, &format, &start,
- &stop, &pos);
+ gst_event_parse_segment (event, &segment);
- if (format == GST_FORMAT_BYTES) {
+ if (segment.format == GST_FORMAT_BYTES) {
/* only try to seek and fail when we are going to a different
* position */
- if (filesink->current_pos != start) {
+ if (filesink->current_pos != segment.start) {
/* FIXME, the seek should be performed on the pos field, start/stop are
* just boundaries for valid bytes offsets. We should also fill the file
* with zeroes if the new position extends the current EOF (sparse streams
* and segment accumulation). */
- if (!gst_file_sink_do_seek (filesink, (guint64) start))
+ if (!gst_file_sink_do_seek (filesink, (guint64) segment.start))
goto seek_failed;
} else {
- GST_DEBUG_OBJECT (filesink, "Ignored NEWSEGMENT, no seek needed");
+ GST_DEBUG_OBJECT (filesink, "Ignored SEGMENT, no seek needed");
}
} else {
GST_DEBUG_OBJECT (filesink,
- "Ignored NEWSEGMENT event of format %u (%s)", (guint) format,
- gst_format_get_name (format));
+ "Ignored SEGMENT event of format %u (%s)", (guint) segment.format,
+ gst_format_get_name (segment.format));
}
break;
}
if (fpad->segment.format == GST_FORMAT_UNDEFINED) {
GST_WARNING_OBJECT (funnel, "Got buffer without segment,"
" setting segment [0,inf[");
- gst_segment_set_newsegment (&fpad->segment, FALSE, 1.0, 1.0,
- GST_FORMAT_TIME, 0, -1, 0);
+ gst_segment_init (&fpad->segment, GST_FORMAT_TIME);
}
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buffer)))
- gst_segment_set_last_stop (&fpad->segment, fpad->segment.format,
- GST_BUFFER_TIMESTAMP (buffer));
+ fpad->segment.position = GST_BUFFER_TIMESTAMP (buffer);
newts = gst_segment_to_running_time (&fpad->segment,
fpad->segment.format, GST_BUFFER_TIMESTAMP (buffer));
}
if (!funnel->has_segment) {
- event = gst_event_new_new_segment (FALSE, 1.0, 1.0, GST_FORMAT_TIME,
- 0, -1, 0);
+ GstSegment segment;
+
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ event = gst_event_new_segment (&segment);
funnel->has_segment = TRUE;
}
GST_OBJECT_UNLOCK (funnel);
}
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- gboolean update;
- gdouble rate, arate;
- GstFormat format;
- gint64 start;
- gint64 stop;
- gint64 time;
-
- gst_event_parse_new_segment (event, &update, &rate, &arate,
- &format, &start, &stop, &time);
-
GST_OBJECT_LOCK (funnel);
- gst_segment_set_newsegment (&fpad->segment, update, rate, arate,
- format, start, stop, time);
+ gst_event_parse_segment (event, &fpad->segment);
GST_OBJECT_UNLOCK (funnel);
forward = FALSE;
- }
break;
+ }
case GST_EVENT_FLUSH_STOP:
{
GST_OBJECT_LOCK (funnel);
gst_segment_init (&fpad->segment, GST_FORMAT_UNDEFINED);
funnel->has_segment = FALSE;
GST_OBJECT_UNLOCK (funnel);
- }
break;
+ }
default:
break;
}
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_SINGLE_SEGMENT,
g_param_spec_boolean ("single-segment", "Single Segment",
- "Timestamp buffers and eat newsegments so as to appear as one segment",
+ "Timestamp buffers and eat segments so as to appear as one segment",
DEFAULT_SINGLE_SEGMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
pspec_last_message = g_param_spec_string ("last-message", "last-message",
"last-message", NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
gst_identity_notify_last_message (identity);
}
- if (identity->single_segment
- && (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT)) {
- if (trans->have_newsegment == FALSE) {
+ if (identity->single_segment && (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT)) {
+ if (trans->have_segment == FALSE) {
GstEvent *news;
- GstFormat format;
+ GstSegment segment;
- gst_event_parse_new_segment (event, NULL, NULL, NULL, &format, NULL, NULL,
- NULL);
+ gst_event_parse_segment (event, &segment);
- /* This is the first newsegment, send out a (0, -1) newsegment */
- news = gst_event_new_new_segment (TRUE, 1.0, 1.0, format, 0, -1, 0);
+ /* This is the first segment, send out a (0, -1) segment */
+ gst_segment_init (&segment, segment.format);
+ news = gst_event_new_segment (&segment);
gst_pad_event_default (trans->sinkpad, news);
}
/* Reset previous timestamp, duration and offsets on NEWSEGMENT
* to prevent false warnings when checking for perfect streams */
- if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
+ if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
identity->prev_timestamp = identity->prev_duration = GST_CLOCK_TIME_NONE;
identity->prev_offset = identity->prev_offset_end = GST_BUFFER_OFFSET_NONE;
}
ret = GST_BASE_TRANSFORM_CLASS (parent_class)->event (trans, event);
- if (identity->single_segment
- && (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT)) {
+ if (identity->single_segment && (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT)) {
/* eat up segments */
ret = FALSE;
}
GST_OBJECT_LOCK (pad);
if (pad->active) {
- gint64 last_stop = pad->segment.last_stop;
+ gint64 position = pad->segment.position;
- if (last_stop >= 0)
+ if (position >= 0)
ret = gst_segment_to_running_time (&pad->segment, GST_FORMAT_TIME,
- last_stop);
+ position);
}
GST_OBJECT_UNLOCK (pad);
sel->pending_close = FALSE;
GST_INPUT_SELECTOR_UNLOCK (sel);
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- gboolean update;
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
-
- gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
- &start, &stop, &time);
-
- GST_DEBUG_OBJECT (pad,
- "configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
- "format %d, "
- "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
- G_GINT64_FORMAT, update, rate, arate, format, start, stop, time);
-
GST_INPUT_SELECTOR_LOCK (sel);
GST_OBJECT_LOCK (selpad);
- gst_segment_set_newsegment (&selpad->segment, update,
- rate, arate, format, start, stop, time);
+ gst_event_parse_segment (event, &selpad->segment);
+ GST_DEBUG_OBJECT (pad, "configured SEGMENT %" GST_SEGMENT_FORMAT,
+ &selpad->segment);
GST_OBJECT_UNLOCK (selpad);
/* If we aren't forwarding the event because the pad is not the
GstSelectorPad *selpad;
GstClockTime start_time;
GstSegment *seg;
- GstEvent *close_event = NULL, *start_event = NULL;
+ GstEvent *start_event = NULL;
#if 0
GstCaps *caps;
#endif
GST_TIME_ARGS (start_time + GST_BUFFER_DURATION (buf)));
GST_OBJECT_LOCK (pad);
- gst_segment_set_last_stop (seg, seg->format, start_time);
+ seg->position = start_time;
GST_OBJECT_UNLOCK (pad);
}
if (pad != active_sinkpad)
goto ignore;
- if (G_UNLIKELY (sel->pending_close)) {
- GstSegment *cseg = &sel->segment;
-
- GST_DEBUG_OBJECT (sel,
- "pushing close NEWSEGMENT update %d, rate %lf, applied rate %lf, "
- "format %d, "
- "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
- G_GINT64_FORMAT, TRUE, cseg->rate, cseg->applied_rate, cseg->format,
- cseg->start, cseg->stop, cseg->time);
-
- /* create update segment */
- close_event = gst_event_new_new_segment (TRUE, cseg->rate,
- cseg->applied_rate, cseg->format, cseg->start, cseg->stop, cseg->time);
-
- sel->pending_close = FALSE;
- }
/* if we have a pending segment, push it out now */
if (G_UNLIKELY (selpad->segment_pending)) {
GST_DEBUG_OBJECT (pad,
G_GINT64_FORMAT, FALSE, seg->rate, seg->applied_rate, seg->format,
seg->start, seg->stop, seg->time);
- start_event = gst_event_new_new_segment (FALSE, seg->rate,
- seg->applied_rate, seg->format, seg->start, seg->stop, seg->time);
+ start_event = gst_event_new_segment (seg);
selpad->segment_pending = FALSE;
}
NOTIFY_MUTEX_UNLOCK ();
}
- if (close_event)
- gst_pad_push_event (sel->srcpad, close_event);
-
if (start_event)
gst_pad_push_event (sel->srcpad, start_event);
static gint64
gst_segment_get_timestamp (GstSegment * segment, gint64 running_time)
{
- if (running_time <= segment->accum)
+ if (running_time <= segment->base)
return segment->start;
else
- return (running_time - segment->accum) * ABS (segment->rate) +
+ return (running_time - segment->base) * ABS (segment->rate) +
segment->start;
}
gst_segment_set_stop (GstSegment * segment, gint64 running_time)
{
segment->stop = gst_segment_get_timestamp (segment, running_time);
- segment->last_stop = -1;
+ segment->position = -1;
}
static void
/* this is the duration we skipped */
duration = new_start - segment->start;
/* add the duration to the accumulated segment time */
- segment->accum += duration;
+ segment->base += duration;
/* move position in the segment */
segment->time += duration;
segment->start += duration;
if (sq->sink_tainted) {
sink_time = sq->sinktime =
gst_segment_to_running_time (&sq->sink_segment, GST_FORMAT_TIME,
- sq->sink_segment.last_stop);
+ sq->sink_segment.position);
if (G_UNLIKELY (sink_time != GST_CLOCK_TIME_NONE))
/* if we have a time, we become untainted and use the time */
if (sq->src_tainted) {
src_time = sq->srctime =
gst_segment_to_running_time (&sq->src_segment, GST_FORMAT_TIME,
- sq->src_segment.last_stop);
+ sq->src_segment.position);
/* if we have a time, we become untainted and use the time */
if (G_UNLIKELY (src_time != GST_CLOCK_TIME_NONE))
sq->src_tainted = FALSE;
return;
}
-/* take a NEWSEGMENT event and apply the values to segment, updating the time
+/* take a SEGMENT event and apply the values to segment, updating the time
* level of queue. */
static void
apply_segment (GstMultiQueue * mq, GstSingleQueue * sq, GstEvent * event,
GstSegment * segment)
{
- gboolean update;
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
-
- gst_event_parse_new_segment (event, &update, &rate, &arate,
- &format, &start, &stop, &time);
+ gst_event_parse_segment (event, segment);
/* now configure the values, we use these to track timestamps on the
* sinkpad. */
- if (format != GST_FORMAT_TIME) {
+ if (segment->format != GST_FORMAT_TIME) {
/* non-time format, pretent the current time segment is closed with a
* 0 start and unknown stop time. */
- update = FALSE;
- format = GST_FORMAT_TIME;
- start = 0;
- stop = -1;
- time = 0;
+ segment->format = GST_FORMAT_TIME;
+ segment->start = 0;
+ segment->stop = -1;
+ segment->time = 0;
}
-
GST_MULTI_QUEUE_MUTEX_LOCK (mq);
- gst_segment_set_newsegment (segment, update,
- rate, arate, format, start, stop, time);
-
if (segment == &sq->sink_segment)
sq->sink_tainted = TRUE;
else
sq->src_tainted = TRUE;
GST_DEBUG_OBJECT (mq,
- "queue %d, configured NEWSEGMENT %" GST_SEGMENT_FORMAT, sq->id, segment);
+ "queue %d, configured SEGMENT %" GST_SEGMENT_FORMAT, sq->id, segment);
/* segment can update the time level of the queue */
update_time_level (mq, sq);
/* if no timestamp is set, assume it's continuous with the previous
* time */
if (timestamp == GST_CLOCK_TIME_NONE)
- timestamp = segment->last_stop;
+ timestamp = segment->position;
/* add duration */
if (duration != GST_CLOCK_TIME_NONE)
timestamp += duration;
- GST_DEBUG_OBJECT (mq, "queue %d, last_stop updated to %" GST_TIME_FORMAT,
+ GST_DEBUG_OBJECT (mq, "queue %d, position updated to %" GST_TIME_FORMAT,
sq->id, GST_TIME_ARGS (timestamp));
- gst_segment_set_last_stop (segment, GST_FORMAT_TIME, timestamp);
+ segment->position = timestamp;
if (segment == &sq->sink_segment)
sq->sink_tainted = TRUE;
case GST_EVENT_EOS:
result = GST_FLOW_UNEXPECTED;
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
apply_segment (mq, sq, event, &sq->src_segment);
/* Applying the segment may have made the queue non-full again, unblock it if needed */
gst_data_queue_limits_changed (sq->queue);
gst_single_queue_flush (mq, sq, FALSE);
goto done;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
/* take ref because the queue will take ownership and we need the event
* afterwards to update the segment */
sref = gst_event_ref (event);
update_buffering (mq, sq);
single_queue_overrun_cb (sq->queue, sq);
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
apply_segment (mq, sq, sref, &sq->sink_segment);
gst_event_unref (sref);
break;
osel->pending_srcpad = NULL;
GST_OBJECT_UNLOCK (GST_OBJECT (osel));
- /* Send NEWSEGMENT event and latest buffer if switching succeeded */
+ /* Send SEGMENT event and latest buffer if switching succeeded */
if (res) {
- /* Send NEWSEGMENT to the pad we are going to switch to */
+ /* Send SEGMENT to the pad we are going to switch to */
seg = &osel->segment;
- /* If resending then mark newsegment start and position accordingly */
+ /* If resending then mark segment start and position accordingly */
if (osel->resend_latest && osel->latest_buffer &&
GST_BUFFER_TIMESTAMP_IS_VALID (osel->latest_buffer)) {
start = position = GST_BUFFER_TIMESTAMP (osel->latest_buffer);
} else {
- start = position = seg->last_stop;
+ start = position = seg->position;
}
- ev = gst_event_new_new_segment (TRUE, seg->rate, seg->applied_rate,
- seg->format, start, seg->stop, position);
+
+ seg->start = start;
+ seg->position = position;
+ ev = gst_event_new_segment (seg);
+
if (!gst_pad_push_event (osel->active_srcpad, ev)) {
GST_WARNING_OBJECT (osel,
"newsegment handling failed in %" GST_PTR_FORMAT,
{
GstFlowReturn res;
GstOutputSelector *osel;
- GstClockTime last_stop, duration;
+ GstClockTime position, duration;
osel = GST_OUTPUT_SELECTOR (gst_pad_get_parent (pad));
/* Keep track of last stop and use it in NEWSEGMENT start after
switching to a new src pad */
- last_stop = GST_BUFFER_TIMESTAMP (buf);
- if (GST_CLOCK_TIME_IS_VALID (last_stop)) {
+ position = GST_BUFFER_TIMESTAMP (buf);
+ if (GST_CLOCK_TIME_IS_VALID (position)) {
duration = GST_BUFFER_DURATION (buf);
if (GST_CLOCK_TIME_IS_VALID (duration)) {
- last_stop += duration;
+ position += duration;
}
GST_LOG_OBJECT (osel, "setting last stop %" GST_TIME_FORMAT,
- GST_TIME_ARGS (last_stop));
- gst_segment_set_last_stop (&osel->segment, osel->segment.format, last_stop);
+ GST_TIME_ARGS (position));
+ osel->segment.position = position;
}
GST_LOG_OBJECT (osel, "pushing buffer to %" GST_PTR_FORMAT,
}
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
{
- gboolean update;
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
-
- gst_event_parse_new_segment (event, &update, &rate, &arate, &format,
- &start, &stop, &time);
-
- GST_DEBUG_OBJECT (sel,
- "configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
- "format %d, " "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
- G_GINT64_FORMAT, update, rate, arate, format, start, stop, time);
+ gst_event_parse_segment (event, &sel->segment);
- gst_segment_set_newsegment (&sel->segment, update,
- rate, arate, format, start, stop, time);
+ GST_DEBUG_OBJECT (sel, "configured SEGMENT update %" GST_SEGMENT_FORMAT,
+ &sel->segment);
/* Send newsegment to all src pads */
gst_pad_event_default (pad, event);
if (queue->sink_tainted) {
queue->sinktime =
gst_segment_to_running_time (&queue->sink_segment, GST_FORMAT_TIME,
- queue->sink_segment.last_stop);
+ queue->sink_segment.position);
queue->sink_tainted = FALSE;
}
sink_time = queue->sinktime;
if (queue->src_tainted) {
queue->srctime =
gst_segment_to_running_time (&queue->src_segment, GST_FORMAT_TIME,
- queue->src_segment.last_stop);
+ queue->src_segment.position);
queue->src_tainted = FALSE;
}
src_time = queue->srctime;
queue->cur_level.time = 0;
}
-/* take a NEWSEGMENT event and apply the values to segment, updating the time
+/* take a SEGMENT event and apply the values to segment, updating the time
* level of queue. */
static void
apply_segment (GstQueue * queue, GstEvent * event, GstSegment * segment,
gboolean sink)
{
- gboolean update;
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
-
- gst_event_parse_new_segment (event, &update, &rate, &arate,
- &format, &start, &stop, &time);
+ gst_event_parse_segment (event, segment);
/* now configure the values, we use these to track timestamps on the
* sinkpad. */
- if (format != GST_FORMAT_TIME) {
+ if (segment->format != GST_FORMAT_TIME) {
/* non-time format, pretent the current time segment is closed with a
* 0 start and unknown stop time. */
- update = FALSE;
- format = GST_FORMAT_TIME;
- start = 0;
- stop = -1;
- time = 0;
+ segment->format = GST_FORMAT_TIME;
+ segment->start = 0;
+ segment->stop = -1;
+ segment->time = 0;
}
- gst_segment_set_newsegment (segment, update,
- rate, arate, format, start, stop, time);
-
if (sink)
queue->sink_tainted = TRUE;
else
queue->src_tainted = TRUE;
- GST_DEBUG_OBJECT (queue,
- "configured NEWSEGMENT %" GST_SEGMENT_FORMAT, segment);
+ GST_DEBUG_OBJECT (queue, "configured SEGMENT %" GST_SEGMENT_FORMAT, segment);
/* segment can update the time level of the queue */
update_time_level (queue);
/* if no timestamp is set, assume it's continuous with the previous
* time */
if (timestamp == GST_CLOCK_TIME_NONE)
- timestamp = segment->last_stop;
+ timestamp = segment->position;
/* add duration */
if (with_duration && duration != GST_CLOCK_TIME_NONE)
timestamp += duration;
- GST_LOG_OBJECT (queue, "last_stop updated to %" GST_TIME_FORMAT,
+ GST_LOG_OBJECT (queue, "position updated to %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
- gst_segment_set_last_stop (segment, GST_FORMAT_TIME, timestamp);
+ segment->position = timestamp;
if (sink)
queue->sink_tainted = TRUE;
else
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "got EOS from upstream");
queue->eos = TRUE;
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
apply_segment (queue, event, &queue->sink_segment, TRUE);
/* if the queue is empty, apply sink segment on the source */
if (queue->queue->length == 0) {
/* queue is empty now that we dequeued the EOS */
GST_QUEUE_CLEAR_LEVEL (queue->cur_level);
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
/* apply newsegment if it has not already been applied */
if (G_LIKELY (!queue->newseg_applied_to_src)) {
apply_segment (queue, event, &queue->src_segment, FALSE);
static void
gst_queue_push_newsegment (GstQueue * queue)
{
- GstSegment *s;
GstEvent *event;
- s = &queue->src_segment;
-
- if (s->accum != 0) {
- event = gst_event_new_new_segment (FALSE, 1.0, 1.0, s->format, 0,
- s->accum, 0);
- GST_CAT_LOG_OBJECT (queue_dataflow, queue,
- "pushing accum newsegment event");
- gst_pad_push_event (queue->srcpad, event);
- }
-
- event = gst_event_new_new_segment (FALSE, s->rate, s->applied_rate,
- s->format, s->start, s->stop, s->time);
+ event = gst_event_new_segment (&queue->src_segment);
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "pushing real newsegment event");
gst_pad_push_event (queue->srcpad, event);
}
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
"got UNEXPECTED from downstream");
/* stop pushing buffers, we dequeue all items until we see an item that we
- * can push again, which is EOS or NEWSEGMENT. If there is nothing in the
+ * can push again, which is EOS or SEGMENT. If there is nothing in the
* queue we can push, we set a flag to make the sinkpad refuse more
* buffers with an UNEXPECTED return value. */
while ((data = gst_queue_locked_dequeue (queue, &is_buffer))) {
GstEvent *event = GST_EVENT_CAST (data);
GstEventType type = GST_EVENT_TYPE (event);
- if (type == GST_EVENT_EOS || type == GST_EVENT_NEWSEGMENT) {
+ if (type == GST_EVENT_EOS || type == GST_EVENT_SEGMENT) {
/* we found a pushable item in the queue, push it out */
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
"pushing pushable event %s after UNEXPECTED",
}
/* no more items in the queue. Set the unexpected flag so that upstream
* make us refuse any more buffers on the sinkpad. Since we will still
- * accept EOS and NEWSEGMENT we return _FLOW_OK to the caller so that the
+ * accept EOS and SEGMENT we return _FLOW_OK to the caller so that the
* task function does not shut down. */
queue->unexpected = TRUE;
result = GST_FLOW_OK;
GST_QUEUE_MUTEX_UNLOCK (queue);
- if (queue->push_newsegment && type != GST_EVENT_NEWSEGMENT) {
+ if (queue->push_newsegment && type != GST_EVENT_SEGMENT) {
gst_queue_push_newsegment (queue);
}
gst_pad_push_event (queue->srcpad, event);
if (queue->sink_tainted) {
queue->sinktime =
gst_segment_to_running_time (&queue->sink_segment, GST_FORMAT_TIME,
- queue->sink_segment.last_stop);
+ queue->sink_segment.position);
queue->sink_tainted = FALSE;
}
if (queue->src_tainted) {
queue->srctime =
gst_segment_to_running_time (&queue->src_segment, GST_FORMAT_TIME,
- queue->src_segment.last_stop);
+ queue->src_segment.position);
queue->src_tainted = FALSE;
}
queue->cur_level.time = 0;
}
-/* take a NEWSEGMENT event and apply the values to segment, updating the time
+/* take a SEGMENT event and apply the values to segment, updating the time
* level of queue. */
static void
apply_segment (GstQueue2 * queue, GstEvent * event, GstSegment * segment,
gboolean is_sink)
{
- gboolean update;
- GstFormat format;
- gdouble rate, arate;
- gint64 start, stop, time;
+ gst_event_parse_segment (event, segment);
- gst_event_parse_new_segment (event, &update, &rate, &arate,
- &format, &start, &stop, &time);
-
- GST_DEBUG_OBJECT (queue,
- "received NEWSEGMENT update %d, rate %lf, applied rate %lf, "
- "format %d, "
- "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
- G_GINT64_FORMAT, update, rate, arate, format, start, stop, time);
-
- if (format == GST_FORMAT_BYTES) {
+ if (segment->format == GST_FORMAT_BYTES) {
if (QUEUE_IS_USING_TEMP_FILE (queue)) {
/* start is where we'll be getting from and as such writing next */
- queue->current = add_range (queue, start);
+ queue->current = add_range (queue, segment->start);
/* update the stats for this range */
update_cur_level (queue, queue->current);
}
/* now configure the values, we use these to track timestamps on the
* sinkpad. */
- if (format != GST_FORMAT_TIME) {
+ if (segment->format != GST_FORMAT_TIME) {
/* non-time format, pretent the current time segment is closed with a
* 0 start and unknown stop time. */
- update = FALSE;
- format = GST_FORMAT_TIME;
- start = 0;
- stop = -1;
- time = 0;
+ segment->format = GST_FORMAT_TIME;
+ segment->start = 0;
+ segment->stop = -1;
+ segment->time = 0;
}
- gst_segment_set_newsegment (segment, update,
- rate, arate, format, start, stop, time);
- GST_DEBUG_OBJECT (queue,
- "configured NEWSEGMENT %" GST_SEGMENT_FORMAT, segment);
+ GST_DEBUG_OBJECT (queue, "configured SEGMENT %" GST_SEGMENT_FORMAT, segment);
if (is_sink)
queue->sink_tainted = TRUE;
/* if no timestamp is set, assume it's continuous with the previous
* time */
if (timestamp == GST_CLOCK_TIME_NONE)
- timestamp = segment->last_stop;
+ timestamp = segment->position;
/* add duration */
if (duration != GST_CLOCK_TIME_NONE)
timestamp += duration;
- GST_DEBUG_OBJECT (queue, "last_stop updated to %" GST_TIME_FORMAT,
+ GST_DEBUG_OBJECT (queue, "position updated to %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
- gst_segment_set_last_stop (segment, GST_FORMAT_TIME, timestamp);
+ segment->position = timestamp;
if (is_sink)
queue->sink_tainted = TRUE;
GST_DEBUG_OBJECT (queue, "we have EOS");
queue->is_eos = TRUE;
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
apply_segment (queue, event, &queue->sink_segment, TRUE);
/* This is our first new segment, we hold it
* as we can't save it on the temp file */
/* queue is empty now that we dequeued the EOS */
GST_QUEUE2_CLEAR_LEVEL (queue->cur_level);
break;
- case GST_EVENT_NEWSEGMENT:
+ case GST_EVENT_SEGMENT:
apply_segment (queue, event, &queue->src_segment, FALSE);
break;
default:
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
"got UNEXPECTED from downstream");
/* stop pushing buffers, we dequeue all items until we see an item that we
- * can push again, which is EOS or NEWSEGMENT. If there is nothing in the
+ * can push again, which is EOS or SEGMENT. If there is nothing in the
* queue we can push, we set a flag to make the sinkpad refuse more
* buffers with an UNEXPECTED return value until we receive something
* pushable again or we get flushed. */
GstEvent *event = GST_EVENT_CAST (data);
GstEventType type = GST_EVENT_TYPE (event);
- if (type == GST_EVENT_EOS || type == GST_EVENT_NEWSEGMENT) {
+ if (type == GST_EVENT_EOS || type == GST_EVENT_SEGMENT) {
/* we found a pushable item in the queue, push it out */
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
"pushing pushable event %s after UNEXPECTED",
}
/* no more items in the queue. Set the unexpected flag so that upstream
* make us refuse any more buffers on the sinkpad. Since we will still
- * accept EOS and NEWSEGMENT we return _FLOW_OK to the caller so that the
+ * accept EOS and SEGMENT we return _FLOW_OK to the caller so that the
* task function does not shut down. */
queue->unexpected = TRUE;
result = GST_FLOW_OK;
/* send segment */
{
- GstEvent *segment;
+ GstEvent *event;
+ GstSegment segment;
gboolean eret;
GST_DEBUG ("sending segment");
- segment = gst_event_new_new_segment (FALSE,
- 1.0, 1.0, GST_FORMAT_TIME, 1 * GST_SECOND, 5 * GST_SECOND,
- 1 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 1 * GST_SECOND;
+ segment.stop = 5 * GST_SECOND;
+ segment.time = 1 * GST_SECOND;
+
+ event = gst_event_new_segment (&segment);
- eret = gst_pad_send_event (sinkpad, segment);
+ eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == FALSE);
}
/* send segment */
{
- GstEvent *segment;
+ GstEvent *event;
+ GstSegment segment;
gboolean eret;
GST_DEBUG ("sending segment");
- segment = gst_event_new_new_segment (FALSE,
- 1.0, 1.0, GST_FORMAT_TIME, 0 * GST_SECOND, 102 * GST_SECOND,
- 0 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 0 * GST_SECOND;
+ segment.stop = 102 * GST_SECOND;
+ segment.time = 0 * GST_SECOND;
- eret = gst_pad_send_event (sinkpad, segment);
+ event = gst_event_new_segment (&segment);
+ eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == FALSE);
}
/* send segment, this should fail */
{
- GstEvent *segment;
+ GstEvent *event;
+ GstSegment segment;
gboolean eret;
GST_DEBUG ("sending segment");
- segment = gst_event_new_new_segment (FALSE,
- 1.0, 1.0, GST_FORMAT_TIME, 0 * GST_SECOND, 2 * GST_SECOND,
- 0 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 0 * GST_SECOND;
+ segment.stop = 2 * GST_SECOND;
+ segment.time = 0 * GST_SECOND;
+ event = gst_event_new_segment (&segment);
- eret = gst_pad_send_event (sinkpad, segment);
+ eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == TRUE);
}
/* send segment, this should now work again */
{
- GstEvent *segment;
+ GstEvent *event;
+ GstSegment segment;
gboolean eret;
GST_DEBUG ("sending segment");
- segment = gst_event_new_new_segment (FALSE,
- 1.0, 1.0, GST_FORMAT_TIME, 0 * GST_SECOND, 2 * GST_SECOND,
- 0 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 0 * GST_SECOND;
+ segment.stop = 2 * GST_SECOND;
+ segment.time = 0 * GST_SECOND;
+ event = gst_event_new_segment (&segment);
- eret = gst_pad_send_event (sinkpad, segment);
+ eret = gst_pad_send_event (sinkpad, event);
fail_unless (eret == TRUE);
}
/* send segment, this should work */
{
- GstEvent *segment;
+ GstEvent *event;
+ GstSegment segment;
gboolean eret;
GST_DEBUG ("sending segment");
- segment = gst_event_new_new_segment (FALSE,
- 1.0, 1.0, GST_FORMAT_TIME, 0 * GST_SECOND, 2 * GST_SECOND,
- 0 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 0 * GST_SECOND;
+ segment.stop = 2 * GST_SECOND;
+ segment.time = 0 * GST_SECOND;
+ event = gst_event_new_segment (&segment);
- eret = gst_pad_send_event (sinkpad, segment);
+ eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == FALSE);
}
/* send segment, this should work */
{
+ GstSegment segment;
+
GST_DEBUG ("sending segment");
- event = gst_event_new_new_segment (FALSE,
- 1.0, 1.0, GST_FORMAT_TIME, 1 * GST_SECOND, 3 * GST_SECOND,
- 1 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 1 * GST_SECOND;
+ segment.stop = 3 * GST_SECOND;
+ segment.time = 1 * GST_SECOND;
+ event = gst_event_new_segment (&segment);
eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == FALSE);
/* send segment, this should work */
{
+ GstSegment segment;
+
GST_DEBUG ("sending segment");
- event = gst_event_new_new_segment (FALSE,
- 1.0, 1.0, GST_FORMAT_TIME, 2 * GST_SECOND, 4 * GST_SECOND,
- 1 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 2 * GST_SECOND;
+ segment.stop = 4 * GST_SECOND;
+ segment.time = 1 * GST_SECOND;
+ event = gst_event_new_segment (&segment);
eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == FALSE);
/* send segment, this should work */
{
+ GstSegment segment;
+
GST_DEBUG ("sending segment");
- event = gst_event_new_new_segment (FALSE,
- 1.0, 1.0, GST_FORMAT_TIME, 2 * GST_SECOND, 4 * GST_SECOND,
- 1 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 2 * GST_SECOND;
+ segment.stop = 4 * GST_SECOND;
+ segment.time = 1 * GST_SECOND;
+ event = gst_event_new_segment (&segment);
eret = gst_pad_send_event (sinkpad, event);
fail_if (eret == FALSE);
GstElement *filesink;
gchar *tmp_fn;
gint fd;
+ GstSegment segment;
tmpdir = g_get_tmp_dir ();
if (tmpdir == NULL)
gst_query_unref (seeking_query);
#endif
- fail_unless (gst_pad_push_event (mysrcpad,
- gst_event_new_new_segment (FALSE, 1.0, 1.0, GST_FORMAT_BYTES, 0, -1,
- 0)));
+ gst_segment_init (&segment, GST_FORMAT_BYTES);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
CHECK_QUERY_POSITION (filesink, GST_FORMAT_BYTES, 0);
PUSH_BYTES (8800);
CHECK_QUERY_POSITION (filesink, GST_FORMAT_BYTES, 8900);
- if (gst_pad_push_event (mysrcpad,
- gst_event_new_new_segment (TRUE, 1.0, 1.0, GST_FORMAT_BYTES, 8800, -1,
- 0))) {
+ segment.start = 8800;
+ if (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment))) {
GST_LOG ("seek ok");
/* make sure that that new position is reported immediately */
CHECK_QUERY_POSITION (filesink, GST_FORMAT_BYTES, 8800);
GCond *cond;
gint i;
const gint NBUFFERS = 100;
+ GstSegment segment;
mutex = g_mutex_new ();
cond = g_cond_new ();
gst_element_set_state (pipe, GST_STATE_PLAYING);
/* Push 2 new segment events */
- event =
- gst_event_new_new_segment (FALSE, 1.0, 1.0, GST_FORMAT_TIME, 0, -1, 0);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ event = gst_event_new_segment (&segment);
gst_pad_push_event (inputpads[0], gst_event_ref (event));
gst_pad_push_event (inputpads[1], event);
g_static_mutex_unlock (&_check_lock);
/* Push a new segment update on the 2nd pad */
- event =
- gst_event_new_new_segment (TRUE, 1.0, 1.0, GST_FORMAT_TIME, ts, -1, ts);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = ts;
+ segment.time = ts;
+ event = gst_event_new_segment (&segment);
gst_pad_push_event (inputpads[1], event);
}
{
GstEvent *event;
GstClockTime time;
+ GstSegment segment;
GST_DEBUG ("starting");
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- event = gst_event_new_new_segment (TRUE, 1.0, 1.0, GST_FORMAT_TIME,
- 1 * GST_SECOND, 5 * GST_SECOND, 0);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.start = 1 * GST_SECOND;
+ segment.stop = 5 * GST_SECOND;
+ segment.time = 0;
+
+ event = gst_event_new_segment (&segment);
gst_pad_push_event (mysrcpad, event);
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
fail_if (time != 0 * GST_SECOND);
- event = gst_event_new_new_segment (FALSE, 1.0, 1.0, GST_FORMAT_TIME,
- 1 * GST_SECOND, 5 * GST_SECOND, 0);
+ segment.base = 4 * GST_SECOND;
+ event = gst_event_new_segment (&segment);
gst_pad_push_event (mysrcpad, event);
g_object_get (G_OBJECT (queue), "current-level-time", &time, NULL);
GST_END_TEST;
+#if 0
static gboolean
event_equals_newsegment (GstEvent * event, gboolean update, gdouble rate,
GstFormat format, gint64 start, gint64 stop, gint64 position)
gint64 ns_stop;
gint64 ns_position;
- if (GST_EVENT_TYPE (event) != GST_EVENT_NEWSEGMENT) {
+ if (GST_EVENT_TYPE (event) != GST_EVENT_SEGMENT) {
return FALSE;
}
}
GST_END_TEST;
+#endif
static Suite *
queue_suite (void)
tcase_add_test (tc_chain, test_leaky_downstream);
tcase_add_test (tc_chain, test_time_level);
tcase_add_test (tc_chain, test_time_level_task_not_started);
+#if 0
tcase_add_test (tc_chain, test_newsegment);
+#endif
return s;
}
GstFormat format;
gint64 position;
gboolean qret;
+ GstSegment segment;
sink = gst_element_factory_make ("fakesink", "sink");
g_object_set (G_OBJECT (sink), "sync", TRUE, NULL);
/* make newsegment, this sets the position to 10sec when the buffer prerolls */
GST_DEBUG ("sending segment");
- event =
- gst_event_new_new_segment (FALSE, 1.0, 1.0, GST_FORMAT_TIME, 0, -1,
- 10 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.time = 10 * GST_SECOND;
+
+ event = gst_event_new_segment (&segment);
res = gst_pad_send_event (sinkpad, event);
/* We have not yet received any buffers so we are still in the READY state,
GstFormat format;
gint64 position;
gboolean qret;
+ GstSegment segment;
sink = gst_element_factory_make ("fakesink", "sink");
g_object_set (G_OBJECT (sink), "sync", TRUE, NULL);
/* make newsegment, this sets the position to 10sec when the buffer prerolls */
GST_DEBUG ("sending segment");
- event =
- gst_event_new_new_segment (FALSE, 1.0, 1.0, GST_FORMAT_TIME, 0, -1,
- 10 * GST_SECOND);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.time = 10 * GST_SECOND;
+ event = gst_event_new_segment (&segment);
res = gst_pad_send_event (sinkpad, event);
/* We have not yet received any buffers so we are still in the READY state,
fail_unless (GST_EVENT_IS_SERIALIZED (event));
gst_event_unref (event);
}
- /* NEWSEGMENT */
+ /* SEGMENT */
{
- gdouble rate, applied_rate;
- GstFormat format;
- gint64 start, end, base;
- gboolean update;
-
- event =
- gst_event_new_new_segment (FALSE, 0.5, 1.0, GST_FORMAT_TIME, 1,
- G_MAXINT64, 0xdeadbeef);
- fail_if (event == NULL);
- fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT);
- fail_if (GST_EVENT_IS_UPSTREAM (event));
- fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
- fail_unless (GST_EVENT_IS_SERIALIZED (event));
-
- gst_event_parse_new_segment (event, &update, &rate, &applied_rate, &format,
- &start, &end, &base);
- fail_unless (update == FALSE);
- fail_unless (rate == 0.5);
- fail_unless (applied_rate == 1.0);
- fail_unless (format == GST_FORMAT_TIME);
- fail_unless (start == 1);
- fail_unless (end == G_MAXINT64);
- fail_unless (base == 0xdeadbeef);
+ GstSegment segment, parsed;
- /* Check that the new segment was created with applied_rate of 1.0 */
- gst_event_parse_new_segment (event, &update, &rate, &applied_rate,
- &format, &start, &end, &base);
-
- fail_unless (update == FALSE);
- fail_unless (rate == 0.5);
- fail_unless (applied_rate == 1.0);
- fail_unless (format == GST_FORMAT_TIME);
- fail_unless (start == 1);
- fail_unless (end == G_MAXINT64);
-
- gst_event_unref (event);
-
- event =
- gst_event_new_new_segment (TRUE, 0.75, 0.5, GST_FORMAT_BYTES, 0,
- G_MAXINT64 - 1, 0xdeadbeef);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ segment.rate = 0.5;
+ segment.applied_rate = 1.0;
+ segment.start = 1;
+ segment.stop = G_MAXINT64;
+ segment.time = 0xdeadbeef;
+ event = gst_event_new_segment (&segment);
fail_if (event == NULL);
- fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT);
+ fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
fail_if (GST_EVENT_IS_UPSTREAM (event));
fail_unless (GST_EVENT_IS_DOWNSTREAM (event));
fail_unless (GST_EVENT_IS_SERIALIZED (event));
- gst_event_parse_new_segment (event, &update, &rate, &applied_rate,
- &format, &start, &end, &base);
-
- fail_unless (update == TRUE);
- fail_unless (rate == 0.75);
- fail_unless (applied_rate == 0.5);
- fail_unless (format == GST_FORMAT_BYTES);
- fail_unless (start == 0);
- fail_unless (end == (G_MAXINT64 - 1));
+ gst_event_parse_segment (event, &parsed);
+ fail_unless (parsed.rate == 0.5);
+ fail_unless (parsed.applied_rate == 1.0);
+ fail_unless (parsed.format == GST_FORMAT_TIME);
+ fail_unless (parsed.start == 1);
+ fail_unless (parsed.stop == G_MAXINT64);
+ fail_unless (parsed.time == 0xdeadbeef);
gst_event_unref (event);
}
gst_segment_init (&segment, GST_FORMAT_TIME);
- gst_segment_set_newsegment (&segment, FALSE, 1.0, 2.0,
- GST_FORMAT_TIME, 0, 5 * 60 * GST_SECOND, 0);
+ segment.rate = 1.0;
+ segment.applied_rate = 2.0;
+ segment.start = 0;
+ segment.stop = 5 * 60 * GST_SECOND;
+ segment.time = 0;
- segment.last_stop = 2 * GST_SECOND;
+ segment.position = 2 * GST_SECOND;
segment.duration = 90 * 60 * GST_SECOND;
GST_LOG ("TIME: %" GST_SEGMENT_FORMAT, &segment);
gst_segment_init (&segment, GST_FORMAT_BYTES);
- gst_segment_set_newsegment (&segment, FALSE, 1.0, 1.0,
- GST_FORMAT_BYTES, 0, 9999999, 0);
+ segment.rate = 1.0;
+ segment.applied_rate = 1.0;
+ segment.start = 0;
+ segment.stop = 9999999;
+ segment.time = 0;
GST_LOG ("BYTE: %" GST_SEGMENT_FORMAT, &segment);
}
gst_segment_init (&segment, 98765432);
- gst_segment_set_newsegment (&segment, FALSE, 1.0, 1.0,
- GST_FORMAT_BYTES, 0, 987654321, 0);
+ segment.rate = 1.0;
+ segment.applied_rate = 1.0;
+ segment.start = 0;
+ segment.stop = 987654321;
+ segment.time = 0;
GST_LOG ("UNKNOWN: %" GST_SEGMENT_FORMAT, &segment);
}
{
GstSegment segment;
gboolean res;
- gint64 cstart, cstop;
+ guint64 cstart, cstop;
gboolean update;
gst_segment_init (&segment, GST_FORMAT_BYTES);
/* configure segment to start 100 */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 100, GST_SEEK_TYPE_NONE, -1, &update);
/* configure segment to stop relative, should not do anything since
* size is unknown. */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, 200, GST_SEEK_TYPE_CUR, -100, &update);
fail_unless (cstop == -1);
/* add 100 to start, set stop to 300 */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_CUR, 100, GST_SEEK_TYPE_SET, 300, &update);
fail_unless (update == TRUE);
update = FALSE;
- /* add 100 to start (to 300), set stop to 200, this is not allowed.
+ /* add 100 to start (to 300), set stop to 200, this is not allowed.
* nothing should be updated in the segment. A g_warning is
* emited. */
- ASSERT_CRITICAL (gst_segment_set_seek (&segment, 1.0,
+ ASSERT_CRITICAL (gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_CUR, 100, GST_SEEK_TYPE_SET, 200, &update));
update = TRUE;
/* seek relative to end, should not do anything since size is
* unknown. */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_END, -300, GST_SEEK_TYPE_END, -100, &update);
{
GstSegment segment;
gboolean res;
- gint64 cstart, cstop;
+ guint64 cstart, cstop;
gboolean update;
gst_segment_init (&segment, GST_FORMAT_BYTES);
- gst_segment_set_duration (&segment, GST_FORMAT_BYTES, 200);
+ segment.duration = 200;
/* configure segment to start 100 */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 100, GST_SEEK_TYPE_NONE, -1, &update);
/* configure segment to stop relative, does not update stop
* since we did not set it before. */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, 200, GST_SEEK_TYPE_CUR, -100, &update);
fail_unless (cstop == -1);
/* add 100 to start, set stop to 300, stop clips to 200 */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_CUR, 100, GST_SEEK_TYPE_SET, 300, &update);
/* add 100 to start (to 300), set stop to 200, this clips start
* to duration */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_CUR, 100, GST_SEEK_TYPE_SET, 200, &update);
fail_unless (update == FALSE);
/* seek relative to end */
- gst_segment_set_seek (&segment, 1.0,
+ gst_segment_do_seek (&segment, 1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_END, -100, GST_SEEK_TYPE_END, -20, &update);
gboolean update;
gst_segment_init (&segment, GST_FORMAT_BYTES);
- gst_segment_set_duration (&segment, GST_FORMAT_BYTES, 200);
+ segment.duration = 200;
/* configure segment to stop 100 */
- gst_segment_set_seek (&segment, -1.0,
+ gst_segment_do_seek (&segment, -1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, 100, &update);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 100);
fail_unless (segment.time == 0);
- fail_unless (segment.last_stop == 100);
+ fail_unless (segment.position == 100);
fail_unless (update == TRUE);
/* update */
- gst_segment_set_seek (&segment, -1.0,
+ gst_segment_do_seek (&segment, -1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 10, GST_SEEK_TYPE_CUR, -20, &update);
fail_unless (segment.start == 10);
fail_unless (segment.stop == 80);
fail_unless (segment.time == 10);
- fail_unless (segment.last_stop == 80);
+ fail_unless (segment.position == 80);
fail_unless (update == TRUE);
- gst_segment_set_seek (&segment, -1.0,
+ gst_segment_do_seek (&segment, -1.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 20, GST_SEEK_TYPE_NONE, 0, &update);
fail_unless (segment.start == 20);
fail_unless (segment.stop == 80);
fail_unless (segment.time == 20);
- fail_unless (segment.last_stop == 80);
+ fail_unless (segment.position == 80);
fail_unless (update == FALSE);
}
/* configure segment to rate 2.0, format does not matter when we don't specify
* a start or stop position. */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_UNDEFINED,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_NONE, -1, &update);
fail_unless (update == FALSE);
/* 0 is the same in all formats and should not fail */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, -1, &update);
fail_unless (segment.format == GST_FORMAT_BYTES);
/* set to -1 means start from 0 */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_SET, -1, GST_SEEK_TYPE_NONE, -1, &update);
fail_unless (segment.format == GST_FORMAT_BYTES);
fail_unless (segment.start == 0);
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_CUR, 0, GST_SEEK_TYPE_NONE, -1, &update);
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_END, 0, GST_SEEK_TYPE_NONE, -1, &update);
/* -1 for end is fine too in all formats */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_SET, -1, &update);
/* 0 as relative end is fine too */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_CUR, 0, &update);
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 0, &update);
/* set a real stop position, this must happen in bytes */
- gst_segment_set_seek (&segment, 3.0,
+ gst_segment_do_seek (&segment, 3.0,
GST_FORMAT_BYTES,
GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_SET, 100, &update);
fail_unless (update == FALSE);
/* 0 as relative end is fine too */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_CUR, 0, &update);
fail_unless (segment.stop == 100);
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 0, &update);
fail_unless (segment.stop == 100);
/* -1 for end is fine too in all formats */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_SET, -1, &update);
fail_unless (segment.stop == -1);
/* set some duration, stop -1 END seeks will now work with the
* duration, if the formats match */
- gst_segment_set_duration (&segment, GST_FORMAT_BYTES, 200);
+ segment.duration = 200;
fail_unless (segment.duration == 200);
/* seek to end in any format with 0 should set the stop to the
* duration */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 0, &update);
fail_unless (segment.stop == 200);
fail_unless (segment.duration == 200);
/* subtract 100 from the end */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, -100, &update);
fail_unless (segment.stop == 100);
fail_unless (segment.duration == 200);
/* add 100 to the duration, this should be clamped to the duration */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_END, 100, &update);
fail_unless (segment.stop == 200);
fail_unless (segment.duration == 200);
/* add 300 to the start, this should be clamped to the duration */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_CUR, 300, GST_SEEK_TYPE_END, 0, &update);
fail_unless (segment.start == 200);
fail_unless (segment.duration == 200);
/* subtract 300 from the start, this should be clamped to 0 */
- gst_segment_set_seek (&segment, 2.0,
+ gst_segment_do_seek (&segment, 2.0,
GST_FORMAT_BYTES, GST_SEEK_FLAG_NONE,
GST_SEEK_TYPE_CUR, -300, GST_SEEK_TYPE_END, 0, &update);
fail_unless (segment.start == 0);
GST_END_TEST;
+#if 0
/* mess with the segment structure in the bytes format */
GST_START_TEST (segment_newsegment_open)
{
fail_unless (segment.start == 0);
fail_unless (segment.stop == -1);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* we set stop but in the wrong format, stop stays open. */
fail_unless (segment.start == 0);
fail_unless (segment.stop == -1);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
/* update, nothing changes */
gst_segment_set_newsegment (&segment, TRUE, 1.0, 1.0, GST_FORMAT_BYTES, 0, -1,
fail_unless (segment.start == 0);
fail_unless (segment.stop == -1);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
/* update */
gst_segment_set_newsegment (&segment, TRUE, 1.0, 1.0,
fail_unless (segment.start == 100);
fail_unless (segment.stop == -1);
fail_unless (segment.time == 100);
- fail_unless (segment.accum == 100);
- fail_unless (segment.last_stop == 100);
+ fail_unless (segment.base == 100);
+ fail_unless (segment.position == 100);
- /* last_stop 0, accum does not change */
+ /* last_stop 0, base does not change */
gst_segment_set_newsegment (&segment, FALSE, 1.0, 1.0, GST_FORMAT_BYTES, 0,
-1, 0);
fail_unless (segment.start == 0);
fail_unless (segment.stop == -1);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 100);
+ fail_unless (segment.base == 100);
gst_segment_set_last_stop (&segment, GST_FORMAT_BYTES, 200);
- fail_unless (segment.last_stop == 200);
+ fail_unless (segment.position == 200);
- /* last_stop 200, accum changes */
+ /* last_stop 200, base changes */
gst_segment_set_newsegment (&segment, FALSE, 1.0, 1.0, GST_FORMAT_BYTES, 0,
-1, 0);
fail_unless (segment.start == 0);
fail_unless (segment.stop == -1);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 300);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 300);
+ fail_unless (segment.position == 0);
}
GST_END_TEST;
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* assume we advanced to position 40 */
gst_segment_set_last_stop (&segment, GST_FORMAT_BYTES, 40);
- fail_unless (segment.last_stop == 40);
+ fail_unless (segment.position == 40);
/* do an update to the start, last_stop is unchanged because it's bigger */
gst_segment_set_newsegment (&segment, TRUE, 1.0, 1.0, GST_FORMAT_BYTES, 20,
fail_unless (segment.start == 20);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 20);
- fail_unless (segment.accum == 20);
- fail_unless (segment.last_stop == 40);
+ fail_unless (segment.base == 20);
+ fail_unless (segment.position == 40);
/* do an update past our last_stop, it should be updated now */
gst_segment_set_newsegment (&segment, TRUE, 1.0, 1.0, GST_FORMAT_BYTES, 50,
fail_unless (segment.start == 50);
fail_unless (segment.stop == 300);
fail_unless (segment.time == 50);
- fail_unless (segment.accum == 50);
- fail_unless (segment.last_stop == 50);
+ fail_unless (segment.base == 50);
+ fail_unless (segment.position == 50);
/* and a new accumulated one */
gst_segment_set_newsegment (&segment, FALSE, 1.0, 1.0,
fail_unless (segment.start == 100);
fail_unless (segment.stop == 400);
fail_unless (segment.time == 300);
- fail_unless (segment.accum == 300);
+ fail_unless (segment.base == 300);
/* and a new updated one */
gst_segment_set_newsegment (&segment, TRUE, 1.0, 1.0,
fail_unless (segment.start == 100);
fail_unless (segment.stop == 500);
fail_unless (segment.time == 300);
- fail_unless (segment.accum == 300);
+ fail_unless (segment.base == 300);
/* and a new partially updated one */
gst_segment_set_newsegment (&segment, TRUE, 1.0, 1.0,
fail_unless (segment.start == 200);
fail_unless (segment.stop == 500);
fail_unless (segment.time == 400);
- fail_unless (segment.accum == 400);
+ fail_unless (segment.base == 400);
}
GST_END_TEST;
GST_START_TEST (segment_newsegment_streamtime)
{
GstSegment segment;
- gint64 result;
+ guint64 result;
gst_segment_init (&segment, GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
gst_segment_set_newsegment (&segment, FALSE, 1.0, 1.0,
GST_FORMAT_TIME, 0, 200, 500);
- fail_unless (segment.accum == 200);
+ fail_unless (segment.base == 200);
/* invalid time gives invalid result */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1);
gst_segment_set_newsegment (&segment, FALSE, 1.0, 1.0,
GST_FORMAT_TIME, 500, 700, 0);
- fail_unless (segment.accum == 400);
+ fail_unless (segment.base == 400);
/* invalid time gives invalid result */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1);
gst_segment_set_newsegment (&segment, FALSE, 1.0, 1.0,
GST_FORMAT_TIME, 500, 700, 200);
- fail_unless (segment.accum == 600);
+ fail_unless (segment.base == 600);
/* invalid time gives invalid result */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1);
GST_START_TEST (segment_newsegment_streamtime_rate)
{
GstSegment segment;
- gint64 result;
+ guint64 result;
gst_segment_init (&segment, GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
gst_segment_set_newsegment (&segment, FALSE, 2.0, 1.0,
GST_FORMAT_TIME, 100, 300, 0);
- fail_unless (segment.accum == 100);
+ fail_unless (segment.base == 100);
/* invalid time gives invalid result */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1);
gst_segment_set_newsegment (&segment, FALSE, -1.0, 1.0,
GST_FORMAT_TIME, 100, 300, 0);
- fail_unless (segment.accum == 200);
+ fail_unless (segment.base == 200);
/* invalid time gives invalid result */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, -1);
GST_START_TEST (segment_newsegment_streamtime_applied_rate)
{
GstSegment segment;
- gint64 result;
+ guint64 result;
gst_segment_init (&segment, GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 200);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 200);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 200);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
fail_unless (segment.stop == 200);
fail_unless (segment.time == 400);
/* previous segment lasted 200, rate of 2.0 was already applied */
- fail_unless (segment.accum == 400);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 400);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 200);
- fail_unless (segment.accum == 600);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 600);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
{
GstSegment segment;
- gint64 result;
+ guint64 result;
gst_segment_init (&segment, GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
fail_unless (segment.stop == 200);
fail_unless (segment.time == 200);
/* previous segment lasted 100 */
- fail_unless (segment.accum == 100);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 100);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
fail_unless (segment.stop == 200);
fail_unless (segment.time == 200);
/* accumulated 100 of previous segment to make 200 */
- fail_unless (segment.accum == 200);
- fail_unless (segment.last_stop == 200);
+ fail_unless (segment.base == 200);
+ fail_unless (segment.position == 200);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 400);
- fail_unless (segment.last_stop == 200);
+ fail_unless (segment.base == 400);
+ fail_unless (segment.position == 200);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
GST_START_TEST (segment_newsegment_runningtime)
{
GstSegment segment;
- gint64 result;
+ guint64 result;
gst_segment_init (&segment, GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 0);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 0);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
GST_FORMAT_TIME, 0, 200, 500);
/* normal speed gives elapsed of 200 */
- fail_unless (segment.accum == 200);
+ fail_unless (segment.base == 200);
/* invalid time gives invalid result */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1);
/* previous segment played at double speed gives elapsed time of
* 100 added to previous accum of 200 gives 300. */
- fail_unless (segment.accum == 300);
+ fail_unless (segment.base == 300);
/* invalid time gives invalid result */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1);
gst_segment_set_newsegment (&segment, FALSE, -1.0, 1.0,
GST_FORMAT_TIME, 500, 700, 200);
- fail_unless (segment.accum == 500);
+ fail_unless (segment.base == 500);
/* invalid time gives invalid result */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1);
gst_segment_set_newsegment (&segment, FALSE, -2.0, -2.0,
GST_FORMAT_TIME, 500, 700, 200);
- fail_unless (segment.accum == 700);
+ fail_unless (segment.base == 700);
/* invalid time gives invalid result */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, -1);
GST_FORMAT_TIME, 500, 700, 200);
/* previous segment lasted 100, and was at 700 so we should get 800 */
- fail_unless (segment.accum == 800);
+ fail_unless (segment.base == 800);
result = gst_segment_to_position (&segment, GST_FORMAT_TIME, 800);
fail_unless (result == 700);
}
GST_START_TEST (segment_newsegment_accum)
{
GstSegment segment;
- gint64 result;
+ guint64 result;
gst_segment_init (&segment, GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 200);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 200);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
fail_unless (segment.start == 0);
fail_unless (segment.stop == 150);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 50);
- fail_unless (segment.last_stop == 150);
+ fail_unless (segment.base == 50);
+ fail_unless (segment.position == 150);
fail_unless (segment.duration == -1);
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (segment.start == 100);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 100);
- fail_unless (segment.accum == 50);
- fail_unless (segment.last_stop == 150);
+ fail_unless (segment.base == 50);
+ fail_unless (segment.position == 150);
fail_unless (segment.duration == -1);
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100);
GST_START_TEST (segment_newsegment_accum2)
{
GstSegment segment;
- gint64 result;
+ guint64 result;
gst_segment_init (&segment, GST_FORMAT_TIME);
fail_unless (segment.start == 0);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 200);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 200);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
fail_unless (segment.start == 150);
fail_unless (segment.stop == 200);
fail_unless (segment.time == 0);
- fail_unless (segment.accum == 0);
- fail_unless (segment.last_stop == 200);
+ fail_unless (segment.base == 0);
+ fail_unless (segment.position == 200);
fail_unless (segment.duration == -1);
/* new segment, this accumulates 50. */
fail_unless (segment.start == 150);
fail_unless (segment.stop == 300);
fail_unless (segment.time == 150);
- fail_unless (segment.accum == 50);
- fail_unless (segment.last_stop == 150);
+ fail_unless (segment.base == 50);
+ fail_unless (segment.position == 150);
fail_unless (segment.duration == -1);
/* invalid time gives invalid result */
}
GST_END_TEST;
+#endif
GST_START_TEST (segment_copy)
{
gst_segment_init (&segment, GST_FORMAT_TIME);
- gst_segment_set_newsegment (&segment, FALSE, -1.0, 1.0,
- GST_FORMAT_TIME, 0, 200, 0);
+ segment.rate = -1.0;
+ segment.applied_rate = 1.0;
+ segment.start = 0;
+ segment.stop = 200;
+ segment.time = 0;
copy = gst_segment_copy (&segment);
fail_unless (copy != NULL);
tcase_add_test (tc_chain, segment_seek_size);
tcase_add_test (tc_chain, segment_seek_reverse);
tcase_add_test (tc_chain, segment_seek_rate);
+#if 0
tcase_add_test (tc_chain, segment_newsegment_open);
tcase_add_test (tc_chain, segment_newsegment_closed);
tcase_add_test (tc_chain, segment_newsegment_streamtime);
tcase_add_test (tc_chain, segment_newsegment_runningtime);
tcase_add_test (tc_chain, segment_newsegment_accum);
tcase_add_test (tc_chain, segment_newsegment_accum2);
+#endif
tcase_add_test (tc_chain, segment_copy);
return s;
static gboolean
-newsegment_event_catcher (GstObject * pad, GstEvent * event,
- gpointer * user_data)
+segment_event_catcher (GstObject * pad, GstEvent * event, gpointer * user_data)
{
GstEvent **last_event = (GstEvent **) user_data;
fail_unless (event != NULL);
fail_unless (GST_IS_EVENT (event));
fail_unless (user_data != NULL);
- if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
+ if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
if (*last_event)
gst_event_unref (*last_event);
*last_event = gst_event_copy (event);
}
/* basesrc_seek_events_rate_update:
- * - make sure we get expected newsegment after sending a seek event
+ * - make sure we get expected segment after sending a seek event
*/
GST_START_TEST (basesrc_seek_events_rate_update)
{
GstBus *bus;
GstPad *probe_pad;
guint probe;
- GstEvent *newseg_event = NULL;
+ GstEvent *seg_event = NULL;
GstEvent *rate_seek;
gboolean event_ret;
- gdouble rate = 0.5;
+ GstSegment segment;
pipe = gst_pipeline_new ("pipeline");
sink = gst_element_factory_make ("fakesink", "sink");
fail_unless (probe_pad != NULL);
probe = gst_pad_add_event_probe (probe_pad,
- G_CALLBACK (newsegment_event_catcher), &newseg_event);
+ G_CALLBACK (segment_event_catcher), &seg_event);
/* prepare the seek */
rate_seek = gst_event_new_seek (0.5, GST_FORMAT_TIME, GST_SEEK_FLAG_NONE,
GST_INFO ("stopped");
/* check that we have go the event */
- fail_unless (newseg_event != NULL);
+ fail_unless (seg_event != NULL);
- gst_event_parse_new_segment (newseg_event, NULL, &rate, NULL, NULL, NULL,
- NULL, NULL);
- fail_unless (rate == 0.5);
+ gst_event_parse_segment (seg_event, &segment);
+ fail_unless (segment.rate == 0.5);
gst_pad_remove_event_probe (probe_pad, probe);
gst_object_unref (probe_pad);
gst_message_unref (msg);
- gst_event_unref (newseg_event);
+ gst_event_unref (seg_event);
gst_object_unref (bus);
gst_object_unref (pipe);
}