4 gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline)
7 GstElement *new_element;
13 GST_DEBUG ("GstPipeline: play have type");
15 gst_element_set_state (pipeline, GST_STATE_PAUSED);
17 filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "disk_source");
18 autobin = gst_bin_get_by_name (GST_BIN (pipeline), "autobin");
19 cache = gst_bin_get_by_name (GST_BIN (autobin), "cache");
21 /* unlink_pads the typefind from the pipeline and remove it */
22 gst_element_unlink_pads (cache, "src", typefind, "sink");
23 gst_bin_remove (GST_BIN (autobin), typefind);
25 /* and an audio sink */
26 osssink = gst_element_factory_make("osssink", "play_audio");
27 g_assert(osssink != NULL);
29 autoplug = gst_autoplug_factory_make ("staticrender");
30 g_assert (autoplug != NULL);
32 new_element = gst_autoplug_to_renderers (autoplug,
38 g_print ("could not autoplug, no suitable codecs found...\n");
42 gst_element_set_name (new_element, "new_element");
44 gst_bin_add (GST_BIN (autobin), new_element);
46 g_object_set (G_OBJECT (cache), "reset", TRUE, NULL);
48 gst_element_link_pads (cache, "src", new_element, "sink");
50 gst_element_set_state (pipeline, GST_STATE_PLAYING);
54 gst_play_cache_empty (GstElement *element, GstElement *pipeline)
59 GstElement *new_element;
61 fprintf (stderr, "have cache empty\n");
63 gst_element_set_state (pipeline, GST_STATE_PAUSED);
65 filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "disk_source");
66 autobin = gst_bin_get_by_name (GST_BIN (pipeline), "autobin");
67 cache = gst_bin_get_by_name (GST_BIN (autobin), "cache");
68 new_element = gst_bin_get_by_name (GST_BIN (autobin), "new_element");
70 gst_element_unlink_pads (filesrc, "src", cache, "sink");
71 gst_element_unlink_pads (cache, "src", new_element, "sink");
72 gst_bin_remove (GST_BIN (autobin), cache);
73 gst_element_link_pads (filesrc, "src", new_element, "sink");
75 gst_element_set_state (pipeline, GST_STATE_PLAYING);
77 fprintf (stderr, "done with cache_empty\n");
81 main (int argc, char *argv[])
89 gst_init (&argc, &argv);
92 g_print ("usage: %s <filename>\n", argv[0]);
96 /* create a new pipeline to hold the elements */
97 pipeline = gst_pipeline_new ("pipeline");
98 g_assert (pipeline != NULL);
100 /* create a disk reader */
101 filesrc = gst_element_factory_make ("filesrc", "disk_source");
102 g_assert (filesrc != NULL);
103 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
104 gst_bin_add (GST_BIN (pipeline), filesrc);
106 autobin = gst_bin_new ("autobin");
107 cache = gst_element_factory_make ("autoplugcache", "cache");
108 g_signal_connect (G_OBJECT (cache), "cache_empty",
109 G_CALLBACK (gst_play_cache_empty), pipeline);
111 typefind = gst_element_factory_make ("typefind", "typefind");
112 g_signal_connect (G_OBJECT (typefind), "have_type",
113 G_CALLBACK (gst_play_have_type), pipeline);
114 gst_bin_add (GST_BIN (autobin), cache);
115 gst_bin_add (GST_BIN (autobin), typefind);
117 gst_element_link_pads (cache, "src", typefind, "sink");
118 gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"), "sink");
120 gst_bin_add (GST_BIN( pipeline), autobin);
121 gst_element_link_pads (filesrc, "src", autobin, "sink");
124 gst_element_set_state( GST_ELEMENT (pipeline), GST_STATE_PLAYING);
126 while (gst_bin_iterate (GST_BIN (pipeline)));
128 /* stop the pipeline */
129 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
131 gst_object_unref (GST_OBJECT (pipeline));