diff options
author | Julien Isorce <julien.isorce@collabora.co.uk> | 2014-05-13 13:30:47 +0100 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2014-05-13 12:43:42 -0400 |
commit | e46de48f104e6a48680d992b9425826b7c3f05f7 (patch) | |
tree | 244c212ba3d99c9294862f72c883bf3417ba850b | |
parent | 1e90a68aec966d6a56e839db1cf759716b5583d8 (diff) | |
download | gstreamer-plugins-bad-e46de48f104e6a48680d992b9425826b7c3f05f7.tar.gz |
glfilter: rewrite transform_caps to preserve caps fields
https://bugzilla.gnome.org/show_bug.cgi?id=729861
-rw-r--r-- | gst-libs/gst/gl/gstglfilter.c | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index 14f5f9e78..e567f0337 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -660,31 +660,68 @@ done: return othercaps; } + +static GstCaps * +gst_gl_filter_set_caps_features (const GstCaps * caps, + const gchar * feature_name) +{ + GstCaps *tmp = gst_caps_copy (caps); + guint n = gst_caps_get_size (tmp); + guint i = 0; + + for (i = 0; i < n; i++) { + GstCapsFeatures *features = gst_caps_get_features (tmp, i); + if (features) { + guint n_f = gst_caps_features_get_size (features); + guint j = 0; + for (j = 0; j < n_f; j++) { + gst_caps_features_remove_id (features, + gst_caps_features_get_nth_id (features, j)); + } + } + + gst_caps_features_add (features, feature_name); + gst_caps_set_simple (tmp, "format", G_TYPE_STRING, "RGBA", NULL); + } + + return tmp; +} + static GstCaps * gst_gl_filter_transform_caps (GstBaseTransform * bt, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { - GstCaps *newcaps, *result; - - if (direction == GST_PAD_SINK) - newcaps = - gst_static_pad_template_get_caps (&gst_gl_filter_src_pad_template); - else if (direction == GST_PAD_SRC) - newcaps = - gst_static_pad_template_get_caps (&gst_gl_filter_sink_pad_template); - else - newcaps = gst_caps_new_any (); + GstCaps *tmp = NULL; + GstCaps *result = NULL; + + if (direction == GST_PAD_SINK) { + GstCaps *glcaps = gst_gl_filter_set_caps_features (caps, + GST_CAPS_FEATURE_MEMORY_GL_MEMORY); + GstCaps *eglcaps = gst_gl_filter_set_caps_features (caps, + GST_CAPS_FEATURE_MEMORY_EGL_IMAGE); + GstCaps *uploadcaps = gst_gl_filter_set_caps_features (caps, + GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META); + + tmp = gst_caps_new_empty (); + + tmp = gst_caps_merge (tmp, glcaps); + tmp = gst_caps_merge (tmp, eglcaps); + tmp = gst_caps_merge (tmp, uploadcaps); + tmp = gst_caps_merge (tmp, gst_caps_copy (caps)); + } else { + tmp = gst_caps_copy (caps); + } if (filter) { - result = - gst_caps_intersect_full (filter, newcaps, GST_CAPS_INTERSECT_FIRST); - gst_caps_unref (newcaps); - newcaps = result; + result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (tmp); + } else { + result = tmp; } - GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, newcaps); + GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, result); - return newcaps; + return result; } |