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
This commit is contained in:
Thiago Santos 2012-05-04 15:20:47 -03:00
parent a56361623c
commit db74901b6a

View file

@ -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)) {