Blame gst/gstsegment.h

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