glupload: Check that caps contain desired caps features

Use 'contains' checks instead of equality checks on caps features
to allow for uploading when caps also contain GstVideoOverlayComposition
meta.

https://bugzilla.gnome.org/show_bug.cgi?id=752912
This commit is contained in:
Jan Schmidt 2015-07-27 16:36:40 +10:00
parent 01816b861f
commit 45f8a27211

View file

@ -153,42 +153,17 @@ _gl_memory_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
GstCaps * out_caps) GstCaps * out_caps)
{ {
struct GLMemoryUpload *upload = impl; struct GLMemoryUpload *upload = impl;
GstCapsFeatures *features, *gl_features, *gl_overlay_features, GstCapsFeatures *features;
*system_memory_overlay_features;
gboolean ret = TRUE;
int i; int i;
gl_features =
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
features = gst_caps_get_features (out_caps, 0); features = gst_caps_get_features (out_caps, 0);
if (!gst_caps_features_is_equal (features, gl_features)) if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
ret = FALSE; return FALSE;
gl_overlay_features =
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY ","
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
if (gst_caps_features_is_equal (features, gl_overlay_features))
ret = TRUE;
features = gst_caps_get_features (in_caps, 0); features = gst_caps_get_features (in_caps, 0);
if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
system_memory_overlay_features = && !gst_caps_features_contains (features,
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY "," GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY))
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION);
if (!gst_caps_features_is_equal (features, gl_features)
&& !gst_caps_features_is_equal (features, gl_overlay_features)
&& !gst_caps_features_is_equal (features,
GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY)
&& !gst_caps_features_is_equal (features, system_memory_overlay_features))
ret = FALSE;
gst_caps_features_free (gl_features);
gst_caps_features_free (gl_overlay_features);
gst_caps_features_free (system_memory_overlay_features);
if (!ret)
return FALSE; return FALSE;
if (buffer) { if (buffer) {
@ -375,26 +350,18 @@ _egl_image_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
GstCaps * out_caps) GstCaps * out_caps)
{ {
struct EGLImageUpload *image = impl; struct EGLImageUpload *image = impl;
GstCapsFeatures *features, *gl_features; GstCapsFeatures *features;
gboolean ret = TRUE; gboolean ret = TRUE;
int i; int i;
gl_features =
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_EGL_IMAGE);
features = gst_caps_get_features (in_caps, 0); features = gst_caps_get_features (in_caps, 0);
if (!gst_caps_features_is_equal (features, gl_features)) if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_EGL_IMAGE))
ret = FALSE; ret = FALSE;
gst_caps_features_free (gl_features);
gl_features =
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
features = gst_caps_get_features (out_caps, 0); features = gst_caps_get_features (out_caps, 0);
if (!gst_caps_features_is_equal (features, gl_features)) if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
ret = FALSE; ret = FALSE;
gst_caps_features_free (gl_features);
if (!ret) if (!ret)
return FALSE; return FALSE;
@ -559,28 +526,20 @@ _upload_meta_upload_accept (gpointer impl, GstBuffer * buffer,
GstCaps * in_caps, GstCaps * out_caps) GstCaps * in_caps, GstCaps * out_caps)
{ {
struct GLUploadMeta *upload = impl; struct GLUploadMeta *upload = impl;
GstCapsFeatures *features, *gl_features; GstCapsFeatures *features;
GstVideoGLTextureUploadMeta *meta; GstVideoGLTextureUploadMeta *meta;
gboolean ret = TRUE; gboolean ret = TRUE;
features = gst_caps_get_features (in_caps, 0); features = gst_caps_get_features (in_caps, 0);
gl_features =
gst_caps_features_from_string
(GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META);
if (!gst_caps_features_is_equal (features, gl_features)) if (!gst_caps_features_contains (features,
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META))
ret = FALSE; ret = FALSE;
gst_caps_features_free (gl_features);
gl_features =
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
features = gst_caps_get_features (out_caps, 0); features = gst_caps_get_features (out_caps, 0);
if (!gst_caps_features_is_equal (features, gl_features)) if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
ret = FALSE; ret = FALSE;
gst_caps_features_free (gl_features);
if (!ret) if (!ret)
return ret; return ret;
@ -773,19 +732,11 @@ _raw_data_upload_accept (gpointer impl, GstBuffer * buffer, GstCaps * in_caps,
GstCaps * out_caps) GstCaps * out_caps)
{ {
struct RawUpload *raw = impl; struct RawUpload *raw = impl;
GstCapsFeatures *features, *gl_features; GstCapsFeatures *features;
gboolean ret = TRUE;
gl_features =
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
features = gst_caps_get_features (out_caps, 0); features = gst_caps_get_features (out_caps, 0);
if (!gst_caps_features_is_equal (features, gl_features)) if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
ret = FALSE; return FALSE;
gst_caps_features_free (gl_features);
if (!ret)
return ret;
if (buffer) { if (buffer) {
if (!gst_video_frame_map (&raw->in_frame, &raw->upload->priv->in_info, if (!gst_video_frame_map (&raw->in_frame, &raw->upload->priv->in_info,
@ -1002,8 +953,11 @@ gst_gl_upload_transform_caps (GstGLContext * context, GstPadDirection direction,
tmp = gst_gl_overlay_compositor_add_caps (tmp); tmp = gst_gl_overlay_compositor_add_caps (tmp);
if (filter) { if (filter) {
result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST); result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
GST_LOG ("Filtering transformed caps %" GST_PTR_FORMAT " against filter %"
GST_PTR_FORMAT " yields %" GST_PTR_FORMAT, tmp, filter, result);
gst_caps_unref (tmp); gst_caps_unref (tmp);
} else { } else {
result = tmp; result = tmp;