6 /* eos will be called when the src element has an end of stream */
8 eos (GstElement * element, gpointer data)
10 g_print ("have eos, quitting\n");
16 main (int argc, char *argv[])
18 GstElement *filesrc, *osssink, *queue, *parse, *decode;
22 gst_init (&argc, &argv);
25 g_print ("usage: %s <filename>\n", argv[0]);
29 /* create a new thread to hold the elements */
30 thread = gst_thread_new ("thread");
31 g_assert (thread != NULL);
33 /* create a new bin to hold the elements */
34 bin = gst_bin_new ("bin");
35 g_assert (bin != NULL);
37 /* create a disk reader */
38 filesrc = gst_element_factory_make ("filesrc", "disk_source");
39 g_assert (filesrc != NULL);
40 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
41 g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread);
43 queue = gst_element_factory_make ("queue", "queue");
45 /* and an audio sink */
46 osssink = gst_element_factory_make ("osssink", "play_audio");
47 g_assert (osssink != NULL);
49 parse = gst_element_factory_make ("mp3parse", "parse");
50 decode = gst_element_factory_make ("mpg123", "decode");
52 /* add objects to the main bin */
53 gst_bin_add (GST_BIN (bin), filesrc);
54 gst_bin_add (GST_BIN (bin), queue);
56 gst_bin_add (GST_BIN (thread), parse);
57 gst_bin_add (GST_BIN (thread), decode);
58 gst_bin_add (GST_BIN (thread), osssink);
60 gst_element_link_many (filesrc, queue, parse, decode, osssink, NULL);
63 gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
65 gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
70 gst_bin_iterate (GST_BIN (bin));
73 gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);