gst.segment

Module for [Segment] struct

struct Segment

Types 1

structSegment

This helper structure holds the relevant values for tracking the region of interest in a media file, called a segment.

The structure can be used for two purposes:

  • performing seeks (handling seek events)
  • tracking playback regions (handling newsegment events)

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. This information is then used to clip media to the segment boundaries.

A segment structure is initialized with [gst.segment.Segment.init_], which takes a #GstFormat that will be used as the format of the segment values. The segment will be configured with a start value of 0 and a stop/duration of -1, which is undefined. The default rate and applied_rate is 1.0.

The public duration field contains the duration of the 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.

The current position in the segment should be set by changing the position member in the structure.

For elements that perform seeks, the current segment should be updated with the [gst.segment.Segment.doSeek] and the values from the seek event. This method will update all the segment fields. The position field will contain the new playback position. If the start_type was different from GST_SEEK_TYPE_NONE, playback continues from the position position, possibly with updated flags or rate.

For elements that want to use #GstSegment to track the playback region, update the segment fields with the information from the newsegment event. The [gst.segment.Segment.clip] method can be used to check and clip the media data to the segment boundaries.

For elements that want to synchronize to the pipeline clock, [gst.segment.Segment.toRunningTime] can be used to convert a timestamp to a value that can be used to synchronize to the clock. This function takes into account the base as well as any rate or applied_rate conversions.

For elements that need to perform operations on media data in stream_time, [gst.segment.Segment.toStreamTime] 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).

Fields
SegmentFlags flagsflags for this segment
double ratethe playback rate of the segment is set in response to a seek event and, without any seek, the value should be `1.0`. This value is used by elements that synchronize buffer [running times](addition...
double appliedRateThe applied rate is the rate that has been applied to the stream. The effective/resulting playback rate of a stream is `rate * appliedrate`. The applied rate can be set by source elements when a se...
Format formatthe unit used for all of the segment's values.
ulong basethe running time (plus elapsed time, see offset) of the segment [start](GstSegment.start) ([stop](GstSegment.stop) if rate < 0.0).
ulong offsetthe offset expresses the elapsed time (in buffer timestamps) before a seek with its start (stop if rate < 0.0) seek type set to #GSTSEEKTYPE_NONE, the value is set to the position of the segment at...
ulong startthe start time of the segment (in buffer timestamps) [(PTS)](GstBuffer.pts), that is the timestamp of the first buffer to output inside the segment (last one during reverse playback). For example d...
ulong stopthe stop time of the segment (in buffer timestamps) [(PTS)](GstBuffer.pts), that is the timestamp of the last buffer to output inside the segment (first one during reverse playback). For example de...
ulong timethe stream time of the segment [start](GstSegment.start) ([stop](GstSegment.stop) if rate < 0.0).
ulong positionthe buffer timestamp position in the segment is supposed to be updated by elements such as sources, demuxers or parsers to track progress by setting it to the last pushed buffer' end time ([timesta...
ulong durationthe duration of the segment is the maximum absolute difference between #GstSegment.start and #GstSegment.stop if stop is not set, otherwise it should be the difference between those two values. Thi...
void *[4] GstReserved
Methods
GType _gType() @property
void * boxCopy()
bool clip(gst.types.Format format, ulong start, ulong stop, out ulong clipStart, out ulong clipStop)Clip the given start and stop values to the segment boundaries given in segment. start and stop are compared and clipped to segment start and stop values.
gst.segment.Segment copy()Create a copy of given segment.
void copyInto(gst.segment.Segment dest)Copy the contents of src into dest.
bool doSeek(double rate, gst.types.Format format, gst.types.SeekFlags flags, gst.types.SeekType startType, ulong start, gst.types.SeekType stopType, ulong stop, out bool update)Update the segment structure with the field values of a seek event (see [gst.event.Event.newSeek]).
void init_(gst.types.Format format)The start/position fields are set to 0 and the stop/duration fields are set to -1 (unknown). The default rate of 1.0 and no flags are set.
bool isEqual(gst.segment.Segment s1)Checks for two segments being equal. Equality here is defined as perfect equality, including floating point values.
bool offsetRunningTime(gst.types.Format format, long offset)Adjust the values in segment so that offset is applied to all future running-time calculations.
ulong positionFromRunningTime(gst.types.Format format, ulong runningTime)Convert runningtime into a position in the segment so that [gst.segment.Segment.toRunningTime] with that position returns runningtime.
int positionFromRunningTimeFull(gst.types.Format format, ulong runningTime, out ulong position)Translate running_time to the segment position using the currently configured segment. Compared to [gst.segment.Segment.positionFromRunningTime] this function can return negative segment position.
ulong positionFromStreamTime(gst.types.Format format, ulong streamTime)Convert streamtime into a position in the segment so that [gst.segment.Segment.toStreamTime] with that position returns streamtime.
int positionFromStreamTimeFull(gst.types.Format format, ulong streamTime, out ulong position)Translate stream_time to the segment position using the currently configured segment. Compared to [gst.segment.Segment.positionFromStreamTime] this function can return negative segment position.
bool setRunningTime(gst.types.Format format, ulong runningTime)Adjust the start/stop and base values of segment such that the next valid buffer will be one with running_time.
ulong toPosition(gst.types.Format format, ulong runningTime)Convert runningtime into a position in the segment so that [gst.segment.Segment.toRunningTime] with that position returns runningtime.
ulong toRunningTime(gst.types.Format format, ulong position)Translate position to the total running time using the currently configured segment. Position is a value between segment start and stop time.
int toRunningTimeFull(gst.types.Format format, ulong position, out ulong runningTime)Translate position to the total running time using the currently configured segment. Compared to [gst.segment.Segment.toRunningTime] this function can return negative running-time.
ulong toStreamTime(gst.types.Format format, ulong position)Translate position to stream time using the currently configured segment. The position value must be between segment start and stop value.
int toStreamTimeFull(gst.types.Format format, ulong position, out ulong streamTime)Translate position to the total stream time using the currently configured segment. Compared to [gst.segment.Segment.toStreamTime] this function can return negative stream-time.