2 * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
3 * (c) 2006 Jan Schmidt <thaytan@noraisin.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 * SECTION:element-autoaudiosink
23 * @see_also: autovideosink, alsasink, osssink
25 * autoaudiosink is an audio sink that automatically detects an appropriate
26 * audio sink to use. It does so by scanning the registry for all elements
27 * that have <quote>Sink</quote> and <quote>Audio</quote> in the class field
28 * of their element information, and also have a non-zero autoplugging rank.
31 * <title>Example launch line</title>
33 * gst-launch-1.0 -v -m audiotestsrc ! audioconvert ! audioresample ! autoaudiosink
42 #include "gstautoaudiosink.h"
44 #define DEFAULT_TS_OFFSET 0
53 static void gst_auto_audio_sink_set_property (GObject * object, guint prop_id,
54 const GValue * value, GParamSpec * pspec);
55 static void gst_auto_audio_sink_get_property (GObject * object, guint prop_id,
56 GValue * value, GParamSpec * pspec);
57 static void gst_auto_audio_sink_configure (GstAutoDetect * autodetect,
60 G_DEFINE_TYPE (GstAutoAudioSink, gst_auto_audio_sink, GST_TYPE_AUTO_DETECT);
62 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
68 gst_auto_audio_sink_class_init (GstAutoAudioSinkClass * klass)
70 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
71 GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
72 GstAutoDetectClass *aklass = GST_AUTO_DETECT_CLASS (klass);
74 gobject_class->set_property = gst_auto_audio_sink_set_property;
75 gobject_class->get_property = gst_auto_audio_sink_get_property;
77 aklass->configure = gst_auto_audio_sink_configure;
79 g_object_class_install_property (gobject_class, PROP_TS_OFFSET,
80 g_param_spec_int64 ("ts-offset", "TS Offset",
81 "Timestamp offset in nanoseconds", G_MININT64, G_MAXINT64,
82 DEFAULT_TS_OFFSET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
84 gst_element_class_add_static_pad_template (eklass, &sink_template);
85 gst_element_class_set_static_metadata (eklass, "Auto audio sink",
87 "Wrapper audio sink for automatically detected audio sink",
88 "Jan Schmidt <thaytan@noraisin.net>");
92 gst_auto_audio_sink_init (GstAutoAudioSink * sink)
94 GstAutoDetect *autodetect = GST_AUTO_DETECT (sink);
96 autodetect->media_klass = "Audio";
97 autodetect->flag = GST_ELEMENT_FLAG_SINK;
99 sink->ts_offset = DEFAULT_TS_OFFSET;
103 gst_auto_audio_sink_configure (GstAutoDetect * autodetect, GstElement * kid)
105 GstAutoAudioSink *self = GST_AUTO_AUDIO_SINK (autodetect);
107 g_object_set (G_OBJECT (kid), "ts-offset", self->ts_offset, NULL);
111 gst_auto_audio_sink_set_property (GObject * object, guint prop_id,
112 const GValue * value, GParamSpec * pspec)
114 GstAutoAudioSink *sink = GST_AUTO_AUDIO_SINK (object);
115 GstAutoDetect *autodetect = (GstAutoDetect *) sink;
119 sink->ts_offset = g_value_get_int64 (value);
121 g_object_set_property (G_OBJECT (autodetect->kid), pspec->name, value);
124 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
130 gst_auto_audio_sink_get_property (GObject * object, guint prop_id,
131 GValue * value, GParamSpec * pspec)
133 GstAutoAudioSink *sink = GST_AUTO_AUDIO_SINK (object);
137 g_value_set_int64 (value, sink->ts_offset);
140 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);