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

int
main (int argc, char *argv[])
{
  static const char *modes[] = { "auto", "on", "off" };
  GstElement *pipeline, *deinterlace;
  int mode = -1;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /* Run debug mode */
  //gst_debug_set_threshold_for_name ("flacparse", GST_LEVEL_LOG);

  /* Build the pipeline */
  pipeline = gst_parse_launch ("videotestsrc pattern=ball ! interlace ! deinterlace name=d ! xvimagesink", NULL);
  deinterlace = gst_bin_get_by_name (GST_BIN (pipeline), "d");

  g_object_set (deinterlace, "mode", 2, NULL);

  /* Start playing */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  while (TRUE) {
    g_usleep (G_USEC_PER_SEC * 2);
    //g_object_get (deinterlace, "mode", &mode, NULL);
    //mode = (mode + 1) % G_N_ELEMENTS (modes);
    mode = g_random_int () % G_N_ELEMENTS (modes);
    g_print ("Setting mode to %s\n", modes[mode]);
    g_object_set (deinterlace, "mode", mode, NULL);
  }

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}
