A basic dummy player.
[cascardo/moving.git] / main.c
1 /*
2  *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along
15  *  with this program; if not, write to the Free Software Foundation, Inc.,
16  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19
20 #include <gst/gst.h>
21
22 gboolean
23 bus_watch (GstBus *bus, GstMessage *message, gpointer data)
24 {
25   if (message->type == GST_MESSAGE_EOS)
26     g_main_loop_quit ((GMainLoop*) data);
27   return TRUE;
28 }
29
30 int
31 main (int argc, char **argv)
32 {
33   GMainLoop *loop;
34   GstElement *pipeline;
35   GstBus *bus;
36   GstElement *src;
37   GstElement *filter;
38   GstElement *sink;
39   gst_init (&argc, &argv);
40   loop = g_main_loop_new (g_main_context_default (), TRUE);
41   pipeline = gst_pipeline_new (NULL);
42   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
43   gst_bus_add_watch (bus, bus_watch, loop);
44   src = gst_element_factory_make ("videotestsrc", NULL);
45   filter = gst_element_factory_make ("ffmpegcolorspace", NULL);
46   sink = gst_element_factory_make ("ximagesink", NULL);
47   gst_bin_add_many (GST_BIN (pipeline), src, filter, sink, NULL);
48   gst_element_link_many (src, filter, sink, NULL);
49   gst_element_set_state (pipeline, GST_STATE_PLAYING);
50   g_main_loop_run (loop);
51   return 0;
52 }