summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst-libs/gst/video/gstvideometa.c63
-rw-r--r--gst-libs/gst/video/gstvideometa.h10
2 files changed, 72 insertions, 1 deletions
diff --git a/gst-libs/gst/video/gstvideometa.c b/gst-libs/gst/video/gstvideometa.c
index 58b268071..501efd30b 100644
--- a/gst-libs/gst/video/gstvideometa.c
+++ b/gst-libs/gst/video/gstvideometa.c
@@ -736,6 +736,7 @@ gst_video_region_of_interest_meta_init (GstMeta * meta, gpointer params,
emeta->id = 0;
emeta->parent_id = 0;
emeta->x = emeta->y = emeta->w = emeta->h = 0;
+ emeta->params = NULL;
return TRUE;
}
@@ -743,7 +744,9 @@ gst_video_region_of_interest_meta_init (GstMeta * meta, gpointer params,
static void
gst_video_region_of_interest_meta_free (GstMeta * meta, GstBuffer * buffer)
{
- // nothing to do
+ GstVideoRegionOfInterestMeta *emeta = (GstVideoRegionOfInterestMeta *) meta;
+
+ g_list_free_full (emeta->params, (GDestroyNotify) gst_structure_free);
}
const GstMetaInfo *
@@ -850,6 +853,64 @@ gst_buffer_add_video_region_of_interest_meta_id (GstBuffer * buffer,
return meta;
}
+/**
+ * gst_video_region_of_interest_meta_add_param:
+ * @meta: a #GstVideoRegionOfInterestMeta
+ * @s: (transfer full): a #GstStructure
+ *
+ * Attach element-specific parameters to @meta meant to be used by downstream
+ * elements which may handle this ROI.
+ * The name of @s is used to identify the element these parameters are meant for.
+ *
+ * This is typically used to tell encoders how they should encode this specific region.
+ * For example, a structure named "roi/x264enc" could be used to give the
+ * QP offsets this encoder should use when encoding the region described in @meta.
+ * Multiple parameters can be defined for the same meta so different encoders
+ * can be supported by cross platform applications).
+ *
+ * Since: 1.14
+ */
+void
+gst_video_region_of_interest_meta_add_param (GstVideoRegionOfInterestMeta *
+ meta, GstStructure * s)
+{
+ g_return_if_fail (meta);
+ g_return_if_fail (s);
+
+ meta->params = g_list_append (meta->params, s);
+}
+
+/**
+ * gst_video_region_of_interest_meta_get_param:
+ * @meta: a #GstVideoRegionOfInterestMeta
+ *
+ * Retrieve the parameter for @meta having @name as structure name,
+ * or %NULL if there is none.
+ *
+ * Returns: (transfer none) (nullable): a #GstStructure
+ *
+ * Since: 1.14
+ * @see_also: gst_video_region_of_interest_meta_add_param()
+ */
+GstStructure *
+gst_video_region_of_interest_meta_get_param (GstVideoRegionOfInterestMeta *
+ meta, const gchar * name)
+{
+ GList *l;
+
+ g_return_val_if_fail (meta, NULL);
+ g_return_val_if_fail (name, NULL);
+
+ for (l = meta->params; l; l = g_list_next (l)) {
+ GstStructure *s = l->data;
+
+ if (gst_structure_has_name (s, name))
+ return s;
+ }
+
+ return NULL;
+}
+
/* Time Code Meta implementation *******************************************/
GType
diff --git a/gst-libs/gst/video/gstvideometa.h b/gst-libs/gst/video/gstvideometa.h
index 477a29762..cb2ea1c82 100644
--- a/gst-libs/gst/video/gstvideometa.h
+++ b/gst-libs/gst/video/gstvideometa.h
@@ -281,6 +281,7 @@ gboolean gst_video_gl_texture_upload_meta_upload (GstVideoGLTextureUploadMe
* @y: y component of upper-left corner
* @w: bounding box width
* @h: bounding box height
+ * @params: list of #GstStructure containing element-specific params for downstream, see gst_video_region_of_interest_meta_add_params(). (Since: 1.14)
*
* Extra buffer metadata describing an image region of interest
*/
@@ -295,6 +296,8 @@ typedef struct {
guint y;
guint w;
guint h;
+
+ GList *params;
} GstVideoRegionOfInterestMeta;
GST_EXPORT
@@ -325,6 +328,13 @@ GstVideoRegionOfInterestMeta *gst_buffer_add_video_region_of_interest_meta_id (G
guint y,
guint w,
guint h);
+GST_EXPORT
+void gst_video_region_of_interest_meta_add_param (GstVideoRegionOfInterestMeta * meta,
+ GstStructure * s);
+
+GST_EXPORT
+GstStructure *gst_video_region_of_interest_meta_get_param (GstVideoRegionOfInterestMeta * meta,
+ const gchar * name);
/**
* GstVideoTimeCodeMeta: