From db74901b6ab2fade4f3247cf81660b95f1a67b3e Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Fri, 4 May 2012 15:20:47 -0300 Subject: [PATCH] jpegenc: do not proxy our filter caps downstream on caps queries Downstream likely won't accept video/x-raw and the caps query will return EMPTY caps. Instead, create a copy of the caps that has all structure names replaced by 'image/jpeg' Simple pipeline that shows the problem: gst-launch-1.0 videotestsrc num-buffers=1 ! "video/x-raw, \ width=(int)640, height=(int)480" ! videoscale ! jpegenc ! \ "image/jpeg, width=(int)800, height=(int)600" ! filesink \ location=/tmp/image.jpg --- ext/jpeg/gstjpegenc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index 0644aa5b7b..0e9ef275b5 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -304,14 +304,29 @@ gst_jpegenc_getcaps (GstPad * pad, GstCaps * filter) { GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad)); GstCaps *caps, *othercaps; + GstCaps *otherfilter; GstCaps *templ; gint i, j; GstStructure *structure = NULL; /* we want to proxy properties like width, height and framerate from the other end of the element */ + if (filter) { + otherfilter = gst_caps_new_empty (); + for (i = 0; i < gst_caps_get_size (filter); i++) { + GstStructure *s = gst_structure_copy (gst_caps_get_structure (filter, i)); + + gst_structure_set_name (s, "image/jpeg"); + + gst_caps_append_structure (otherfilter, s); + } + } else { + otherfilter = NULL; + } + othercaps = gst_pad_peer_query_caps (jpegenc->srcpad, otherfilter); + if (otherfilter) + gst_caps_unref (otherfilter); - othercaps = gst_pad_peer_query_caps (jpegenc->srcpad, filter); templ = gst_pad_get_pad_template_caps (pad); if (othercaps == NULL || gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps)) {