Blame gst/gstsegment.h

Packit f546b1
/* GStreamer
Packit f546b1
 * Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
Packit f546b1
 *
Packit f546b1
 * gstsegment.h: Header for GstSegment subsystem
Packit f546b1
 *
Packit f546b1
 * This library is free software; you can redistribute it and/or
Packit f546b1
 * modify it under the terms of the GNU Library General Public
Packit f546b1
 * License as published by the Free Software Foundation; either
Packit f546b1
 * version 2 of the License, or (at your option) any later version.
Packit f546b1
 *
Packit f546b1
 * This library is distributed in the hope that it will be useful,
Packit f546b1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit f546b1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit f546b1
 * Library General Public License for more details.
Packit f546b1
 *
Packit f546b1
 * You should have received a copy of the GNU Library General Public
Packit f546b1
 * License along with this library; if not, write to the
Packit f546b1
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit f546b1
 * Boston, MA 02110-1301, USA.
Packit f546b1
 */
Packit f546b1
Packit f546b1
Packit f546b1
#ifndef __GST_SEGMENT_H__
Packit f546b1
#define __GST_SEGMENT_H__
Packit f546b1
Packit f546b1
#include <gst/gstformat.h>
Packit f546b1
Packit f546b1
G_BEGIN_DECLS
Packit f546b1
Packit f546b1
#define GST_TYPE_SEGMENT             (gst_segment_get_type())
Packit f546b1
Packit f546b1
typedef struct _GstSegment GstSegment;
Packit f546b1
Packit f546b1
/**
Packit f546b1
 * GstSeekType:
Packit f546b1
 * @GST_SEEK_TYPE_NONE: no change in position is required
Packit f546b1
 * @GST_SEEK_TYPE_SET: absolute position is requested
Packit f546b1
 * @GST_SEEK_TYPE_END: relative position to duration is requested
Packit f546b1
 *
Packit f546b1
 * The different types of seek events. When constructing a seek event with
Packit f546b1
 * gst_event_new_seek() or when doing gst_segment_do_seek ().
Packit f546b1
 */
