2003-06-29 14:05:49 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2003-05-17 23:04:02 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2003-08-19 08:11:58 +00:00
|
|
|
#include <locale.h>
|
2003-05-17 23:04:02 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* find the type of a media file and display it's properties
|
|
|
|
**/
|
|
|
|
|
|
|
|
gboolean FOUND = FALSE;
|
2003-10-28 20:25:30 +00:00
|
|
|
gchar *filename = NULL;
|
2003-05-17 23:04:02 +00:00
|
|
|
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_caps_print (const char *filename, const GstCaps * caps)
|
2003-05-17 23:04:02 +00:00
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
gchar *caps_str = gst_caps_to_string (caps);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
g_print ("%s - %s\n", filename, caps_str);
|
|
|
|
g_free (caps_str);
|
2003-05-17 23:04:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
have_type_handler (GstElement * typefind, guint probability,
|
|
|
|
const GstCaps * caps, gpointer unused)
|
2003-05-17 23:04:02 +00:00
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
gst_caps_print (filename, caps);
|
2003-05-17 23:04:02 +00:00
|
|
|
FOUND = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
guint i = 1;
|
2003-05-17 23:04:02 +00:00
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *source, *typefind;
|
|
|
|
|
2003-08-19 08:11:58 +00:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2003-05-17 23:04:02 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (argc < 2) {
|
2003-06-29 14:05:49 +00:00
|
|
|
g_print ("Please give a filename to typefind\n\n");
|
2003-10-28 20:25:30 +00:00
|
|
|
return 1;
|
2003-06-29 14:05:49 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-05-17 23:04:02 +00:00
|
|
|
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));
|
2005-03-10 12:51:45 +00:00
|
|
|
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"));
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_connect (G_OBJECT (typefind), "have-type",
|
|
|
|
G_CALLBACK (have_type_handler), NULL);
|
2003-05-17 23:04:02 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
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);
|
2003-05-17 23:04:02 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (!FOUND) {
|
2003-09-14 11:08:50 +00:00
|
|
|
}
|
2003-10-28 20:25:30 +00:00
|
|
|
if (!FOUND) {
|
|
|
|
g_print ("%s - No type found\n", argv[i]);
|
|
|
|
}
|
|
|
|
i++;
|
2003-09-14 11:08:50 +00:00
|
|
|
}
|
2003-10-28 20:25:30 +00:00
|
|
|
g_object_unref (pipeline);
|
2003-05-17 23:04:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|