| 1 | /* GStreamer |
| 2 | * Copyright (C) 2004 Wim Taymans <wim@fluendo.com> |
| 3 | * |
| 4 | * gstmessage.h: Header for GstMessage subsystem |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Library General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Library General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Library General Public |
| 17 | * License along with this library; if not, write to the |
| 18 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
| 20 | */ |
| 21 | |
| 22 | #ifndef __GST_MESSAGE_H__ |
| 23 | #define __GST_MESSAGE_H__ |
| 24 | |
| 25 | #include <glib.h> |
| 26 | |
| 27 | G_BEGIN_DECLS |
| 28 | |
| 29 | typedef struct _GstMessage GstMessage; |
| 30 | |
| 31 | /** |
| 32 | * GstMessageType: |
| 33 | * @GST_MESSAGE_UNKNOWN: an undefined message |
| 34 | * @GST_MESSAGE_EOS: end-of-stream reached in a pipeline. The application will |
| 35 | * only receive this message in the PLAYING state and every time it sets a |
| 36 | * pipeline to PLAYING that is in the EOS state. The application can perform a |
| 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 | * message it should stop playback of the pipeline and not assume that more |
| 40 | * data will be played. It is possible to specify a redirection url to the error |
| 41 | * messages by setting a `redirect-location` field into the error message, application |
| 42 | * or high level bins might use the information as required. |
| 43 | * @GST_MESSAGE_WARNING: a warning occurred. |
| 44 | * @GST_MESSAGE_INFO: an info message occurred |
| 45 | * @GST_MESSAGE_TAG: a tag was found. |
| 46 | * @GST_MESSAGE_BUFFERING: the pipeline is buffering. When the application |
| 47 | * receives a buffering message in the PLAYING state for a non-live pipeline it |
| 48 | * must PAUSE the pipeline until the buffering completes, when the percentage |
| 49 | * field in the message is 100%. For live pipelines, no action must be |
| 50 | * performed and the buffering percentage can be used to inform the user about |
| 51 | * the progress. |
| 52 | * @GST_MESSAGE_STATE_CHANGED: a state change happened |
| 53 | * @GST_MESSAGE_STATE_DIRTY: an element changed state in a streaming thread. |
| 54 | * This message is deprecated. |
| 55 | * @GST_MESSAGE_STEP_DONE: a stepping operation finished. |
| 56 | * @GST_MESSAGE_CLOCK_PROVIDE: an element notifies its capability of providing |
| 57 | * a clock. This message is used internally and |
| 58 | * never forwarded to the application. |
| 59 | * @GST_MESSAGE_CLOCK_LOST: The current clock as selected by the pipeline became |
| 60 | * unusable. The pipeline will select a new clock on |
| 61 | * the next PLAYING state change. The application |
| 62 | * should set the pipeline to PAUSED and back to |
| 63 | * PLAYING when this message is received. |
| 64 | * @GST_MESSAGE_NEW_CLOCK: a new clock was selected in the pipeline. |
| 65 | * @GST_MESSAGE_STRUCTURE_CHANGE: the structure of the pipeline changed. This |
| 66 | * message is used internally and never forwarded to the application. |
| 67 | * @GST_MESSAGE_STREAM_STATUS: status about a stream, emitted when it starts, |
| 68 | * stops, errors, etc.. |
| 69 | * @GST_MESSAGE_APPLICATION: message posted by the application, possibly |
| 70 | * via an application-specific element. |
| 71 | * @GST_MESSAGE_ELEMENT: element-specific message, see the specific element's |
| 72 | * documentation |
| 73 | * @GST_MESSAGE_SEGMENT_START: pipeline started playback of a segment. This |
| 74 | * message is used internally and never forwarded to the application. |
| 75 | * @GST_MESSAGE_SEGMENT_DONE: pipeline completed playback of a segment. This |
| 76 | * message is forwarded to the application after all elements that posted |
| 77 | * @GST_MESSAGE_SEGMENT_START posted a GST_MESSAGE_SEGMENT_DONE message. |
| 78 | * @GST_MESSAGE_DURATION_CHANGED: The duration of a pipeline changed. The |
| 79 | * application can get the new duration with a duration query. |
| 80 | * @GST_MESSAGE_ASYNC_START: Posted by elements when they start an ASYNC |
| 81 | * #GstStateChange. This message is not forwarded to the application but is used |
| 82 | * internally. |
| 83 | * @GST_MESSAGE_ASYNC_DONE: Posted by elements when they complete an ASYNC |
| 84 | * #GstStateChange. The application will only receive this message from the toplevel |
| 85 | * pipeline. |
| 86 | * @GST_MESSAGE_LATENCY: Posted by elements when their latency changes. The |
| 87 | * application should recalculate and distribute a new latency. |
| 88 | * @GST_MESSAGE_REQUEST_STATE: Posted by elements when they want the pipeline to |
| 89 | * change state. This message is a suggestion to the application which can |
| 90 | * decide to perform the state change on (part of) the pipeline. |
| 91 | * @GST_MESSAGE_STEP_START: A stepping operation was started. |
| 92 | * @GST_MESSAGE_QOS: A buffer was dropped or an element changed its processing |
| 93 | * strategy for Quality of Service reasons. |
| 94 | * @GST_MESSAGE_PROGRESS: A progress message. |
| 95 | * @GST_MESSAGE_TOC: A new table of contents (TOC) was found or previously found TOC |
| 96 | * was updated. |
| 97 | * @GST_MESSAGE_RESET_TIME: Message to request resetting the pipeline's |
| 98 | * running time from the pipeline. This is an internal message which |
| 99 | * applications will likely never receive. |
| 100 | * @GST_MESSAGE_STREAM_START: Message indicating start of a new stream. Useful |
| 101 | * e.g. when using playbin in gapless playback mode, to get notified when |
| 102 | * the next title actually starts playing (which will be some time after |
| 103 | * the URI for the next title has been set). |
| 104 | * @GST_MESSAGE_NEED_CONTEXT: Message indicating that an element wants a specific context (Since: 1.2) |
| 105 | * @GST_MESSAGE_HAVE_CONTEXT: Message indicating that an element created a context (Since: 1.2) |
| 106 | * @GST_MESSAGE_EXTENDED: Message is an extended message type (see below). |
| 107 | * These extended message IDs can't be used directly with mask-based API |
| 108 | * like gst_bus_poll() or gst_bus_timed_pop_filtered(), but you can still |
| 109 | * filter for GST_MESSAGE_EXTENDED and then check the result for the |
| 110 | * specific type. (Since: 1.4) |
| 111 | * @GST_MESSAGE_DEVICE_ADDED: Message indicating a #GstDevice was added to |
| 112 | * a #GstDeviceProvider (Since: 1.4) |
| 113 | * @GST_MESSAGE_DEVICE_REMOVED: Message indicating a #GstDevice was removed |
| 114 | * from a #GstDeviceProvider (Since: 1.4) |
| 115 | * @GST_MESSAGE_PROPERTY_NOTIFY: Message indicating a #GObject property has |
| 116 | * changed (Since: 1.10) |
| 117 | * @GST_MESSAGE_STREAM_COLLECTION: Message indicating a new #GstStreamCollection |
| 118 | * is available (Since: 1.10) |
| 119 | * @GST_MESSAGE_STREAMS_SELECTED: Message indicating the active selection of |
| 120 | * #GstStreams has changed (Since: 1.10) |
| 121 | * @GST_MESSAGE_REDIRECT: Message indicating to request the application to |
| 122 | * try to play the given URL(s). Useful if for example a HTTP 302/303 |
| 123 | * response is received with a non-HTTP URL inside. (Since: 1.10) |
| 124 | * @GST_MESSAGE_DEVICE_CHANGED: Message indicating a #GstDevice was changed |
| 125 | * a #GstDeviceProvider (Since: 1.16) |
| 126 | * @GST_MESSAGE_INSTANT_RATE_REQUEST: Message sent by elements to request the |
| 127 | * running time from the pipeline when an instant rate change should |
| 128 | * be applied (which may be in the past when the answer arrives). (Since: 1.18) |
| 129 | * @GST_MESSAGE_ANY: mask for all of the above messages. |
| 130 | * |
| 131 | * The different message types that are available. |
| 132 | */ |
| 133 | /* NOTE: keep in sync with quark registration in gstmessage.c |
| 134 | * NOTE: keep GST_MESSAGE_ANY a valid gint to avoid compiler warnings. |
| 135 | */ |
| 136 | /* FIXME: 2.0: Make it NOT flags, just a regular 1,2,3,4.. enumeration */ |
| 137 | /* FIXME: For GST_MESSAGE_ANY ~0 -> 0xffffffff see |
| 138 | * https://bugzilla.gnome.org/show_bug.cgi?id=732633 |
| 139 | */ |
| 140 | typedef enum |
| 141 | { |
| 142 | GST_MESSAGE_UNKNOWN = 0, |
| 143 | GST_MESSAGE_EOS = (1 << 0), |
| 144 | GST_MESSAGE_ERROR = (1 << 1), |
| 145 | GST_MESSAGE_WARNING = (1 << 2), |
| 146 | GST_MESSAGE_INFO = (1 << 3), |
| 147 | GST_MESSAGE_TAG = (1 << 4), |
| 148 | GST_MESSAGE_BUFFERING = (1 << 5), |
| 149 | GST_MESSAGE_STATE_CHANGED = (1 << 6), |
| 150 | GST_MESSAGE_STATE_DIRTY = (1 << 7), |
| 151 | GST_MESSAGE_STEP_DONE = (1 << 8), |
| 152 | GST_MESSAGE_CLOCK_PROVIDE = (1 << 9), |
| 153 | GST_MESSAGE_CLOCK_LOST = (1 << 10), |
| 154 | GST_MESSAGE_NEW_CLOCK = (1 << 11), |
| 155 | GST_MESSAGE_STRUCTURE_CHANGE = (1 << 12), |
| 156 | GST_MESSAGE_STREAM_STATUS = (1 << 13), |
| 157 | GST_MESSAGE_APPLICATION = (1 << 14), |
| 158 | GST_MESSAGE_ELEMENT = (1 << 15), |
| 159 | GST_MESSAGE_SEGMENT_START = (1 << 16), |
| 160 | GST_MESSAGE_SEGMENT_DONE = (1 << 17), |
| 161 | GST_MESSAGE_DURATION_CHANGED = (1 << 18), |
| 162 | GST_MESSAGE_LATENCY = (1 << 19), |
| 163 | GST_MESSAGE_ASYNC_START = (1 << 20), |
| 164 | GST_MESSAGE_ASYNC_DONE = (1 << 21), |
| 165 | GST_MESSAGE_REQUEST_STATE = (1 << 22), |
| 166 | GST_MESSAGE_STEP_START = (1 << 23), |
| 167 | GST_MESSAGE_QOS = (1 << 24), |
| 168 | GST_MESSAGE_PROGRESS = (1 << 25), |
| 169 | GST_MESSAGE_TOC = (1 << 26), |
| 170 | GST_MESSAGE_RESET_TIME = (1 << 27), |
| 171 | GST_MESSAGE_STREAM_START = (1 << 28), |
| 172 | GST_MESSAGE_NEED_CONTEXT = (1 << 29), |
| 173 | GST_MESSAGE_HAVE_CONTEXT = (1 << 30), |
| 174 | GST_MESSAGE_EXTENDED = (gint) (1u << 31), |
| 175 | GST_MESSAGE_DEVICE_ADDED = GST_MESSAGE_EXTENDED + 1, |
| 176 | GST_MESSAGE_DEVICE_REMOVED = GST_MESSAGE_EXTENDED + 2, |
| 177 | GST_MESSAGE_PROPERTY_NOTIFY = GST_MESSAGE_EXTENDED + 3, |
| 178 | GST_MESSAGE_STREAM_COLLECTION = GST_MESSAGE_EXTENDED + 4, |
| 179 | GST_MESSAGE_STREAMS_SELECTED = GST_MESSAGE_EXTENDED + 5, |
| 180 | GST_MESSAGE_REDIRECT = GST_MESSAGE_EXTENDED + 6, |
| 181 | GST_MESSAGE_DEVICE_CHANGED = GST_MESSAGE_EXTENDED + 7, |
| 182 | GST_MESSAGE_INSTANT_RATE_REQUEST = GST_MESSAGE_EXTENDED + 8, |
| 183 | GST_MESSAGE_ANY = (gint) (0xffffffff) |
| 184 | } GstMessageType; |
| 185 | |
| 186 | #include <gst/gstminiobject.h> |
| 187 | #include <gst/gstobject.h> |
| 188 | #include <gst/gstelement.h> |
| 189 | #include <gst/gsttaglist.h> |
| 190 | #include <gst/gststructure.h> |
| 191 | #include <gst/gstquery.h> |
| 192 | #include <gst/gsttoc.h> |
| 193 | #include <gst/gstdevice.h> |
| 194 | #include <gst/gststreams.h> |
| 195 | #include <gst/gststreamcollection.h> |
| 196 | |
| 197 | GST_API GType _gst_message_type; |
| 198 | |
| 199 | #define GST_TYPE_MESSAGE (_gst_message_type) |
| 200 | #define GST_IS_MESSAGE(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_MESSAGE)) |
| 201 | #define GST_MESSAGE_CAST(obj) ((GstMessage*)(obj)) |
| 202 | #define GST_MESSAGE(obj) (GST_MESSAGE_CAST(obj)) |
| 203 | |
| 204 | /* the lock is used to handle the synchronous handling of messages, |
| 205 | * the emitting thread is blocked until the handling thread processed |
| 206 | * the message using this mutex/cond pair */ |
| 207 | #define GST_MESSAGE_GET_LOCK(message) (&GST_MESSAGE_CAST(message)->lock) |
| 208 | #define GST_MESSAGE_LOCK(message) g_mutex_lock(GST_MESSAGE_GET_LOCK(message)) |
| 209 | #define GST_MESSAGE_UNLOCK(message) g_mutex_unlock(GST_MESSAGE_GET_LOCK(message)) |
| 210 | #define GST_MESSAGE_GET_COND(message) (&GST_MESSAGE_CAST(message)->cond) |
| 211 | #define GST_MESSAGE_WAIT(message) g_cond_wait(GST_MESSAGE_GET_COND(message),GST_MESSAGE_GET_LOCK(message)) |
| 212 | #define GST_MESSAGE_SIGNAL(message) g_cond_signal(GST_MESSAGE_GET_COND(message)) |
| 213 | |
| 214 | /** |
| 215 | * GST_MESSAGE_TYPE: |
| 216 | * @message: a #GstMessage |
| 217 | * |
| 218 | * Get the #GstMessageType of @message. |
| 219 | */ |
| 220 | #define GST_MESSAGE_TYPE(message) (GST_MESSAGE_CAST(message)->type) |
| 221 | /** |
| 222 | * GST_MESSAGE_TYPE_IS_EXTENDED: |
| 223 | * @message: a #GstMessage |
| 224 | * |
| 225 | * Check if the message is in the extended message group |
| 226 | * Since: 1.4 |
| 227 | */ |
| 228 | #define GST_MESSAGE_TYPE_IS_EXTENDED(message) (!!(GST_MESSAGE_CAST(message)->type & GST_MESSAGE_EXTENDED)) |
| 229 | |
| 230 | /** |
| 231 | * GST_MESSAGE_TYPE_NAME: |
| 232 | * @message: a #GstMessage |
| 233 | * |
| 234 | * Get a constant string representation of the #GstMessageType of @message. |
| 235 | */ |
| 236 | #define GST_MESSAGE_TYPE_NAME(message) gst_message_type_get_name(GST_MESSAGE_TYPE(message)) |
| 237 | /** |
| 238 | * GST_MESSAGE_TIMESTAMP: |
| 239 | * @message: a #GstMessage |
| 240 | * |
| 241 | * Get the timestamp of @message. This is the timestamp when the message |
| 242 | * was created. |
| 243 | */ |
| 244 | #define GST_MESSAGE_TIMESTAMP(message) (GST_MESSAGE_CAST(message)->timestamp) |
| 245 | /** |
| 246 | * GST_MESSAGE_SRC: |
| 247 | * @message: a #GstMessage |
| 248 | * |
| 249 | * Get the object that posted @message. |
| 250 | */ |
| 251 | #define GST_MESSAGE_SRC(message) (GST_MESSAGE_CAST(message)->src) |
| 252 | |
| 253 | /** |
| 254 | * GST_MESSAGE_SEQNUM: |
| 255 | * @message: a #GstMessage |
| 256 | * |
| 257 | * Get the sequence number of @message. |
| 258 | */ |
| 259 | #define GST_MESSAGE_SEQNUM(message) (GST_MESSAGE_CAST(message)->seqnum) |
| 260 | |
| 261 | /** |
| 262 | * GST_MESSAGE_SRC_NAME: |
| 263 | * @message: a #GstMessage |
| 264 | * |
| 265 | * Get the name of the object that posted @message. Returns "(NULL)" if |
| 266 | * the message has no source object set. |
| 267 | */ |
| 268 | #define GST_MESSAGE_SRC_NAME(message) (GST_MESSAGE_SRC(message) ? \ |
| 269 | GST_OBJECT_NAME (GST_MESSAGE_SRC(message)) : "(NULL)") |
| 270 | |
| 271 | /** |
| 272 | * GstStructureChangeType: |
| 273 | * @GST_STRUCTURE_CHANGE_TYPE_PAD_LINK: Pad linking is starting or done. |
| 274 | * @GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK: Pad unlinking is starting or done. |
| 275 | * |
| 276 | * The type of a %GST_MESSAGE_STRUCTURE_CHANGE. |
| 277 | */ |
| 278 | typedef enum { |
| 279 | GST_STRUCTURE_CHANGE_TYPE_PAD_LINK = 0, |
| 280 | GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK = 1 |
| 281 | } GstStructureChangeType; |
| 282 | |
| 283 | /** |
| 284 | * GstStreamStatusType: |
| 285 | * @GST_STREAM_STATUS_TYPE_CREATE: A new thread need to be created. |
| 286 | * @GST_STREAM_STATUS_TYPE_ENTER: a thread entered its loop function |
| 287 | * @GST_STREAM_STATUS_TYPE_LEAVE: a thread left its loop function |
| 288 | * @GST_STREAM_STATUS_TYPE_DESTROY: a thread is destroyed |
| 289 | * @GST_STREAM_STATUS_TYPE_START: a thread is started |
| 290 | * @GST_STREAM_STATUS_TYPE_PAUSE: a thread is paused |
| 291 | * @GST_STREAM_STATUS_TYPE_STOP: a thread is stopped |
| 292 | * |
| 293 | * The type of a %GST_MESSAGE_STREAM_STATUS. The stream status messages inform the |
| 294 | * application of new streaming threads and their status. |
| 295 | */ |
| 296 | typedef enum { |
| 297 | GST_STREAM_STATUS_TYPE_CREATE = 0, |
| 298 | GST_STREAM_STATUS_TYPE_ENTER = 1, |
| 299 | GST_STREAM_STATUS_TYPE_LEAVE = 2, |
| 300 | GST_STREAM_STATUS_TYPE_DESTROY = 3, |
| 301 | |
| 302 | GST_STREAM_STATUS_TYPE_START = 8, |
| 303 | GST_STREAM_STATUS_TYPE_PAUSE = 9, |
| 304 | GST_STREAM_STATUS_TYPE_STOP = 10 |
| 305 | } GstStreamStatusType; |
| 306 | |
| 307 | /** |
| 308 | * GstProgressType: |
| 309 | * @GST_PROGRESS_TYPE_START: A new task started. |
| 310 | * @GST_PROGRESS_TYPE_CONTINUE: A task completed and a new one continues. |
| 311 | * @GST_PROGRESS_TYPE_COMPLETE: A task completed. |
| 312 | * @GST_PROGRESS_TYPE_CANCELED: A task was canceled. |
| 313 | * @GST_PROGRESS_TYPE_ERROR: A task caused an error. An error message is also |
| 314 | * posted on the bus. |
| 315 | * |
| 316 | * The type of a %GST_MESSAGE_PROGRESS. The progress messages inform the |
| 317 | * application of the status of asynchronous tasks. |
| 318 | */ |
| 319 | typedef enum { |
| 320 | GST_PROGRESS_TYPE_START = 0, |
| 321 | GST_PROGRESS_TYPE_CONTINUE = 1, |
| 322 | GST_PROGRESS_TYPE_COMPLETE = 2, |
| 323 | GST_PROGRESS_TYPE_CANCELED = 3, |
| 324 | GST_PROGRESS_TYPE_ERROR = 4 |
| 325 | } GstProgressType; |
| 326 | |
| 327 | /** |
| 328 | * GstMessage: |
| 329 | * @mini_object: the parent structure |
| 330 | * @type: the #GstMessageType of the message |
| 331 | * @timestamp: the timestamp of the message |
| 332 | * @src: the src of the message |
| 333 | * @seqnum: the sequence number of the message |
| 334 | * |
| 335 | * A #GstMessage. |
| 336 | */ |
| 337 | struct _GstMessage |
| 338 | { |
| 339 | GstMiniObject mini_object; |
| 340 | |
| 341 | /*< public > *//* with COW */ |
| 342 | GstMessageType type; |
| 343 | guint64 timestamp; |
| 344 | GstObject *src; |
| 345 | guint32 seqnum; |
| 346 | |
| 347 | /*< private >*//* with MESSAGE_LOCK */ |
| 348 | GMutex lock; /* lock and cond for async delivery */ |
| 349 | GCond cond; |
| 350 | }; |
| 351 | |
| 352 | #include <gst/gstquery.h> |
| 353 | |
| 354 | GST_API |
| 355 | GType gst_message_get_type (void); |
| 356 | |
| 357 | GST_API |
| 358 | const gchar* gst_message_type_get_name (GstMessageType type); |
| 359 | |
| 360 | GST_API |
| 361 | GQuark gst_message_type_to_quark (GstMessageType type); |
| 362 | |
| 363 | #ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS |
| 364 | /* refcounting */ |
| 365 | static inline GstMessage * |
| 366 | gst_message_ref (GstMessage * msg) |
| 367 | { |
| 368 | return (GstMessage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (msg)); |
| 369 | } |
| 370 | |
| 371 | static inline void |
| 372 | gst_message_unref (GstMessage * msg) |
| 373 | { |
| 374 | gst_mini_object_unref (GST_MINI_OBJECT_CAST (msg)); |
| 375 | } |
| 376 | |
| 377 | static inline void |
| 378 | gst_clear_message (GstMessage ** msg_ptr) |
| 379 | { |
| 380 | gst_clear_mini_object ((GstMiniObject **) msg_ptr); |
| 381 | } |
| 382 | |
| 383 | /* copy message */ |
| 384 | static inline GstMessage * gst_message_copy (const GstMessage * msg); |
| 385 | static inline GstMessage * |
| 386 | gst_message_copy (const GstMessage * msg) |
| 387 | { |
| 388 | return GST_MESSAGE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (msg))); |
| 389 | } |
| 390 | #else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */ |
| 391 | GST_API |
| 392 | GstMessage * gst_message_ref (GstMessage * msg); |
| 393 | |
| 394 | GST_API |
| 395 | void gst_message_unref (GstMessage * msg); |
| 396 | |
| 397 | GST_API |
| 398 | void gst_clear_message (GstMessage ** msg_ptr); |
| 399 | |
| 400 | GST_API |
| 401 | GstMessage * gst_message_copy (const GstMessage * msg); |
| 402 | #endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */ |
| 403 | |
| 404 | /** |
| 405 | * gst_message_is_writable: |
| 406 | * @msg: a #GstMessage |
| 407 | * |
| 408 | * Tests if you can safely write into a message's structure or validly |
| 409 | * modify the seqnum and timestamp fields. |
| 410 | */ |
| 411 | #define gst_message_is_writable(msg) gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (msg)) |
| 412 | /** |
| 413 | * gst_message_make_writable: |
| 414 | * @msg: (transfer full): the message to make writable |
| 415 | * |
| 416 | * Checks if a message is writable. If not, a writable copy is made and |
| 417 | * returned. |
| 418 | * |
| 419 | * Returns: (transfer full): a message (possibly a duplicate) that is writable. |
| 420 | * |
| 421 | * MT safe |
| 422 | */ |
| 423 | #define gst_message_make_writable(msg) GST_MESSAGE_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (msg))) |
| 424 | |
| 425 | #ifndef GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS |
| 426 | static inline gboolean gst_message_replace (GstMessage **old_message, GstMessage *new_message); |
| 427 | static inline gboolean |
| 428 | gst_message_replace (GstMessage **old_message, GstMessage *new_message) |
| 429 | { |
| 430 | return gst_mini_object_replace (olddata: (GstMiniObject **) old_message, newdata: (GstMiniObject *) new_message); |
| 431 | } |
| 432 | |
| 433 | static inline gboolean |
| 434 | gst_message_take (GstMessage **old_message, GstMessage *new_message) |
| 435 | { |
| 436 | return gst_mini_object_take (olddata: (GstMiniObject **) old_message, |
| 437 | newdata: (GstMiniObject *) new_message); |
| 438 | } |
| 439 | #else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */ |
| 440 | GST_API |
| 441 | gboolean gst_message_replace (GstMessage ** old_message, |
| 442 | GstMessage * new_message); |
| 443 | |
| 444 | GST_API |
| 445 | gboolean gst_message_take (GstMessage ** old_message, |
| 446 | GstMessage * new_message); |
| 447 | #endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */ |
| 448 | |
| 449 | /* custom messages */ |
| 450 | |
| 451 | GST_API |
| 452 | GstMessage * gst_message_new_custom (GstMessageType type, |
| 453 | GstObject * src, |
| 454 | GstStructure * structure) G_GNUC_MALLOC; |
| 455 | GST_API |
| 456 | const GstStructure * |
| 457 | gst_message_get_structure (GstMessage *message); |
| 458 | |
| 459 | GST_API |
| 460 | GstStructure * gst_message_writable_structure (GstMessage *message); |
| 461 | |
| 462 | GST_API |
| 463 | gboolean gst_message_has_name (GstMessage *message, const gchar *name); |
| 464 | |
| 465 | /* identifiers for events and messages */ |
| 466 | |
| 467 | GST_API |
| 468 | guint32 gst_message_get_seqnum (GstMessage *message); |
| 469 | |
| 470 | GST_API |
| 471 | void gst_message_set_seqnum (GstMessage *message, guint32 seqnum); |
| 472 | |
| 473 | /* EOS */ |
| 474 | |
| 475 | GST_API |
| 476 | GstMessage * gst_message_new_eos (GstObject * src) G_GNUC_MALLOC; |
| 477 | |
| 478 | /* ERROR */ |
| 479 | |
| 480 | GST_API |
| 481 | GstMessage * gst_message_new_error (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC; |
| 482 | |
| 483 | GST_API |
| 484 | GstMessage * gst_message_new_error_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC; |
| 485 | |
| 486 | GST_API |
| 487 | void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug); |
| 488 | |
| 489 | GST_API |
| 490 | void gst_message_parse_error_details (GstMessage *message, const GstStructure **structure); |
| 491 | |
| 492 | /* WARNING */ |
| 493 | |
| 494 | GST_API |
| 495 | GstMessage * gst_message_new_warning (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC; |
| 496 | |
| 497 | GST_API |
| 498 | GstMessage * gst_message_new_warning_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC; |
| 499 | |
| 500 | GST_API |
| 501 | void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug); |
| 502 | |
| 503 | GST_API |
| 504 | void gst_message_parse_warning_details (GstMessage *message, const GstStructure **structure); |
| 505 | |
| 506 | /* INFO */ |
| 507 | |
| 508 | GST_API |
| 509 | GstMessage * gst_message_new_info (GstObject * src, GError * error, const gchar * debug) G_GNUC_MALLOC; |
| 510 | |
| 511 | GST_API |
| 512 | GstMessage * gst_message_new_info_with_details (GstObject * src, GError * error, const gchar * debug, GstStructure * details) G_GNUC_MALLOC; |
| 513 | |
| 514 | GST_API |
| 515 | void gst_message_parse_info (GstMessage *message, GError **gerror, gchar **debug); |
| 516 | |
| 517 | GST_API |
| 518 | void gst_message_parse_info_details (GstMessage *message, const GstStructure **structure); |
| 519 | |
| 520 | /* TAG */ |
| 521 | |
| 522 | GST_API |
| 523 | GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list) G_GNUC_MALLOC; |
| 524 | |
| 525 | GST_API |
| 526 | void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list); |
| 527 | |
| 528 | /* BUFFERING */ |
| 529 | |
| 530 | GST_API |
| 531 | GstMessage * gst_message_new_buffering (GstObject * src, gint percent) G_GNUC_MALLOC; |
| 532 | |
| 533 | GST_API |
| 534 | void gst_message_parse_buffering (GstMessage *message, gint *percent); |
| 535 | |
| 536 | GST_API |
| 537 | void gst_message_set_buffering_stats (GstMessage *message, GstBufferingMode mode, |
| 538 | gint avg_in, gint avg_out, |
| 539 | gint64 buffering_left); |
| 540 | GST_API |
| 541 | void gst_message_parse_buffering_stats (GstMessage *message, GstBufferingMode *mode, |
| 542 | gint *avg_in, gint *avg_out, |
| 543 | gint64 *buffering_left); |
| 544 | |
| 545 | /* STATE_CHANGED */ |
| 546 | |
| 547 | GST_API |
| 548 | GstMessage * gst_message_new_state_changed (GstObject * src, GstState oldstate, |
| 549 | GstState newstate, GstState pending) G_GNUC_MALLOC; |
| 550 | GST_API |
| 551 | void gst_message_parse_state_changed (GstMessage *message, GstState *oldstate, |
| 552 | GstState *newstate, GstState *pending); |
| 553 | |
| 554 | /* STATE_DIRTY */ |
| 555 | |
| 556 | GST_API |
| 557 | GstMessage * gst_message_new_state_dirty (GstObject * src) G_GNUC_MALLOC; |
| 558 | |
| 559 | /* STEP_DONE */ |
| 560 | |
| 561 | GST_API |
| 562 | GstMessage * gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount, |
| 563 | gdouble rate, gboolean flush, gboolean intermediate, |
| 564 | guint64 duration, gboolean eos) G_GNUC_MALLOC; |
| 565 | GST_API |
| 566 | void gst_message_parse_step_done (GstMessage * message, GstFormat *format, guint64 *amount, |
| 567 | gdouble *rate, gboolean *flush, gboolean *intermediate, |
| 568 | guint64 *duration, gboolean *eos); |
| 569 | /* CLOCK_PROVIDE */ |
| 570 | |
| 571 | GST_API |
| 572 | GstMessage * gst_message_new_clock_provide (GstObject * src, GstClock *clock, gboolean ready) G_GNUC_MALLOC; |
| 573 | |
| 574 | GST_API |
| 575 | void gst_message_parse_clock_provide (GstMessage *message, GstClock **clock, |
| 576 | gboolean *ready); |
| 577 | |
| 578 | /* CLOCK_LOST */ |
| 579 | |
| 580 | GST_API |
| 581 | GstMessage * gst_message_new_clock_lost (GstObject * src, GstClock *clock) G_GNUC_MALLOC; |
| 582 | |
| 583 | GST_API |
| 584 | void gst_message_parse_clock_lost (GstMessage *message, GstClock **clock); |
| 585 | |
| 586 | /* NEW_CLOCK */ |
| 587 | |
| 588 | GST_API |
| 589 | GstMessage * gst_message_new_new_clock (GstObject * src, GstClock *clock) G_GNUC_MALLOC; |
| 590 | |
| 591 | GST_API |
| 592 | void gst_message_parse_new_clock (GstMessage *message, GstClock **clock); |
| 593 | |
| 594 | /* APPLICATION */ |
| 595 | |
| 596 | GST_API |
| 597 | GstMessage * gst_message_new_application (GstObject * src, GstStructure * structure) G_GNUC_MALLOC; |
| 598 | |
| 599 | /* ELEMENT */ |
| 600 | |
| 601 | GST_API |
| 602 | GstMessage * gst_message_new_element (GstObject * src, GstStructure * structure) G_GNUC_MALLOC; |
| 603 | |
| 604 | /* SEGMENT_START */ |
| 605 | |
| 606 | GST_API |
| 607 | GstMessage * gst_message_new_segment_start (GstObject * src, GstFormat format, gint64 position) G_GNUC_MALLOC; |
| 608 | |
| 609 | GST_API |
| 610 | void gst_message_parse_segment_start (GstMessage *message, GstFormat *format, |
| 611 | gint64 *position); |
| 612 | |
| 613 | /* SEGMENT_DONE */ |
| 614 | |
| 615 | GST_API |
| 616 | GstMessage * gst_message_new_segment_done (GstObject * src, GstFormat format, gint64 position) G_GNUC_MALLOC; |
| 617 | |
| 618 | GST_API |
| 619 | void gst_message_parse_segment_done (GstMessage *message, GstFormat *format, |
| 620 | gint64 *position); |
| 621 | |
| 622 | /* DURATION_CHANGED */ |
| 623 | |
| 624 | GST_API |
| 625 | GstMessage * gst_message_new_duration_changed (GstObject * src) G_GNUC_MALLOC; |
| 626 | |
| 627 | /* LATENCY */ |
| 628 | |
| 629 | GST_API |
| 630 | GstMessage * gst_message_new_latency (GstObject * src) G_GNUC_MALLOC; |
| 631 | |
| 632 | /* ASYNC_START */ |
| 633 | |
| 634 | GST_API |
| 635 | GstMessage * gst_message_new_async_start (GstObject * src) G_GNUC_MALLOC; |
| 636 | |
| 637 | /* ASYNC_DONE */ |
| 638 | |
| 639 | GST_API |
| 640 | GstMessage * gst_message_new_async_done (GstObject * src, GstClockTime running_time) G_GNUC_MALLOC; |
| 641 | |
| 642 | GST_API |
| 643 | void gst_message_parse_async_done (GstMessage *message, GstClockTime *running_time); |
| 644 | |
| 645 | /* STRUCTURE CHANGE */ |
| 646 | |
| 647 | GST_API |
| 648 | GstMessage * gst_message_new_structure_change (GstObject * src, GstStructureChangeType type, |
| 649 | GstElement *owner, gboolean busy) G_GNUC_MALLOC; |
| 650 | GST_API |
| 651 | void gst_message_parse_structure_change (GstMessage *message, GstStructureChangeType *type, |
| 652 | GstElement **owner, gboolean *busy); |
| 653 | |
| 654 | /* STREAM STATUS */ |
| 655 | |
| 656 | GST_API |
| 657 | GstMessage * gst_message_new_stream_status (GstObject * src, GstStreamStatusType type, |
| 658 | GstElement *owner) G_GNUC_MALLOC; |
| 659 | GST_API |
| 660 | void gst_message_parse_stream_status (GstMessage *message, GstStreamStatusType *type, |
| 661 | GstElement **owner); |
| 662 | GST_API |
| 663 | void gst_message_set_stream_status_object (GstMessage *message, const GValue *object); |
| 664 | |
| 665 | GST_API |
| 666 | const GValue * gst_message_get_stream_status_object (GstMessage *message); |
| 667 | |
| 668 | /* REQUEST_STATE */ |
| 669 | |
| 670 | GST_API |
| 671 | GstMessage * gst_message_new_request_state (GstObject * src, GstState state) G_GNUC_MALLOC; |
| 672 | |
| 673 | GST_API |
| 674 | void gst_message_parse_request_state (GstMessage * message, GstState *state); |
| 675 | |
| 676 | /* STEP_START */ |
| 677 | |
| 678 | GST_API |
| 679 | GstMessage * gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format, |
| 680 | guint64 amount, gdouble rate, gboolean flush, |
| 681 | gboolean intermediate) G_GNUC_MALLOC; |
| 682 | GST_API |
| 683 | void gst_message_parse_step_start (GstMessage * message, gboolean *active, GstFormat *format, |
| 684 | guint64 *amount, gdouble *rate, gboolean *flush, |
| 685 | gboolean *intermediate); |
| 686 | |
| 687 | /* QOS */ |
| 688 | |
| 689 | GST_API |
| 690 | GstMessage * gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time, |
| 691 | guint64 stream_time, guint64 timestamp, guint64 duration) G_GNUC_MALLOC; |
| 692 | GST_API |
| 693 | void gst_message_set_qos_values (GstMessage * message, gint64 jitter, gdouble proportion, |
| 694 | gint quality); |
| 695 | GST_API |
| 696 | void gst_message_set_qos_stats (GstMessage * message, GstFormat format, guint64 processed, |
| 697 | guint64 dropped); |
| 698 | GST_API |
| 699 | void gst_message_parse_qos (GstMessage * message, gboolean * live, guint64 * running_time, |
| 700 | guint64 * stream_time, guint64 * timestamp, guint64 * duration); |
| 701 | GST_API |
| 702 | void gst_message_parse_qos_values (GstMessage * message, gint64 * jitter, gdouble * proportion, |
| 703 | gint * quality); |
| 704 | GST_API |
| 705 | void gst_message_parse_qos_stats (GstMessage * message, GstFormat * format, guint64 * processed, |
| 706 | guint64 * dropped); |
| 707 | /* PROGRESS */ |
| 708 | |
| 709 | GST_API |
| 710 | GstMessage * gst_message_new_progress (GstObject * src, GstProgressType type, const gchar *code, |
| 711 | const gchar *text) G_GNUC_MALLOC; |
| 712 | GST_API |
| 713 | void gst_message_parse_progress (GstMessage * message, GstProgressType * type, gchar ** code, |
| 714 | gchar ** text); |
| 715 | |
| 716 | /* TOC */ |
| 717 | |
| 718 | GST_API |
| 719 | GstMessage * gst_message_new_toc (GstObject *src, GstToc *toc, gboolean updated); |
| 720 | |
| 721 | GST_API |
| 722 | void gst_message_parse_toc (GstMessage *message, GstToc **toc, gboolean *updated); |
| 723 | |
| 724 | /* RESET_TIME */ |
| 725 | |
| 726 | GST_API |
| 727 | GstMessage * gst_message_new_reset_time (GstObject * src, GstClockTime running_time) G_GNUC_MALLOC; |
| 728 | |
| 729 | GST_API |
| 730 | void gst_message_parse_reset_time (GstMessage *message, GstClockTime *running_time); |
| 731 | |
| 732 | /* STREAM_START */ |
| 733 | |
| 734 | GST_API |
| 735 | GstMessage * gst_message_new_stream_start (GstObject * src) G_GNUC_MALLOC; |
| 736 | |
| 737 | GST_API |
| 738 | void gst_message_set_group_id (GstMessage *message, guint group_id); |
| 739 | |
| 740 | GST_API |
| 741 | gboolean gst_message_parse_group_id (GstMessage *message, guint *group_id); |
| 742 | |
| 743 | /* NEED_CONTEXT */ |
| 744 | |
| 745 | GST_API |
| 746 | GstMessage * gst_message_new_need_context (GstObject * src, const gchar * context_type) G_GNUC_MALLOC; |
| 747 | |
| 748 | GST_API |
| 749 | gboolean gst_message_parse_context_type (GstMessage * message, const gchar ** context_type); |
| 750 | |
| 751 | /* HAVE_CONTEXT */ |
| 752 | |
| 753 | GST_API |
| 754 | GstMessage * gst_message_new_have_context (GstObject * src, GstContext *context) G_GNUC_MALLOC; |
| 755 | |
| 756 | GST_API |
| 757 | void gst_message_parse_have_context (GstMessage *message, GstContext **context); |
| 758 | |
| 759 | /* DEVICE_ADDED */ |
| 760 | |
| 761 | GST_API |
| 762 | GstMessage * gst_message_new_device_added (GstObject * src, GstDevice * device) G_GNUC_MALLOC; |
| 763 | |
| 764 | GST_API |
| 765 | void gst_message_parse_device_added (GstMessage * message, GstDevice ** device); |
| 766 | |
| 767 | /* DEVICE_REMOVED */ |
| 768 | |
| 769 | GST_API |
| 770 | GstMessage * gst_message_new_device_removed (GstObject * src, GstDevice * device) G_GNUC_MALLOC; |
| 771 | |
| 772 | GST_API |
| 773 | void gst_message_parse_device_removed (GstMessage * message, GstDevice ** device); |
| 774 | |
| 775 | /* DEVICE_CHANGED */ |
| 776 | |
| 777 | GST_API |
| 778 | GstMessage * gst_message_new_device_changed (GstObject * src, GstDevice * device, GstDevice *changed_device); |
| 779 | |
| 780 | GST_API |
| 781 | void gst_message_parse_device_changed (GstMessage * message, GstDevice ** device, GstDevice ** changed_device); |
| 782 | |
| 783 | |
| 784 | /* PROPERTY_NOTIFY */ |
| 785 | |
| 786 | GST_API |
| 787 | GstMessage * gst_message_new_property_notify (GstObject * src, const gchar * property_name, GValue * val) G_GNUC_MALLOC; |
| 788 | |
| 789 | GST_API |
| 790 | void gst_message_parse_property_notify (GstMessage * message, GstObject ** object, const gchar ** property_name, const GValue ** property_value); |
| 791 | |
| 792 | /* STREAM_COLLECTION */ |
| 793 | |
| 794 | GST_API |
| 795 | GstMessage * gst_message_new_stream_collection (GstObject * src, GstStreamCollection * collection) G_GNUC_MALLOC; |
| 796 | |
| 797 | GST_API |
| 798 | void gst_message_parse_stream_collection (GstMessage *message, GstStreamCollection **collection); |
| 799 | |
| 800 | /* STREAMS_SELECTED */ |
| 801 | |
| 802 | GST_API |
| 803 | GstMessage * gst_message_new_streams_selected (GstObject *src, GstStreamCollection *collection); |
| 804 | |
| 805 | GST_API |
| 806 | void gst_message_streams_selected_add (GstMessage *message, GstStream *stream); |
| 807 | |
| 808 | GST_API |
| 809 | void gst_message_parse_streams_selected (GstMessage * message, GstStreamCollection **collection); |
| 810 | |
| 811 | GST_API |
| 812 | guint gst_message_streams_selected_get_size (GstMessage * message); |
| 813 | |
| 814 | GST_API |
| 815 | GstStream *gst_message_streams_selected_get_stream (GstMessage *message, guint idx); |
| 816 | |
| 817 | /* REDIRECT */ |
| 818 | |
| 819 | GST_API |
| 820 | GstMessage * gst_message_new_redirect (GstObject * src, const gchar * location, GstTagList * tag_list, const GstStructure * entry_struct) G_GNUC_MALLOC; |
| 821 | |
| 822 | GST_API |
| 823 | void gst_message_add_redirect_entry (GstMessage * message, const gchar * location, GstTagList * tag_list, const GstStructure * entry_struct); |
| 824 | |
| 825 | GST_API |
| 826 | void gst_message_parse_redirect_entry (GstMessage * message, gsize entry_index, const gchar ** location, GstTagList ** tag_list, const GstStructure ** entry_struct); |
| 827 | |
| 828 | GST_API |
| 829 | gsize gst_message_get_num_redirect_entries (GstMessage * message); |
| 830 | |
| 831 | /* INSTANT_RATE_REQUEST */ |
| 832 | |
| 833 | GST_API |
| 834 | GstMessage * gst_message_new_instant_rate_request (GstObject * src, gdouble rate_multiplier) G_GNUC_MALLOC; |
| 835 | GST_API |
| 836 | void gst_message_parse_instant_rate_request (GstMessage * message, gdouble * rate_multiplier); |
| 837 | |
| 838 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstMessage, gst_message_unref) |
| 839 | |
| 840 | G_END_DECLS |
| 841 | |
| 842 | #endif /* __GST_MESSAGE_H__ */ |
| 843 | |