gstevent.h 22 KB
Newer Older
Erik Walthinsen's avatar
Erik Walthinsen committed
1 2 3
/* GStreamer
 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
 *                    2000 Wim Taymans <wim.taymans@chello.be>
Wim Taymans's avatar
Wim Taymans committed
4
 *                    2005 Wim Taymans <wim@fluendo.com>
Erik Walthinsen's avatar
Erik Walthinsen committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * gstevent.h: Header for GstEvent subsystem
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */


#ifndef __GST_EVENT_H__
#define __GST_EVENT_H__

Wim Taymans's avatar
Wim Taymans committed
28 29
typedef struct _GstEvent GstEvent;

Wim Taymans's avatar
Wim Taymans committed
30
/**
31
 * GstEventTypeFlags:
Wim Taymans's avatar
Wim Taymans committed
32 33 34 35 36 37 38
 * @GST_EVENT_TYPE_UPSTREAM:     Set if the event can travel upstream.
 * @GST_EVENT_TYPE_DOWNSTREAM:   Set if the event can travel downstream.
 * @GST_EVENT_TYPE_SERIALIZED:   Set if the event should be serialized with data
 *                               flow.
 * @GST_EVENT_TYPE_STICKY:       Set if the event is sticky on the pads.
 * @GST_EVENT_TYPE_STICKY_MULTI: Multiple sticky events can be on a pad, each
 *                               identified by the event name.
Wim Taymans's avatar
Wim Taymans committed
39
 *
40 41 42
 * #GstEventTypeFlags indicate the aspects of the different #GstEventType
 * values. You can get the type flags of a #GstEventType with the
 * gst_event_type_get_flags() function.
Wim Taymans's avatar
Wim Taymans committed
43
 */
44
typedef enum {
Wim Taymans's avatar
Wim Taymans committed
45 46
  GST_EVENT_TYPE_UPSTREAM       = 1 << 0,
  GST_EVENT_TYPE_DOWNSTREAM     = 1 << 1,
47
  GST_EVENT_TYPE_SERIALIZED     = 1 << 2,
Wim Taymans's avatar
Wim Taymans committed
48 49
  GST_EVENT_TYPE_STICKY         = 1 << 3,
  GST_EVENT_TYPE_STICKY_MULTI   = 1 << 4
50 51
} GstEventTypeFlags;

Wim Taymans's avatar
Wim Taymans committed
52
/**
53
 * GST_EVENT_TYPE_BOTH:
Wim Taymans's avatar
Wim Taymans committed
54
 *
55
 * The same thing as #GST_EVENT_TYPE_UPSTREAM | #GST_EVENT_TYPE_DOWNSTREAM.
Wim Taymans's avatar
Wim Taymans committed
56
 */
57 58 59
#define GST_EVENT_TYPE_BOTH \
    (GST_EVENT_TYPE_UPSTREAM | GST_EVENT_TYPE_DOWNSTREAM)

60
#define GST_EVENT_NUM_SHIFT     (8)
Wim Taymans's avatar
Wim Taymans committed
61

Wim Taymans's avatar
Wim Taymans committed
62 63 64 65 66 67 68 69
/**
 * GST_EVENT_MAKE_TYPE:
 * @num: the event number to create
 * @flags: the event flags
 *
 * when making custom event types, use this macro with the num and
 * the given flags
 */
70 71
#define GST_EVENT_MAKE_TYPE(num,flags) \
    (((num) << GST_EVENT_NUM_SHIFT) | (flags))
72 73

#define FLAG(name) GST_EVENT_TYPE_##name
Wim Taymans's avatar
Wim Taymans committed
74

