gstmessage.h 29.7 KB
Newer Older
Wim Taymans's avatar
Wim Taymans committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* GStreamer
 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
 *
 * gstmessage.h: Header for GstMessage 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
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
18 19
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
Wim Taymans's avatar
Wim Taymans committed
20 21 22 23 24
 */

#ifndef __GST_MESSAGE_H__
#define __GST_MESSAGE_H__

25 26
#include <glib.h>

27
G_BEGIN_DECLS
Wim Taymans's avatar
Wim Taymans committed
28

Wim Taymans's avatar
Wim Taymans committed
29 30
typedef struct _GstMessage GstMessage;

Wim Taymans's avatar
Wim Taymans committed
31 32 33
/**
 * GstMessageType:
 * @GST_MESSAGE_UNKNOWN: an undefined message
34 35 36
 * @GST_MESSAGE_EOS: end-of-stream reached in a pipeline. The application will
 * only receive this message in the PLAYING state and every time it sets a
 * pipeline to PLAYING that is in the EOS state. The application can perform a
Wim Taymans's avatar
Wim Taymans committed
37
 * flushing seek in the pipeline, which will undo the EOS state again.
38
 * @GST_MESSAGE_ERROR: an error occurred. When the application receives an error
39 40
 * message it should stop playback of the pipeline and not assume that more
 * data will be played.
41 42
 * @GST_MESSAGE_WARNING: a warning occurred.
 * @GST_MESSAGE_INFO: an info message occurred
Wim Taymans's avatar
Wim Taymans committed
43
 * @GST_MESSAGE_TAG: a tag was found.
44 45 46 47
 * @GST_MESSAGE_BUFFERING: the pipeline is buffering. When the application
 * receives a buffering message in the PLAYING state for a non-live pipeline it
 * must PAUSE the pipeline until the buffering completes, when the percentage
 * field in the message is 100%. For live pipelines, no action must be
48
 * performed and the buffering percentage can be used to inform the user about
49
 * the progress.
Wim Taymans's avatar
Wim Taymans committed
50
 * @GST_MESSAGE_STATE_CHANGED: a state change happened
51 52
 * @GST_MESSAGE_STATE_DIRTY: an element changed state in a streaming thread.
 * This message is deprecated.
Wim Taymans's avatar
Wim Taymans committed
53
 * @GST_MESSAGE_STEP_DONE: a stepping operation finished.
54
 * @GST_MESSAGE_CLOCK_PROVIDE: an element notifies its capability of providing
55 56
 *                             a clock. This message is used internally and
 *                             never forwarded to the application.
Wim Taymans's avatar
Wim Taymans committed
57
 * @GST_MESSAGE_CLOCK_LOST: The current clock as selected by the pipeline became
58
 *                          unusable. The pipeline will select a new clock on
Wim Taymans's avatar
Wim Taymans committed
59 60 61
 *                          the next PLAYING state change. The application
 *                          should set the pipeline to PAUSED and back to
 *                          PLAYING when this message is received.
62
 * @GST_MESSAGE_NEW_CLOCK: a new clock was selected in the pipeline.
63 64
 * @GST_MESSAGE_STRUCTURE_CHANGE: the structure of the pipeline changed. This
 * message is used internally and never forwarded to the application.
65
 * @GST_MESSAGE_STREAM_STATUS: status about a stream, emitted when it starts,
66
 *                             stops, errors, etc..
Wim Taymans's avatar
Wim Taymans committed
67 68
 * @GST_MESSAGE_APPLICATION: message posted by the application, possibly
 *                           via an application-specific element.
69 70
 * @GST_MESSAGE_ELEMENT: element-specific message, see the specific element's
 *                       documentation
71 72 73 74 75
 * @GST_MESSAGE_SEGMENT_START: pipeline started playback of a segment. This
 * message is used internally and never forwarded to the application.
 * @GST_MESSAGE_SEGMENT_DONE: pipeline completed playback of a segment. This
 * message is forwarded to the application after all elements that posted
 * @GST_MESSAGE_SEGMENT_START posted a GST_MESSAGE_SEGMENT_DONE message.
76 77
 * @GST_MESSAGE_DURATION_CHANGED: The duration of a pipeline changed. The
 * application can get the new duration with a duration query.
78 79
 * @GST_MESSAGE_ASYNC_START: Posted by elements when they start an ASYNC
 * #GstStateChange. This message is not forwarded to the application but is used
80
 * internally.
81 82
 * @GST_MESSAGE_ASYNC_DONE: Posted by elements when they complete an ASYNC
 * #GstStateChange. The application will only receive this message from the toplevel
83
 * pipeline.
84
 * @GST_MESSAGE_LATENCY: Posted by elements when their latency changes. The
85
 * application should recalculate and distribute a new latency.
86 87
 * @GST_MESSAGE_REQUEST_STATE: Posted by elements when they want the pipeline to
 * change state. This message is a suggestion to the application which can
88 89
 * decide to perform the state change on (part of) the pipeline.
 * @GST_MESSAGE_STEP_START: A stepping operation was started.
90
 * @GST_MESSAGE_QOS: A buffer was dropped or an element changed its processing
91 92
 * strategy for Quality of Service reasons.
 * @GST_MESSAGE_PROGRESS: A progress message.
Alexander Saprykin's avatar
Alexander Saprykin committed
93
 * @GST_MESSAGE_TOC: A new table of contents (TOC) was found or previously found TOC
94 95 96 97 98 99 100 101
 * was updated.
 * @GST_MESSAGE_RESET_TIME: Message to request resetting the pipeline's
 *     running time from the pipeline. This is an internal message which
 *     applications will likely never receive.
 * @GST_MESSAGE_STREAM_START: Message indicating start of a new stream. Useful
 *     e.g. when using playbin in gapless playback mode, to get notified when
 *     the next title actually starts playing (which will be some time after
 *     the URI for the next title has been set).
102 103
 * @GST_MESSAGE_NEED_CONTEXT: Message indicating that an element wants a specific context (Since 1.2)
 * @GST_MESSAGE_HAVE_CONTEXT: Message indicating that an element created a context (Since 1.2)
104 105 106 107 108 109
 * @GST_MESSAGE_EXTENDED: Message is an extended message type (see below).
 *     These extended message IDs can't be used directly with mask-based API
 *     like gst_bus_poll() or gst_bus_timed_pop_filtered(), but you can still
 *     filter for GST_MESSAGE_EXTENDED and then check the result for the
 *     specific type. (Since 1.4)
 * @GST_MESSAGE_DEVICE_ADDED: Message indicating a #GstDevice was added to
110
 *     a #GstDeviceProvider (Since 1.4)
111
 * @GST_MESSAGE_DEVICE_REMOVED: Message indicating a #GstDevice was removed
112
 *     from a #GstDeviceProvider (Since 1.4)
113 114
 * @GST_MESSAGE_PROPERTY_NOTIFY: Message indicating a #GObject property has
 *     changed (Since 1.10)
115
 * @GST_MESSAGE_STREAM_COLLECTION: Message indicating a new #GstStreamCollection
116
 *     is available (Since 1.10)
117
 * @GST_MESSAGE_STREAMS_SELECTED: Message indicating the active selection of
118
 *     #GstStreams has changed (Since 1.10)
119 120 121
 * @GST_MESSAGE_REDIRECT: Message indicating to request the application to
 *     try to play the given URL(s). Useful if for example a HTTP 302/303
 *     response is received with a non-HTTP URL inside. (Since 1.10)
Wim Taymans's avatar
Wim Taymans committed
122
 * @GST_MESSAGE_ANY: mask for all of the above messages.
Wim Taymans's avatar
Wim Taymans committed
123
 *
124
 * The different message types that are available.
Wim Taymans's avatar
Wim Taymans committed
125
 */
