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);
22 g_print ("%s - %s\n", filename, caps_str);
27 have_type_handler (GstElement * typefind, guint probability,
28 const GstCaps * caps, gpointer unused)
30 gst_caps_print (filename, caps);
35 main (int argc, char *argv[])
39 GstElement *source, *typefind;
41 setlocale (LC_ALL, "");
43 gst_init (&argc, &argv);
46 g_print ("Please give a filename to typefind\n\n");
50 pipeline = gst_pipeline_new (NULL);
51 source = gst_element_factory_make ("filesrc", "source");
52 g_assert (GST_IS_ELEMENT (source));
53 typefind = gst_element_factory_make ("typefind", "typefind");
54 g_assert (GST_IS_ELEMENT (typefind));
55 gst_bin_add (GST_BIN (pipeline), source);
56 gst_bin_add (GST_BIN (pipeline), typefind);
57 gst_pad_link (gst_element_get_pad (source, "src"),
58 gst_element_get_pad (typefind, "sink"));
59 g_signal_connect (G_OBJECT (typefind), "have-type",
60 G_CALLBACK (have_type_handler), NULL);
64 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
66 g_object_set (source, "location", filename, NULL);
68 gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
73 g_print ("%s - No type found\n", argv[i]);
77 g_object_unref (pipeline);