Wim Taymans's avatar
Wim Taymans committed
75 76
/**
 * GstEventType:
Wim Taymans's avatar
Wim Taymans committed
77
 * @GST_EVENT_UNKNOWN: unknown event.
78 79 80 81
 * @GST_EVENT_FLUSH_START: Start a flush operation. This event clears all data
 *                 from the pipeline and unblock all streaming threads.
 * @GST_EVENT_FLUSH_STOP: Stop a flush operation. This event resets the
 *                 running-time of the pipeline.
82 83 84
 * @GST_EVENT_STREAM_START: Event to mark the start of a new stream. Sent before any
 *                 other serialized event and only sent at the start of a new stream,
 *                 not after flushing seeks.
Wim Taymans's avatar
Wim Taymans committed
85
 * @GST_EVENT_CAPS: #GstCaps event. Notify the pad of a new media type.
86 87
 * @GST_EVENT_STREAM_CONFIG: contains configuration information for the stream,
 *                 for example stream-headers and codec-data.
Wim Taymans's avatar
Wim Taymans committed
88
 * @GST_EVENT_SEGMENT: A new media segment follows in the dataflow. The
89 90 91
 *                 segment events contains information for clipping buffers and
 *                 converting buffer timestamps to running-time and
 *                 stream-time.
92
 * @GST_EVENT_TAG: A new set of metadata tags has been found in the stream.
93 94
 * @GST_EVENT_BUFFERSIZE: Notification of buffering requirements. Currently not
 *                 used yet.
Stefan Kost's avatar
Stefan Kost committed
95 96 97
 * @GST_EVENT_SINK_MESSAGE: An event that sinks turn into a message. Used to
 *                          send messages that should be emitted in sync with
 *                          rendering.
98
 *                          Since: 0.10.26
Wim Taymans's avatar
Wim Taymans committed
99 100
 * @GST_EVENT_EOS: End-Of-Stream. No more data is to be expected to follow
 *                 without a SEGMENT event.
Wim Taymans's avatar
Wim Taymans committed
101
 * @GST_EVENT_SEGMENT_DONE: (unimplemented) Marks the end of a segment playback.
102
 * @GST_EVENT_GAP: (unimplemented) Marks a gap in the datastream.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
103
 * @GST_EVENT_QOS: A quality message. Used to indicate to upstream elements
Wim Taymans's avatar
Wim Taymans committed
104 105
 *                 that the downstream elements should adjust their processing
 *                 rate.
106
 * @GST_EVENT_SEEK: A request for a new playback position and rate.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
107
 * @GST_EVENT_NAVIGATION: Navigation events are usually used for communicating
108
 *                        user requests, such as mouse or keyboard movements,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
109
 *                        to upstream elements.
110 111 112 113 114
 * @GST_EVENT_LATENCY: Notification of new latency adjustment. Sinks will use
 *                     the latency information to adjust their synchronisation.
 *                     Since: 0.10.12
 * @GST_EVENT_STEP: A request for stepping through the media. Sinks will usually
 *                  execute the step operation. Since: 0.10.24
115
 * @GST_EVENT_RECONFIGURE: A request for upstream renegotiating caps and reconfiguring.
116
 *                         Since: 0.11.0
117 118 119 120
 * @GST_EVENT_CUSTOM_UPSTREAM: Upstream custom event
 * @GST_EVENT_CUSTOM_DOWNSTREAM: Downstream custom event that travels in the
 *                        data flow.
 * @GST_EVENT_CUSTOM_DOWNSTREAM_OOB: Custom out-of-band downstream event.
121
 * @GST_EVENT_CUSTOM_DOWNSTREAM_STICKY: Custom sticky downstream event.
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
122 123
 * @GST_EVENT_CUSTOM_BOTH: Custom upstream or downstream event.
 *                         In-band when travelling downstream.
124
 * @GST_EVENT_CUSTOM_BOTH_OOB: Custom upstream or downstream out-of-band event.
Jan Schmidt's avatar
Jan Schmidt committed
125
 *
Wim Taymans's avatar
Wim Taymans committed
126
 * #GstEventType lists the standard event types that can be sent in a pipeline.
127
 *
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
128 129 130
 * The custom event types can be used for private messages between elements
 * that can't be expressed using normal
 * GStreamer buffer passing semantics. Custom events carry an arbitrary
Wim Taymans's avatar
Wim Taymans committed
131
 * #GstStructure.
132
 * Specific custom events are distinguished by the name of the structure.
Wim Taymans's avatar
Wim Taymans committed
133
 */
