4 /* returns all factories which have a maximum of maxtemplates GstPadTemplates in direction dir
7 gst_factories_at_most_templates (GList * factories, GstPadDirection dir,
14 GList *templs = ((GstElementFactory *) factories->data)->padtemplates;
17 if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) {
20 if (count > maxtemplates)
22 templs = g_list_next (templs);
24 if (count <= maxtemplates)
25 ret = g_list_prepend (ret, factories->data);
27 factories = g_list_next (factories);
33 property_change_callback (GObject * object, GstObject * orig,
36 GValue value = { 0, }; /* the important thing is that value.type = 0 */
39 if (pspec->flags & G_PARAM_READABLE) {
40 g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
41 g_object_get_property (G_OBJECT (orig), pspec->name, &value);
42 if (G_IS_PARAM_SPEC_STRING (pspec))
43 str = g_value_dup_string (&value);
44 else if (G_IS_PARAM_SPEC_ENUM (pspec))
45 str = g_strdup_printf ("%d", g_value_get_enum (&value));
46 else if (G_IS_PARAM_SPEC_INT64 (pspec))
47 str = g_strdup_printf ("%" G_GINT64_FORMAT, g_value_get_int64 (&value));
49 str = g_strdup_value_contents (&value);
51 g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str);
53 g_value_unset (&value);
55 g_warning ("Parameter not readable. What's up with that?");
60 error_callback (GObject * object, GstObject * orig, gchar * error)
62 g_print ("ERROR: %s: %s\n", GST_OBJECT_NAME (orig), error);
66 * Test program for the autoplugger.
67 * Uses new API extensions (2002-01-28), too.
69 * USAGE: spidertest <mediafile>
70 * If mediafile can be recognized, xvideo and oss audio output are tried.
73 main (int argc, char *argv[])
75 GstElement *bin, *filesrc, *decoder, *osssink, *videosink;
79 g_print ("usage: %s <file>\n", argv[0]);
83 gst_init (&argc, &argv);
85 /* create a new bin to hold the elements */
86 bin = gst_pipeline_new ("pipeline");
87 g_signal_connect (bin, "deep_notify", G_CALLBACK (property_change_callback),
89 g_signal_connect (bin, "error", G_CALLBACK (error_callback), NULL);
91 /* create a disk reader */
92 filesrc = gst_element_factory_make ("filesrc", "disk_source");
93 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
95 /* now it's time to get the decoder */
96 decoder = gst_element_factory_make ("spider", "spider");
98 g_print ("could not find plugin \"spider\"\n");
102 /* only use decoding plugins */
103 g_object_get (decoder, "factories", &facs, NULL);
104 facs = gst_factories_at_most_templates (facs, GST_PAD_SINK, 1);
105 g_object_set (decoder, "factories", facs, NULL);
107 /* create video and audio sink */
108 osssink = gst_element_factory_make ("osssink", "audio");
109 videosink = gst_element_factory_make ("xvideosink", "video");
111 if ((!osssink) || (!videosink)) {
112 g_print ("could not create output plugins\n");
116 /* add objects to the main pipeline */
117 gst_bin_add (GST_BIN (bin), filesrc);
118 gst_bin_add (GST_BIN (bin), decoder);
119 gst_bin_add (GST_BIN (bin), osssink);
120 gst_bin_add (GST_BIN (bin), videosink);
123 if (!(gst_element_link (filesrc, decoder) &&
124 gst_element_link (decoder, osssink) &&
125 gst_element_link (decoder, videosink))) {
126 g_print ("the pipeline could not be linked\n");
130 /* gst_bin_use_clock (GST_BIN (bin), gst_system_clock_obtain ());*/
133 gst_element_set_state (bin, GST_STATE_PLAYING);
135 while (gst_bin_iterate (GST_BIN (bin)));