1 #include <stdlib.h>
2 #include <gst/gst.h>
4 int
5 main (int argc, char *argv[])
6 {
7 GstElement *filesrc, *osssink, *parse, *decode, *queue;
8 GstElement *bin;
9 GstElement *thread;
11 gst_init (&argc, &argv);
13 if (argc != 2) {
14 g_print ("usage: %s <filename>\n", argv[0]);
15 exit (-1);
16 }
18 /* create a new thread to hold the elements */
19 thread = gst_thread_new ("thread");
20 g_assert (thread != NULL);
22 /* create a new bin to hold the elements */
23 bin = gst_bin_new ("bin");
24 g_assert (bin != NULL);
26 /* create a disk reader */
27 filesrc = gst_element_factory_make ("filesrc", "disk_source");
28 g_assert (filesrc != NULL);
29 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
31 parse = gst_element_factory_make ("mp3parse", "parse");
32 decode = gst_element_factory_make ("mpg123", "decode");
34 queue = gst_element_factory_make ("queue", "queue");
36 /* and an audio sink */
37 osssink = gst_element_factory_make ("osssink", "play_audio");
38 g_assert (osssink != NULL);
40 /* add objects to the main pipeline */
41 gst_bin_add_many (GST_BIN (bin), filesrc, parse, decode, queue, NULL);
43 gst_bin_add (GST_BIN (thread), osssink);
44 gst_bin_add (GST_BIN (bin), thread);
46 gst_element_link_many (filesrc, parse, decode, queue, osssink, NULL);
48 /* start playing */
49 gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
51 while (gst_bin_iterate (GST_BIN (bin)));
53 gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
55 exit (0);
56 }