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	9 Aug 2007 18:48:42 -0000
@@ -54,6 +54,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
         "mode = (string) { \"20\", \"30\" }")
     );
 
+
+static GstCaps *gst_rtpilbcpay_getcaps (GstPad *pad);
 static gboolean gst_rtpilbcpay_setcaps (GstBaseRTPPayload * payload,
     GstCaps * caps);
 
@@ -106,6 +108,9 @@ gst_rtpilbcpay_init (GstRTPILBCPay * rtp
 
   rtpilbcpay->mode = -1;
 
+  gst_pad_set_getcaps_function (basertppayload->sinkpad,
+				gst_rtpilbcpay_getcaps);
+
   /* tell basertpaudiopayload that this is a frame based codec */
   gst_base_rtp_audio_payload_set_frame_based (basertpaudiopayload);
 }
@@ -173,6 +178,47 @@ mode_changed:
   }
 }
 
+static GstCaps *
+gst_rtpilbcpay_getcaps (GstPad *pad)
+{
+  GstBaseRTPPayload *rtppayload = gst_pad_get_parent_element (pad);
+  GstCaps *peercaps;
+  GstCaps *caps = NULL;
+  GstStructure *structure;
+  gchar *mode_str;
+  gint mode = 0;
+
+  peercaps = gst_pad_peer_get_caps (rtppayload->srcpad);
+  
+  if (peercaps) {
+    structure = gst_caps_get_structure (peercaps, 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)
+	mode = 0;
+    }
+
+    if (mode) {
+      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(peercaps);
+  }
+
+  if (!mode) {
+    caps = gst_caps_ref (gst_pad_get_pad_template_caps (pad));
+  }
+ 
+
+
+  return caps;
+}
+
 gboolean
 gst_rtp_ilbc_pay_plugin_init (GstPlugin * plugin)
 {
