11 * find the type of a media file and display it's properties
14 gboolean FOUND = FALSE;
15 gchar *filename = NULL;
18 gst_caps_print (const char *filename, const GstCaps *caps)
20 gchar *caps_str = gst_caps_to_string (caps);
21 g_print ("%s - %s\n", filename, caps_str);
26 have_type_handler (GstElement *typefind, guint probability, const GstCaps *caps, gpointer unused)
28 gst_caps_print (filename, caps);
33 main (int argc, char *argv[])
37 GstElement *source, *typefind;
39 setlocale (LC_ALL, "");
41 gst_init (&argc, &argv);
44 g_print ("Please give a filename to typefind\n\n");
48 pipeline = gst_pipeline_new (NULL);
49 source = gst_element_factory_make ("filesrc", "source");
50 g_assert (GST_IS_ELEMENT (source));
51 typefind = gst_element_factory_make ("typefind", "typefind");
52 g_assert (GST_IS_ELEMENT (typefind));
53 gst_bin_add_many (GST_BIN (pipeline), source, typefind, NULL);
54 gst_element_link (source, typefind);
55 g_signal_connect (G_OBJECT (typefind), "have-type",
56 G_CALLBACK (have_type_handler), NULL);
60 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
62 g_object_set (source, "location", filename, NULL);
64 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
67 if (!gst_bin_iterate (GST_BIN (pipeline)))
71 g_print ("%s - No type found\n", argv[i]);
75 g_object_unref (pipeline);