134
/* NOTE: keep in sync with quark registration in gstevent.c */
135
typedef enum {
136
  GST_EVENT_UNKNOWN               = GST_EVENT_MAKE_TYPE (0, 0),
Wim Taymans's avatar
Wim Taymans committed
137

Wim Taymans's avatar
Wim Taymans committed
138
  /* bidirectional events */
139 140
  GST_EVENT_FLUSH_START           = GST_EVENT_MAKE_TYPE (10, FLAG(BOTH)),
  GST_EVENT_FLUSH_STOP            = GST_EVENT_MAKE_TYPE (20, FLAG(BOTH) | FLAG(SERIALIZED)),
Wim Taymans's avatar
Wim Taymans committed
141

Wim Taymans's avatar
Wim Taymans committed
142
  /* downstream serialized events */
Wim Taymans's avatar
Wim Taymans committed
143 144 145 146 147 148
  GST_EVENT_STREAM_START          = GST_EVENT_MAKE_TYPE (40, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
  GST_EVENT_CAPS                  = GST_EVENT_MAKE_TYPE (50, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
  GST_EVENT_STREAM_CONFIG         = GST_EVENT_MAKE_TYPE (60, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
  GST_EVENT_SEGMENT               = GST_EVENT_MAKE_TYPE (70, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
  GST_EVENT_TAG                   = GST_EVENT_MAKE_TYPE (80, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY) | FLAG(STICKY_MULTI)),
  GST_EVENT_BUFFERSIZE            = GST_EVENT_MAKE_TYPE (90, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
149 150
  GST_EVENT_SINK_MESSAGE          = GST_EVENT_MAKE_TYPE (100, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY) | FLAG(STICKY_MULTI)),
  GST_EVENT_EOS                   = GST_EVENT_MAKE_TYPE (110, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
Wim Taymans's avatar
Wim Taymans committed
151 152 153

  /* non-sticky downstream serialized */
  GST_EVENT_SEGMENT_DONE          = GST_EVENT_MAKE_TYPE (150, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)),
154
  GST_EVENT_GAP                   = GST_EVENT_MAKE_TYPE (160, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)),
Wim Taymans's avatar
Wim Taymans committed
155

Wim Taymans's avatar
Wim Taymans committed
156
  /* upstream events */
157 158 159 160 161 162
  GST_EVENT_QOS                   = GST_EVENT_MAKE_TYPE (190, FLAG(UPSTREAM)),
  GST_EVENT_SEEK                  = GST_EVENT_MAKE_TYPE (200, FLAG(UPSTREAM)),
  GST_EVENT_NAVIGATION            = GST_EVENT_MAKE_TYPE (210, FLAG(UPSTREAM)),
  GST_EVENT_LATENCY               = GST_EVENT_MAKE_TYPE (220, FLAG(UPSTREAM)),
  GST_EVENT_STEP                  = GST_EVENT_MAKE_TYPE (230, FLAG(UPSTREAM)),
  GST_EVENT_RECONFIGURE           = GST_EVENT_MAKE_TYPE (240, FLAG(UPSTREAM)),
Wim Taymans's avatar
Wim Taymans committed
163 164

  /* custom events start here */
165 166 167 168 169 170
  GST_EVENT_CUSTOM_UPSTREAM          = GST_EVENT_MAKE_TYPE (270, FLAG(UPSTREAM)),
  GST_EVENT_CUSTOM_DOWNSTREAM        = GST_EVENT_MAKE_TYPE (280, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)),
  GST_EVENT_CUSTOM_DOWNSTREAM_OOB    = GST_EVENT_MAKE_TYPE (290, FLAG(DOWNSTREAM)),
  GST_EVENT_CUSTOM_DOWNSTREAM_STICKY = GST_EVENT_MAKE_TYPE (300, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY) | FLAG(STICKY_MULTI)),
  GST_EVENT_CUSTOM_BOTH              = GST_EVENT_MAKE_TYPE (310, FLAG(BOTH) | FLAG(SERIALIZED)),
  GST_EVENT_CUSTOM_BOTH_OOB          = GST_EVENT_MAKE_TYPE (320, FLAG(BOTH))
171
} GstEventType;
172
#undef FLAG
Erik Walthinsen's avatar
Erik Walthinsen committed
173

