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>
35 GST_EVENT_UNKNOWN = 0,
39 GST_EVENT_DISCONTINUOUS = 4,
40 GST_EVENT_NEW_MEDIA = 5,
43 GST_EVENT_SEEK_SEGMENT = 8,
44 GST_EVENT_SEGMENT_DONE = 9,
47 GST_EVENT_FILLER = 12,
48 GST_EVENT_TS_OFFSET = 13,
49 GST_EVENT_INTERRUPT = 14
52 extern GType _gst_event_type;
54 #define GST_EVENT_TRACE_NAME "GstEvent"
56 #define GST_TYPE_EVENT (_gst_event_type)
57 #define GST_EVENT(event) ((GstEvent*)(event))
58 #define GST_IS_EVENT(event) (GST_DATA_TYPE(event) == GST_TYPE_EVENT)
60 #define GST_EVENT_TYPE(event) (GST_EVENT(event)->type)
61 #define GST_EVENT_TIMESTAMP(event) (GST_EVENT(event)->timestamp)
62 #define GST_EVENT_SRC(event) (GST_EVENT(event)->src)
64 #define GST_EVENT_IS_INTERRUPT(event) (GST_EVENT_TYPE (event) == GST_EVENT_INTERRUPT)
66 #define GST_SEEK_FORMAT_SHIFT 0
67 #define GST_SEEK_METHOD_SHIFT 16
68 #define GST_SEEK_FLAGS_SHIFT 20
69 #define GST_SEEK_FORMAT_MASK 0x0000ffff
70 #define GST_SEEK_METHOD_MASK 0x000f0000
71 #define GST_SEEK_FLAGS_MASK 0xfff00000
74 GST_EVENT_FLAG_NONE = 0,
76 /* indicates negative rates are supported */
77 GST_RATE_FLAG_NEGATIVE = (1 << 1)
86 #ifdef G_HAVE_ISO_VARARGS
87 #define GST_EVENT_MASK_FUNCTION(type,functionname, ...) \
88 static const GstEventMask* \
89 functionname (type pad) \
91 static const GstEventMask masks[] = { \
97 #elif defined(G_HAVE_GNUC_VARARGS)
98 #define GST_EVENT_MASK_FUNCTION(type,functionname, a...) \
99 static const GstEventMask* \
100 functionname (type pad) \
102 static const GstEventMask masks[] = { \
110 /* seek events, extends GstEventFlag */
112 /* | with some format */
113 /* | with one of these */
114 GST_SEEK_METHOD_CUR = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
115 GST_SEEK_METHOD_SET = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
116 GST_SEEK_METHOD_END = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
118 /* | with optional seek flags */
120 GST_SEEK_FLAG_FLUSH = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
121 GST_SEEK_FLAG_ACCURATE = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
122 GST_SEEK_FLAG_KEY_UNIT = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
123 GST_SEEK_FLAG_SEGMENT_LOOP = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
138 #define GST_EVENT_SEEK_TYPE(event) (GST_EVENT(event)->event_data.seek.type)
139 #define GST_EVENT_SEEK_FORMAT(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FORMAT_MASK)
140 #define GST_EVENT_SEEK_METHOD(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_METHOD_MASK)
141 #define GST_EVENT_SEEK_FLAGS(event) (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FLAGS_MASK)
142 #define GST_EVENT_SEEK_OFFSET(event) (GST_EVENT(event)->event_data.seek.offset)
143 #define GST_EVENT_SEEK_ENDOFFSET(event) (GST_EVENT(event)->event_data.seek.endoffset)
144 #define GST_EVENT_SEEK_ACCURACY(event) (GST_EVENT(event)->event_data.seek.accuracy)
146 #define GST_EVENT_DISCONT_NEW_MEDIA(event) (GST_EVENT(event)->event_data.discont.new_media)
147 #define GST_EVENT_DISCONT_OFFSET(event,i) (GST_EVENT(event)->event_data.discont.offsets[i])
148 #define GST_EVENT_DISCONT_OFFSET_LEN(event) (GST_EVENT(event)->event_data.discont.noffsets)
150 #define GST_EVENT_SIZE_FORMAT(event) (GST_EVENT(event)->event_data.size.format)
151 #define GST_EVENT_SIZE_VALUE(event) (GST_EVENT(event)->event_data.size.value)
153 #define GST_EVENT_RATE_VALUE(event) (GST_EVENT(event)->event_data.rate.value)
167 GstSeekAccuracy accuracy;
170 GstFormatValue offsets[8];
184 void _gst_event_initialize (void);
186 GType gst_event_get_type (void);
187 GstEvent* gst_event_new (GstEventType type);
190 #define gst_event_ref(ev) GST_EVENT (gst_data_ref (GST_DATA (ev)))
191 #define gst_event_ref_by_count(ev,c) GST_EVENT (gst_data_ref_by_count (GST_DATA (ev), c))
192 #define gst_event_unref(ev) gst_data_unref (GST_DATA (ev))
194 #define gst_event_copy(ev) GST_EVENT (gst_data_copy (GST_DATA (ev)))
196 gboolean gst_event_masks_contains (const GstEventMask *masks, GstEventMask *mask);
199 GstEvent* gst_event_new_seek (GstSeekType type, gint64 offset);
201 GstEvent* gst_event_new_segment_seek (GstSeekType type, gint64 start, gint64 stop);
205 GstEvent* gst_event_new_size (GstFormat format, gint64 value);
207 /* discontinous event */
208 GstEvent* gst_event_new_discontinuous (gboolean new_media,
209 GstFormat format1, ...);
210 gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value);
211 gboolean gst_event_has_new_media (GstEvent *event);
213 #define gst_event_new_filler() gst_event_new(GST_EVENT_FILLER)
216 #define gst_event_new_flush() gst_event_new(GST_EVENT_FLUSH)
220 #endif /* __GST_EVENT_H__ */