message: Add GST_MESSAGE_EXTENDED
authorOlivier Crête <olivier.crete@collabora.com>
Wed, 14 Aug 2013 19:56:11 +0000 (15:56 -0400)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 16 Mar 2014 14:38:07 +0000 (14:38 +0000)
https://bugzilla.gnome.org/show_bug.cgi?id=678402

gst/gst.c
gst/gstmessage.c
gst/gstmessage.h
gst/gstquark.c
gst/gstquark.h

index f734dc9..b24ecbe 100644 (file)
--- a/gst/gst.c
+++ b/gst/gst.c
@@ -667,6 +667,7 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
   g_type_class_ref (gst_lock_flags_get_type ());
   g_type_class_ref (gst_allocator_flags_get_type ());
   g_type_class_ref (gst_stream_flags_get_type ());
+  g_type_class_ref (gst_message_extended_type_get_type ());
 
   _priv_gst_event_initialize ();
   _priv_gst_buffer_initialize ();
@@ -1062,6 +1063,8 @@ gst_deinit (void)
   g_type_class_unref (g_type_class_peek (gst_allocator_flags_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_stream_flags_get_type ()));
   g_type_class_unref (g_type_class_peek (gst_debug_color_mode_get_type ()));
+  g_type_class_unref (g_type_class_peek (gst_message_extended_type_get_type
+          ()));
 
   gst_deinitialized = TRUE;
   GST_INFO ("deinitialized GStreamer");
index 1402a67..debc526 100644 (file)
@@ -60,6 +60,8 @@ typedef struct
 {
   GstMessage message;
 
+  GstMessageExtendedType extended_type;
+
   GstStructure *structure;
 } GstMessageImpl;
 
@@ -105,6 +107,8 @@ static GstMessageQuarks message_quarks[] = {
   {GST_MESSAGE_STREAM_START, "stream-start", 0},
   {GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
   {GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
+  {GST_MESSAGE_EXTENDED, "extended", 0},
+  {GST_MESSAGE_DEVICE, "device", 0},
   {0, NULL, 0}
 };
 
@@ -235,6 +239,16 @@ _gst_message_copy (GstMessage * message)
   return GST_MESSAGE_CAST (copy);
 }
 
+GstMessageExtendedType
+gst_message_get_extended_type (GstMessage * msg)
+{
+  GstMessageImpl *message = (GstMessageImpl *) msg;
+
+  g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
+
+  return message->extended_type;
+}
+
 static void
 gst_message_init (GstMessageImpl * message, GstMessageType type,
     GstObject * src)
@@ -300,6 +314,20 @@ had_parent:
   }
 }
 
+static inline GstMessage *
+gst_message_new_extended (GstMessageExtendedType extended_type, GstObject * src,
+    GstStructure * structure)
+{
+  GstMessageImpl *message;
+
+  message = (GstMessageImpl *) gst_message_new_custom (GST_MESSAGE_EXTENDED,
+      src, structure);
+
+  message->extended_type = extended_type;
+
+  return GST_MESSAGE_CAST (message);
+}
+
 /**
  * gst_message_get_seqnum:
  * @message: A #GstMessage.
index fc73661..951a620 100644 (file)
@@ -99,13 +99,16 @@ typedef struct _GstMessage GstMessage;
  *     the URI for the next title has been set).
  * @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)
+ * @GST_MESSAGE_EXTENDED: See gst_message_get_extended_type() to get the type (Since 1.2)
  * @GST_MESSAGE_ANY: mask for all of the above messages.
  *
- * The different message types that are available.
+ * The different message types that are available. Also see
+ * #GstMessageExtendedType for more types.
  */
 /* NOTE: keep in sync with quark registration in gstmessage.c
  * NOTE: keep GST_MESSAGE_ANY a valid gint to avoid compiler warnings.
  */
+/* FIXME: 2.0: Make it NOT flags, just a regular 1,2,3,4.. enumeration */
 typedef enum
 {
   GST_MESSAGE_UNKNOWN           = 0,
@@ -140,9 +143,23 @@ typedef enum
   GST_MESSAGE_STREAM_START      = (1 << 28),
   GST_MESSAGE_NEED_CONTEXT      = (1 << 29),
   GST_MESSAGE_HAVE_CONTEXT      = (1 << 30),
+  GST_MESSAGE_EXTENDED          = (1 << 31),
   GST_MESSAGE_ANY               = ~0
 } GstMessageType;
 
+/**
+ * GstMessageExtendedType:
+ * @GST_MESSAGE_DEVICE: A #GstDevice addition or removal according to
+ * a #GstDeviceMonitor
+ *
+ * Extra message types, see #GstMessageType for the basic types
+ */
+
+typedef enum {
+  /* Skip those defined in #GstMessage to avoid confusion */
+  GST_MESSAGE_DEVICE            = 3
+} GstMessageExtendedType;
+
 #include <gst/gstminiobject.h>
 #include <gst/gstobject.h>
 #include <gst/gstelement.h>
@@ -300,6 +317,8 @@ GType           gst_message_get_type            (void);
 const gchar*    gst_message_type_get_name       (GstMessageType type);
 GQuark          gst_message_type_to_quark       (GstMessageType type);
 
+GstMessageExtendedType gst_message_get_extended_type (GstMessage * msg);
+
 /* refcounting */
 /**
  * gst_message_ref:
index 5598b99..714aac8 100644 (file)
@@ -68,7 +68,7 @@ static const gchar *_quark_strings[] = {
   "GstEventSegmentDone",
   "GstEventStreamStart", "stream-id", "GstQueryContext",
   "GstMessageNeedContext", "GstMessageHaveContext", "context", "context-type",
-  "GstMessageStreamStart", "group-id", "uri-redirection"
+  "GstMessageStreamStart", "group-id", "uri-redirection", "GstMessageExtended"
 };
 
 GQuark _priv_gst_quark_table[GST_QUARK_MAX];
index 025f508..3a3f440 100644 (file)
@@ -196,7 +196,8 @@ typedef enum _GstQuarkId
   GST_QUARK_MESSAGE_STREAM_START = 167,
   GST_QUARK_GROUP_ID = 168,
   GST_QUARK_URI_REDIRECTION = 169,
-  GST_QUARK_MAX = 170
+  GST_QUARK_MESSAGE_EXTENDED = 170,
+  GST_QUARK_MAX = 171
 } GstQuarkId;
 
 extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];