summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: de95dcc)
raw | patch | inline | side by side (parent: de95dcc)
author | Tim-Philipp Müller <tim@centricular.net> | |
Wed, 8 Nov 2006 02:03:48 +0000 (02:03 +0000) | ||
committer | Tim-Philipp Müller <tim@centricular.net> | |
Wed, 8 Nov 2006 02:03:48 +0000 (02:03 +0000) |
Original commit message from CVS:
* tests/examples/typefind/typefind.c: (type_found), (main):
Make typefind element example work again (#371894); add a
license header.
* tests/examples/typefind/typefind.c: (type_found), (main):
Make typefind element example work again (#371894); add a
license header.
ChangeLog | patch | blob | history | |
tests/examples/typefind/typefind.c | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index d2ddf0a33b60168dc0e3d8b1dd076ed0c81ae10c..095f962f0887c9cdbbaddac5f7f0eff0bdddc7f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-11-07 Tim-Philipp Müller <tim at centricular dot net>
+
+ * tests/examples/typefind/typefind.c: (type_found), (main):
+ Make typefind element example work again (#371894); add a
+ license header.
+
2006-11-07 Tim-Philipp Müller <tim at centricular dot net>
* docs/random/draft-missing-plugins.txt:
index e7ed9aaa15a3ff8a3e03fb28df8b946cf2fa5ab6..06cb56b68e231e71ecce01fb374881a50f8056f7 100644 (file)
+/* GStreamer typefind element example
+ * Copyright (C) <2005> Stefan Kost
+ * Copyright (C) <2006> Tim-Philipp Müller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
#include <gst/gst.h>
static void
-type_found (GstElement * typefind, const GstCaps * caps)
+type_found (GstElement * typefind, guint probability, const GstCaps * caps,
+ gpointer user_data)
{
- xmlDocPtr doc;
- xmlNodePtr parent;
-
- doc = xmlNewDoc ((xmlChar *) "1.0");
- doc->xmlRootNode = xmlNewDocNode (doc, NULL, (xmlChar *) "Capabilities",
- NULL);
+ gchar *xml, *caps_str;
- parent = xmlNewChild (doc->xmlRootNode, NULL, (xmlChar *) "Caps1", NULL);
- /* FIXME */
- //gst_caps_save_thyself (caps, parent);
+ caps_str = gst_caps_to_string (caps);
+ xml = g_markup_printf_escaped ("<?xml version=\"1.0\"?>\n<Capabilities>\n"
+ " <Caps1>%s</Caps1>\n</Capabilities>", caps_str);
+ g_free (caps_str);
- xmlDocDump (stdout, doc);
+ g_print ("%s\n", xml);
+ g_free (xml);
}
static void
int
main (int argc, char *argv[])
{
- GstElement *bin, *filesrc, *typefind;
+ GstElement *pipeline, *filesrc, *typefind, *sink;
gst_init (&argc, &argv);
exit (-1);
}
- /* create a new bin to hold the elements */
- bin = gst_pipeline_new ("bin");
- g_assert (bin != NULL);
+ /* create a new pipeline to hold the elements */
+ pipeline = gst_pipeline_new ("pipeline");
+ g_assert (pipeline != NULL);
/* create a file reader */
filesrc = gst_element_factory_make ("filesrc", "file_source");
typefind = gst_element_factory_make ("typefind", "typefind");
g_assert (typefind != NULL);
+ sink = gst_element_factory_make ("fakesink", "sink");
+ g_assert (sink != NULL);
+
/* add objects to the main pipeline */
- gst_bin_add (GST_BIN (bin), filesrc);
- gst_bin_add (GST_BIN (bin), typefind);
+ gst_bin_add (GST_BIN (pipeline), filesrc);
+ gst_bin_add (GST_BIN (pipeline), typefind);
+ gst_bin_add (GST_BIN (pipeline), sink);
- g_signal_connect (G_OBJECT (typefind), "have_type",
+ g_signal_connect (G_OBJECT (typefind), "have-type",
G_CALLBACK (type_found), NULL);
- gst_element_link (filesrc, typefind);
+ gst_element_link_many (filesrc, typefind, sink, NULL);
/* start playing */
- gst_element_set_state (bin, GST_STATE_PLAYING);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Run event loop listening for bus messages until EOS or ERROR */
- event_loop (bin);
+ event_loop (pipeline);
/* stop the bin */
- gst_element_set_state (bin, GST_STATE_NULL);
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (pipeline);
exit (0);
}