gstreamer/tools/gst-typefind.c
Wim Taymans c2f41a8906 Next big merge.
Original commit message from CVS:
Next big merge.
Added GstBus for mainloop integration.
Added GstMessage for sending notifications on the bus.
Added GstTask as an abstraction for pipeline entry points.
Removed GstThread.
Removed Schedulers.
Simplified GstQueue for multithreaded core.
Made _link threadsafe, removed old capsnego.
Added STREAM_LOCK and PREROLL_LOCK in GstPad.
Added pad blocking functions.
Reworked scheduling functions in GstPad to prepare for
scheduling updates soon.
Moved events out of data stream.
Simplified GstEvent types.
Added return values to push/pull.
Removed clocking from GstElement.
Added prototypes for state change function for next merge.
Removed iterate from bins and state change management.
Fixed some elements, disabled others for now.
Fixed -inspect and -launch.
Added check for GstBus.
2005-03-21 17:34:02 +00:00

80 lines
1.8 KiB
C

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <gst/gst.h>
/*
* find the type of a media file and display it's properties
**/
gboolean FOUND = FALSE;
gchar *filename = NULL;
void
gst_caps_print (const char *filename, const GstCaps * caps)
{
gchar *caps_str = gst_caps_to_string (caps);
g_print ("%s - %s\n", filename, caps_str);
g_free (caps_str);
}
void
have_type_handler (GstElement * typefind, guint probability,
const GstCaps * caps, gpointer unused)
{
gst_caps_print (filename, caps);
FOUND = TRUE;
}
int
main (int argc, char *argv[])
{
guint i = 1;
GstElement *pipeline;
GstElement *source, *typefind;
setlocale (LC_ALL, "");
gst_init (&argc, &argv);
if (argc < 2) {
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 (GST_BIN (pipeline), source);
gst_bin_add (GST_BIN (pipeline), typefind);
gst_pad_link (gst_element_get_pad (source, "src"),
gst_element_get_pad (typefind, "sink"));
g_signal_connect (G_OBJECT (typefind), "have-type",
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) {
}
if (!FOUND) {
g_print ("%s - No type found\n", argv[i]);
}
i++;
}
g_object_unref (pipeline);
return 0;
}