Packit f546b1
typedef enum {
Packit f546b1
  /* one of these */
Packit f546b1
  GST_SEEK_TYPE_NONE            = 0,
Packit f546b1
  GST_SEEK_TYPE_SET             = 1,
Packit f546b1
  GST_SEEK_TYPE_END             = 2
Packit f546b1
} GstSeekType;
Packit f546b1
Packit f546b1
/**
Packit f546b1
 * GstSeekFlags:
Packit f546b1
 * @GST_SEEK_FLAG_NONE: no flag
Packit f546b1
 * @GST_SEEK_FLAG_FLUSH: flush pipeline
Packit f546b1
 * @GST_SEEK_FLAG_ACCURATE: accurate position is requested, this might
Packit f546b1
 *                     be considerably slower for some formats.
Packit f546b1
 * @GST_SEEK_FLAG_KEY_UNIT: seek to the nearest keyframe. This might be
Packit f546b1
 *                     faster but less accurate.
Packit f546b1
 * @GST_SEEK_FLAG_SEGMENT: perform a segment seek.
Packit f546b1
 * @GST_SEEK_FLAG_TRICKMODE: when doing fast forward or fast reverse playback, allow
Packit f546b1
 *                     elements to skip frames instead of generating all
Packit f546b1
 *                     frames. (Since 1.6)
Packit f546b1
 * @GST_SEEK_FLAG_SNAP_BEFORE: go to a location before the requested position,
Packit f546b1
 *                     if %GST_SEEK_FLAG_KEY_UNIT this means the keyframe at or before
Packit f546b1
 *                     the requested position the one at or before the seek target.
Packit f546b1
 * @GST_SEEK_FLAG_SNAP_AFTER: go to a location after the requested position,
Packit f546b1
 *                     if %GST_SEEK_FLAG_KEY_UNIT this means the keyframe at of after the
Packit f546b1
 *                     requested position.
Packit f546b1
 * @GST_SEEK_FLAG_SNAP_NEAREST: go to a position near the requested position,
Packit f546b1
 *                     if %GST_SEEK_FLAG_KEY_UNIT this means the keyframe closest
Packit f546b1
 *                     to the requested position, if both keyframes are at an equal
Packit f546b1
 *                     distance, behaves like %GST_SEEK_FLAG_SNAP_BEFORE.
Packit f546b1
 * @GST_SEEK_FLAG_TRICKMODE_KEY_UNITS: when doing fast forward or fast reverse
Packit f546b1
 *                     playback, request that elements only decode keyframes
Packit f546b1
 *                     and skip all other content, for formats that have
Packit f546b1
 *                     keyframes. (Since 1.6)
Packit f546b1
 * @GST_SEEK_FLAG_TRICKMODE_NO_AUDIO: when doing fast forward or fast reverse
Packit f546b1
 *                     playback, request that audio decoder elements skip
Packit f546b1
 *                     decoding and output only gap events or silence. (Since 1.6)
Packit f546b1
 * @GST_SEEK_FLAG_SKIP: Deprecated backward compatibility flag, replaced
Packit f546b1
 *                     by %GST_SEEK_FLAG_TRICKMODE
Packit f546b1
 *
Packit f546b1
 * Flags to be used with gst_element_seek() or gst_event_new_seek(). All flags
Packit f546b1
 * can be used together.
Packit f546b1
 *
Packit f546b1
 * A non flushing seek might take some time to perform as the currently
Packit f546b1
 * playing data in the pipeline will not be cleared.
Packit f546b1
 *
Packit f546b1
 * An accurate seek might be slower for formats that don't have any indexes
Packit f546b1
 * or timestamp markers in the stream. Specifying this flag might require a
Packit f546b1
 * complete scan of the file in those cases.
Packit f546b1
 *
Packit f546b1
 * When performing a segment seek: after the playback of the segment completes,
Packit f546b1
 * no EOS will be emitted by the element that performed the seek, but a
Packit f546b1
 * %GST_MESSAGE_SEGMENT_DONE message will be posted on the bus by the element.
Packit f546b1
 * When this message is posted, it is possible to send a new seek event to
Packit f546b1
 * continue playback. With this seek method it is possible to perform seamless
Packit f546b1
 * looping or simple linear editing.
Packit f546b1
 *
Packit f546b1
 * When doing fast forward (rate > 1.0) or fast reverse (rate < -1.0) trickmode
Packit f546b1
 * playback, the %GST_SEEK_FLAG_TRICKMODE flag can be used to instruct decoders
Packit f546b1
 * and demuxers to adjust the playback rate by skipping frames. This can improve
Packit f546b1
 * performance and decrease CPU usage because not all frames need to be decoded.
Packit f546b1
 *
Packit f546b1
 * Beyond that, the %GST_SEEK_FLAG_TRICKMODE_KEY_UNITS flag can be used to
Packit f546b1
 * request that decoders skip all frames except key units, and
Packit f546b1
 * %GST_SEEK_FLAG_TRICKMODE_NO_AUDIO flags can be used to request that audio
Packit f546b1
 * decoders do no decoding at all, and simple output silence.
Packit f546b1
 *
Packit f546b1
 * The %GST_SEEK_FLAG_SNAP_BEFORE flag can be used to snap to the previous
Packit f546b1
 * relevant location, and the %GST_SEEK_FLAG_SNAP_AFTER flag can be used to
Packit f546b1
 * select the next relevant location. If %GST_SEEK_FLAG_KEY_UNIT is specified,
Packit f546b1
 * the relevant location is a keyframe. If both flags are specified, the nearest
Packit f546b1
 * of these locations will be selected. If none are specified, the implementation is
Packit f546b1
 * free to select whichever it wants.
Packit f546b1
 *
Packit f546b1
 * The before and after here are in running time, so when playing backwards,
Packit f546b1
 * the next location refers to the one that will played in next, and not the
Packit f546b1
 * one that is located after in the actual source stream.
Packit f546b1
 *
Packit f546b1
 * Also see part-seeking.txt in the GStreamer design documentation for more
Packit f546b1
 * details on the meaning of these flags and the behaviour expected of
Packit f546b1
 * elements that handle them.
Packit f546b1
 */
