1 This is the current implementation of events, based on an earlier
2 document, in this same directory, called "events".
7 The event system is designed to be a mechanism for _inter_plugin_
8 communication. Their scope is therefore limited in a way that they do
9 not serve as a way to communicate between plugins and the app (signals
10 and properties are still used for plugin-app communication).
12 Events will be generated by either a plugin or the app. It should be
13 possible for a plugin to generate an event on one of its pads and it
14 should be possible for an app to insert an event on an arbitrary pad or
15 element in the pipeline.
21 Events can both travel upstream or downstream. Some events, by nature,
22 only travel in one direction.
26 - Travel in the same way buffers do. This includes that they are handled
27 by the scheduler. The rationale is that the events should be kept
28 as close to the buffers are possible.
30 - plugins should check the type of the GstData passed in the _chain
31 or _loop function and act appropriatly. This can be done by either
32 doing their own stuff or by calling the default handler.
34 - are handled on the sink pad.
38 - are handled with an event handler attached to the srcpad. A default
39 handler is implemented for pads that don't implement their own
42 - travel as fast as possible. the rationale is that a seek event should
43 get to the src element ASAP.
47 Plugin generated events
48 -----------------------
50 We cover the range of events a plugin can generate and how they
51 are supposed to handle them.
55 when the plugin has no more data to push, it pushes an EOS
56 event and calls gst_element_set_eos.
58 _get based plugins should call gst_element_set_eos() before
59 returning the EOS event.
61 gst_element_set_eos() will put an element into the PAUSED state
62 and will emit the eos signal to the app.
64 Elements receiving the EOS event on a pad should not pull anymore
65 data from that pad (in case of a loop based element).
66 If the plugin cannot operate when it doesn't receive data on that
67 pad, the element should go to EOS too. It does this by pushing
68 any data it might still have, to the srcpad after which it
69 pushes an EOS event on thet pad and calls gst_element_set_eos().
71 The EOS event will typically originate from a source element, it
72 will eventually put all elements into the PAUSED state so that the
75 The EOS event is strictly a downstream event.
79 The discontinuous event is used to indicate a discontinuity in the
80 stream to downstream elements. A disctontinuity happens for the
83 - a source element is sending the first buffers of a stream.
84 - an element has performed a seek operation resulting in a
85 discontinuity in the data.
87 elements that receive a discontinuity event should flush any state
88 they might have and treat the new data as the start of new data.
89 Before sending out the new data the element must send a discont event
90 to the downstream element with at least a GST_FORMAT_TIME or
91 GST_FORMAT_BYTES as the format/value pair (see below).
93 a DISCONTINUOUS event has a flush flag. If that flag is set, the
94 element should also remove any buffered data it might have.
96 In addition to the flush flag, a DISCONTINUOUS event also caries up
97 to GST_DISCONTINUOUS_MAX_FORMATS format/value pairs. These values
98 might be used by the receiver of the event to resynchronize itself.
100 elements that are using a clock must take special actions upon
101 receiving the DISCONTINUOUS event: they must call
102 gst_clock_handle_discont() with the GST_FORMAT_TIME value of
105 The DISCONTINUOUS event is strictly a downstream event.
110 The seek event is used to reposition the upstream elements to
111 a new position in the media stream.
113 The seek event caries a bitwise-or of a GstFormat and a GstSeekType.
115 An element receiving the seek event on its srcpad should try to
116 reposition itself as closely to the requested location as possible.
117 if the ACCURATE flag is set and it cannot reposition itself with
118 absolute certainty, it should reposition itself well before the
119 requested position. If the ACCURATE flag is not set, the element
120 is free to choose a suitable position in the stream before or after
123 If the flush flag is set it should make sure that it pushes the
124 DISCONTINUOUS event the next time it is scheduled, clearing any
125 data it might have buffered.
127 The element is free to set the ACCURACY field in the event to notify
128 the originator of the event of the result. If no accuracy is set, it
131 The SEEK event is stricly an upstream event.
135 QoS is sent to indicate Quality of Service to the upstream element(s).
137 The QOS event is stricly an upstream event.
141 A plugin can send a flush event to its src or sink peer to clear the
142 buffered contents in the pipeline.
145 application generated events
146 ----------------------------
148 The application can insert events into the pipeline at arbirary
149 places. This is done by calling gst_pad_send_event() on a pad.
151 An application can also insert events on any element. The element
152 can implement its own handler for these events or it can use
153 the default handler, which simply forwards the event to the first
154 connected sinkpad of the element. Events to an element are send using
155 gst_element_send_event().
157 This first implementation only covers inserting events on src pads
158 since inserting events on sinkpads needs changes to the scheduler.
163 A flush event is used to clear any buffered data an element might
164 have. It is a downstream and upstream event.
166 Flush events are typically inserted into the pipeline by the app.
167 Elements that buffer data should implement an event handler on
168 both the sink and src pads it might have and respond to the flush
169 event by clearing all data they have buffered.
173 The application can insert the seek event into the pipeline on
174 a srcpad with gst_pad_send_event () or on an element with
175 gst_element_send_event().
177 The semantics of the seek parameters are described above.
183 All upstream events can occur outside the element's thread context.
184 It is not required to protect the element's data structures with
185 mutexes because in principal we don't support sending events to
186 a running threaded pipeline.
188 GstQueue in its current form will refuse to pass events upstream if
189 it is in the PLAYING state. Future versions might pass the event
190 on as soon as the element is scheduled again on the sinkpad.
192 An application cannot insert an event on an element that is PLAYING
193 in another thread context. It is therefore strongly recommended to
194 PAUSE the threaded pipeline before inserting an event.
200 1) filesrc ! fakesink
205 2) filesrc ! fakesink
207 The app wants to perform a seek on filesrc. It'll call the gst_pad_send_event()
208 on filesrcs src pad with the SEEK event type. The event handler will
209 react and change filesrcs internal status. filesrc will return a DISCONT
210 event before returning the buffer with the new offset.
212 3) filesrc ! mpeg2parse video_0! queue ! { mpeg2dec ! xvideosink }
214 lost of possibilities here: The app can choose to insert a seek event
215 on the filesrc element (byte offset), it can insert a byte/time offset
216 seek on the video_0 pad of mpeg2parse or it can insert a time seek event
217 on mpeg2decs src pad.
219 the event will travel upstream using the handlers and the intermediate
220 elements can convert the event from a time to a byte offset (possibly
221 using GstTimeCache to speed up things).
223 Filesrc will get a byte seek event on its src pad and will proceed as
226 As can be seen from this example the app will generate an event in another
227 context than those of the plugins, so this will need proper locking.
229 The app can also choose to insert a flush event on one of the src
230 pads. The plugins would clear their cached data and forward the event
231 to their upstream peer pad(s).
235 Insert impossible case here..