From 763f3d595bcfc33aac5d098a640bf1a32d1f2a39 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sat, 17 May 2003 23:04:02 +0000 Subject: [PATCH] adding typefind binary Original commit message from CVS: adding typefind binary --- tools/Makefile.am | 5 ++++ tools/gst-typefind.c | 61 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 tools/gst-typefind.c diff --git a/tools/Makefile.am b/tools/Makefile.am index e455f724c3..e96c0fbd9c 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -14,6 +14,7 @@ bin_PROGRAMS = gst-launch \ $(GST_REGISTRY_SRC) \ gst-inspect \ gst-xmlinspect \ + gst-typefind \ $(GST_LOADSAVE_SRC) \ gst-md5sum @@ -31,6 +32,10 @@ gst_md5sum_LDADD = $(GST_LIBS) #-lefence gst_md5sum_CFLAGS = $(GST_CFLAGS) -DGST_CONFIG_DIR=\"$(GST_CONFIG_DIR)\" \ -DGST_CACHE_DIR=\""$(GST_CACHE_DIR)"\" +gst_typefind_LDADD = $(GST_LIBS) #-lefence +gst_typefind_CFLAGS = $(GST_CFLAGS) -DGST_CONFIG_DIR=\"$(GST_CONFIG_DIR)\" \ + -DGST_CACHE_DIR=\""$(GST_CACHE_DIR)"\" + gst_inspect_LDADD = $(GST_LIBS) ../libs/gst/control/libgstcontrol-@GST_MAJORMINOR@.la gst_inspect_CFLAGS = $(GST_CFLAGS) -DGST_CONFIG_DIR=\"$(GST_CONFIG_DIR)\" \ -DGST_CACHE_DIR=\""$(GST_CACHE_DIR)"\" diff --git a/tools/gst-typefind.c b/tools/gst-typefind.c new file mode 100644 index 0000000000..29416b2313 --- /dev/null +++ b/tools/gst-typefind.c @@ -0,0 +1,61 @@ +#include +#include +#include + +/* + * find the type of a media file and display it's properties + **/ + +gboolean FOUND = FALSE; + +void +gst_caps_print (GstCaps *caps) +{ + while (caps) { + g_print ("%s (%s)\n", caps->name, gst_caps_get_mime (caps)); + if (caps->properties) { + g_print ("has properties\n"); + } + caps = caps->next; + } +} + +void +have_type_handler (GstElement *typefind, gpointer data) +{ + GstCaps *caps = (GstCaps *) data; + gst_caps_print (caps); + FOUND = TRUE; +} + +int +main (int argc, char *argv[]) +{ + GstElement *pipeline; + GstElement *source, *typefind; + + gst_init (&argc, &argv); + + if (argc < 2) { g_error ("Please give a filename to typefind"); } + pipeline = gst_pipeline_new (NULL); + source = gst_element_factory_make ("filesrc", "source"); + g_assert (GST_IS_ELEMENT (source)); + g_object_set (source, "location", argv[1], NULL); + typefind = gst_element_factory_make ("typefind", "typefind"); + g_assert (GST_IS_ELEMENT (typefind)); + gst_bin_add_many (GST_BIN (pipeline), source, typefind, NULL); + gst_element_link (source, typefind); + g_signal_connect (G_OBJECT (typefind), "have-type", + G_CALLBACK (have_type_handler), NULL); + + /* set to play */ + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); + + while (gst_bin_iterate (GST_BIN (pipeline)) && !FOUND) ; + if (!FOUND) { + g_print ("No type found\n"); + return 1; + } + return 0; +} +