#include <gst/gst.h>
#include <unistd.h>

gpointer
thread(gpointer data)
{
  GstElement *p = data;
  GstElement *r2 = gst_bin_get_by_name(GST_BIN(p), "r2");

  sleep(5);

  gst_bin_remove(GST_BIN(p), r2);
  gst_object_unref(r2);
}

int main (int argc, char **argv)
{
  GstElement *p;
  GstElement *e;
  GstPad *pad;

  gst_init(&argc, &argv);

  p = gst_parse_launch ("audiotestsrc name=src ! audioresample name=r2 ! fakesink", NULL);

  g_thread_create(thread, p, FALSE, NULL);

  e =  gst_bin_get_by_name(GST_BIN(p), "src");
  pad = gst_element_get_static_pad(e, "src");

  gst_pad_peer_accept_caps(pad, gst_caps_new_simple("audio/x-raw-int", NULL));


  return 0;
}
