stereo: Port to GStreamer 1.0 API

This commit is contained in:
Olivier Crête 2013-12-06 17:58:13 -05:00
parent 7d12db0ccb
commit d914cb9298

View file

@ -43,16 +43,12 @@
#include <gst/base/gstbasetransform.h>
#include <gst/audio/audio.h>
#include <gst/audio/gstaudiofilter.h>
#include <gst/controller/gstcontroller.h>
#define ALLOWED_CAPS \
"audio/x-raw-int," \
" depth = (int) 16, " \
" width = (int) 16, " \
" endianness = (int) BYTE_ORDER," \
" rate = (int) [ 1, MAX ]," \
" channels = (int) 2, " \
" signed = (boolean) TRUE"
"audio/x-raw," \
" format = "GST_AUDIO_NE (S16) "," \
" rate = (int) [ 1, MAX ]," \
" channels = (int) 2"
/* Stereo signals and args */
enum
@ -76,14 +72,15 @@ static void gst_stereo_get_property (GObject * object, guint prop_id,
static GstFlowReturn gst_stereo_transform_ip (GstBaseTransform * base,
GstBuffer * outbuf);
/*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */
GST_BOILERPLATE (GstStereo, gst_stereo, GstAudioFilter, GST_TYPE_AUDIO_FILTER);
G_DEFINE_TYPE (GstStereo, gst_stereo, GST_TYPE_AUDIO_FILTER);
static void
gst_stereo_base_init (gpointer g_class)
gst_stereo_class_init (GstStereoClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (klass);
GstAudioFilterClass *audiofilter_class = GST_AUDIO_FILTER_CLASS (klass);
GstCaps *caps;
gst_element_class_set_static_metadata (element_class, "Stereo effect",
@ -92,24 +89,11 @@ gst_stereo_base_init (gpointer g_class)
"Erik Walthinsen <omega@cse.ogi.edu>");
caps = gst_caps_from_string (ALLOWED_CAPS);
gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (g_class),
caps);
gst_audio_filter_class_add_pad_templates (audiofilter_class, caps);
gst_caps_unref (caps);
}
static void
gst_stereo_class_init (GstStereoClass * klass)
{
GObjectClass *gobject_class;
GstBaseTransformClass *trans_class;
gobject_class = (GObjectClass *) klass;
trans_class = (GstBaseTransformClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_stereo_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_stereo_get_property);
gobject_class->set_property = gst_stereo_set_property;
gobject_class->get_property = gst_stereo_get_property;
g_object_class_install_property (gobject_class, ARG_ACTIVE,
g_param_spec_boolean ("active", "active", "active",
@ -125,7 +109,7 @@ gst_stereo_class_init (GstStereoClass * klass)
}
static void
gst_stereo_init (GstStereo * stereo, GstStereoClass * klass)
gst_stereo_init (GstStereo * stereo)
{
stereo->active = TRUE;
stereo->stereo = 0.1;
@ -135,14 +119,18 @@ static GstFlowReturn
gst_stereo_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
{
GstStereo *stereo = GST_STEREO (base);
gint16 *data = (gint16 *) GST_BUFFER_DATA (outbuf);
gint samples = GST_BUFFER_SIZE (outbuf) / 2;
gint samples;
gint i;
gdouble avg, ldiff, rdiff, tmp;
gdouble mul = stereo->stereo;
gint16 *data;
GstMapInfo info;
if (!gst_buffer_is_writable (outbuf))
return GST_FLOW_OK;
if (!gst_buffer_map (outbuf, &info, GST_MAP_READWRITE))
return GST_FLOW_ERROR;
data = (gint16 *) info.data;
samples = info.size / 2;
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (outbuf)))
gst_object_sync_values (GST_OBJECT (stereo), GST_BUFFER_TIMESTAMP (outbuf));
@ -169,6 +157,8 @@ gst_stereo_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
}
}
gst_buffer_unmap (outbuf, &info);
return GST_FLOW_OK;
}
@ -176,10 +166,7 @@ static void
gst_stereo_set_property (GObject * object, guint prop_id, const GValue * value,
GParamSpec * pspec)
{
GstStereo *stereo;
g_return_if_fail (GST_IS_STEREO (object));
stereo = GST_STEREO (object);
GstStereo *stereo = GST_STEREO (object);
switch (prop_id) {
case ARG_ACTIVE:
@ -198,10 +185,7 @@ static void
gst_stereo_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstStereo *stereo;
g_return_if_fail (GST_IS_STEREO (object));
stereo = GST_STEREO (object);
GstStereo *stereo = GST_STEREO (object);
switch (prop_id) {
case ARG_ACTIVE: