]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/blob - gst/gstevent.h
5427232aedf7bd9c55d820ae21d8af93ef27bde2
[glsdk/gstreamer0-10.git] / gst / gstevent.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wim.taymans@chello.be>
4  *
5  * gstevent.h: Header for GstEvent subsystem
6  *
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.
11  *
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.
16  *
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.
21  */
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>
32 G_BEGIN_DECLS
34 /**
35  * GstEventType:
36  * @GST_EVENT_UNKNOWN: 
37  * @GST_EVENT_EOS:
38  * @GST_EVENT_FLUSH:
39  * @GST_EVENT_DISCONTINUOUS:
40  * @GST_EVENT_QOS:
41  * @GST_EVENT_SEEK:
42  * @GST_EVENT_SIZE:
43  * @GST_EVENT_RATE:
44  * @GST_EVENT_NAVIGATION:
45  * @GST_EVENT_TAG:
46  */
47 typedef enum {
48   GST_EVENT_UNKNOWN             = 0,
49   GST_EVENT_EOS                 = 1,
50   GST_EVENT_FLUSH               = 2,
51   GST_EVENT_DISCONTINUOUS       = 3,
52   GST_EVENT_QOS                 = 4,
53   GST_EVENT_SEEK                = 5,
54   GST_EVENT_SIZE                = 8,
55   GST_EVENT_RATE                = 9,
56   GST_EVENT_NAVIGATION          = 10,
57   GST_EVENT_TAG                 = 11
58 } GstEventType;
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
86 typedef enum {
87   GST_EVENT_FLAG_NONE           = 0,
89   /* indicates negative rates are supported */
90   GST_RATE_FLAG_NEGATIVE        = (1 << 1)
91 } GstEventFlag;
93 typedef struct
94 {
95   GstEventType  type;
96   GstEventFlag  flags;
97 } GstEventMask;
99 /* seek events, extends GstEventFlag */
100 typedef enum {
101   /* | with some format */
102   /* | with one of these */
103   GST_SEEK_METHOD_CUR           = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
104   GST_SEEK_METHOD_SET           = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
105   GST_SEEK_METHOD_END           = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
107   /* | with optional seek flags */
108   /* seek flags */
109   GST_SEEK_FLAG_FLUSH           = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
110   GST_SEEK_FLAG_ACCURATE        = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
111   GST_SEEK_FLAG_KEY_UNIT        = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
112   GST_SEEK_FLAG_SEGMENT_LOOP    = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
113         
114 } GstSeekType;
116 typedef enum {
117   GST_SEEK_CERTAIN,
118   GST_SEEK_FUZZY
119 } GstSeekAccuracy;
121 typedef struct
123   GstFormat     format;
124   gint64        start_value;
125   gint64        end_value;
126 } GstFormatValue;
128 #define GST_EVENT_SEEK_TYPE(event)              (GST_EVENT(event)->event_data.seek.type)
129 #define GST_EVENT_SEEK_FORMAT(event)            (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FORMAT_MASK)
130 #define GST_EVENT_SEEK_METHOD(event)            (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_METHOD_MASK)
131 #define GST_EVENT_SEEK_FLAGS(event)             (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FLAGS_MASK)
132 #define GST_EVENT_SEEK_OFFSET(event)            (GST_EVENT(event)->event_data.seek.offset)
133 #define GST_EVENT_SEEK_ENDOFFSET(event)         (GST_EVENT(event)->event_data.seek.endoffset)
134 #define GST_EVENT_SEEK_ACCURACY(event)          (GST_EVENT(event)->event_data.seek.accuracy)
136 #define GST_EVENT_DISCONT_RATE(event)           (GST_EVENT(event)->event_data.discont.rate)
137 #define GST_EVENT_DISCONT_OFFSET(event,i)       (GST_EVENT(event)->event_data.discont.offsets[i])
138 #define GST_EVENT_DISCONT_OFFSET_LEN(event)     (GST_EVENT(event)->event_data.discont.noffsets)
140 #define GST_EVENT_FLUSH_DONE(event)             (GST_EVENT(event)->event_data.flush.done)
142 #define GST_EVENT_SIZE_FORMAT(event)            (GST_EVENT(event)->event_data.size.format)
143 #define GST_EVENT_SIZE_VALUE(event)             (GST_EVENT(event)->event_data.size.value)
145 #define GST_EVENT_RATE_VALUE(event)             (GST_EVENT(event)->event_data.rate.value)
147 struct _GstEvent {
148   GstMiniObject mini_object;
150   /*< public >*/ /* with COW */
151   GstEventType  type;
152   guint64       timestamp;
153   GstObject     *src;
155   union {
156     struct {
157       GstSeekType       type;
158       gint64            offset;
159       gint64            endoffset;
160       GstSeekAccuracy   accuracy;
161     } seek;
162     struct {
163       GstFormatValue    offsets[8];
164       gint              noffsets;
165       gdouble           rate;
166     } discont;
167     struct {
168       gboolean          done;
169     } flush;
170     struct {
171       GstFormat         format;
172       gint64            value;
173     } size;
174     struct {
175       gdouble           value;
176     } rate;
177     struct {
178       GstStructure      *structure;
179     } structure;
180   } event_data;
182   /*< private >*/
183   gpointer _gst_reserved[GST_PADDING];
184 };
186 struct _GstEventClass {
187   GstMiniObjectClass mini_object_class;
189   /*< private >*/
190   gpointer _gst_reserved[GST_PADDING];
191 };
193 void            _gst_event_initialize           (void);
194         
195 GType           gst_event_get_type              (void);
196 GstEvent*       gst_event_new                   (GstEventType type);
198 /* refcounting */
199 #define         gst_event_ref(ev)               GST_EVENT (gst_mini_object_ref (GST_MINI_OBJECT (ev)))
200 #define         gst_event_unref(ev)             gst_mini_object_unref (GST_MINI_OBJECT (ev))
201 /* copy buffer */
202 #define         gst_event_copy(ev)              GST_EVENT (gst_mini_object_copy (GST_MINI_OBJECT (ev)))
204 gboolean        gst_event_masks_contains        (const GstEventMask *masks, GstEventMask *mask);
206 /* seek event */
207 GstEvent*       gst_event_new_seek              (GstSeekType type, gint64 offset);
209 GstEvent*       gst_event_new_segment_seek      (GstSeekType type, gint64 start, gint64 stop);
212 /* size events */
213 GstEvent*       gst_event_new_size              (GstFormat format, gint64 value);
215 /* discontinous event */
216 GstEvent*       gst_event_new_discontinuous     (gdouble rate,
217                                                  GstFormat format1, ...);
218 GstEvent*       gst_event_new_discontinuous_valist      (gdouble rate,
219                                                  GstFormat format1,
220                                                  va_list var_args);
221 gboolean        gst_event_discont_get_value     (GstEvent *event, GstFormat format, 
222                                                  gint64 *start_value, gint64 *end_value);
224 #define         gst_event_new_filler()          gst_event_new(GST_EVENT_FILLER)
225 #define         gst_event_new_eos()             gst_event_new(GST_EVENT_EOS)
227 /* flush events */
228 GstEvent*       gst_event_new_flush             (gboolean done);
230 G_END_DECLS
232 #endif /* __GST_EVENT_H__ */