#include <gst/gst.h>

int main (int argc, char *argv[])
{
  GstElement *pipeline, *sine, *tee, *audiosink;
  GstPad *src, *sink;
  gst_init (&argc, &argv);

  pipeline = gst_pipeline_new ("main");
  sine = gst_element_factory_make ("sinesrc", "source");
  tee = gst_element_factory_make ("tee", "splitter");
  audiosink = gst_element_factory_make ("alsasink", "ouput");

  gst_bin_add_many (GST_BIN(pipeline), sine, tee, audiosink, NULL);

  /* Linking the elements */
  /* Linking the sink of the tee BEFORE requesting and linking a source pad */
  gst_element_link_many (sine, tee, NULL);

  sink = gst_element_get_pad (audiosink, "sink");
  src = gst_element_get_request_pad (tee, "src%d");
  gst_pad_link (src, sink);



  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  while (gst_bin_iterate (GST_BIN (pipeline)));

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (GST_OBJECT (pipeline));

  return 0;
}

