/* This function handles GstBuffer creation */ static GstFlowReturn gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, GstBufferPoolAcquireParams * params) { GstGLMemoryAllocator *alloc; GstGLBufferPool *glpool = GST_GL_BUFFER_POOL_CAST (pool); GstGLBufferPoolPrivate *priv = glpool->priv; GstBuffer *buf; if (!(buf = gst_buffer_new ())) { goto no_buffer; } #if GST_GL_HAVE_PLATFORM_EGL if (priv->want_eglimage) { /* alloc and append memories, also add video_meta and * texture_upload_meta */ if (!gst_egl_image_memory_setup_buffer (glpool->context, priv->gl_params->v_info, buf)) goto egl_image_mem_create_failed; *buffer = buf; return GST_FLOW_OK; } #endif alloc = GST_GL_MEMORY_ALLOCATOR (priv->allocator); if (!gst_gl_memory_setup_buffer (alloc, buf, priv->gl_params)) goto mem_create_failed; if (priv->add_glsyncmeta) gst_buffer_add_gl_sync_meta (glpool->context, buf); *buffer = buf; return GST_FLOW_OK; /* ERROR */ no_buffer: { GST_WARNING_OBJECT (pool, "can't create image"); return GST_FLOW_ERROR; } mem_create_failed: { GST_WARNING_OBJECT (pool, "Could not create GL Memory"); return GST_FLOW_ERROR; } #if GST_GL_HAVE_PLATFORM_EGL egl_image_mem_create_failed: { GST_WARNING_OBJECT (pool, "Could not create EGLImage Memory"); return GST_FLOW_ERROR; } #endif }
/* This function handles GstBuffer creation */ static GstFlowReturn gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, GstBufferPoolAcquireParams * params) { GstGLMemoryAllocator *alloc; GstGLBufferPool *glpool = GST_GL_BUFFER_POOL_CAST (pool); GstGLBufferPoolPrivate *priv = glpool->priv; GstBuffer *buf; if (!(buf = gst_buffer_new ())) { goto no_buffer; } alloc = GST_GL_MEMORY_ALLOCATOR (priv->allocator); if (!gst_gl_memory_setup_buffer (alloc, buf, priv->gl_params, NULL, NULL, 0)) goto mem_create_failed; if (priv->add_glsyncmeta) gst_buffer_add_gl_sync_meta (glpool->context, buf); *buffer = buf; return GST_FLOW_OK; /* ERROR */ no_buffer: { GST_WARNING_OBJECT (pool, "can't create image"); return GST_FLOW_ERROR; } mem_create_failed: { GST_WARNING_OBJECT (pool, "Could not create GL Memory"); return GST_FLOW_ERROR; } }