make it reuse the existing pipeline - quite a speedup

Original commit message from CVS:
make it reuse the existing pipeline - quite a speedup
This commit is contained in:
Benjamin Otte 2003-10-28 00:33:55 +00:00
parent d967c20451
commit d2cf080210

View file

@ -12,8 +12,7 @@
**/ **/
gboolean FOUND = FALSE; gboolean FOUND = FALSE;
int iterations; gchar *filename = NULL;
int max_iterations = 100;
void void
gst_caps_print (const char *filename, GstCaps *caps) gst_caps_print (const char *filename, GstCaps *caps)
@ -24,7 +23,7 @@ gst_caps_print (const char *filename, GstCaps *caps)
} }
void 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); gst_caps_print (filename, caps);
FOUND = TRUE; FOUND = TRUE;
@ -45,36 +44,34 @@ main (int argc, char *argv[])
g_print ("Please give a filename to typefind\n\n"); g_print ("Please give a filename to typefind\n\n");
return 1; 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) { while (i < argc) {
FOUND = FALSE; FOUND = FALSE;
iterations = 0; gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
pipeline = gst_pipeline_new (NULL); filename = argv[i];
source = gst_element_factory_make ("filesrc", "source"); g_object_set (source, "location", filename, NULL);
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]);
/* set to play */ /* set to play */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
while (!FOUND){ while (!FOUND) {
if (!gst_bin_iterate (GST_BIN (pipeline))) if (!gst_bin_iterate (GST_BIN (pipeline)))
break; break;
iterations++;
if(iterations >= max_iterations){
break;
}
} }
if (!FOUND) { if (!FOUND) {
g_print ("%s - No type found\n", argv[i]); g_print ("%s - No type found\n", argv[i]);
} }
i++; i++;
/* g_object_unref (pipeline); */
} }
g_object_unref (pipeline);
return 0; return 0;
} }