4 gst_play_have_type (GstElement * typefind, GstCaps * caps,
8 GstElement *new_element;
14 GST_DEBUG ("GstPipeline: play have type");
16 gst_element_set_state (pipeline, GST_STATE_PAUSED);
18 filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "disk_source");
19 autobin = gst_bin_get_by_name (GST_BIN (pipeline), "autobin");
20 cache = gst_bin_get_by_name (GST_BIN (autobin), "cache");
22 /* unlink_pads the typefind from the pipeline and remove it */
23 gst_element_unlink_pads (cache, "src", typefind, "sink");
24 gst_bin_remove (GST_BIN (autobin), typefind);
26 /* and an audio sink */
27 osssink = gst_element_factory_make ("osssink", "play_audio");
28 g_assert (osssink != NULL);
30 autoplug = gst_autoplug_factory_make ("staticrender");
31 g_assert (autoplug != NULL);
33 new_element = gst_autoplug_to_renderers (autoplug, caps, osssink, NULL);
36 g_print ("could not autoplug, no suitable codecs found...\n");
40 gst_element_set_name (new_element, "new_element");
42 gst_bin_add (GST_BIN (autobin), new_element);
44 g_object_set (G_OBJECT (cache), "reset", TRUE, NULL);
46 gst_element_link_pads (cache, "src", new_element, "sink");
48 gst_element_set_state (pipeline, GST_STATE_PLAYING);
52 gst_play_cache_empty (GstElement * element, GstElement * pipeline)
57 GstElement *new_element;
59 fprintf (stderr, "have cache empty\n");
61 gst_element_set_state (pipeline, GST_STATE_PAUSED);
63 filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "disk_source");
64 autobin = gst_bin_get_by_name (GST_BIN (pipeline), "autobin");
65 cache = gst_bin_get_by_name (GST_BIN (autobin), "cache");
66 new_element = gst_bin_get_by_name (GST_BIN (autobin), "new_element");
68 gst_element_unlink_pads (filesrc, "src", cache, "sink");
69 gst_element_unlink_pads (cache, "src", new_element, "sink");
70 gst_bin_remove (GST_BIN (autobin), cache);
71 gst_element_link_pads (filesrc, "src", new_element, "sink");
73 gst_element_set_state (pipeline, GST_STATE_PLAYING);
75 fprintf (stderr, "done with cache_empty\n");
79 main (int argc, char *argv[])
87 gst_init (&argc, &argv);
90 g_print ("usage: %s <filename>\n", argv[0]);
94 /* create a new pipeline to hold the elements */
95 pipeline = gst_pipeline_new ("pipeline");
96 g_assert (pipeline != NULL);
98 /* create a disk reader */
99 filesrc = gst_element_factory_make ("filesrc", "disk_source");
100 g_assert (filesrc != NULL);
101 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
102 gst_bin_add (GST_BIN (pipeline), filesrc);
104 autobin = gst_bin_new ("autobin");
105 cache = gst_element_factory_make ("autoplugcache", "cache");
106 g_signal_connect (G_OBJECT (cache), "cache_empty",
107 G_CALLBACK (gst_play_cache_empty), pipeline);
109 typefind = gst_element_factory_make ("typefind", "typefind");
110 g_signal_connect (G_OBJECT (typefind), "have_type",
111 G_CALLBACK (gst_play_have_type), pipeline);
112 gst_bin_add (GST_BIN (autobin), cache);
113 gst_bin_add (GST_BIN (autobin), typefind);
115 gst_element_link_pads (cache, "src", typefind, "sink");
116 gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"),
119 gst_bin_add (GST_BIN (pipeline), autobin);
120 gst_element_link_pads (filesrc, "src", autobin, "sink");
123 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
125 while (gst_bin_iterate (GST_BIN (pipeline)));
127 /* stop the pipeline */
128 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
130 gst_object_unref (GST_OBJECT (pipeline));