174 175 176 177 178 179 180 181 182 183 184 185
#include <gst/gstminiobject.h>
#include <gst/gstformat.h>
#include <gst/gstobject.h>
#include <gst/gstclock.h>
#include <gst/gststructure.h>
#include <gst/gsttaglist.h>
#include <gst/gstsegment.h>
#include <gst/gstsegment.h>
#include <gst/gstmessage.h>

G_BEGIN_DECLS

186
GST_EXPORT GType _gst_event_type;
187 188 189 190 191 192

#define GST_TYPE_EVENT                  (_gst_event_type)
#define GST_IS_EVENT(obj)               (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_EVENT))
#define GST_EVENT_CAST(obj)             ((GstEvent *)(obj))
#define GST_EVENT(obj)                  (GST_EVENT_CAST(obj))

193 194 195 196
/**
 * GST_EVENT_TYPE:
 * @event: the event to query
 *
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
197
 * Get the #GstEventType of the event.
198
 */
Wim Taymans's avatar
Wim Taymans committed
199
#define GST_EVENT_TYPE(event)           (GST_EVENT_CAST(event)->type)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
200

201 202 203 204 205 206
/**
 * GST_EVENT_TYPE_NAME:
 * @event: the event to query
 *
 * Get a constant string representation of the #GstEventType of the event.
 */
Wim Taymans's avatar
Wim Taymans committed
207
#define GST_EVENT_TYPE_NAME(event)      (gst_event_type_get_name(GST_EVENT_TYPE(event)))
208

209 210 211 212
/**
 * GST_EVENT_TIMESTAMP:
 * @event: the event to query
 *
Wim Taymans's avatar
Wim Taymans committed
213 214
 * Get the #GstClockTime timestamp of the event. This is the time when the event
 * was created.
215
 */
Wim Taymans's avatar
Wim Taymans committed
216
#define GST_EVENT_TIMESTAMP(event)      (GST_EVENT_CAST(event)->timestamp)
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
217

Wim Taymans's avatar
Wim Taymans committed
218 219 220 221 222 223 224 225
/**
 * GST_EVENT_SEQNUM:
 * @event: the event to query
 *
 * The sequence number of @event.
 */
#define GST_EVENT_SEQNUM(event)         (GST_EVENT_CAST(event)->seqnum)

Wim Taymans's avatar
Wim Taymans committed
226 227 228 229 230 231
/**
 * GST_EVENT_IS_UPSTREAM:
 * @ev: the event to query
 *
 * Check if an event can travel upstream.
 */
Wim Taymans's avatar
Wim Taymans committed
232
#define GST_EVENT_IS_UPSTREAM(ev)       !!(GST_EVENT_TYPE (ev) & GST_EVENT_TYPE_UPSTREAM)
Wim Taymans's avatar
Wim Taymans committed
233 234 235 236 237 238
/**
 * GST_EVENT_IS_DOWNSTREAM:
 * @ev: the event to query
 *
 * Check if an event can travel downstream.
 */
Wim Taymans's avatar
Wim Taymans committed
239
#define GST_EVENT_IS_DOWNSTREAM(ev)     !!(GST_EVENT_TYPE (ev) & GST_EVENT_TYPE_DOWNSTREAM)
Wim Taymans's avatar
Wim Taymans committed
240 241 242 243 244 245
/**
 * GST_EVENT_IS_SERIALIZED:
 * @ev: the event to query
 *
 * Check if an event is serialized with the data stream.
 */
