[Cogl] [PATCH 07/13] cogl-gst: video-sink: use intended GStreamer API for data/stride/etc...
Lionel Landwerlin
llandwerlin at gmail.com
Mon Dec 9 03:17:54 PST 2013
Based on a patch for ClutterGst from Matthieu Bouron <matthieu.bouron at collabora.com>
---
cogl-gst/cogl-gst-video-sink.c | 115 +++++++++++++++++++++++++++--------------
1 file changed, 76 insertions(+), 39 deletions(-)
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index f2f7ef6..5bbb266 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -163,7 +163,7 @@ struct _CoglGstVideoSinkPrivate
{
CoglContext *ctx;
CoglPipeline *pipeline;
- CoglTexture *frame[3];
+ CoglTexture *frame[MAX_LAYERS];
CoglBool frame_dirty;
CoglGstVideoFormat format;
CoglBool bgr;
@@ -547,11 +547,13 @@ cogl_gst_rgb24_upload (CoglGstVideoSink *sink,
clear_frame_textures (sink);
- priv->frame[0] = video_texture_new_from_data (priv->ctx, priv->info.width,
- priv->info.height,
+ priv->frame[0] = video_texture_new_from_data (priv->ctx,
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 0),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 0),
format, format,
- priv->info.stride[0],
- frame.data[0], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),
+ NULL);
gst_video_frame_unmap (&frame);
@@ -594,11 +596,13 @@ cogl_gst_rgb32_upload (CoglGstVideoSink *sink,
clear_frame_textures (sink);
- priv->frame[0] = video_texture_new_from_data (priv->ctx, priv->info.width,
- priv->info.height,
+ priv->frame[0] = video_texture_new_from_data (priv->ctx,
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 0),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 0),
format, format,
- priv->info.stride[0],
- frame.data[0], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),
+ NULL);
gst_video_frame_unmap (&frame);
@@ -628,8 +632,8 @@ cogl_gst_yv12_upload (CoglGstVideoSink *sink,
GstBuffer *buffer)
{
CoglGstVideoSinkPrivate *priv = sink->priv;
- GstVideoFrame frame;
CoglPixelFormat format = COGL_PIXEL_FORMAT_G_8;
+ GstVideoFrame frame;
if (!gst_video_frame_map (&frame, &priv->info, buffer, GST_MAP_READ))
goto map_fail;
@@ -638,24 +642,30 @@ cogl_gst_yv12_upload (CoglGstVideoSink *sink,
priv->frame[0] =
video_texture_new_from_data (priv->ctx,
- GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 0),
- GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 0),
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 0),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 0),
format, format,
- priv->info.stride[0], frame.data[0], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),
+ NULL);
priv->frame[2] =
video_texture_new_from_data (priv->ctx,
- GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 1),
- GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 1),
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 1),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 1),
format, format,
- priv->info.stride[1], frame.data[1], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 1),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 1),
+ NULL);
priv->frame[1] =
video_texture_new_from_data (priv->ctx,
- GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 2),
- GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 2),
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 2),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 2),
format, format,
- priv->info.stride[2], frame.data[2], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 2),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 2),
+ NULL);
gst_video_frame_unmap (&frame);
@@ -673,8 +683,8 @@ cogl_gst_i420_upload (CoglGstVideoSink *sink,
GstBuffer *buffer)
{
CoglGstVideoSinkPrivate *priv = sink->priv;
- GstVideoFrame frame;
CoglPixelFormat format = COGL_PIXEL_FORMAT_G_8;
+ GstVideoFrame frame;
if (!gst_video_frame_map (&frame, &priv->info, buffer, GST_MAP_READ))
goto map_fail;
@@ -683,24 +693,30 @@ cogl_gst_i420_upload (CoglGstVideoSink *sink,
priv->frame[0] =
video_texture_new_from_data (priv->ctx,
- GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 0),
- GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 0),
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 0),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 0),
format, format,
- priv->info.stride[0], frame.data[0], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),
+ NULL);
priv->frame[1] =
video_texture_new_from_data (priv->ctx,
- GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 1),
- GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 1),
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 1),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 1),
format, format,
- priv->info.stride[1], frame.data[1], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 1),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 1),
+ NULL);
priv->frame[2] =
video_texture_new_from_data (priv->ctx,
- GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 2),
- GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 2),
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 2),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 2),
format, format,
- priv->info.stride[2], frame.data[2], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 2),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 2),
+ NULL);
gst_video_frame_unmap (&frame);
@@ -836,11 +852,13 @@ cogl_gst_ayuv_upload (CoglGstVideoSink *sink,
clear_frame_textures (sink);
- priv->frame[0] = video_texture_new_from_data (priv->ctx, priv->info.width,
- priv->info.height,
+ priv->frame[0] = video_texture_new_from_data (priv->ctx,
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 0),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 0),
format, format,
- priv->info.stride[0],
- frame.data[0], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),
+ NULL);
gst_video_frame_unmap (&frame);
@@ -931,17 +949,21 @@ cogl_gst_nv12_upload (CoglGstVideoSink *sink,
priv->frame[0] =
video_texture_new_from_data (priv->ctx,
- GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 0),
- GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 0),
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 0),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 0),
COGL_PIXEL_FORMAT_G_8, COGL_PIXEL_FORMAT_G_8,
- priv->info.stride[0], frame.data[0], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),
+ NULL);
priv->frame[1] =
video_texture_new_from_data (priv->ctx,
- GST_VIDEO_INFO_COMP_WIDTH (&priv->info, 1),
- GST_VIDEO_INFO_COMP_HEIGHT (&priv->info, 1),
+ GST_VIDEO_FRAME_COMP_WIDTH (&frame, 1),
+ GST_VIDEO_FRAME_COMP_HEIGHT (&frame, 1),
COGL_PIXEL_FORMAT_RGB_565, COGL_PIXEL_FORMAT_RGB_565,
- priv->info.stride[1], frame.data[1], NULL);
+ GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 1),
+ GST_VIDEO_FRAME_PLANE_DATA (&frame, 1),
+ NULL);
gst_video_frame_unmap (&frame);
@@ -1452,6 +1474,20 @@ cogl_gst_video_sink_stop (GstBaseSink *base_sink)
return TRUE;
}
+static gboolean
+cogl_gst_video_sink_propose_allocation (GstBaseSink *base_sink, GstQuery *query)
+{
+ gboolean need_pool = FALSE;
+ GstCaps *caps = NULL;
+
+ gst_query_parse_allocation (query, &caps, &need_pool);
+
+ gst_query_add_allocation_meta (query,
+ GST_VIDEO_META_API_TYPE, NULL);
+
+ return TRUE;
+}
+
static void
cogl_gst_video_sink_class_init (CoglGstVideoSinkClass *klass)
{
@@ -1486,6 +1522,7 @@ cogl_gst_video_sink_class_init (CoglGstVideoSinkClass *klass)
gb_class->stop = cogl_gst_video_sink_stop;
gb_class->set_caps = cogl_gst_video_sink_set_caps;
gb_class->get_caps = cogl_gst_video_sink_get_caps;
+ gb_class->propose_allocation = cogl_gst_video_sink_propose_allocation;
pspec = g_param_spec_int ("update-priority",
"Update Priority",
--
1.8.5
More information about the Cogl
mailing list