summaryrefslogtreecommitdiff
path: root/include/gst/audio
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-08-03 21:02:36 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-08-03 21:02:36 +0300
commit5323a782c4e8c42781f22ce2f488962a18f82554 (patch)
treef71537197b16f0f8fd0d6937f7120d018d220814 /include/gst/audio
parent50acf9d37183f86f6f623aad410003392b0af41f (diff)
Jabber: initial version of Jingle support
Diffstat (limited to 'include/gst/audio')
-rw-r--r--include/gst/audio/audio-bad-prelude.h35
-rw-r--r--include/gst/audio/audio-buffer.h98
-rw-r--r--include/gst/audio/audio-channel-mixer.h84
-rw-r--r--include/gst/audio/audio-channels.h180
-rw-r--r--include/gst/audio/audio-converter.h180
-rw-r--r--include/gst/audio/audio-enumtypes.h120
-rw-r--r--include/gst/audio/audio-format.h412
-rw-r--r--include/gst/audio/audio-info.h143
-rw-r--r--include/gst/audio/audio-prelude.h33
-rw-r--r--include/gst/audio/audio-quantize.h103
-rw-r--r--include/gst/audio/audio-resampler.h259
-rw-r--r--include/gst/audio/audio.h120
-rw-r--r--include/gst/audio/gstaudioaggregator.h232
-rw-r--r--include/gst/audio/gstaudiobasesink.h277
-rw-r--r--include/gst/audio/gstaudiobasesrc.h160
-rw-r--r--include/gst/audio/gstaudiocdsrc.h145
-rw-r--r--include/gst/audio/gstaudioclock.h115
-rw-r--r--include/gst/audio/gstaudiodecoder.h449
-rw-r--r--include/gst/audio/gstaudioencoder.h378
-rw-r--r--include/gst/audio/gstaudiofilter.h107
-rw-r--r--include/gst/audio/gstaudioiec61937.h36
-rw-r--r--include/gst/audio/gstaudiometa.h252
-rw-r--r--include/gst/audio/gstaudioringbuffer.h414
-rw-r--r--include/gst/audio/gstaudiosink.h136
-rw-r--r--include/gst/audio/gstaudiosrc.h106
-rw-r--r--include/gst/audio/gstaudiostreamalign.h92
-rw-r--r--include/gst/audio/gstnonstreamaudiodecoder.h412
-rw-r--r--include/gst/audio/gstplanaraudioadapter.h116
-rw-r--r--include/gst/audio/streamvolume.h80
29 files changed, 5274 insertions, 0 deletions
diff --git a/include/gst/audio/audio-bad-prelude.h b/include/gst/audio/audio-bad-prelude.h
new file mode 100644
index 0000000000..ceb4d95150
--- /dev/null
+++ b/include/gst/audio/audio-bad-prelude.h
@@ -0,0 +1,35 @@
+/* GStreamer Audio Library
+ * Copyright (C) 2018 GStreamer developers
+ *
+ * audiobad-prelude.h: prelude include header for gst-audiobad library
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_BAD_PRELUDE_H__
+#define __GST_AUDIO_BAD_PRELUDE_H__
+
+#include <gst/gst.h>
+
+#ifndef GST_AUDIO_BAD_API
+# ifdef BUILDING_GST_AUDIO_BAD
+# define GST_AUDIO_BAD_API GST_API_EXPORT /* from config.h */
+# else
+# define GST_AUDIO_BAD_API GST_API_IMPORT
+# endif
+#endif
+
+#endif /* __GST_AUDIO_BAD_PRELUDE_H__ */
diff --git a/include/gst/audio/audio-buffer.h b/include/gst/audio/audio-buffer.h
new file mode 100644
index 0000000000..075b59d35e
--- /dev/null
+++ b/include/gst/audio/audio-buffer.h
@@ -0,0 +1,98 @@
+/* GStreamer
+ * Copyright (C) <2018> Collabora Ltd.
+ * @author George Kiagiadakis <george.kiagiadakis@collabora.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_BUFFER_H__
+#define __GST_AUDIO_BUFFER_H__
+
+G_BEGIN_DECLS
+
+/**
+ * GstAudioBuffer:
+ * @info: a #GstAudioInfo describing the audio properties of this buffer
+ * @n_samples: the size of the buffer in samples
+ * @n_planes: the number of planes available
+ * @planes: an array of @n_planes pointers pointing to the start of each
+ * plane in the mapped buffer
+ * @buffer: the mapped buffer
+ *
+ * A structure containing the result of an audio buffer map operation,
+ * which is executed with gst_audio_buffer_map(). For non-interleaved (planar)
+ * buffers, the beginning of each channel in the buffer has its own pointer in
+ * the @planes array. For interleaved buffers, the @planes array only contains
+ * one item, which is the pointer to the beginning of the buffer, and @n_planes
+ * equals 1.
+ *
+ * The different channels in @planes are always in the GStreamer channel order.
+ *
+ * Since: 1.16
+ */
+typedef struct {
+ GstAudioInfo info;
+
+ gsize n_samples;
+ gint n_planes;
+ gpointer *planes;
+
+ GstBuffer *buffer;
+
+ /*< private >*/
+ GstMapInfo *map_infos;
+ gpointer priv_planes_arr[8];
+ GstMapInfo priv_map_infos_arr[8];
+
+ gpointer _gst_reserved[GST_PADDING];
+} GstAudioBuffer;
+
+
+GST_AUDIO_API
+gboolean gst_audio_buffer_map (GstAudioBuffer *buffer, const GstAudioInfo *info,
+ GstBuffer *gstbuffer, GstMapFlags flags);
+
+GST_AUDIO_API
+void gst_audio_buffer_unmap (GstAudioBuffer *buffer);
+
+
+#define GST_AUDIO_BUFFER_FORMAT(b) (GST_AUDIO_INFO_FORMAT(&(b)->info))
+#define GST_AUDIO_BUFFER_CHANNELS(b) (GST_AUDIO_INFO_CHANNELS(&(b)->info))
+#define GST_AUDIO_BUFFER_LAYOUT(b) (GST_AUDIO_INFO_LAYOUT(&(b)->info))
+#define GST_AUDIO_BUFFER_RATE(b) (GST_AUDIO_INFO_RATE(&(b)->info))
+
+#define GST_AUDIO_BUFFER_WIDTH(b) (GST_AUDIO_INFO_WIDTH(&(b)->info))
+#define GST_AUDIO_BUFFER_DEPTH(b) (GST_AUDIO_INFO_DEPTH(&(b)->info))
+#define GST_AUDIO_BUFFER_SAMPLE_STRIDE(b) (GST_AUDIO_INFO_WIDTH(&(b)->info) >> 3)
+#define GST_AUDIO_BUFFER_BPS(b) (GST_AUDIO_INFO_DEPTH(&(b)->info) >> 3)
+#define GST_AUDIO_BUFFER_BPF(b) (GST_AUDIO_INFO_BPF(&(b)->info))
+
+#define GST_AUDIO_BUFFER_N_SAMPLES(b) ((b)->n_samples)
+#define GST_AUDIO_BUFFER_N_PLANES(b) ((b)->n_planes)
+#define GST_AUDIO_BUFFER_PLANE_DATA(b,p) ((b)->planes[p])
+
+/* the size of each plane in bytes */
+#define GST_AUDIO_BUFFER_PLANE_SIZE(b) \
+ (GST_AUDIO_BUFFER_N_SAMPLES(b) * GST_AUDIO_BUFFER_SAMPLE_STRIDE(b) * \
+ GST_AUDIO_BUFFER_CHANNELS(b) / GST_AUDIO_BUFFER_N_PLANES(b))
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_BUFFER_H__ */
diff --git a/include/gst/audio/audio-channel-mixer.h b/include/gst/audio/audio-channel-mixer.h
new file mode 100644
index 0000000000..35c2f6d83f
--- /dev/null
+++ b/include/gst/audio/audio-channel-mixer.h
@@ -0,0 +1,84 @@
+/* GStreamer
+ * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ * (C) 2015 Wim Taymans <wim.taymans@gmail.com>
+ *
+ * audio-channel-mixer.h: setup of channel conversion matrices
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_CHANNEL_MIXER_H__
+#define __GST_AUDIO_CHANNEL_MIXER_H__
+
+#include <gst/gst.h>
+#include <gst/audio/audio.h>
+
+typedef struct _GstAudioChannelMixer GstAudioChannelMixer;
+
+/**
+ * GstAudioChannelMixerFlags:
+ * @GST_AUDIO_CHANNEL_MIXER_FLAGS_NONE: no flag
+ * @GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN: input channels are not interleaved
+ * @GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT: output channels are not interleaved
+ * @GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_IN: input channels are explicitly unpositioned
+ * @GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_OUT: output channels are explicitly unpositioned
+ *
+ * Flags passed to gst_audio_channel_mixer_new()
+ */
+typedef enum {
+ GST_AUDIO_CHANNEL_MIXER_FLAGS_NONE = 0,
+ GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN = (1 << 0),
+ GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT = (1 << 1),
+ GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_IN = (1 << 2),
+ GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_OUT = (1 << 3)
+} GstAudioChannelMixerFlags;
+
+GST_AUDIO_API
+GstAudioChannelMixer * gst_audio_channel_mixer_new (GstAudioChannelMixerFlags flags,
+ GstAudioFormat format,
+ gint in_channels,
+ GstAudioChannelPosition *in_position,
+ gint out_channels,
+ GstAudioChannelPosition *out_position);
+
+GST_AUDIO_API
+GstAudioChannelMixer * gst_audio_channel_mixer_new_with_matrix (GstAudioChannelMixerFlags flags,
+ GstAudioFormat format,
+ gint in_channels,
+ gint out_channels,
+ gfloat **matrix);
+
+GST_AUDIO_API
+void gst_audio_channel_mixer_free (GstAudioChannelMixer *mix);
+
+/*
+ * Checks for passthrough (= identity matrix).
+ */
+
+GST_AUDIO_API
+gboolean gst_audio_channel_mixer_is_passthrough (GstAudioChannelMixer *mix);
+
+/*
+ * Do actual mixing.
+ */
+
+GST_AUDIO_API
+void gst_audio_channel_mixer_samples (GstAudioChannelMixer * mix,
+ const gpointer in[],
+ gpointer out[],
+ gint samples);
+
+#endif /* __GST_AUDIO_CHANNEL_MIXER_H__ */
diff --git a/include/gst/audio/audio-channels.h b/include/gst/audio/audio-channels.h
new file mode 100644
index 0000000000..0089257b12
--- /dev/null
+++ b/include/gst/audio/audio-channels.h
@@ -0,0 +1,180 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Library <2001> Thomas Vander Stichele <thomas@apestaart.org>
+ * <2011> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_CHANNELS_H__
+#define __GST_AUDIO_CHANNELS_H__
+
+G_BEGIN_DECLS
+
+/**
+ * GstAudioChannelPosition:
+ * @GST_AUDIO_CHANNEL_POSITION_MONO: Mono without direction;
+ * can only be used with 1 channel
+ * @GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT: Front left
+ * @GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT: Front right
+ * @GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER: Front center
+ * @GST_AUDIO_CHANNEL_POSITION_LFE1: Low-frequency effects 1 (subwoofer)
+ * @GST_AUDIO_CHANNEL_POSITION_REAR_LEFT: Rear left
+ * @GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT: Rear right
+ * @GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: Front left of center
+ * @GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: Front right of center
+ * @GST_AUDIO_CHANNEL_POSITION_REAR_CENTER: Rear center
+ * @GST_AUDIO_CHANNEL_POSITION_LFE2: Low-frequency effects 2 (subwoofer)
+ * @GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT: Side left
+ * @GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT: Side right
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT: Top front left
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT: Top front right
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER: Top front center
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_CENTER: Top center
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT: Top rear left
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT: Top rear right
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_LEFT: Top side right
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_RIGHT: Top rear right
+ * @GST_AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER: Top rear center
+ * @GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_CENTER: Bottom front center
+ * @GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_LEFT: Bottom front left
+ * @GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT: Bottom front right
+ * @GST_AUDIO_CHANNEL_POSITION_WIDE_LEFT: Wide left (between front left and side left)
+ * @GST_AUDIO_CHANNEL_POSITION_WIDE_RIGHT: Wide right (between front right and side right)
+ * @GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT: Surround left (between rear left and side left)
+ * @GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT: Surround right (between rear right and side right)
+ * @GST_AUDIO_CHANNEL_POSITION_NONE: used for position-less channels, e.g.
+ * from a sound card that records 1024 channels; mutually exclusive with
+ * any other channel position
+ * @GST_AUDIO_CHANNEL_POSITION_INVALID: invalid position
+ *
+ * Audio channel positions.
+ *
+ * These are the channels defined in SMPTE 2036-2-2008
+ * Table 1 for 22.2 audio systems with the Surround and Wide channels from
+ * DTS Coherent Acoustics (v.1.3.1) and 10.2 and 7.1 layouts. In the caps the
+ * actual channel layout is expressed with a channel count and a channel mask,
+ * which describes the existing channels. The positions in the bit mask correspond
+ * to the enum values.
+ * For negotiation it is allowed to have more bits set in the channel mask than
+ * the number of channels to specify the allowed channel positions but this is
+ * not allowed in negotiated caps. It is not allowed in any situation other
+ * than the one mentioned below to have less bits set in the channel mask than
+ * the number of channels.
+ *
+ * @GST_AUDIO_CHANNEL_POSITION_MONO can only be used with a single mono channel that
+ * has no direction information and would be mixed into all directional channels.
+ * This is expressed in caps by having a single channel and no channel mask.
+ *
+ * @GST_AUDIO_CHANNEL_POSITION_NONE can only be used if all channels have this position.
+ * This is expressed in caps by having a channel mask with no bits set.
+ *
+ * As another special case it is allowed to have two channels without a channel mask.
+ * This implicitly means that this is a stereo stream with a front left and front right
+ * channel.
+ */
+typedef enum {
+ /* These get negative indices to allow to use
+ * the enum values of the normal cases for the
+ * bit-mask position */
+ GST_AUDIO_CHANNEL_POSITION_NONE = -3,
+ GST_AUDIO_CHANNEL_POSITION_MONO = -2,
+ GST_AUDIO_CHANNEL_POSITION_INVALID = -1,
+
+ /* Normal cases */
+ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT = 0,
+ GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
+ GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
+ GST_AUDIO_CHANNEL_POSITION_LFE1,
+ GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
+ GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
+ GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
+ GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
+ GST_AUDIO_CHANNEL_POSITION_LFE2,
+ GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
+ GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT,
+ GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER,
+ GST_AUDIO_CHANNEL_POSITION_TOP_CENTER,
+ GST_AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT,
+ GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_RIGHT,
+ GST_AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER,
+ GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_CENTER,
+ GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT,
+ GST_AUDIO_CHANNEL_POSITION_WIDE_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_WIDE_RIGHT,
+ GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT
+} GstAudioChannelPosition;
+
+#define GST_AUDIO_CHANNEL_POSITION_MASK(pos) (G_GUINT64_CONSTANT(1)<< GST_AUDIO_CHANNEL_POSITION_ ## pos)
+
+GST_AUDIO_API
+gboolean gst_audio_buffer_reorder_channels (GstBuffer * buffer,
+ GstAudioFormat format,
+ gint channels,
+ const GstAudioChannelPosition * from,
+ const GstAudioChannelPosition * to);
+
+GST_AUDIO_API
+gboolean gst_audio_reorder_channels (gpointer data, gsize size,
+ GstAudioFormat format,
+ gint channels,
+ const GstAudioChannelPosition * from,
+ const GstAudioChannelPosition * to);
+
+GST_AUDIO_API
+gboolean gst_audio_channel_positions_to_valid_order (GstAudioChannelPosition *position,
+ gint channels);
+
+GST_AUDIO_API
+gboolean gst_audio_check_valid_channel_positions (const GstAudioChannelPosition *position,
+ gint channels, gboolean force_order);
+
+GST_AUDIO_API
+gboolean gst_audio_channel_positions_to_mask (const GstAudioChannelPosition *position,
+ gint channels, gboolean force_order,
+ guint64 *channel_mask);
+
+GST_AUDIO_API
+gboolean gst_audio_channel_positions_from_mask (gint channels, guint64 channel_mask,
+ GstAudioChannelPosition * position);
+
+GST_AUDIO_API
+gboolean gst_audio_get_channel_reorder_map (gint channels,
+ const GstAudioChannelPosition * from,
+ const GstAudioChannelPosition * to,
+ gint *reorder_map);
+
+GST_AUDIO_API
+guint64 gst_audio_channel_get_fallback_mask (gint channels);
+
+GST_AUDIO_API
+gchar* gst_audio_channel_positions_to_string (const GstAudioChannelPosition * position,
+ gint channels);
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_CHANNELS_H__ */
diff --git a/include/gst/audio/audio-converter.h b/include/gst/audio/audio-converter.h
new file mode 100644
index 0000000000..083bda4fa2
--- /dev/null
+++ b/include/gst/audio/audio-converter.h
@@ -0,0 +1,180 @@
+/* GStreamer
+ * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ * (C) 2015 Wim Taymans <wim.taymans@gmail.com>
+ *
+ * audioconverter.h: audio format conversion library
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_CONVERTER_H__
+#define __GST_AUDIO_CONVERTER_H__
+
+#include <gst/gst.h>
+#include <gst/audio/audio.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GstAudioConverter:
+ *
+ * Opaque #GstAudioConverter struct.
+ *
+ * Since: 1.8
+ */
+typedef struct _GstAudioConverter GstAudioConverter;
+
+/**
+ * GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD:
+ *
+ * #GstAudioResamplerMethod, The resampler method to use when
+ * changing sample rates.
+ * Default is #GST_AUDIO_RESAMPLER_METHOD_BLACKMAN_NUTTALL.
+ */
+#define GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD "GstAudioConverter.resampler-method"
+
+/**
+ * GST_AUDIO_CONVERTER_OPT_DITHER_METHOD:
+ *
+ * #GstAudioDitherMethod, The dither method to use when
+ * changing bit depth.
+ * Default is #GST_AUDIO_DITHER_NONE.
+ */
+#define GST_AUDIO_CONVERTER_OPT_DITHER_METHOD "GstAudioConverter.dither-method"
+
+/**
+ * GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD:
+ *
+ * #GstAudioNoiseShapingMethod, The noise shaping method to use
+ * to mask noise from quantization errors.
+ * Default is #GST_AUDIO_NOISE_SHAPING_NONE.
+ */
+#define GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD "GstAudioConverter.noise-shaping-method"
+
+/**
+ * GST_AUDIO_CONVERTER_OPT_QUANTIZATION:
+ *
+ * #G_TYPE_UINT, The quantization amount. Components will be
+ * quantized to multiples of this value.
+ * Default is 1
+ */
+#define GST_AUDIO_CONVERTER_OPT_QUANTIZATION "GstAudioConverter.quantization"
+
+/**
+ * GST_AUDIO_CONVERTER_OPT_MIX_MATRIX:
+ *
+ * #GST_TYPE_LIST, The channel mapping matrix.
+ *
+ * The matrix coefficients must be between -1 and 1: the number of rows is equal
+ * to the number of output channels and the number of columns is equal to the
+ * number of input channels.
+ *
+ * ## Example matrix generation code
+ * To generate the matrix using code:
+ *
+ * |[
+ * GValue v = G_VALUE_INIT;
+ * GValue v2 = G_VALUE_INIT;
+ * GValue v3 = G_VALUE_INIT;
+ *
+ * g_value_init (&v2, GST_TYPE_ARRAY);
+ * g_value_init (&v3, G_TYPE_DOUBLE);
+ * g_value_set_double (&v3, 1);
+ * gst_value_array_append_value (&v2, &v3);
+ * g_value_unset (&v3);
+ * [ Repeat for as many double as your input channels - unset and reinit v3 ]
+ * g_value_init (&v, GST_TYPE_ARRAY);
+ * gst_value_array_append_value (&v, &v2);
+ * g_value_unset (&v2);
+ * [ Repeat for as many v2's as your output channels - unset and reinit v2]
+ * g_object_set_property (G_OBJECT (audiomixmatrix), "matrix", &v);
+ * g_value_unset (&v);
+ * ]|
+ */
+#define GST_AUDIO_CONVERTER_OPT_MIX_MATRIX "GstAudioConverter.mix-matrix"
+
+/**
+ * GstAudioConverterFlags:
+ * @GST_AUDIO_CONVERTER_FLAG_NONE: no flag
+ * @GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE: the input sample arrays are writable and can be
+ * used as temporary storage during conversion.
+ * @GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE: allow arbitrary rate updates with
+ * gst_audio_converter_update_config().
+ *
+ * Extra flags passed to gst_audio_converter_new() and gst_audio_converter_samples().
+ */
+typedef enum {
+ GST_AUDIO_CONVERTER_FLAG_NONE = 0,
+ GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE = (1 << 0),
+ GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE = (1 << 1)
+} GstAudioConverterFlags;
+
+GST_AUDIO_API
+GstAudioConverter * gst_audio_converter_new (GstAudioConverterFlags flags,
+ GstAudioInfo *in_info,
+ GstAudioInfo *out_info,
+ GstStructure *config);
+
+GST_AUDIO_API
+GType gst_audio_converter_get_type (void);
+
+GST_AUDIO_API
+void gst_audio_converter_free (GstAudioConverter * convert);
+
+GST_AUDIO_API
+void gst_audio_converter_reset (GstAudioConverter * convert);
+
+GST_AUDIO_API
+gboolean gst_audio_converter_update_config (GstAudioConverter * convert,
+ gint in_rate, gint out_rate,
+ GstStructure *config);
+
+GST_AUDIO_API
+const GstStructure * gst_audio_converter_get_config (GstAudioConverter * convert,
+ gint *in_rate, gint *out_rate);
+
+GST_AUDIO_API
+gsize gst_audio_converter_get_out_frames (GstAudioConverter *convert,
+ gsize in_frames);
+
+GST_AUDIO_API
+gsize gst_audio_converter_get_in_frames (GstAudioConverter *convert,
+ gsize out_frames);
+
+GST_AUDIO_API
+gsize gst_audio_converter_get_max_latency (GstAudioConverter *convert);
+
+GST_AUDIO_API
+gboolean gst_audio_converter_samples (GstAudioConverter * convert,
+ GstAudioConverterFlags flags,
+ gpointer in[], gsize in_frames,
+ gpointer out[], gsize out_frames);
+
+GST_AUDIO_API
+gboolean gst_audio_converter_supports_inplace (GstAudioConverter *convert);
+
+GST_AUDIO_API
+gboolean gst_audio_converter_is_passthrough (GstAudioConverter *convert);
+
+GST_AUDIO_API
+gboolean gst_audio_converter_convert (GstAudioConverter * convert,
+ GstAudioConverterFlags flags,
+ gpointer in, gsize in_size,
+ gpointer *out, gsize *out_size);
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_CONVERTER_H__ */
diff --git a/include/gst/audio/audio-enumtypes.h b/include/gst/audio/audio-enumtypes.h
new file mode 100644
index 0000000000..6a875e6bb7
--- /dev/null
+++ b/include/gst/audio/audio-enumtypes.h
@@ -0,0 +1,120 @@
+
+/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+
+#pragma once
+
+ #include <glib-object.h>
+ #include <gst/audio/audio-prelude.h>
+
+ G_BEGIN_DECLS
+
+/* enumerations from "audio-channel-mixer.h" */
+
+GST_AUDIO_API
+GType gst_audio_channel_mixer_flags_get_type (void);
+#define GST_TYPE_AUDIO_CHANNEL_MIXER_FLAGS (gst_audio_channel_mixer_flags_get_type())
+
+/* enumerations from "audio-channels.h" */
+
+GST_AUDIO_API
+GType gst_audio_channel_position_get_type (void);
+#define GST_TYPE_AUDIO_CHANNEL_POSITION (gst_audio_channel_position_get_type())
+
+/* enumerations from "audio-converter.h" */
+
+GST_AUDIO_API
+GType gst_audio_converter_flags_get_type (void);
+#define GST_TYPE_AUDIO_CONVERTER_FLAGS (gst_audio_converter_flags_get_type())
+
+/* enumerations from "audio-format.h" */
+
+GST_AUDIO_API
+GType gst_audio_format_get_type (void);
+#define GST_TYPE_AUDIO_FORMAT (gst_audio_format_get_type())
+
+GST_AUDIO_API
+GType gst_audio_format_flags_get_type (void);
+#define GST_TYPE_AUDIO_FORMAT_FLAGS (gst_audio_format_flags_get_type())
+
+GST_AUDIO_API
+GType gst_audio_pack_flags_get_type (void);
+#define GST_TYPE_AUDIO_PACK_FLAGS (gst_audio_pack_flags_get_type())
+
+GST_AUDIO_API
+GType gst_audio_layout_get_type (void);
+#define GST_TYPE_AUDIO_LAYOUT (gst_audio_layout_get_type())
+
+/* enumerations from "audio-info.h" */
+
+GST_AUDIO_API
+GType gst_audio_flags_get_type (void);
+#define GST_TYPE_AUDIO_FLAGS (gst_audio_flags_get_type())
+
+/* enumerations from "audio-quantize.h" */
+
+GST_AUDIO_API
+GType gst_audio_dither_method_get_type (void);
+#define GST_TYPE_AUDIO_DITHER_METHOD (gst_audio_dither_method_get_type())
+
+GST_AUDIO_API
+GType gst_audio_noise_shaping_method_get_type (void);
+#define GST_TYPE_AUDIO_NOISE_SHAPING_METHOD (gst_audio_noise_shaping_method_get_type())
+
+GST_AUDIO_API
+GType gst_audio_quantize_flags_get_type (void);
+#define GST_TYPE_AUDIO_QUANTIZE_FLAGS (gst_audio_quantize_flags_get_type())
+
+/* enumerations from "audio-resampler.h" */
+
+GST_AUDIO_API
+GType gst_audio_resampler_filter_mode_get_type (void);
+#define GST_TYPE_AUDIO_RESAMPLER_FILTER_MODE (gst_audio_resampler_filter_mode_get_type())
+
+GST_AUDIO_API
+GType gst_audio_resampler_filter_interpolation_get_type (void);
+#define GST_TYPE_AUDIO_RESAMPLER_FILTER_INTERPOLATION (gst_audio_resampler_filter_interpolation_get_type())
+
+GST_AUDIO_API
+GType gst_audio_resampler_method_get_type (void);
+#define GST_TYPE_AUDIO_RESAMPLER_METHOD (gst_audio_resampler_method_get_type())
+
+GST_AUDIO_API
+GType gst_audio_resampler_flags_get_type (void);
+#define GST_TYPE_AUDIO_RESAMPLER_FLAGS (gst_audio_resampler_flags_get_type())
+
+/* enumerations from "gstaudiobasesink.h" */
+
+GST_AUDIO_API
+GType gst_audio_base_sink_slave_method_get_type (void);
+#define GST_TYPE_AUDIO_BASE_SINK_SLAVE_METHOD (gst_audio_base_sink_slave_method_get_type())
+
+GST_AUDIO_API
+GType gst_audio_base_sink_discont_reason_get_type (void);
+#define GST_TYPE_AUDIO_BASE_SINK_DISCONT_REASON (gst_audio_base_sink_discont_reason_get_type())
+
+/* enumerations from "gstaudiobasesrc.h" */
+
+GST_AUDIO_API
+GType gst_audio_base_src_slave_method_get_type (void);
+#define GST_TYPE_AUDIO_BASE_SRC_SLAVE_METHOD (gst_audio_base_src_slave_method_get_type())
+
+/* enumerations from "gstaudiocdsrc.h" */
+
+GST_AUDIO_API
+GType gst_audio_cd_src_mode_get_type (void);
+#define GST_TYPE_AUDIO_CD_SRC_MODE (gst_audio_cd_src_mode_get_type())
+
+/* enumerations from "gstaudioringbuffer.h" */
+
+GST_AUDIO_API
+GType gst_audio_ring_buffer_state_get_type (void);
+#define GST_TYPE_AUDIO_RING_BUFFER_STATE (gst_audio_ring_buffer_state_get_type())
+
+GST_AUDIO_API
+GType gst_audio_ring_buffer_format_type_get_type (void);
+#define GST_TYPE_AUDIO_RING_BUFFER_FORMAT_TYPE (gst_audio_ring_buffer_format_type_get_type())
+
+G_END_DECLS
+
+/* Generated data ends here */
+
diff --git a/include/gst/audio/audio-format.h b/include/gst/audio/audio-format.h
new file mode 100644
index 0000000000..15e970fd44
--- /dev/null
+++ b/include/gst/audio/audio-format.h
@@ -0,0 +1,412 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Library <2001> Thomas Vander Stichele <thomas@apestaart.org>
+ * <2011> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_FORMAT_H__
+#define __GST_AUDIO_FORMAT_H__
+
+G_BEGIN_DECLS
+
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+#define _GST_AUDIO_FORMAT_NE(fmt) GST_AUDIO_FORMAT_ ## fmt ## BE
+#define _GST_AUDIO_FORMAT_OE(fmt) GST_AUDIO_FORMAT_ ## fmt ## LE
+#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define _GST_AUDIO_FORMAT_NE(fmt) GST_AUDIO_FORMAT_ ## fmt ## LE
+#define _GST_AUDIO_FORMAT_OE(fmt) GST_AUDIO_FORMAT_ ## fmt ## BE
+#endif
+
+/**
+ * GstAudioFormat:
+ * @GST_AUDIO_FORMAT_UNKNOWN: unknown or unset audio format
+ * @GST_AUDIO_FORMAT_ENCODED: encoded audio format
+ * @GST_AUDIO_FORMAT_S8: 8 bits in 8 bits, signed
+ * @GST_AUDIO_FORMAT_U8: 8 bits in 8 bits, unsigned
+ * @GST_AUDIO_FORMAT_S16LE: 16 bits in 16 bits, signed, little endian
+ * @GST_AUDIO_FORMAT_S16BE: 16 bits in 16 bits, signed, big endian
+ * @GST_AUDIO_FORMAT_U16LE: 16 bits in 16 bits, unsigned, little endian
+ * @GST_AUDIO_FORMAT_U16BE: 16 bits in 16 bits, unsigned, big endian
+ * @GST_AUDIO_FORMAT_S24_32LE: 24 bits in 32 bits, signed, little endian
+ * @GST_AUDIO_FORMAT_S24_32BE: 24 bits in 32 bits, signed, big endian
+ * @GST_AUDIO_FORMAT_U24_32LE: 24 bits in 32 bits, unsigned, little endian
+ * @GST_AUDIO_FORMAT_U24_32BE: 24 bits in 32 bits, unsigned, big endian
+ * @GST_AUDIO_FORMAT_S32LE: 32 bits in 32 bits, signed, little endian
+ * @GST_AUDIO_FORMAT_S32BE: 32 bits in 32 bits, signed, big endian
+ * @GST_AUDIO_FORMAT_U32LE: 32 bits in 32 bits, unsigned, little endian
+ * @GST_AUDIO_FORMAT_U32BE: 32 bits in 32 bits, unsigned, big endian
+ * @GST_AUDIO_FORMAT_S24LE: 24 bits in 24 bits, signed, little endian
+ * @GST_AUDIO_FORMAT_S24BE: 24 bits in 24 bits, signed, big endian
+ * @GST_AUDIO_FORMAT_U24LE: 24 bits in 24 bits, unsigned, little endian
+ * @GST_AUDIO_FORMAT_U24BE: 24 bits in 24 bits, unsigned, big endian
+ * @GST_AUDIO_FORMAT_S20LE: 20 bits in 24 bits, signed, little endian
+ * @GST_AUDIO_FORMAT_S20BE: 20 bits in 24 bits, signed, big endian
+ * @GST_AUDIO_FORMAT_U20LE: 20 bits in 24 bits, unsigned, little endian
+ * @GST_AUDIO_FORMAT_U20BE: 20 bits in 24 bits, unsigned, big endian
+ * @GST_AUDIO_FORMAT_S18LE: 18 bits in 24 bits, signed, little endian
+ * @GST_AUDIO_FORMAT_S18BE: 18 bits in 24 bits, signed, big endian
+ * @GST_AUDIO_FORMAT_U18LE: 18 bits in 24 bits, unsigned, little endian
+ * @GST_AUDIO_FORMAT_U18BE: 18 bits in 24 bits, unsigned, big endian
+ * @GST_AUDIO_FORMAT_F32LE: 32-bit floating point samples, little endian
+ * @GST_AUDIO_FORMAT_F32BE: 32-bit floating point samples, big endian
+ * @GST_AUDIO_FORMAT_F64LE: 64-bit floating point samples, little endian
+ * @GST_AUDIO_FORMAT_F64BE: 64-bit floating point samples, big endian
+ * @GST_AUDIO_FORMAT_S16: 16 bits in 16 bits, signed, native endianness
+ * @GST_AUDIO_FORMAT_U16: 16 bits in 16 bits, unsigned, native endianness
+ * @GST_AUDIO_FORMAT_S24_32: 24 bits in 32 bits, signed, native endianness
+ * @GST_AUDIO_FORMAT_U24_32: 24 bits in 32 bits, unsigned, native endianness
+ * @GST_AUDIO_FORMAT_S32: 32 bits in 32 bits, signed, native endianness
+ * @GST_AUDIO_FORMAT_U32: 32 bits in 32 bits, unsigned, native endianness
+ * @GST_AUDIO_FORMAT_S24: 24 bits in 24 bits, signed, native endianness
+ * @GST_AUDIO_FORMAT_U24: 24 bits in 24 bits, unsigned, native endianness
+ * @GST_AUDIO_FORMAT_S20: 20 bits in 24 bits, signed, native endianness
+ * @GST_AUDIO_FORMAT_U20: 20 bits in 24 bits, unsigned, native endianness
+ * @GST_AUDIO_FORMAT_S18: 18 bits in 24 bits, signed, native endianness
+ * @GST_AUDIO_FORMAT_U18: 18 bits in 24 bits, unsigned, native endianness
+ * @GST_AUDIO_FORMAT_F32: 32-bit floating point samples, native endianness
+ * @GST_AUDIO_FORMAT_F64: 64-bit floating point samples, native endianness
+ *
+ * Enum value describing the most common audio formats.
+ */
+typedef enum {
+ GST_AUDIO_FORMAT_UNKNOWN,
+ GST_AUDIO_FORMAT_ENCODED,
+ /* 8 bit */
+ GST_AUDIO_FORMAT_S8,
+ GST_AUDIO_FORMAT_U8,
+ /* 16 bit */
+ GST_AUDIO_FORMAT_S16LE,
+ GST_AUDIO_FORMAT_S16BE,
+ GST_AUDIO_FORMAT_U16LE,
+ GST_AUDIO_FORMAT_U16BE,
+ /* 24 bit in low 3 bytes of 32 bits*/
+ GST_AUDIO_FORMAT_S24_32LE,
+ GST_AUDIO_FORMAT_S24_32BE,
+ GST_AUDIO_FORMAT_U24_32LE,
+ GST_AUDIO_FORMAT_U24_32BE,
+ /* 32 bit */
+ GST_AUDIO_FORMAT_S32LE,
+ GST_AUDIO_FORMAT_S32BE,
+ GST_AUDIO_FORMAT_U32LE,
+ GST_AUDIO_FORMAT_U32BE,
+ /* 24 bit in 3 bytes*/
+ GST_AUDIO_FORMAT_S24LE,
+ GST_AUDIO_FORMAT_S24BE,
+ GST_AUDIO_FORMAT_U24LE,
+ GST_AUDIO_FORMAT_U24BE,
+ /* 20 bit in 3 bytes*/
+ GST_AUDIO_FORMAT_S20LE,
+ GST_AUDIO_FORMAT_S20BE,
+ GST_AUDIO_FORMAT_U20LE,
+ GST_AUDIO_FORMAT_U20BE,
+ /* 18 bit in 3 bytes*/
+ GST_AUDIO_FORMAT_S18LE,
+ GST_AUDIO_FORMAT_S18BE,
+ GST_AUDIO_FORMAT_U18LE,
+ GST_AUDIO_FORMAT_U18BE,
+ /* float */
+ GST_AUDIO_FORMAT_F32LE,
+ GST_AUDIO_FORMAT_F32BE,
+ GST_AUDIO_FORMAT_F64LE,
+ GST_AUDIO_FORMAT_F64BE,
+ /* native endianness equivalents */
+ GST_AUDIO_FORMAT_S16 = _GST_AUDIO_FORMAT_NE(S16),
+ GST_AUDIO_FORMAT_U16 = _GST_AUDIO_FORMAT_NE(U16),
+ GST_AUDIO_FORMAT_S24_32 = _GST_AUDIO_FORMAT_NE(S24_32),
+ GST_AUDIO_FORMAT_U24_32 = _GST_AUDIO_FORMAT_NE(U24_32),
+ GST_AUDIO_FORMAT_S32 = _GST_AUDIO_FORMAT_NE(S32),
+ GST_AUDIO_FORMAT_U32 = _GST_AUDIO_FORMAT_NE(U32),
+ GST_AUDIO_FORMAT_S24 = _GST_AUDIO_FORMAT_NE(S24),
+ GST_AUDIO_FORMAT_U24 = _GST_AUDIO_FORMAT_NE(U24),
+ GST_AUDIO_FORMAT_S20 = _GST_AUDIO_FORMAT_NE(S20),
+ GST_AUDIO_FORMAT_U20 = _GST_AUDIO_FORMAT_NE(U20),
+ GST_AUDIO_FORMAT_S18 = _GST_AUDIO_FORMAT_NE(S18),
+ GST_AUDIO_FORMAT_U18 = _GST_AUDIO_FORMAT_NE(U18),
+ GST_AUDIO_FORMAT_F32 = _GST_AUDIO_FORMAT_NE(F32),
+ GST_AUDIO_FORMAT_F64 = _GST_AUDIO_FORMAT_NE(F64)
+} GstAudioFormat;
+
+
+typedef struct _GstAudioFormatInfo GstAudioFormatInfo;
+
+/**
+ * GstAudioFormatFlags:
+ * @GST_AUDIO_FORMAT_FLAG_INTEGER: integer samples
+ * @GST_AUDIO_FORMAT_FLAG_FLOAT: float samples
+ * @GST_AUDIO_FORMAT_FLAG_SIGNED: signed samples
+ * @GST_AUDIO_FORMAT_FLAG_COMPLEX: complex layout
+ * @GST_AUDIO_FORMAT_FLAG_UNPACK: the format can be used in
+ * #GstAudioFormatUnpack and #GstAudioFormatPack functions
+ *
+ * The different audio flags that a format info can have.
+ */
+typedef enum
+{
+ GST_AUDIO_FORMAT_FLAG_INTEGER = (1 << 0),
+ GST_AUDIO_FORMAT_FLAG_FLOAT = (1 << 1),
+ GST_AUDIO_FORMAT_FLAG_SIGNED = (1 << 2),
+ GST_AUDIO_FORMAT_FLAG_COMPLEX = (1 << 4),
+ GST_AUDIO_FORMAT_FLAG_UNPACK = (1 << 5)
+} GstAudioFormatFlags;
+
+/**
+ * GstAudioPackFlags:
+ * @GST_AUDIO_PACK_FLAG_NONE: No flag
+ * @GST_AUDIO_PACK_FLAG_TRUNCATE_RANGE: When the source has a smaller depth
+ * than the target format, set the least significant bits of the target
+ * to 0. This is likely slightly faster but less accurate. When this flag
+ * is not specified, the most significant bits of the source are duplicated
+ * in the least significant bits of the destination.
+ *
+ * The different flags that can be used when packing and unpacking.
+ */
+typedef enum
+{
+ GST_AUDIO_PACK_FLAG_NONE = 0,
+ GST_AUDIO_PACK_FLAG_TRUNCATE_RANGE = (1 << 0)
+} GstAudioPackFlags;
+
+/**
+ * GstAudioFormatUnpack:
+ * @info: a #GstAudioFormatInfo
+ * @flags: #GstAudioPackFlags
+ * @dest: (array) (element-type guint8): a destination array
+ * @data: (array) (element-type guint8): pointer to the audio data
+ * @length: the amount of samples to unpack.
+ *
+ * Unpacks @length samples from the given data of format @info.
+ * The samples will be unpacked into @dest which each channel
+ * interleaved. @dest should at least be big enough to hold @length *
+ * channels * size(unpack_format) bytes.
+ */
+typedef void (*GstAudioFormatUnpack) (const GstAudioFormatInfo *info,
+ GstAudioPackFlags flags, gpointer dest,
+ gconstpointer data, gint length);
+/**
+ * GstAudioFormatPack:
+ * @info: a #GstAudioFormatInfo
+ * @flags: #GstAudioPackFlags
+ * @src: (array) (element-type guint8): a source array
+ * @data: (array) (element-type guint8): pointer to the destination
+ * data
+ * @length: the amount of samples to pack.
+ *
+ * Packs @length samples from @src to the data array in format @info.
+ * The samples from source have each channel interleaved
+ * and will be packed into @data.
+ */
+typedef void (*GstAudioFormatPack) (const GstAudioFormatInfo *info,
+ GstAudioPackFlags flags, gconstpointer src,
+ gpointer data, gint length);
+
+/**
+ * GstAudioFormatInfo:
+ * @format: #GstAudioFormat
+ * @name: string representation of the format
+ * @description: user readable description of the format
+ * @flags: #GstAudioFormatFlags
+ * @endianness: the endianness
+ * @width: amount of bits used for one sample
+ * @depth: amount of valid bits in @width
+ * @silence: @width/8 bytes with 1 silent sample
+ * @unpack_format: the format of the unpacked samples
+ * @unpack_func: function to unpack samples
+ * @pack_func: function to pack samples
+ *
+ * Information for an audio format.
+ */
+struct _GstAudioFormatInfo {
+ /*< public >*/
+ GstAudioFormat format;
+ const gchar *name;
+ const gchar *description;
+ GstAudioFormatFlags flags;
+ gint endianness;
+ gint width;
+ gint depth;
+ guint8 silence[8];
+
+ GstAudioFormat unpack_format;
+ GstAudioFormatUnpack unpack_func;
+ GstAudioFormatPack pack_func;
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_format_info_get_type (void);
+
+#define GST_AUDIO_FORMAT_INFO_FORMAT(info) ((info)->format)
+#define GST_AUDIO_FORMAT_INFO_NAME(info) ((info)->name)
+#define GST_AUDIO_FORMAT_INFO_FLAGS(info) ((info)->flags)
+
+#define GST_AUDIO_FORMAT_INFO_IS_INTEGER(info) !!((info)->flags & GST_AUDIO_FORMAT_FLAG_INTEGER)
+#define GST_AUDIO_FORMAT_INFO_IS_FLOAT(info) !!((info)->flags & GST_AUDIO_FORMAT_FLAG_FLOAT)
+#define GST_AUDIO_FORMAT_INFO_IS_SIGNED(info) !!((info)->flags & GST_AUDIO_FORMAT_FLAG_SIGNED)
+
+#define GST_AUDIO_FORMAT_INFO_ENDIANNESS(info) ((info)->endianness)
+#define GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN(info) ((info)->endianness == G_LITTLE_ENDIAN)
+#define GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN(info) ((info)->endianness == G_BIG_ENDIAN)
+#define GST_AUDIO_FORMAT_INFO_WIDTH(info) ((info)->width)
+#define GST_AUDIO_FORMAT_INFO_DEPTH(info) ((info)->depth)
+
+
+GST_AUDIO_API
+GstAudioFormat gst_audio_format_build_integer (gboolean sign, gint endianness,
+ gint width, gint depth) G_GNUC_CONST;
+
+GST_AUDIO_API
+GstAudioFormat gst_audio_format_from_string (const gchar *format) G_GNUC_CONST;
+
+GST_AUDIO_API
+const gchar * gst_audio_format_to_string (GstAudioFormat format) G_GNUC_CONST;
+
+GST_AUDIO_API
+const GstAudioFormatInfo *
+ gst_audio_format_get_info (GstAudioFormat format) G_GNUC_CONST;
+
+GST_AUDIO_API
+void gst_audio_format_info_fill_silence (const GstAudioFormatInfo *info,
+ gpointer dest, gsize length);
+GST_AUDIO_API G_DEPRECATED_FOR(gst_audio_format_info_fill_silence)
+void gst_audio_format_fill_silence (const GstAudioFormatInfo *info,
+ gpointer dest, gsize length);
+
+/**
+ * GST_AUDIO_RATE_RANGE:
+ *
+ * Maximum range of allowed sample rates, for use in template caps strings.
+ */
+#define GST_AUDIO_RATE_RANGE "(int) [ 1, max ]"
+/**
+ * GST_AUDIO_CHANNELS_RANGE:
+ *
+ * Maximum range of allowed channels, for use in template caps strings.
+ */
+#define GST_AUDIO_CHANNELS_RANGE "(int) [ 1, max ]"
+
+/**
+ * GST_AUDIO_NE:
+ * @s: format string without endianness marker
+ *
+ * Turns audio format string @s into the format string for native endianness.
+ */
+/**
+ * GST_AUDIO_OE:
+ * @s: format string without endianness marker
+ *
+ * Turns audio format string @s into the format string for other endianness.
+ */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+# define GST_AUDIO_NE(s) G_STRINGIFY(s)"LE"
+# define GST_AUDIO_OE(s) G_STRINGIFY(s)"BE"
+#else
+# define GST_AUDIO_NE(s) G_STRINGIFY(s)"BE"
+# define GST_AUDIO_OE(s) G_STRINGIFY(s)"LE"
+#endif
+
+/**
+ * GST_AUDIO_FORMATS_ALL:
+ *
+ * List of all audio formats, for use in template caps strings.
+ *
+ * Formats are sorted by decreasing "quality", using these criteria by priority:
+ * - depth
+ * - width
+ * - Float > Signed > Unsigned
+ * - native endianness preferred
+ */
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+#define GST_AUDIO_FORMATS_ALL "{ F64BE, F64LE, " \
+ "F32BE, F32LE, S32BE, S32LE, U32BE, U32LE, " \
+ "S24_32BE, S24_32LE, U24_32BE, U24_32LE, " \
+ "S24BE, S24LE, U24BE, U24LE, " \
+ "S20BE, S20LE, U20BE, U20LE, " \
+ "S18BE, S18LE, U18BE, U18LE, " \
+ "S16BE, S16LE, U16BE, U16LE, " \
+ "S8, U8 }"
+#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define GST_AUDIO_FORMATS_ALL "{ F64LE, F64BE, " \
+ "F32LE, F32BE, S32LE, S32BE, U32LE, U32BE, " \
+ "S24_32LE, S24_32BE, U24_32LE, U24_32BE, " \
+ "S24LE, S24BE, U24LE, U24BE, " \
+ "S20LE, S20BE, U20LE, U20BE, " \
+ "S18LE, S18BE, U18LE, U18BE, " \
+ "S16LE, S16BE, U16LE, U16BE, " \
+ "S8, U8 }"
+#endif
+
+GST_AUDIO_API
+const GstAudioFormat * gst_audio_formats_raw (guint * len);
+
+/**
+ * GST_AUDIO_CAPS_MAKE:
+ * @format: string format that describes the sample layout, as string
+ * (e.g. "S16LE", "S8", etc.)
+ *
+ * Generic caps string for audio, for use in pad templates.
+ */
+#define GST_AUDIO_CAPS_MAKE(format) \
+ "audio/x-raw, " \
+ "format = (string) " format ", " \
+ "rate = " GST_AUDIO_RATE_RANGE ", " \
+ "channels = " GST_AUDIO_CHANNELS_RANGE
+
+/**
+ * GST_AUDIO_DEF_RATE:
+ *
+ * Standard sampling rate used in consumer audio.
+ */
+#define GST_AUDIO_DEF_RATE 44100
+/**
+ * GST_AUDIO_DEF_CHANNELS:
+ *
+ * Standard number of channels used in consumer audio.
+ */
+#define GST_AUDIO_DEF_CHANNELS 2
+/**
+ * GST_AUDIO_DEF_FORMAT:
+ *
+ * Standard format used in consumer audio.
+ */
+#define GST_AUDIO_DEF_FORMAT "S16LE"
+
+/**
+ * GstAudioLayout:
+ * @GST_AUDIO_LAYOUT_INTERLEAVED: interleaved audio
+ * @GST_AUDIO_LAYOUT_NON_INTERLEAVED: non-interleaved audio
+ *
+ * Layout of the audio samples for the different channels.
+ */
+typedef enum {
+ GST_AUDIO_LAYOUT_INTERLEAVED = 0,
+ GST_AUDIO_LAYOUT_NON_INTERLEAVED
+} GstAudioLayout;
+
+GST_AUDIO_API
+GstCaps * gst_audio_make_raw_caps (const GstAudioFormat formats[], guint len,
+ GstAudioLayout layout);
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_FORMAT_H__ */
diff --git a/include/gst/audio/audio-info.h b/include/gst/audio/audio-info.h
new file mode 100644
index 0000000000..51264b9304
--- /dev/null
+++ b/include/gst/audio/audio-info.h
@@ -0,0 +1,143 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Library <2001> Thomas Vander Stichele <thomas@apestaart.org>
+ * <2011> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_INFO_H__
+#define __GST_AUDIO_INFO_H__
+
+G_BEGIN_DECLS
+
+typedef struct _GstAudioInfo GstAudioInfo;
+
+/**
+ * GstAudioFlags:
+ * @GST_AUDIO_FLAG_NONE: no valid flag
+ * @GST_AUDIO_FLAG_UNPOSITIONED: the position array explicitly
+ * contains unpositioned channels.
+ *
+ * Extra audio flags
+ */
+typedef enum {
+ GST_AUDIO_FLAG_NONE = 0,
+ GST_AUDIO_FLAG_UNPOSITIONED = (1 << 0)
+} GstAudioFlags;
+
+/**
+ * GstAudioInfo:
+ * @finfo: the format info of the audio
+ * @flags: additional audio flags
+ * @layout: audio layout
+ * @rate: the audio sample rate
+ * @channels: the number of channels
+ * @bpf: the number of bytes for one frame, this is the size of one
+ * sample * @channels
+ * @position: the positions for each channel
+ *
+ * Information describing audio properties. This information can be filled
+ * in from GstCaps with gst_audio_info_from_caps().
+ *
+ * Use the provided macros to access the info in this structure.
+ */
+struct _GstAudioInfo {
+ const GstAudioFormatInfo *finfo;
+ GstAudioFlags flags;
+ GstAudioLayout layout;
+ gint rate;
+ gint channels;
+ gint bpf;
+ GstAudioChannelPosition position[64];
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+#define GST_TYPE_AUDIO_INFO (gst_audio_info_get_type ())
+GST_AUDIO_API
+GType gst_audio_info_get_type (void);
+
+#define GST_AUDIO_INFO_IS_VALID(i) ((i)->finfo != NULL && (i)->rate > 0 && (i)->channels > 0 && (i)->bpf > 0)
+
+#define GST_AUDIO_INFO_FORMAT(i) (GST_AUDIO_FORMAT_INFO_FORMAT((i)->finfo))
+#define GST_AUDIO_INFO_NAME(i) (GST_AUDIO_FORMAT_INFO_NAME((i)->finfo))
+#define GST_AUDIO_INFO_WIDTH(i) (GST_AUDIO_FORMAT_INFO_WIDTH((i)->finfo))
+#define GST_AUDIO_INFO_DEPTH(i) (GST_AUDIO_FORMAT_INFO_DEPTH((i)->finfo))
+#define GST_AUDIO_INFO_BPS(info) (GST_AUDIO_INFO_DEPTH(info) >> 3)
+
+#define GST_AUDIO_INFO_IS_INTEGER(i) (GST_AUDIO_FORMAT_INFO_IS_INTEGER((i)->finfo))
+#define GST_AUDIO_INFO_IS_FLOAT(i) (GST_AUDIO_FORMAT_INFO_IS_FLOAT((i)->finfo))
+#define GST_AUDIO_INFO_IS_SIGNED(i) (GST_AUDIO_FORMAT_INFO_IS_SIGNED((i)->finfo))
+
+#define GST_AUDIO_INFO_ENDIANNESS(i) (GST_AUDIO_FORMAT_INFO_ENDIANNESS((i)->finfo))
+#define GST_AUDIO_INFO_IS_LITTLE_ENDIAN(i) (GST_AUDIO_FORMAT_INFO_IS_LITTLE_ENDIAN((i)->finfo))
+#define GST_AUDIO_INFO_IS_BIG_ENDIAN(i) (GST_AUDIO_FORMAT_INFO_IS_BIG_ENDIAN((i)->finfo))
+
+#define GST_AUDIO_INFO_FLAGS(info) ((info)->flags)
+#define GST_AUDIO_INFO_IS_UNPOSITIONED(info) (((info)->flags & GST_AUDIO_FLAG_UNPOSITIONED) != 0)
+#define GST_AUDIO_INFO_LAYOUT(info) ((info)->layout)
+
+#define GST_AUDIO_INFO_RATE(info) ((info)->rate)
+#define GST_AUDIO_INFO_CHANNELS(info) ((info)->channels)
+#define GST_AUDIO_INFO_BPF(info) ((info)->bpf)
+#define GST_AUDIO_INFO_POSITION(info,c) ((info)->position[c])
+
+GST_AUDIO_API
+GstAudioInfo * gst_audio_info_new (void);
+
+GST_AUDIO_API
+GstAudioInfo * gst_audio_info_new_from_caps (const GstCaps * caps);
+
+GST_AUDIO_API
+void gst_audio_info_init (GstAudioInfo *info);
+
+GST_AUDIO_API
+GstAudioInfo * gst_audio_info_copy (const GstAudioInfo *info);
+
+GST_AUDIO_API
+void gst_audio_info_free (GstAudioInfo *info);
+
+GST_AUDIO_API
+void gst_audio_info_set_format (GstAudioInfo *info, GstAudioFormat format,
+ gint rate, gint channels,
+ const GstAudioChannelPosition *position);
+
+GST_AUDIO_API
+gboolean gst_audio_info_from_caps (GstAudioInfo *info, const GstCaps *caps);
+
+GST_AUDIO_API
+GstCaps * gst_audio_info_to_caps (const GstAudioInfo *info);
+
+GST_AUDIO_API
+gboolean gst_audio_info_convert (const GstAudioInfo * info,
+ GstFormat src_fmt, gint64 src_val,
+ GstFormat dest_fmt, gint64 * dest_val);
+
+GST_AUDIO_API
+gboolean gst_audio_info_is_equal (const GstAudioInfo *info,
+ const GstAudioInfo *other);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioInfo, gst_audio_info_free)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_INFO_H__ */
diff --git a/include/gst/audio/audio-prelude.h b/include/gst/audio/audio-prelude.h
new file mode 100644
index 0000000000..b006a06ced
--- /dev/null
+++ b/include/gst/audio/audio-prelude.h
@@ -0,0 +1,33 @@
+/* GStreamer Audio Library
+ * Copyright (C) 2018 GStreamer developers
+ *
+ * audio-prelude.h: prelude include header for gst-audio library
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_PRELUDE_H__
+#define __GST_AUDIO_PRELUDE_H__
+
+#include <gst/gst.h>
+
+#ifdef BUILDING_GST_AUDIO
+#define GST_AUDIO_API GST_API_EXPORT /* from config.h */
+#else
+#define GST_AUDIO_API GST_API_IMPORT
+#endif
+
+#endif /* __GST_AUDIO_PRELUDE_H__ */
diff --git a/include/gst/audio/audio-quantize.h b/include/gst/audio/audio-quantize.h
new file mode 100644
index 0000000000..2944b4b918
--- /dev/null
+++ b/include/gst/audio/audio-quantize.h
@@ -0,0 +1,103 @@
+/* GStreamer
+ * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
+ * (C) 2015 Wim Taymans <wim.taymans@gmail.com>
+ *
+ * gstaudioquantize.h: quantizes audio to the target format and optionally
+ * applies dithering and noise shaping.
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gst/gst.h>
+
+#include <gst/audio/audio.h>
+
+
+#ifndef __GST_AUDIO_QUANTIZE_H__
+#define __GST_AUDIO_QUANTIZE_H__
+
+/**
+ * GstAudioDitherMethod:
+ * @GST_AUDIO_DITHER_NONE: No dithering
+ * @GST_AUDIO_DITHER_RPDF: Rectangular dithering
+ * @GST_AUDIO_DITHER_TPDF: Triangular dithering (default)
+ * @GST_AUDIO_DITHER_TPDF_HF: High frequency triangular dithering
+ *
+ * Set of available dithering methods.
+ */
+typedef enum
+{
+ GST_AUDIO_DITHER_NONE = 0,
+ GST_AUDIO_DITHER_RPDF,
+ GST_AUDIO_DITHER_TPDF,
+ GST_AUDIO_DITHER_TPDF_HF
+} GstAudioDitherMethod;
+
+/**
+ * GstAudioNoiseShapingMethod:
+ * @GST_AUDIO_NOISE_SHAPING_NONE: No noise shaping (default)
+ * @GST_AUDIO_NOISE_SHAPING_ERROR_FEEDBACK: Error feedback
+ * @GST_AUDIO_NOISE_SHAPING_SIMPLE: Simple 2-pole noise shaping
+ * @GST_AUDIO_NOISE_SHAPING_MEDIUM: Medium 5-pole noise shaping
+ * @GST_AUDIO_NOISE_SHAPING_HIGH: High 8-pole noise shaping
+ *
+ * Set of available noise shaping methods
+ */
+typedef enum
+{
+ GST_AUDIO_NOISE_SHAPING_NONE = 0,
+ GST_AUDIO_NOISE_SHAPING_ERROR_FEEDBACK,
+ GST_AUDIO_NOISE_SHAPING_SIMPLE,
+ GST_AUDIO_NOISE_SHAPING_MEDIUM,
+ GST_AUDIO_NOISE_SHAPING_HIGH
+} GstAudioNoiseShapingMethod;
+
+/**
+ * GstAudioQuantizeFlags:
+ * @GST_AUDIO_QUANTIZE_FLAG_NONE: no flags
+ * @GST_AUDIO_QUANTIZE_FLAG_NON_INTERLEAVED: samples are non-interleaved
+ *
+ * Extra flags that can be passed to gst_audio_quantize_new()
+ */
+typedef enum
+{
+ GST_AUDIO_QUANTIZE_FLAG_NONE = 0,
+ GST_AUDIO_QUANTIZE_FLAG_NON_INTERLEAVED = (1 << 0)
+} GstAudioQuantizeFlags;
+
+
+typedef struct _GstAudioQuantize GstAudioQuantize;
+
+GST_AUDIO_API
+GstAudioQuantize * gst_audio_quantize_new (GstAudioDitherMethod dither,
+ GstAudioNoiseShapingMethod ns,
+ GstAudioQuantizeFlags flags,
+ GstAudioFormat format,
+ guint channels,
+ guint quantizer);
+
+GST_AUDIO_API
+void gst_audio_quantize_free (GstAudioQuantize * quant);
+
+GST_AUDIO_API
+void gst_audio_quantize_reset (GstAudioQuantize * quant);
+
+GST_AUDIO_API
+void gst_audio_quantize_samples (GstAudioQuantize * quant,
+ const gpointer in[],
+ gpointer out[], guint samples);
+
+#endif /* __GST_AUDIO_QUANTIZE_H__ */
diff --git a/include/gst/audio/audio-resampler.h b/include/gst/audio/audio-resampler.h
new file mode 100644
index 0000000000..3fa3d7bc08
--- /dev/null
+++ b/include/gst/audio/audio-resampler.h
@@ -0,0 +1,259 @@
+/* GStreamer
+ * Copyright (C) <2015> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_RESAMPLER_H__
+#define __GST_AUDIO_RESAMPLER_H__
+
+#include <gst/gst.h>
+#include <gst/audio/audio.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GstAudioResampler:
+ *
+ * Opaque #GstAudioResampler struct.
+ *
+ * Since: 1.10
+ */
+typedef struct _GstAudioResampler GstAudioResampler;
+
+/**
+ * GST_AUDIO_RESAMPLER_OPT_CUTOFF:
+ *
+ * G_TYPE_DOUBLE, Cutoff parameter for the filter. 0.940 is the default.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_CUTOFF "GstAudioResampler.cutoff"
+/**
+ * GST_AUDIO_RESAMPLER_OPT_STOP_ATTENUATION:
+ *
+ * G_TYPE_DOUBLE, stopband attenuation in decibels. The attenuation
+ * after the stopband for the kaiser window. 85 dB is the default.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_STOP_ATTENUATION "GstAudioResampler.stop-attenutation"
+/**
+ * GST_AUDIO_RESAMPLER_OPT_TRANSITION_BANDWIDTH:
+ *
+ * G_TYPE_DOUBLE, transition bandwidth. The width of the
+ * transition band for the kaiser window. 0.087 is the default.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_TRANSITION_BANDWIDTH "GstAudioResampler.transition-bandwidth"
+
+/**
+ * GST_AUDIO_RESAMPLER_OPT_CUBIC_B:
+ *
+ * G_TYPE_DOUBLE, B parameter of the cubic filter.
+ * Values between 0.0 and 2.0 are accepted. 1.0 is the default.
+ *
+ * Below are some values of popular filters:
+ * B C
+ * Hermite 0.0 0.0
+ * Spline 1.0 0.0
+ * Catmull-Rom 0.0 1/2
+ */
+#define GST_AUDIO_RESAMPLER_OPT_CUBIC_B "GstAudioResampler.cubic-b"
+/**
+ * GST_AUDIO_RESAMPLER_OPT_CUBIC_C:
+ *
+ * G_TYPE_DOUBLE, C parameter of the cubic filter.
+ * Values between 0.0 and 2.0 are accepted. 0.0 is the default.
+ *
+ * See #GST_AUDIO_RESAMPLER_OPT_CUBIC_B for some more common values
+ */
+#define GST_AUDIO_RESAMPLER_OPT_CUBIC_C "GstAudioResampler.cubic-c"
+
+/**
+ * GST_AUDIO_RESAMPLER_OPT_N_TAPS:
+ *
+ * G_TYPE_INT: the number of taps to use for the filter.
+ * 0 is the default and selects the taps automatically.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_N_TAPS "GstAudioResampler.n-taps"
+
+/**
+ * GstAudioResamplerFilterMode:
+ * @GST_AUDIO_RESAMPLER_FILTER_MODE_INTERPOLATED: Use interpolated filter tables. This
+ * uses less memory but more CPU and is slightly less accurate but it allows for more
+ * efficient variable rate resampling with gst_audio_resampler_update().
+ * @GST_AUDIO_RESAMPLER_FILTER_MODE_FULL: Use full filter table. This uses more memory
+ * but less CPU.
+ * @GST_AUDIO_RESAMPLER_FILTER_MODE_AUTO: Automatically choose between interpolated
+ * and full filter tables.
+ *
+ * Select for the filter tables should be set up.
+ *
+ * Since: 1.10
+ */
+typedef enum {
+ GST_AUDIO_RESAMPLER_FILTER_MODE_INTERPOLATED = (0),
+ GST_AUDIO_RESAMPLER_FILTER_MODE_FULL,
+ GST_AUDIO_RESAMPLER_FILTER_MODE_AUTO,
+} GstAudioResamplerFilterMode;
+/**
+ * GST_AUDIO_RESAMPLER_OPT_FILTER_MODE:
+ *
+ * GST_TYPE_AUDIO_RESAMPLER_FILTER_MODE: how the filter tables should be
+ * constructed.
+ * GST_AUDIO_RESAMPLER_FILTER_MODE_AUTO is the default.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_FILTER_MODE "GstAudioResampler.filter-mode"
+/**
+ * GST_AUDIO_RESAMPLER_OPT_FILTER_MODE_THRESHOLD:
+ *
+ * G_TYPE_UINT: the amount of memory to use for full filter tables before
+ * switching to interpolated filter tables.
+ * 1048576 is the default.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_FILTER_MODE_THRESHOLD "GstAudioResampler.filter-mode-threshold"
+
+/**
+ * GstAudioResamplerFilterInterpolation:
+ * @GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_NONE: no interpolation
+ * @GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_LINEAR: linear interpolation of the
+ * filter coefficients.
+ * @GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_CUBIC: cubic interpolation of the
+ * filter coefficients.
+ *
+ * The different filter interpolation methods.
+ *
+ * Since: 1.10
+ */
+typedef enum {
+ GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_NONE = (0),
+ GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_LINEAR,
+ GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_CUBIC,
+} GstAudioResamplerFilterInterpolation;
+/**
+ * GST_AUDIO_RESAMPLER_OPT_FILTER_INTERPOLATION:
+ *
+ * GST_TYPE_AUDIO_RESAMPLER_INTERPOLATION: how the filter coefficients should be
+ * interpolated.
+ * GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_CUBIC is default.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_FILTER_INTERPOLATION "GstAudioResampler.filter-interpolation"
+/**
+ * GST_AUDIO_RESAMPLER_OPT_FILTER_OVERSAMPLE:
+ *
+ * G_TYPE_UINT, oversampling to use when interpolating filters
+ * 8 is the default.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_FILTER_OVERSAMPLE "GstAudioResampler.filter-oversample"
+
+/**
+ * GST_AUDIO_RESAMPLER_OPT_MAX_PHASE_ERROR:
+ *
+ * G_TYPE_DOUBLE: The maximum allowed phase error when switching sample
+ * rates.
+ * 0.1 is the default.
+ */
+#define GST_AUDIO_RESAMPLER_OPT_MAX_PHASE_ERROR "GstAudioResampler.max-phase-error"
+
+/**
+ * GstAudioResamplerMethod:
+ * @GST_AUDIO_RESAMPLER_METHOD_NEAREST: Duplicates the samples when
+ * upsampling and drops when downsampling
+ * @GST_AUDIO_RESAMPLER_METHOD_LINEAR: Uses linear interpolation to reconstruct
+ * missing samples and averaging to downsample
+ * @GST_AUDIO_RESAMPLER_METHOD_CUBIC: Uses cubic interpolation
+ * @GST_AUDIO_RESAMPLER_METHOD_BLACKMAN_NUTTALL: Uses Blackman-Nuttall windowed sinc interpolation
+ * @GST_AUDIO_RESAMPLER_METHOD_KAISER: Uses Kaiser windowed sinc interpolation
+ *
+ * Different subsampling and upsampling methods
+ *
+ * Since: 1.10
+ */
+typedef enum {
+ GST_AUDIO_RESAMPLER_METHOD_NEAREST,
+ GST_AUDIO_RESAMPLER_METHOD_LINEAR,
+ GST_AUDIO_RESAMPLER_METHOD_CUBIC,
+ GST_AUDIO_RESAMPLER_METHOD_BLACKMAN_NUTTALL,
+ GST_AUDIO_RESAMPLER_METHOD_KAISER
+} GstAudioResamplerMethod;
+
+/**
+ * GstAudioResamplerFlags:
+ * @GST_AUDIO_RESAMPLER_FLAG_NONE: no flags
+ * @GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_IN: input samples are non-interleaved.
+ * an array of blocks of samples, one for each channel, should be passed to the
+ * resample function.
+ * @GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_OUT: output samples are non-interleaved.
+ * an array of blocks of samples, one for each channel, should be passed to the
+ * resample function.
+ * @GST_AUDIO_RESAMPLER_FLAG_VARIABLE_RATE: optimize for dynamic updates of the sample
+ * rates with gst_audio_resampler_update(). This will select an interpolating filter
+ * when #GST_AUDIO_RESAMPLER_FILTER_MODE_AUTO is configured.
+ *
+ * Different resampler flags.
+ *
+ * Since: 1.10
+ */
+typedef enum {
+ GST_AUDIO_RESAMPLER_FLAG_NONE = (0),
+ GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_IN = (1 << 0),
+ GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_OUT = (1 << 1),
+ GST_AUDIO_RESAMPLER_FLAG_VARIABLE_RATE = (1 << 2),
+} GstAudioResamplerFlags;
+
+#define GST_AUDIO_RESAMPLER_QUALITY_MIN 0
+#define GST_AUDIO_RESAMPLER_QUALITY_MAX 10
+#define GST_AUDIO_RESAMPLER_QUALITY_DEFAULT 4
+
+GST_AUDIO_API
+void gst_audio_resampler_options_set_quality (GstAudioResamplerMethod method,
+ guint quality,
+ gint in_rate, gint out_rate,
+ GstStructure *options);
+
+GST_AUDIO_API
+GstAudioResampler * gst_audio_resampler_new (GstAudioResamplerMethod method,
+ GstAudioResamplerFlags flags,
+ GstAudioFormat format, gint channels,
+ gint in_rate, gint out_rate,
+ GstStructure *options);
+
+GST_AUDIO_API
+void gst_audio_resampler_free (GstAudioResampler *resampler);
+
+GST_AUDIO_API
+void gst_audio_resampler_reset (GstAudioResampler *resampler);
+
+GST_AUDIO_API
+gboolean gst_audio_resampler_update (GstAudioResampler *resampler,
+ gint in_rate, gint out_rate,
+ GstStructure *options);
+
+GST_AUDIO_API
+gsize gst_audio_resampler_get_out_frames (GstAudioResampler *resampler,
+ gsize in_frames);
+
+GST_AUDIO_API
+gsize gst_audio_resampler_get_in_frames (GstAudioResampler *resampler,
+ gsize out_frames);
+
+GST_AUDIO_API
+gsize gst_audio_resampler_get_max_latency (GstAudioResampler *resampler);
+
+GST_AUDIO_API
+void gst_audio_resampler_resample (GstAudioResampler * resampler,
+ gpointer in[], gsize in_frames,
+ gpointer out[], gsize out_frames);
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_RESAMPLER_H__ */
diff --git a/include/gst/audio/audio.h b/include/gst/audio/audio.h
new file mode 100644
index 0000000000..a0aa8a6031
--- /dev/null
+++ b/include/gst/audio/audio.h
@@ -0,0 +1,120 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Library <2001> Thomas Vander Stichele <thomas@apestaart.org>
+ * <2011> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#define __GST_AUDIO_AUDIO_H__
+
+#include <gst/gst.h>
+#include <gst/audio/audio-prelude.h>
+#include <gst/audio/audio-enumtypes.h>
+#include <gst/audio/audio-format.h>
+#include <gst/audio/audio-channels.h>
+#include <gst/audio/audio-channel-mixer.h>
+#include <gst/audio/audio-info.h>
+#include <gst/audio/audio-buffer.h>
+#include <gst/audio/audio-quantize.h>
+#include <gst/audio/audio-converter.h>
+#include <gst/audio/audio-resampler.h>
+#include <gst/audio/gstaudiostreamalign.h>
+#include <gst/audio/gstaudioaggregator.h>
+
+G_BEGIN_DECLS
+
+/* conversion macros */
+/**
+ * GST_FRAMES_TO_CLOCK_TIME:
+ * @frames: sample frames
+ * @rate: sampling rate
+ *
+ * Calculate clocktime from sample @frames and @rate.
+ */
+#define GST_FRAMES_TO_CLOCK_TIME(frames, rate) \
+ ((GstClockTime) gst_util_uint64_scale_round (frames, GST_SECOND, rate))
+
+/**
+ * GST_CLOCK_TIME_TO_FRAMES:
+ * @clocktime: clock time
+ * @rate: sampling rate
+ *
+ * Calculate frames from @clocktime and sample @rate.
+ */
+#define GST_CLOCK_TIME_TO_FRAMES(clocktime, rate) \
+ gst_util_uint64_scale_round (clocktime, rate, GST_SECOND)
+
+/* metadata macros */
+
+/**
+ * GST_META_TAG_AUDIO_STR:
+ *
+ * This metadata is relevant for audio streams.
+ *
+ * Since: 1.2
+ */
+#define GST_META_TAG_AUDIO_STR "audio"
+/**
+ * GST_META_TAG_AUDIO_CHANNELS_STR:
+ *
+ * This metadata stays relevant as long as channels are unchanged.
+ *
+ * Since: 1.2
+ */
+#define GST_META_TAG_AUDIO_CHANNELS_STR "channels"
+
+/**
+ * GST_META_TAG_AUDIO_RATE_STR:
+ *
+ * This metadata stays relevant as long as sample rate is unchanged.
+ *
+ * Since: 1.8
+ */
+#define GST_META_TAG_AUDIO_RATE_STR "rate"
+
+/*
+ * this library defines and implements some helper functions for audio
+ * handling
+ */
+
+GST_AUDIO_API
+GstBuffer * gst_audio_buffer_clip (GstBuffer *buffer,
+ const GstSegment *segment,
+ gint rate, gint bpf);
+
+GST_AUDIO_API
+GstBuffer * gst_audio_buffer_truncate (GstBuffer *buffer,
+ gint bpf, gsize trim, gsize samples);
+
+G_END_DECLS
+
+#include <gst/audio/gstaudioringbuffer.h>
+#include <gst/audio/gstaudioclock.h>
+#include <gst/audio/gstaudiofilter.h>
+#include <gst/audio/gstaudiocdsrc.h>
+#include <gst/audio/gstaudiodecoder.h>
+#include <gst/audio/gstaudioencoder.h>
+#include <gst/audio/gstaudiobasesink.h>
+#include <gst/audio/gstaudiobasesrc.h>
+#include <gst/audio/gstaudiometa.h>
+#include <gst/audio/gstaudiosink.h>
+#include <gst/audio/gstaudiosrc.h>
+#include <gst/audio/streamvolume.h>
+#include <gst/audio/gstaudioiec61937.h>
+
+#endif /* __GST_AUDIO_AUDIO_H__ */
diff --git a/include/gst/audio/gstaudioaggregator.h b/include/gst/audio/gstaudioaggregator.h
new file mode 100644
index 0000000000..2184f54b4c
--- /dev/null
+++ b/include/gst/audio/gstaudioaggregator.h
@@ -0,0 +1,232 @@
+/* GStreamer
+ * Copyright (C) 2014 Collabora
+ * Author: Olivier Crete <olivier.crete@collabora.com>
+ *
+ * gstaudioaggregator.h:
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AGGREGATOR_H__
+#define __GST_AUDIO_AGGREGATOR_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstaggregator.h>
+#include <gst/audio/audio.h>
+
+G_BEGIN_DECLS
+
+/*******************************
+ * GstAudioAggregator Structs *
+ *******************************/
+
+typedef struct _GstAudioAggregator GstAudioAggregator;
+typedef struct _GstAudioAggregatorPrivate GstAudioAggregatorPrivate;
+typedef struct _GstAudioAggregatorClass GstAudioAggregatorClass;
+
+
+/************************
+ * GstAudioAggregatorPad API *
+ ***********************/
+
+#define GST_TYPE_AUDIO_AGGREGATOR_PAD (gst_audio_aggregator_pad_get_type())
+#define GST_AUDIO_AGGREGATOR_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPad))
+#define GST_AUDIO_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPadClass))
+#define GST_AUDIO_AGGREGATOR_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD, GstAudioAggregatorPadClass))
+#define GST_IS_AUDIO_AGGREGATOR_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_PAD))
+#define GST_IS_AUDIO_AGGREGATOR_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_PAD))
+
+/****************************
+ * GstAudioAggregatorPad Structs *
+ ***************************/
+
+typedef struct _GstAudioAggregatorPad GstAudioAggregatorPad;
+typedef struct _GstAudioAggregatorPadClass GstAudioAggregatorPadClass;
+typedef struct _GstAudioAggregatorPadPrivate GstAudioAggregatorPadPrivate;
+
+/**
+ * GstAudioAggregatorPad:
+ * @info: The audio info for this pad set from the incoming caps
+ *
+ * The default implementation of GstPad used with #GstAudioAggregator
+ *
+ * Since: 1.14
+ */
+struct _GstAudioAggregatorPad
+{
+ GstAggregatorPad parent;
+
+ /*< public >*/
+ /* read-only, with OBJECT_LOCK */
+ GstAudioInfo info;
+
+ /*< private >*/
+ GstAudioAggregatorPadPrivate *priv;
+
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+/**
+ * GstAudioAggregatorPadClass:
+ * @convert_buffer: Convert a buffer from one format to another.
+ * @update_conversion_info: Called when either the input or output
+ * formats have changed.
+ *
+ * Since: 1.14
+ */
+struct _GstAudioAggregatorPadClass
+ {
+ GstAggregatorPadClass parent_class;
+
+ GstBuffer * (* convert_buffer) (GstAudioAggregatorPad * pad,
+ GstAudioInfo *in_info,
+ GstAudioInfo *out_info,
+ GstBuffer * buffer);
+
+ void (* update_conversion_info) (GstAudioAggregatorPad *pad);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING_LARGE];
+};
+
+GST_AUDIO_API
+GType gst_audio_aggregator_pad_get_type (void);
+
+#define GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD (gst_audio_aggregator_convert_pad_get_type())
+#define GST_AUDIO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPad))
+#define GST_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass))
+#define GST_AUDIO_AGGREGATOR_CONVERT_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD, GstAudioAggregatorConvertPadClass))
+#define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD))
+#define GST_IS_AUDIO_AGGREGATOR_CONVERT_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR_CONVERT_PAD))
+
+/****************************
+ * GstAudioAggregatorPad Structs *
+ ***************************/
+
+typedef struct _GstAudioAggregatorConvertPad GstAudioAggregatorConvertPad;
+typedef struct _GstAudioAggregatorConvertPadClass GstAudioAggregatorConvertPadClass;
+typedef struct _GstAudioAggregatorConvertPadPrivate GstAudioAggregatorConvertPadPrivate;
+
+/**
+ * GstAudioAggregatorConvertPad:
+ *
+ * An implementation of GstPad that can be used with #GstAudioAggregator.
+ *
+ * See #GstAudioAggregator for more details.
+ *
+ * Since: 1.14
+ */
+struct _GstAudioAggregatorConvertPad
+{
+ /*< private >*/
+ GstAudioAggregatorPad parent;
+
+ GstAudioAggregatorConvertPadPrivate *priv;
+
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+/**
+ * GstAudioAggregatorConvertPadClass:
+ *
+ * Since: 1.14
+ */
+struct _GstAudioAggregatorConvertPadClass
+{
+ GstAudioAggregatorPadClass parent_class;
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_aggregator_convert_pad_get_type (void);
+
+/**************************
+ * GstAudioAggregator API *
+ **************************/
+
+#define GST_TYPE_AUDIO_AGGREGATOR (gst_audio_aggregator_get_type())
+#define GST_AUDIO_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregator))
+#define GST_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass))
+#define GST_AUDIO_AGGREGATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_AGGREGATOR,GstAudioAggregatorClass))
+#define GST_IS_AUDIO_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_AGGREGATOR))
+#define GST_IS_AUDIO_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_AGGREGATOR))
+
+/**
+ * GstAudioAggregator:
+ * @current_caps: The caps set by the subclass
+ *
+ * GstAudioAggregator object
+ *
+ * Since: 1.14
+ */
+struct _GstAudioAggregator
+{
+ GstAggregator parent;
+
+ /*< public >*/
+ GstCaps *current_caps;
+
+ /*< private >*/
+ GstAudioAggregatorPrivate *priv;
+
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+/**
+ * GstAudioAggregatorClass:
+ * @create_output_buffer: Create a new output buffer contains num_frames frames.
+ * @aggregate_one_buffer: Aggregates one input buffer to the output
+ * buffer. The in_offset and out_offset are in "frames", which is
+ * the size of a sample times the number of channels. Returns TRUE if
+ * any non-silence was added to the buffer
+ *
+ * Since: 1.14
+ */
+struct _GstAudioAggregatorClass {
+ GstAggregatorClass parent_class;
+
+ /*< public >*/
+ GstBuffer * (* create_output_buffer) (GstAudioAggregator * aagg,
+ guint num_frames);
+ gboolean (* aggregate_one_buffer) (GstAudioAggregator * aagg,
+ GstAudioAggregatorPad * pad, GstBuffer * inbuf, guint in_offset,
+ GstBuffer * outbuf, guint out_offset, guint num_frames);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING_LARGE];
+};
+
+/*************************
+ * GstAggregator methods *
+ ************************/
+
+GST_AUDIO_API
+GType gst_audio_aggregator_get_type(void);
+
+GST_AUDIO_API
+void gst_audio_aggregator_set_sink_caps (GstAudioAggregator * aagg,
+ GstAudioAggregatorPad * pad,
+ GstCaps * caps);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioAggregator, gst_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioAggregatorPad, gst_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioAggregatorConvertPad, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_AGGREGATOR_H__ */
diff --git a/include/gst/audio/gstaudiobasesink.h b/include/gst/audio/gstaudiobasesink.h
new file mode 100644
index 0000000000..883ed6ecef
--- /dev/null
+++ b/include/gst/audio/gstaudiobasesink.h
@@ -0,0 +1,277 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2005 Wim Taymans <wim@fluendo.com>
+ *
+ * gstaudiobasesink.h:
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* a base class for audio sinks.
+ *
+ * It uses a ringbuffer to schedule playback of samples. This makes
+ * it very easy to drop or insert samples to align incoming
+ * buffers to the exact playback timestamp.
+ *
+ * Subclasses must provide a ringbuffer pointing to either DMA
+ * memory or regular memory. A subclass should also call a callback
+ * function when it has played N segments in the buffer. The subclass
+ * is free to use a thread to signal this callback, use EIO or any
+ * other mechanism.
+ *
+ * The base class is able to operate in push or pull mode. The chain
+ * mode will queue the samples in the ringbuffer as much as possible.
+ * The available space is calculated in the callback function.
+ *
+ * The pull mode will pull_range() a new buffer of N samples with a
+ * configurable latency. This allows for high-end real time
+ * audio processing pipelines driven by the audiosink. The callback
+ * function will be used to perform a pull_range() on the sinkpad.
+ * The thread scheduling the callback can be a real-time thread.
+ *
+ * Subclasses must implement a GstAudioRingBuffer in addition to overriding
+ * the methods in GstBaseSink and this class.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_BASE_SINK_H__
+#define __GST_AUDIO_BASE_SINK_H__
+
+#include <gst/base/gstbasesink.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_BASE_SINK (gst_audio_base_sink_get_type())
+#define GST_AUDIO_BASE_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_BASE_SINK,GstAudioBaseSink))
+#define GST_AUDIO_BASE_SINK_CAST(obj) ((GstAudioBaseSink*)obj)
+#define GST_AUDIO_BASE_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_BASE_SINK,GstAudioBaseSinkClass))
+#define GST_AUDIO_BASE_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_BASE_SINK, GstAudioBaseSinkClass))
+#define GST_IS_AUDIO_BASE_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_BASE_SINK))
+#define GST_IS_AUDIO_BASE_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_BASE_SINK))
+
+/**
+ * GST_AUDIO_BASE_SINK_CLOCK:
+ * @obj: a #GstAudioBaseSink
+ *
+ * Get the #GstClock of @obj.
+ */
+#define GST_AUDIO_BASE_SINK_CLOCK(obj) (GST_AUDIO_BASE_SINK (obj)->clock)
+/**
+ * GST_AUDIO_BASE_SINK_PAD:
+ * @obj: a #GstAudioBaseSink
+ *
+ * Get the sink #GstPad of @obj.
+ */
+#define GST_AUDIO_BASE_SINK_PAD(obj) (GST_BASE_SINK (obj)->sinkpad)
+
+/**
+ * GstAudioBaseSinkSlaveMethod:
+ * @GST_AUDIO_BASE_SINK_SLAVE_RESAMPLE: Resample to match the master clock
+ * @GST_AUDIO_BASE_SINK_SLAVE_SKEW: Adjust playout pointer when master clock
+ * drifts too much.
+ * @GST_AUDIO_BASE_SINK_SLAVE_NONE: No adjustment is done.
+ * @GST_AUDIO_BASE_SINK_SLAVE_CUSTOM: Use custom clock slaving algorithm (Since: 1.6)
+ *
+ * Different possible clock slaving algorithms used when the internal audio
+ * clock is not selected as the pipeline master clock.
+ */
+typedef enum
+{
+ GST_AUDIO_BASE_SINK_SLAVE_RESAMPLE,
+ GST_AUDIO_BASE_SINK_SLAVE_SKEW,
+ GST_AUDIO_BASE_SINK_SLAVE_NONE,
+ GST_AUDIO_BASE_SINK_SLAVE_CUSTOM
+} GstAudioBaseSinkSlaveMethod;
+
+typedef struct _GstAudioBaseSink GstAudioBaseSink;
+typedef struct _GstAudioBaseSinkClass GstAudioBaseSinkClass;
+typedef struct _GstAudioBaseSinkPrivate GstAudioBaseSinkPrivate;
+
+/**
+ * GstAudioBaseSinkDiscontReason:
+ * @GST_AUDIO_BASE_SINK_DISCONT_REASON_NO_DISCONT: No discontinuity occurred
+ * @GST_AUDIO_BASE_SINK_DISCONT_REASON_NEW_CAPS: New caps are set, causing renegotiotion
+ * @GST_AUDIO_BASE_SINK_DISCONT_REASON_FLUSH: Samples have been flushed
+ * @GST_AUDIO_BASE_SINK_DISCONT_REASON_SYNC_LATENCY: Sink was synchronized to the estimated latency (occurs during initialization)
+ * @GST_AUDIO_BASE_SINK_DISCONT_REASON_ALIGNMENT: Aligning buffers failed because the timestamps are too discontinuous
+ * @GST_AUDIO_BASE_SINK_DISCONT_REASON_DEVICE_FAILURE: Audio output device experienced and recovered from an error but introduced latency in the process (see also gst_audio_base_sink_report_device_failure())
+ *
+ * Different possible reasons for discontinuities. This enum is useful for the custom
+ * slave method.
+ *
+ * Since: 1.6
+ */
+typedef enum
+{
+ GST_AUDIO_BASE_SINK_DISCONT_REASON_NO_DISCONT,
+ GST_AUDIO_BASE_SINK_DISCONT_REASON_NEW_CAPS,
+ GST_AUDIO_BASE_SINK_DISCONT_REASON_FLUSH,
+ GST_AUDIO_BASE_SINK_DISCONT_REASON_SYNC_LATENCY,
+ GST_AUDIO_BASE_SINK_DISCONT_REASON_ALIGNMENT,
+ GST_AUDIO_BASE_SINK_DISCONT_REASON_DEVICE_FAILURE
+} GstAudioBaseSinkDiscontReason;
+
+/**
+ * GstAudioBaseSinkCustomSlavingCallback:
+ * @sink: a #GstAudioBaseSink
+ * @etime: external clock time
+ * @itime: internal clock time
+ * @requested_skew: skew amount requested by the callback
+ * @discont_reason: reason for discontinuity (if any)
+ * @user_data: user data
+ *
+ * This function is set with gst_audio_base_sink_set_custom_slaving_callback()
+ * and is called during playback. It receives the current time of external and
+ * internal clocks, which the callback can then use to apply any custom
+ * slaving/synchronization schemes.
+ *
+ * The external clock is the sink's element clock, the internal one is the
+ * internal audio clock. The internal audio clock's calibration is applied to
+ * the timestamps before they are passed to the callback. The difference between
+ * etime and itime is the skew; how much internal and external clock lie apart
+ * from each other. A skew of 0 means both clocks are perfectly in sync.
+ * itime > etime means the external clock is going slower, while itime < etime
+ * means it is going faster than the internal clock. etime and itime are always
+ * valid timestamps, except for when a discontinuity happens.
+ *
+ * requested_skew is an output value the callback can write to. It informs the
+ * sink of whether or not it should move the playout pointer, and if so, by how
+ * much. This pointer is only NULL if a discontinuity occurs; otherwise, it is
+ * safe to write to *requested_skew. The default skew is 0.
+ *
+ * The sink may experience discontinuities. If one happens, discont is TRUE,
+ * itime, etime are set to GST_CLOCK_TIME_NONE, and requested_skew is NULL.
+ * This makes it possible to reset custom clock slaving algorithms when a
+ * discontinuity happens.
+ *
+ * Since: 1.6
+ */
+typedef void (*GstAudioBaseSinkCustomSlavingCallback) (GstAudioBaseSink *sink, GstClockTime etime, GstClockTime itime, GstClockTimeDiff *requested_skew, GstAudioBaseSinkDiscontReason discont_reason, gpointer user_data);
+
+/**
+ * GstAudioBaseSink:
+ *
+ * Opaque #GstAudioBaseSink.
+ */
+struct _GstAudioBaseSink {
+ GstBaseSink element;
+
+ /*< protected >*/ /* with LOCK */
+ /* our ringbuffer */
+ GstAudioRingBuffer *ringbuffer;
+
+ /* required buffer and latency in microseconds */
+ guint64 buffer_time;
+ guint64 latency_time;
+
+ /* the next sample to write */
+ guint64 next_sample;
+
+ /* clock */
+ GstClock *provided_clock;
+
+ /* with g_atomic_; currently rendering eos */
+ gboolean eos_rendering;
+
+ /*< private >*/
+ GstAudioBaseSinkPrivate *priv;
+
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+/**
+ * GstAudioBaseSinkClass:
+ * @parent_class: the parent class.
+ * @create_ringbuffer: create and return a #GstAudioRingBuffer to write to.
+ * @payload: payload data in a format suitable to write to the sink. If no
+ * payloading is required, returns a reffed copy of the original
+ * buffer, else returns the payloaded buffer with all other metadata
+ * copied.
+ *
+ * #GstAudioBaseSink class. Override the vmethod to implement
+ * functionality.
+ */
+struct _GstAudioBaseSinkClass {
+ GstBaseSinkClass parent_class;
+
+ /* subclass ringbuffer allocation */
+ GstAudioRingBuffer* (*create_ringbuffer) (GstAudioBaseSink *sink);
+
+ /* subclass payloader */
+ GstBuffer* (*payload) (GstAudioBaseSink *sink,
+ GstBuffer *buffer);
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_base_sink_get_type(void);
+
+GST_AUDIO_API
+GstAudioRingBuffer *
+ gst_audio_base_sink_create_ringbuffer (GstAudioBaseSink *sink);
+
+GST_AUDIO_API
+void gst_audio_base_sink_set_provide_clock (GstAudioBaseSink *sink, gboolean provide);
+
+GST_AUDIO_API
+gboolean gst_audio_base_sink_get_provide_clock (GstAudioBaseSink *sink);
+
+GST_AUDIO_API
+void gst_audio_base_sink_set_slave_method (GstAudioBaseSink *sink,
+ GstAudioBaseSinkSlaveMethod method);
+GST_AUDIO_API
+GstAudioBaseSinkSlaveMethod
+ gst_audio_base_sink_get_slave_method (GstAudioBaseSink *sink);
+
+GST_AUDIO_API
+void gst_audio_base_sink_set_drift_tolerance (GstAudioBaseSink *sink,
+ gint64 drift_tolerance);
+GST_AUDIO_API
+gint64 gst_audio_base_sink_get_drift_tolerance (GstAudioBaseSink *sink);
+
+GST_AUDIO_API
+void gst_audio_base_sink_set_alignment_threshold (GstAudioBaseSink * sink,
+ GstClockTime alignment_threshold);
+GST_AUDIO_API
+GstClockTime
+ gst_audio_base_sink_get_alignment_threshold (GstAudioBaseSink * sink);
+
+GST_AUDIO_API
+void gst_audio_base_sink_set_discont_wait (GstAudioBaseSink * sink,
+ GstClockTime discont_wait);
+GST_AUDIO_API
+GstClockTime
+ gst_audio_base_sink_get_discont_wait (GstAudioBaseSink * sink);
+
+GST_AUDIO_API
+void
+gst_audio_base_sink_set_custom_slaving_callback (GstAudioBaseSink * sink,
+ GstAudioBaseSinkCustomSlavingCallback callback,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+GST_AUDIO_API
+void gst_audio_base_sink_report_device_failure (GstAudioBaseSink * sink);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioBaseSink, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_BASE_SINK_H__ */
diff --git a/include/gst/audio/gstaudiobasesrc.h b/include/gst/audio/gstaudiobasesrc.h
new file mode 100644
index 0000000000..67eb829914
--- /dev/null
+++ b/include/gst/audio/gstaudiobasesrc.h
@@ -0,0 +1,160 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2005 Wim Taymans <wim@fluendo.com>
+ *
+ * gstaudiobasesrc.h:
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* a base class for audio sources.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_BASE_SRC_H__
+#define __GST_AUDIO_BASE_SRC_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstpushsrc.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_BASE_SRC (gst_audio_base_src_get_type())
+#define GST_AUDIO_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_BASE_SRC,GstAudioBaseSrc))
+#define GST_AUDIO_BASE_SRC_CAST(obj) ((GstAudioBaseSrc*)obj)
+#define GST_AUDIO_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_BASE_SRC,GstAudioBaseSrcClass))
+#define GST_AUDIO_BASE_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_BASE_SRC, GstAudioBaseSrcClass))
+#define GST_IS_AUDIO_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_BASE_SRC))
+#define GST_IS_AUDIO_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_BASE_SRC))
+
+/**
+ * GST_AUDIO_BASE_SRC_CLOCK:
+ * @obj: a #GstAudioBaseSrc
+ *
+ * Get the #GstClock of @obj.
+ */
+#define GST_AUDIO_BASE_SRC_CLOCK(obj) (GST_AUDIO_BASE_SRC (obj)->clock)
+/**
+ * GST_AUDIO_BASE_SRC_PAD:
+ * @obj: a #GstAudioBaseSrc
+ *
+ * Get the source #GstPad of @obj.
+ */
+#define GST_AUDIO_BASE_SRC_PAD(obj) (GST_BASE_SRC (obj)->srcpad)
+
+typedef struct _GstAudioBaseSrc GstAudioBaseSrc;
+typedef struct _GstAudioBaseSrcClass GstAudioBaseSrcClass;
+typedef struct _GstAudioBaseSrcPrivate GstAudioBaseSrcPrivate;
+
+/* FIXME 2.0: Should be "retimestamp" not "re-timestamp" */
+
+/**
+ * GstAudioBaseSrcSlaveMethod:
+ * @GST_AUDIO_BASE_SRC_SLAVE_RESAMPLE: Resample to match the master clock.
+ * @GST_AUDIO_BASE_SRC_SLAVE_RE_TIMESTAMP: Retimestamp output buffers with master
+ * clock time.
+ * @GST_AUDIO_BASE_SRC_SLAVE_SKEW: Adjust capture pointer when master clock
+ * drifts too much.
+ * @GST_AUDIO_BASE_SRC_SLAVE_NONE: No adjustment is done.
+ *
+ * Different possible clock slaving algorithms when the internal audio clock was
+ * not selected as the pipeline clock.
+ */
+typedef enum
+{
+ GST_AUDIO_BASE_SRC_SLAVE_RESAMPLE,
+ GST_AUDIO_BASE_SRC_SLAVE_RE_TIMESTAMP,
+ GST_AUDIO_BASE_SRC_SLAVE_SKEW,
+ GST_AUDIO_BASE_SRC_SLAVE_NONE
+} GstAudioBaseSrcSlaveMethod;
+
+#define GST_AUDIO_BASE_SRC_SLAVE_RETIMESTAMP GST_AUDIO_BASE_SRC_SLAVE_RE_TIMESTAMP
+
+/**
+ * GstAudioBaseSrc:
+ *
+ * Opaque #GstAudioBaseSrc.
+ */
+struct _GstAudioBaseSrc {
+ GstPushSrc element;
+
+ /*< protected >*/ /* with LOCK */
+ /* our ringbuffer */
+ GstAudioRingBuffer *ringbuffer;
+
+ /* required buffer and latency */
+ GstClockTime buffer_time;
+ GstClockTime latency_time;
+
+ /* the next sample to write */
+ guint64 next_sample;
+
+ /* clock */
+ GstClock *clock;
+
+ /*< private >*/
+ GstAudioBaseSrcPrivate *priv;
+
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+/**
+ * GstAudioBaseSrcClass:
+ * @parent_class: the parent class.
+ * @create_ringbuffer: create and return a #GstAudioRingBuffer to read from.
+ *
+ * #GstAudioBaseSrc class. Override the vmethod to implement
+ * functionality.
+ */
+struct _GstAudioBaseSrcClass {
+ GstPushSrcClass parent_class;
+
+ /* subclass ringbuffer allocation */
+ GstAudioRingBuffer* (*create_ringbuffer) (GstAudioBaseSrc *src);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_base_src_get_type(void);
+
+GST_AUDIO_API
+GstAudioRingBuffer *
+ gst_audio_base_src_create_ringbuffer (GstAudioBaseSrc *src);
+
+GST_AUDIO_API
+void gst_audio_base_src_set_provide_clock (GstAudioBaseSrc *src, gboolean provide);
+
+GST_AUDIO_API
+gboolean gst_audio_base_src_get_provide_clock (GstAudioBaseSrc *src);
+
+GST_AUDIO_API
+void gst_audio_base_src_set_slave_method (GstAudioBaseSrc *src,
+ GstAudioBaseSrcSlaveMethod method);
+GST_AUDIO_API
+GstAudioBaseSrcSlaveMethod
+ gst_audio_base_src_get_slave_method (GstAudioBaseSrc *src);
+
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioBaseSrc, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_BASE_SRC_H__ */
diff --git a/include/gst/audio/gstaudiocdsrc.h b/include/gst/audio/gstaudiocdsrc.h
new file mode 100644
index 0000000000..65dd173179
--- /dev/null
+++ b/include/gst/audio/gstaudiocdsrc.h
@@ -0,0 +1,145 @@
+/* GStreamer Audio CD Source Base Class
+ * Copyright (C) 2005 Tim-Philipp Müller <tim centricular net>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_CD_SRC_H__
+#define __GST_AUDIO_CD_SRC_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstpushsrc.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_CD_SRC (gst_audio_cd_src_get_type())
+#define GST_AUDIO_CD_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AUDIO_CD_SRC, GstAudioCdSrc))
+#define GST_AUDIO_CD_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AUDIO_CD_SRC, GstAudioCdSrcClass))
+#define GST_IS_AUDIO_CD_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AUDIO_CD_SRC))
+#define GST_IS_AUDIO_CD_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AUDIO_CD_SRC))
+#define GST_AUDIO_CD_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_CD_SRC, GstAudioCdSrcClass))
+
+typedef struct _GstAudioCdSrc GstAudioCdSrc;
+typedef struct _GstAudioCdSrcClass GstAudioCdSrcClass;
+typedef struct _GstAudioCdSrcTrack GstAudioCdSrcTrack;
+typedef struct _GstAudioCdSrcPrivate GstAudioCdSrcPrivate;
+
+/**
+ * GstAudioCdSrcMode:
+ * @GST_AUDIO_CD_SRC_MODE_NORMAL : each single track is a stream
+ * @GST_AUDIO_CD_SRC_MODE_CONTINUOUS : the entire disc is a single stream
+ *
+ * Mode in which the CD audio source operates. Influences timestamping,
+ * EOS handling and seeking.
+ */
+typedef enum {
+ GST_AUDIO_CD_SRC_MODE_NORMAL, /* stream = one track */
+ GST_AUDIO_CD_SRC_MODE_CONTINUOUS /* stream = whole disc */
+} GstAudioCdSrcMode;
+
+/**
+ * GstAudioCdSrcTrack:
+ * @is_audio: Whether this is an audio track
+ * @num: Track number in TOC (usually starts from 1, but not always)
+ * @start: The first sector of this track (LBA)
+ * @end: The last sector of this track (LBA)
+ * @tags: Track-specific tags (e.g. from cd-text information), or NULL
+ *
+ * CD track abstraction to communicate TOC entries to the base class.
+ *
+ * This structure is only for use by sub-classed in connection with
+ * gst_audio_cd_src_add_track().
+ *
+ * Applications will be informed of the available tracks via a TOC message
+ * on the pipeline's #GstBus instead.
+ */
+/* FIXME 2.0: remove this struct and pass values directly to _add_track() */
+struct _GstAudioCdSrcTrack {
+ gboolean is_audio; /* TRUE if this is an audio track */
+ guint num; /* real track number (usually starts from 1) */
+ guint start; /* first sector of track (LBA, not LSN!) */
+ guint end; /* last sector of track (LBA, not LSN!) */
+ GstTagList *tags; /* NULL or tags for track (e.g. from cd-text) */
+
+ /*< private >*/
+ guint _gst_reserved1[GST_PADDING/2];
+ gpointer _gst_reserved2[GST_PADDING/2];
+};
+
+struct _GstAudioCdSrc {
+ GstPushSrc pushsrc;
+
+ /*< protected >*/ /* for use by sub-classes only */
+ GstTagList *tags; /* tags that apply to all tracks */
+
+ /*< private >*/
+ GstAudioCdSrcPrivate *priv;
+
+ /*< private >*/
+ guint _gst_reserved1[GST_PADDING/2];
+ gpointer _gst_reserved2[GST_PADDING/2];
+};
+
+/**
+ * GstAudioCdSrcClass:
+ * @pushsrc_class: the parent class
+ * @open: opening the device
+ * @close: closing the device
+ * @read_sector: reading a sector
+ * @get_default_device: getting the default device
+ * @probe_devices: probing possible devices
+ *
+ * Audio CD source base class.
+ */
+struct _GstAudioCdSrcClass {
+ GstPushSrcClass pushsrc_class;
+
+ /* open/close the CD device */
+ gboolean (*open) (GstAudioCdSrc *src, const gchar *device);
+ void (*close) (GstAudioCdSrc *src);
+
+ /* read one sector (LBA) */
+ GstBuffer * (*read_sector) (GstAudioCdSrc *src, gint sector);
+
+#if 0
+ /* return default device or NULL (optional) */
+ gchar * (*get_default_device) (GstAudioCdSrc *src);
+
+ /* return NULL-terminated string array of CD devices, or NULL (optional) */
+ /* FIXME 0.11: reconsider for new probing/device discovery API, remove if in doubt */
+ gchar ** (*probe_devices) (GstAudioCdSrc *src);
+#endif
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING_LARGE];
+};
+
+GST_AUDIO_API
+GType gst_audio_cd_src_get_type (void);
+
+GST_AUDIO_API
+gboolean gst_audio_cd_src_add_track (GstAudioCdSrc * src,
+ GstAudioCdSrcTrack * track);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioCdSrc, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_CD_SRC_H__ */
diff --git a/include/gst/audio/gstaudioclock.h b/include/gst/audio/gstaudioclock.h
new file mode 100644
index 0000000000..f4bd47ff2e
--- /dev/null
+++ b/include/gst/audio/gstaudioclock.h
@@ -0,0 +1,115 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2005 Wim Taymans <wim@fluendo.com>
+ *
+ * gstaudioclock.h: Clock for use by audio plugins
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_CLOCK_H__
+#define __GST_AUDIO_CLOCK_H__
+
+#include <gst/gst.h>
+#include <gst/gstsystemclock.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_CLOCK \
+ (gst_audio_clock_get_type())
+#define GST_AUDIO_CLOCK(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_CLOCK,GstAudioClock))
+#define GST_AUDIO_CLOCK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_CLOCK,GstAudioClockClass))
+#define GST_IS_AUDIO_CLOCK(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_CLOCK))
+#define GST_IS_AUDIO_CLOCK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_CLOCK))
+#define GST_AUDIO_CLOCK_CAST(obj) \
+ ((GstAudioClock*)(obj))
+
+typedef struct _GstAudioClock GstAudioClock;
+typedef struct _GstAudioClockClass GstAudioClockClass;
+
+/**
+ * GstAudioClockGetTimeFunc:
+ * @clock: the #GstAudioClock
+ * @user_data: user data
+ *
+ * This function will be called whenever the current clock time needs to be
+ * calculated. If this function returns #GST_CLOCK_TIME_NONE, the last reported
+ * time will be returned by the clock.
+ *
+ * Returns: the current time or #GST_CLOCK_TIME_NONE if the previous time should
+ * be used.
+ */
+typedef GstClockTime (*GstAudioClockGetTimeFunc) (GstClock *clock, gpointer user_data);
+
+/**
+ * GstAudioClock:
+ *
+ * Opaque #GstAudioClock.
+ */
+struct _GstAudioClock {
+ GstSystemClock clock;
+
+ /*< protected >*/
+ GstAudioClockGetTimeFunc func;
+ gpointer user_data;
+ GDestroyNotify destroy_notify;
+
+ /*< private >*/
+ GstClockTime last_time;
+ GstClockTimeDiff time_offset;
+
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+struct _GstAudioClockClass {
+ GstSystemClockClass parent_class;
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_clock_get_type (void);
+
+GST_AUDIO_API
+GstClock* gst_audio_clock_new (const gchar *name, GstAudioClockGetTimeFunc func,
+ gpointer user_data, GDestroyNotify destroy_notify);
+
+GST_AUDIO_API
+void gst_audio_clock_reset (GstAudioClock *clock, GstClockTime time);
+
+GST_AUDIO_API
+GstClockTime gst_audio_clock_get_time (GstAudioClock * clock);
+
+GST_AUDIO_API
+GstClockTime gst_audio_clock_adjust (GstAudioClock * clock, GstClockTime time);
+
+GST_AUDIO_API
+void gst_audio_clock_invalidate (GstAudioClock * clock);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioClock, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_CLOCK_H__ */
diff --git a/include/gst/audio/gstaudiodecoder.h b/include/gst/audio/gstaudiodecoder.h
new file mode 100644
index 0000000000..b2f36648a7
--- /dev/null
+++ b/include/gst/audio/gstaudiodecoder.h
@@ -0,0 +1,449 @@
+/* GStreamer
+ * Copyright (C) 2009 Igalia S.L.
+ * Author: Iago Toral Quiroga <itoral@igalia.com>
+ * Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>.
+ * Copyright (C) 2011 Nokia Corporation. All rights reserved.
+ * Contact: Stefan Kost <stefan.kost@nokia.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef _GST_AUDIO_DECODER_H_
+#define _GST_AUDIO_DECODER_H_
+
+#include <gst/gst.h>
+#include <gst/base/gstadapter.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_DECODER \
+ (gst_audio_decoder_get_type())
+#define GST_AUDIO_DECODER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_DECODER,GstAudioDecoder))
+#define GST_AUDIO_DECODER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_DECODER,GstAudioDecoderClass))
+#define GST_AUDIO_DECODER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_AUDIO_DECODER,GstAudioDecoderClass))
+#define GST_IS_AUDIO_DECODER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_DECODER))
+#define GST_IS_AUDIO_DECODER_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_DECODER))
+#define GST_AUDIO_DECODER_CAST(obj) \
+ ((GstAudioDecoder *)(obj))
+
+/**
+ * GST_AUDIO_DECODER_SINK_NAME:
+ *
+ * The name of the templates for the sink pad.
+ */
+#define GST_AUDIO_DECODER_SINK_NAME "sink"
+/**
+ * GST_AUDIO_DECODER_SRC_NAME:
+ *
+ * The name of the templates for the source pad.
+ */
+#define GST_AUDIO_DECODER_SRC_NAME "src"
+
+/**
+ * GST_AUDIO_DECODER_SRC_PAD:
+ * @obj: base audio codec instance
+ *
+ * Gives the pointer to the source #GstPad object of the element.
+ */
+#define GST_AUDIO_DECODER_SRC_PAD(obj) (((GstAudioDecoder *) (obj))->srcpad)
+
+/**
+ * GST_AUDIO_DECODER_SINK_PAD:
+ * @obj: base audio codec instance
+ *
+ * Gives the pointer to the sink #GstPad object of the element.
+ */
+#define GST_AUDIO_DECODER_SINK_PAD(obj) (((GstAudioDecoder *) (obj))->sinkpad)
+
+#define GST_AUDIO_DECODER_STREAM_LOCK(dec) g_rec_mutex_lock (&GST_AUDIO_DECODER (dec)->stream_lock)
+#define GST_AUDIO_DECODER_STREAM_UNLOCK(dec) g_rec_mutex_unlock (&GST_AUDIO_DECODER (dec)->stream_lock)
+
+/**
+ * GST_AUDIO_DECODER_INPUT_SEGMENT:
+ * @obj: audio decoder instance
+ *
+ * Gives the input segment of the element.
+ */
+#define GST_AUDIO_DECODER_INPUT_SEGMENT(obj) (GST_AUDIO_DECODER_CAST (obj)->input_segment)
+
+/**
+ * GST_AUDIO_DECODER_OUTPUT_SEGMENT:
+ * @obj: audio decoder instance
+ *
+ * Gives the output segment of the element.
+ */
+#define GST_AUDIO_DECODER_OUTPUT_SEGMENT(obj) (GST_AUDIO_DECODER_CAST (obj)->output_segment)
+
+typedef struct _GstAudioDecoder GstAudioDecoder;
+typedef struct _GstAudioDecoderClass GstAudioDecoderClass;
+
+typedef struct _GstAudioDecoderPrivate GstAudioDecoderPrivate;
+
+/* do not use this one, use macro below */
+
+GST_AUDIO_API
+GstFlowReturn _gst_audio_decoder_error (GstAudioDecoder *dec, gint weight,
+ GQuark domain, gint code,
+ gchar *txt, gchar *debug,
+ const gchar *file, const gchar *function,
+ gint line);
+
+/**
+ * GST_AUDIO_DECODER_ERROR:
+ * @el: the base audio decoder element that generates the error
+ * @weight: element defined weight of the error, added to error count
+ * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
+ * @code: error code defined for that domain (see #gstreamer-GstGError)
+ * @text: the message to display (format string and args enclosed in
+ * parentheses)
+ * @debug: debugging information for the message (format string and args
+ * enclosed in parentheses)
+ * @ret: variable to receive return value
+ *
+ * Utility function that audio decoder elements can use in case they encountered
+ * a data processing error that may be fatal for the current "data unit" but
+ * need not prevent subsequent decoding. Such errors are counted and if there
+ * are too many, as configured in the context's max_errors, the pipeline will
+ * post an error message and the application will be requested to stop further
+ * media processing. Otherwise, it is considered a "glitch" and only a warning
+ * is logged. In either case, @ret is set to the proper value to
+ * return to upstream/caller (indicating either GST_FLOW_ERROR or GST_FLOW_OK).
+ */
+#define GST_AUDIO_DECODER_ERROR(el, weight, domain, code, text, debug, ret) \
+G_STMT_START { \
+ gchar *__txt = _gst_element_error_printf text; \
+ gchar *__dbg = _gst_element_error_printf debug; \
+ GstAudioDecoder *__dec = GST_AUDIO_DECODER (el); \
+ ret = _gst_audio_decoder_error (__dec, weight, GST_ ## domain ## _ERROR, \
+ GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, \
+ GST_FUNCTION, __LINE__); \
+} G_STMT_END
+
+
+/**
+ * GST_AUDIO_DECODER_MAX_ERRORS:
+ *
+ * Default maximum number of errors tolerated before signaling error.
+ */
+#define GST_AUDIO_DECODER_MAX_ERRORS 10
+
+/**
+ * GstAudioDecoder:
+ *
+ * The opaque #GstAudioDecoder data structure.
+ */
+struct _GstAudioDecoder
+{
+ GstElement element;
+
+ /*< protected >*/
+ /* source and sink pads */
+ GstPad *sinkpad;
+ GstPad *srcpad;
+
+ /* protects all data processing, i.e. is locked
+ * in the chain function, finish_frame and when
+ * processing serialized events */
+ GRecMutex stream_lock;
+
+ /* MT-protected (with STREAM_LOCK) */
+ GstSegment input_segment;
+ GstSegment output_segment;
+
+ /*< private >*/
+ GstAudioDecoderPrivate *priv;
+
+ gpointer _gst_reserved[GST_PADDING_LARGE];
+};
+
+/**
+ * GstAudioDecoderClass:
+ * @element_class: The parent class structure
+ * @start: Optional.
+ * Called when the element starts processing.
+ * Allows opening external resources.
+ * @stop: Optional.
+ * Called when the element stops processing.
+ * Allows closing external resources.
+ * @set_format: Notifies subclass of incoming data format (caps).
+ * @parse: Optional.
+ * Allows chopping incoming data into manageable units (frames)
+ * for subsequent decoding. This division is at subclass
+ * discretion and may or may not correspond to 1 (or more)
+ * frames as defined by audio format.
+ * @handle_frame: Provides input data (or NULL to clear any remaining data)
+ * to subclass. Input data ref management is performed by
+ * base class, subclass should not care or intervene,
+ * and input data is only valid until next call to base class,
+ * most notably a call to gst_audio_decoder_finish_frame().
+ * @flush: Optional.
+ * Instructs subclass to clear any codec caches and discard
+ * any pending samples and not yet returned decoded data.
+ * @hard indicates whether a FLUSH is being processed,
+ * or otherwise a DISCONT (or conceptually similar).
+ * @sink_event: Optional.
+ * Event handler on the sink pad. Subclasses should chain up to
+ * the parent implementation to invoke the default handler.
+ * @src_event: Optional.
+ * Event handler on the src pad. Subclasses should chain up to
+ * the parent implementation to invoke the default handler.
+ * @pre_push: Optional.
+ * Called just prior to pushing (encoded data) buffer downstream.
+ * Subclass has full discretionary access to buffer,
+ * and a not OK flow return will abort downstream pushing.
+ * @open: Optional.
+ * Called when the element changes to GST_STATE_READY.
+ * Allows opening external resources.
+ * @close: Optional.
+ * Called when the element changes to GST_STATE_NULL.
+ * Allows closing external resources.
+ * @negotiate: Optional.
+ * Negotiate with downstream and configure buffer pools, etc.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ * @decide_allocation: Optional.
+ * Setup the allocation parameters for allocating output
+ * buffers. The passed in query contains the result of the
+ * downstream allocation query.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ * @propose_allocation: Optional.
+ * Propose buffer allocation parameters for upstream elements.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ * @sink_query: Optional.
+ * Query handler on the sink pad. This function should
+ * return TRUE if the query could be performed. Subclasses
+ * should chain up to the parent implementation to invoke the
+ * default handler. Since: 1.6
+ * @src_query: Optional.
+ * Query handler on the source pad. This function should
+ * return TRUE if the query could be performed. Subclasses
+ * should chain up to the parent implementation to invoke the
+ * default handler. Since: 1.6
+ * @getcaps: Optional.
+ * Allows for a custom sink getcaps implementation.
+ * If not implemented,
+ * default returns gst_audio_decoder_proxy_getcaps
+ * applied to sink template caps.
+ * @transform_meta: Optional. Transform the metadata on the input buffer to the
+ * output buffer. By default this method copies all meta without
+ * tags and meta with only the "audio" tag. subclasses can
+ * implement this method and return %TRUE if the metadata is to be
+ * copied. Since: 1.6
+ *
+ * Subclasses can override any of the available virtual methods or not, as
+ * needed. At minimum @handle_frame (and likely @set_format) needs to be
+ * overridden.
+ */
+struct _GstAudioDecoderClass
+{
+ GstElementClass element_class;
+
+ /*< public >*/
+ /* virtual methods for subclasses */
+
+ gboolean (*start) (GstAudioDecoder *dec);
+
+ gboolean (*stop) (GstAudioDecoder *dec);
+
+ gboolean (*set_format) (GstAudioDecoder *dec,
+ GstCaps *caps);
+
+ GstFlowReturn (*parse) (GstAudioDecoder *dec,
+ GstAdapter *adapter,
+ gint *offset, gint *length);
+
+ GstFlowReturn (*handle_frame) (GstAudioDecoder *dec,
+ GstBuffer *buffer);
+
+ void (*flush) (GstAudioDecoder *dec, gboolean hard);
+
+ GstFlowReturn (*pre_push) (GstAudioDecoder *dec,
+ GstBuffer **buffer);
+
+ gboolean (*sink_event) (GstAudioDecoder *dec,
+ GstEvent *event);
+ gboolean (*src_event) (GstAudioDecoder *dec,
+ GstEvent *event);
+
+ gboolean (*open) (GstAudioDecoder *dec);
+
+ gboolean (*close) (GstAudioDecoder *dec);
+
+ gboolean (*negotiate) (GstAudioDecoder *dec);
+
+ gboolean (*decide_allocation) (GstAudioDecoder *dec, GstQuery *query);
+
+ gboolean (*propose_allocation) (GstAudioDecoder *dec,
+ GstQuery * query);
+
+ gboolean (*sink_query) (GstAudioDecoder *dec, GstQuery *query);
+
+ gboolean (*src_query) (GstAudioDecoder *dec, GstQuery *query);
+
+ GstCaps * (*getcaps) (GstAudioDecoder * dec,
+ GstCaps * filter);
+
+ gboolean (*transform_meta) (GstAudioDecoder *enc, GstBuffer *outbuf,
+ GstMeta *meta, GstBuffer *inbuf);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING_LARGE - 4];
+};
+
+GST_AUDIO_API
+GType gst_audio_decoder_get_type (void);
+
+GST_AUDIO_API
+gboolean gst_audio_decoder_set_output_format (GstAudioDecoder * dec,
+ const GstAudioInfo * info);
+
+GST_AUDIO_API
+gboolean gst_audio_decoder_set_output_caps (GstAudioDecoder * dec,
+ GstCaps * caps);
+GST_AUDIO_API
+GstCaps * gst_audio_decoder_proxy_getcaps (GstAudioDecoder * decoder,
+ GstCaps * caps,
+ GstCaps * filter);
+
+GST_AUDIO_API
+gboolean gst_audio_decoder_negotiate (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+GstFlowReturn gst_audio_decoder_finish_subframe (GstAudioDecoder * dec,
+ GstBuffer * buf);
+
+GST_AUDIO_API
+GstFlowReturn gst_audio_decoder_finish_frame (GstAudioDecoder * dec,
+ GstBuffer * buf, gint frames);
+
+GST_AUDIO_API
+GstBuffer * gst_audio_decoder_allocate_output_buffer (GstAudioDecoder * dec,
+ gsize size);
+
+/* context parameters */
+
+GST_AUDIO_API
+GstAudioInfo * gst_audio_decoder_get_audio_info (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_plc_aware (GstAudioDecoder * dec,
+ gboolean plc);
+
+GST_AUDIO_API
+gint gst_audio_decoder_get_plc_aware (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_estimate_rate (GstAudioDecoder * dec,
+ gboolean enabled);
+
+GST_AUDIO_API
+gint gst_audio_decoder_get_estimate_rate (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+gint gst_audio_decoder_get_delay (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_max_errors (GstAudioDecoder * dec,
+ gint num);
+
+GST_AUDIO_API
+gint gst_audio_decoder_get_max_errors (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_latency (GstAudioDecoder * dec,
+ GstClockTime min,
+ GstClockTime max);
+
+GST_AUDIO_API
+void gst_audio_decoder_get_latency (GstAudioDecoder * dec,
+ GstClockTime * min,
+ GstClockTime * max);
+
+GST_AUDIO_API
+void gst_audio_decoder_get_parse_state (GstAudioDecoder * dec,
+ gboolean * sync,
+ gboolean * eos);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_allocation_caps (GstAudioDecoder * dec,
+ GstCaps * allocation_caps);
+
+/* object properties */
+
+GST_AUDIO_API
+void gst_audio_decoder_set_plc (GstAudioDecoder * dec,
+ gboolean enabled);
+
+GST_AUDIO_API
+gboolean gst_audio_decoder_get_plc (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_min_latency (GstAudioDecoder * dec,
+ GstClockTime num);
+
+GST_AUDIO_API
+GstClockTime gst_audio_decoder_get_min_latency (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_tolerance (GstAudioDecoder * dec,
+ GstClockTime tolerance);
+
+GST_AUDIO_API
+GstClockTime gst_audio_decoder_get_tolerance (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_drainable (GstAudioDecoder * dec,
+ gboolean enabled);
+
+GST_AUDIO_API
+gboolean gst_audio_decoder_get_drainable (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_needs_format (GstAudioDecoder * dec,
+ gboolean enabled);
+
+GST_AUDIO_API
+gboolean gst_audio_decoder_get_needs_format (GstAudioDecoder * dec);
+
+GST_AUDIO_API
+void gst_audio_decoder_get_allocator (GstAudioDecoder * dec,
+ GstAllocator ** allocator,
+ GstAllocationParams * params);
+
+GST_AUDIO_API
+void gst_audio_decoder_merge_tags (GstAudioDecoder * dec,
+ const GstTagList * tags, GstTagMergeMode mode);
+
+GST_AUDIO_API
+void gst_audio_decoder_set_use_default_pad_acceptcaps (GstAudioDecoder * decoder,
+ gboolean use);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioDecoder, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* _GST_AUDIO_DECODER_H_ */
diff --git a/include/gst/audio/gstaudioencoder.h b/include/gst/audio/gstaudioencoder.h
new file mode 100644
index 0000000000..e95938b5d5
--- /dev/null
+++ b/include/gst/audio/gstaudioencoder.h
@@ -0,0 +1,378 @@
+/* GStreamer
+ * Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>.
+ * Copyright (C) 2011 Nokia Corporation. All rights reserved.
+ * Contact: Stefan Kost <stefan.kost@nokia.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_ENCODER_H__
+#define __GST_AUDIO_ENCODER_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_ENCODER (gst_audio_encoder_get_type())
+#define GST_AUDIO_ENCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_ENCODER,GstAudioEncoder))
+#define GST_AUDIO_ENCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_ENCODER,GstAudioEncoderClass))
+#define GST_AUDIO_ENCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_AUDIO_ENCODER,GstAudioEncoderClass))
+#define GST_IS_AUDIO_ENCODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_ENCODER))
+#define GST_IS_AUDIO_ENCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_ENCODER))
+#define GST_AUDIO_ENCODER_CAST(obj) ((GstAudioEncoder *)(obj))
+
+/**
+ * GST_AUDIO_ENCODER_SINK_NAME:
+ *
+ * the name of the templates for the sink pad
+ */
+#define GST_AUDIO_ENCODER_SINK_NAME "sink"
+/**
+ * GST_AUDIO_ENCODER_SRC_NAME:
+ *
+ * the name of the templates for the source pad
+ */
+#define GST_AUDIO_ENCODER_SRC_NAME "src"
+
+/**
+ * GST_AUDIO_ENCODER_SRC_PAD:
+ * @obj: audio encoder instance
+ *
+ * Gives the pointer to the source #GstPad object of the element.
+ */
+#define GST_AUDIO_ENCODER_SRC_PAD(obj) (GST_AUDIO_ENCODER_CAST (obj)->srcpad)
+
+/**
+ * GST_AUDIO_ENCODER_SINK_PAD:
+ * @obj: audio encoder instance
+ *
+ * Gives the pointer to the sink #GstPad object of the element.
+ */
+#define GST_AUDIO_ENCODER_SINK_PAD(obj) (GST_AUDIO_ENCODER_CAST (obj)->sinkpad)
+
+/**
+ * GST_AUDIO_ENCODER_INPUT_SEGMENT:
+ * @obj: base parse instance
+ *
+ * Gives the input segment of the element.
+ */
+#define GST_AUDIO_ENCODER_INPUT_SEGMENT(obj) (GST_AUDIO_ENCODER_CAST (obj)->input_segment)
+
+/**
+ * GST_AUDIO_ENCODER_OUTPUT_SEGMENT:
+ * @obj: base parse instance
+ *
+ * Gives the output segment of the element.
+ */
+#define GST_AUDIO_ENCODER_OUTPUT_SEGMENT(obj) (GST_AUDIO_ENCODER_CAST (obj)->output_segment)
+
+#define GST_AUDIO_ENCODER_STREAM_LOCK(enc) g_rec_mutex_lock (&GST_AUDIO_ENCODER (enc)->stream_lock)
+#define GST_AUDIO_ENCODER_STREAM_UNLOCK(enc) g_rec_mutex_unlock (&GST_AUDIO_ENCODER (enc)->stream_lock)
+
+typedef struct _GstAudioEncoder GstAudioEncoder;
+typedef struct _GstAudioEncoderClass GstAudioEncoderClass;
+
+typedef struct _GstAudioEncoderPrivate GstAudioEncoderPrivate;
+
+/**
+ * GstAudioEncoder:
+ *
+ * The opaque #GstAudioEncoder data structure.
+ */
+struct _GstAudioEncoder {
+ GstElement element;
+
+ /*< protected >*/
+ /* source and sink pads */
+ GstPad *sinkpad;
+ GstPad *srcpad;
+
+ /* protects all data processing, i.e. is locked
+ * in the chain function, finish_frame and when
+ * processing serialized events */
+ GRecMutex stream_lock;
+
+ /* MT-protected (with STREAM_LOCK) */
+ GstSegment input_segment;
+ GstSegment output_segment;
+
+ /*< private >*/
+ GstAudioEncoderPrivate *priv;
+
+ gpointer _gst_reserved[GST_PADDING_LARGE];
+};
+
+/**
+ * GstAudioEncoderClass:
+ * @element_class: The parent class structure
+ * @start: Optional.
+ * Called when the element starts processing.
+ * Allows opening external resources.
+ * @stop: Optional.
+ * Called when the element stops processing.
+ * Allows closing external resources.
+ * @set_format: Notifies subclass of incoming data format.
+ * GstAudioInfo contains the format according to provided caps.
+ * @handle_frame: Provides input samples (or NULL to clear any remaining data)
+ * according to directions as configured by the subclass
+ * using the API. Input data ref management is performed
+ * by base class, subclass should not care or intervene,
+ * and input data is only valid until next call to base class,
+ * most notably a call to gst_audio_encoder_finish_frame().
+ * @flush: Optional.
+ * Instructs subclass to clear any codec caches and discard
+ * any pending samples and not yet returned encoded data.
+ * @sink_event: Optional.
+ * Event handler on the sink pad. Subclasses should chain up to
+ * the parent implementation to invoke the default handler.
+ * @src_event: Optional.
+ * Event handler on the src pad. Subclasses should chain up to
+ * the parent implementation to invoke the default handler.
+ * @pre_push: Optional.
+ * Called just prior to pushing (encoded data) buffer downstream.
+ * Subclass has full discretionary access to buffer,
+ * and a not OK flow return will abort downstream pushing.
+ * @getcaps: Optional.
+ * Allows for a custom sink getcaps implementation (e.g.
+ * for multichannel input specification). If not implemented,
+ * default returns gst_audio_encoder_proxy_getcaps
+ * applied to sink template caps.
+ * @open: Optional.
+ * Called when the element changes to GST_STATE_READY.
+ * Allows opening external resources.
+ * @close: Optional.
+ * Called when the element changes to GST_STATE_NULL.
+ * Allows closing external resources.
+ * @negotiate: Optional.
+ * Negotiate with downstream and configure buffer pools, etc.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ * @decide_allocation: Optional.
+ * Setup the allocation parameters for allocating output
+ * buffers. The passed in query contains the result of the
+ * downstream allocation query.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ * @propose_allocation: Optional.
+ * Propose buffer allocation parameters for upstream elements.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ * @transform_meta: Optional. Transform the metadata on the input buffer to the
+ * output buffer. By default this method copies all meta without
+ * tags and meta with only the "audio" tag. subclasses can
+ * implement this method and return %TRUE if the metadata is to be
+ * copied. Since: 1.6
+ * @sink_query: Optional.
+ * Query handler on the sink pad. This function should
+ * return TRUE if the query could be performed. Subclasses
+ * should chain up to the parent implementation to invoke the
+ * default handler. Since: 1.6
+ * @src_query: Optional.
+ * Query handler on the source pad. This function should
+ * return TRUE if the query could be performed. Subclasses
+ * should chain up to the parent implementation to invoke the
+ * default handler. Since: 1.6
+ *
+ * Subclasses can override any of the available virtual methods or not, as
+ * needed. At minimum @set_format and @handle_frame needs to be overridden.
+ */
+struct _GstAudioEncoderClass {
+ GstElementClass element_class;
+
+ /*< public >*/
+ /* virtual methods for subclasses */
+
+ gboolean (*start) (GstAudioEncoder *enc);
+
+ gboolean (*stop) (GstAudioEncoder *enc);
+
+ gboolean (*set_format) (GstAudioEncoder *enc,
+ GstAudioInfo *info);
+
+ GstFlowReturn (*handle_frame) (GstAudioEncoder *enc,
+ GstBuffer *buffer);
+
+ void (*flush) (GstAudioEncoder *enc);
+
+ GstFlowReturn (*pre_push) (GstAudioEncoder *enc,
+ GstBuffer **buffer);
+
+ gboolean (*sink_event) (GstAudioEncoder *enc,
+ GstEvent *event);
+
+ gboolean (*src_event) (GstAudioEncoder *enc,
+ GstEvent *event);
+
+ GstCaps * (*getcaps) (GstAudioEncoder *enc, GstCaps *filter);
+
+ gboolean (*open) (GstAudioEncoder *enc);
+
+ gboolean (*close) (GstAudioEncoder *enc);
+
+ gboolean (*negotiate) (GstAudioEncoder *enc);
+
+ gboolean (*decide_allocation) (GstAudioEncoder *enc, GstQuery *query);
+
+ gboolean (*propose_allocation) (GstAudioEncoder * enc,
+ GstQuery * query);
+
+ gboolean (*transform_meta) (GstAudioEncoder *enc, GstBuffer *outbuf,
+ GstMeta *meta, GstBuffer *inbuf);
+
+ gboolean (*sink_query) (GstAudioEncoder *encoder,
+ GstQuery *query);
+
+ gboolean (*src_query) (GstAudioEncoder *encoder,
+ GstQuery *query);
+
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING_LARGE-3];
+};
+
+GST_AUDIO_API
+GType gst_audio_encoder_get_type (void);
+
+GST_AUDIO_API
+GstFlowReturn gst_audio_encoder_finish_frame (GstAudioEncoder * enc,
+ GstBuffer * buffer,
+ gint samples);
+
+GST_AUDIO_API
+GstCaps * gst_audio_encoder_proxy_getcaps (GstAudioEncoder * enc,
+ GstCaps * caps,
+ GstCaps * filter);
+
+GST_AUDIO_API
+gboolean gst_audio_encoder_set_output_format (GstAudioEncoder * enc,
+ GstCaps * caps);
+
+GST_AUDIO_API
+gboolean gst_audio_encoder_negotiate (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+GstBuffer * gst_audio_encoder_allocate_output_buffer (GstAudioEncoder * enc,
+ gsize size);
+
+/* context parameters */
+
+GST_AUDIO_API
+GstAudioInfo * gst_audio_encoder_get_audio_info (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+gint gst_audio_encoder_get_frame_samples_min (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_frame_samples_min (GstAudioEncoder * enc, gint num);
+
+GST_AUDIO_API
+gint gst_audio_encoder_get_frame_samples_max (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_frame_samples_max (GstAudioEncoder * enc, gint num);
+
+GST_AUDIO_API
+gint gst_audio_encoder_get_frame_max (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_frame_max (GstAudioEncoder * enc, gint num);
+
+GST_AUDIO_API
+gint gst_audio_encoder_get_lookahead (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_lookahead (GstAudioEncoder * enc, gint num);
+
+GST_AUDIO_API
+void gst_audio_encoder_get_latency (GstAudioEncoder * enc,
+ GstClockTime * min,
+ GstClockTime * max);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_latency (GstAudioEncoder * enc,
+ GstClockTime min,
+ GstClockTime max);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_headers (GstAudioEncoder * enc,
+ GList * headers);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_allocation_caps (GstAudioEncoder * enc,
+ GstCaps * allocation_caps);
+
+/* object properties */
+
+GST_AUDIO_API
+void gst_audio_encoder_set_mark_granule (GstAudioEncoder * enc,
+ gboolean enabled);
+
+GST_AUDIO_API
+gboolean gst_audio_encoder_get_mark_granule (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_perfect_timestamp (GstAudioEncoder * enc,
+ gboolean enabled);
+
+GST_AUDIO_API
+gboolean gst_audio_encoder_get_perfect_timestamp (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_hard_resync (GstAudioEncoder * enc,
+ gboolean enabled);
+
+GST_AUDIO_API
+gboolean gst_audio_encoder_get_hard_resync (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_tolerance (GstAudioEncoder * enc,
+ GstClockTime tolerance);
+
+GST_AUDIO_API
+GstClockTime gst_audio_encoder_get_tolerance (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_hard_min (GstAudioEncoder * enc,
+ gboolean enabled);
+
+GST_AUDIO_API
+gboolean gst_audio_encoder_get_hard_min (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_set_drainable (GstAudioEncoder * enc,
+ gboolean enabled);
+
+GST_AUDIO_API
+gboolean gst_audio_encoder_get_drainable (GstAudioEncoder * enc);
+
+GST_AUDIO_API
+void gst_audio_encoder_get_allocator (GstAudioEncoder * enc,
+ GstAllocator ** allocator,
+ GstAllocationParams * params);
+
+GST_AUDIO_API
+void gst_audio_encoder_merge_tags (GstAudioEncoder * enc,
+ const GstTagList * tags, GstTagMergeMode mode);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioEncoder, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_ENCODER_H__ */
diff --git a/include/gst/audio/gstaudiofilter.h b/include/gst/audio/gstaudiofilter.h
new file mode 100644
index 0000000000..6108e79f10
--- /dev/null
+++ b/include/gst/audio/gstaudiofilter.h
@@ -0,0 +1,107 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_FILTER_H__
+#define __GST_AUDIO_FILTER_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstbasetransform.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GstAudioFilter GstAudioFilter;
+typedef struct _GstAudioFilterClass GstAudioFilterClass;
+
+#define GST_TYPE_AUDIO_FILTER \
+ (gst_audio_filter_get_type())
+#define GST_AUDIO_FILTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_FILTER,GstAudioFilter))
+#define GST_AUDIO_FILTER_CAST(obj) \
+ ((GstAudioFilter *) (obj))
+#define GST_AUDIO_FILTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_FILTER,GstAudioFilterClass))
+#define GST_AUDIO_FILTER_CLASS_CAST(klass) \
+ ((GstAudioFilterClass *) (klass))
+#define GST_AUDIO_FILTER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_AUDIO_FILTER,GstAudioFilterClass))
+#define GST_IS_AUDIO_FILTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_FILTER))
+#define GST_IS_AUDIO_FILTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_FILTER))
+
+/**
+ * GstAudioFilter:
+ *
+ * Base class for audio filters with the same format for input and output.
+ */
+struct _GstAudioFilter {
+ GstBaseTransform basetransform;
+
+ /*< protected >*/
+ GstAudioInfo info; /* currently configured format */
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+#define GST_AUDIO_FILTER_INFO(filter) (&GST_AUDIO_FILTER_CAST(filter)->info)
+
+#define GST_AUDIO_FILTER_FORMAT(filter) (GST_AUDIO_INFO_FORMAT(GST_AUDIO_FILTER_INFO(filter)))
+#define GST_AUDIO_FILTER_RATE(filter) (GST_AUDIO_INFO_RATE(GST_AUDIO_FILTER_INFO(filter)))
+#define GST_AUDIO_FILTER_CHANNELS(filter) (GST_AUDIO_INFO_CHANNELS(GST_AUDIO_FILTER_INFO(filter)))
+#define GST_AUDIO_FILTER_BPF(filter) (GST_AUDIO_INFO_BPF(GST_AUDIO_FILTER_INFO(filter)))
+#define GST_AUDIO_FILTER_BPS(filter) (GST_AUDIO_INFO_BPS(GST_AUDIO_FILTER_INFO(filter)))
+
+/**
+ * GstAudioFilterClass:
+ * @basetransformclass: parent class
+ * @setup: virtual function called whenever the format changes
+ *
+ * In addition to the @setup virtual function, you should also override the
+ * GstBaseTransform::transform and/or GstBaseTransform::transform_ip virtual
+ * function.
+ */
+
+struct _GstAudioFilterClass {
+ GstBaseTransformClass basetransformclass;
+
+ /* virtual function, called whenever the format changes */
+ gboolean (*setup) (GstAudioFilter * filter, const GstAudioInfo * info);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_filter_get_type (void);
+
+GST_AUDIO_API
+void gst_audio_filter_class_add_pad_templates (GstAudioFilterClass * klass,
+ GstCaps * allowed_caps);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioFilter, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_FILTER_H__ */
+
diff --git a/include/gst/audio/gstaudioiec61937.h b/include/gst/audio/gstaudioiec61937.h
new file mode 100644
index 0000000000..1885a921dd
--- /dev/null
+++ b/include/gst/audio/gstaudioiec61937.h
@@ -0,0 +1,36 @@
+/* GStreamer audio helper functions for IEC 61937 payloading
+ * (c) 2011 Intel Corporation
+ * 2011 Collabora Multimedia
+ * 2011 Arun Raghavan <arun.raghavan@collabora.co.uk>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_IEC61937_H__
+#define __GST_AUDIO_IEC61937_H__
+
+#include <gst/audio/gstaudioringbuffer.h>
+
+GST_AUDIO_API
+guint gst_audio_iec61937_frame_size (const GstAudioRingBufferSpec * spec);
+
+GST_AUDIO_API
+gboolean gst_audio_iec61937_payload (const guint8 * src, guint src_n,
+ guint8 * dst, guint dst_n,
+ const GstAudioRingBufferSpec * spec,
+ gint endianness);
+
+#endif /* __GST_AUDIO_IEC61937_H__ */
diff --git a/include/gst/audio/gstaudiometa.h b/include/gst/audio/gstaudiometa.h
new file mode 100644
index 0000000000..94954d1940
--- /dev/null
+++ b/include/gst/audio/gstaudiometa.h
@@ -0,0 +1,252 @@
+/* GStreamer
+ * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_META_H__
+#define __GST_AUDIO_META_H__
+
+#include <gst/audio/audio.h>
+
+G_BEGIN_DECLS
+
+#define GST_AUDIO_DOWNMIX_META_API_TYPE (gst_audio_downmix_meta_api_get_type())
+#define GST_AUDIO_DOWNMIX_META_INFO (gst_audio_downmix_meta_get_info())
+
+typedef struct _GstAudioDownmixMeta GstAudioDownmixMeta;
+
+/**
+ * GstAudioDownmixMeta:
+ * @meta: parent #GstMeta
+ * @from_position: the channel positions of the source
+ * @to_position: the channel positions of the destination
+ * @from_channels: the number of channels of the source
+ * @to_channels: the number of channels of the destination
+ * @matrix: the matrix coefficients.
+ *
+ * Extra buffer metadata describing audio downmixing matrix. This metadata is
+ * attached to audio buffers and contains a matrix to downmix the buffer number
+ * of channels to @channels.
+ *
+ * @matrix is an two-dimensional array of @to_channels times @from_channels
+ * coefficients, i.e. the i-th output channels is constructed by multiplicating
+ * the input channels with the coefficients in @matrix[i] and taking the sum
+ * of the results.
+ */
+struct _GstAudioDownmixMeta {
+ GstMeta meta;
+
+ GstAudioChannelPosition *from_position;
+ GstAudioChannelPosition *to_position;
+ gint from_channels, to_channels;
+ gfloat **matrix;
+};
+
+GST_AUDIO_API
+GType gst_audio_downmix_meta_api_get_type (void);
+
+GST_AUDIO_API
+const GstMetaInfo * gst_audio_downmix_meta_get_info (void);
+
+#define gst_buffer_get_audio_downmix_meta(b) ((GstAudioDownmixMeta*)gst_buffer_get_meta((b), GST_AUDIO_DOWNMIX_META_API_TYPE))
+GST_AUDIO_API
+GstAudioDownmixMeta * gst_buffer_get_audio_downmix_meta_for_channels (GstBuffer *buffer,
+ const GstAudioChannelPosition *to_position,
+ gint to_channels);
+
+GST_AUDIO_API
+GstAudioDownmixMeta * gst_buffer_add_audio_downmix_meta (GstBuffer *buffer,
+ const GstAudioChannelPosition *from_position,
+ gint from_channels,
+ const GstAudioChannelPosition *to_position,
+ gint to_channels,
+ const gfloat **matrix);
+
+
+#define GST_AUDIO_CLIPPING_META_API_TYPE (gst_audio_clipping_meta_api_get_type())
+#define GST_AUDIO_CLIPPING_META_INFO (gst_audio_clipping_meta_get_info())
+
+typedef struct _GstAudioClippingMeta GstAudioClippingMeta;
+
+/**
+ * GstAudioClippingMeta:
+ * @meta: parent #GstMeta
+ * @format: GstFormat of @start and @stop, GST_FORMAT_DEFAULT is samples
+ * @start: Amount of audio to clip from start of buffer
+ * @end: Amount of to clip from end of buffer
+ *
+ * Extra buffer metadata describing how much audio has to be clipped from
+ * the start or end of a buffer. This is used for compressed formats, where
+ * the first frame usually has some additional samples due to encoder and
+ * decoder delays, and the last frame usually has some additional samples to
+ * be able to fill the complete last frame.
+ *
+ * This is used to ensure that decoded data in the end has the same amount of
+ * samples, and multiply decoded streams can be gaplessly concatenated.
+ *
+ * Note: If clipping of the start is done by adjusting the segment, this meta
+ * has to be dropped from buffers as otherwise clipping could happen twice.
+ *
+ * Since: 1.8
+ */
+struct _GstAudioClippingMeta {
+ GstMeta meta;
+
+ GstFormat format;
+ guint64 start;
+ guint64 end;
+};
+
+GST_AUDIO_API
+GType gst_audio_clipping_meta_api_get_type (void);
+
+GST_AUDIO_API
+const GstMetaInfo * gst_audio_clipping_meta_get_info (void);
+
+#define gst_buffer_get_audio_clipping_meta(b) ((GstAudioClippingMeta*)gst_buffer_get_meta((b), GST_AUDIO_CLIPPING_META_API_TYPE))
+
+GST_AUDIO_API
+GstAudioClippingMeta * gst_buffer_add_audio_clipping_meta (GstBuffer *buffer,
+ GstFormat format,
+ guint64 start,
+ guint64 end);
+
+
+#define GST_AUDIO_META_API_TYPE (gst_audio_meta_api_get_type())
+#define GST_AUDIO_META_INFO (gst_audio_meta_get_info())
+
+typedef struct _GstAudioMeta GstAudioMeta;
+
+/**
+ * GstAudioMeta:
+ * @meta: parent #GstMeta
+ * @info: the audio properties of the buffer
+ * @samples: the number of valid samples in the buffer
+ * @offsets: the offsets (in bytes) where each channel plane starts in the
+ * buffer or %NULL if the buffer has interleaved layout; if not %NULL, this
+ * is guaranteed to be an array of @info.channels elements
+ *
+ * Buffer metadata describing how data is laid out inside the buffer. This
+ * is useful for non-interleaved (planar) buffers, where it is necessary to
+ * have a place to store where each plane starts and how long each plane is.
+ *
+ * It is a requirement for non-interleaved buffers to have this metadata
+ * attached and to be mapped with gst_audio_buffer_map() in order to ensure
+ * correct handling of clipping and channel reordering.
+ *
+ * The different channels in @offsets are always in the GStreamer channel order.
+ * Zero-copy channel reordering can be implemented by swapping the values in
+ * @offsets.
+ *
+ * It is not allowed for channels to overlap in memory,
+ * i.e. for each i in [0, channels), the range
+ * [@offsets[i], @offsets[i] + @samples * sample_stride) must not overlap
+ * with any other such range.
+ *
+ * It is, however, allowed to have parts of the buffer memory unused,
+ * by using @offsets and @samples in such a way that leave gaps on it.
+ * This is used to implement zero-copy clipping in non-interleaved buffers.
+ *
+ * Obviously, due to the above, it is not safe to infer the
+ * number of valid samples from the size of the buffer. You should always
+ * use the @samples variable of this metadata.
+ *
+ * Note that for interleaved audio it is not a requirement to have this
+ * metadata attached and at the moment of writing, there is actually no use
+ * case to do so. It is, however, allowed to attach it, for some potential
+ * future use case.
+ *
+ * Since: 1.16
+ */
+struct _GstAudioMeta {
+ GstMeta meta;
+
+ GstAudioInfo info;
+ gsize samples;
+ gsize *offsets;
+
+ /*< private >*/
+ gsize priv_offsets_arr[8];
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_meta_api_get_type (void);
+
+GST_AUDIO_API
+const GstMetaInfo * gst_audio_meta_get_info (void);
+
+#define gst_buffer_get_audio_meta(b) \
+ ((GstAudioMeta*)gst_buffer_get_meta((b), GST_AUDIO_META_API_TYPE))
+
+GST_AUDIO_API
+GstAudioMeta * gst_buffer_add_audio_meta (GstBuffer *buffer,
+ const GstAudioInfo *info,
+ gsize samples, gsize offsets[]);
+
+/**
+ * GST_AUDIO_LEVEL_META_API_TYPE:
+ *
+ * The #GType associated with #GstAudioLevelMeta.
+ *
+ * Since: 1.20
+ */
+#define GST_AUDIO_LEVEL_META_API_TYPE (gst_audio_level_meta_api_get_type())
+/**
+ * GST_AUDIO_LEVEL_META_INFO:
+ *
+ * The #GstMetaInfo associated with #GstAudioLevelMeta.
+ *
+ * Since: 1.20
+ */
+#define GST_AUDIO_LEVEL_META_INFO (gst_audio_level_meta_get_info())
+typedef struct _GstAudioLevelMeta GstAudioLevelMeta;
+
+/**
+ * GstAudioLevelMeta:
+ * @meta: parent #GstMeta
+ * @level: the -dBov from 0-127 (127 is silence).
+ * @voice_activity: whether the buffer contains voice activity
+ *
+ * Meta containing Audio Level Indication: https://tools.ietf.org/html/rfc6464
+ *
+ * Since: 1.20
+ */
+struct _GstAudioLevelMeta
+{
+ GstMeta meta;
+
+ guint8 level;
+ gboolean voice_activity;
+};
+
+GST_AUDIO_API
+GType gst_audio_level_meta_api_get_type (void);
+
+GST_AUDIO_API
+const GstMetaInfo * gst_audio_level_meta_get_info (void);
+
+GST_AUDIO_API
+GstAudioLevelMeta * gst_buffer_add_audio_level_meta (GstBuffer * buffer,
+ guint8 level,
+ gboolean voice_activity);
+GST_AUDIO_API
+GstAudioLevelMeta * gst_buffer_get_audio_level_meta (GstBuffer * buffer);
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_META_H__ */
diff --git a/include/gst/audio/gstaudioringbuffer.h b/include/gst/audio/gstaudioringbuffer.h
new file mode 100644
index 0000000000..615041f71d
--- /dev/null
+++ b/include/gst/audio/gstaudioringbuffer.h
@@ -0,0 +1,414 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2005 Wim Taymans <wim@fluendo.com>
+ *
+ * gstaudioringbuffer.h:
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_RING_BUFFER_H__
+#define __GST_AUDIO_RING_BUFFER_H__
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_RING_BUFFER (gst_audio_ring_buffer_get_type())
+#define GST_AUDIO_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_RING_BUFFER,GstAudioRingBuffer))
+#define GST_AUDIO_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_RING_BUFFER,GstAudioRingBufferClass))
+#define GST_AUDIO_RING_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AUDIO_RING_BUFFER, GstAudioRingBufferClass))
+#define GST_AUDIO_RING_BUFFER_CAST(obj) ((GstAudioRingBuffer *)obj)
+#define GST_IS_AUDIO_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_RING_BUFFER))
+#define GST_IS_AUDIO_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_RING_BUFFER))
+
+typedef struct _GstAudioRingBuffer GstAudioRingBuffer;
+typedef struct _GstAudioRingBufferClass GstAudioRingBufferClass;
+typedef struct _GstAudioRingBufferSpec GstAudioRingBufferSpec;
+
+/**
+ * GstAudioRingBufferCallback:
+ * @rbuf: a #GstAudioRingBuffer
+ * @data: (array length=len): target to fill
+ * @len: amount to fill
+ * @user_data: user data
+ *
+ * This function is set with gst_audio_ring_buffer_set_callback() and is
+ * called to fill the memory at @data with @len bytes of samples.
+ */
+typedef void (*GstAudioRingBufferCallback) (GstAudioRingBuffer *rbuf, guint8* data, guint len, gpointer user_data);
+
+/**
+ * GstAudioRingBufferState:
+ * @GST_AUDIO_RING_BUFFER_STATE_STOPPED: The ringbuffer is stopped
+ * @GST_AUDIO_RING_BUFFER_STATE_PAUSED: The ringbuffer is paused
+ * @GST_AUDIO_RING_BUFFER_STATE_STARTED: The ringbuffer is started
+ * @GST_AUDIO_RING_BUFFER_STATE_ERROR: The ringbuffer has encountered an
+ * error after it has been started, e.g. because the device was
+ * disconnected (Since: 1.2)
+ *
+ * The state of the ringbuffer.
+ */
+typedef enum {
+ GST_AUDIO_RING_BUFFER_STATE_STOPPED,
+ GST_AUDIO_RING_BUFFER_STATE_PAUSED,
+ GST_AUDIO_RING_BUFFER_STATE_STARTED,
+ GST_AUDIO_RING_BUFFER_STATE_ERROR
+} GstAudioRingBufferState;
+
+/**
+ * GstAudioRingBufferFormatType:
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW: samples in linear or float
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MU_LAW: samples in mulaw
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_A_LAW: samples in alaw
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IMA_ADPCM: samples in ima adpcm
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG: samples in mpeg audio (but not AAC) format
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_GSM: samples in gsm format
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IEC958: samples in IEC958 frames (e.g. AC3)
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3: samples in AC3 format
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3: samples in EAC3 format
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS: samples in DTS format
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC: samples in MPEG-2 AAC ADTS format
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC: samples in MPEG-4 AAC ADTS format
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC_RAW: samples in MPEG-2 AAC raw format (Since: 1.12)
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC_RAW: samples in MPEG-4 AAC raw format (Since: 1.12)
+ * @GST_AUDIO_RING_BUFFER_FORMAT_TYPE_FLAC: samples in FLAC format (Since: 1.12)
+ *
+ * The format of the samples in the ringbuffer.
+ */
+typedef enum
+{
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MU_LAW,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_A_LAW,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IMA_ADPCM,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_GSM,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IEC958,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC_RAW,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC_RAW,
+ GST_AUDIO_RING_BUFFER_FORMAT_TYPE_FLAC
+} GstAudioRingBufferFormatType;
+
+/**
+ * GstAudioRingBufferSpec:
+ * @caps: The caps that generated the Spec.
+ * @type: the sample type
+ * @info: the #GstAudioInfo
+ * @latency_time: the latency in microseconds
+ * @buffer_time: the total buffer size in microseconds
+ * @segsize: the size of one segment in bytes
+ * @segtotal: the total number of segments
+ * @seglatency: number of segments queued in the lower level device,
+ * defaults to segtotal
+ *
+ * The structure containing the format specification of the ringbuffer.
+ */
+struct _GstAudioRingBufferSpec
+{
+ /*< public >*/
+ /* in */
+ GstCaps *caps; /* the caps of the buffer */
+
+ /* in/out */
+ GstAudioRingBufferFormatType type;
+ GstAudioInfo info;
+
+
+ guint64 latency_time; /* the required/actual latency time, this is the
+ * actual the size of one segment and the
+ * minimum possible latency we can achieve. */
+ guint64 buffer_time; /* the required/actual time of the buffer, this is
+ * the total size of the buffer and maximum
+ * latency we can compensate for. */
+ gint segsize; /* size of one buffer segment in bytes, this value
+ * should be chosen to match latency_time as
+ * well as possible. */
+ gint segtotal; /* total number of segments, this value is the
+ * number of segments of @segsize and should be
+ * chosen so that it matches buffer_time as
+ * close as possible. */
+ /* ABI added 0.10.20 */
+ gint seglatency; /* number of segments queued in the lower
+ * level device, defaults to segtotal. */
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+#define GST_AUDIO_RING_BUFFER_GET_COND(buf) (&(((GstAudioRingBuffer *)buf)->cond))
+#define GST_AUDIO_RING_BUFFER_WAIT(buf) (g_cond_wait (GST_AUDIO_RING_BUFFER_GET_COND (buf), GST_OBJECT_GET_LOCK (buf)))
+#define GST_AUDIO_RING_BUFFER_SIGNAL(buf) (g_cond_signal (GST_AUDIO_RING_BUFFER_GET_COND (buf)))
+#define GST_AUDIO_RING_BUFFER_BROADCAST(buf)(g_cond_broadcast (GST_AUDIO_RING_BUFFER_GET_COND (buf)))
+
+/**
+ * GstAudioRingBuffer:
+ * @cond: used to signal start/stop/pause/resume actions
+ * @open: boolean indicating that the ringbuffer is open
+ * @acquired: boolean indicating that the ringbuffer is acquired
+ * @memory: data in the ringbuffer
+ * @size: size of data in the ringbuffer
+ * @spec: format and layout of the ringbuffer data
+ * @samples_per_seg: number of samples in one segment
+ * @empty_seg: pointer to memory holding one segment of silence samples
+ * @state: state of the buffer
+ * @segdone: readpointer in the ringbuffer
+ * @segbase: segment corresponding to segment 0 (unused)
+ * @waiting: is a reader or writer waiting for a free segment
+ *
+ * The ringbuffer base class structure.
+ */
+struct _GstAudioRingBuffer {
+ GstObject object;
+
+ /*< public >*/ /* with LOCK */
+ GCond cond;
+ gboolean open;
+ gboolean acquired;
+ guint8 *memory;
+ gsize size;
+ /*< private >*/
+ GstClockTime *timestamps;
+ /*< public >*/ /* with LOCK */
+ GstAudioRingBufferSpec spec;
+ gint samples_per_seg;
+ guint8 *empty_seg;
+
+ /*< public >*/ /* ATOMIC */
+ gint state;
+ gint segdone;
+ gint segbase;
+ gint waiting;
+
+ /*< private >*/
+ GstAudioRingBufferCallback callback;
+ gpointer cb_data;
+
+ gboolean need_reorder;
+ /* gst[channel_reorder_map[i]] = device[i] */
+ gint channel_reorder_map[64];
+
+ gboolean flushing;
+ /* ATOMIC */
+ gint may_start;
+ gboolean active;
+
+ GDestroyNotify cb_data_notify;
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING - 1];
+};
+
+/**
+ * GstAudioRingBufferClass:
+ * @parent_class: parent class
+ * @open_device: open the device, don't set any params or allocate anything
+ * @acquire: allocate the resources for the ringbuffer using the given spec
+ * @release: free resources of the ringbuffer
+ * @close_device: close the device
+ * @start: start processing of samples
+ * @pause: pause processing of samples
+ * @resume: resume processing of samples after pause
+ * @stop: stop processing of samples
+ * @delay: get number of frames queued in device
+ * @activate: activate the thread that starts pulling and monitoring the
+ * consumed segments in the device.
+ * @commit: write samples into the ringbuffer
+ * @clear_all: Optional.
+ * Clear the entire ringbuffer.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ *
+ * The vmethods that subclasses can override to implement the ringbuffer.
+ */
+struct _GstAudioRingBufferClass {
+ GstObjectClass parent_class;
+
+ /*< public >*/
+ gboolean (*open_device) (GstAudioRingBuffer *buf);
+ gboolean (*acquire) (GstAudioRingBuffer *buf, GstAudioRingBufferSpec *spec);
+ gboolean (*release) (GstAudioRingBuffer *buf);
+ gboolean (*close_device) (GstAudioRingBuffer *buf);
+
+ gboolean (*start) (GstAudioRingBuffer *buf);
+ gboolean (*pause) (GstAudioRingBuffer *buf);
+ gboolean (*resume) (GstAudioRingBuffer *buf);
+ gboolean (*stop) (GstAudioRingBuffer *buf);
+
+ guint (*delay) (GstAudioRingBuffer *buf);
+
+ /* ABI added */
+ gboolean (*activate) (GstAudioRingBuffer *buf, gboolean active);
+
+ guint (*commit) (GstAudioRingBuffer * buf, guint64 *sample,
+ guint8 * data, gint in_samples,
+ gint out_samples, gint * accum);
+
+ void (*clear_all) (GstAudioRingBuffer * buf);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_ring_buffer_get_type(void);
+
+/* callback stuff */
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_set_callback (GstAudioRingBuffer *buf,
+ GstAudioRingBufferCallback cb,
+ gpointer user_data);
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_set_callback_full (GstAudioRingBuffer *buf,
+ GstAudioRingBufferCallback cb,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_parse_caps (GstAudioRingBufferSpec *spec, GstCaps *caps);
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_debug_spec_caps (GstAudioRingBufferSpec *spec);
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_debug_spec_buff (GstAudioRingBufferSpec *spec);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_convert (GstAudioRingBuffer * buf, GstFormat src_fmt,
+ gint64 src_val, GstFormat dest_fmt,
+ gint64 * dest_val);
+
+/* device state */
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_open_device (GstAudioRingBuffer *buf);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_close_device (GstAudioRingBuffer *buf);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_device_is_open (GstAudioRingBuffer *buf);
+
+/* allocate resources */
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_acquire (GstAudioRingBuffer *buf, GstAudioRingBufferSpec *spec);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_release (GstAudioRingBuffer *buf);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_is_acquired (GstAudioRingBuffer *buf);
+
+/* set the device channel positions */
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_set_channel_positions (GstAudioRingBuffer *buf, const GstAudioChannelPosition *position);
+
+/* activating */
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_activate (GstAudioRingBuffer *buf, gboolean active);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_is_active (GstAudioRingBuffer *buf);
+
+/* flushing */
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_set_flushing (GstAudioRingBuffer *buf, gboolean flushing);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_is_flushing (GstAudioRingBuffer *buf);
+
+/* playback/pause */
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_start (GstAudioRingBuffer *buf);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_pause (GstAudioRingBuffer *buf);
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_stop (GstAudioRingBuffer *buf);
+
+/* get status */
+
+GST_AUDIO_API
+guint gst_audio_ring_buffer_delay (GstAudioRingBuffer *buf);
+
+GST_AUDIO_API
+guint64 gst_audio_ring_buffer_samples_done (GstAudioRingBuffer *buf);
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_set_sample (GstAudioRingBuffer *buf, guint64 sample);
+
+/* clear all segments */
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_clear_all (GstAudioRingBuffer *buf);
+
+/* commit samples */
+
+GST_AUDIO_API
+guint gst_audio_ring_buffer_commit (GstAudioRingBuffer * buf, guint64 *sample,
+ guint8 * data, gint in_samples,
+ gint out_samples, gint * accum);
+
+/* read samples */
+
+GST_AUDIO_API
+guint gst_audio_ring_buffer_read (GstAudioRingBuffer *buf, guint64 sample,
+ guint8 *data, guint len, GstClockTime *timestamp);
+
+/* Set timestamp on buffer */
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_set_timestamp (GstAudioRingBuffer * buf, gint readseg, GstClockTime
+ timestamp);
+
+/* mostly protected */
+/* not yet implemented
+gboolean gst_audio_ring_buffer_prepare_write (GstAudioRingBuffer *buf, gint *segment, guint8 **writeptr, gint *len);
+*/
+
+GST_AUDIO_API
+gboolean gst_audio_ring_buffer_prepare_read (GstAudioRingBuffer *buf, gint *segment,
+ guint8 **readptr, gint *len);
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_clear (GstAudioRingBuffer *buf, gint segment);
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_advance (GstAudioRingBuffer *buf, guint advance);
+
+GST_AUDIO_API
+void gst_audio_ring_buffer_may_start (GstAudioRingBuffer *buf, gboolean allowed);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioRingBuffer, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_RING_BUFFER_H__ */
diff --git a/include/gst/audio/gstaudiosink.h b/include/gst/audio/gstaudiosink.h
new file mode 100644
index 0000000000..06f65ffa33
--- /dev/null
+++ b/include/gst/audio/gstaudiosink.h
@@ -0,0 +1,136 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2005 Wim Taymans <wim@fluendo.com>
+ *
+ * gstaudiosink.h:
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_SINK_H__
+#define __GST_AUDIO_SINK_H__
+
+#include <gst/gst.h>
+#include <gst/audio/gstaudiobasesink.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_SINK (gst_audio_sink_get_type())
+#define GST_AUDIO_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_SINK,GstAudioSink))
+#define GST_AUDIO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_SINK,GstAudioSinkClass))
+#define GST_AUDIO_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_SINK,GstAudioSinkClass))
+#define GST_IS_AUDIO_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_SINK))
+#define GST_IS_AUDIO_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_SINK))
+
+typedef struct _GstAudioSink GstAudioSink;
+typedef struct _GstAudioSinkClass GstAudioSinkClass;
+typedef struct _GstAudioSinkClassExtension GstAudioSinkClassExtension;
+
+/**
+ * GstAudioSink:
+ *
+ * Opaque #GstAudioSink.
+ */
+struct _GstAudioSink {
+ GstAudioBaseSink element;
+
+ /*< private >*/ /* with LOCK */
+ GThread *thread;
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+/**
+ * GstAudioSinkClass:
+ * @parent_class: the parent class structure.
+ * @open: Open the device. No configuration needs to be done at this point.
+ * This function is also used to check if the device is available.
+ * @prepare: Prepare the device to operate with the specified parameters.
+ * @unprepare: Undo operations done in prepare.
+ * @close: Close the device.
+ * @write: Write data to the device.
+ * This vmethod is allowed to block until all the data is written.
+ * If such is the case then it is expected that pause, stop and
+ * reset will unblock the write when called.
+ * @delay: Return how many frames are still in the device. Participates in
+ * computing the time for audio clocks and drives the synchronisation.
+ * @reset: Returns as quickly as possible from a write and flush any pending
+ * samples from the device.
+ * This vmethod is deprecated. Please provide pause and stop instead.
+ * @pause: Pause the device and unblock write as fast as possible.
+ * For retro compatibility, the audio sink will fallback
+ * to calling reset if this vmethod is not provided. Since: 1.18
+ * @resume: Resume the device. Since: 1.18
+ * @stop: Stop the device and unblock write as fast as possible.
+ * Pending samples are flushed from the device.
+ * For retro compatibility, the audio sink will fallback
+ * to calling reset if this vmethod is not provided. Since: 1.18
+ * @extension: class extension structure. Since: 1.18
+ */
+struct _GstAudioSinkClass {
+ GstAudioBaseSinkClass parent_class;
+
+ /* vtable */
+
+ /* open the device with given specs */
+ gboolean (*open) (GstAudioSink *sink);
+ /* prepare resources and state to operate with the given specs */
+ gboolean (*prepare) (GstAudioSink *sink, GstAudioRingBufferSpec *spec);
+ /* undo anything that was done in prepare() */
+ gboolean (*unprepare) (GstAudioSink *sink);
+ /* close the device */
+ gboolean (*close) (GstAudioSink *sink);
+ /* write samples to the device */
+ gint (*write) (GstAudioSink *sink, gpointer data, guint length);
+ /* get number of frames queued in the device */
+ guint (*delay) (GstAudioSink *sink);
+ /* deprecated: reset the audio device, unblock from a write */
+ void (*reset) (GstAudioSink *sink);
+ /* pause the audio device, unblock from a write */
+ void (*pause) (GstAudioSink *sink);
+ /* resume the audio device */
+ void (*resume) (GstAudioSink *sink);
+ /* stop the audio device, unblock from a write */
+ void (*stop) (GstAudioSink *sink);
+
+ GstAudioSinkClassExtension *extension;
+};
+
+/**
+ * GstAudioSinkClassExtension:
+ * @clear-all: Clear the device. Since: 1.18
+ */
+struct _GstAudioSinkClassExtension
+{
+ /* clear the audio device */
+ void (*clear_all) (GstAudioSink *sink);
+
+ /* no padding needed */
+};
+
+GST_AUDIO_API
+GType gst_audio_sink_get_type(void);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioSink, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_SINK_H__ */
diff --git a/include/gst/audio/gstaudiosrc.h b/include/gst/audio/gstaudiosrc.h
new file mode 100644
index 0000000000..93cb5d06eb
--- /dev/null
+++ b/include/gst/audio/gstaudiosrc.h
@@ -0,0 +1,106 @@
+/* GStreamer
+ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
+ * 2005 Wim Taymans <wim@fluendo.com>
+ *
+ * gstaudiosrc.h:
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_AUDIO_H__
+#include <gst/audio/audio.h>
+#endif
+
+#ifndef __GST_AUDIO_SRC_H__
+#define __GST_AUDIO_SRC_H__
+
+#include <gst/gst.h>
+#include <gst/audio/gstaudiobasesrc.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_SRC (gst_audio_src_get_type())
+#define GST_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_SRC,GstAudioSrc))
+#define GST_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_SRC,GstAudioSrcClass))
+#define GST_AUDIO_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_AUDIO_SRC,GstAudioSrcClass))
+#define GST_IS_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_SRC))
+#define GST_IS_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_SRC))
+
+typedef struct _GstAudioSrc GstAudioSrc;
+typedef struct _GstAudioSrcClass GstAudioSrcClass;
+
+/**
+ * GstAudioSrc:
+ *
+ * Base class for simple audio sources.
+ */
+struct _GstAudioSrc {
+ GstAudioBaseSrc element;
+
+ /*< private >*/ /* with LOCK */
+ GThread *thread;
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+/**
+ * GstAudioSrcClass:
+ * @parent_class: the parent class.
+ * @open: open the device with the specified caps
+ * @prepare: configure device with format
+ * @unprepare: undo the configuration
+ * @close: close the device
+ * @read: read samples from the audio device
+ * @delay: the number of frames queued in the device
+ * @reset: unblock a read to the device and reset.
+ *
+ * #GstAudioSrc class. Override the vmethod to implement
+ * functionality.
+ */
+struct _GstAudioSrcClass {
+ GstAudioBaseSrcClass parent_class;
+
+ /* vtable */
+
+ /* open the device with given specs */
+ gboolean (*open) (GstAudioSrc *src);
+ /* prepare resources and state to operate with the given specs */
+ gboolean (*prepare) (GstAudioSrc *src, GstAudioRingBufferSpec *spec);
+ /* undo anything that was done in prepare() */
+ gboolean (*unprepare) (GstAudioSrc *src);
+ /* close the device */
+ gboolean (*close) (GstAudioSrc *src);
+ /* read samples from the device */
+ guint (*read) (GstAudioSrc *src, gpointer data, guint length,
+ GstClockTime *timestamp);
+ /* get number of frames queued in the device */
+ guint (*delay) (GstAudioSrc *src);
+ /* reset the audio device, unblock from a write */
+ void (*reset) (GstAudioSrc *src);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
+};
+
+GST_AUDIO_API
+GType gst_audio_src_get_type(void);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAudioSrc, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_SRC_H__ */
diff --git a/include/gst/audio/gstaudiostreamalign.h b/include/gst/audio/gstaudiostreamalign.h
new file mode 100644
index 0000000000..080e9ea44b
--- /dev/null
+++ b/include/gst/audio/gstaudiostreamalign.h
@@ -0,0 +1,92 @@
+/* GStreamer
+ * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
+ *
+ * gstaudiostreamalign.h:
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_AUDIO_STREAM_ALIGN_H__
+#define __GST_AUDIO_STREAM_ALIGN_H__
+
+#include <gst/gst.h>
+#include <gst/audio/audio-prelude.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_AUDIO_INFO_STREAM_ALIGN (gst_audio_stream_align_get_type ())
+
+/**
+ * GstAudioStreamAlign:
+ *
+ * The opaque #GstAudioStreamAlign data structure.
+ *
+ * Since: 1.14
+ */
+typedef struct _GstAudioStreamAlign GstAudioStreamAlign;
+
+GST_AUDIO_API
+GType gst_audio_stream_align_get_type (void);
+
+GST_AUDIO_API
+GstAudioStreamAlign * gst_audio_stream_align_new (gint rate,
+ GstClockTime alignment_threshold,
+ GstClockTime discont_wait);
+GST_AUDIO_API
+GstAudioStreamAlign * gst_audio_stream_align_copy (const GstAudioStreamAlign * align);
+GST_AUDIO_API
+void gst_audio_stream_align_free (GstAudioStreamAlign * align);
+
+GST_AUDIO_API
+void gst_audio_stream_align_set_rate (GstAudioStreamAlign * align,
+ gint rate);
+GST_AUDIO_API
+gint gst_audio_stream_align_get_rate (const GstAudioStreamAlign * align);
+
+GST_AUDIO_API
+void gst_audio_stream_align_set_alignment_threshold (GstAudioStreamAlign * align,
+ GstClockTime alignment_threshold);
+GST_AUDIO_API
+GstClockTime gst_audio_stream_align_get_alignment_threshold (const GstAudioStreamAlign * align);
+
+GST_AUDIO_API
+void gst_audio_stream_align_set_discont_wait (GstAudioStreamAlign * align,
+ GstClockTime discont_wait);
+GST_AUDIO_API
+GstClockTime gst_audio_stream_align_get_discont_wait (const GstAudioStreamAlign * align);
+
+
+GST_AUDIO_API
+void gst_audio_stream_align_mark_discont (GstAudioStreamAlign * align);
+
+GST_AUDIO_API
+GstClockTime gst_audio_stream_align_get_timestamp_at_discont (const GstAudioStreamAlign * align);
+
+GST_AUDIO_API
+guint64 gst_audio_stream_align_get_samples_since_discont (const GstAudioStreamAlign * align);
+
+GST_AUDIO_API
+gboolean gst_audio_stream_align_process (GstAudioStreamAlign * align,
+ gboolean discont,
+ GstClockTime timestamp,
+ guint n_samples,
+ GstClockTime *out_timestamp,
+ GstClockTime *out_duration,
+ guint64 *out_sample_position);
+
+G_END_DECLS
+
+#endif /* __GST_AUDIO_STREAM_ALIGN_H__ */
diff --git a/include/gst/audio/gstnonstreamaudiodecoder.h b/include/gst/audio/gstnonstreamaudiodecoder.h
new file mode 100644
index 0000000000..4de1fc7ee9
--- /dev/null
+++ b/include/gst/audio/gstnonstreamaudiodecoder.h
@@ -0,0 +1,412 @@
+/* GStreamer
+ * Copyright (C) <2017> Carlos Rafael Giani <dv at pseudoterminal dot org>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef __GST_NONSTREAM_AUDIO_DECODER_H__
+#define __GST_NONSTREAM_AUDIO_DECODER_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstadapter.h>
+#include <gst/audio/audio.h>
+#include <gst/audio/audio-bad-prelude.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _GstNonstreamAudioDecoder GstNonstreamAudioDecoder;
+typedef struct _GstNonstreamAudioDecoderClass GstNonstreamAudioDecoderClass;
+
+
+/**
+ * GstNonstreamAudioOutputMode:
+ * @GST_NONSTREAM_AUDIO_OUTPUT_MODE_LOOPING: Playback position is moved back to the beginning of the loop
+ * @GST_NONSTREAM_AUDIO_OUTPUT_MODE_STEADY: Playback position increases steadily, even when looping
+ *
+ * The output mode defines how the output behaves with regards to looping. Either the playback position is
+ * moved back to the beginning of the loop, acting like a backwards seek, or it increases steadily, as if
+ * loop were "unrolled".
+ */
+typedef enum
+{
+ GST_NONSTREAM_AUDIO_OUTPUT_MODE_LOOPING,
+ GST_NONSTREAM_AUDIO_OUTPUT_MODE_STEADY
+} GstNonstreamAudioOutputMode;
+
+
+/**
+ * GstNonstreamAudioSubsongMode:
+ * @GST_NONSTREAM_AUDIO_SUBSONG_MODE_SINGLE: Only the current subsong is played
+ * @GST_NONSTREAM_AUDIO_SUBSONG_MODE_ALL: All subsongs are played (current subsong index is ignored)
+ * @GST_NONSTREAM_AUDIO_SUBSONG_MODE_DECODER_DEFAULT: Use decoder specific default behavior
+ *
+ * The subsong mode defines how the decoder shall handle subsongs.
+ */
+typedef enum
+{
+ GST_NONSTREAM_AUDIO_SUBSONG_MODE_SINGLE,
+ GST_NONSTREAM_AUDIO_SUBSONG_MODE_ALL,
+ GST_NONSTREAM_AUDIO_SUBSONG_MODE_DECODER_DEFAULT
+} GstNonstreamAudioSubsongMode;
+
+
+#define GST_TYPE_NONSTREAM_AUDIO_DECODER (gst_nonstream_audio_decoder_get_type())
+#define GST_NONSTREAM_AUDIO_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_NONSTREAM_AUDIO_DECODER, GstNonstreamAudioDecoder))
+#define GST_NONSTREAM_AUDIO_DECODER_CAST(obj) ((GstNonstreamAudioDecoder *)(obj))
+#define GST_NONSTREAM_AUDIO_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_NONSTREAM_AUDIO_DECODER, GstNonstreamAudioDecoderClass))
+#define GST_NONSTREAM_AUDIO_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_NONSTREAM_AUDIO_DECODER, GstNonstreamAudioDecoderClass))
+#define GST_IS_NONSTREAM_AUDIO_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_NONSTREAM_AUDIO_DECODER))
+#define GST_IS_NONSTREAM_AUDIO_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_NONSTREAM_AUDIO_DECODER))
+
+/**
+ * GST_NONSTREAM_AUDIO_DECODER_SINK_NAME:
+ *
+ * The name of the template for the sink pad.
+ */
+#define GST_NONSTREAM_AUDIO_DECODER_SINK_NAME "sink"
+/**
+ * GST_NONSTREAM_AUDIO_DECODER_SRC_NAME:
+ *
+ * The name of the template for the source pad.
+ */
+#define GST_NONSTREAM_AUDIO_DECODER_SRC_NAME "src"
+
+/**
+ * GST_NONSTREAM_AUDIO_DECODER_SINK_PAD:
+ * @obj: base nonstream audio codec instance
+ *
+ * Gives the pointer to the sink #GstPad object of the element.
+ */
+#define GST_NONSTREAM_AUDIO_DECODER_SINK_PAD(obj) (((GstNonstreamAudioDecoder *) (obj))->sinkpad)
+/**
+ * GST_NONSTREAM_AUDIO_DECODER_SRC_PAD:
+ * @obj: base nonstream audio codec instance
+ *
+ * Gives the pointer to the source #GstPad object of the element.
+ */
+#define GST_NONSTREAM_AUDIO_DECODER_SRC_PAD(obj) (((GstNonstreamAudioDecoder *) (obj))->srcpad)
+
+
+/**
+ * GST_NONSTREAM_AUDIO_DECODER_LOCK_MUTEX:
+ * @obj: base nonstream audio codec instance
+ *
+ * Locks the decoder mutex.
+ *
+ * Internally, the mutex is locked before one of the class vfuncs are
+ * called, when position and duration queries are handled, and when
+ * properties are set/retrieved.
+ *
+ * Derived classes should call lock during decoder related modifications
+ * (for example, setting/clearing filter banks), when at the same time
+ * audio might get decoded. An example are configuration changes that
+ * happen when properties are set. Properties might be set from another
+ * thread, so while the derived decoder is reconfigured, the mutex
+ * should be locked.
+ */
+#define GST_NONSTREAM_AUDIO_DECODER_LOCK_MUTEX(obj) g_mutex_lock(&(((GstNonstreamAudioDecoder *)(obj))->mutex))
+#define GST_NONSTREAM_AUDIO_DECODER_UNLOCK_MUTEX(obj) g_mutex_unlock(&(((GstNonstreamAudioDecoder *)(obj))->mutex))
+
+
+/**
+ * GstNonstreamAudioDecoder:
+ *
+ * The opaque #GstNonstreamAudioDecoder data structure.
+ */
+struct _GstNonstreamAudioDecoder
+{
+ GstElement element;
+
+ /*< protected > */
+
+ /* source and sink pads */
+ GstPad *sinkpad, *srcpad;
+
+ /* loading information */
+ gint64 upstream_size;
+ gboolean loaded_mode;
+ GstAdapter *input_data_adapter;
+
+ /* subsong states */
+ guint current_subsong;
+ GstNonstreamAudioSubsongMode subsong_mode;
+ GstClockTime subsong_duration;
+
+ /* output states */
+ GstNonstreamAudioOutputMode output_mode;
+ gint num_loops;
+ gboolean output_format_changed;
+ GstAudioInfo output_audio_info;
+ /* The difference between these two values is: cur_pos_in_samples is
+ * used for the GstBuffer offsets, while num_decoded_samples is used
+ * for the segment base time values.
+ * cur_pos_in_samples is reset after seeking, looping (when output mode
+ * is LOOPING) and switching subsongs, while num_decoded is only reset
+ * to 0 after a flushing seek (because flushing seeks alter the
+ * pipeline's base_time). */
+ guint64 cur_pos_in_samples, num_decoded_samples;
+ GstSegment cur_segment;
+ gboolean discont;
+
+ /* metadata */
+ GstToc *toc;
+
+ /* allocation */
+ GstAllocator *allocator;
+ GstAllocationParams allocation_params;
+
+ /* thread safety */
+ GMutex mutex;
+};
+
+
+/**
+ * GstNonstreamAudioDecoderClass:
+ * @element_class: The parent class structure
+ * @seek: Optional.
+ * Called when a seek event is received by the parent class.
+ * new_position is a pointer to a GstClockTime integer which
+ * contains a position relative to the current subsong.
+ * Minimum is 0, maximum is the subsong length.
+ * After this function finishes, new_position is set to the
+ * actual new position (which may differ from the request
+ * position, depending on the decoder).
+ * @tell: Optional.
+ * Called when a position query is received by the parent class.
+ * The position that this function returns must be relative to
+ * the current subsong. Thus, the minimum is 0, and the maximum
+ * is the subsong length.
+ * @load_from_buffer: Required if loads_from_sinkpad is set to TRUE (the default value).
+ * Loads the media from the given buffer. The entire media is supplied at once,
+ * so after this call, loading should be finished. This function
+ * can also make use of a suggested initial subsong & subsong mode and initial
+ * playback position (but isn't required to). In case it chooses a different starting
+ * position, the function must pass this position to *initial_position.
+ * The subclass does not have to unref the input buffer; the base class does that
+ * already.
+ * @load_from_custom: Required if loads_from_sinkpad is set to FALSE.
+ * Loads the media in a way defined by the custom sink. Data is not supplied;
+ * the derived class has to handle this on its own. Otherwise, this function is
+ * identical to @load_from_buffer.
+ * @get_main_tags: Optional.
+ * Returns a tag list containing the main song tags, or NULL if there are
+ * no such tags. Returned tags will be unref'd. Use this vfunc instead of
+ * manually pushing a tag event downstream to avoid edge cases where not yet
+ * pushed sticky tag events get overwritten before they are pushed (can for
+ * example happen with decodebin if tags are pushed downstream before the
+ * decodebin pads are linked).
+ * @set_current_subsong: Optional.
+ * Sets the current subsong. This function is allowed to switch to a different
+ * subsong than the required one, and can optionally make use of the suggested initial
+ * position. In case it chooses a different starting position, the function must pass
+ * this position to *initial_position.
+ * This function switches the subsong mode to GST_NONSTREAM_AUDIO_SUBSONG_MODE_SINGLE
+ * automatically.
+ * If this function is implemented by the subclass, @get_current_subsong and
+ * @get_num_subsongs should be implemented as well.
+ * @get_current_subsong: Optional.
+ * Returns the current subsong.
+ * If the current subsong mode is not GST_NONSTREAM_AUDIO_SUBSONG_MODE_SINGLE, this
+ * function's return value is undefined.
+ * If this function is implemented by the subclass,
+ * @get_num_subsongs should be implemented as well.
+ * @get_num_subsongs: Optional.
+ * Returns the number of subsongs available.
+ * The return values 0 and 1 have a similar, but distinct, meaning.
+ * If this function returns 0, then this decoder does not support subsongs at all.
+ * @get_current_subsong must then also always return 0. In other words, this function
+ * either never returns 0, or never returns anything else than 0.
+ * A return value of 1 means that the media contains either only one or no subsongs
+ * (the entire song is then considered to be one single subsong). 1 also means that only
+ * this very media has no or just one subsong, and the decoder itself can
+ * support multiple subsongs.
+ * @get_subsong_duration: Optional.
+ * Returns the duration of a subsong. Returns GST_CLOCK_TIME_NONE if duration is unknown.
+ * @get_subsong_tags: Optional.
+ * Returns tags for a subsong, or NULL if there are no tags.
+ * Returned tags will be unref'd.
+ * @set_subsong_mode: Optional.
+ * Sets the current subsong mode. Since this might influence the current playback position,
+ * this function must set the initial_position integer argument to a defined value.
+ * If the playback position is not affected at all, it must be set to GST_CLOCK_TIME_NONE.
+ * If the subsong is restarted after the mode switch, it is recommended to set the value
+ * to the position in the playback right after the switch (or 0 if the subsongs are always
+ * reset back to the beginning).
+ * @set_num_loops: Optional.
+ * Sets the number of loops for playback. If this is called during playback,
+ * the subclass must set any internal loop counters to zero. A loop value of -1
+ * means infinite looping; 0 means no looping; and when the num_loops is greater than 0,
+ * playback should loop exactly num_loops times. If this function is implemented,
+ * @get_num_loops should be implemented as well. The function can ignore the given values
+ * and choose another; however, @get_num_loops should return this other value afterwards.
+ * It is up to the subclass to define where the loop starts and ends. It can mean that only
+ * a subset at the end or in the middle of a song is repeated, for example.
+ * If the current subsong mode is GST_NONSTREAM_AUDIO_SUBSONG_MODE_SINGLE, then the subsong
+ * is repeated this many times. If it is GST_NONSTREAM_AUDIO_SUBSONG_MODE_ALL, then all
+ * subsongs are repeated this many times. With GST_NONSTREAM_AUDIO_SUBSONG_MODE_DECODER_DEFAULT,
+ * the behavior is decoder specific.
+ * @get_num_loops: Optional.
+ * Returns the number of loops for playback.
+ * @get_supported_output_modes: Always required.
+ * Returns a bitmask containing the output modes the subclass supports.
+ * The mask is formed by a bitwise OR combination of integers, which can be calculated
+ * this way: 1 << GST_NONSTREAM_AUDIO_OUTPUT_MODE_<mode> , where mode is either STEADY or LOOPING
+ * @set_output_mode: Optional.
+ * Sets the output mode the subclass has to use. Unlike with most other functions, the subclass
+ * cannot choose a different mode; it must use the requested one.
+ * If the output mode is set to LOOPING, @gst_nonstream_audio_decoder_handle_loop
+ * must be called after playback moved back to the start of a loop.
+ * @decode: Always required.
+ * Allocates an output buffer, fills it with decoded audio samples, and must be passed on to
+ * *buffer . The number of decoded samples must be passed on to *num_samples.
+ * If decoding finishes or the decoding is no longer possible (for example, due to an
+ * unrecoverable error), this function returns FALSE, otherwise TRUE.
+ * @decide_allocation: Optional.
+ * Sets up the allocation parameters for allocating output
+ * buffers. The passed in query contains the result of the
+ * downstream allocation query.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ * @propose_allocation: Optional.
+ * Proposes buffer allocation parameters for upstream elements.
+ * Subclasses should chain up to the parent implementation to
+ * invoke the default handler.
+ *
+ * Subclasses can override any of the available optional virtual methods or not, as
+ * needed. At minimum, @load_from_buffer (or @load_from_custom), @get_supported_output_modes,
+ * and @decode need to be overridden.
+ *
+ * All functions are called with a locked decoder mutex.
+ *
+ * > If GST_ELEMENT_ERROR, GST_ELEMENT_WARNING, or GST_ELEMENT_INFO are called from
+ * > inside one of these functions, it is strongly recommended to unlock the decoder mutex
+ * > before and re-lock it after these macros to prevent potential deadlocks in case the
+ * > application does something with the element when it receives an ERROR/WARNING/INFO
+ * > message. Same goes for gst_element_post_message() calls and non-serialized events.
+ *
+ * By default, this class works by reading media data from the sinkpad, and then commencing
+ * playback. Some decoders cannot be given data from a memory block, so the usual way of
+ * reading all upstream data and passing it to @load_from_buffer doesn't work then. In this case,
+ * set the value of loads_from_sinkpad to FALSE. This changes the way this class operates;
+ * it does not require a sinkpad to exist anymore, and will call @load_from_custom instead.
+ * One example of a decoder where this makes sense is UADE (Unix Amiga Delitracker Emulator).
+ * For some formats (such as TFMX), it needs to do the file loading by itself.
+ * Since most decoders can read input data from a memory block, the default value of
+ * loads_from_sinkpad is TRUE.
+ */
+struct _GstNonstreamAudioDecoderClass
+{
+ GstElementClass element_class;
+
+ gboolean loads_from_sinkpad;
+
+ /*< public > */
+ /* virtual methods for subclasses */
+
+ gboolean (*seek) (GstNonstreamAudioDecoder * dec,
+ GstClockTime * new_position);
+ GstClockTime (*tell) (GstNonstreamAudioDecoder * dec);
+
+ gboolean (*load_from_buffer) (GstNonstreamAudioDecoder * dec,
+ GstBuffer * source_data,
+ guint initial_subsong,
+ GstNonstreamAudioSubsongMode initial_subsong_mode,
+ GstClockTime * initial_position,
+ GstNonstreamAudioOutputMode * initial_output_mode,
+ gint * initial_num_loops);
+ gboolean (*load_from_custom) (GstNonstreamAudioDecoder * dec,
+ guint initial_subsong,
+ GstNonstreamAudioSubsongMode initial_subsong_mode,
+ GstClockTime * initial_position,
+ GstNonstreamAudioOutputMode * initial_output_mode,
+ gint * initial_num_loops);
+
+ GstTagList * (*get_main_tags) (GstNonstreamAudioDecoder * dec);
+
+ gboolean (*set_current_subsong) (GstNonstreamAudioDecoder * dec,
+ guint subsong,
+ GstClockTime * initial_position);
+ guint (*get_current_subsong) (GstNonstreamAudioDecoder * dec);
+
+ guint (*get_num_subsongs) (GstNonstreamAudioDecoder * dec);
+ GstClockTime (*get_subsong_duration) (GstNonstreamAudioDecoder * dec,
+ guint subsong);
+ GstTagList * (*get_subsong_tags) (GstNonstreamAudioDecoder * dec,
+ guint subsong);
+ gboolean (*set_subsong_mode) (GstNonstreamAudioDecoder * dec,
+ GstNonstreamAudioSubsongMode mode,
+ GstClockTime * initial_position);
+
+ gboolean (*set_num_loops) (GstNonstreamAudioDecoder * dec,
+ gint num_loops);
+ gint (*get_num_loops) (GstNonstreamAudioDecoder * dec);
+
+ guint (*get_supported_output_modes) (GstNonstreamAudioDecoder * dec);
+ gboolean (*set_output_mode) (GstNonstreamAudioDecoder * dec,
+ GstNonstreamAudioOutputMode mode,
+ GstClockTime * current_position);
+
+ gboolean (*decode) (GstNonstreamAudioDecoder * dec,
+ GstBuffer ** buffer,
+ guint * num_samples);
+
+ gboolean (*negotiate) (GstNonstreamAudioDecoder * dec);
+
+ gboolean (*decide_allocation) (GstNonstreamAudioDecoder * dec,
+ GstQuery * query);
+ gboolean (*propose_allocation) (GstNonstreamAudioDecoder * dec,
+ GstQuery * query);
+
+ /*< private > */
+ gpointer _gst_reserved[GST_PADDING_LARGE];
+};
+
+
+GST_AUDIO_BAD_API
+GType gst_nonstream_audio_decoder_get_type (void);
+
+
+GST_AUDIO_BAD_API
+void gst_nonstream_audio_decoder_handle_loop (GstNonstreamAudioDecoder * dec,
+ GstClockTime new_position);
+
+GST_AUDIO_BAD_API
+gboolean gst_nonstream_audio_decoder_set_output_format (GstNonstreamAudioDecoder * dec,
+ GstAudioInfo const *audio_info);
+
+GST_AUDIO_BAD_API
+gboolean gst_nonstream_audio_decoder_set_output_format_simple (GstNonstreamAudioDecoder * dec,
+ guint sample_rate,
+ GstAudioFormat sample_format,
+ guint num_channels);
+
+GST_AUDIO_BAD_API
+void gst_nonstream_audio_decoder_get_downstream_info (GstNonstreamAudioDecoder * dec,
+ GstAudioFormat * format,
+ gint * sample_rate,
+ gint * num_channels);
+
+GST_AUDIO_BAD_API
+GstBuffer *gst_nonstream_audio_decoder_allocate_output_buffer (GstNonstreamAudioDecoder * dec,
+ gsize size);
+
+
+G_END_DECLS
+
+
+#endif /* __GST_NONSTREAM_AUDIO_DECODER_H__ */
diff --git a/include/gst/audio/gstplanaraudioadapter.h b/include/gst/audio/gstplanaraudioadapter.h
new file mode 100644
index 0000000000..0b97b5508d
--- /dev/null
+++ b/include/gst/audio/gstplanaraudioadapter.h
@@ -0,0 +1,116 @@
+/* GStreamer
+ * Copyright (C) 2018 Collabora Ltd.
+ * @author George Kiagiadakis <george.kiagiadakis@collabora.com>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_PLANAR_AUDIO_ADAPTER_H__
+#define __GST_PLANAR_AUDIO_ADAPTER_H__
+
+#ifndef GST_USE_UNSTABLE_API
+#warning "The Base library from gst-plugins-bad is unstable API and may change in future."
+#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
+#endif
+
+#include <gst/gst.h>
+#include <gst/audio/audio-info.h>
+#include <gst/audio/audio-bad-prelude.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_PLANAR_AUDIO_ADAPTER \
+ (gst_planar_audio_adapter_get_type())
+#define GST_PLANAR_AUDIO_ADAPTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_PLANAR_AUDIO_ADAPTER, GstPlanarAudioAdapter))
+#define GST_PLANAR_AUDIO_ADAPTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_PLANAR_AUDIO_ADAPTER, GstPlanarAudioAdapterClass))
+#define GST_PLANAR_AUDIO_ADAPTER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLANAR_AUDIO_ADAPTER, GstPlanarAudioAdapterClass))
+#define GST_IS_PLANAR_AUDIO_ADAPTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_PLANAR_AUDIO_ADAPTER))
+#define GST_IS_PLANAR_AUDIO_ADAPTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_PLANAR_AUDIO_ADAPTER))
+
+/**
+ * GstPlanarAudioAdapter:
+ *
+ * The opaque #GstPlanarAudioAdapter data structure.
+ */
+typedef struct _GstPlanarAudioAdapter GstPlanarAudioAdapter;
+typedef struct _GstPlanarAudioAdapterClass GstPlanarAudioAdapterClass;
+
+GST_AUDIO_BAD_API
+GType gst_planar_audio_adapter_get_type (void);
+
+GST_AUDIO_BAD_API
+GstPlanarAudioAdapter * gst_planar_audio_adapter_new (void) G_GNUC_MALLOC;
+
+GST_AUDIO_BAD_API
+void gst_planar_audio_adapter_configure (GstPlanarAudioAdapter * adapter,
+ const GstAudioInfo * info);
+
+GST_AUDIO_BAD_API
+void gst_planar_audio_adapter_clear (GstPlanarAudioAdapter * adapter);
+
+GST_AUDIO_BAD_API
+void gst_planar_audio_adapter_push (GstPlanarAudioAdapter * adapter,
+ GstBuffer * buf);
+
+GST_AUDIO_BAD_API
+void gst_planar_audio_adapter_flush (GstPlanarAudioAdapter * adapter,
+ gsize to_flush);
+
+GST_AUDIO_BAD_API
+GstBuffer * gst_planar_audio_adapter_get_buffer (GstPlanarAudioAdapter * adapter,
+ gsize nsamples, GstMapFlags flags);
+
+GST_AUDIO_BAD_API
+GstBuffer * gst_planar_audio_adapter_take_buffer (GstPlanarAudioAdapter * adapter,
+ gsize nsamples, GstMapFlags flags);
+
+GST_AUDIO_BAD_API
+gsize gst_planar_audio_adapter_available (GstPlanarAudioAdapter * adapter);
+
+GST_AUDIO_BAD_API
+guint64 gst_planar_audio_adapter_distance_from_discont (GstPlanarAudioAdapter * adapter);
+
+GST_AUDIO_BAD_API
+guint64 gst_planar_audio_adapter_offset_at_discont (GstPlanarAudioAdapter * adapter);
+
+GST_AUDIO_BAD_API
+GstClockTime gst_planar_audio_adapter_pts_at_discont (GstPlanarAudioAdapter * adapter);
+
+GST_AUDIO_BAD_API
+GstClockTime gst_planar_audio_adapter_dts_at_discont (GstPlanarAudioAdapter * adapter);
+
+GST_AUDIO_BAD_API
+guint64 gst_planar_audio_adapter_prev_offset (GstPlanarAudioAdapter * adapter,
+ guint64 * distance);
+
+GST_AUDIO_BAD_API
+GstClockTime gst_planar_audio_adapter_prev_pts (GstPlanarAudioAdapter * adapter,
+ guint64 * distance);
+
+GST_AUDIO_BAD_API
+GstClockTime gst_planar_audio_adapter_prev_dts (GstPlanarAudioAdapter * adapter,
+ guint64 * distance);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPlanarAudioAdapter, gst_object_unref)
+
+G_END_DECLS
+
+#endif /* __GST_PLANAR_AUDIO_ADAPTER_H__ */
diff --git a/include/gst/audio/streamvolume.h b/include/gst/audio/streamvolume.h
new file mode 100644
index 0000000000..2af4291aad
--- /dev/null
+++ b/include/gst/audio/streamvolume.h
@@ -0,0 +1,80 @@
+/* GStreamer StreamVolume
+ * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_STREAM_VOLUME_H__
+#define __GST_STREAM_VOLUME_H__
+
+#include <gst/gst.h>
+#include <gst/audio/audio-prelude.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_STREAM_VOLUME (gst_stream_volume_get_type ())
+GST_AUDIO_API
+G_DECLARE_INTERFACE (GstStreamVolume, gst_stream_volume, GST, STREAM_VOLUME,
+ GObject)
+
+#define GST_STREAM_VOLUME_GET_INTERFACE(obj) GST_STREAM_VOLUME_GET_IFACE(obj)
+
+struct _GstStreamVolumeInterface {
+ GTypeInterface iface;
+};
+
+/**
+ * GstStreamVolumeFormat:
+ * @GST_STREAM_VOLUME_FORMAT_LINEAR: Linear scale factor, 1.0 = 100%
+ * @GST_STREAM_VOLUME_FORMAT_CUBIC: Cubic volume scale
+ * @GST_STREAM_VOLUME_FORMAT_DB: Logarithmic volume scale (dB, amplitude not power)
+ *
+ * Different representations of a stream volume. gst_stream_volume_convert_volume()
+ * allows to convert between the different representations.
+ *
+ * Formulas to convert from a linear to a cubic or dB volume are
+ * cbrt(val) and 20 * log10 (val).
+ */
+typedef enum {
+ GST_STREAM_VOLUME_FORMAT_LINEAR = 0,
+ GST_STREAM_VOLUME_FORMAT_CUBIC,
+ GST_STREAM_VOLUME_FORMAT_DB
+} GstStreamVolumeFormat;
+
+GST_AUDIO_API
+void gst_stream_volume_set_volume (GstStreamVolume *volume,
+ GstStreamVolumeFormat format,
+ gdouble val);
+
+GST_AUDIO_API
+gdouble gst_stream_volume_get_volume (GstStreamVolume *volume,
+ GstStreamVolumeFormat format);
+
+GST_AUDIO_API
+void gst_stream_volume_set_mute (GstStreamVolume *volume,
+ gboolean mute);
+
+GST_AUDIO_API
+gboolean gst_stream_volume_get_mute (GstStreamVolume *volume);
+
+GST_AUDIO_API
+gdouble gst_stream_volume_convert_volume (GstStreamVolumeFormat from,
+ GstStreamVolumeFormat to,
+ gdouble val) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GST_STREAM_VOLUME_H__ */