Wim Taymans's avatar
Wim Taymans committed
246
#define GST_EVENT_IS_SERIALIZED(ev)     !!(GST_EVENT_TYPE (ev) & GST_EVENT_TYPE_SERIALIZED)
247 248 249 250 251 252 253
/**
 * GST_EVENT_IS_STICKY:
 * @ev: the event to query
 *
 * Check if an event is sticky on the pads.
 */
#define GST_EVENT_IS_STICKY(ev)     !!(GST_EVENT_TYPE (ev) & GST_EVENT_TYPE_STICKY)
254

Wim Taymans's avatar
Wim Taymans committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
/**
 * gst_event_is_writable:
 * @ev: a #GstEvent
 *
 * Tests if you can safely write data into a event's structure or validly
 * modify the seqnum and timestamp field.
 */
#define         gst_event_is_writable(ev)     gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (ev))
/**
 * gst_event_make_writable:
 * @ev: (transfer full): a #GstEvent
 *
 * Makes a writable event from the given event. If the source event is
 * already writable, this will simply return the same event. A copy will
 * otherwise be made using gst_event_copy().
 *
 * Returns: (transfer full): a writable event which may or may not be the
 *     same as @ev
 */
#define         gst_event_make_writable(ev)   GST_EVENT_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (ev)))
275 276
/**
 * gst_event_replace:
277 278 279 280
 * @old_event: (inout) (transfer full): pointer to a pointer to a #GstEvent
 *     to be replaced.
 * @new_event: (allow-none) (transfer none): pointer to a #GstEvent that will
 *     replace the event pointed to by @old_event.
281 282 283
 *
 * Modifies a pointer to a #GstEvent to point to a different #GstEvent. The
 * modification is done atomically (so this is useful for ensuring thread safety
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
284
 * in some cases), and the reference counts are updated appropriately (the old
285 286 287 288
 * event is unreffed, the new one is reffed).
 *
 * Either @new_event or the #GstEvent pointed to by @old_event may be NULL.
 *
289
 * Returns: TRUE if @new_event was different from @old_event
290
 */
291
#ifdef _FOOL_GTK_DOC_
292
G_INLINE_FUNC gboolean gst_event_replace (GstEvent **old_event, GstEvent *new_event);
293 294
#endif

295
static inline gboolean
296 297
gst_event_replace (GstEvent **old_event, GstEvent *new_event)
{
298
  return gst_mini_object_replace ((GstMiniObject **) old_event, (GstMiniObject *) new_event);
299
}
300

301 302 303 304 305 306 307 308 309 310
/**
 * gst_event_steal:
 * @old_event: (inout) (transfer full): pointer to a pointer to a #GstEvent
 *     to be stolen.
 *
 * Atomically replace the #GstEvent pointed to by @old_event with NULL and
 * return the original event.
 *
 * Returns: the #GstEvent that was in @old_event
 */
311 312 313 314 315 316 317 318 319 320
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC GstEvent * gst_event_steal (GstEvent **old_event);
#endif

static inline GstEvent *
gst_event_steal (GstEvent **old_event)
{
  return GST_EVENT_CAST (gst_mini_object_steal ((GstMiniObject **) old_event));
}

321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
/**
 * gst_event_take:
 * @old_event: (inout) (transfer full): pointer to a pointer to a #GstEvent
 *     to be stolen.
 * @new_event: (allow-none) (transfer full): pointer to a #GstEvent that will
 *     replace the event pointed to by @old_event.
 *
 * Modifies a pointer to a #GstEvent to point to a different #GstEvent. This
 * function is similar to gst_event_replace() except that it takes ownership of
 * @new_event.
 *
 * Either @new_event or the #GstEvent pointed to by @old_event may be NULL.
 *
 * Returns: TRUE if @new_event was different from @old_event
 */
336 337 338 339 340 341 342 343 344
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC gboolean gst_event_take (GstEvent **old_event, GstEvent *new_event);
#endif

static inline gboolean
gst_event_take (GstEvent **old_event, GstEvent *new_event)
{
  return gst_mini_object_take ((GstMiniObject **) old_event, (GstMiniObject *) new_event);
}
345

