From: Edward Hervey Date: Wed, 30 Mar 2022 08:01:33 +0000 (+0200) Subject: query: Add a new stream selection query X-Git-Tag: 1.22.0~1966 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=e291ad2cbbc6f898a5b64f58e83928784f95d8d2;p=platform%2Fupstream%2Fgstreamer.git query: Add a new stream selection query This new API allows querying whether elements can handle stream selection themselves or not. Part-of: --- diff --git a/subprojects/gstreamer/gst/gstquark.c b/subprojects/gstreamer/gst/gstquark.c index dd9f1c1..304e274 100644 --- a/subprojects/gstreamer/gst/gstquark.c +++ b/subprojects/gstreamer/gst/gstquark.c @@ -80,7 +80,7 @@ static const gchar *_quark_strings[] = { "GstEventInstantRateChange", "GstEventInstantRateSyncTime", "GstMessageInstantRateRequest", "upstream-running-time", "base", "offset", "plugin-api", "plugin-api-flags", - "gap-flags" + "gap-flags", "GstQuerySelectable", "selectable" }; GQuark _priv_gst_quark_table[GST_QUARK_MAX]; diff --git a/subprojects/gstreamer/gst/gstquark.h b/subprojects/gstreamer/gst/gstquark.h index df2e585..f7de510 100644 --- a/subprojects/gstreamer/gst/gstquark.h +++ b/subprojects/gstreamer/gst/gstquark.h @@ -231,7 +231,9 @@ typedef enum _GstQuarkId GST_QUARK_PLUGIN_API = 200, GST_QUARK_PLUGIN_API_FLAGS = 201, GST_QUARK_GAP_FLAGS = 202, - GST_QUARK_MAX = 203 + GST_QUARK_QUERY_SELECTABLE = 203, + GST_QUARK_SELECTABLE = 204, + GST_QUARK_MAX = 205 } GstQuarkId; extern GQuark _priv_gst_quark_table[GST_QUARK_MAX]; diff --git a/subprojects/gstreamer/gst/gstquery.c b/subprojects/gstreamer/gst/gstquery.c index 6ae1f76..f700e12 100644 --- a/subprojects/gstreamer/gst/gstquery.c +++ b/subprojects/gstreamer/gst/gstquery.c @@ -2729,6 +2729,80 @@ gst_query_parse_bitrate (GstQuery * query, guint * nominal_bitrate) } /** + * gst_query_new_selectable: + * + * Constructs a new query object for querying the stream selection capability. + * + * Free-function: gst_query_unref() + * + * Returns: (transfer full): a new #GstQuery + * + * Since: 1.22 + */ +GstQuery * +gst_query_new_selectable (void) +{ + GstQuery *query; + GstStructure *structure; + + structure = gst_structure_new_id_empty (GST_QUARK (QUERY_SELECTABLE)); + query = gst_query_new_custom (GST_QUERY_SELECTABLE, structure); + + return query; +} + +/** + * gst_query_set_selectable: + * @query: a GST_QUERY_SELECTABLE type #GstQuery + * @selectable: Whether the element can handle stream selection. + * + * Set the results of a selectable query. If the element answering the query can + * handle stream selection, @selectable should be set to %TRUE. + * + * Since: 1.22 + */ +void +gst_query_set_selectable (GstQuery * query, gboolean selectable) +{ + GstStructure *s; + + g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SELECTABLE); + + s = GST_QUERY_STRUCTURE (query); + + gst_structure_id_set (s, + GST_QUARK (SELECTABLE), G_TYPE_BOOLEAN, selectable, NULL); +} + +/** + * gst_query_parse_selectable: + * @query: a GST_QUERY_SELECTABLE type #GstQuery + * @selectable: (out) (allow-none): The resulting stream selection capability + * + * Get the results of a selectable query. See also gst_query_set_selectable(). + * + * Since: 1.22 + */ +void +gst_query_parse_selectable (GstQuery * query, gboolean * selectable) +{ + GstStructure *structure; + + g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SELECTABLE); + + structure = GST_QUERY_STRUCTURE (query); + + if (selectable) { + const GValue *value = + gst_structure_id_get_value (structure, GST_QUARK (SELECTABLE)); + if (value) + *selectable = g_value_get_boolean (value); + else + *selectable = FALSE; + } +} + +/** * gst_query_ref: * @q: a #GstQuery to increase the refcount of. * diff --git a/subprojects/gstreamer/gst/gstquery.h b/subprojects/gstreamer/gst/gstquery.h index 949e30a..7bf2774 100644 --- a/subprojects/gstreamer/gst/gstquery.h +++ b/subprojects/gstreamer/gst/gstquery.h @@ -100,6 +100,7 @@ typedef enum { * @GST_QUERY_CONTEXT: query the pipeline-local context from * downstream or upstream (since 1.2) * @GST_QUERY_BITRATE: the bitrate query (since 1.16) + * @GST_QUERY_SELECTABLE: Query stream selection capability (Since: 1.22) * * Standard predefined Query types */ @@ -126,6 +127,15 @@ typedef enum { GST_QUERY_DRAIN = GST_QUERY_MAKE_TYPE (180, _FLAG(DOWNSTREAM) | _FLAG(SERIALIZED)), GST_QUERY_CONTEXT = GST_QUERY_MAKE_TYPE (190, _FLAG(BOTH)), GST_QUERY_BITRATE = GST_QUERY_MAKE_TYPE (200, _FLAG(DOWNSTREAM)), + + /** + * GST_QUERY_SELECTABLE: + * + * Query stream selection capability. + * + * Since: 1.22 + */ + GST_QUERY_SELECTABLE = GST_QUERY_MAKE_TYPE (210, _FLAG(BOTH)), } GstQueryType; #undef _FLAG @@ -653,6 +663,17 @@ void gst_query_set_bitrate (GstQuery * query, guint nomi GST_API void gst_query_parse_bitrate (GstQuery * query, guint * nominal_bitrate); +/* selectable query */ + +GST_API +GstQuery * gst_query_new_selectable (void) G_GNUC_MALLOC; + +GST_API +void gst_query_set_selectable (GstQuery *query, gboolean selectable); + +GST_API +void gst_query_parse_selectable (GstQuery *query, gboolean * selectable); + G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstQuery, gst_query_unref) G_END_DECLS