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/gsttypes.h>
28 #include <gst/gstdata.h>
29 #include <gst/gstformat.h>
30 #include <gst/gstobject.h>
31 #include <gst/gststructure.h>
35 GST_EXPORT GType _gst_event_type;
38 GST_EVENT_UNKNOWN = 0,
42 GST_EVENT_DISCONTINUOUS = 4,
43 /*GST_EVENT_NEW_MEDIA = 5, <- removed */
46 GST_EVENT_SEEK_SEGMENT = 8,
47 GST_EVENT_SEGMENT_DONE = 9,
50 GST_EVENT_FILLER = 12,
51 GST_EVENT_TS_OFFSET = 13,
52 GST_EVENT_INTERRUPT = 14,
53 GST_EVENT_NAVIGATION = 15,
56 #define GST_EVENT_ANY GST_EVENT_NAVIGATION
58 #define GST_EVENT_TRACE_NAME "GstEvent"
60 #define GST_TYPE_EVENT (_gst_event_type)
61 #define GST_EVENT(event) ((GstEvent*)(event))
62 #define GST_IS_EVENT(event) (GST_DATA_TYPE(event) == GST_TYPE_EVENT)
64 #define GST_EVENT_TYPE(event) (GST_EVENT(event)->type)
65 #define GST_EVENT_TIMESTAMP(event) (GST_EVENT(event)->timestamp)
66 #define GST_EVENT_SRC(event) (GST_EVENT(event)->src)
68 #define GST_EVENT_IS_INTERRUPT(event) (GST_EVENT_TYPE (event) == GST_EVENT_INTERRUPT)
70 #define GST_SEEK_FORMAT_SHIFT 0
71 #define GST_SEEK_METHOD_SHIFT 16
72 #define GST_SEEK_FLAGS_SHIFT 20
73 #define GST_SEEK_FORMAT_MASK 0x0000ffff
74 #define GST_SEEK_METHOD_MASK 0x000f0000
75 #define GST_SEEK_FLAGS_MASK 0xfff00000
78 GST_EVENT_FLAG_NONE = 0,
80 /* indicates negative rates are supported */
81 GST_RATE_FLAG_NEGATIVE = (1 << 1)
90 #ifndef GST_DISABLE_DEPRECATED
91 #ifdef G_HAVE_ISO_VARARGS
92 #define GST_EVENT_MASK_FUNCTION(type,functionname, ...) \
93 static const GstEventMask* \
94 functionname (type pad) \
96 static const GstEventMask masks[] = { \
102 #elif defined(G_HAVE_GNUC_VARARGS)
103 #define GST_EVENT_MASK_FUNCTION(type,functionname, a...) \
104 static const GstEventMask* \
105 functionname (type pad) \
107 static const GstEventMask masks[] = { \
116 /* seek events, extends GstEventFlag */
118 /* | with some format */
119 /* | with one of these */
120 GST_SEEK_METHOD_CUR = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
121 GST_SEEK_METHOD_SET = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
122 GST_SEEK_METHOD_END = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
124 /* | with optional seek flags */
126 GST_SEEK_FLAG_FLUSH = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
127 GST_SEEK_FLAG_ACCURATE = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
128 GST_SEEK_FLAG_KEY_UNIT = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
129 GST_SEEK_FLAG_SEGMENT_LOOP = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
144 #define GST_EVENT_SEEK_TYPE(event) (GST_EVENT(event)->event_data.seek.type)
145 #define GST_EVENT_SEEK_FORMAT(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FORMAT_MASK)
146 #define GST_EVENT_SEEK_METHOD(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_METHOD_MASK)
147 #define GST_EVENT_SEEK_FLAGS(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FLAGS_MASK)
148 #define GST_EVENT_SEEK_OFFSET(event) (GST_EVENT(event)->event_data.seek.offset)
149 #define GST_EVENT_SEEK_ENDOFFSET(event) (GST_EVENT(event)->event_data.seek.endoffset)
150 #define GST_EVENT_SEEK_ACCURACY(event) (GST_EVENT(event)->event_data.seek.accuracy)
152 #define GST_EVENT_DISCONT_NEW_MEDIA(event) (GST_EVENT(event)->event_data.discont.new_media)
153 #define GST_EVENT_DISCONT_OFFSET(event,i) (GST_EVENT(event)->event_data.discont.offsets[i])
154 #define GST_EVENT_DISCONT_OFFSET_LEN(event) (GST_EVENT(event)->event_data.discont.noffsets)
156 #define GST_EVENT_SIZE_FORMAT(event) (GST_EVENT(event)->event_data.size.format)
157 #define GST_EVENT_SIZE_VALUE(event) (GST_EVENT(event)->event_data.size.value)
159 #define GST_EVENT_RATE_VALUE(event) (GST_EVENT(event)->event_data.rate.value)
164 /*< public >*/ /* with COW */
174 GstSeekAccuracy accuracy;
177 GstFormatValue offsets[8];
189 GstStructure *structure;
194 gpointer _gst_reserved[GST_PADDING];
197 void _gst_event_initialize (void);
199 GType gst_event_get_type (void);
200 GstEvent* gst_event_new (GstEventType type);
203 #define gst_event_ref(ev) GST_EVENT (gst_data_ref (GST_DATA (ev)))
204 #define gst_event_ref_by_count(ev,c) GST_EVENT (gst_data_ref_by_count (GST_DATA (ev), c))
205 #define gst_event_unref(ev) gst_data_unref (GST_DATA (ev))
207 #define gst_event_copy(ev) GST_EVENT (gst_data_copy (GST_DATA (ev)))
209 gboolean gst_event_masks_contains (const GstEventMask *masks, GstEventMask *mask);
212 GstEvent* gst_event_new_seek (GstSeekType type, gint64 offset);
214 GstEvent* gst_event_new_segment_seek (GstSeekType type, gint64 start, gint64 stop);
218 GstEvent* gst_event_new_size (GstFormat format, gint64 value);
220 /* discontinous event */
221 GstEvent* gst_event_new_discontinuous (gboolean new_media,
222 GstFormat format1, ...);
223 GstEvent* gst_event_new_discontinuous_valist (gboolean new_media,
226 gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value);
228 #define gst_event_new_filler() gst_event_new(GST_EVENT_FILLER)
229 GstEvent* gst_event_new_filler_stamped (guint64 time,
231 guint64 gst_event_filler_get_duration (GstEvent *event);
234 #define gst_event_new_flush() gst_event_new(GST_EVENT_FLUSH)
238 #endif /* __GST_EVENT_H__ */