Wim Taymans's avatar
Wim Taymans committed
126
/* NOTE: keep in sync with quark registration in gstmessage.c
127
 * NOTE: keep GST_MESSAGE_ANY a valid gint to avoid compiler warnings.
Wim Taymans's avatar
Wim Taymans committed
128
 */
129
/* FIXME: 2.0: Make it NOT flags, just a regular 1,2,3,4.. enumeration */
130 131 132
/* FIXME: For GST_MESSAGE_ANY ~0 -> 0xffffffff see
 *        https://bugzilla.gnome.org/show_bug.cgi?id=732633
 */
133
typedef enum
Wim Taymans's avatar
Wim Taymans committed
134 135 136 137 138 139 140 141 142
{
  GST_MESSAGE_UNKNOWN           = 0,
  GST_MESSAGE_EOS               = (1 << 0),
  GST_MESSAGE_ERROR             = (1 << 1),
  GST_MESSAGE_WARNING           = (1 << 2),
  GST_MESSAGE_INFO              = (1 << 3),
  GST_MESSAGE_TAG               = (1 << 4),
  GST_MESSAGE_BUFFERING         = (1 << 5),
  GST_MESSAGE_STATE_CHANGED     = (1 << 6),
143 144 145 146 147 148 149 150 151 152 153
  GST_MESSAGE_STATE_DIRTY       = (1 << 7),
  GST_MESSAGE_STEP_DONE         = (1 << 8),
  GST_MESSAGE_CLOCK_PROVIDE     = (1 << 9),
  GST_MESSAGE_CLOCK_LOST        = (1 << 10),
  GST_MESSAGE_NEW_CLOCK         = (1 << 11),
  GST_MESSAGE_STRUCTURE_CHANGE  = (1 << 12),
  GST_MESSAGE_STREAM_STATUS     = (1 << 13),
  GST_MESSAGE_APPLICATION       = (1 << 14),
  GST_MESSAGE_ELEMENT           = (1 << 15),
  GST_MESSAGE_SEGMENT_START     = (1 << 16),
  GST_MESSAGE_SEGMENT_DONE      = (1 << 17),
154
  GST_MESSAGE_DURATION_CHANGED  = (1 << 18),
155
  GST_MESSAGE_LATENCY           = (1 << 19),
156 157
  GST_MESSAGE_ASYNC_START       = (1 << 20),
  GST_MESSAGE_ASYNC_DONE        = (1 << 21),
158
  GST_MESSAGE_REQUEST_STATE     = (1 << 22),
159
  GST_MESSAGE_STEP_START        = (1 << 23),
160
  GST_MESSAGE_QOS               = (1 << 24),
161
  GST_MESSAGE_PROGRESS          = (1 << 25),
Alexander Saprykin's avatar
Alexander Saprykin committed
162
  GST_MESSAGE_TOC               = (1 << 26),
163
  GST_MESSAGE_RESET_TIME        = (1 << 27),
164
  GST_MESSAGE_STREAM_START      = (1 << 28),
165 166
  GST_MESSAGE_NEED_CONTEXT      = (1 << 29),
  GST_MESSAGE_HAVE_CONTEXT      = (1 << 30),
167
  GST_MESSAGE_EXTENDED          = (gint) (1u << 31),
168 169
  GST_MESSAGE_DEVICE_ADDED      = GST_MESSAGE_EXTENDED + 1,
  GST_MESSAGE_DEVICE_REMOVED    = GST_MESSAGE_EXTENDED + 2,
170
  GST_MESSAGE_PROPERTY_NOTIFY   = GST_MESSAGE_EXTENDED + 3,
171 172
  GST_MESSAGE_STREAM_COLLECTION = GST_MESSAGE_EXTENDED + 4,
  GST_MESSAGE_STREAMS_SELECTED  = GST_MESSAGE_EXTENDED + 5,
173
  GST_MESSAGE_REDIRECT          = GST_MESSAGE_EXTENDED + 6,
174
  GST_MESSAGE_ANY               = (gint) (0xffffffff)
Wim Taymans's avatar
Wim Taymans committed
175 176
} GstMessageType;

