buffer: add gst_buffer_get_n_meta() convenience function

Counts how many metas there are for a certain api type.

https://bugzilla.gnome.org/show_bug.cgi?id=791918
This commit is contained in:
Tim-Philipp Müller 2017-12-23 16:45:18 +01:00
parent b5028383ab
commit cd10f14726
4 changed files with 27 additions and 0 deletions

View file

@ -253,6 +253,7 @@ gst_buffer_append
gst_buffer_append_region gst_buffer_append_region
gst_buffer_get_meta gst_buffer_get_meta
gst_buffer_get_n_meta
gst_buffer_add_meta gst_buffer_add_meta
gst_buffer_remove_meta gst_buffer_remove_meta
gst_buffer_iterate_meta gst_buffer_iterate_meta

View file

@ -2139,6 +2139,28 @@ gst_buffer_get_meta (GstBuffer * buffer, GType api)
return result; return result;
} }
/**
* gst_buffer_get_n_meta:
* @buffer: a #GstBuffer
* @api_type: the #GType of an API
*
* Returns: number of metas of type @api_type on @buffer.
*
* Since: 1.14
*/
guint
gst_buffer_get_n_meta (GstBuffer * buffer, GType api_type)
{
gpointer state = NULL;
GstMeta *meta;
guint n = 0;
while ((meta = gst_buffer_iterate_meta_filtered (buffer, &state, api_type)))
++n;
return n;
}
/** /**
* gst_buffer_add_meta: * gst_buffer_add_meta:
* @buffer: a #GstBuffer * @buffer: a #GstBuffer

View file

@ -612,6 +612,9 @@ typedef gboolean (*GstBufferForeachMetaFunc) (GstBuffer *buffer, GstMeta **me
GST_EXPORT GST_EXPORT
GstMeta * gst_buffer_get_meta (GstBuffer *buffer, GType api); GstMeta * gst_buffer_get_meta (GstBuffer *buffer, GType api);
GST_EXPORT
guint gst_buffer_get_n_meta (GstBuffer *buffer, GType api);
GST_EXPORT GST_EXPORT
GstMeta * gst_buffer_add_meta (GstBuffer *buffer, const GstMetaInfo *info, GstMeta * gst_buffer_add_meta (GstBuffer *buffer, const GstMetaInfo *info,
gpointer params); gpointer params);

View file

@ -136,6 +136,7 @@ EXPORTS
gst_buffer_get_memory gst_buffer_get_memory
gst_buffer_get_memory_range gst_buffer_get_memory_range
gst_buffer_get_meta gst_buffer_get_meta
gst_buffer_get_n_meta
gst_buffer_get_reference_timestamp_meta gst_buffer_get_reference_timestamp_meta
gst_buffer_get_size gst_buffer_get_size
gst_buffer_get_sizes gst_buffer_get_sizes