4 gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline)
6 GstElement *osssink, *videosink, *videoelement, *colorspace;
7 GstElement *new_element;
13 GST_DEBUG (0,"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 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 videosink = gst_bin_new ("videosink");
30 /* and an video sink */
31 videoelement = gst_element_factory_make ("xvideosink", "play_video");
32 g_assert (videosink != NULL);
34 colorspace = gst_element_factory_make ("colorspace", "colorspace");
35 g_assert (colorspace != NULL);
37 gst_element_link_pads (colorspace, "src", videoelement, "sink");
38 gst_bin_add (GST_BIN (videosink), colorspace);
39 gst_bin_add (GST_BIN (videosink), videoelement);
41 gst_element_add_ghost_pad (videosink,
42 gst_element_get_pad (colorspace, "sink"), "sink");
44 autoplug = gst_autoplug_factory_make ("staticrender");
45 g_assert (autoplug != NULL);
47 new_element = gst_autoplug_to_renderers (autoplug,
54 g_print ("could not autoplug, no suitable codecs found...\n");
58 gst_element_set_name (new_element, "new_element");
60 gst_bin_add (GST_BIN (autobin), new_element);
62 g_object_set (G_OBJECT (cache), "reset", TRUE, NULL);
64 gst_element_link_pads (cache, "src", new_element, "sink");
66 gst_element_set_state (pipeline, GST_STATE_PLAYING);
68 #ifndef GST_DISABLE_LOADSAVE
69 gst_xml_write_file (GST_ELEMENT (pipeline), fopen ("xmlTest.gst", "w"));
74 gst_play_cache_empty (GstElement *element, GstElement *pipeline)
79 GstElement *new_element;
81 fprintf (stderr, "have cache empty\n");
83 gst_element_set_state (pipeline, GST_STATE_PAUSED);
85 filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "disk_source");
86 autobin = gst_bin_get_by_name (GST_BIN (pipeline), "autobin");
87 cache = gst_bin_get_by_name (GST_BIN (autobin), "cache");
88 new_element = gst_bin_get_by_name (GST_BIN (autobin), "new_element");
90 gst_element_unlink_many (filesrc, cache, new_element, NULL);
91 gst_bin_remove (GST_BIN (autobin), cache);
92 gst_element_link_pads (filesrc, "src", new_element, "sink");
94 gst_element_set_state (pipeline, GST_STATE_PLAYING);
96 fprintf (stderr, "done with cache_empty\n");
99 int main(int argc,char *argv[])
102 GstElement *pipeline;
104 GstElement *typefind;
108 gst_init(&argc,&argv);
111 g_print("usage: %s <filename>\n", argv[0]);
115 /* create a new pipeline to hold the elements */
116 pipeline = gst_pipeline_new("pipeline");
117 g_assert(pipeline != NULL);
119 /* create a disk reader */
120 filesrc = gst_element_factory_make("filesrc", "disk_source");
121 g_assert(filesrc != NULL);
122 g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
123 gst_bin_add (GST_BIN (pipeline), filesrc);
125 autobin = gst_bin_new ("autobin");
126 cache = gst_element_factory_make ("autoplugcache", "cache");
127 g_signal_connect (G_OBJECT (cache), "cache_empty", G_CALLBACK (gst_play_cache_empty), pipeline);
129 typefind = gst_element_factory_make ("typefind", "typefind");
130 g_signal_connect (G_OBJECT (typefind), "have_type", G_CALLBACK (gst_play_have_type), pipeline);
131 gst_bin_add (GST_BIN (autobin), cache);
132 gst_bin_add (GST_BIN (autobin), typefind);
134 gst_element_link_pads (cache, "src", typefind, "sink");
135 gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"), "sink");
137 gst_bin_add (GST_BIN( pipeline), autobin);
138 gst_element_link_pads (filesrc, "src", autobin, "sink");
141 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
143 while (gst_bin_iterate (GST_BIN (pipeline)));
145 /* stop the pipeline */
146 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
148 gst_object_unref (GST_OBJECT (pipeline));