Wim Taymans's avatar
Wim Taymans committed
177 178 179
#include <gst/gstminiobject.h>
#include <gst/gstobject.h>
#include <gst/gstelement.h>
180
#include <gst/gsttaglist.h>
Wim Taymans's avatar
Wim Taymans committed
181
#include <gst/gststructure.h>
Wim Taymans's avatar
Wim Taymans committed
182
#include <gst/gstquery.h>
Alexander Saprykin's avatar
Alexander Saprykin committed
183
#include <gst/gsttoc.h>
184
#include <gst/gstdevice.h>
185
#include <gst/gststreams.h>
186
#include <gst/gststreamcollection.h>
Wim Taymans's avatar
Wim Taymans committed
187

188 189 190
GST_EXPORT GType _gst_message_type;

#define GST_TYPE_MESSAGE                         (_gst_message_type)
Wim Taymans's avatar
Wim Taymans committed
191
#define GST_IS_MESSAGE(obj)                      (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_MESSAGE))
192
#define GST_MESSAGE_CAST(obj)                    ((GstMessage*)(obj))
193
#define GST_MESSAGE(obj)                         (GST_MESSAGE_CAST(obj))
Wim Taymans's avatar
Wim Taymans committed
194 195 196 197

/* the lock is used to handle the synchronous handling of messages,
 * the emiting thread is block until the handling thread processed
 * the message using this mutex/cond pair */
Wim Taymans's avatar
Wim Taymans committed
198
#define GST_MESSAGE_GET_LOCK(message)   (&GST_MESSAGE_CAST(message)->lock)
Wim Taymans's avatar
Wim Taymans committed
199 200
#define GST_MESSAGE_LOCK(message)       g_mutex_lock(GST_MESSAGE_GET_LOCK(message))
#define GST_MESSAGE_UNLOCK(message)     g_mutex_unlock(GST_MESSAGE_GET_LOCK(message))
Wim Taymans's avatar
Wim Taymans committed
201 202 203
#define GST_MESSAGE_GET_COND(message)   (&GST_MESSAGE_CAST(message)->cond)
#define GST_MESSAGE_WAIT(message)       g_cond_wait(GST_MESSAGE_GET_COND(message),GST_MESSAGE_GET_LOCK(message))
#define GST_MESSAGE_SIGNAL(message)     g_cond_signal(GST_MESSAGE_GET_COND(message))
Wim Taymans's avatar
Wim Taymans committed
204

205 206 207 208 209 210
/**
 * GST_MESSAGE_TYPE:
 * @message: a #GstMessage
 *
 * Get the #GstMessageType of @message.
 */
