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>
36 GST_EVENT_UNKNOWN = 0,
40 GST_EVENT_DISCONTINUOUS = 4,
41 /*GST_EVENT_NEW_MEDIA = 5, <- removed */
44 GST_EVENT_SEEK_SEGMENT = 8,
45 GST_EVENT_SEGMENT_DONE = 9,
48 GST_EVENT_FILLER = 12,
49 GST_EVENT_TS_OFFSET = 13,
50 GST_EVENT_INTERRUPT = 14,
51 GST_EVENT_NAVIGATION = 15,
55 extern GType _gst_event_type;
57 #define GST_EVENT_TRACE_NAME "GstEvent"
59 #define GST_TYPE_EVENT (_gst_event_type)
60 #define GST_EVENT(event) ((GstEvent*)(event))
61 #define GST_IS_EVENT(event) (GST_DATA_TYPE(event) == GST_TYPE_EVENT)
63 #define GST_EVENT_TYPE(event) (GST_EVENT(event)->type)
64 #define GST_EVENT_TIMESTAMP(event) (GST_EVENT(event)->timestamp)
65 #define GST_EVENT_SRC(event) (GST_EVENT(event)->src)
67 #define GST_EVENT_IS_INTERRUPT(event) (GST_EVENT_TYPE (event) == GST_EVENT_INTERRUPT)
69 #define GST_SEEK_FORMAT_SHIFT 0
70 #define GST_SEEK_METHOD_SHIFT 16
71 #define GST_SEEK_FLAGS_SHIFT 20
72 #define GST_SEEK_FORMAT_MASK 0x0000ffff
73 #define GST_SEEK_METHOD_MASK 0x000f0000
74 #define GST_SEEK_FLAGS_MASK 0xfff00000
77 GST_EVENT_FLAG_NONE = 0,
79 /* indicates negative rates are supported */
80 GST_RATE_FLAG_NEGATIVE = (1 << 1)
89 #ifdef G_HAVE_ISO_VARARGS
90 #define GST_EVENT_MASK_FUNCTION(type,functionname, ...) \
91 static const GstEventMask* \
92 functionname (type pad) \
94 static const GstEventMask masks[] = { \
100 #elif defined(G_HAVE_GNUC_VARARGS)
101 #define GST_EVENT_MASK_FUNCTION(type,functionname, a...) \
102 static const GstEventMask* \
103 functionname (type pad) \
105 static const GstEventMask masks[] = { \
113 /* seek events, extends GstEventFlag */
115 /* | with some format */
116 /* | with one of these */
117 GST_SEEK_METHOD_CUR = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
118 GST_SEEK_METHOD_SET = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
119 GST_SEEK_METHOD_END = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
121 /* | with optional seek flags */
123 GST_SEEK_FLAG_FLUSH = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
124 GST_SEEK_FLAG_ACCURATE = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
125 GST_SEEK_FLAG_KEY_UNIT = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
126 GST_SEEK_FLAG_SEGMENT_LOOP = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
141 #define GST_EVENT_SEEK_TYPE(event) (GST_EVENT(event)->event_data.seek.type)
142 #define GST_EVENT_SEEK_FORMAT(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FORMAT_MASK)
143 #define GST_EVENT_SEEK_METHOD(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_METHOD_MASK)
144 #define GST_EVENT_SEEK_FLAGS(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FLAGS_MASK)
145 #define GST_EVENT_SEEK_OFFSET(event) (GST_EVENT(event)->event_data.seek.offset)
146 #define GST_EVENT_SEEK_ENDOFFSET(event) (GST_EVENT(event)->event_data.seek.endoffset)
147 #define GST_EVENT_SEEK_ACCURACY(event) (GST_EVENT(event)->event_data.seek.accuracy)
149 #define GST_EVENT_DISCONT_NEW_MEDIA(event) (GST_EVENT(event)->event_data.discont.new_media)
150 #define GST_EVENT_DISCONT_OFFSET(event,i) (GST_EVENT(event)->event_data.discont.offsets[i])
151 #define GST_EVENT_DISCONT_OFFSET_LEN(event) (GST_EVENT(event)->event_data.discont.noffsets)
153 #define GST_EVENT_SIZE_FORMAT(event) (GST_EVENT(event)->event_data.size.format)
154 #define GST_EVENT_SIZE_VALUE(event) (GST_EVENT(event)->event_data.size.value)
156 #define GST_EVENT_RATE_VALUE(event) (GST_EVENT(event)->event_data.rate.value)
170 GstSeekAccuracy accuracy;
173 GstFormatValue offsets[8];
185 GstStructure *structure;
189 gpointer _gst_reserved[GST_PADDING];
192 void _gst_event_initialize (void);
194 GType gst_event_get_type (void);
195 GstEvent* gst_event_new (GstEventType type);
198 #define gst_event_ref(ev) GST_EVENT (gst_data_ref (GST_DATA (ev)))
199 #define gst_event_ref_by_count(ev,c) GST_EVENT (gst_data_ref_by_count (GST_DATA (ev), c))
200 #define gst_event_unref(ev) gst_data_unref (GST_DATA (ev))
202 #define gst_event_copy(ev) GST_EVENT (gst_data_copy (GST_DATA (ev)))
204 gboolean gst_event_masks_contains (const GstEventMask *masks, GstEventMask *mask);
207 GstEvent* gst_event_new_seek (GstSeekType type, gint64 offset);
209 GstEvent* gst_event_new_segment_seek (GstSeekType type, gint64 start, gint64 stop);
213 GstEvent* gst_event_new_size (GstFormat format, gint64 value);
215 /* discontinous event */
216 GstEvent* gst_event_new_discontinuous (gboolean new_media,
217 GstFormat format1, ...);
218 GstEvent* gst_event_new_discontinuous_valist (gboolean new_media,
221 gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value);
223 #define gst_event_new_filler() gst_event_new(GST_EVENT_FILLER)
226 #define gst_event_new_flush() gst_event_new(GST_EVENT_FLUSH)
230 #endif /* __GST_EVENT_H__ */