Index: gst/rtp/gstrtpilbcpay.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/gst/rtp/gstrtpilbcpay.c,v
retrieving revision 1.7
diff -u -p -r1.7 gstrtpilbcpay.c
--- gst/rtp/gstrtpilbcpay.c	8 Aug 2007 10:54:50 -0000	1.7
+++ gst/rtp/gstrtpilbcpay.c	13 Aug 2007 16:50:16 -0000
@@ -54,6 +54,9 @@ GST_STATIC_PAD_TEMPLATE ("src",
         "mode = (string) { \"20\", \"30\" }")
     );
 
+
+static GstCaps *gst_rtpilbcpay_getcaps (GstBaseRTPPayload * payload,
+                                       GstPad *pad);
 static gboolean gst_rtpilbcpay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 
@@ -86,6 +89,7 @@ gst_rtpilbcpay_class_init (GstRTPILBCPay
   parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD);
 
   gstbasertppayload_class->set_caps = gst_rtpilbcpay_setcaps;
+  gstbasertppayload_class->get_caps = gst_rtpilbcpay_getcaps;
 
   GST_DEBUG_CATEGORY_INIT (rtpilbcpay_debug, "rtpilbcpay", 0,
       "iLBC audio RTP payloader");
@@ -173,6 +177,43 @@ mode_changed:
   }
 }
 
+static GstCaps *
+gst_rtpilbcpay_getcaps (GstBaseRTPPayload *rtppayload, GstPad *pad)
+{
+  GstCaps *otherpadcaps = gst_pad_get_allowed_caps(rtppayload->srcpad);
+  GstCaps *caps = NULL;
+
+  if (otherpadcaps) {
+    GstStructure *structure;
+    gchar *mode_str;
+    gint mode;
+
+    if (gst_caps_is_empty(otherpadcaps)) {
+      return otherpadcaps;
+    }
+
+    structure = gst_caps_get_structure (otherpadcaps, 0);
+
+    /* parse mode, if we can */
+    mode_str = gst_structure_get_string(structure, "mode");
+    if (mode_str) {
+      mode = strtol (mode_str, NULL, 10);
+      if (mode == 20 || mode == 30) {
+       caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
+       structure = gst_caps_get_structure (caps, 0);
+       gst_structure_set(structure, "mode", G_TYPE_INT, mode, NULL);
+      }
+    }
+    gst_caps_unref(otherpadcaps);
+  }
+
+  if (!caps) {
+    caps = gst_caps_ref (gst_pad_get_pad_template_caps (pad));
+  }
+
+  return caps;
+}
+
 gboolean
 gst_rtp_ilbc_pay_plugin_init (GstPlugin * plugin)
 {
