From dafe104298cdaa6d61173476827f694539075a8f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 8 Oct 2005 12:56:37 +0000 Subject: [PATCH] gst/gstmessage.*: Also carry the clock in question. 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 | 13 +++++++++ gst/gstmessage.c | 76 +++++++++++++++++++++++++++++++++++++++++++++--- gst/gstmessage.h | 7 +++-- 3 files changed, 89 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index d0e88fe961..bd4fa54e11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-10-08 Wim Taymans + + * 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 * gst/gstmessage.c: (gst_message_new_custom), diff --git a/gst/gstmessage.c b/gst/gstmessage.c index 80e25cc12e..2a9cec62f3 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -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,17 +410,47 @@ 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. @@ -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); } /** diff --git a/gst/gstmessage.h b/gst/gstmessage.h index e86d92ba3b..ca435b947e 100644 --- a/gst/gstmessage.h +++ b/gst/gstmessage.h @@ -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);