glupload: Only offer custom allocator with caps features

To use GLMemory and EGLImage allocators, one need to know the
libgstgl API. This is only expected if the associated caps features
have been negotiated. Generic element that otherwise receive those
allocators may fail, resulting in broken pieline. We don't want to
force all generic element to check if the allocator is a custom
allocator or a normal allocator (which implement the _alloc method).

https://bugzilla.gnome.org/show_bug.cgi?id=758877
This commit is contained in:
Nicolas Dufresne 2015-12-01 18:09:25 -05:00
parent 2ab188bf29
commit d84d1708b7

View file

@ -209,16 +209,24 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
GstQuery * query)
{
struct GLMemoryUpload *upload = impl;
GstAllocationParams params;
GstAllocator *allocator;
GstBufferPool *pool = NULL;
guint n_pools, i;
GstCaps *caps;
GstCapsFeatures *features;
gst_allocation_params_init (&params);
gst_query_parse_allocation (query, &caps, NULL);
features = gst_caps_get_features (caps, 0);
allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR);
gst_query_add_allocation_param (query, allocator, &params);
gst_object_unref (allocator);
/* Only offer our custom allocator if that type of memory was negotiated. */
if (gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)) {
GstAllocator *allocator;
GstAllocationParams params;
gst_allocation_params_init (&params);
allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR);
gst_query_add_allocation_param (query, allocator, &params);
gst_object_unref (allocator);
}
n_pools = gst_query_get_n_allocation_pools (query);
for (i = 0; i < n_pools; i++) {
@ -232,10 +240,8 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
if (!pool) {
GstStructure *config;
GstVideoInfo info;
GstCaps *caps;
gsize size;
gst_query_parse_allocation (query, &caps, NULL);
if (!gst_video_info_from_caps (&info, caps))
goto invalid_caps;
@ -424,13 +430,22 @@ _egl_image_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
GstQuery * query)
{
struct EGLImageUpload *image = impl;
GstAllocationParams params;
GstAllocator *allocator;
GstCaps *caps;
GstCapsFeatures *features;
gst_allocation_params_init (&params);
gst_query_parse_allocation (query, &caps, NULL);
features = gst_caps_get_features (caps, 0);
if (gst_gl_context_check_feature (image->upload->context,
/* Only offer our custom allocator if that type of memory was negotiated. */
if (gst_caps_features_contains (features,
GST_CAPS_FEATURE_MEMORY_EGL_IMAGE) &&
gst_gl_context_check_feature (image->upload->context,
"EGL_KHR_image_base")) {
GstAllocationParams params;
GstAllocator *allocator;
gst_allocation_params_init (&params);
allocator = gst_allocator_find (GST_EGL_IMAGE_MEMORY_TYPE);
gst_query_add_allocation_param (query, allocator, &params);
gst_object_unref (allocator);