mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
cf2c17a13d
Original commit message from CVS: * po/POTFILES.in: * tools/Makefile.am: * tools/tools.h: add tools.h for common stuff of all our tools. Currently does what's necessary for the --version command line switch. * tools/gst-compprep.c: (main): * tools/gst-inspect.c: (main): * tools/gst-launch.1.in: * tools/gst-launch.c: (main): * tools/gst-md5sum.1.in: * tools/gst-md5sum.c: (main): * tools/gst-register.1.in: * tools/gst-register.c: (main): * tools/gst-typefind.1.in: * tools/gst-typefind.c: (main): * tools/gst-xmlinspect.1.in: * tools/gst-xmlinspect.c: (main): * tools/gst-xmllaunch.1.in: add and document --version switch to all tools.
81 lines
1.9 KiB
C
81 lines
1.9 KiB
C
#include "tools.h"
|
|
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <locale.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;
|
|
struct poptOption options[] = {
|
|
GST_TOOLS_POPT_VERSION,
|
|
POPT_TABLEEND
|
|
};
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
gst_init_with_popt_table (&argc, &argv, options);
|
|
gst_tools_print_version ("gst-typefind-0.8");
|
|
|
|
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_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) {
|
|
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 (!gst_bin_iterate (GST_BIN (pipeline)))
|
|
break;
|
|
}
|
|
if (!FOUND) {
|
|
g_print ("%s - No type found\n", argv[i]);
|
|
}
|
|
i++;
|
|
}
|
|
g_object_unref (pipeline);
|
|
return 0;
|
|
}
|