3 /* eos will be called when the src element has an end of stream */
4 void eos(GstElement *element, gpointer data)
6 GstThread *thread = GST_THREAD(data);
7 g_print("have eos, quitting\n");
10 gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL);
15 int main(int argc,char *argv[])
17 GstElement *disksrc, *audiosink;
21 gst_init(&argc,&argv);
24 g_print("usage: %s <filename>\n", argv[0]);
28 /* create a new thread to hold the elements */
29 thread = gst_thread_new("thread");
30 g_assert(thread != NULL);
32 /* create a new bin to hold the elements */
33 pipeline = gst_pipeline_new("pipeline");
34 g_assert(pipeline != NULL);
36 /* create a disk reader */
37 disksrc = gst_elementfactory_make("disksrc", "disk_source");
38 g_assert(disksrc != NULL);
39 gtk_object_set(GTK_OBJECT(disksrc),"location", argv[1],NULL);
40 gtk_signal_connect(GTK_OBJECT(disksrc),"eos",
41 GTK_SIGNAL_FUNC(eos), thread);
43 /* and an audio sink */
44 audiosink = gst_elementfactory_make("audiosink", "play_audio");
45 g_assert(audiosink != NULL);
47 /* add objects to the main pipeline */
48 gst_pipeline_add_src(GST_PIPELINE(pipeline), disksrc);
49 gst_pipeline_add_sink(GST_PIPELINE(pipeline), audiosink);
51 if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) {
52 g_print("unable to handle stream\n");
56 //gst_bin_remove(GST_BIN(pipeline), disksrc);
58 //gst_bin_add(GST_BIN(thread), disksrc);
59 gst_bin_add(GST_BIN(thread), GST_ELEMENT(pipeline));
62 gst_element_set_state(GST_ELEMENT(thread), GST_STATE_READY);
64 gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING);
68 gst_pipeline_destroy(thread);