From f712a9596c2bc1863edf9b816d9854eefca9ba45 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 2 Sep 2012 01:17:44 +0100 Subject: [PATCH] message: rename GST_MESSAGE_DURATION -> GST_MESSAGE_DURATION_CHANGED The duration should be re-queried via a query using the normal path, we don't want applications to use the value from the message itself, since it might no match what a duration query done from the sink upstream might yield. Also disables duration caching in GstBin. It should be added back again at some point. --- docs/gst/gstreamer-sections.txt | 3 +-- docs/random/porting-to-0.11.txt | 9 +++++-- gst/gstbin.c | 19 +++++++++++---- gst/gstcompat.h | 13 ++++++++++ gst/gstmessage.c | 54 ++++++----------------------------------- gst/gstmessage.h | 12 ++++----- gst/gstquark.c | 3 ++- gst/gstquark.h | 2 +- win32/common/libgstreamer.def | 3 +-- 9 files changed, 52 insertions(+), 66 deletions(-) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index ca0389f..64fcf0f 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1434,8 +1434,7 @@ gst_message_new_segment_start gst_message_parse_segment_start gst_message_new_segment_done gst_message_parse_segment_done -gst_message_new_duration -gst_message_parse_duration +gst_message_new_duration_changed gst_message_new_latency gst_message_new_async_start gst_message_new_async_done diff --git a/docs/random/porting-to-0.11.txt b/docs/random/porting-to-0.11.txt index 79315a8..0c4fffe 100644 --- a/docs/random/porting-to-0.11.txt +++ b/docs/random/porting-to-0.11.txt @@ -351,6 +351,11 @@ The 0.11 porting guide The GstStructure is removed from the public API, use the getters to get a handle to a GstStructure. + GST_MESSAGE_DURATION -> GST_MESSAGE_DURATION_CHANGED + + gst_message_parse_duration() was removed (not needed any longer, do + a duration query to query the updated duration) + * GstCaps Is now a boxed type derived from GstMiniObject. @@ -602,8 +607,8 @@ The 0.11 porting guide create request pads from elements. * some elements that used to have a single dynamic source pad have a - static source pad now. Example: wavparse, id3demux, apedemux. (This - does not affect applications using decodebin or playbin) + static source pad now. Example: wavparse, id3demux, iceydemux, apedemux. + (This does not affect applications using decodebin or playbin). * the name of the GstXOverlay "prepare-xwindow-id" message has changed to "prepare-window-handle" (and GstXOverlay has been renamed to diff --git a/gst/gstbin.c b/gst/gstbin.c index b1e05bf..cc39027 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -78,7 +78,7 @@ * a SEGMENT_START have posted a SEGMENT_DONE. * * - * GST_MESSAGE_DURATION + * GST_MESSAGE_DURATION_CHANGED * Is posted by an element that detected a change * in the stream duration. The default bin behaviour is to clear any * cached duration values so that the next duration query will perform @@ -3229,7 +3229,7 @@ bin_do_message_forward (GstBin * bin, GstMessage * message) * with the segment_done message. If there are no more segment_start * messages, post segment_done message upwards. * - * GST_MESSAGE_DURATION: remove all previously cached duration messages. + * GST_MESSAGE_DURATION_CHANGED: clear any cached durations. * Whenever someone performs a duration query on the bin, we store the * result so we can answer it quicker the next time. Any element that * changes its duration marks our cached values invalid. @@ -3392,13 +3392,15 @@ gst_bin_handle_message_func (GstBin * bin, GstMessage * message) } break; } - case GST_MESSAGE_DURATION: + case GST_MESSAGE_DURATION_CHANGED: { - /* remove all cached duration messages, next time somebody asks + /* FIXME: remove all cached durations, next time somebody asks * for duration, we will recalculate. */ +#if 0 GST_OBJECT_LOCK (bin); bin_remove_messages (bin, NULL, GST_MESSAGE_DURATION); GST_OBJECT_UNLOCK (bin); +#endif goto forward; } case GST_MESSAGE_CLOCK_LOST: @@ -3634,11 +3636,14 @@ bin_query_duration_done (GstBin * bin, QueryFold * fold) GST_DEBUG_OBJECT (bin, "max duration %" G_GINT64_FORMAT, fold->max); + /* FIXME: re-implement duration caching */ +#if 0 /* and cache now */ GST_OBJECT_LOCK (bin); bin->messages = g_list_prepend (bin->messages, gst_message_new_duration (GST_OBJECT_CAST (bin), format, fold->max)); GST_OBJECT_UNLOCK (bin); +#endif } static gboolean @@ -3752,6 +3757,8 @@ gst_bin_query (GstElement * element, GstQuery * query) switch (GST_QUERY_TYPE (query)) { case GST_QUERY_DURATION: { + /* FIXME: implement duration caching in GstBin again */ +#if 0 GList *cached; GstFormat qformat; @@ -3782,6 +3789,9 @@ gst_bin_query (GstElement * element, GstQuery * query) } } GST_OBJECT_UNLOCK (bin); +#else + GST_FIXME ("implement duration caching in GstBin again"); +#endif /* no cached value found, iterate and collect durations */ fold_func = (GstIteratorFoldFunction) bin_query_duration_fold; fold_init = bin_query_min_max_init; @@ -3847,7 +3857,6 @@ gst_bin_query (GstElement * element, GstQuery * query) done: gst_iterator_free (iter); -exit: GST_DEBUG_OBJECT (bin, "query %p result %d", query, res); return res; diff --git a/gst/gstcompat.h b/gst/gstcompat.h index 62ee85d..2b88f0e 100644 --- a/gst/gstcompat.h +++ b/gst/gstcompat.h @@ -80,6 +80,19 @@ gst_pad_set_caps (GstPad * pad, GstCaps * caps) #ifndef GST_DISABLE_DEPRECATED +#define GST_MESSAGE_DURATION GST_MESSAGE_DURATION_CHANGED +#define gst_message_new_duration_changed(src,fmt,dur) \ + gst_message_new_duration_changed(src) +#define gst_message_parse_duration(msg,fmt,dur) \ +G_STMT_START { \ + GstFormat *p_fmt = fmt; \ + gint64 *p_dur = dur; \ + if (p_fmt) \ + *p_fmt = GST_FORMAT_TIME; \ + if (p_dur) \ + *p_dur = GST_CLOCK_TIME_NONE; \ +} G_STMT_END + #endif /* not GST_DISABLE_DEPRECATED */ G_END_DECLS diff --git a/gst/gstmessage.c b/gst/gstmessage.c index d7a9735..d2bb8d7 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -96,7 +96,7 @@ static GstMessageQuarks message_quarks[] = { {GST_MESSAGE_ELEMENT, "element", 0}, {GST_MESSAGE_SEGMENT_START, "segment-start", 0}, {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0}, - {GST_MESSAGE_DURATION, "duration", 0}, + {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0}, {GST_MESSAGE_LATENCY, "latency", 0}, {GST_MESSAGE_ASYNC_START, "async-start", 0}, {GST_MESSAGE_ASYNC_DONE, "async-done", 0}, @@ -805,33 +805,28 @@ gst_message_new_element (GstObject * src, GstStructure * structure) } /** - * gst_message_new_duration: + * gst_message_new_duration_changed: * @src: (transfer none): The object originating the message. - * @format: The format of the duration - * @duration: The new duration * - * Create a new duration message. This message is posted by elements that - * know the duration of a stream in a specific format. This message + * Create a new duration changed message. This message is posted by elements + * that know the duration of a stream when the duration changes. This message * is received by bins and is used to calculate the total duration of a * pipeline. Elements may post a duration message with a duration of * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the * cached duration should be discarded. The new duration can then be * retrieved via a query. * - * Returns: (transfer full): The new duration message. + * Returns: (transfer full): The new duration-changed message. * * MT safe. */ GstMessage * -gst_message_new_duration (GstObject * src, GstFormat format, gint64 duration) +gst_message_new_duration_changed (GstObject * src) { GstMessage *message; - GstStructure *structure; - structure = gst_structure_new_id (GST_QUARK (MESSAGE_DURATION), - GST_QUARK (FORMAT), GST_TYPE_FORMAT, format, - GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL); - message = gst_message_new_custom (GST_MESSAGE_DURATION, src, structure); + message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src, + gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED))); return message; } @@ -1482,39 +1477,6 @@ gst_message_parse_segment_done (GstMessage * message, GstFormat * format, } /** - * gst_message_parse_duration: - * @message: A valid #GstMessage of type GST_MESSAGE_DURATION. - * @format: (out): Result location for the format, or NULL - * @duration: (out): Result location for the duration, or NULL - * - * Extracts the duration and format from the duration message. The duration - * might be GST_CLOCK_TIME_NONE, which indicates that the duration has - * changed. Applications should always use a query to retrieve the duration - * of a pipeline. - * - * MT safe. - */ -void -gst_message_parse_duration (GstMessage * message, GstFormat * format, - gint64 * duration) -{ - GstStructure *structure; - - g_return_if_fail (GST_IS_MESSAGE (message)); - g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DURATION); - - structure = GST_MESSAGE_STRUCTURE (message); - if (format) - *format = (GstFormat) - g_value_get_enum (gst_structure_id_get_value (structure, - GST_QUARK (FORMAT))); - if (duration) - *duration = - g_value_get_int64 (gst_structure_id_get_value (structure, - GST_QUARK (DURATION))); -} - -/** * gst_message_parse_async_done: * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE. * @running_time: (out): Result location for the running_time or NULL diff --git a/gst/gstmessage.h b/gst/gstmessage.h index 7d05f95..0328667 100644 --- a/gst/gstmessage.h +++ b/gst/gstmessage.h @@ -71,8 +71,8 @@ typedef struct _GstMessage GstMessage; * @GST_MESSAGE_SEGMENT_DONE: pipeline completed playback of a segment. This * message is forwarded to the application after all elements that posted * @GST_MESSAGE_SEGMENT_START posted a GST_MESSAGE_SEGMENT_DONE message. - * @GST_MESSAGE_DURATION: The duration of a pipeline changed. The application - * can get the new duration with a duration query. + * @GST_MESSAGE_DURATION_CHANGED: The duration of a pipeline changed. The + * application can get the new duration with a duration query. * @GST_MESSAGE_ASYNC_START: Posted by elements when they start an ASYNC * #GstStateChange. This message is not forwarded to the application but is used * internally. @@ -125,7 +125,7 @@ typedef enum GST_MESSAGE_ELEMENT = (1 << 15), GST_MESSAGE_SEGMENT_START = (1 << 16), GST_MESSAGE_SEGMENT_DONE = (1 << 17), - GST_MESSAGE_DURATION = (1 << 18), + GST_MESSAGE_DURATION_CHANGED = (1 << 18), GST_MESSAGE_LATENCY = (1 << 19), GST_MESSAGE_ASYNC_START = (1 << 20), GST_MESSAGE_ASYNC_DONE = (1 << 21), @@ -488,10 +488,8 @@ GstMessage * gst_message_new_segment_done (GstObject * src, GstFormat form void gst_message_parse_segment_done (GstMessage *message, GstFormat *format, gint64 *position); -/* DURATION */ -GstMessage * gst_message_new_duration (GstObject * src, GstFormat format, gint64 duration) G_GNUC_MALLOC; -void gst_message_parse_duration (GstMessage *message, GstFormat *format, - gint64 *duration); +/* DURATION_CHANGED */ +GstMessage * gst_message_new_duration_changed (GstObject * src) G_GNUC_MALLOC; /* LATENCY */ GstMessage * gst_message_new_latency (GstObject * src) G_GNUC_MALLOC; diff --git a/gst/gstquark.c b/gst/gstquark.c index dc439ed..6384bfd 100644 --- a/gst/gstquark.c +++ b/gst/gstquark.c @@ -43,7 +43,8 @@ static const gchar *_quark_strings[] = { "GstMessageError", "GstMessageWarning", "GstMessageInfo", "GstMessageBuffering", "GstMessageStateChanged", "GstMessageClockProvide", "GstMessageClockLost", "GstMessageNewClock", "GstMessageStructureChange", - "GstMessageSegmentStart", "GstMessageSegmentDone", "GstMessageDuration", + "GstMessageSegmentStart", "GstMessageSegmentDone", + "GstMessageDurationChanged", "GstMessageAsyncDone", "GstMessageRequestState", "GstMessageStreamStatus", "GstQueryPosition", "GstQueryDuration", "GstQueryLatency", "GstQueryConvert", "GstQuerySegment", "GstQuerySeeking", "GstQueryFormats", "GstQueryBuffering", diff --git a/gst/gstquark.h b/gst/gstquark.h index e77af84..f03d2fd 100644 --- a/gst/gstquark.h +++ b/gst/gstquark.h @@ -96,7 +96,7 @@ typedef enum _GstQuarkId GST_QUARK_MESSAGE_STRUCTURE_CHANGE = 67, GST_QUARK_MESSAGE_SEGMENT_START = 68, GST_QUARK_MESSAGE_SEGMENT_DONE = 69, - GST_QUARK_MESSAGE_DURATION = 70, + GST_QUARK_MESSAGE_DURATION_CHANGED = 70, GST_QUARK_MESSAGE_ASYNC_DONE = 71, GST_QUARK_MESSAGE_REQUEST_STATE = 72, GST_QUARK_MESSAGE_STREAM_STATUS = 73, diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 8e08e84..81f88ad 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -555,7 +555,7 @@ EXPORTS gst_message_new_clock_lost gst_message_new_clock_provide gst_message_new_custom - gst_message_new_duration + gst_message_new_duration_changed gst_message_new_element gst_message_new_eos gst_message_new_error @@ -583,7 +583,6 @@ EXPORTS gst_message_parse_buffering_stats gst_message_parse_clock_lost gst_message_parse_clock_provide - gst_message_parse_duration gst_message_parse_error gst_message_parse_info gst_message_parse_new_clock -- 2.7.4