Next: , Previous: GstGError, Up: Top


12 GstEvent

Structure describing events that are passed up and down a pipeline

12.1 Overview

The event class provides factory methods to construct and functions query (parse) events.

Events are usually created with gst_event_new_*() which takes event-type specific parameters as arguments. To send an event application will usually use gst-element-send-event and elements will use gst-pad-send-event or gst-pad-push-event. The event should be unreffed with gst-event-unref if it has not been sent.

Events that have been received can be parsed with their respective gst_event_parse_*() functions.

Events are passed between elements in parallel to the data stream. Some events are serialized with buffers, others are not. Some events only travel downstream, others only upstream. Some events can travel both upstream and downstream.

The events are used to signal special conditions in the datastream such as EOS (end of stream) or the start of a new stream-segment. Events are also used to flush the pipeline of any pending data.

Most of the event API is used inside plugins. Applications usually only construct and use seek events. To do that gst-event-new-seek is used to create a seek event. It takes the needed parameters to specity seeking time and mode.

     
       GstEvent *event;
       gboolean result;
       ...
       // construct a seek event to play the media from second 2 to 5, flush
       // the pipeline to decrease latency.
       event = gst_event_new_seek (1.0,
          GST_FORMAT_TIME,
          GST_SEEK_FLAG_FLUSH,
          GST_SEEK_TYPE_SET, 2 * GST_SECOND,
          GST_SEEK_TYPE_SET, 5 * GST_SECOND);
       ...
       result = gst_element_send_event (pipeline, event);
       if (!result)
         g_warning ("seek failed");
       ...
     

Last reviewed on 2006-09-6 (0.10.10)

12.2 Usage

— Class: <gst-event>
— Function: gst-event-get-structure (self <gst-event>)   (ret <gst-structure>)
— Method: get-structure

Access the structure of the event.

event
The <gst-event>.
ret
The structure of the event. The structure is still owned by the event, which means that you should not free it and that the pointer becomes invalid when you free the event. MT safe.
— Function: gst-event-new-buffer-size (format <gst-format>) (minsize int64) (maxsize int64) (async bool)   (ret <gst-event>)

Create a new buffersize event. The event is sent downstream and notifies elements that they should provide a buffer of the specified dimensions.

When the async flag is set, a thread boundary is prefered.

format
buffer format
minsize
minimum buffer size
maxsize
maximum buffer size
async
thread behavior
ret
a new <gst-event>
— Function: gst-event-new-eos   (ret <gst-event>)

Create a new EOS event. The eos event can only travel downstream synchronized with the buffer flow. Elements that receive the EOS event on a pad can return <gst-flow-unexpected> as a <gst-flow-return> when data after the EOS event arrives.

The EOS event will travel down to the sink elements in the pipeline which will then post the <gst-message-eos> on the bus after they have finished playing any buffered data.

When all sinks have posted an EOS message, an EOS message is forwarded to the application.

ret
The new EOS event.
— Function: gst-event-new-flush-start   (ret <gst-event>)

Allocate a new flush start event. The flush start event can be sent upstream and downstream and travels out-of-bounds with the dataflow.

It marks pads as being flushing and will make them return <gst-flow-wrong-state> when used for data flow with gst-pad-push, gst-pad-chain, gst-pad-alloc-buffer, gst-pad-get-range and gst-pad-pull-range. Any event (except a <gst-event-flush-stop>) received on a flushing pad will return ‘#f’ immediately.

Elements should unlock any blocking functions and exit their streaming functions as fast as possible when this event is received.

This event is typically generated after a seek to flush out all queued data in the pipeline so that the new media is played as soon as possible.

ret
A new flush start event.
— Function: gst-event-new-flush-stop   (ret <gst-event>)

Allocate a new flush stop event. The flush stop event can be sent upstream and downstream and travels out-of-bounds with the dataflow. It is typically sent after sending a FLUSH_START event to make the pads accept data again.

Elements can process this event synchronized with the dataflow since the preceeding FLUSH_START event stopped the dataflow.

This event is typically generated to complete a seek and to resume dataflow.

ret
A new flush stop event.
— Function: gst-event-new-navigation (structure <gst-structure>)   (ret <gst-event>)

Create a new navigation event from the given description.

structure
description of the event
ret
a new <gst-event>
— Function: gst-event-new-new-segment (update bool) (rate double) (format <gst-format>) (start int64) (stop int64) (position int64)   (ret <gst-event>)

