6 * find the type of a media file and display it's properties
9 gboolean FOUND = FALSE;
12 gst_caps_print (GstCaps *caps)
15 g_print ("%s (%s)\n", caps->name, gst_caps_get_mime (caps));
16 if (caps->properties) {
17 g_print ("has properties\n");
24 have_type_handler (GstElement *typefind, gpointer data)
26 GstCaps *caps = (GstCaps *) data;
27 gst_caps_print (caps);
32 main (int argc, char *argv[])
35 GstElement *source, *typefind;
37 gst_init (&argc, &argv);
39 if (argc < 2) { g_error ("Please give a filename to typefind"); }
40 pipeline = gst_pipeline_new (NULL);
41 source = gst_element_factory_make ("filesrc", "source");
42 g_assert (GST_IS_ELEMENT (source));
43 g_object_set (source, "location", argv[1], NULL);
44 typefind = gst_element_factory_make ("typefind", "typefind");
45 g_assert (GST_IS_ELEMENT (typefind));
46 gst_bin_add_many (GST_BIN (pipeline), source, typefind, NULL);
47 gst_element_link (source, typefind);
48 g_signal_connect (G_OBJECT (typefind), "have-type",
49 G_CALLBACK (have_type_handler), NULL);
52 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
54 while (gst_bin_iterate (GST_BIN (pipeline)) && !FOUND) ;
56 g_print ("No type found\n");