Stack Exchange
Incompatible pad linking error in gstreamer 0.1
I am trying to pragmatically create the following chain with gstreamer-0.10.
gst-launch filesrc location=<file>.mkv ! decodebin ! ffenc_mpeg4 bitrate=5000000 ! rtpmp4vpay mtu=1400 pt=96 ssrc=0 timestamp-offset=0 seqnum-offset=0 send-config=true ! udpsink host=127.0.0.1 port=5000

Here is the code:
#include <gst/gst.h>

int
main (int   argc,
      char *argv[])
{
  GstElement* pipeline;
  GstElement* source;
  GstElement* decodebin;
  GstElement* encoder;
  GstElement* rtp;
  GstElement* udpsink;

  /* init */
  gst_init (&argc, &argv);

  /* create pipeline */
  pipeline = gst_pipeline_new ("my-pipeline");

  /* create elements */
  source = gst_element_factory_make ("filesrc", "source");
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);

  decodebin = gst_element_factory_make ("decodebin", "decoder");

  encoder = gst_element_factory_make ("ffenc_mpeg4", "encoder");
  g_object_set (G_OBJECT (encoder), "bitrate", "5000000", NULL);

  rtp = gst_element_factory_make ("rtpmp4vpay", "rtp");
  g_object_set (G_OBJECT (rtp), "mtu", "1400", NULL);
  g_object_set (G_OBJECT (rtp), "pt", 96, NULL);
  g_object_set (G_OBJECT (rtp), "ssrc", "0", NULL);
  g_object_set (G_OBJECT (rtp), "timestamp-offset", "0", NULL);
  g_object_set (G_OBJECT (rtp), "seqnum-offset", 0, NULL);
  g_object_set (G_OBJECT (rtp), "send-config", true, NULL); 

  udpsink = gst_element_factory_make ("udpsink", "udp");
  g_object_set (G_OBJECT (udpsink), "host", "127.0.0.1", NULL);
  g_object_set (G_OBJECT (udpsink), "port", 5000, NULL);

//  /* must add elements to pipeline before linking them */
  gst_bin_add_many (GST_BIN (pipeline), source, decodebin, encoder, rtp, udpsink, NULL);

  /* link */
  if (!gst_element_link_many (source, decodebin, encoder, rtp, udpsink, NULL)) {
    g_warning ("Failed to link elements!");
  }

}

Although this matches the gst-launch chain exactly, I get the following error in gst_element_link_many call.
0:00:03.025847872 28265       0x611400 INFO      GST_PLUGIN_LOADING gstplugin.c:859:gst_plugin_load_file: plugin "/usr/lib64/gstreamer-0.10/libgstudp.so" loaded
0:00:03.025912744 28265       0x611400 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:374:gst_element_factory_create: creating element "udpsink" named "udp"
0:00:03.026163748 28265       0x611400 INFO        GST_ELEMENT_PADS gstelement.c:728:gst_element_add_pad:<GstBaseSink@0x82b9e0> adding pad 'sink'
0:00:04.824498407 28265       0x611400 INFO        GST_ELEMENT_PADS gstutils.c:1698:gst_element_link_pads_full: trying to link element source:(any) to element decoder:(any)
0:00:04.824604374 28265       0x611400 INFO                GST_PADS gstutils.c:1032:gst_pad_check_link: trying to link source:src and decoder:sink
0:00:04.824676367 28265       0x611400 INFO                GST_PADS gstutils.c:1596:prepare_link_maybe_ghosting: source and decoder in same bin, no need for ghost pads
0:00:04.824725877 28265       0x611400 INFO                GST_PADS gstpad.c:1978:gst_pad_link_prepare: trying to link source:src and decoder:sink
0:00:04.824786544 28265       0x611400 INFO                GST_PADS gstpad.c:2161:gst_pad_link_full: linked source:src and decoder:sink, successful
0:00:04.824863468 28265       0x611400 INFO        GST_ELEMENT_PADS gstutils.c:1698:gst_element_link_pads_full: trying to link element decoder:(any) to element encoder:(any)
0:00:04.824989178 28265       0x611400 INFO        GST_ELEMENT_PADS gstelement.c:972:gst_element_get_static_pad: no such pad 'src%d' in element "decoder"
0:00:04.825051308 28265       0x611400 INFO        GST_ELEMENT_PADS gstutils.c:1216:gst_element_get_compatible_pad:<decoder> Could not find a compatible pad to link to encoder:sink

What am I doing wrong? Can't I use the decode bin like this programatically?

bin documentation and found that src of decoder is not always pad and is sometimes pad.The same can be observed by the log present. 
