gstreamer_core/gst/gstmessage.h
changeset 0 0e761a78d257
child 7 567bb019e3e3
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     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., 59 Temple Place - Suite 330,
       
    19  * Boston, MA 02111-1307, USA.
       
    20  */
       
    21 
       
    22 #ifndef __GST_MESSAGE_H__
       
    23 #define __GST_MESSAGE_H__
       
    24 
       
    25 G_BEGIN_DECLS
       
    26 
       
    27 typedef struct _GstMessage GstMessage;
       
    28 typedef struct _GstMessageClass GstMessageClass;
       
    29 
       
    30 /**
       
    31  * GstMessageType:
       
    32  * @GST_MESSAGE_UNKNOWN: an undefined message
       
    33  * @GST_MESSAGE_EOS: end-of-stream reached in a pipeline. The application will
       
    34  * only receive this message in the PLAYING state and every time it sets a
       
    35  * pipeline to PLAYING that is in the EOS state. The application can perform a
       
    36  * flushing seek in the pipeline, which will undo the EOS state again. 
       
    37  * @GST_MESSAGE_ERROR: an error occured. Whe the application receives an error
       
    38  * message it should stop playback of the pipeline and not assume that more
       
    39  * data will be played.
       
    40  * @GST_MESSAGE_WARNING: a warning occured.
       
    41  * @GST_MESSAGE_INFO: an info message occured
       
    42  * @GST_MESSAGE_TAG: a tag was found.
       
    43  * @GST_MESSAGE_BUFFERING: the pipeline is buffering. When the application
       
    44  * receives a buffering message in the PLAYING state for a non-live pipeline it
       
    45  * must PAUSE the pipeline until the buffering completes, when the percentage
       
    46  * field in the message is 100%. For live pipelines, no action must be
       
    47  * performed and the buffering percentage can be used to inform the user about
       
    48  * the progress.
       
    49  * @GST_MESSAGE_STATE_CHANGED: a state change happened
       
    50  * @GST_MESSAGE_STATE_DIRTY: an element changed state in a streaming thread.
       
    51  * This message is deprecated.
       
    52  * @GST_MESSAGE_STEP_DONE: a framestep finished. This message is not yet
       
    53  * implemented.
       
    54  * @GST_MESSAGE_CLOCK_PROVIDE: an element notifies its capability of providing
       
    55  *                             a clock. This message is used internally and
       
    56  *                             never forwarded to the application.
       
    57  * @GST_MESSAGE_CLOCK_LOST: The current clock as selected by the pipeline became
       
    58  *                          unusable. The pipeline will select a new clock on
       
    59  *                          the next PLAYING state change.
       
    60  * @GST_MESSAGE_NEW_CLOCK: a new clock was selected in the pipeline.
       
    61  * @GST_MESSAGE_STRUCTURE_CHANGE: the structure of the pipeline changed. Not
       
    62  * implemented yet.
       
    63  * @GST_MESSAGE_STREAM_STATUS: status about a stream, emitted when it starts,
       
    64  *                             stops, errors, etc.. Not implemented yet.
       
    65  * @GST_MESSAGE_APPLICATION: message posted by the application, possibly
       
    66  *                           via an application-specific element.
       
    67  * @GST_MESSAGE_ELEMENT: element-specific message, see the specific element's
       
    68  *                       documentation
       
    69  * @GST_MESSAGE_SEGMENT_START: pipeline started playback of a segment. This
       
    70  * message is used internally and never forwarded to the application.
       
    71  * @GST_MESSAGE_SEGMENT_DONE: pipeline completed playback of a segment. This
       
    72  * message is forwarded to the application after all elements that posted
       
    73  * @GST_MESSAGE_SEGMENT_START posted a GST_MESSAGE_SEGMENT_DONE message.
       
    74  * @GST_MESSAGE_DURATION: The duration of a pipeline changed. The application
       
    75  * can get the new duration with a duration query.
       
    76  * @GST_MESSAGE_ASYNC_START: Posted by elements when they start an ASYNC state
       
    77  * change. This message is not forwarded to the application but is used
       
    78  * internally. Since: 0.10.13. 
       
    79  * @GST_MESSAGE_ASYNC_DONE: Posted by elements when they complete an ASYNC state
       
    80  * change. The application will only receive this message from the toplevel
       
    81  * pipeline. Since: 0.10.13
       
    82  * @GST_MESSAGE_LATENCY: Posted by elements when their latency changes. The
       
    83  * pipeline will calculate and distribute a new latency. Since: 0.10.12
       
    84  * @GST_MESSAGE_ANY: mask for all of the above messages.
       
    85  *
       
    86  * The different message types that are available.
       
    87  */
       
    88 /* NOTE: keep in sync with quark registration in gstmessage.c 
       
    89  * NOTE: keep GST_MESSAGE_ANY a valid gint to avoid compiler warnings.
       
    90  */ 
       
    91 typedef enum
       
    92 {
       
    93   GST_MESSAGE_UNKNOWN           = 0,
       
    94   GST_MESSAGE_EOS               = (1 << 0),
       
    95   GST_MESSAGE_ERROR             = (1 << 1),
       
    96   GST_MESSAGE_WARNING           = (1 << 2),
       
    97   GST_MESSAGE_INFO              = (1 << 3),
       
    98   GST_MESSAGE_TAG               = (1 << 4),
       
    99   GST_MESSAGE_BUFFERING         = (1 << 5),
       
   100   GST_MESSAGE_STATE_CHANGED     = (1 << 6),
       
   101   GST_MESSAGE_STATE_DIRTY       = (1 << 7),
       
   102   GST_MESSAGE_STEP_DONE         = (1 << 8),
       
   103   GST_MESSAGE_CLOCK_PROVIDE     = (1 << 9),
       
   104   GST_MESSAGE_CLOCK_LOST        = (1 << 10),
       
   105   GST_MESSAGE_NEW_CLOCK         = (1 << 11),
       
   106   GST_MESSAGE_STRUCTURE_CHANGE  = (1 << 12),
       
   107   GST_MESSAGE_STREAM_STATUS     = (1 << 13),
       
   108   GST_MESSAGE_APPLICATION       = (1 << 14),
       
   109   GST_MESSAGE_ELEMENT           = (1 << 15),
       
   110   GST_MESSAGE_SEGMENT_START     = (1 << 16),
       
   111   GST_MESSAGE_SEGMENT_DONE      = (1 << 17),
       
   112   GST_MESSAGE_DURATION          = (1 << 18),
       
   113   GST_MESSAGE_LATENCY           = (1 << 19),
       
   114   GST_MESSAGE_ASYNC_START       = (1 << 20),
       
   115   GST_MESSAGE_ASYNC_DONE        = (1 << 21),
       
   116   GST_MESSAGE_ANY               = ~0
       
   117 } GstMessageType;
       
   118 
       
   119 #include <gst/gstminiobject.h>
       
   120 #include <gst/gstobject.h>
       
   121 #include <gst/gstelement.h>
       
   122 #include <gst/gsttaglist.h>
       
   123 #include <gst/gststructure.h>
       
   124 
       
   125 /**
       
   126  * GST_MESSAGE_TRACE_NAME:
       
   127  *
       
   128  * The name used for memory allocation tracing
       
   129  */
       
   130 #define GST_MESSAGE_TRACE_NAME	"GstMessage"
       
   131 
       
   132 #define GST_TYPE_MESSAGE			 (gst_message_get_type())
       
   133 #define GST_IS_MESSAGE(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MESSAGE))
       
   134 #define GST_IS_MESSAGE_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MESSAGE))
       
   135 #define GST_MESSAGE_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MESSAGE, GstMessageClass))
       
   136 #define GST_MESSAGE(obj)                         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MESSAGE, GstMessage))
       
   137 #define GST_MESSAGE_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MESSAGE, GstMessageClass))
       
   138 #define GST_MESSAGE_CAST(obj)                    ((GstMessage*)(obj))
       
   139 
       
   140 /* the lock is used to handle the synchronous handling of messages,
       
   141  * the emiting thread is block until the handling thread processed
       
   142  * the message using this mutex/cond pair */
       
   143 #define GST_MESSAGE_GET_LOCK(message)	(GST_MESSAGE(message)->lock)
       
   144 #define GST_MESSAGE_LOCK(message)	g_mutex_lock(GST_MESSAGE_GET_LOCK(message))
       
   145 #define GST_MESSAGE_UNLOCK(message)	g_mutex_unlock(GST_MESSAGE_GET_LOCK(message))
       
   146 #define GST_MESSAGE_COND(message)	(GST_MESSAGE(message)->cond)
       
   147 #define GST_MESSAGE_WAIT(message)	g_cond_wait(GST_MESSAGE_COND(message),GST_MESSAGE_GET_LOCK(message))
       
   148 #define GST_MESSAGE_SIGNAL(message)	g_cond_signal(GST_MESSAGE_COND(message))
       
   149 
       
   150 /**
       
   151  * GST_MESSAGE_TYPE:
       
   152  * @message: a #GstMessage
       
   153  *
       
   154  * Get the #GstMessageType of @message.
       
   155  */
       
   156 #define GST_MESSAGE_TYPE(message)	(GST_MESSAGE(message)->type)
       
   157 /**
       
   158  * GST_MESSAGE_TYPE_NAME:
       
   159  * @message: a #GstMessage
       
   160  *
       
   161  * Get a constant string representation of the #GstMessageType of @message.
       
   162  *
       
   163  * Since: 0.10.4
       
   164  */
       
   165 #define GST_MESSAGE_TYPE_NAME(message)	gst_message_type_get_name(GST_MESSAGE_TYPE(message))
       
   166 /**
       
   167  * GST_MESSAGE_TIMESTAMP:
       
   168  * @message: a #GstMessage
       
   169  *
       
   170  * Get the timestamp of @message. This is the timestamp when the message
       
   171  * was created.
       
   172  */
       
   173 #define GST_MESSAGE_TIMESTAMP(message)	(GST_MESSAGE(message)->timestamp)
       
   174 /**
       
   175  * GST_MESSAGE_SRC:
       
   176  * @message: a #GstMessage
       
   177  *
       
   178  * Get the object that posted @message.
       
   179  */
       
   180 #define GST_MESSAGE_SRC(message)	(GST_MESSAGE(message)->src)
       
   181 
       
   182 /**
       
   183  * GstMessage:
       
   184  * @mini_object: the parent structure
       
   185  * @type: the #GstMessageType of the message
       
   186  * @timestamp: the timestamp of the message
       
   187  * @src: the src of the message
       
   188  * @structure: the #GstStructure containing the message info.
       
   189  *
       
   190  * A #GstMessage.
       
   191  */
       
   192 struct _GstMessage
       
   193 {
       
   194   GstMiniObject mini_object;
       
   195 
       
   196   /*< private > *//* with MESSAGE_LOCK */
       
   197   GMutex *lock;                 /* lock and cond for async delivery */
       
   198   GCond *cond;
       
   199 
       
   200   /*< public > *//* with COW */
       
   201   GstMessageType type;
       
   202   guint64 timestamp;
       
   203   GstObject *src;
       
   204 
       
   205   GstStructure *structure;
       
   206 
       
   207   /*< private > */
       
   208   gpointer _gst_reserved[GST_PADDING];
       
   209 };
       
   210 
       
   211 struct _GstMessageClass {
       
   212   GstMiniObjectClass mini_object_class;
       
   213 
       
   214   /*< private > */
       
   215   gpointer _gst_reserved[GST_PADDING];
       
   216 };
       
   217 #ifdef __SYMBIAN32__
       
   218 IMPORT_C
       
   219 #endif
       
   220 
       
   221 
       
   222 GType		gst_message_get_type		(void);
       
   223 #ifdef __SYMBIAN32__
       
   224 IMPORT_C
       
   225 #endif
       
   226 
       
   227 
       
   228 const gchar*	gst_message_type_get_name	(GstMessageType type);
       
   229 #ifdef __SYMBIAN32__
       
   230 IMPORT_C
       
   231 #endif
       
   232 
       
   233 GQuark		gst_message_type_to_quark	(GstMessageType type);
       
   234 
       
   235 /* refcounting */
       
   236 /**
       
   237  * gst_message_ref:
       
   238  * @msg: the message to ref
       
   239  *
       
   240  * Convenience macro to increase the reference count of the message.
       
   241  *
       
   242  * Returns: @msg (for convenience when doing assignments)
       
   243  */
       
   244 #ifdef _FOOL_GTK_DOC_
       
   245 G_INLINE_FUNC GstMessage * gst_message_ref (GstMessage * msg);
       
   246 #endif
       
   247 
       
   248 static inline GstMessage *
       
   249 gst_message_ref (GstMessage * msg)
       
   250 {
       
   251   /* not using a macro here because gcc-4.1 will complain
       
   252    * if the return value isn't used (because of the cast) */
       
   253   return (GstMessage *) gst_mini_object_ref (GST_MINI_OBJECT (msg));
       
   254 }
       
   255 
       
   256 /**
       
   257  * gst_message_unref:
       
   258  * @msg: the message to unref
       
   259  *
       
   260  * Convenience macro to decrease the reference count of the message, possibly
       
   261  * freeing it.
       
   262  */
       
   263 #define         gst_message_unref(msg)		gst_mini_object_unref (GST_MINI_OBJECT (msg))
       
   264 /* copy message */
       
   265 /**
       
   266  * gst_message_copy:
       
   267  * @msg: the message to copy
       
   268  *
       
   269  * Creates a copy of the message. Returns a copy of the message.
       
   270  *
       
   271  * MT safe
       
   272  */
       
   273 #define         gst_message_copy(msg)		GST_MESSAGE (gst_mini_object_copy (GST_MINI_OBJECT (msg)))
       
   274 /**
       
   275  * gst_message_make_writable:
       
   276  * @msg: the message to make writable
       
   277  *
       
   278  * Checks if a message is writable. If not, a writable copy is made and
       
   279  * returned. Returns a message (possibly a duplicate) that is writable.
       
   280  *
       
   281  * MT safe
       
   282  */
       
   283 #define         gst_message_make_writable(msg)	GST_MESSAGE (gst_mini_object_make_writable (GST_MINI_OBJECT (msg)))
       
   284 
       
   285 GstMessage *	gst_message_new_eos		(GstObject * src);
       
   286 #ifdef __SYMBIAN32__
       
   287 IMPORT_C
       
   288 #endif
       
   289 
       
   290 GstMessage *	gst_message_new_error		(GstObject * src, GError * error, gchar * debug);
       
   291 #ifdef __SYMBIAN32__
       
   292 IMPORT_C
       
   293 #endif
       
   294 
       
   295 GstMessage *	gst_message_new_warning		(GstObject * src, GError * error, gchar * debug);
       
   296 #ifdef __SYMBIAN32__
       
   297 IMPORT_C
       
   298 #endif
       
   299 
       
   300 GstMessage *	gst_message_new_info		(GstObject * src, GError * error, gchar * debug);
       
   301 #ifdef __SYMBIAN32__
       
   302 IMPORT_C
       
   303 #endif
       
   304 
       
   305 GstMessage *	gst_message_new_tag		(GstObject * src, GstTagList * tag_list);
       
   306 #ifdef __SYMBIAN32__
       
   307 IMPORT_C
       
   308 #endif
       
   309 
       
   310 GstMessage *	gst_message_new_buffering	(GstObject * src, gint percent);
       
   311 #ifdef __SYMBIAN32__
       
   312 IMPORT_C
       
   313 #endif
       
   314 
       
   315 GstMessage *	gst_message_new_state_changed	(GstObject * src, GstState oldstate,
       
   316                                                  GstState newstate, GstState pending);
       
   317 #ifdef __SYMBIAN32__
       
   318 IMPORT_C
       
   319 #endif
       
   320 
       
   321 GstMessage *	gst_message_new_state_dirty	(GstObject * src);
       
   322 #ifdef __SYMBIAN32__
       
   323 IMPORT_C
       
   324 #endif
       
   325 
       
   326 GstMessage *	gst_message_new_clock_provide	(GstObject * src, GstClock *clock, gboolean ready);
       
   327 #ifdef __SYMBIAN32__
       
   328 IMPORT_C
       
   329 #endif
       
   330 
       
   331 GstMessage *	gst_message_new_clock_lost	(GstObject * src, GstClock *clock);
       
   332 #ifdef __SYMBIAN32__
       
   333 IMPORT_C
       
   334 #endif
       
   335 
       
   336 GstMessage *	gst_message_new_new_clock	(GstObject * src, GstClock *clock);
       
   337 #ifdef __SYMBIAN32__
       
   338 IMPORT_C
       
   339 #endif
       
   340 
       
   341 GstMessage *	gst_message_new_application	(GstObject * src, GstStructure * structure);
       
   342 #ifdef __SYMBIAN32__
       
   343 IMPORT_C
       
   344 #endif
       
   345 
       
   346 GstMessage *	gst_message_new_element		(GstObject * src, GstStructure * structure);
       
   347 #ifdef __SYMBIAN32__
       
   348 IMPORT_C
       
   349 #endif
       
   350 
       
   351 GstMessage *	gst_message_new_segment_start	(GstObject * src, GstFormat format, gint64 position);
       
   352 #ifdef __SYMBIAN32__
       
   353 IMPORT_C
       
   354 #endif
       
   355 
       
   356 GstMessage *	gst_message_new_segment_done	(GstObject * src, GstFormat format, gint64 position);
       
   357 #ifdef __SYMBIAN32__
       
   358 IMPORT_C
       
   359 #endif
       
   360 
       
   361 GstMessage *	gst_message_new_duration	(GstObject * src, GstFormat format, gint64 duration);
       
   362 #ifdef __SYMBIAN32__
       
   363 IMPORT_C
       
   364 #endif
       
   365 
       
   366 GstMessage *	gst_message_new_async_start	(GstObject * src, gboolean new_base_time);
       
   367 #ifdef __SYMBIAN32__
       
   368 IMPORT_C
       
   369 #endif
       
   370 
       
   371 GstMessage *	gst_message_new_async_done	(GstObject * src);
       
   372 #ifdef __SYMBIAN32__
       
   373 IMPORT_C
       
   374 #endif
       
   375 
       
   376 GstMessage *	gst_message_new_latency         (GstObject * src);
       
   377 #ifdef __SYMBIAN32__
       
   378 IMPORT_C
       
   379 #endif
       
   380 
       
   381 GstMessage *	gst_message_new_custom		(GstMessageType type,
       
   382 						 GstObject    * src,
       
   383 						 GstStructure * structure);
       
   384 #ifdef __SYMBIAN32__
       
   385 IMPORT_C
       
   386 #endif
       
   387 
       
   388 
       
   389 void		gst_message_parse_error		(GstMessage *message, GError **gerror, gchar **debug);
       
   390 #ifdef __SYMBIAN32__
       
   391 IMPORT_C
       
   392 #endif
       
   393 
       
   394 void		gst_message_parse_warning	(GstMessage *message, GError **gerror, gchar **debug);
       
   395 #ifdef __SYMBIAN32__
       
   396 IMPORT_C
       
   397 #endif
       
   398 
       
   399 void		gst_message_parse_info 		(GstMessage *message, GError **gerror, gchar **debug);
       
   400 #ifdef __SYMBIAN32__
       
   401 IMPORT_C
       
   402 #endif
       
   403 
       
   404 void		gst_message_parse_tag		(GstMessage *message, GstTagList **tag_list);
       
   405 #ifdef __SYMBIAN32__
       
   406 IMPORT_C
       
   407 #endif
       
   408 
       
   409 void 		gst_message_parse_buffering	(GstMessage *message, gint *percent);
       
   410 #ifdef __SYMBIAN32__
       
   411 IMPORT_C
       
   412 #endif
       
   413 
       
   414 void		gst_message_parse_state_changed	(GstMessage *message, GstState *oldstate,
       
   415                                                  GstState *newstate, GstState *pending);
       
   416 #ifdef __SYMBIAN32__
       
   417 IMPORT_C
       
   418 #endif
       
   419 
       
   420 void		gst_message_parse_clock_provide (GstMessage *message, GstClock **clock, gboolean *ready);
       
   421 #ifdef __SYMBIAN32__
       
   422 IMPORT_C
       
   423 #endif
       
   424 
       
   425 void		gst_message_parse_clock_lost	(GstMessage *message, GstClock **clock);
       
   426 #ifdef __SYMBIAN32__
       
   427 IMPORT_C
       
   428 #endif
       
   429 
       
   430 void		gst_message_parse_new_clock	(GstMessage *message, GstClock **clock);
       
   431 #ifdef __SYMBIAN32__
       
   432 IMPORT_C
       
   433 #endif
       
   434 
       
   435 void		gst_message_parse_segment_start (GstMessage *message, GstFormat *format, gint64 *position);
       
   436 #ifdef __SYMBIAN32__
       
   437 IMPORT_C
       
   438 #endif
       
   439 
       
   440 void		gst_message_parse_segment_done	(GstMessage *message, GstFormat *format, gint64 *position);
       
   441 #ifdef __SYMBIAN32__
       
   442 IMPORT_C
       
   443 #endif
       
   444 
       
   445 void		gst_message_parse_duration	(GstMessage *message, GstFormat *format, gint64 *duration);
       
   446 #ifdef __SYMBIAN32__
       
   447 IMPORT_C
       
   448 #endif
       
   449 
       
   450 void		gst_message_parse_async_start	(GstMessage *message, gboolean *new_base_time);
       
   451 #ifdef __SYMBIAN32__
       
   452 IMPORT_C
       
   453 #endif
       
   454 
       
   455 
       
   456 const GstStructure *  gst_message_get_structure	(GstMessage *message);
       
   457 
       
   458 G_END_DECLS
       
   459 
       
   460 #endif /* __GST_MESSAGE_H__ */