Implement STRUCTURE_CHANGED messages. These messages will be used to signal the paren...
authorWim Taymans <wim.taymans@gmail.com>
Mon, 6 Oct 2008 15:31:49 +0000 (15:31 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Mon, 6 Oct 2008 15:31:49 +0000 (15:31 +0000)
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gstmessage.c: (gst_message_new_structure_change),
(gst_message_parse_structure_change):
* gst/gstmessage.h:
Implement STRUCTURE_CHANGED messages. These messages will be used to
signal the parent bin of link/unlink operations that could require a
resync when doing a state change. See ##510354.
API: gst_message_new_structure_change()
API: gst_message_parse_structure_change()

ChangeLog
docs/gst/gstreamer-sections.txt
gst/gstmessage.c
gst/gstmessage.h

index cdcc7fd..ae6f284 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2008-10-06  Wim Taymans  <wim.taymans@collabora.co.uk>
 
+       * docs/gst/gstreamer-sections.txt:
+       * gst/gstmessage.c: (gst_message_new_structure_change),
+       (gst_message_parse_structure_change):
+       * gst/gstmessage.h:
+       Implement STRUCTURE_CHANGED messages. These messages will be used to
+       signal the parent bin of link/unlink operations that could require a
+       resync when doing a state change. See ##510354.
+       API: gst_message_new_structure_change()
+       API: gst_message_parse_structure_change()
+
+2008-10-06  Wim Taymans  <wim.taymans@collabora.co.uk>
+
        * gst/gstquark.c:
        * gst/gstquark.h:
        Add some more quarks for new message. See #510354.
index acbacf7..480dfb6 100644 (file)
@@ -1019,6 +1019,7 @@ gst_iterator_result_get_type
 <TITLE>GstMessage</TITLE>
 GstMessage
 GstMessageType
+GstStructureChangeType
 GST_MESSAGE_SRC
 GST_MESSAGE_TIMESTAMP
 GST_MESSAGE_TYPE
@@ -1067,7 +1068,8 @@ gst_message_new_latency
 gst_message_new_async_start
 gst_message_parse_async_start
 gst_message_new_async_done
-
+gst_message_new_structure_change
+gst_message_parse_structure_change
 <SUBSECTION Standard>
 GstMessageClass
 GST_MESSAGE
@@ -1078,9 +1080,11 @@ GST_MESSAGE_CLASS
 GST_IS_MESSAGE_CLASS
 GST_MESSAGE_GET_CLASS
 GST_TYPE_MESSAGE_TYPE
+GST_TYPE_STRUCTURE_CHANGE_TYPE
 <SUBSECTION Private>
 gst_message_get_type
 gst_message_type_get_type
+gst_structure_change_type_get_type
 GST_MESSAGE_COND
 GST_MESSAGE_GET_LOCK
 GST_MESSAGE_LOCK
index d443c81..777b97d 100644 (file)
@@ -623,6 +623,48 @@ gst_message_new_new_clock (GstObject * src, GstClock * clock)
 }
 
 /**
+ * gst_message_new_structure_change:
+ * @src: The object originating the message.
+ * @type: The change type.
+ * @owner: The owner element of @src.
+ * @busy: Whether the structure change is busy.
+ *
+ * Create a new structure change message. This message is posted when the
+ * structure of a pipeline is in the process of being changed, for example
+ * when pads are linked or unlinked.
+ *
+ * @src should be the srcpad that unlinked or linked.
+ *
+ * Returns: The new structure change message.
+ *
+ * MT safe.
+ *
+ * Since: 0.10.22.
+ */
+GstMessage *
+gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
+    GstElement * owner, gboolean busy)
+{
+  GstMessage *message;
+  GstStructure *structure;
+
+  g_return_val_if_fail (GST_IS_PAD (src), NULL);
+  g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SRC, NULL);
+  g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
+
+  structure = gst_structure_empty_new ("GstMessageStructureChange");
+  gst_structure_id_set (structure,
+      GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
+      GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
+      GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
+
+  message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
+      structure);
+
+  return message;
+}
+
+/**
  * gst_message_new_segment_start:
  * @src: The object originating the message.
  * @format: The format of the position being played
@@ -1072,6 +1114,45 @@ gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
 }
 
 /**
+ * gst_message_parse_structure_change:
+ * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
+ * @type: A pointer to hold the change type
+ * @owner: The owner element of the message source
+ * @busy: A pointer to hold whether the change is in progress or has been
+ * completed
+ *
+ * Extracts the change type and completion status from the GstMessage.
+ *
+ * MT safe.
+ *
+ * Since: 0.10.22
+ */
+void
+gst_message_parse_structure_change (GstMessage * message,
+    GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
+{
+  const GValue *owner_gvalue;
+
+  g_return_if_fail (GST_IS_MESSAGE (message));
+  g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
+
+  owner_gvalue =
+      gst_structure_id_get_value (message->structure, GST_QUARK (OWNER));
+  g_return_if_fail (owner_gvalue != NULL);
+  g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
+
+  if (type)
+    *type = g_value_get_enum (gst_structure_id_get_value (message->structure,
+            GST_QUARK (TYPE)));
+  if (owner)
+    *owner = (GstElement *) g_value_get_object (owner_gvalue);
+  if (busy)
+    *busy =
+        g_value_get_boolean (gst_structure_id_get_value (message->structure,
+            GST_QUARK (BUSY)));
+}
+
+/**
  * gst_message_parse_error:
  * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
  * @gerror: Location for the GError
index 2caa85f..2494da8 100644 (file)
@@ -58,8 +58,8 @@ typedef struct _GstMessageClass GstMessageClass;
  *                          unusable. The pipeline will select a new clock on
  *                          the next PLAYING state change.
  * @GST_MESSAGE_NEW_CLOCK: a new clock was selected in the pipeline.
- * @GST_MESSAGE_STRUCTURE_CHANGE: the structure of the pipeline changed. Not
- * implemented yet.
+ * @GST_MESSAGE_STRUCTURE_CHANGE: the structure of the pipeline changed. This
+ * message is used internally and never forwarded to the application.
  * @GST_MESSAGE_STREAM_STATUS: status about a stream, emitted when it starts,
  *                             stops, errors, etc.. Not implemented yet.
  * @GST_MESSAGE_APPLICATION: message posted by the application, possibly
@@ -180,6 +180,20 @@ typedef enum
 #define GST_MESSAGE_SRC(message)       (GST_MESSAGE(message)->src)
 
 /**
+ * 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.
+ *
+ * The type of a #GstMessageStructureChange.
+ *
+ * Since: 0.10.22
+ */
+typedef enum {
+  GST_STRUCTURE_CHANGE_TYPE_PAD_LINK   = 0,
+  GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK = 1
+} GstStructureChangeType;
+
+/**
  * GstMessage:
  * @mini_object: the parent structure
  * @type: the #GstMessageType of the message
@@ -353,6 +367,12 @@ void               gst_message_parse_async_start   (GstMessage *message, gboolean *new_base_tim
 /* ASYNC_DONE */
 GstMessage *   gst_message_new_async_done      (GstObject * src);
 
+/* STRUCTURE CHANGE */
+GstMessage *   gst_message_new_structure_change   (GstObject * src, GstStructureChangeType type,
+                                                    GstElement *owner, gboolean busy);
+void           gst_message_parse_structure_change (GstMessage *message, GstStructureChangeType *type,
+                                                    GstElement **owner, gboolean *busy);
+
 /* custom messages */
 GstMessage *   gst_message_new_custom          (GstMessageType type,
                                                 GstObject    * src,