}
static GArray *
-ensure_array (GstStructure * s, GQuark quark, gsize element_size)
+ensure_array (GstStructure * s, GQuark quark, gsize element_size,
+ GDestroyNotify clear_func)
{
GArray *array;
const GValue *value;
GValue new_array_val = { 0, };
array = g_array_new (FALSE, TRUE, element_size);
+ if (clear_func)
+ g_array_set_clear_func (array, clear_func);
g_value_init (&new_array_val, G_TYPE_ARRAY);
g_value_take_boxed (&new_array_val, array);
/**
* gst_query_parse_n_formats:
* @query: a #GstQuery
- * @n_formats: (out): the number of formats in this query.
+ * @n_formats: (out) (allow-none): the number of formats in this query.
*
* Parse the number of formats in the formats @query.
*
* gst_query_parse_nth_format:
* @query: a #GstQuery
* @nth: (out): the nth format to retrieve.
- * @format: (out): a pointer to store the nth format
+ * @format: (out) (allow-none): a pointer to store the nth format
*
* Parse the format query and retrieve the @nth format from it into
* @format. If the list contains less elements than @nth, @format will be
structure = GST_QUERY_STRUCTURE (query);
array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
- sizeof (GstQueryBufferingRange));
+ sizeof (GstQueryBufferingRange), NULL);
if (array->len > 1) {
GstQueryBufferingRange *last;
structure = GST_QUERY_STRUCTURE (query);
array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
- sizeof (GstQueryBufferingRange));
+ sizeof (GstQueryBufferingRange), NULL);
return array->len;
}
structure = GST_QUERY_STRUCTURE (query);
array = ensure_array (structure, GST_QUARK (BUFFERING_RANGES),
- sizeof (GstQueryBufferingRange));
+ sizeof (GstQueryBufferingRange), NULL);
if (index >= array->len)
return FALSE;
/**
* gst_query_parse_allocation_params:
* @query: A valid #GstQuery of type GST_QUERY_ALLOCATION.
- * @size: the size
- * @min_buffers: the min buffers
- * @max_buffers: the max buffers
- * @prefix: the prefix
- * @alignment: the alignment
- * @pool: the #GstBufferPool
+ * @size: (out) (allow-none): the size
+ * @min_buffers: (out) (allow-none): the min buffers
+ * @max_buffers: (out) (allow-none): the max buffers
+ * @prefix: (out) (allow-none): the prefix
+ * @alignment: (out) (allow-none): the alignment
+ * @pool: (out) (allow-none) (transfer full): the #GstBufferPool
*
* Get the allocation parameters in @query.
*/
g_return_if_fail (gst_query_is_writable (query));
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (const gchar *));
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (const gchar *), NULL);
api = g_intern_string (api);
g_array_append_val (array, api);
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, 0);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (const gchar *));
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (const gchar *), NULL);
return array->len;
}
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, NULL);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (const gchar *));
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (const gchar *), NULL);
if (index < array->len)
ret = g_array_index (array, const gchar *, index);
g_return_val_if_fail (api != NULL, FALSE);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (META), sizeof (const gchar *));
+ array =
+ ensure_array (structure, GST_QUARK (META), sizeof (const gchar *), NULL);
len = array->len;
for (i = 0; i < len; i++) {
/**
* gst_query_add_allocation_memory:
* @query: a GST_QUERY_ALLOCATION type query #GstQuery
- * @alloc: the memory allocator
+ * @allocator: the memory allocator
*
- * Add @alloc as a supported memory allocator.
+ * Add @allocator as a supported memory allocator.
*/
void
-gst_query_add_allocation_memory (GstQuery * query, const gchar * alloc)
+gst_query_add_allocation_memory (GstQuery * query, GstAllocator * allocator)
{
GArray *array;
GstStructure *structure;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION);
g_return_if_fail (gst_query_is_writable (query));
+ g_return_if_fail (allocator != NULL);
structure = GST_QUERY_STRUCTURE (query);
array =
- ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (const gchar *));
+ ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (GstAllocator *),
+ (GDestroyNotify) gst_allocator_unref);
- alloc = g_intern_string (alloc);
- g_array_append_val (array, alloc);
+ g_array_append_val (array, allocator);
}
/**
structure = GST_QUERY_STRUCTURE (query);
array =
- ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (const gchar *));
+ ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (GstAllocator *),
+ (GDestroyNotify) gst_allocator_unref);
return array->len;
}
* Parse an available query and get the alloctor
* at @index of the allocator array.
*
- * Returns: the name of the allocator at @index.
+ * Returns: (transfer none): the allocator at @index. The allocator remains
+ * valid for as long as @query is valid.
*/
-const gchar *
+GstAllocator *
gst_query_parse_nth_allocation_memory (GstQuery * query, guint index)
{
GArray *array;
- const gchar *ret = NULL;
+ GstAllocator *ret = NULL;
GstStructure *structure;
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION, NULL);
structure = GST_QUERY_STRUCTURE (query);
array =
- ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (const gchar *));
+ ensure_array (structure, GST_QUARK (ALLOCATOR), sizeof (GstAllocator *),
+ (GDestroyNotify) gst_allocator_unref);
if (index < array->len)
- ret = g_array_index (array, const gchar *, index);
+ ret = g_array_index (array, GstAllocator *, index);
return ret;
}
/**
* gst_query_parse_scheduling:
* @query: A valid #GstQuery of type GST_QUERY_SCHEDULING.
- * @flags: #GstSchedulingFlags
- * @minsize: the suggested minimum size of pull requests
- * @maxsize: the suggested maximum size of pull requests:
- * @align: the suggested alignment of pull requests
+ * @flags: (out) (allow-none): #GstSchedulingFlags
+ * @minsize: (out) (allow-none): the suggested minimum size of pull requests
+ * @maxsize: (out) (allow-none): the suggested maximum size of pull requests:
+ * @align: (out) (allow-none): the suggested alignment of pull requests
*
* Set the scheduling properties.
*/
g_return_if_fail (gst_query_is_writable (query));
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode));
+ array =
+ ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
g_array_append_val (array, mode);
}
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, 0);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode));
+ array =
+ ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
return array->len;
}
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, ret);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode));
+ array =
+ ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
if (index < array->len)
ret = g_array_index (array, GstPadMode, index);
g_return_val_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SCHEDULING, FALSE);
structure = GST_QUERY_STRUCTURE (query);
- array = ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode));
+ array =
+ ensure_array (structure, GST_QUARK (MODES), sizeof (GstPadMode), NULL);
len = array->len;
for (i = 0; i < len; i++) {
GstStructure *structure;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_ACCEPT_CAPS);
+ g_return_if_fail (caps != NULL);
structure = GST_QUERY_STRUCTURE (query);
*caps = g_value_get_boxed (gst_structure_id_get_value (structure,
GstStructure *structure;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
+ g_return_if_fail (filter != NULL);
structure = GST_QUERY_STRUCTURE (query);
*filter = g_value_get_boxed (gst_structure_id_get_value (structure,
GstStructure *structure;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_CAPS);
+ g_return_if_fail (caps != NULL);
structure = GST_QUERY_STRUCTURE (query);
*caps = g_value_get_boxed (gst_structure_id_get_value (structure,