From 0236b2efc3be6e954c4bbc647c87d870a2d7e0e9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 22 Sep 2010 19:01:40 +0200 Subject: [PATCH] pulse: add test app for pulse device probe --- configure.ac | 1 + tests/examples/Makefile.am | 4 +-- tests/examples/pulse/.gitignore | 1 + tests/examples/pulse/Makefile.am | 5 +++ tests/examples/pulse/pulse.c | 70 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 tests/examples/pulse/.gitignore create mode 100644 tests/examples/pulse/Makefile.am create mode 100644 tests/examples/pulse/pulse.c diff --git a/configure.ac b/configure.ac index 0dd4c7f..451fac0 100644 --- a/configure.ac +++ b/configure.ac @@ -1160,6 +1160,7 @@ tests/examples/Makefile tests/examples/audiofx/Makefile tests/examples/equalizer/Makefile tests/examples/level/Makefile +tests/examples/pulse/Makefile tests/examples/rtp/Makefile tests/examples/shapewipe/Makefile tests/examples/spectrum/Makefile diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am index a655b2d..d3d93d4 100644 --- a/tests/examples/Makefile.am +++ b/tests/examples/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS = audiofx equalizer level rtp shapewipe spectrum v4l2 +SUBDIRS = audiofx equalizer level pulse rtp shapewipe spectrum v4l2 -DIST_SUBDIRS = audiofx equalizer level rtp shapewipe spectrum v4l2 +DIST_SUBDIRS = audiofx equalizer level pulse rtp shapewipe spectrum v4l2 include $(top_srcdir)/common/parallel-subdirs.mak diff --git a/tests/examples/pulse/.gitignore b/tests/examples/pulse/.gitignore new file mode 100644 index 0000000..5f7ce5e --- /dev/null +++ b/tests/examples/pulse/.gitignore @@ -0,0 +1 @@ +pulse diff --git a/tests/examples/pulse/Makefile.am b/tests/examples/pulse/Makefile.am new file mode 100644 index 0000000..5d35e61 --- /dev/null +++ b/tests/examples/pulse/Makefile.am @@ -0,0 +1,5 @@ +noinst_PROGRAMS = pulse +pulse_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) +pulse_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-0.10 $(GST_BASE_LIBS) $(GST_LIBS) + + diff --git a/tests/examples/pulse/pulse.c b/tests/examples/pulse/pulse.c new file mode 100644 index 0000000..54c1a87 --- /dev/null +++ b/tests/examples/pulse/pulse.c @@ -0,0 +1,70 @@ +/* GStreamer + * Copyright (C) 2010 Wim Taymans + * + * 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 + +#include + +static void +test_element (const gchar * name) +{ + GstElement *element; + GstPropertyProbe *probe = NULL; + const GParamSpec *pspec = NULL; + GValueArray *array = NULL; + guint i; + + g_print ("testing element %s\n", name); + element = gst_element_factory_make (name, NULL); + g_assert (element); + + gst_element_set_state (element, GST_STATE_READY); + probe = GST_PROPERTY_PROBE (element); + pspec = gst_property_probe_get_property (probe, "device"); + + array = gst_property_probe_probe_and_get_values (probe, pspec); + g_assert (array); + + for (i = 0; i < array->n_values; i++) { + GValue *device = NULL; + gchar *name = NULL; + + device = g_value_array_get_nth (array, i); + g_object_set_property (G_OBJECT (element), "device", device); + g_object_get (G_OBJECT (element), "device-name", &name, NULL); + + g_print ("device: %s (%s)\n", g_value_get_string (device), + GST_STR_NULL (name)); + } + g_value_array_free (array); + + gst_element_set_state (element, GST_STATE_NULL); + gst_object_unref (GST_OBJECT (element)); +} + +int +main (int argc, char *argv[]) +{ + gst_init (&argc, &argv); + + test_element ("pulsesink"); + test_element ("pulsesrc"); + + return 0; +} -- 2.7.4