From 1365624d7462c9d90d99a85d4f510c5d043d7118 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 8 Apr 2008 20:17:49 +0000 Subject: [PATCH] Add busy field and quark for the buffering query so that the app can only use the query to see if buffering is in pro... Original commit message from CVS: * docs/design/part-buffering.txt: * gst/gstquark.c: * gst/gstquark.h: * gst/gstquery.c: (gst_query_parse_latency), (gst_query_new_buffering), (gst_query_set_buffering_percent), (gst_query_parse_buffering_percent): * gst/gstquery.h: Add busy field and quark for the buffering query so that the app can only use the query to see if buffering is in progress. --- ChangeLog | 12 ++++++++++++ docs/design/part-buffering.txt | 4 ++++ gst/gstquark.c | 2 +- gst/gstquark.h | 3 ++- gst/gstquery.c | 18 +++++++++++++++--- gst/gstquery.h | 4 ++-- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2a1688007..e03d36c0eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-04-08 Wim Taymans + + * docs/design/part-buffering.txt: + * gst/gstquark.c: + * gst/gstquark.h: + * gst/gstquery.c: (gst_query_parse_latency), + (gst_query_new_buffering), (gst_query_set_buffering_percent), + (gst_query_parse_buffering_percent): + * gst/gstquery.h: + Add busy field and quark for the buffering query so that the app can + only use the query to see if buffering is in progress. + 2008-04-08 Wim Taymans * docs/gst/gstreamer-sections.txt: diff --git a/docs/design/part-buffering.txt b/docs/design/part-buffering.txt index 9d443dd330..3665a4255d 100644 --- a/docs/design/part-buffering.txt +++ b/docs/design/part-buffering.txt @@ -191,6 +191,10 @@ In addition to all the fields present in the buffering message, the BUFFERING query contains the following field, which indicate the available downloaded range in a specific format and the estimated time to complete: + "busy", G_TYPE_BOOLEAN + - if buffering was busy. This flag allows the application to pause the + pipeline by using the query only. + "format", GST_TYPE_FORMAT - the format of the "start" and "stop" values below diff --git a/gst/gstquark.c b/gst/gstquark.c index 0b1789667d..71de551ad1 100644 --- a/gst/gstquark.c +++ b/gst/gstquark.c @@ -34,7 +34,7 @@ static const gchar *_quark_strings[] = { "avg-in-rate", "avg-out-rate", "buffering-left", "estimated-total", "old-state", "new-state", "pending-state", "clock", "ready", "position", "new-base-time", "live", "min-latency", - "max-latency" + "max-latency", "busy" }; GQuark _priv_gst_quark_table[GST_QUARK_MAX]; diff --git a/gst/gstquark.h b/gst/gstquark.h index c9f386f3e8..12e1601aa9 100644 --- a/gst/gstquark.h +++ b/gst/gstquark.h @@ -59,8 +59,9 @@ typedef enum _GstQuarkId GST_QUARK_LIVE = 30, GST_QUARK_MIN_LATENCY = 31, GST_QUARK_MAX_LATENCY = 32, + GST_QUARK_BUSY = 33, - GST_QUARK_MAX = 33 + GST_QUARK_MAX = 34 } GstQuarkId; extern GQuark _priv_gst_quark_table[GST_QUARK_MAX]; diff --git a/gst/gstquery.c b/gst/gstquery.c index 15b166230b..464194a9de 100644 --- a/gst/gstquery.c +++ b/gst/gstquery.c @@ -1118,8 +1118,11 @@ gst_query_new_buffering (GstFormat format) GstStructure *structure; structure = gst_structure_empty_new ("GstQueryBuffering"); + /* by default, we configure the answer as no buffering with a 100% buffering + * progress */ gst_structure_id_set (structure, - GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, -1, + GST_QUARK (BUSY), G_TYPE_BOOLEAN, FALSE, + GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, 100, GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM, GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1, GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1, @@ -1137,36 +1140,45 @@ gst_query_new_buffering (GstFormat format) /** * gst_query_set_buffering_percent * @query: A valid #GstQuery of type GST_QUERY_BUFFERING. + * @busy: if buffering is busy * @percent: a buffering percent * * Set the percentage of buffered data. This is a value between 0 and 100. + * The @busy indicator is %TRUE when the buffering is in progress. * * Since: 0.10.20 */ void -gst_query_set_buffering_percent (GstQuery * query, gint percent) +gst_query_set_buffering_percent (GstQuery * query, gboolean busy, gint percent) { g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING); g_return_if_fail (percent >= 0 && percent <= 100); gst_structure_id_set (query->structure, + GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent, NULL); } /** * gst_query_parse_buffering_percent * @query: A valid #GstQuery of type GST_QUERY_BUFFERING. + * @busy: if buffering is busy * @percent: a buffering percent * * Get the percentage of buffered data. This is a value between 0 and 100. + * The @busy indicator is %TRUE when the buffering is in progress. * * Since: 0.10.20 */ void -gst_query_parse_buffering_percent (GstQuery * query, gint * percent) +gst_query_parse_buffering_percent (GstQuery * query, gboolean * busy, + gint * percent) { g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_BUFFERING); + if (busy) + *busy = g_value_get_boolean (gst_structure_id_get_value (query->structure, + GST_QUARK (BUSY))); if (percent) *percent = g_value_get_int (gst_structure_id_get_value (query->structure, GST_QUARK (BUFFER_PERCENT))); diff --git a/gst/gstquery.h b/gst/gstquery.h index 588b576405..4788c2480c 100644 --- a/gst/gstquery.h +++ b/gst/gstquery.h @@ -266,8 +266,8 @@ void gst_query_parse_formats_nth (GstQuery *query, guint nth, Gst /* buffering query */ GstQuery* gst_query_new_buffering (GstFormat format); -void gst_query_set_buffering_percent (GstQuery *query, gint percent); -void gst_query_parse_buffering_percent (GstQuery *query, gint *percent); +void gst_query_set_buffering_percent (GstQuery *query, gboolean busy, gint percent); +void gst_query_parse_buffering_percent (GstQuery *query, gboolean *busy, gint *percent); void gst_query_set_buffering_stats (GstQuery *query, GstBufferingMode mode, gint avg_in, gint avg_out, -- 2.34.1