Wim Taymans's avatar
Wim Taymans committed
346 347 348 349 350 351 352 353
/**
 * GstQOSType:
 * @GST_QOS_TYPE_OVERFLOW: The QoS event type that is produced when downstream
 *    elements are producing data too quickly and the element can't keep up
 *    processing the data. Upstream should reduce their processing rate. This
 *    type is also used when buffers arrive early or in time.
 * @GST_QOS_TYPE_UNDERFLOW: The QoS event type that is produced when downstream
 *    elements are producing data too slowly and need to speed up their processing
Wim Taymans's avatar
Wim Taymans committed
354
 *    rate.
Wim Taymans's avatar
Wim Taymans committed
355 356 357
 * @GST_QOS_TYPE_THROTTLE: The QoS event type that is produced when the
 *    application enabled throttling to limit the datarate.
 *
Wim Taymans's avatar
Wim Taymans committed
358 359
 * The different types of QoS events that can be given to the
 * gst_event_new_qos() method.
Wim Taymans's avatar
Wim Taymans committed
360 361 362 363 364 365 366 367 368
 *
 * Since: 0.10.33
 */
typedef enum {
  GST_QOS_TYPE_OVERFLOW        = 0,
  GST_QOS_TYPE_UNDERFLOW       = 1,
  GST_QOS_TYPE_THROTTLE        = 2
} GstQOSType;

369 370 371 372 373 374 375 376 377 378 379
/**
 * GstStreamConfigFlags:
 * @GST_STREAM_CONFIG_FLAG_NONE: no flags set
 *
 * GstStreamConfigFlags are flags passed with the stream config event, see
 * gst_event_new_stream_config().
 */
typedef enum {
  GST_STREAM_CONFIG_FLAG_NONE = 0
} GstStreamConfigFlags;

Wim Taymans's avatar
Wim Taymans committed
380 381 382 383 384
/**
 * GstEvent:
 * @mini_object: the parent structure
 * @type: the #GstEventType of the event
 * @timestamp: the timestamp of the event
Wim Taymans's avatar
Wim Taymans committed
385
 * @seqnum: the sequence number of the event
Wim Taymans's avatar
Wim Taymans committed
386 387 388
 *
 * A #GstEvent.
 */
389
struct _GstEvent {
390
  GstMiniObject mini_object;
391

392
  /*< public >*/ /* with COW */
393
  GstEventType  type;
Wim Taymans's avatar
Wim Taymans committed
394
  guint64       timestamp;
Wim Taymans's avatar
Wim Taymans committed
395
  guint32       seqnum;
Erik Walthinsen's avatar
Erik Walthinsen committed
396 397
};

398
const gchar*    gst_event_type_get_name         (GstEventType type);
Wim Taymans's avatar
Wim Taymans committed
399
GQuark          gst_event_type_to_quark         (GstEventType type);
400
GstEventTypeFlags
Wim Taymans's avatar
Wim Taymans committed
401
                gst_event_type_get_flags        (GstEventType type);
402 403


404
/* refcounting */
405 406
/**
 * gst_event_ref:
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
407
 * @event: The event to refcount
408 409
 *
 * Increase the refcount of this event.
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
410
 *
411
 * Returns: (transfer full): @event (for convenience when doing assignments)
412
 */
413
#ifdef _FOOL_GTK_DOC_
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
414
G_INLINE_FUNC GstEvent * gst_event_ref (GstEvent * event);
415 416
#endif

417
static inline GstEvent *
Wim Taymans's avatar
Wim Taymans committed
418
gst_event_ref (GstEvent * event)
419
{
420
  return (GstEvent *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (event));
421 422
}

423
/**
Stefan Kost's avatar
Stefan Kost committed
424
 * gst_event_unref:
425
 * @event: (transfer full): the event to refcount
426 427 428
 *
 * Decrease the refcount of an event, freeing it if the refcount reaches 0.
 */
