4 /* returns all factories which have a maximum of maxtemplates GstPadTemplates in direction dir
7 gst_factories_at_most_templates(GList *factories, GstPadDirection dir, guint maxtemplates)
14 GList *templs = ((GstElementFactory *) factories->data)->padtemplates;
18 if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir)
22 if (count > maxtemplates)
24 templs = g_list_next (templs);
26 if (count <= maxtemplates)
27 ret = g_list_prepend (ret, factories->data);
29 factories = g_list_next (factories);
35 property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec)
37 GValue value = { 0, }; /* the important thing is that value.type = 0 */
40 if (pspec->flags & G_PARAM_READABLE) {
41 g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
42 g_object_get_property (G_OBJECT (orig), pspec->name, &value);
43 if (G_IS_PARAM_SPEC_STRING (pspec))
44 str = g_value_dup_string (&value);
45 else if (G_IS_PARAM_SPEC_ENUM (pspec))
46 str = g_strdup_printf ("%d", g_value_get_enum (&value));
47 else if (G_IS_PARAM_SPEC_INT64 (pspec))
48 str = g_strdup_printf ("%lld", g_value_get_int64 (&value));
50 str = g_strdup_value_contents (&value);
52 g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str);
54 g_value_unset(&value);
56 g_warning ("Parameter not readable. What's up with that?");
61 error_callback (GObject *object, GstObject *orig, gchar *error)
63 g_print ("ERROR: %s: %s\n", GST_OBJECT_NAME (orig), error);
67 * Test program for the autoplugger.
68 * Uses new API extensions (2002-01-28), too.
70 * USAGE: spidertest <mediafile>
71 * If mediafile can be recognized, xvideo and oss audio output are tried.
73 int 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), NULL);
88 g_signal_connect (bin, "error", G_CALLBACK (error_callback), NULL);
90 /* create a disk reader */
91 filesrc = gst_element_factory_make("filesrc", "disk_source");
92 g_object_set(G_OBJECT(filesrc),"location", argv[1], NULL);
94 /* now it's time to get the decoder */
95 decoder = gst_element_factory_make("spider", "spider");
97 g_print ("could not find plugin \"spider\"\n");
101 /* only use decoding plugins */
102 g_object_get (decoder, "factories", &facs, NULL);
103 facs = gst_factories_at_most_templates(facs, GST_PAD_SINK, 1);
104 g_object_set (decoder, "factories", facs, NULL);
106 /* create video and audio sink */
107 osssink = gst_element_factory_make("osssink", "audio");
108 videosink = gst_element_factory_make("xvideosink", "video");
110 if ((!osssink) || (!videosink)) {
111 g_print ("could not create output plugins\n");
115 /* add objects to the main pipeline */
116 gst_bin_add(GST_BIN(bin), filesrc);
117 gst_bin_add(GST_BIN(bin), decoder);
118 gst_bin_add(GST_BIN(bin), osssink);
119 gst_bin_add(GST_BIN(bin), videosink);
122 if (!(gst_element_link(filesrc, decoder) &&
123 gst_element_link(decoder, osssink) &&
124 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)));