Packit f546b1
typedef enum {
Packit f546b1
  GST_SEEK_FLAG_NONE            = 0,
Packit f546b1
  GST_SEEK_FLAG_FLUSH           = (1 << 0),
Packit f546b1
  GST_SEEK_FLAG_ACCURATE        = (1 << 1),
Packit f546b1
  GST_SEEK_FLAG_KEY_UNIT        = (1 << 2),
Packit f546b1
  GST_SEEK_FLAG_SEGMENT         = (1 << 3),
Packit f546b1
  GST_SEEK_FLAG_TRICKMODE       = (1 << 4),
Packit f546b1
  /* FIXME 2.0: Remove _SKIP flag,
Packit f546b1
   * which was kept for backward compat when _TRICKMODE was added */
Packit f546b1
  GST_SEEK_FLAG_SKIP            = (1 << 4),
Packit f546b1
  GST_SEEK_FLAG_SNAP_BEFORE     = (1 << 5),
Packit f546b1
  GST_SEEK_FLAG_SNAP_AFTER      = (1 << 6),
Packit f546b1
  GST_SEEK_FLAG_SNAP_NEAREST    = GST_SEEK_FLAG_SNAP_BEFORE | GST_SEEK_FLAG_SNAP_AFTER,
Packit f546b1
  /* Careful to restart next flag with 1<<7 here */
Packit f546b1
  GST_SEEK_FLAG_TRICKMODE_KEY_UNITS = (1 << 7),
Packit f546b1
  GST_SEEK_FLAG_TRICKMODE_NO_AUDIO  = (1 << 8),
Packit f546b1
} GstSeekFlags;
Packit f546b1
Packit f546b1
/**
Packit f546b1
 * GstSegmentFlags:
Packit f546b1
 * @GST_SEGMENT_FLAG_NONE: no flags
Packit f546b1
 * @GST_SEGMENT_FLAG_RESET: reset the pipeline running_time to the segment
Packit f546b1
 *                          running_time
Packit f546b1
 * @GST_SEGMENT_FLAG_TRICKMODE: perform skip playback (Since 1.6)
Packit f546b1
 * @GST_SEGMENT_FLAG_SEGMENT: send SEGMENT_DONE instead of EOS
Packit f546b1
 * @GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS: Decode only keyframes, where
Packit f546b1
 *                                        possible (Since 1.6)
Packit f546b1
 * @GST_SEGMENT_FLAG_TRICKMODE_NO_AUDIO: Do not decode any audio, where
Packit f546b1
 *                                        possible (Since 1.6)
Packit f546b1
 * @GST_SEGMENT_FLAG_SKIP: Deprecated backward compatibility flag, replaced
Packit f546b1
 *                         by @GST_SEGMENT_FLAG_TRICKMODE
Packit f546b1
 *
Packit f546b1
 * Flags for the GstSegment structure. Currently mapped to the corresponding
Packit f546b1
 * values of the seek flags.
Packit f546b1
 */
Packit f546b1
/* Note: update gst_segment_do_seek() when adding new flags here */
Packit f546b1
typedef enum { /*< flags >*/
Packit f546b1
  GST_SEGMENT_FLAG_NONE            = GST_SEEK_FLAG_NONE,
Packit f546b1
  GST_SEGMENT_FLAG_RESET           = GST_SEEK_FLAG_FLUSH,
Packit f546b1
  GST_SEGMENT_FLAG_TRICKMODE       = GST_SEEK_FLAG_TRICKMODE,
Packit f546b1
  /* FIXME 2.0: Remove _SKIP flag,
Packit f546b1
   * which was kept for backward compat when _TRICKMODE was added */
Packit f546b1
  GST_SEGMENT_FLAG_SKIP            = GST_SEEK_FLAG_TRICKMODE,
Packit f546b1
  GST_SEGMENT_FLAG_SEGMENT         = GST_SEEK_FLAG_SEGMENT,
Packit f546b1
  GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS = GST_SEEK_FLAG_TRICKMODE_KEY_UNITS,
Packit f546b1
  GST_SEGMENT_FLAG_TRICKMODE_NO_AUDIO      = GST_SEEK_FLAG_TRICKMODE_NO_AUDIO
Packit f546b1
} GstSegmentFlags;
Packit f546b1
Packit f546b1
/**
Packit f546b1
 * GstSegment:
Packit f546b1
 * @flags: flags for this segment
Packit f546b1
 * @rate: the playback rate of the segment
Packit f546b1
 * @applied_rate: the already applied rate to the segment
Packit f546b1
 * @format: the format of the segment values
Packit f546b1
 * @base: the running time (plus elapsed time, see offset) of the segment start
Packit f546b1
 * @offset: the amount (in buffer timestamps) that has already been elapsed in
Packit f546b1
 *     the segment
Packit f546b1
 * @start: the start of the segment in buffer timestamp time (PTS)
Packit f546b1
 * @stop: the stop of the segment in buffer timestamp time (PTS)
Packit f546b1
 * @time: the stream time of the segment start
Packit f546b1
 * @position: the buffer timestamp position in the segment (used internally by
Packit f546b1
 *     elements such as sources, demuxers or parsers to track progress)
Packit f546b1
 * @duration: the duration of the stream
Packit f546b1
 *
Packit f546b1
 * A helper structure that holds the configured region of
Packit f546b1
 * interest in a media file.
Packit f546b1
 */