429 430 431 432 433
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC void gst_event_unref (GstEvent * event);
#endif

static inline void
Wim Taymans's avatar
Wim Taymans committed
434
gst_event_unref (GstEvent * event)
435
{
436
  gst_mini_object_unref (GST_MINI_OBJECT_CAST (event));
437
}
438

Wim Taymans's avatar
Wim Taymans committed
439
/* copy event */
440 441
/**
 * gst_event_copy:
Wim Taymans's avatar
Wim Taymans committed
442
 * @event: The event to copy
443 444
 *
 * Copy the event using the event specific copy function.
Stefan Kost's avatar
Stefan Kost committed
445
 *
446
 * Returns: (transfer full): the new event
447
 */
448
#ifdef _FOOL_GTK_DOC_
Wim Taymans's avatar
Wim Taymans committed
449
G_INLINE_FUNC GstEvent * gst_event_copy (const GstEvent * event);
450 451 452
#endif

static inline GstEvent *
Wim Taymans's avatar
Wim Taymans committed
453
gst_event_copy (const GstEvent * event)
454
{
455
  return GST_EVENT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (event)));
456 457
}

Wim Taymans's avatar
Wim Taymans committed
458
GType           gst_event_get_type              (void);
459

Wim Taymans's avatar
Wim Taymans committed
460
/* custom event */
461
GstEvent*       gst_event_new_custom            (GstEventType type, GstStructure *structure) G_GNUC_MALLOC;
462

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
463
const GstStructure *
Wim Taymans's avatar
Wim Taymans committed
464
                gst_event_get_structure         (GstEvent *event);
Wim Taymans's avatar
Wim Taymans committed
465
GstStructure *  gst_event_writable_structure    (GstEvent *event);
466

467 468
gboolean        gst_event_has_name              (GstEvent *event, const gchar *name);

469 470 471 472
/* identifiers for events and messages */
guint32         gst_event_get_seqnum            (GstEvent *event);
void            gst_event_set_seqnum            (GstEvent *event, guint32 seqnum);

473 474 475
/* Stream start event */
GstEvent *      gst_event_new_stream_start      (void) G_GNUC_MALLOC;

476
/* flush events */
477
GstEvent *      gst_event_new_flush_start       (void) G_GNUC_MALLOC;
478

479
GstEvent *      gst_event_new_flush_stop        (gboolean reset_time) G_GNUC_MALLOC;
480
void            gst_event_parse_flush_stop      (GstEvent *event, gboolean *reset_time);
Wim Taymans's avatar
Wim Taymans committed
481 482

/* EOS event */
483
GstEvent *      gst_event_new_eos               (void) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
484

485
/* GAP event */
Edward Hervey's avatar
Edward Hervey committed
486
GstEvent *      gst_event_new_gap               (GstClockTime   timestamp,
487 488 489 490 491 492
                                                 GstClockTime   duration) G_GNUC_MALLOC;

void            gst_event_parse_gap             (GstEvent     * event,
                                                 GstClockTime * timestamp,
                                                 GstClockTime * duration);

Wim Taymans's avatar
Wim Taymans committed
493
/* Caps events */
494
GstEvent *      gst_event_new_caps              (GstCaps *caps) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
495 496
void            gst_event_parse_caps            (GstEvent *event, GstCaps **caps);

497 498 499 500 501 502
/* Stream config */
GstEvent *      gst_event_new_stream_config                (GstStreamConfigFlags flags) G_GNUC_MALLOC;

void            gst_event_parse_stream_config              (GstEvent * event, GstStreamConfigFlags * flags);


503
void            gst_event_set_stream_config_setup_data     (GstEvent * event, GstBuffer  * buf);
504

505
gboolean        gst_event_parse_stream_config_setup_data   (GstEvent * event, GstBuffer ** buf);
506 507 508 509 510 511


void            gst_event_add_stream_config_header         (GstEvent * event, GstBuffer  * buf);

guint           gst_event_get_n_stream_config_headers      (GstEvent * event);

