mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-26 14:00:29 +00:00
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:
parent
d967c20451
commit
d2cf080210
1 changed files with 18 additions and 21 deletions
|
@ -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;
|
||||
}
|
||||
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]);
|
||||
G_CALLBACK (have_type_handler), NULL);
|
||||
|
||||
while (i < argc) {
|
||||
FOUND = FALSE;
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue