mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 05:28:48 +00:00
query: add methods to query allocators
Add API to add and query allocator implementations to/from the ALLOCATION query.
This commit is contained in:
parent
acb3ee9b2c
commit
78ea732149
4 changed files with 109 additions and 2 deletions
|
@ -54,7 +54,7 @@ static const gchar *_quark_strings[] = {
|
||||||
"min-buffers", "max-buffers", "prefix", "postfix", "align", "time",
|
"min-buffers", "max-buffers", "prefix", "postfix", "align", "time",
|
||||||
"GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
|
"GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
|
||||||
"GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
|
"GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
|
||||||
"random-access", "sequential"
|
"random-access", "sequential", "allocator"
|
||||||
};
|
};
|
||||||
|
|
||||||
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
||||||
|
|
|
@ -152,8 +152,9 @@ typedef enum _GstQuarkId
|
||||||
GST_QUARK_PULL_MODE = 123,
|
GST_QUARK_PULL_MODE = 123,
|
||||||
GST_QUARK_RANDOM_ACCESS = 124,
|
GST_QUARK_RANDOM_ACCESS = 124,
|
||||||
GST_QUARK_SEQUENTIAL = 125,
|
GST_QUARK_SEQUENTIAL = 125,
|
||||||
|
GST_QUARK_ALLOCATOR = 126,
|
||||||
|
|
||||||
GST_QUARK_MAX = 126
|
GST_QUARK_MAX = 127
|
||||||
} GstQuarkId;
|
} GstQuarkId;
|
||||||
|
|
||||||
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
||||||
|
|
102
gst/gstquery.c
102
gst/gstquery.c
|
@ -1759,6 +1759,108 @@ gst_query_parse_nth_allocation_meta (GstQuery * query, guint index)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_query_add_allocation_memory
|
||||||
|
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
|
||||||
|
* @alloc: the memory allocator
|
||||||
|
*
|
||||||
|
* Add @alloc as a supported memory allocator.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_query_add_allocation_memory (GstQuery * query, const gchar * alloc)
|
||||||
|
{
|
||||||
|
GValueArray *array;
|
||||||
|
const GValue *value;
|
||||||
|
GValue alloc_value = { 0 };
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
|
||||||
|
g_return_if_fail (gst_query_is_writable (query));
|
||||||
|
|
||||||
|
structure = GST_QUERY_STRUCTURE (query);
|
||||||
|
value = gst_structure_id_get_value (structure, GST_QUARK (ALLOCATOR));
|
||||||
|
if (value) {
|
||||||
|
array = (GValueArray *) g_value_get_boxed (value);
|
||||||
|
} else {
|
||||||
|
GValue new_array_val = { 0, };
|
||||||
|
|
||||||
|
array = g_value_array_new (0);
|
||||||
|
|
||||||
|
g_value_init (&new_array_val, G_TYPE_VALUE_ARRAY);
|
||||||
|
g_value_take_boxed (&new_array_val, array);
|
||||||
|
|
||||||
|
gst_structure_id_take_value (structure, GST_QUARK (ALLOCATOR),
|
||||||
|
&new_array_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_value_init (&alloc_value, G_TYPE_STRING);
|
||||||
|
g_value_set_string (&alloc_value, alloc);
|
||||||
|
g_value_array_append (array, &alloc_value);
|
||||||
|
g_value_unset (&alloc_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_query_get_n_allocation_memories:
|
||||||
|
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
|
||||||
|
*
|
||||||
|
* Retrieve the number of values currently stored in the
|
||||||
|
* allocator array of the query's structure.
|
||||||
|
*
|
||||||
|
* Returns: the allocator array size as a #guint.
|
||||||
|
*/
|
||||||
|
guint
|
||||||
|
gst_query_get_n_allocation_memories (GstQuery * query)
|
||||||
|
{
|
||||||
|
GValueArray *array;
|
||||||
|
const GValue *value;
|
||||||
|
guint size = 0;
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
|
||||||
|
|
||||||
|
structure = GST_QUERY_STRUCTURE (query);
|
||||||
|
value = gst_structure_id_get_value (structure, GST_QUARK (ALLOCATOR));
|
||||||
|
if (value) {
|
||||||
|
array = (GValueArray *) g_value_get_boxed (value);
|
||||||
|
size = array->n_values;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_query_parse_nth_allocation_memory
|
||||||
|
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
|
||||||
|
* @index: position in the allocator array to read
|
||||||
|
*
|
||||||
|
* Parse an available query and get the alloctor
|
||||||
|
* at @index of the allocator array.
|
||||||
|
*
|
||||||
|
* Returns: the name of the allocator at @index.
|
||||||
|
*/
|
||||||
|
const gchar *
|
||||||
|
gst_query_parse_nth_allocation_memory (GstQuery * query, guint index)
|
||||||
|
{
|
||||||
|
const GValue *value;
|
||||||
|
const gchar *ret = NULL;
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, NULL);
|
||||||
|
|
||||||
|
structure = GST_QUERY_STRUCTURE (query);
|
||||||
|
value = gst_structure_id_get_value (structure, GST_QUARK (ALLOCATOR));
|
||||||
|
if (value) {
|
||||||
|
GValueArray *memory;
|
||||||
|
GValue *alloc_value;
|
||||||
|
|
||||||
|
memory = (GValueArray *) g_value_get_boxed (value);
|
||||||
|
alloc_value = g_value_array_get_nth (memory, index);
|
||||||
|
|
||||||
|
if (alloc_value)
|
||||||
|
ret = g_value_get_string (alloc_value);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_query_new_scheduling
|
* gst_query_new_scheduling
|
||||||
*
|
*
|
||||||
|
|
|
@ -364,6 +364,10 @@ void gst_query_add_allocation_meta (GstQuery *query, const gcha
|
||||||
guint gst_query_get_n_allocation_metas (GstQuery *query);
|
guint gst_query_get_n_allocation_metas (GstQuery *query);
|
||||||
const gchar * gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
|
const gchar * gst_query_parse_nth_allocation_meta (GstQuery *query, guint index);
|
||||||
|
|
||||||
|
void gst_query_add_allocation_memory (GstQuery *query, const gchar *alloc);
|
||||||
|
guint gst_query_get_n_allocation_memories (GstQuery *query);
|
||||||
|
const gchar * gst_query_parse_nth_allocation_memory (GstQuery *query, guint index);
|
||||||
|
|
||||||
/* scheduling query */
|
/* scheduling query */
|
||||||
GstQuery * gst_query_new_scheduling (void);
|
GstQuery * gst_query_new_scheduling (void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue