gst/gstmessage.*: Also carry the clock in question.
authorWim Taymans <wim.taymans@gmail.com>
Sat, 8 Oct 2005 12:56:37 +0000 (12:56 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Sat, 8 Oct 2005 12:56:37 +0000 (12:56 +0000)
Original commit message from CVS:
* gst/gstmessage.c: (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_clock_provide),
(gst_message_new_clock_lost), (gst_message_new_new_clock),
(gst_message_new_segment_start), (gst_message_new_segment_done),
(gst_message_parse_state_changed),
(gst_message_parse_clock_provide), (gst_message_parse_clock_lost),
(gst_message_parse_new_clock):
* gst/gstmessage.h:
Also carry the clock in question.

ChangeLog
gst/gstmessage.c
gst/gstmessage.h

index d0e88fe..bd4fa54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2005-10-08  Wim Taymans  <wim@fluendo.com>
 
+       * gst/gstmessage.c: (gst_message_new_error),
+       (gst_message_new_warning), (gst_message_new_tag),
+       (gst_message_new_state_changed), (gst_message_new_clock_provide),
+       (gst_message_new_clock_lost), (gst_message_new_new_clock),
+       (gst_message_new_segment_start), (gst_message_new_segment_done),
+       (gst_message_parse_state_changed),
+       (gst_message_parse_clock_provide), (gst_message_parse_clock_lost),
+       (gst_message_parse_new_clock):
+       * gst/gstmessage.h:
+       Also carry the clock in question.
+
+2005-10-08  Wim Taymans  <wim@fluendo.com>
+
        * gst/gstmessage.c: (gst_message_new_custom),
        (gst_message_new_eos), (gst_message_new_error),
        (gst_message_new_warning), (gst_message_new_tag),
index 80e25cc..2a9cec6 100644 (file)
@@ -395,6 +395,7 @@ gst_message_new_state_changed (GstObject * src,
 /**
  * gst_message_new_clock_provide:
  * @src: The object originating the message.
+ * @clock: The clock it provides
  * @ready: TRUE if the sender can provide a clock
  *
  * Create a clock provide message. This message is posted whenever an 
@@ -409,18 +410,48 @@ gst_message_new_state_changed (GstObject * src,
  * MT safe.
  */
 GstMessage *
-gst_message_new_clock_provide (GstObject * src, gboolean ready)
+gst_message_new_clock_provide (GstObject * src, GstClock * clock,
+    gboolean ready)
 {
   GstMessage *message;
 
   message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src,
       gst_structure_new ("GstMessageClockProvide",
+          "clock", GST_TYPE_CLOCK, clock,
           "ready", G_TYPE_BOOLEAN, ready, NULL));
 
   return message;
 }
 
 /**
+ * gst_message_new_clock_lost:
+ * @src: The object originating the message.
+ * @clock: the clock that was lost
+ *
+ * Create a clock lost message. This message is posted whenever the
+ * clock is not valid anymore.
+ *
+ * If this message is posted by the pipeline, the pipeline will
+ * select a new clock again when it goes to PLAYING. It might therefore
+ * be needed to set the pipeline to PAUSED and PLAYING again.
+ *
+ * Returns: The new clock lost message.
+ *
+ * MT safe.
+ */
+GstMessage *
+gst_message_new_clock_lost (GstObject * src, GstClock * clock)
+{
+  GstMessage *message;
+
+  message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src,
+      gst_structure_new ("GstMessageClockLost",
+          "clock", GST_TYPE_CLOCK, clock, NULL));
+
+  return message;
+}
+
+/**
  * gst_message_new_new_clock:
  * @src: The object originating the message.
  * @clock: the new selected clock
@@ -602,20 +633,57 @@ gst_message_parse_state_changed (GstMessage * message, GstState * old,
 /**
  * gst_message_parse_clock_provide:
  * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
- * @ready: If the src can provide a clock or not.
+ * @clock: A pointer to  hold a clock object.
+ * @ready: A pointer to hold the ready flag.
  *
- * Extracts the ready flag from the GstMessage.
+ * Extracts the clock and ready flag from the GstMessage.
+ * The clock object returned remains valid until the message is freed.
  *
  * MT safe.
  */
 void
-gst_message_parse_clock_provide (GstMessage * message, gboolean * ready)
+gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
+    gboolean * ready)
 {
+  const GValue *clock_gvalue;
+
   g_return_if_fail (GST_IS_MESSAGE (message));
   g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
 
+  clock_gvalue = gst_structure_get_value (message->structure, "clock");
+  g_return_if_fail (clock_gvalue != NULL);
+  g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
+
   if (ready)
     gst_structure_get_boolean (message->structure, "ready", ready);
+  if (clock)
+    *clock = (GstClock *) g_value_get_object (clock_gvalue);
+}
+
+/**
+ * gst_message_parse_clock_lost:
+ * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
+ * @clock: A pointer to hold the lost clock
+ *
+ * Extracts the lost clock from the GstMessage.
+ * The clock object returned remains valid until the message is freed.
+ *
+ * MT safe.
+ */
+void
+gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
+{
+  const GValue *clock_gvalue;
+
+  g_return_if_fail (GST_IS_MESSAGE (message));
+  g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
+
+  clock_gvalue = gst_structure_get_value (message->structure, "clock");
+  g_return_if_fail (clock_gvalue != NULL);
+  g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
+
+  if (clock)
+    *clock = (GstClock *) g_value_get_object (clock_gvalue);
 }
 
 /**
index e86d92b..ca435b9 100644 (file)
@@ -154,8 +154,8 @@ GstMessage *        gst_message_new_warning         (GstObject * src, GError * error, gchar *
 GstMessage *   gst_message_new_tag             (GstObject * src, GstTagList * tag_list);
 GstMessage *   gst_message_new_state_changed   (GstObject * src, GstState old_state,
                                                  GstState new_state, GstState pending);
-GstMessage *   gst_message_new_clock_provide   (GstObject * src, gboolean ready);
-GstMessage *   gst_message_new_clock_lost      (GstObject * src);
+GstMessage *   gst_message_new_clock_provide   (GstObject * src, GstClock *clock, gboolean ready);
+GstMessage *   gst_message_new_clock_lost      (GstObject * src, GstClock *clock);
 GstMessage *   gst_message_new_new_clock       (GstObject * src, GstClock *clock);
 GstMessage *   gst_message_new_segment_start   (GstObject * src, GstClockTime timestamp);
 GstMessage *   gst_message_new_segment_done    (GstObject * src, GstClockTime timestamp);
@@ -170,7 +170,8 @@ void                gst_message_parse_warning       (GstMessage *message, GError **gerror, gchar **d
 void           gst_message_parse_tag           (GstMessage *message, GstTagList **tag_list);
 void           gst_message_parse_state_changed (GstMessage *message, GstState *old_state,
                                                  GstState *new_state, GstState *pending);
-void           gst_message_parse_clock_provide (GstMessage *message, gboolean *ready);
+void           gst_message_parse_clock_provide (GstMessage *message, GstClock **clock, gboolean *ready);
+void           gst_message_parse_clock_lost    (GstMessage *message, GstClock **clock);
 void           gst_message_parse_new_clock     (GstMessage *message, GstClock **clock);
 void           gst_message_parse_segment_start (GstMessage *message, GstClockTime *timestamp);
 void           gst_message_parse_segment_done  (GstMessage *message, GstClockTime *timestamp);