Packit f546b1
struct _GstSegment {
Packit f546b1
  /*< public >*/
Packit f546b1
  GstSegmentFlags flags;
Packit f546b1
Packit f546b1
  gdouble         rate;
Packit f546b1
  gdouble         applied_rate;
Packit f546b1
Packit f546b1
  GstFormat       format;
Packit f546b1
  guint64         base;
Packit f546b1
  guint64         offset;
Packit f546b1
  guint64         start;
Packit f546b1
  guint64         stop;
Packit f546b1
  guint64         time;
Packit f546b1
Packit f546b1
  guint64         position;
Packit f546b1
  guint64         duration;
Packit f546b1
Packit f546b1
  /* < private > */
Packit f546b1
  gpointer        _gst_reserved[GST_PADDING];
Packit f546b1
};
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
GType        gst_segment_get_type            (void);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
GstSegment * gst_segment_new                 (void) G_GNUC_MALLOC;
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
GstSegment * gst_segment_copy                (const GstSegment *segment) G_GNUC_MALLOC;
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
void         gst_segment_copy_into           (const GstSegment *src, GstSegment *dest);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
void         gst_segment_free                (GstSegment *segment);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
void         gst_segment_init                (GstSegment *segment, GstFormat format);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gint         gst_segment_to_stream_time_full (const GstSegment *segment, GstFormat format, guint64 position, guint64 * stream_time);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
guint64      gst_segment_to_stream_time      (const GstSegment *segment, GstFormat format, guint64 position);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gint         gst_segment_position_from_stream_time_full (const GstSegment * segment, GstFormat format, guint64 stream_time, guint64 * position);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
guint64      gst_segment_position_from_stream_time (const GstSegment * segment, GstFormat format, guint64 stream_time);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
guint64      gst_segment_to_running_time     (const GstSegment *segment, GstFormat format, guint64 position);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gint         gst_segment_to_running_time_full (const GstSegment *segment, GstFormat format, guint64 position,
Packit f546b1
                                               guint64 * running_time);
Packit f546b1
Packit f546b1
GST_DEPRECATED_FOR(gst_segment_position_from_running_time)
Packit f546b1
guint64      gst_segment_to_position         (const GstSegment *segment, GstFormat format, guint64 running_time);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gint         gst_segment_position_from_running_time_full (const GstSegment *segment, GstFormat format, guint64 running_time, guint64 * position);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
guint64      gst_segment_position_from_running_time (const GstSegment *segment, GstFormat format, guint64 running_time);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gboolean     gst_segment_set_running_time    (GstSegment *segment, GstFormat format, guint64 running_time);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gboolean     gst_segment_offset_running_time (GstSegment *segment, GstFormat format, gint64 offset);
Packit f546b1
Packit f546b1
GST_API
Packit f546b1
gboolean     gst_segment_clip                (const GstSegment *segment, GstFormat format, guint64 start,
Packit f546b1
                                              guint64 stop, guint64 *clip_start, guint64 *clip_stop);
Packit f546b1
GST_API
Packit f546b1
gboolean     gst_segment_do_seek             (GstSegment * segment, gdouble rate,
Packit f546b1
                                              GstFormat format, GstSeekFlags flags,
Packit f546b1
                                              GstSeekType start_type, guint64 start,
Packit f546b1
                                              GstSeekType stop_type, guint64 stop, gboolean * update);
Packit f546b1
GST_API
Packit f546b1
gboolean     gst_segment_is_equal            (const GstSegment * s0, const GstSegment * s1);
Packit f546b1
Packit f546b1
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
Packit f546b1
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSegment, gst_segment_free)
Packit f546b1
#endif
Packit f546b1
Packit f546b1
G_END_DECLS
Packit f546b1
Packit f546b1
#endif /* __GST_SEGMENT_H__ */