2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wim.taymans@chello.be>
5 * gstevent.h: Header for GstEvent subsystem
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 #ifndef __GST_EVENT_H__
25 #define __GST_EVENT_H__
27 #include <gst/gstminiobject.h>
28 #include <gst/gstformat.h>
29 #include <gst/gstobject.h>
30 #include <gst/gststructure.h>
39 * @GST_EVENT_DISCONTINUOUS:
44 * @GST_EVENT_NAVIGATION:
48 GST_EVENT_UNKNOWN = 0,
51 GST_EVENT_DISCONTINUOUS = 3,
56 GST_EVENT_NAVIGATION = 10,
59 #define GST_EVENT_ANY GST_EVENT_NAVIGATION
61 #define GST_EVENT_TRACE_NAME "GstEvent"
63 typedef struct _GstEvent GstEvent;
64 typedef struct _GstEventClass GstEventClass;
66 #define GST_TYPE_EVENT (gst_event_get_type())
67 #define GST_IS_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_EVENT))
68 #define GST_IS_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_EVENT))
69 #define GST_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EVENT, GstEventClass))
70 #define GST_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EVENT, GstEvent))
71 #define GST_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EVENT, GstEventClass))
73 #define GST_EVENT_TYPE(event) (GST_EVENT(event)->type)
74 #define GST_EVENT_TIMESTAMP(event) (GST_EVENT(event)->timestamp)
75 #define GST_EVENT_SRC(event) (GST_EVENT(event)->src)
77 #define GST_EVENT_IS_INTERRUPT(event) (GST_EVENT_TYPE (event) == GST_EVENT_INTERRUPT)
79 #define GST_SEEK_FORMAT_SHIFT 0
80 #define GST_SEEK_METHOD_SHIFT 16
81 #define GST_SEEK_FLAGS_SHIFT 20
82 #define GST_SEEK_FORMAT_MASK 0x0000ffff
83 #define GST_SEEK_METHOD_MASK 0x000f0000
84 #define GST_SEEK_FLAGS_MASK 0xfff00000
87 GST_EVENT_FLAG_NONE = 0,
89 /* indicates negative rates are supported */
90 GST_RATE_FLAG_NEGATIVE = (1 << 1)
99 #ifdef G_HAVE_ISO_VARARGS
100 #define GST_EVENT_MASK_FUNCTION(type,functionname, ...) \
101 static const GstEventMask* \
102 functionname (type pad) \
104 static const GstEventMask masks[] = { \
110 #elif defined(G_HAVE_GNUC_VARARGS)
111 #define GST_EVENT_MASK_FUNCTION(type,functionname, a...) \
112 static const GstEventMask* \
113 functionname (type pad) \
115 static const GstEventMask masks[] = { \
123 /* seek events, extends GstEventFlag */
125 /* | with some format */
126 /* | with one of these */
127 GST_SEEK_METHOD_CUR = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
128 GST_SEEK_METHOD_SET = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
129 GST_SEEK_METHOD_END = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
131 /* | with optional seek flags */
133 GST_SEEK_FLAG_FLUSH = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
134 GST_SEEK_FLAG_ACCURATE = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
135 GST_SEEK_FLAG_KEY_UNIT = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
136 GST_SEEK_FLAG_SEGMENT_LOOP = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
152 #define GST_EVENT_SEEK_TYPE(event) (GST_EVENT(event)->event_data.seek.type)
153 #define GST_EVENT_SEEK_FORMAT(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FORMAT_MASK)
154 #define GST_EVENT_SEEK_METHOD(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_METHOD_MASK)
155 #define GST_EVENT_SEEK_FLAGS(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FLAGS_MASK)
156 #define GST_EVENT_SEEK_OFFSET(event) (GST_EVENT(event)->event_data.seek.offset)
157 #define GST_EVENT_SEEK_ENDOFFSET(event) (GST_EVENT(event)->event_data.seek.endoffset)
158 #define GST_EVENT_SEEK_ACCURACY(event) (GST_EVENT(event)->event_data.seek.accuracy)
160 #define GST_EVENT_DISCONT_RATE(event) (GST_EVENT(event)->event_data.discont.rate)
161 #define GST_EVENT_DISCONT_OFFSET(event,i) (GST_EVENT(event)->event_data.discont.offsets[i])
162 #define GST_EVENT_DISCONT_OFFSET_LEN(event) (GST_EVENT(event)->event_data.discont.noffsets)
164 #define GST_EVENT_FLUSH_DONE(event) (GST_EVENT(event)->event_data.flush.done)
166 #define GST_EVENT_SIZE_FORMAT(event) (GST_EVENT(event)->event_data.size.format)
167 #define GST_EVENT_SIZE_VALUE(event) (GST_EVENT(event)->event_data.size.value)
169 #define GST_EVENT_RATE_VALUE(event) (GST_EVENT(event)->event_data.rate.value)
172 GstMiniObject mini_object;
174 /*< public >*/ /* with COW */
184 GstSeekAccuracy accuracy;
187 GstFormatValue offsets[8];
202 GstStructure *structure;
207 gpointer _gst_reserved[GST_PADDING];
210 struct _GstEventClass {
211 GstMiniObjectClass mini_object_class;
214 gpointer _gst_reserved[GST_PADDING];
217 void _gst_event_initialize (void);
219 GType gst_event_get_type (void);
220 GstEvent* gst_event_new (GstEventType type);
223 #define gst_event_ref(ev) GST_EVENT (gst_mini_object_ref (GST_MINI_OBJECT (ev)))
224 #define gst_event_unref(ev) gst_mini_object_unref (GST_MINI_OBJECT (ev))
226 #define gst_event_copy(ev) GST_EVENT (gst_mini_object_copy (GST_MINI_OBJECT (ev)))
228 gboolean gst_event_masks_contains (const GstEventMask *masks, GstEventMask *mask);
231 GstEvent* gst_event_new_seek (GstSeekType type, gint64 offset);
233 GstEvent* gst_event_new_segment_seek (GstSeekType type, gint64 start, gint64 stop);
237 GstEvent* gst_event_new_size (GstFormat format, gint64 value);
239 /* discontinous event */
240 GstEvent* gst_event_new_discontinuous (gdouble rate,
241 GstFormat format1, ...);
242 GstEvent* gst_event_new_discontinuous_valist (gdouble rate,
245 gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format,
246 gint64 *start_value, gint64 *end_value);
248 #define gst_event_new_filler() gst_event_new(GST_EVENT_FILLER)
249 #define gst_event_new_eos() gst_event_new(GST_EVENT_EOS)
252 GstEvent* gst_event_new_flush (gboolean done);
256 #endif /* __GST_EVENT_H__ */