From d2cf080210ad523ed34655c485846eda7e5e2587 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 28 Oct 2003 00:33:55 +0000 Subject: [PATCH] make it reuse the existing pipeline - quite a speedup Original commit message from CVS: make it reuse the existing pipeline - quite a speedup --- tools/gst-typefind.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/tools/gst-typefind.c b/tools/gst-typefind.c index b27451c421..fc0551ac47 100644 --- a/tools/gst-typefind.c +++ b/tools/gst-typefind.c @@ -12,8 +12,7 @@ **/ gboolean FOUND = FALSE; -int iterations; -int max_iterations = 100; +gchar *filename = NULL; void gst_caps_print (const char *filename, GstCaps *caps) @@ -24,7 +23,7 @@ gst_caps_print (const char *filename, GstCaps *caps) } void -have_type_handler (GstElement *typefind, guint probability, GstCaps *caps, gpointer filename) +have_type_handler (GstElement *typefind, guint probability, GstCaps *caps, gpointer unused) { gst_caps_print (filename, caps); FOUND = TRUE; @@ -45,36 +44,34 @@ main (int argc, char *argv[]) g_print ("Please give a filename to typefind\n\n"); return 1; } + + pipeline = gst_pipeline_new (NULL); + source = gst_element_factory_make ("filesrc", "source"); + g_assert (GST_IS_ELEMENT (source)); + 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); + while (i < argc) { FOUND = FALSE; - iterations = 0; - pipeline = gst_pipeline_new (NULL); - source = gst_element_factory_make ("filesrc", "source"); - g_assert (GST_IS_ELEMENT (source)); - g_object_set (source, "location", argv[i], 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), argv[i]); - + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); + filename = argv[i]; + g_object_set (source, "location", filename, NULL); /* set to play */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - while (!FOUND){ + while (!FOUND) { if (!gst_bin_iterate (GST_BIN (pipeline))) break; - iterations++; - if(iterations >= max_iterations){ - break; - } } if (!FOUND) { g_print ("%s - No type found\n", argv[i]); } i++; - /* g_object_unref (pipeline); */ } + g_object_unref (pipeline); return 0; }