x11: handle new bufferpool metadata api
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 20 Jun 2011 11:28:12 +0000 (13:28 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 20 Jun 2011 11:28:12 +0000 (13:28 +0200)
Provide a method to list the supported metadata apis.
Activate the video metadata on buffers when a downstream element configured the
bufferpool to support that api.

sys/ximage/ximagepool.c
sys/xvimage/xvimagepool.c

index 152a02c..21068ca 100644 (file)
@@ -440,6 +440,14 @@ struct _GstXImageBufferPoolPrivate
 G_DEFINE_TYPE (GstXImageBufferPool, gst_ximage_buffer_pool,
     GST_TYPE_BUFFER_POOL);
 
+static const gchar **
+ximage_buffer_pool_get_metas (GstBufferPool * pool)
+{
+  static const gchar *metas[] = { "GstMetaVideo", NULL };
+
+  return metas;
+}
+
 static gboolean
 ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
 {
@@ -467,8 +475,10 @@ ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
   if (priv->caps)
     gst_caps_unref (priv->caps);
   priv->caps = gst_caps_copy (caps);
-  /* FIXME, configure based on config of the bufferpool */
-  priv->add_metavideo = FALSE;
+
+  /* check for the configured metadata */
+  priv->add_metavideo =
+      gst_buffer_pool_config_has_meta (config, GST_META_API_VIDEO);
 
   return TRUE;
 
@@ -557,6 +567,7 @@ gst_ximage_buffer_pool_class_init (GstXImageBufferPoolClass * klass)
 
   gobject_class->finalize = gst_ximage_buffer_pool_finalize;
 
+  gstbufferpool_class->get_metas = ximage_buffer_pool_get_metas;
   gstbufferpool_class->set_config = ximage_buffer_pool_set_config;
   gstbufferpool_class->alloc_buffer = ximage_buffer_pool_alloc;
   gstbufferpool_class->free_buffer = ximage_buffer_pool_free;
index ed7e149..40f294c 100644 (file)
@@ -473,6 +473,14 @@ struct _GstXvImageBufferPoolPrivate
 G_DEFINE_TYPE (GstXvImageBufferPool, gst_xvimage_buffer_pool,
     GST_TYPE_BUFFER_POOL);
 
+static const gchar **
+xvimage_buffer_pool_get_metas (GstBufferPool * pool)
+{
+  static const gchar *metas[] = { "GstMetaVideo", NULL };
+
+  return metas;
+}
+
 static gboolean
 xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
 {
@@ -502,8 +510,11 @@ xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
   priv->caps = gst_caps_copy (caps);
   priv->im_format =
       gst_xvimagesink_get_format_from_caps (xvpool->sink, (GstCaps *) caps);
-  /* FIXME, enable metadata based on config of the pool */
-  priv->add_metavideo = FALSE;
+
+  /* enable metadata based on config of the pool */
+  priv->add_metavideo =
+      gst_buffer_pool_config_has_meta (config, GST_META_API_VIDEO);
+
   if (priv->im_format == -1)
     goto unknown_format;
 
@@ -605,6 +616,7 @@ gst_xvimage_buffer_pool_class_init (GstXvImageBufferPoolClass * klass)
 
   gobject_class->finalize = gst_xvimage_buffer_pool_finalize;
 
+  gstbufferpool_class->get_metas = xvimage_buffer_pool_get_metas;
   gstbufferpool_class->set_config = xvimage_buffer_pool_set_config;
   gstbufferpool_class->alloc_buffer = xvimage_buffer_pool_alloc;
   gstbufferpool_class->free_buffer = xvimage_buffer_pool_free;