#include <gst/gst.h>

static void
on_msg (GstBus * bus, GstMessage * msg, gpointer userdata)
{
  g_print ("Message %s from %s\n", GST_MESSAGE_TYPE_NAME (msg),
      (msg->src) ? GST_OBJECT_NAME (msg->src) : "---");
}

int
main (int argc, char ** argv)
{
  GMainLoop *loop;
  GstElement *pipe, *fakesink1, *fakesink2;
  GstBus *bus;

  gst_init (&argc, &argv);

  pipe = gst_element_factory_make ("playbin2", NULL);
  fakesink1 = gst_element_factory_make ("fakesink", NULL);
  fakesink2 = gst_element_factory_make ("fakesink", NULL);
  g_object_set (pipe, "video-sink", fakesink1, NULL);
  g_object_set (pipe, "audio-sink", fakesink2, NULL);

  bus = gst_element_get_bus (pipe);
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (on_msg), NULL);
  gst_object_unref (bus);

  loop = g_main_loop_new (NULL, FALSE);
  g_object_set (pipe, "uri", argv[1], NULL);
  gst_element_set_state (pipe, GST_STATE_PAUSED);
  g_main_loop_run (loop);

  return 0;
}
