2005-07-24 21:05:46 +00:00
|
|
|
#include "tools.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
2005-07-24 21:05:46 +00:00
|
|
|
struct poptOption options[] = {
|
|
|
|
GST_TOOLS_POPT_VERSION,
|
|
|
|
POPT_TABLEEND
|
|
|
|
};
|
2003-05-17 23:04:02 +00:00
|
|
|
|
2003-08-19 08:11:58 +00:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2005-07-24 21:05:46 +00:00
|
|
|
gst_init_with_popt_table (&argc, &argv, options);
|
|
|
|
gst_tools_print_version ("gst-typefind-0.8");
|
2003-05-17 23:04:02 +00:00
|
|
|
|
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));
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), source, typefind, NULL);
|
|
|
|
gst_element_link (source, typefind);
|
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-10-28 20:25:30 +00:00
|
|
|
if (!gst_bin_iterate (GST_BIN (pipeline)))
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
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;
|
|
|
|
}
|