From 318baf4cd9d2ece90723b4a3137f115d07ca0758 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 14 Mar 2012 16:14:12 +0100 Subject: [PATCH] query: add new drain query With the new serialized downstream queries we can implement a drain query that makes an element waits until a downstream element replies to the query. --- gst/gstquark.c | 2 +- gst/gstquark.h | 3 ++- gst/gstquery.c | 22 ++++++++++++++++++++++ gst/gstquery.h | 6 +++++- win32/common/libgstreamer.def | 1 + 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/gst/gstquark.c b/gst/gstquark.c index a416add28f..22f2104f67 100644 --- a/gst/gstquark.c +++ b/gst/gstquark.c @@ -56,7 +56,7 @@ static const gchar *_quark_strings[] = { "GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode", "allocator", "GstEventFlushStop", "options", "GstQueryAcceptCaps", "result", "GstQueryCaps", "filter", "modes", "GstEventStreamConfig", - "setup-data", "stream-headers", "GstEventGap" + "setup-data", "stream-headers", "GstEventGap", "GstQueryDrain" }; GQuark _priv_gst_quark_table[GST_QUARK_MAX]; diff --git a/gst/gstquark.h b/gst/gstquark.h index 5225b24026..354a6c487c 100644 --- a/gst/gstquark.h +++ b/gst/gstquark.h @@ -162,7 +162,8 @@ typedef enum _GstQuarkId GST_QUARK_SETUP_DATA = 133, GST_QUARK_STREAM_HEADERS = 134, GST_QUARK_EVENT_GAP = 135, - GST_QUARK_MAX = 136 + GST_QUARK_QUERY_DRAIN = 136, + GST_QUARK_MAX = 137 } GstQuarkId; extern GQuark _priv_gst_quark_table[GST_QUARK_MAX]; diff --git a/gst/gstquery.c b/gst/gstquery.c index 1b01a88081..2ad44b5a29 100644 --- a/gst/gstquery.c +++ b/gst/gstquery.c @@ -121,6 +121,7 @@ static GstQueryQuarks query_quarks[] = { {GST_QUERY_SCHEDULING, "scheduling", 0}, {GST_QUERY_ACCEPT_CAPS, "accept-caps", 0}, {GST_QUERY_CAPS, "caps", 0}, + {GST_QUERY_DRAIN, "drain", 0}, {0, NULL, 0} }; @@ -2147,3 +2148,24 @@ gst_query_intersect_caps_result (GstQuery * query, GstCaps * filter, gst_query_set_caps_result (query, res); gst_caps_unref (res); } + +/** + * gst_query_new_drain: + * + * Constructs a new query object for querying the drain state. + * + * Free-function: gst_query_unref + * + * Returns: (transfer full): a new #GstQuery + */ +GstQuery * +gst_query_new_drain (void) +{ + GstQuery *query; + GstStructure *structure; + + structure = gst_structure_new_id_empty (GST_QUARK (QUERY_DRAIN)); + query = gst_query_new_custom (GST_QUERY_DRAIN, structure); + + return query; +} diff --git a/gst/gstquery.h b/gst/gstquery.h index f32b92e02c..c79ab7987a 100644 --- a/gst/gstquery.h +++ b/gst/gstquery.h @@ -101,6 +101,7 @@ typedef enum { * @GST_QUERY_SCHEDULING: the scheduling properties * @GST_QUERY_ACCEPT_CAPS: the accept caps query * @GST_QUERY_CAPS: the caps query + * @GST_QUERY_DRAIN: wait till all serialized data is consumed downstream * * Standard predefined Query types */ @@ -123,7 +124,8 @@ typedef enum { GST_QUERY_ALLOCATION = GST_QUERY_MAKE_TYPE (140, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)), GST_QUERY_SCHEDULING = GST_QUERY_MAKE_TYPE (150, FLAG(UPSTREAM)), GST_QUERY_ACCEPT_CAPS = GST_QUERY_MAKE_TYPE (160, FLAG(BOTH)), - GST_QUERY_CAPS = GST_QUERY_MAKE_TYPE (170, FLAG(BOTH)) + GST_QUERY_CAPS = GST_QUERY_MAKE_TYPE (170, FLAG(BOTH)), + GST_QUERY_DRAIN = GST_QUERY_MAKE_TYPE (180, FLAG(DOWNSTREAM) | FLAG(SERIALIZED)) } GstQueryType; #undef FLAG @@ -456,6 +458,8 @@ void gst_query_parse_caps_result (GstQuery *query, GstCaps **c void gst_query_intersect_caps_result (GstQuery *query, GstCaps *filter, GstCapsIntersectMode mode); +/* drain query */ +GstQuery * gst_query_new_drain (void) G_GNUC_MALLOC; G_END_DECLS diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 44d9b9966b..57a8f864fe 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -825,6 +825,7 @@ EXPORTS gst_query_new_caps gst_query_new_convert gst_query_new_custom + gst_query_new_drain gst_query_new_duration gst_query_new_formats gst_query_new_latency