vorbisenc: fix getcaps ignoring filter caps
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 10 Nov 2011 14:37:02 +0000 (14:37 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 10 Nov 2011 14:38:09 +0000 (14:38 +0000)
ext/vorbis/gstvorbisenc.c

index 8460b76..ab309af 100644 (file)
@@ -302,11 +302,21 @@ static GstCaps *
 gst_vorbis_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter)
 {
   GstVorbisEnc *vorbisenc = GST_VORBISENC (enc);
+  GstCaps *caps;
 
   if (vorbisenc->sinkcaps == NULL)
     vorbisenc->sinkcaps = gst_vorbis_enc_generate_sink_caps ();
 
-  return gst_audio_encoder_proxy_getcaps (enc, vorbisenc->sinkcaps);
+  if (filter) {
+    GstCaps *int_caps = gst_caps_intersect_full (filter, vorbisenc->sinkcaps,
+        GST_CAPS_INTERSECT_FIRST);
+    caps = gst_audio_encoder_proxy_getcaps (enc, int_caps);
+    gst_caps_unref (int_caps);
+  } else {
+    caps = gst_audio_encoder_proxy_getcaps (enc, vorbisenc->sinkcaps);
+  }
+
+  return caps;
 }
 
 static gint64