- peercaps = gst_pad_peer_get_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (payload));
- if (!peercaps)
- return
- gst_caps_copy (gst_pad_get_pad_template_caps
- (GST_BASE_RTP_PAYLOAD_SINKPAD (payload)));
+ peercaps =
+ gst_pad_peer_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), NULL);
+
+ /* if we're just outputting to udpsink or fakesink or so, we should also
+ * accept any input compatible with our sink template caps */
+ if (!peercaps || gst_caps_is_any (peercaps)) {
+ if (peercaps)
+ gst_caps_unref (peercaps);
+ caps =
+ gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SINKPAD (payload));
+ goto done;
+ }
+
+ /* We basically need to differentiate two use-cases here: One where there's
+ * a capsfilter after the payloader with caps created from an SDP; in this
+ * case the filter caps are fixed and we want to signal to an encoder what
+ * we want it to produce. The second case is simply payloader ! depayloader
+ * where we are dealing with the depayloader's template caps. In this case
+ * we should accept any input compatible with our sink template caps. */
+ if (!gst_caps_is_fixed (peercaps)) {
+ gst_caps_unref (peercaps);
+ caps =
+ gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SINKPAD (payload));
+ goto done;
+ }