#include <gst/gst.h>

int main(int argc, char** argv)
{
    gst_init(&argc, &argv);
    gst_debug_set_default_threshold(GST_LEVEL_INFO);

    GstElement *v4l2src;
    GstElement* pipeline;
    GMainLoop* loop;
    loop = g_main_loop_new (NULL, FALSE);

    pipeline      = gst_pipeline_new("camera");
    v4l2src      = gst_element_factory_make("v4l2src",  NULL);

    if (!pipeline || !v4l2src)
    {
	    g_print ("Elements could not be created. Exiting.\n");
    }

    gst_bin_add_many (GST_BIN (pipeline), v4l2src, NULL);

    /* Iterate */
    g_print ("Running...\n");

    g_object_set(G_OBJECT (v4l2src), "device", "/dev/video0", NULL);
    
    //the next line leads to boo-boo
    gst_element_set_state (pipeline, GST_STATE_PLAYING);
    
    g_main_loop_run (loop);
}