Skip to content

Commit

Permalink
glbufferpool: provide a consistent API regardless of platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ystreet authored and tp-m committed Dec 9, 2017
1 parent c399908 commit ec8f3e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 11 additions & 12 deletions gst-libs/gst/gl/gstglbufferpool.c
Expand Up @@ -51,10 +51,8 @@ struct _GstGLBufferPoolPrivate
gint im_format;
GstVideoInfo info;
gboolean add_videometa;
#if GST_GL_HAVE_PLATFORM_EGL
gboolean want_eglimage;
GstBuffer *last_buffer;
#endif
};

static void gst_gl_buffer_pool_finalize (GObject * object);
Expand Down Expand Up @@ -129,6 +127,8 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
#if GST_GL_HAVE_PLATFORM_EGL
priv->want_eglimage = (priv->allocator
&& g_strcmp0 (priv->allocator->mem_type, GST_EGL_IMAGE_MEMORY_TYPE) == 0);
#else
priv->want_eglimage = FALSE;
#endif

if (reset) {
Expand Down Expand Up @@ -228,6 +228,7 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
GST_WARNING_OBJECT (pool, "Could not create GL Memory");
return GST_FLOW_ERROR;
}

#if GST_GL_HAVE_PLATFORM_EGL
egl_image_mem_create_failed:
{
Expand All @@ -243,17 +244,14 @@ gst_gl_buffer_pool_acquire_buffer (GstBufferPool * bpool,
GstBuffer ** buffer, GstBufferPoolAcquireParams * params)
{
GstFlowReturn ret = GST_FLOW_OK;
#if GST_GL_HAVE_PLATFORM_EGL
GstGLBufferPool *glpool = NULL;
#endif

ret =
GST_BUFFER_POOL_CLASS
(gst_gl_buffer_pool_parent_class)->acquire_buffer (bpool, buffer, params);
if (ret != GST_FLOW_OK || !*buffer)
return ret;

#if GST_GL_HAVE_PLATFORM_EGL
glpool = GST_GL_BUFFER_POOL (bpool);

/* XXX: Don't return the memory we just rendered, glEGLImageTargetTexture2DOES()
Expand All @@ -270,7 +268,6 @@ gst_gl_buffer_pool_acquire_buffer (GstBufferPool * bpool,
gst_object_replace ((GstObject **) & oldbuf->pool, (GstObject *) glpool);
gst_buffer_unref (oldbuf);
}
#endif

return ret;
}
Expand All @@ -294,7 +291,14 @@ gst_gl_buffer_pool_new (GstGLContext * context)
return GST_BUFFER_POOL_CAST (pool);
}

#if GST_GL_HAVE_PLATFORM_EGL
/**
* gst_gl_buffer_pool_replace_last_buffer:
* @pool: a #GstGLBufferPool
* @buffer: a #GstBuffer
*
* Set @pool<-- -->s last buffer to @buffer for #GstGLPlatform<-- -->s that
* require it.
*/
void
gst_gl_buffer_pool_replace_last_buffer (GstGLBufferPool * pool,
GstBuffer * buffer)
Expand All @@ -304,7 +308,6 @@ gst_gl_buffer_pool_replace_last_buffer (GstGLBufferPool * pool,

gst_buffer_replace (&pool->priv->last_buffer, buffer);
}
#endif

static void
gst_gl_buffer_pool_class_init (GstGLBufferPoolClass * klass)
Expand Down Expand Up @@ -335,10 +338,8 @@ gst_gl_buffer_pool_init (GstGLBufferPool * pool)
priv->caps = NULL;
priv->im_format = GST_VIDEO_FORMAT_UNKNOWN;
priv->add_videometa = TRUE;
#if GST_GL_HAVE_PLATFORM_EGL
priv->want_eglimage = FALSE;
priv->last_buffer = FALSE;
#endif

gst_video_info_init (&priv->info);
gst_allocation_params_init (&priv->params);
Expand All @@ -352,9 +353,7 @@ gst_gl_buffer_pool_finalize (GObject * object)

GST_LOG_OBJECT (pool, "finalize GL buffer pool %p", pool);

#if GST_GL_HAVE_PLATFORM_EGL
gst_buffer_replace (&pool->priv->last_buffer, NULL);
#endif

if (priv->caps)
gst_caps_unref (priv->caps);
Expand Down
2 changes: 0 additions & 2 deletions gst-libs/gst/gl/gstglbufferpool.h
Expand Up @@ -66,10 +66,8 @@ struct _GstGLBufferPoolClass
};

GstBufferPool *gst_gl_buffer_pool_new (GstGLContext * context);
#if GST_GL_HAVE_PLATFORM_EGL
void gst_gl_buffer_pool_replace_last_buffer (GstGLBufferPool * pool,
GstBuffer * buffer);
#endif

G_END_DECLS

Expand Down

0 comments on commit ec8f3e5

Please sign in to comment.