#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_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_SET = 1,
+ GST_SEEK_TYPE_END = 2
+} 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 seamless
+ * 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;
+
+/**
+ * GstSegmentFlags:
+ * @GST_SEGMENT_FLAG_NONE: no flags
+ * @GST_SEGMENT_FLAG_RESET: reset the pipeline running_time to the segment
+ * running_time
+ * @GST_SEGMENT_FLAG_SKIP: perform skip playback
+ *
+ * Flags for the GstSegment structure. Currently mapped to the corresponding
+ * values of the seek flags.
+ */
+typedef enum {
+ GST_SEGMENT_FLAG_NONE = GST_SEEK_FLAG_NONE,
+ GST_SEGMENT_FLAG_RESET = GST_SEEK_FLAG_FLUSH,
+ GST_SEGMENT_FLAG_SKIP = GST_SEEK_FLAG_SKIP
+} GstSegmentFlags;
+
+/**
* GstSegment:
+ * @flags: flags for this segment
* @rate: the rate of the segment
- * @abs_rate: absolute value of @rate
+ * @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
- * @applied_rate: the already applied rate to the segment
+ * @position: the position in the segment
+ * @duration: the duration of the segment
*
* A helper structure that holds the configured region of
* interest in a media file.
*/
struct _GstSegment {
/*< public >*/
- gdouble rate;
- gdouble abs_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];
+ GstSegmentFlags 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);
+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_seek (GstSegment *segment, gdouble rate,
- GstFormat format, GstSeekFlags flags,
- GstSeekType start_type, gint64 start,
- GstSeekType stop_type, gint64 stop,
- gboolean *update);
+gboolean gst_segment_set_running_time (GstSegment *segment, GstFormat format, guint64 running_time);
-void gst_segment_set_newsegment (GstSegment *segment, gboolean update, gdouble rate,
- GstFormat format, gint64 start, gint64 stop, gint64 time);
-void gst_segment_set_newsegment_full (GstSegment *segment, gboolean update, gdouble rate,
- gdouble applied_rate, GstFormat format, gint64 start,
- gint64 stop, gint64 time);
+gboolean gst_segment_clip (const GstSegment *segment, GstFormat format, guint64 start,
+ guint64 stop, guint64 *clip_start, guint64 *clip_stop);
-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 (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