2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wim.taymans@chello.be>
4 * 2005 Wim Taymans <wim@fluendo.com>
6 * gstevent.h: Header for GstEvent subsystem
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
25 #ifndef __GST_EVENT_H__
26 #define __GST_EVENT_H__
28 #include <gst/gstminiobject.h>
29 #include <gst/gstformat.h>
30 #include <gst/gstobject.h>
31 #include <gst/gstclock.h>
32 #include <gst/gststructure.h>
33 #include <gst/gsttag.h>
37 /* bitmaks defining the direction */
38 #define GST_EVDIR_US (1 << 0)
39 #define GST_EVDIR_DS (1 << 1)
40 #define GST_EVDIR_BOTH GST_EVDIR_US | GST_EVDIR_DS
41 /* mask defining event is serialized with data */
42 #define GST_EVSER (1 << 2)
45 /* when making custom event types, use this macro with the num and
47 #define GST_EVENT_MAKE_TYPE(num,flags) (((num) << GST_EVSHIFT) | (flags))
51 * @GST_EVENT_UNKNOWN: unknown event.
52 * @GST_EVENT_FLUSH_START: Start a flush operation
53 * @GST_EVENT_FLUSH_STOP: Stop a flush operation
54 * @GST_EVENT_EOS: End-Of-Stream. No more data is to be expected to follow without
56 * @GST_EVENT_NEWSEGMENT: A new media segment follows in the dataflow.
57 * @GST_EVENT_TAG: A new set of metadata tags has been found in the stream.
58 * @GST_EVENT_FILLER: Filler for sparse data streams.
59 * @GST_EVENT_QOS: A quality message. Used to indicate to upstream elements that the downstream elements
60 * are being starved of or flooded with data.
61 * @GST_EVENT_SEEK: A request for a new playback position and rate.
62 * @GST_EVENT_NAVIGATION: Navigation events are usually used for communicating user
63 * requests, such as mouse or keyboard movements, to upstream elements.
64 * @GST_EVENT_CUSTOM_UP: Upstream custom event
65 * @GST_EVENT_CUSTOM_DS: Downstream custom event that travels in the data flow.
66 * @GST_EVENT_CUSTOM_DS_OOB: Custom out-of-band downstream event.
67 * @GST_EVENT_CUSTOM_BOTH: Custom upstream or downstream event. In-band when travelling downstream.
68 * @GST_EVENT_CUSTOM_BOTH_OOB: Custom upstream or downstream out-of-band event.
70 * GstEventType lists the standard event types that can be sent in a pipeline.
72 * The custom event types can be used for private messages between elements that can't be expressed using normal
73 * GStreamer buffer passing semantics. Custom events carry an arbitrary GstStructure.
74 * Specific custom events are distinguished by the name of the structure.
77 GST_EVENT_UNKNOWN = GST_EVENT_MAKE_TYPE (0, 0),
78 /* bidirectional events */
79 GST_EVENT_FLUSH_START = GST_EVENT_MAKE_TYPE (1, GST_EVDIR_BOTH),
80 GST_EVENT_FLUSH_STOP = GST_EVENT_MAKE_TYPE (2, GST_EVDIR_BOTH),
81 /* downstream serialized events */
82 GST_EVENT_EOS = GST_EVENT_MAKE_TYPE (3, GST_EVDIR_DS | GST_EVSER),
83 GST_EVENT_NEWSEGMENT = GST_EVENT_MAKE_TYPE (4, GST_EVDIR_DS | GST_EVSER),
84 GST_EVENT_TAG = GST_EVENT_MAKE_TYPE (5, GST_EVDIR_DS | GST_EVSER),
85 GST_EVENT_FILLER = GST_EVENT_MAKE_TYPE (6, GST_EVDIR_DS | GST_EVSER),
87 GST_EVENT_QOS = GST_EVENT_MAKE_TYPE (7, GST_EVDIR_US),
88 GST_EVENT_SEEK = GST_EVENT_MAKE_TYPE (8, GST_EVDIR_US),
89 GST_EVENT_NAVIGATION = GST_EVENT_MAKE_TYPE (9, GST_EVDIR_US),
91 /* custom events start here */
92 GST_EVENT_CUSTOM_UP = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_US),
93 GST_EVENT_CUSTOM_DS = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_DS | GST_EVSER),
94 GST_EVENT_CUSTOM_DS_OOB = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_DS),
95 GST_EVENT_CUSTOM_BOTH = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_BOTH | GST_EVSER),
96 GST_EVENT_CUSTOM_BOTH_OOB = GST_EVENT_MAKE_TYPE (32, GST_EVDIR_BOTH)
100 * GST_EVENT_TRACE_NAME:
102 * The name used for memory allocation tracing
104 #define GST_EVENT_TRACE_NAME "GstEvent"
106 typedef struct _GstEvent GstEvent;
107 typedef struct _GstEventClass GstEventClass;
109 #define GST_TYPE_EVENT (gst_event_get_type())
110 #define GST_IS_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_EVENT))
111 #define GST_IS_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_EVENT))
112 #define GST_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EVENT, GstEventClass))
113 #define GST_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EVENT, GstEvent))
114 #define GST_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EVENT, GstEventClass))
118 * @event: the event to query
120 * Get the event type.
122 * Returns: the #GstEventType of the given event
124 #define GST_EVENT_TYPE(event) (GST_EVENT(event)->type)
126 * GST_EVENT_TIMESTAMP:
127 * @event: the event to query
129 * Get the timestamp of the event.
131 * Returns: the timestamp of the given event
133 #define GST_EVENT_TIMESTAMP(event) (GST_EVENT(event)->timestamp)
136 * @event: the event to query
138 * The source object that generated this event.
140 * Returns: the source #GstObject for the given event
142 #define GST_EVENT_SRC(event) (GST_EVENT(event)->src)
144 #define GST_EVENT_IS_UPSTREAM(ev) !!(GST_EVENT_TYPE (ev) & GST_EVDIR_US)
145 #define GST_EVENT_IS_DOWNSTREAM(ev) !!(GST_EVENT_TYPE (ev) & GST_EVDIR_DS)
146 #define GST_EVENT_IS_SERIALIZED(ev) !!(GST_EVENT_TYPE (ev) & GST_EVSER)
150 * @GST_SEEK_TYPE_NONE: no change in position is required
151 * @GST_SEEK_TYPE_CUR: change relative to current position
152 * @GST_SEEK_TYPE_SET: absolute position is requested
153 * @GST_SEEK_TYPE_END: relative position to duration is requested
155 * The different types of seek events. When constructing a seek event a format,
156 * a seek method and optional flags are OR-ed together. The seek event is then
157 * inserted into the graph with #gst_pad_send_event() or
158 * #gst_element_send_event().
160 * Following example illustrates how to insert a seek event (1 second in the stream)
163 * <title>Insertion of a seek event into a pipeline</title>
168 * event = gst_event_new_seek (
169 * GST_FORMAT_TIME | // seek on time
170 * GST_SEEK_METHOD_SET | // set the absolute position
171 * GST_SEEK_FLAG_FLUSH, // flush any pending data
172 * 1 * GST_SECOND); // the seek offset (1 second)
174 * res = gst_element_send_event (GST_ELEMENT (osssink), event);
176 * g_warning ("seek failed");
183 GST_SEEK_TYPE_NONE = 0,
184 GST_SEEK_TYPE_CUR = 1,
185 GST_SEEK_TYPE_SET = 2,
186 GST_SEEK_TYPE_END = 3
191 * @GST_SEEK_FLAG_NONE: no flag
192 * @GST_SEEK_FLAG_FLUSH: flush pipeline
193 * @GST_SEEK_FLAG_ACCURATE: accurate position is requested, this might
194 * be slower for some formats.
195 * @GST_SEEK_FLAG_KEY_UNIT: seek to the nearest keyframe. This might be
196 * faster but less accurate.
197 * @GST_SEEK_FLAG_SEGMENT: perform a segment seek. After the playback
198 * of the segment completes, no EOS will be emmited but a
199 * SEGMENT_DONE message will be posted on the bus.
202 GST_SEEK_FLAG_NONE = 0,
203 GST_SEEK_FLAG_FLUSH = (1 << 0),
204 GST_SEEK_FLAG_ACCURATE = (1 << 1),
205 GST_SEEK_FLAG_KEY_UNIT = (1 << 2),
206 GST_SEEK_FLAG_SEGMENT = (1 << 3)
210 GstMiniObject mini_object;
212 /*< public >*/ /* with COW */
217 GstStructure *structure;
220 gpointer _gst_reserved[GST_PADDING];
223 struct _GstEventClass {
224 GstMiniObjectClass mini_object_class;
227 gpointer _gst_reserved[GST_PADDING];
230 void _gst_event_initialize (void);
232 GType gst_event_get_type (void);
237 * @ev: The event to refcount
239 * Increase the refcount of this event.
241 #define gst_event_ref(ev) GST_EVENT (gst_mini_object_ref (GST_MINI_OBJECT (ev)))
244 * @ev: The event to refcount
246 * Decrease the refcount of an event, freeing it if the refcount reaches 0.
248 #define gst_event_unref(ev) gst_mini_object_unref (GST_MINI_OBJECT (ev))
253 * @ev: The event to copy
255 * Copy the event using the event specific copy function.
257 * Returns: A new event that is a copy of the given input event
259 #define gst_event_copy(ev) GST_EVENT (gst_mini_object_copy (GST_MINI_OBJECT (ev)))
262 GstEvent* gst_event_new_custom (GstEventType type, GstStructure *structure);
265 gst_event_get_structure (GstEvent *event);
268 GstEvent * gst_event_new_flush_start (void);
269 GstEvent * gst_event_new_flush_stop (void);
272 GstEvent * gst_event_new_eos (void);
274 /* newsegment events */
275 GstEvent* gst_event_new_newsegment (gdouble rate,
276 GstFormat format, gint64 start_value, gint64 stop_value,
278 void gst_event_parse_newsegment (GstEvent *event, gdouble *rate, GstFormat *format,
279 gint64 *start_value, gint64 *end_value, gint64 *base);
281 GstEvent* gst_event_new_tag (GstTagList *taglist);
282 void gst_event_parse_tag (GstEvent *event, GstTagList **taglist);
285 /* FIXME: FILLER events need to be fully specified and implemented */
286 GstEvent * gst_event_new_filler (void);
290 /* FIXME: QOS events need to be fully specified and implemented */
291 GstEvent* gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff,
292 GstClockTime timestamp);
293 void gst_event_parse_qos (GstEvent *event, gdouble *proportion, GstClockTimeDiff *diff,
294 GstClockTime *timestamp);
296 GstEvent* gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags,
297 GstSeekType cur_type, gint64 cur,
298 GstSeekType stop_type, gint64 stop);
299 void gst_event_parse_seek (GstEvent *event, gdouble *rate, GstFormat *format,
301 GstSeekType *cur_type, gint64 *cur,
302 GstSeekType *stop_type, gint64 *stop);
303 /* navigation event */
304 GstEvent* gst_event_new_navigation (GstStructure *structure);
308 #endif /* __GST_EVENT_H__ */