Allocate a new newsegment event with the given format/values tripplets

This method calls gst-event-new-new-segment-full passing a default value of 1.0 for applied_rate

update
is this segment an update to a previous one
rate
a new rate for playback
format
The format of the segment values
start
the start value of the segment
stop
the stop value of the segment
position
stream position
ret
A new newsegment event.
— Function: gst-event-new-new-segment-full (update bool) (rate double) (applied_rate double) (format <gst-format>) (start int64) (stop int64) (position int64)   (ret <gst-event>)

Allocate a new newsegment event with the given format/values triplets.

The newsegment event marks the range of buffers to be processed. All data not within the segment range is not to be processed. This can be used intelligently by plugins to apply more efficient methods of skipping unneeded data.

The position value of the segment is used in conjunction with the start value to convert the buffer timestamps into the stream time. This is usually done in sinks to report the current stream_time. position represents the stream_time of a buffer carrying a timestamp of start. position cannot be -1.

start cannot be -1, stop can be -1. If there is a valid stop given, it must be greater or equal the start, including when the indicated playback rate is < 0.

The applied-rate value provides information about any rate adjustment that has already been made to the timestamps and content on the buffers of the stream. (rate * applied-rate) should always equal the rate that has been requested for playback. For example, if an element has an input segment with intended playback rate of 2.0 and applied_rate of 1.0, it can adjust incoming timestamps and buffer content by half and output a newsegment event with rate of 1.0 and applied-rate of 2.0

After a newsegment event, the buffer stream time is calculated with:

position + (TIMESTAMP(buf) - start) * ABS (rate * applied_rate)

update
Whether this segment is an update to a previous one
rate
A new rate for playback
applied-rate
The rate factor which has already been applied
format
The format of the segment values
start
The start value of the segment
stop
The stop value of the segment
position
stream position
ret
A new newsegment event.

Since 0.10.6

— Function: gst-event-new-qos (proportion double) (diff unsigned-long-long) (timestamp unsigned-long-long)   (ret <gst-event>)

Allocate a new qos event with the given values. The QOS event is generated in an element that wants an upstream element to either reduce or increase its rate because of high/low CPU load or other resource usage such as network performance. Typically sinks generate these events for each buffer they receive.

proportion indicates the real-time performance of the streaming in the element that generated the QoS event (usually the sink). The value is generally computed based on more long term statistics about the streams timestamps compared to the clock. A value < 1.0 indicates that the upstream element is producing data faster than real-time. A value > 1.0 indicates that the upstream element is not producing data fast enough. 1.0 is the ideal proportion value. The proportion value can safely be used to lower or increase the quality of the element.

diff is the difference against the clock in running time of the last buffer that caused the element to generate the QOS event. A negative value means that the buffer with timestamp arrived in time. A positive value indicates how late the buffer with timestamp was.

timestamp is the timestamp of the last buffer that cause the element to generate the QOS event. It is expressed in running time and thus an ever increasing value.

The upstream element can use the diff and timestamp values to decide whether to process more buffers. For possitive diff, all buffers with timestamp <= timestamp + diff will certainly arrive late in the sink as well.

The application can use general event probes to intercept the QoS event and implement custom application specific QoS handling.

proportion
the proportion of the qos message
diff
The time difference of the last Clock sync
timestamp
The timestamp of the buffer
ret
A new QOS event.
— Function: gst-event-new-seek (rate double) (format <gst-format>) (flags <gst-seek-flags>) (cur_type <gst-seek-type>) (cur int64) (stop_type <gst-seek-type>) (stop int64)   (ret <gst-event>)

Allocate a new seek event with the given parameters.

The seek event configures playback of the pipeline between start to stop at the speed given in rate, also called a playback segment. The start and stop values are expressed in format.

A rate of 1.0 means normal playback rate, 2.0 means double speed. Negatives values means backwards playback. A value of 0.0 for the rate is not allowed and should be accomplished instead by PAUSING the pipeline.

A pipeline has a default playback segment configured with a start position of 0, a stop position of -1 and a rate of 1.0. The currently configured playback segment can be queried with <gst-query-segment>.

start-type and stop-type specify how to adjust the currently configured start and stop fields in segment. Adjustments can be made relative or absolute to the last configured values. A type of <gst-seek-type-none> means that the position should not be updated.

When the rate is positive and start has been updated, playback will start from the newly configured start position.