211
#define GST_MESSAGE_TYPE(message)       (GST_MESSAGE_CAST(message)->type)
212 213 214 215 216
/**
 * GST_MESSAGE_TYPE_IS_EXTENDED:
 * @message: a #GstMessage
 *
 * Check if the message is in the extended message group
Nicolas Dufresne's avatar
Nicolas Dufresne committed
217
 * Since: 1.4
218 219 220
 */
#define GST_MESSAGE_TYPE_IS_EXTENDED(message)       (!!(GST_MESSAGE_CAST(message)->type & GST_MESSAGE_EXTENDED))

221 222 223 224 225 226
/**
 * GST_MESSAGE_TYPE_NAME:
 * @message: a #GstMessage
 *
 * Get a constant string representation of the #GstMessageType of @message.
 */
Wim Taymans's avatar
Wim Taymans committed
227
#define GST_MESSAGE_TYPE_NAME(message)  gst_message_type_get_name(GST_MESSAGE_TYPE(message))
228 229 230 231 232 233 234
/**
 * GST_MESSAGE_TIMESTAMP:
 * @message: a #GstMessage
 *
 * Get the timestamp of @message. This is the timestamp when the message
 * was created.
 */
235
#define GST_MESSAGE_TIMESTAMP(message)  (GST_MESSAGE_CAST(message)->timestamp)
236 237 238 239 240 241
/**
 * GST_MESSAGE_SRC:
 * @message: a #GstMessage
 *
 * Get the object that posted @message.
 */
242
#define GST_MESSAGE_SRC(message)        (GST_MESSAGE_CAST(message)->src)
Wim Taymans's avatar
Wim Taymans committed
243 244 245 246 247 248 249 250 251

/**
 * GST_MESSAGE_SEQNUM:
 * @message: a #GstMessage
 *
 * Get the sequence number of @message.
 */
#define GST_MESSAGE_SEQNUM(message)     (GST_MESSAGE_CAST(message)->seqnum)

252 253 254 255 256 257 258
/**
 * GST_MESSAGE_SRC_NAME:
 * @message: a #GstMessage
 *
 * Get the name of the object that posted @message. Returns "(NULL)" if
 * the message has no source object set.
 */
Wim Taymans's avatar
Wim Taymans committed
259
#define GST_MESSAGE_SRC_NAME(message)   (GST_MESSAGE_SRC(message) ? \
260
    GST_OBJECT_NAME (GST_MESSAGE_SRC(message)) : "(NULL)")
Wim Taymans's avatar
Wim Taymans committed
261

262 263 264 265 266
/**
 * GstStructureChangeType:
 * @GST_STRUCTURE_CHANGE_TYPE_PAD_LINK: Pad linking is starting or done.
 * @GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK: Pad unlinking is starting or done.
 *
Stefan Kost's avatar
Stefan Kost committed
267
 * The type of a %GST_MESSAGE_STRUCTURE_CHANGE.
268 269 270 271 272 273
 */
typedef enum {
  GST_STRUCTURE_CHANGE_TYPE_PAD_LINK   = 0,
  GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK = 1
} GstStructureChangeType;

274 275 276 277 278 279 280 281 282 283
/**
 * GstStreamStatusType:
 * @GST_STREAM_STATUS_TYPE_CREATE: A new thread need to be created.
 * @GST_STREAM_STATUS_TYPE_ENTER: a thread entered its loop function
 * @GST_STREAM_STATUS_TYPE_LEAVE: a thread left its loop function
 * @GST_STREAM_STATUS_TYPE_DESTROY: a thread is destroyed
 * @GST_STREAM_STATUS_TYPE_START: a thread is started
 * @GST_STREAM_STATUS_TYPE_PAUSE: a thread is paused
 * @GST_STREAM_STATUS_TYPE_STOP: a thread is stopped
 *
Stefan Kost's avatar
Stefan Kost committed
284
 * The type of a %GST_MESSAGE_STREAM_STATUS. The stream status messages inform the
285 286 287 288 289 290 291 292 293 294 295 296 297
 * application of new streaming threads and their status.
 */
typedef enum {
  GST_STREAM_STATUS_TYPE_CREATE   = 0,
  GST_STREAM_STATUS_TYPE_ENTER    = 1,
  GST_STREAM_STATUS_TYPE_LEAVE    = 2,
  GST_STREAM_STATUS_TYPE_DESTROY  = 3,

  GST_STREAM_STATUS_TYPE_START    = 8,
  GST_STREAM_STATUS_TYPE_PAUSE    = 9,
  GST_STREAM_STATUS_TYPE_STOP     = 10
} GstStreamStatusType;

