diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 08534dd74f..5628d8cbb2 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -254,6 +254,7 @@ gst_buffer_get_meta gst_buffer_add_meta gst_buffer_remove_meta gst_buffer_iterate_meta +gst_buffer_iterate_meta_filtered GstBufferForeachMetaFunc gst_buffer_foreach_meta diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 9fd83be0a0..8252b447e9 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -2276,6 +2276,49 @@ gst_buffer_iterate_meta (GstBuffer * buffer, gpointer * state) return NULL; } +/** + * gst_buffer_iterate_meta_filtered: (skip) + * @buffer: a #GstBuffer + * @state: an opaque state pointer + * @meta_api_type: only return #GstMeta of this type + * + * Retrieve the next #GstMeta of type @meta_api_type after the current one + * according to @state. If @state points to %NULL, the first metadata of + * type @meta_api_type is returned. + * + * @state will be updated with an opaque state pointer + * + * Returns: (transfer none) (nullable): The next #GstMeta of type + * @meta_api_type or %NULL when there are no more items. + * + * Since: 1.12 + */ +GstMeta * +gst_buffer_iterate_meta_filtered (GstBuffer * buffer, gpointer * state, + GType meta_api_type) +{ + GstMetaItem **meta; + + g_return_val_if_fail (buffer != NULL, NULL); + g_return_val_if_fail (state != NULL, NULL); + + meta = (GstMetaItem **) state; + if (*meta == NULL) + /* state NULL, move to first item */ + *meta = GST_BUFFER_META (buffer); + else + /* state !NULL, move to next item in list */ + *meta = (*meta)->next; + + while (*meta != NULL && (*meta)->meta.info->api != meta_api_type) + *meta = (*meta)->next; + + if (*meta) + return &(*meta)->meta; + else + return NULL; +} + /** * gst_buffer_foreach_meta: * @buffer: a #GstBuffer diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 41ddbb6bef..be6fae8524 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -545,6 +545,10 @@ gboolean gst_buffer_remove_meta (GstBuffer *buffer, GstMeta *met GstMeta * gst_buffer_iterate_meta (GstBuffer *buffer, gpointer *state); +GstMeta * gst_buffer_iterate_meta_filtered (GstBuffer * buffer, + gpointer * state, + GType meta_api_type); + gboolean gst_buffer_foreach_meta (GstBuffer *buffer, GstBufferForeachMetaFunc func, gpointer user_data); diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index fb37e7ef25..1f0fe3ff3b 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -144,6 +144,7 @@ EXPORTS gst_buffer_is_all_memory_writable gst_buffer_is_memory_range_writable gst_buffer_iterate_meta + gst_buffer_iterate_meta_filtered gst_buffer_list_copy_deep gst_buffer_list_foreach gst_buffer_list_get