512
gboolean        gst_event_parse_nth_stream_config_header   (GstEvent * event, guint index, GstBuffer ** buf);
513

Wim Taymans's avatar
Wim Taymans committed
514
/* segment event */
515
GstEvent*       gst_event_new_segment           (const GstSegment *segment) G_GNUC_MALLOC;
516 517
void            gst_event_parse_segment         (GstEvent *event, const GstSegment **segment);
void            gst_event_copy_segment          (GstEvent *event, GstSegment *segment);
518

Wim Taymans's avatar
Wim Taymans committed
519
/* tag event */
520
GstEvent*       gst_event_new_tag               (GstTagList *taglist) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
521
void            gst_event_parse_tag             (GstEvent *event, GstTagList **taglist);
Wim Taymans's avatar
Wim Taymans committed
522

523
/* buffer */
Wim Taymans's avatar
Wim Taymans committed
524
GstEvent *      gst_event_new_buffer_size       (GstFormat format, gint64 minsize, gint64 maxsize,
525
                                                 gboolean async) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
526 527
void            gst_event_parse_buffer_size     (GstEvent *event, GstFormat *format, gint64 *minsize,
                                                 gint64 *maxsize, gboolean *async);
Wim Taymans's avatar
Wim Taymans committed
528

Wim Taymans's avatar
Wim Taymans committed
529
/* sink message */
530
GstEvent*       gst_event_new_sink_message      (GstMessage *msg) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
531 532
void            gst_event_parse_sink_message    (GstEvent *event, GstMessage **msg);

Wim Taymans's avatar
Wim Taymans committed
533
/* QOS events */
Wim Taymans's avatar
Wim Taymans committed
534
GstEvent*       gst_event_new_qos               (GstQOSType type, gdouble proportion,
535
                                                 GstClockTimeDiff diff, GstClockTime timestamp) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
536
void            gst_event_parse_qos             (GstEvent *event, GstQOSType *type,
Wim Taymans's avatar
Wim Taymans committed
537 538
                                                 gdouble *proportion, GstClockTimeDiff *diff,
                                                 GstClockTime *timestamp);
Wim Taymans's avatar
Wim Taymans committed
539
/* seek event */
Wim Taymans's avatar
Wim Taymans committed
540 541
GstEvent*       gst_event_new_seek              (gdouble rate, GstFormat format, GstSeekFlags flags,
                                                 GstSeekType start_type, gint64 start,
542
                                                 GstSeekType stop_type, gint64 stop) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
543 544 545 546
void            gst_event_parse_seek            (GstEvent *event, gdouble *rate, GstFormat *format,
                                                 GstSeekFlags *flags,
                                                 GstSeekType *start_type, gint64 *start,
                                                 GstSeekType *stop_type, gint64 *stop);
Wim Taymans's avatar
Wim Taymans committed
547

Wim Taymans's avatar
Wim Taymans committed
548
/* navigation event */
549
GstEvent*       gst_event_new_navigation        (GstStructure *structure) G_GNUC_MALLOC;
550

551
/* latency event */
552
GstEvent*       gst_event_new_latency           (GstClockTime latency) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
553
void            gst_event_parse_latency         (GstEvent *event, GstClockTime *latency);
554

Wim Taymans's avatar
Wim Taymans committed
555
/* step event */
Wim Taymans's avatar
Wim Taymans committed
556
GstEvent*       gst_event_new_step              (GstFormat format, guint64 amount, gdouble rate,
557
                                                 gboolean flush, gboolean intermediate) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
558
void            gst_event_parse_step            (GstEvent *event, GstFormat *format, guint64 *amount,
Wim Taymans's avatar
Wim Taymans committed
559 560
                                                 gdouble *rate, gboolean *flush, gboolean *intermediate);

561
/* renegotiate event */
562
GstEvent*       gst_event_new_reconfigure       (void) G_GNUC_MALLOC;
563

564
G_END_DECLS
565

Erik Walthinsen's avatar
Erik Walthinsen committed
566
#endif /* __GST_EVENT_H__ */