298 299 300 301 302 303 304 305 306 307
/**
 * GstProgressType:
 * @GST_PROGRESS_TYPE_START: A new task started.
 * @GST_PROGRESS_TYPE_CONTINUE: A task completed and a new one continues.
 * @GST_PROGRESS_TYPE_COMPLETE: A task completed.
 * @GST_PROGRESS_TYPE_CANCELED: A task was canceled.
 * @GST_PROGRESS_TYPE_ERROR: A task caused an error. An error message is also
 *          posted on the bus.
 *
 * The type of a %GST_MESSAGE_PROGRESS. The progress messages inform the
308
 * application of the status of asynchronous tasks.
309 310 311 312 313 314
 */
typedef enum {
  GST_PROGRESS_TYPE_START    = 0,
  GST_PROGRESS_TYPE_CONTINUE = 1,
  GST_PROGRESS_TYPE_COMPLETE = 2,
  GST_PROGRESS_TYPE_CANCELED = 3,
315
  GST_PROGRESS_TYPE_ERROR    = 4
316 317
} GstProgressType;

318 319 320 321 322 323
/**
 * GstMessage:
 * @mini_object: the parent structure
 * @type: the #GstMessageType of the message
 * @timestamp: the timestamp of the message
 * @src: the src of the message
Wim Taymans's avatar
Wim Taymans committed
324
 * @seqnum: the sequence number of the message
325
 *
326
 * A #GstMessage.
327
 */
Wim Taymans's avatar
Wim Taymans committed
328 329
struct _GstMessage
{
Wim Taymans's avatar
Wim Taymans committed
330
  GstMiniObject   mini_object;
Wim Taymans's avatar
Wim Taymans committed
331 332

  /*< public > *//* with COW */
Wim Taymans's avatar
Wim Taymans committed
333 334 335 336
  GstMessageType  type;
  guint64         timestamp;
  GstObject      *src;
  guint32         seqnum;
Wim Taymans's avatar
Wim Taymans committed
337

338
  /*< private >*//* with MESSAGE_LOCK */
Wim Taymans's avatar
Wim Taymans committed
339 340
  GMutex          lock;                 /* lock and cond for async delivery */
  GCond           cond;
Wim Taymans's avatar
Wim Taymans committed
341 342
};

343 344
#include <gst/gstquery.h>

Wim Taymans's avatar
Wim Taymans committed
345
GType           gst_message_get_type            (void);
Wim Taymans's avatar
Wim Taymans committed
346

Wim Taymans's avatar
Wim Taymans committed
347 348
const gchar*    gst_message_type_get_name       (GstMessageType type);
GQuark          gst_message_type_to_quark       (GstMessageType type);
349

Wim Taymans's avatar
Wim Taymans committed
350
/* refcounting */
Stefan Kost's avatar
Stefan Kost committed
351 352 353 354
/**
 * gst_message_ref:
 * @msg: the message to ref
 *
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
355 356 357
 * Convenience macro to increase the reference count of the message.
 *
 * Returns: @msg (for convenience when doing assignments)
Stefan Kost's avatar
Stefan Kost committed
358
 */
359 360 361
static inline GstMessage *
gst_message_ref (GstMessage * msg)
{
362
  return (GstMessage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (msg));
363 364
}

Stefan Kost's avatar
Stefan Kost committed
365 366 367 368
/**
 * gst_message_unref:
 * @msg: the message to unref
 *
369 370
 * Convenience macro to decrease the reference count of the message, possibly
 * freeing it.
Stefan Kost's avatar
Stefan Kost committed
371
 */
372 373 374 375 376 377
static inline void
gst_message_unref (GstMessage * msg)
{
  gst_mini_object_unref (GST_MINI_OBJECT_CAST (msg));
}

Wim Taymans's avatar
Wim Taymans committed
378
/* copy message */
Stefan Kost's avatar
Stefan Kost committed
379 380 381 382
/**
 * gst_message_copy:
 * @msg: the message to copy
 *
Wim Taymans's avatar
Wim Taymans committed
383
 * Creates a copy of the message. Returns a copy of the message.
Stefan Kost's avatar
Stefan Kost committed
384
 *
385
 * Returns: (transfer full): a new copy of @msg.
Wim Taymans's avatar
Wim Taymans committed
386
 *
Stefan Kost's avatar
Stefan Kost committed
387 388
 * MT safe
 */
389 390 391
static inline GstMessage *
gst_message_copy (const GstMessage * msg)
{
392
  return GST_MESSAGE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (msg)));
393 394
}

395 396 397 398 399 400 401 402
/**
 * gst_message_is_writable:
 * @msg: a #GstMessage
 *
 * Tests if you can safely write into a message's structure or validly
 * modify the seqnum and timestamp fields.
 */
#define         gst_message_is_writable(msg)     gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (msg))
Stefan Kost's avatar
Stefan Kost committed
403 404
/**
 * gst_message_make_writable:
405
 * @msg: (transfer full): the message to make writable
Stefan Kost's avatar
Stefan Kost committed
406 407
 *
 * Checks if a message is writable. If not, a writable copy is made and
408 409 410
 * returned.
 *
 * Returns: (transfer full): a message (possibly a duplicate) that is writable.
Stefan Kost's avatar
Stefan Kost committed
411 412 413
 *
 * MT safe
 */
