2 * Copyright (C) 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 #include <gst/interfaces/propertyprobe.h>
25 main (int argc, char *argv[])
27 GstElement *src, *sink;
29 GstPropertyProbe *probe = NULL;
30 const GParamSpec *pspec = NULL;
31 GValueArray *array = NULL;
38 gst_init (&argc, &argv);
40 bin = gst_pipeline_new ("pipeline");
43 src = gst_element_factory_make ("v4lsrc", "v4l_source");
45 sink = gst_element_factory_make ("fakesink", "fake_sink");
48 /* add objects to the main pipeline */
49 gst_bin_add_many (GST_BIN (bin), src, sink, NULL);
50 /* link the elements */
51 gst_element_link_many (src, sink, NULL);
54 g_print ("Probing devices with propertyprobe...\n");
55 probe = GST_PROPERTY_PROBE (src);
56 pspec = gst_property_probe_get_property (probe, "device");
57 array = gst_property_probe_probe_and_get_values (probe, pspec);
60 g_print ("No device found\n");
64 for (i = 0; i < array->n_values; i++) {
65 value = g_value_array_get_nth (array, i);
66 device = g_value_get_string (value);
67 g_print ("Device: %s\n", device);
68 g_object_set_property (G_OBJECT (src), "device", value);
69 gst_element_set_state (bin, GST_STATE_READY);
70 ret = gst_element_get_state (bin, NULL, NULL, 10 * GST_SECOND);
71 if (ret != GST_STATE_CHANGE_SUCCESS) {
72 g_print ("Couldn't set STATE_READY\n");
75 g_object_get (G_OBJECT (src), "device-name", &name, NULL);
76 g_print ("Name: %s\n", name);
78 g_object_get (G_OBJECT (src), "flags", &flags, NULL);
79 g_print ("Flags: 0x%08X\n", flags);
80 gst_element_set_state (bin, GST_STATE_NULL);