mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
query: Add a new stream selection query
This new API allows querying whether elements can handle stream selection themselves or not. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1905>
This commit is contained in:
parent
d19dbfc1e3
commit
e291ad2cbb
4 changed files with 99 additions and 2 deletions
|
@ -80,7 +80,7 @@ static const gchar *_quark_strings[] = {
|
||||||
"GstEventInstantRateChange",
|
"GstEventInstantRateChange",
|
||||||
"GstEventInstantRateSyncTime", "GstMessageInstantRateRequest",
|
"GstEventInstantRateSyncTime", "GstMessageInstantRateRequest",
|
||||||
"upstream-running-time", "base", "offset", "plugin-api", "plugin-api-flags",
|
"upstream-running-time", "base", "offset", "plugin-api", "plugin-api-flags",
|
||||||
"gap-flags"
|
"gap-flags", "GstQuerySelectable", "selectable"
|
||||||
};
|
};
|
||||||
|
|
||||||
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
||||||
|
|
|
@ -231,7 +231,9 @@ typedef enum _GstQuarkId
|
||||||
GST_QUARK_PLUGIN_API = 200,
|
GST_QUARK_PLUGIN_API = 200,
|
||||||
GST_QUARK_PLUGIN_API_FLAGS = 201,
|
GST_QUARK_PLUGIN_API_FLAGS = 201,
|
||||||
GST_QUARK_GAP_FLAGS = 202,
|
GST_QUARK_GAP_FLAGS = 202,
|
||||||
GST_QUARK_MAX = 203
|
GST_QUARK_QUERY_SELECTABLE = 203,
|
||||||
|
GST_QUARK_SELECTABLE = 204,
|
||||||
|
GST_QUARK_MAX = 205
|
||||||
} GstQuarkId;
|
} GstQuarkId;
|
||||||
|
|
||||||
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
||||||
|
|
|
@ -2728,6 +2728,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:
|
* gst_query_ref:
|
||||||
* @q: a #GstQuery to increase the refcount of.
|
* @q: a #GstQuery to increase the refcount of.
|
||||||
|
|
|
@ -100,6 +100,7 @@ typedef enum {
|
||||||
* @GST_QUERY_CONTEXT: query the pipeline-local context from
|
* @GST_QUERY_CONTEXT: query the pipeline-local context from
|
||||||
* downstream or upstream (since 1.2)
|
* downstream or upstream (since 1.2)
|
||||||
* @GST_QUERY_BITRATE: the bitrate query (since 1.16)
|
* @GST_QUERY_BITRATE: the bitrate query (since 1.16)
|
||||||
|
* @GST_QUERY_SELECTABLE: Query stream selection capability (Since: 1.22)
|
||||||
*
|
*
|
||||||
* Standard predefined Query types
|
* Standard predefined Query types
|
||||||
*/
|
*/
|
||||||
|
@ -126,6 +127,15 @@ typedef enum {
|
||||||
GST_QUERY_DRAIN = GST_QUERY_MAKE_TYPE (180, _FLAG(DOWNSTREAM) | _FLAG(SERIALIZED)),
|
GST_QUERY_DRAIN = GST_QUERY_MAKE_TYPE (180, _FLAG(DOWNSTREAM) | _FLAG(SERIALIZED)),
|
||||||
GST_QUERY_CONTEXT = GST_QUERY_MAKE_TYPE (190, _FLAG(BOTH)),
|
GST_QUERY_CONTEXT = GST_QUERY_MAKE_TYPE (190, _FLAG(BOTH)),
|
||||||
GST_QUERY_BITRATE = GST_QUERY_MAKE_TYPE (200, _FLAG(DOWNSTREAM)),
|
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;
|
} GstQueryType;
|
||||||
#undef _FLAG
|
#undef _FLAG
|
||||||
|
|
||||||
|
@ -653,6 +663,17 @@ void gst_query_set_bitrate (GstQuery * query, guint nomi
|
||||||
GST_API
|
GST_API
|
||||||
void gst_query_parse_bitrate (GstQuery * query, guint * nominal_bitrate);
|
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_DEFINE_AUTOPTR_CLEANUP_FUNC(GstQuery, gst_query_unref)
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Reference in a new issue