414
#define         gst_message_make_writable(msg)  GST_MESSAGE_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (msg)))
415 416
/**
 * gst_message_replace:
417 418
 * @old_message: (inout) (transfer full) (nullable): pointer to a
 *     pointer to a #GstMessage to be replaced.
419 420 421 422 423 424 425 426
 * @new_message: (allow-none) (transfer none): pointer to a #GstMessage that will
 *     replace the message pointed to by @old_message.
 *
 * Modifies a pointer to a #GstMessage to point to a different #GstMessage. The
 * modification is done atomically (so this is useful for ensuring thread safety
 * in some cases), and the reference counts are updated appropriately (the old
 * message is unreffed, the new one is reffed).
 *
427
 * Either @new_message or the #GstMessage pointed to by @old_message may be %NULL.
428
 *
429
 * Returns: %TRUE if @new_message was different from @old_message
430
 */
431 432 433 434 435
static inline gboolean
gst_message_replace (GstMessage **old_message, GstMessage *new_message)
{
  return gst_mini_object_replace ((GstMiniObject **) old_message, (GstMiniObject *) new_message);
}
436 437 438 439 440


/* custom messages */
GstMessage *    gst_message_new_custom          (GstMessageType type,
                                                 GstObject    * src,
441
                                                 GstStructure * structure) G_GNUC_MALLOC;
442 443 444 445
const GstStructure *
                gst_message_get_structure       (GstMessage *message);

gboolean        gst_message_has_name            (GstMessage *message, const gchar *name);
Wim Taymans's avatar
Wim Taymans committed
446

447 448 449 450
/* identifiers for events and messages */
guint32         gst_message_get_seqnum          (GstMessage *message);
void            gst_message_set_seqnum          (GstMessage *message, guint32 seqnum);

451
/* EOS */
452
GstMessage *    gst_message_new_eos             (GstObject * src) G_GNUC_MALLOC;
453 454 455

/* ERROR */

