4 int main(int argc,char *argv[])
6 GstElement *disksrc, *osssink, *parse, *decode, *queue;
10 gst_init(&argc,&argv);
13 g_print("usage: %s <filename>\n", argv[0]);
17 /* create a new thread to hold the elements */
18 thread = gst_thread_new("thread");
19 g_assert(thread != NULL);
21 /* create a new bin to hold the elements */
22 bin = gst_bin_new("bin");
23 g_assert(bin != NULL);
25 /* create a disk reader */
26 disksrc = gst_elementfactory_make("disksrc", "disk_source");
27 g_assert(disksrc != NULL);
28 g_object_set(G_OBJECT(disksrc),"location", argv[1],NULL);
30 parse = gst_elementfactory_make("mp3parse", "parse");
31 decode = gst_elementfactory_make("mpg123", "decode");
33 queue = gst_elementfactory_make("queue", "queue");
35 /* and an audio sink */
36 osssink = gst_elementfactory_make("osssink", "play_audio");
37 g_assert(osssink != NULL);
39 /* add objects to the main pipeline */
40 gst_bin_add(GST_BIN(bin), disksrc);
41 gst_bin_add(GST_BIN(bin), parse);
42 gst_bin_add(GST_BIN(bin), decode);
43 gst_bin_add(GST_BIN(bin), queue);
45 gst_bin_add(GST_BIN(thread), osssink);
47 gst_bin_add(GST_BIN(bin), thread);
49 gst_pad_connect(gst_element_get_pad(disksrc,"src"),
50 gst_element_get_pad(parse,"sink"));
51 gst_pad_connect(gst_element_get_pad(parse,"src"),
52 gst_element_get_pad(decode,"sink"));
53 gst_pad_connect(gst_element_get_pad(decode,"src"),
54 gst_element_get_pad(queue,"sink"));
55 gst_pad_connect(gst_element_get_pad(queue,"src"),
56 gst_element_get_pad(osssink,"sink"));
59 gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
61 while (gst_bin_iterate(GST_BIN(bin)));
63 gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);