diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-08-19 16:09:48 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-08-19 16:09:48 +0200 |
commit | 445bf71bd16fec111f6d2240070e6638cf62f9e5 (patch) | |
tree | 93b6091c6075704f05e9c34b2982807fc12cb1a3 /gst/replaygain | |
parent | 77ad0a13631d19d16fcf31b12529005a2a52f425 (diff) | |
download | gstreamer-plugins-good-445bf71bd16fec111f6d2240070e6638cf62f9e5.tar.gz |
port to more audio api changes
Diffstat (limited to 'gst/replaygain')
-rw-r--r-- | gst/replaygain/Makefile.am | 2 | ||||
-rw-r--r-- | gst/replaygain/gstrganalysis.c | 93 | ||||
-rw-r--r-- | gst/replaygain/gstrglimiter.c | 17 | ||||
-rw-r--r-- | gst/replaygain/gstrgvolume.c | 35 |
4 files changed, 61 insertions, 86 deletions
diff --git a/gst/replaygain/Makefile.am b/gst/replaygain/Makefile.am index 0153e9fdb..b7e948702 100644 --- a/gst/replaygain/Makefile.am +++ b/gst/replaygain/Makefile.am @@ -9,7 +9,7 @@ libgstreplaygain_la_SOURCES = \ libgstreplaygain_la_CFLAGS = \ $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) libgstreplaygain_la_LIBADD = \ - $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_MAJORMINOR) \ + $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-$(GST_MAJORMINOR) -lgstaudio-$(GST_MAJORMINOR)\ $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) libgstreplaygain_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstreplaygain_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/gst/replaygain/gstrganalysis.c b/gst/replaygain/gstrganalysis.c index 2d7d8e640..9b34f24dd 100644 --- a/gst/replaygain/gstrganalysis.c +++ b/gst/replaygain/gstrganalysis.c @@ -79,6 +79,7 @@ #include <gst/gst.h> #include <gst/base/gstbasetransform.h> +#include <gst/audio/audio.h> #include "gstrganalysis.h" #include "replaygain.h" @@ -103,27 +104,20 @@ enum * audio. The used implementation has filter coefficients for the * "usual" sample rates in the 8000 to 48000 Hz range. */ #define REPLAY_GAIN_CAPS \ + "format = (string) { "GST_AUDIO_NE(F32)","GST_AUDIO_NE(S16)" }, " \ "channels = (int) { 1, 2 }, " \ "rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, " \ "44100, 48000 }" static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, " - "width = (int) 32, " "endianness = (int) BYTE_ORDER, " - REPLAY_GAIN_CAPS "; " - "audio/x-raw-int, " - "width = (int) 16, " "depth = (int) [ 1, 16 ], " - "signed = (boolean) true, " "endianness = (int) BYTE_ORDER, " - REPLAY_GAIN_CAPS)); + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (REPLAY_GAIN_CAPS)); static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, " - "width = (int) 32, " "endianness = (int) BYTE_ORDER, " - REPLAY_GAIN_CAPS "; " - "audio/x-raw-int, " - "width = (int) 16, " "depth = (int) [ 1, 16 ], " - "signed = (boolean) true, " "endianness = (int) BYTE_ORDER, " - REPLAY_GAIN_CAPS)); + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (REPLAY_GAIN_CAPS)); #define gst_rg_analysis_parent_class parent_class G_DEFINE_TYPE (GstRgAnalysis, gst_rg_analysis, GST_TYPE_BASE_TRANSFORM); @@ -396,9 +390,8 @@ gst_rg_analysis_set_caps (GstBaseTransform * base, GstCaps * in_caps, GstCaps * out_caps) { GstRgAnalysis *filter = GST_RG_ANALYSIS (base); - GstStructure *structure; - const gchar *name; - gint n_channels, sample_rate, sample_bit_size, sample_size; + GstAudioInfo info; + gint rate, channels; g_return_val_if_fail (filter->ctx != NULL, FALSE); @@ -406,58 +399,42 @@ gst_rg_analysis_set_caps (GstBaseTransform * base, GstCaps * in_caps, "set_caps in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, in_caps, out_caps); - structure = gst_caps_get_structure (in_caps, 0); - name = gst_structure_get_name (structure); - - if (!gst_structure_get_int (structure, "width", &sample_bit_size) - || !gst_structure_get_int (structure, "channels", &n_channels) - || !gst_structure_get_int (structure, "rate", &sample_rate)) + if (!gst_audio_info_from_caps (&info, in_caps)) goto invalid_format; - if (!rg_analysis_set_sample_rate (filter->ctx, sample_rate)) - goto invalid_format; + rate = GST_AUDIO_INFO_RATE (&info); - if (sample_bit_size % 8 != 0) + if (!rg_analysis_set_sample_rate (filter->ctx, rate)) goto invalid_format; - sample_size = sample_bit_size / 8; - - if (g_str_equal (name, "audio/x-raw-float")) { - - if (sample_size != sizeof (gfloat)) - goto invalid_format; - /* The depth is not variable for float formats of course. It just - * makes the transform function nice and simple if the - * rg_analysis_analyze_* functions have a common signature. */ - filter->depth = sizeof (gfloat) * 8; + channels = GST_AUDIO_INFO_CHANNELS (&info); - if (n_channels == 1) - filter->analyze = rg_analysis_analyze_mono_float; - else if (n_channels == 2) - filter->analyze = rg_analysis_analyze_stereo_float; - else - goto invalid_format; + if (channels < 1 || channels > 2) + goto invalid_format; - } else if (g_str_equal (name, "audio/x-raw-int")) { + switch (GST_AUDIO_INFO_FORMAT (&info)) { + case GST_AUDIO_FORMAT_F32: + /* The depth is not variable for float formats of course. It just + * makes the transform function nice and simple if the + * rg_analysis_analyze_* functions have a common signature. */ + filter->depth = sizeof (gfloat) * 8; - if (sample_size != sizeof (gint16)) - goto invalid_format; + if (channels == 1) + filter->analyze = rg_analysis_analyze_mono_float; + else + filter->analyze = rg_analysis_analyze_stereo_float; - if (!gst_structure_get_int (structure, "depth", &filter->depth)) - goto invalid_format; - if (filter->depth < 1 || filter->depth > 16) - goto invalid_format; + break; + case GST_AUDIO_FORMAT_S16: + filter->depth = sizeof (gint16) * 8; - if (n_channels == 1) - filter->analyze = rg_analysis_analyze_mono_int16; - else if (n_channels == 2) - filter->analyze = rg_analysis_analyze_stereo_int16; - else + if (channels == 1) + filter->analyze = rg_analysis_analyze_mono_int16; + else + filter->analyze = rg_analysis_analyze_stereo_int16; + break; + default: goto invalid_format; - - } else { - - goto invalid_format; } return TRUE; diff --git a/gst/replaygain/gstrglimiter.c b/gst/replaygain/gstrglimiter.c index bb79d1f5e..3291f6d9b 100644 --- a/gst/replaygain/gstrglimiter.c +++ b/gst/replaygain/gstrglimiter.c @@ -45,6 +45,7 @@ #include <gst/gst.h> #include <math.h> +#include <gst/audio/audio.h> #include "gstrglimiter.h" @@ -58,14 +59,18 @@ enum }; static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, " - "width = (int) 32, channels = (int) [1, MAX], " - "rate = (int) [1, MAX], endianness = (int) BYTE_ORDER")); + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " GST_AUDIO_NE (F32) ", " + "channels = (int) [1, MAX], " "rate = (int) [1, MAX]")); static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, " - "width = (int) 32, channels = (int) [1, MAX], " - "rate = (int) [1, MAX], endianness = (int) BYTE_ORDER")); + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " GST_AUDIO_NE (F32) ", " + "channels = (int) [1, MAX], " "rate = (int) [1, MAX]")); #define gst_rg_limiter_parent_class parent_class G_DEFINE_TYPE (GstRgLimiter, gst_rg_limiter, GST_TYPE_BASE_TRANSFORM); diff --git a/gst/replaygain/gstrgvolume.c b/gst/replaygain/gstrgvolume.c index c5baa6632..bd2cf1889 100644 --- a/gst/replaygain/gstrgvolume.c +++ b/gst/replaygain/gstrgvolume.c @@ -61,6 +61,7 @@ #include <gst/gst.h> #include <gst/pbutils/pbutils.h> +#include <gst/audio/audio.h> #include <math.h> #include "gstrgvolume.h" @@ -96,29 +97,21 @@ enum /* Same template caps as GstVolume, for I don't like having just ANY caps. */ +#define FORMAT "{ "GST_AUDIO_NE(F32)","GST_AUDIO_NE(S16)" }" + static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, " - "rate = (int) [ 1, MAX ], " - "channels = (int) [ 1, MAX ], " - "endianness = (int) BYTE_ORDER, " - "width = (int) 32; " - "audio/x-raw-int, " - "channels = (int) [ 1, MAX ], " - "rate = (int) [ 1, MAX ], " - "endianness = (int) BYTE_ORDER, " - "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")); + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " FORMAT ", " + "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")); static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-float, " - "rate = (int) [ 1, MAX ], " - "channels = (int) [ 1, MAX ], " - "endianness = (int) BYTE_ORDER, " - "width = (int) 32; " - "audio/x-raw-int, " - "channels = (int) [ 1, MAX ], " - "rate = (int) [ 1, MAX ], " - "endianness = (int) BYTE_ORDER, " - "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")); + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " FORMAT ", " + "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")); #define gst_rg_volume_parent_class parent_class G_DEFINE_TYPE (GstRgVolume, gst_rg_volume, GST_TYPE_BIN); @@ -186,7 +179,7 @@ gst_rg_volume_class_init (GstRgVolumeClass * klass) * This element internally uses a volume element, which also supports * operating on integer audio formats. These formats do not allow exceeding * digital full scale. If extra headroom is used, make sure that the raw - * audio data format is floating point (audio/x-raw-float). Otherwise, + * audio data format is floating point (F32). Otherwise, * clipping distortion might be introduced as part of the volume adjustment * itself. */ |