gstreamermm
1.10.0
|
A class that describes the configured region of interest in a media file. More...
#include <gstreamermm/segment.h>
Public Member Functions | |
Segment () | |
Segment (GstSegment* gobject, bool make_a_copy=true) | |
Segment (const Segment& other) | |
Segment& | operator= (const Segment& other) |
Segment (Segment&& other) noexcept | |
Segment& | operator= (Segment&& other) noexcept |
~Segment () noexcept | |
void | swap (Segment& other) noexcept |
GstSegment* | gobj () |
Provides access to the underlying C instance. More... | |
const GstSegment* | gobj () const |
Provides access to the underlying C instance. More... | |
GstSegment* | gobj_copy () const |
Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. More... | |
bool | clip (Format format, guint64 start, guint64 stop, guint64& clip_start, guint64& clip_stop) const |
Clip the given start and stop values to the segment boundaries given in segment. More... | |
void | init (Format format) |
The start/position fields are set to 0 and the stop/duration fields are set to -1 (unknown). More... | |
void | set_seek (double rate, Format format, SeekFlags flags, SeekType start_type, gint64 start, SeekType stop_type, gint64 stop, bool& update) |
Update the segment structure with the field values of a seek event (see Gst::Event::new_seek()). More... | |
guint64 | to_running_time (Format format, guint64 position) const |
Translate position to the total running time using the currently configured segment. More... | |
int | to_running_time (Format format, guint64 position, guint64& running_time) const |
Translate position to the total running time using the currently configured segment. More... | |
guint64 | to_stream_time (Format format, guint64 position) const |
Translate position to stream time using the currently configured segment. More... | |
int | to_stream_time (Format format, guint64 position, guint64& stream_time) const |
Translate position to the total stream time using the currently configured segment. More... | |
guint64 | to_position (Format format, guint64 running_time) const |
Convert running_time into a position in the segment so that to_running_time() with that position returns running_time. More... | |
bool | set_running_time (Format format, guint64 running_time) |
Adjust the start/stop and base values of segment such that the next valid buffer will be one with running_time. More... | |
guint64 | position_from_running_time (Gst::Format format, guint64 running_time) const |
Convert running_time into a position in the segment so that to_running_time() with that position returns running_time. More... | |
int | position_from_running_time (Gst::Format format, guint64 running_time, guint64& position) const |
Translate running_time to the segment position using the currently configured segment. More... | |
guint64 | position_from_stream_time (Gst::Format format, guint64 stream_time) const |
Convert stream_time into a position in the segment so that to_stream_time() with that position returns stream_time. More... | |
int | position_from_stream_time (Gst::Format format, guint64 stream_time, guint64& position) const |
Translate stream_time to the segment position using the currently configured segment. More... | |
bool | offset_running_time (Gst::Format format, gint64 offset) |
Adjust the values in segment so that offset is applied to all future running-time calculations. More... | |
bool | is_equal (const Gst::Segment& s2) const |
Checks for two segments being equal. More... | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. More... | |
Protected Attributes | |
GstSegment* | gobject_ |
Related Functions | |
(Note that these are not member functions.) | |
void | swap (Segment& lhs, Segment& rhs) noexcept |
Gst::Segment | wrap (GstSegment* object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
A class that describes the configured region of interest in a media file.
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:
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 init(), which takes a Format 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 current position in the segment should be set with the set_last_stop(). The public last_stop field contains the last set stop position in the segment.
For elements that perform seeks, the current segment should be updated with the set_seek() and the values from the seek event. This method will update all the segment fields. The last_stop field will contain the new playback position. If the cur_type was different from Gst::SEEK_TYPE_NONE, playback continues from the last_stop position, possibly with updated flags or rate.
For elements that want to synchronize to the pipeline clock, to_running_time() can be used to convert a timestamp to a value that can be used to synchronize 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, 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).
Last reviewed on 2016-07-12 (1.8.0)
Gst::Segment::Segment | ( | ) |
|
explicit |
Gst::Segment::Segment | ( | const Segment& | other | ) |
|
noexcept |
|
noexcept |
bool Gst::Segment::clip | ( | Format | format, |
guint64 | start, | ||
guint64 | stop, | ||
guint64 & | clip_start, | ||
guint64 & | clip_stop | ||
) | const |
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.
If the function returns false
, start and stop are known to fall outside of segment and clip_start and clip_stop are not updated.
When the function returns true
, clip_start and clip_stop will be updated. If clip_start or clip_stop are different from start or stop respectively, the region fell partially in the segment.
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.
format | The format of the segment. |
start | The start position in the segment. |
stop | The stop position in the segment. |
clip_start | The clipped start position in the segment. |
clip_stop | The clipped stop position in the segment. |
true
if the given start and stop times fall partially or completely in segment, false
if the values are completely outside of the segment.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C instance.
|
inline |
Provides access to the underlying C instance.
GstSegment* Gst::Segment::gobj_copy | ( | ) | const |
Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
void Gst::Segment::init | ( | 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.
Initialize segment to its default values.
format | The format of the segment. |
bool Gst::Segment::is_equal | ( | const Gst::Segment& | s2 | ) | const |
Checks for two segments being equal.
Equality here is defined as perfect equality, including floating point values.
s2 | A Gst::Segment structure. |
true
if the segments are equal, false
otherwise. bool Gst::Segment::offset_running_time | ( | Gst::Format | format, |
gint64 | offset | ||
) |
Adjust the values in segment so that offset is applied to all future running-time calculations.
format | The format of the segment. |
offset | The offset to apply in the segment. |
true
if the segment could be updated successfully. If false
is returned, offset is not in segment. guint64 Gst::Segment::position_from_running_time | ( | Gst::Format | format, |
guint64 | running_time | ||
) | const |
Convert running_time into a position in the segment so that to_running_time() with that position returns running_time.
format | The format of the segment. |
running_time | The running_time in the segment. |
int Gst::Segment::position_from_running_time | ( | Gst::Format | format, |
guint64 | running_time, | ||
guint64 & | position | ||
) | const |
Translate running_time to the segment position using the currently configured segment.
Compared to position_from_running_time() this function can return negative segment position.
This function is typically used by elements that need to synchronize buffers against the clock or each other.
running_time can be any value and the result of this function for values outside of the segment is extrapolated.
When 1 is returned, running_time resulted in a positive position returned in position.
When this function returns -1, the returned position should be negated to get the real negative segment position.
format | The format of the segment. |
running_time | The running-time. |
position | The resulting position in the segment. |
guint64 Gst::Segment::position_from_stream_time | ( | Gst::Format | format, |
guint64 | stream_time | ||
) | const |
Convert stream_time into a position in the segment so that to_stream_time() with that position returns stream_time.
format | The format of the segment. |
stream_time | The stream_time in the segment. |
int Gst::Segment::position_from_stream_time | ( | Gst::Format | format, |
guint64 | stream_time, | ||
guint64 & | position | ||
) | const |
Translate stream_time to the segment position using the currently configured segment.
Compared to position_from_stream_time() this function can return negative segment position.
This function is typically used by elements that need to synchronize buffers against the clock or each other.
stream_time can be any value and the result of this function for values outside of the segment is extrapolated.
When 1 is returned, stream_time resulted in a positive position returned in position.
When this function returns -1, the returned position should be negated to get the real negative segment position.
format | The format of the segment. |
stream_time | The stream-time. |
position | The resulting position in the segment. |
bool Gst::Segment::set_running_time | ( | Format | format, |
guint64 | running_time | ||
) |
Adjust the start/stop and base values of segment such that the next valid buffer will be one with running_time.
format | The format of the segment. |
running_time | The running_time in the segment. |
true
if the segment could be updated successfully. If false
is returned, running_time is -1 or not in segment. void Gst::Segment::set_seek | ( | double | rate, |
Format | format, | ||
SeekFlags | flags, | ||
SeekType | start_type, | ||
gint64 | start, | ||
SeekType | stop_type, | ||
gint64 | stop, | ||
bool & | update | ||
) |
Update the segment structure with the field values of a seek event (see Gst::Event::new_seek()).
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.
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 position is unmodified.
For negative rate, the new position in the segment is the new segment stop field when it was updated with a stop_type different from 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 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 position field. This field can be false
if, for example, only the rate has been changed but not the playback position.
rate | The rate of the segment. |
format | The format of 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 position was updated. |
true
if the seek could be performed.
|
noexcept |
guint64 Gst::Segment::to_position | ( | Format | format, |
guint64 | running_time | ||
) | const |
Convert running_time into a position in the segment so that to_running_time() with that position returns running_time.
format | The format of the segment. |
running_time | The running_time in the segment. |
Deprecated. Use position_from_running_time() instead.
guint64 Gst::Segment::to_running_time | ( | Format | format, |
guint64 | position | ||
) | const |
Translate position to the total running time using the currently configured segment.
Position is a value between segment start and stop time.
This function is typically used by elements that need to synchronize to the global clock in a pipeline. The running time is a constantly increasing value starting from 0. When init() is called, this value will reset to 0.
This function returns -1 if the position is outside of segment start and stop.
format | The format of the segment. |
position | The position in the segment. |
int Gst::Segment::to_running_time | ( | Format | format, |
guint64 | position, | ||
guint64 & | running_time | ||
) | const |
Translate position to the total running time using the currently configured segment.
Compared to to_running_time() this function can return negative running-time.
This function is typically used by elements that need to synchronize buffers against the clock or eachother.
position can be any value and the result of this function for values outside of the segment is extrapolated.
When 1 is returned, position resulted in a positive running-time returned in running_time.
When this function returns -1, the returned running_time should be negated to get the real negative running time.
format | The format of the segment. |
position | The position in the segment. |
running_time | Result running-time. |
guint64 Gst::Segment::to_stream_time | ( | Format | format, |
guint64 | position | ||
) | const |
Translate position to stream time using the currently configured segment.
The position value must be between segment start and 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 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.
format | The format of the segment. |
position | The position in the segment. |
int Gst::Segment::to_stream_time | ( | Format | format, |
guint64 | position, | ||
guint64 & | stream_time | ||
) | const |
Translate position to the total stream time using the currently configured segment.
Compared to to_stream_time() this function can return negative stream-time.
This function is typically used by elements that need to synchronize buffers against the clock or eachother.
position can be any value and the result of this function for values outside of the segment is extrapolated.
When 1 is returned, position resulted in a positive stream-time returned in stream_time.
When this function returns -1, the returned stream_time should be negated to get the real negative stream time.
format | The format of the segment. |
position | The position in the segment. |
stream_time | Result stream-time. |
lhs | The left-hand side |
rhs | The right-hand side |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |
|
protected |