For negative rates, playback will start from the newly configured stop position (if any). If the stop position if updated, it must be different from -1 for negative rates.

It is not possible to seek relative to the current playback position, to do this, PAUSE the pipeline, query the current playback position with <gst-query-position> and update the playback segment current position with a <gst-seek-type-set> to the desired position.

rate
The new playback rate
format
The format of the seek values
flags
The optional seek flags
start-type
The type and flags for the new start position
start
The value of the new start position
stop-type
The type and flags for the new stop position
stop
The value of the new stop position
ret
A new seek event.
— Function: gst-event-new-tag (taglist <gst-tag-list*>)   (ret <gst-event>)

Generates a metadata tag event from the given taglist.

taglist
metadata list
ret
a new <gst-event>
— Function: gst-event-parse-buffer-size (self <gst-event>) (format <gst-format*>)   (minsize int64) (maxsize int64) (async bool)
— Method: parse-buffer-size

Get the format, minsize, maxsize and async-flag in the buffersize event.

event
The event to query
format
A pointer to store the format in
minsize
A pointer to store the minsize in
maxsize
A pointer to store the maxsize in
async
A pointer to store the async-flag in
— Function: gst-event-parse-new-segment (self <gst-event>) (format <gst-format*>)   (update bool) (rate double) (start int64) (stop int64) (position int64)
— Method: parse-new-segment

Get the update flag, rate, format, start, stop and position in the newsegment event. In general, gst-event-parse-new-segment-full should be used instead of this, to also retrieve the applied_rate value of the segment. See gst-event-new-new-segment-full for a full description of the newsegment event.

event
The event to query
update
A pointer to the update flag of the segment
rate
A pointer to the rate of the segment
format
A pointer to the format of the newsegment values
start
A pointer to store the start value in
stop
A pointer to store the stop value in
position
A pointer to store the stream time in
— Function: gst-event-parse-new-segment-full (self <gst-event>) (format <gst-format*>)   (update bool) (rate double) (applied_rate double) (start int64) (stop int64) (position int64)
— Method: parse-new-segment-full

Get the update, rate, applied_rate, format, start, stop and position in the newsegment event. See gst-event-new-new-segment-full for a full description of the newsegment event.

event
The event to query
update
A pointer to the update flag of the segment
rate
A pointer to the rate of the segment
applied-rate
A pointer to the applied_rate of the segment
format
A pointer to the format of the newsegment values
start
A pointer to store the start value in
stop
A pointer to store the stop value in
position
A pointer to store the stream time in

Since 0.10.6

— Function: gst-event-parse-qos (self <gst-event>) (diff <gst-clock-time-diff*>) (timestamp <gst-clock-time*>)   (proportion double)
— Method: parse-qos

Get the proportion, diff and timestamp in the qos event. See gst-event-new-qos for more information about the different QoS values.

event
The event to query
proportion
A pointer to store the proportion in
diff
A pointer to store the diff in
timestamp
A pointer to store the timestamp in
— Function: gst-event-parse-seek (self <gst-event>) (format <gst-format*>) (flags <gst-seek-flags*>) (cur_type <gst-seek-type*>) (stop_type <gst-seek-type*>)   (rate double) (cur int64) (stop int64)
— Method: parse-seek

Parses a seek event and stores the results in the given result locations.

event
a seek event
rate
result location for the rate
format
result location for the stream format
flags
result location for the <gst-seek-flags>
start-type
result location for the <gst-seek-type> of the start position
start
result location for the start postion expressed in format
stop-type
result location for the <gst-seek-type> of the stop position
stop
result location for the stop postion expressed in format
— Function: gst-event-parse-tag (self <gst-event>) (taglist <gst-tag-list**>)
— Method: parse-tag

Parses a tag event and stores the results in the given taglist location.

event
a tag event
taglist
pointer to metadata list
— Function: gst-event-type-get-flags (self <gst-event-type*>)   (ret <gst-event-type-flags>)

Gets the <gst-event-type-flags> associated with type.

type
a <gst-event-type>
ret
a <gst-event-type-flags>.
— Function: gst-event-type-get-name (self <gst-event-type*>)   (ret mchars)

Get a printable name for the given event type. Do not modify or free.

type
the event type
ret
a reference to the static name of the event.
— Function: gst-event-type-to-quark (self <gst-event-type*>)   (ret unsigned-int)

Get the unique quark for the given event type.

type
the event type
ret
the quark associated with the event type