456
GstMessage *    gst_message_new_error           (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
457
GstMessage *    gst_message_new_error_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
458
void            gst_message_parse_error         (GstMessage *message, GError **gerror, gchar **debug);
459
void            gst_message_parse_error_details (GstMessage *message, const GstStructure **structure);
460 461

/* WARNING */
462
GstMessage *    gst_message_new_warning         (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
463
GstMessage *    gst_message_new_warning_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
464
void            gst_message_parse_warning       (GstMessage *message, GError **gerror, gchar **debug);
465
void            gst_message_parse_warning_details (GstMessage *message, const GstStructure **structure);
466 467

/* INFO */
468
GstMessage *    gst_message_new_info            (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC;
469
GstMessage *    gst_message_new_info_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
470
void            gst_message_parse_info          (GstMessage *message, GError **gerror, gchar **debug);
471
void            gst_message_parse_info_details  (GstMessage *message, const GstStructure **structure);
472 473

/* TAG */
474
GstMessage *    gst_message_new_tag             (GstObject * src, GstTagList * tag_list) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
475
void            gst_message_parse_tag           (GstMessage *message, GstTagList **tag_list);
476 477

/* BUFFERING */
478
GstMessage *    gst_message_new_buffering         (GstObject * src, gint percent) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
479
void            gst_message_parse_buffering       (GstMessage *message, gint *percent);
480 481 482
void            gst_message_set_buffering_stats   (GstMessage *message, GstBufferingMode mode,
                                                   gint avg_in, gint avg_out,
                                                   gint64 buffering_left);
483 484 485 486 487
void            gst_message_parse_buffering_stats (GstMessage *message, GstBufferingMode *mode,
                                                   gint *avg_in, gint *avg_out,
                                                   gint64 *buffering_left);

/* STATE_CHANGED */
Wim Taymans's avatar
Wim Taymans committed
488
GstMessage *    gst_message_new_state_changed   (GstObject * src, GstState oldstate,
489
                                                 GstState newstate, GstState pending) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
490
void            gst_message_parse_state_changed (GstMessage *message, GstState *oldstate,
491 492 493
                                                 GstState *newstate, GstState *pending);

/* STATE_DIRTY */
494
GstMessage *    gst_message_new_state_dirty     (GstObject * src) G_GNUC_MALLOC;
495

Wim Taymans's avatar
Wim Taymans committed
496 497
/* STEP_DONE */
GstMessage *    gst_message_new_step_done       (GstObject * src, GstFormat format, guint64 amount,
Wim Taymans's avatar
Wim Taymans committed
498
                                                 gdouble rate, gboolean flush, gboolean intermediate,
499
                                                 guint64 duration, gboolean eos) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
500
void            gst_message_parse_step_done     (GstMessage * message, GstFormat *format, guint64 *amount,
501
                                                 gdouble *rate, gboolean *flush, gboolean *intermediate,
Wim Taymans's avatar
Wim Taymans committed
502
                                                 guint64 *duration, gboolean *eos);
503
/* CLOCK_PROVIDE */
504
GstMessage *    gst_message_new_clock_provide   (GstObject * src, GstClock *clock, gboolean ready) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
505
void            gst_message_parse_clock_provide (GstMessage *message, GstClock **clock,
506 507 508
                                                 gboolean *ready);

/* CLOCK_LOST */
509
GstMessage *    gst_message_new_clock_lost      (GstObject * src, GstClock *clock) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
510
void            gst_message_parse_clock_lost    (GstMessage *message, GstClock **clock);
511 512

/* NEW_CLOCK */
513
GstMessage *    gst_message_new_new_clock       (GstObject * src, GstClock *clock) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
514
void            gst_message_parse_new_clock     (GstMessage *message, GstClock **clock);
515 516

/* APPLICATION */
517
GstMessage *    gst_message_new_application     (GstObject * src, GstStructure * structure) G_GNUC_MALLOC;
518 519

/* ELEMENT */
520
GstMessage *    gst_message_new_element         (GstObject * src, GstStructure * structure) G_GNUC_MALLOC;
521 522

/* SEGMENT_START */
523
GstMessage *    gst_message_new_segment_start   (GstObject * src, GstFormat format, gint64 position) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
524
void            gst_message_parse_segment_start (GstMessage *message, GstFormat *format,
525 526 527
                                                 gint64 *position);

/* SEGMENT_DONE */
528
GstMessage *    gst_message_new_segment_done    (GstObject * src, GstFormat format, gint64 position) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
529
void            gst_message_parse_segment_done  (GstMessage *message, GstFormat *format,
530 531
                                                 gint64 *position);

532 533
/* DURATION_CHANGED */
GstMessage *    gst_message_new_duration_changed (GstObject * src) G_GNUC_MALLOC;
534 535

/* LATENCY */
536
GstMessage *    gst_message_new_latency         (GstObject * src) G_GNUC_MALLOC;
537 538

/* ASYNC_START */
539
GstMessage *    gst_message_new_async_start     (GstObject * src) G_GNUC_MALLOC;
540 541

/* ASYNC_DONE */
542 543
GstMessage *    gst_message_new_async_done      (GstObject * src, GstClockTime running_time) G_GNUC_MALLOC;
void            gst_message_parse_async_done    (GstMessage *message, GstClockTime *running_time);
544

545
/* STRUCTURE CHANGE */
Wim Taymans's avatar
Wim Taymans committed
546
GstMessage *    gst_message_new_structure_change   (GstObject * src, GstStructureChangeType type,
547
                                                    GstElement *owner, gboolean busy) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
548
void            gst_message_parse_structure_change (GstMessage *message, GstStructureChangeType *type,
549 550
                                                    GstElement **owner, gboolean *busy);

551
/* STREAM STATUS */
Wim Taymans's avatar
Wim Taymans committed
552
GstMessage *    gst_message_new_stream_status        (GstObject * src, GstStreamStatusType type,
553
                                                      GstElement *owner) G_GNUC_MALLOC;
Wim Taymans's avatar
Wim Taymans committed
554
void            gst_message_parse_stream_status      (GstMessage *message, GstStreamStatusType *type,
555 556 557 558
                                                      GstElement **owner);
void            gst_message_set_stream_status_object (GstMessage *message, const GValue *object);
const GValue *  gst_message_get_stream_status_object (GstMessage *message);

559
/* REQUEST_STATE */
560
GstMessage *    gst_message_new_request_state   (GstObject * src, GstState state) G_GNUC_MALLOC;
561 562
void            gst_message_parse_request_state (GstMessage * message, GstState *state);

563
/* STEP_START */
564 565
GstMessage *    gst_message_new_step_start      (GstObject * src, gboolean active, GstFormat format,
                                                 guint64 amount, gdouble rate, gboolean flush,
566
                                                 gboolean intermediate) G_GNUC_MALLOC;
567 568
void            gst_message_parse_step_start    (GstMessage * message, gboolean *active, GstFormat *format,
                                                 guint64 *amount, gdouble *rate, gboolean *flush,
Wim Taymans's avatar
Wim Taymans committed
569
                                                 gboolean *intermediate);
570

571 572
/* QOS */
GstMessage *    gst_message_new_qos             (GstObject * src, gboolean live, guint64 running_time,
573
                                                 guint64 stream_time, guint64 timestamp, guint64 duration) G_GNUC_MALLOC;
574 575 576 577 578 579 580 581 582 583
void            gst_message_set_qos_values      (GstMessage * message, gint64 jitter, gdouble proportion,
                                                 gint quality);
void            gst_message_set_qos_stats       (GstMessage * message, GstFormat format, guint64 processed,
                                                 guint64 dropped);
void            gst_message_parse_qos           (GstMessage * message, gboolean * live, guint64 * running_time,
                                                 guint64 * stream_time, guint64 * timestamp, guint64 * duration);
void            gst_message_parse_qos_values    (GstMessage * message, gint64 * jitter, gdouble * proportion,
                                                 gint * quality);
void            gst_message_parse_qos_stats     (GstMessage * message, GstFormat * format, guint64 * processed,
                                                 guint64 * dropped);
584
/* PROGRESS */
585
GstMessage *    gst_message_new_progress           (GstObject * src, GstProgressType type, const gchar *code,
586
                                                    const gchar *text) G_GNUC_MALLOC;
587
void            gst_message_parse_progress         (GstMessage * message, GstProgressType * type, gchar ** code,
588 589
                                                    gchar ** text);

Alexander Saprykin's avatar
Alexander Saprykin committed
590 591 592
/* TOC */
GstMessage *    gst_message_new_toc             (GstObject *src, GstToc *toc, gboolean updated);
void            gst_message_parse_toc           (GstMessage *message, GstToc **toc, gboolean *updated);
593

594 595 596 597
/* RESET_TIME */
GstMessage *    gst_message_new_reset_time      (GstObject * src, GstClockTime running_time) G_GNUC_MALLOC;
void            gst_message_parse_reset_time    (GstMessage *message, GstClockTime *running_time);

598 599 600
/* STREAM_START */
GstMessage *    gst_message_new_stream_start    (GstObject * src) G_GNUC_MALLOC;

601 602 603
void            gst_message_set_group_id        (GstMessage *message, guint group_id);
gboolean        gst_message_parse_group_id      (GstMessage *message, guint *group_id);

604
/* NEED_CONTEXT */
605 606
GstMessage *    gst_message_new_need_context    (GstObject * src, const gchar * context_type) G_GNUC_MALLOC;
gboolean        gst_message_parse_context_type  (GstMessage * message, const gchar ** context_type);
607 608 609 610 611

/* HAVE_CONTEXT */
GstMessage *    gst_message_new_have_context    (GstObject * src, GstContext *context) G_GNUC_MALLOC;
void            gst_message_parse_have_context  (GstMessage *message, GstContext **context);

612 613 614 615 616 617 618 619
/* DEVICE_ADDED */
GstMessage *    gst_message_new_device_added    (GstObject * src, GstDevice * device) G_GNUC_MALLOC;
void            gst_message_parse_device_added  (GstMessage * message, GstDevice ** device);

/* DEVICE_REMOVED */
GstMessage *    gst_message_new_device_removed    (GstObject * src, GstDevice * device) G_GNUC_MALLOC;
void            gst_message_parse_device_removed  (GstMessage * message, GstDevice ** device);

620 621 622
/* PROPERTY_NOTIFY */
GstMessage *    gst_message_new_property_notify   (GstObject * src, const gchar * property_name, GValue * val) G_GNUC_MALLOC;
void            gst_message_parse_property_notify (GstMessage * message, GstObject ** object, const gchar ** property_name, const GValue ** property_value);
623

624 625 626 627 628 629 630 631 632 633 634
/* STREAM_COLLECTION */
GstMessage *    gst_message_new_stream_collection   (GstObject * src, GstStreamCollection * collection) G_GNUC_MALLOC;
void            gst_message_parse_stream_collection (GstMessage *message, GstStreamCollection **collection);

/* STREAMS_SELECTED */
GstMessage *    gst_message_new_streams_selected (GstObject *src, GstStreamCollection *collection);
void            gst_message_streams_selected_add (GstMessage *message, GstStream *stream);
void            gst_message_parse_streams_selected (GstMessage * message, GstStreamCollection **collection);
guint           gst_message_streams_selected_get_size (GstMessage * message);
GstStream      *gst_message_streams_selected_get_stream (GstMessage *message, guint idx);

635 636 637 638 639 640
/* REDIRECT */
GstMessage *    gst_message_new_redirect             (GstObject * src, const gchar * location, GstTagList * tag_list, const GstStructure * entry_struct) G_GNUC_MALLOC;
void            gst_message_add_redirect_entry       (GstMessage * message, const gchar * location, GstTagList * tag_list, const GstStructure * entry_struct);
void            gst_message_parse_redirect_entry     (GstMessage * message, gsize entry_index, const gchar ** location, GstTagList ** tag_list, const GstStructure ** entry_struct);
gsize           gst_message_get_num_redirect_entries (GstMessage * message);

641 642 643 644
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMessage, gst_message_unref)
#endif

Wim Taymans's avatar
Wim Taymans committed
645
G_END_DECLS
Wim Taymans's avatar
Wim Taymans committed
646

Wim Taymans's avatar
Wim Taymans committed
647
#endif /* __GST_MESSAGE_H__ */