mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
stereo: Port to GStreamer 1.0 API
This commit is contained in:
parent
7d12db0ccb
commit
d914cb9298
1 changed files with 26 additions and 42 deletions
|
@ -43,16 +43,12 @@
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
#include <gst/audio/audio.h>
|
#include <gst/audio/audio.h>
|
||||||
#include <gst/audio/gstaudiofilter.h>
|
#include <gst/audio/gstaudiofilter.h>
|
||||||
#include <gst/controller/gstcontroller.h>
|
|
||||||
|
|
||||||
#define ALLOWED_CAPS \
|
#define ALLOWED_CAPS \
|
||||||
"audio/x-raw-int," \
|
"audio/x-raw," \
|
||||||
" depth = (int) 16, " \
|
" format = "GST_AUDIO_NE (S16) "," \
|
||||||
" width = (int) 16, " \
|
" rate = (int) [ 1, MAX ]," \
|
||||||
" endianness = (int) BYTE_ORDER," \
|
" channels = (int) 2"
|
||||||
" rate = (int) [ 1, MAX ]," \
|
|
||||||
" channels = (int) 2, " \
|
|
||||||
" signed = (boolean) TRUE"
|
|
||||||
|
|
||||||
/* Stereo signals and args */
|
/* Stereo signals and args */
|
||||||
enum
|
enum
|
||||||
|
@ -76,14 +72,15 @@ static void gst_stereo_get_property (GObject * object, guint prop_id,
|
||||||
static GstFlowReturn gst_stereo_transform_ip (GstBaseTransform * base,
|
static GstFlowReturn gst_stereo_transform_ip (GstBaseTransform * base,
|
||||||
GstBuffer * outbuf);
|
GstBuffer * outbuf);
|
||||||
|
|
||||||
/*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */
|
G_DEFINE_TYPE (GstStereo, gst_stereo, GST_TYPE_AUDIO_FILTER);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstStereo, gst_stereo, GstAudioFilter, GST_TYPE_AUDIO_FILTER);
|
|
||||||
|
|
||||||
static void
|
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;
|
GstCaps *caps;
|
||||||
|
|
||||||
gst_element_class_set_static_metadata (element_class, "Stereo effect",
|
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>");
|
"Erik Walthinsen <omega@cse.ogi.edu>");
|
||||||
|
|
||||||
caps = gst_caps_from_string (ALLOWED_CAPS);
|
caps = gst_caps_from_string (ALLOWED_CAPS);
|
||||||
gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (g_class),
|
gst_audio_filter_class_add_pad_templates (audiofilter_class, caps);
|
||||||
caps);
|
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
gobject_class->set_property = gst_stereo_set_property;
|
||||||
gst_stereo_class_init (GstStereoClass * klass)
|
gobject_class->get_property = gst_stereo_get_property;
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, ARG_ACTIVE,
|
g_object_class_install_property (gobject_class, ARG_ACTIVE,
|
||||||
g_param_spec_boolean ("active", "active", "active",
|
g_param_spec_boolean ("active", "active", "active",
|
||||||
|
@ -125,7 +109,7 @@ gst_stereo_class_init (GstStereoClass * klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_stereo_init (GstStereo * stereo, GstStereoClass * klass)
|
gst_stereo_init (GstStereo * stereo)
|
||||||
{
|
{
|
||||||
stereo->active = TRUE;
|
stereo->active = TRUE;
|
||||||
stereo->stereo = 0.1;
|
stereo->stereo = 0.1;
|
||||||
|
@ -135,14 +119,18 @@ static GstFlowReturn
|
||||||
gst_stereo_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
|
gst_stereo_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
|
||||||
{
|
{
|
||||||
GstStereo *stereo = GST_STEREO (base);
|
GstStereo *stereo = GST_STEREO (base);
|
||||||
gint16 *data = (gint16 *) GST_BUFFER_DATA (outbuf);
|
gint samples;
|
||||||
gint samples = GST_BUFFER_SIZE (outbuf) / 2;
|
|
||||||
gint i;
|
gint i;
|
||||||
gdouble avg, ldiff, rdiff, tmp;
|
gdouble avg, ldiff, rdiff, tmp;
|
||||||
gdouble mul = stereo->stereo;
|
gdouble mul = stereo->stereo;
|
||||||
|
gint16 *data;
|
||||||
|
GstMapInfo info;
|
||||||
|
|
||||||
if (!gst_buffer_is_writable (outbuf))
|
if (!gst_buffer_map (outbuf, &info, GST_MAP_READWRITE))
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_ERROR;
|
||||||
|
|
||||||
|
data = (gint16 *) info.data;
|
||||||
|
samples = info.size / 2;
|
||||||
|
|
||||||
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (outbuf)))
|
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (outbuf)))
|
||||||
gst_object_sync_values (GST_OBJECT (stereo), 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;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,10 +166,7 @@ static void
|
||||||
gst_stereo_set_property (GObject * object, guint prop_id, const GValue * value,
|
gst_stereo_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
GParamSpec * pspec)
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstStereo *stereo;
|
GstStereo *stereo = GST_STEREO (object);
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_STEREO (object));
|
|
||||||
stereo = GST_STEREO (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_ACTIVE:
|
case ARG_ACTIVE:
|
||||||
|
@ -198,10 +185,7 @@ static void
|
||||||
gst_stereo_get_property (GObject * object, guint prop_id, GValue * value,
|
gst_stereo_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
GParamSpec * pspec)
|
GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstStereo *stereo;
|
GstStereo *stereo = GST_STEREO (object);
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_STEREO (object));
|
|
||||||
stereo = GST_STEREO (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case ARG_ACTIVE:
|
case ARG_ACTIVE:
|
||||||
|
|
Loading…
Reference in a new issue