video: Make gst_buffer_get_video_meta() a real function, Return lowest id

Instead of returning the first video meta found on a buffer, return the
one with the lowest id (which is usually the same thing, except on
multi-view buffers)
This commit is contained in:
Jan Schmidt 2014-10-09 01:13:29 +11:00
parent a24b9cd5c2
commit d18aa5b741
3 changed files with 34 additions and 1 deletions

View file

@ -96,6 +96,38 @@ gst_video_meta_get_info (void)
return video_meta_info;
}
/**
* gst_buffer_get_video_meta:
* @buffer: a #GstBuffer
*
* Find the #GstVideoMeta on @buffer with the lowest @id.
*
* Buffers can contain multiple #GstVideoMeta metadata items when dealing with
* multiview buffers.
*
* Returns: the #GstVideoMeta with lowest id (usually 0) or %NULL when there
* is no such metadata on @buffer.
*/
GstVideoMeta *
gst_buffer_get_video_meta (GstBuffer * buffer)
{
gpointer state = NULL;
GstVideoMeta *out = NULL;
GstMeta *meta;
const GstMetaInfo *info = GST_VIDEO_META_INFO;
while ((meta = gst_buffer_iterate_meta (buffer, &state))) {
if (meta->info->api == info->api) {
GstVideoMeta *vmeta = (GstVideoMeta *) meta;
if (vmeta->id == 0)
return vmeta; /* Early out for id 0 */
if (out == NULL || vmeta->id < out->id)
out = vmeta;
}
}
return out;
}
/**
* gst_buffer_get_video_meta_id:
* @buffer: a #GstBuffer

View file

@ -78,7 +78,7 @@ struct _GstVideoMeta {
GType gst_video_meta_api_get_type (void);
const GstMetaInfo * gst_video_meta_get_info (void);
#define gst_buffer_get_video_meta(b) ((GstVideoMeta*)gst_buffer_get_meta((b),GST_VIDEO_META_API_TYPE))
GstVideoMeta * gst_buffer_get_video_meta (GstBuffer *buffer);
GstVideoMeta * gst_buffer_get_video_meta_id (GstBuffer *buffer, gint id);
GstVideoMeta * gst_buffer_add_video_meta (GstBuffer *buffer, GstVideoFrameFlags flags,

View file

@ -6,6 +6,7 @@ EXPORTS
gst_buffer_add_video_overlay_composition_meta
gst_buffer_add_video_region_of_interest_meta
gst_buffer_add_video_region_of_interest_meta_id
gst_buffer_get_video_meta
gst_buffer_get_video_meta_id
gst_buffer_get_video_region_of_interest_meta_id
gst_buffer_pool_config_get_video_alignment