[0.11] gst-plugins-good: speex: Use new audio encoder/ decoder base class API for srcpad caps
Sebastian Dröge
slomo at kemper.freedesktop.org
Wed Feb 1 07:27:52 PST 2012
Module: gst-plugins-good
Branch: 0.11
Commit: a67bd41d7583cd59c5d63e9aacd2dc0ae4d7e4ea
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=a67bd41d7583cd59c5d63e9aacd2dc0ae4d7e4ea
Author: Sebastian Dröge <sebastian.droege at collabora.co.uk>
Date: Wed Feb 1 16:11:14 2012 +0100
speex: Use new audio encoder/decoder base class API for srcpad caps
---
ext/speex/gstspeexdec.c | 27 ++++++++++++---------------
ext/speex/gstspeexenc.c | 2 +-
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/ext/speex/gstspeexdec.c b/ext/speex/gstspeexdec.c
index 6ec7d5b..b0dfa8b 100644
--- a/ext/speex/gstspeexdec.c
+++ b/ext/speex/gstspeexdec.c
@@ -189,8 +189,13 @@ gst_speex_dec_stop (GstAudioDecoder * dec)
static GstFlowReturn
gst_speex_dec_parse_header (GstSpeexDec * dec, GstBuffer * buf)
{
- GstCaps *caps;
GstMapInfo map;
+ GstAudioInfo info;
+ static const GstAudioChannelPosition chan_pos[2][2] = {
+ {GST_AUDIO_CHANNEL_POSITION_MONO},
+ {GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
+ GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}
+ };
/* get the header */
gst_buffer_map (buf, &map, GST_MAP_READ);
@@ -229,22 +234,15 @@ gst_speex_dec_parse_header (GstSpeexDec * dec, GstBuffer * buf)
speex_bits_init (&dec->bits);
/* set caps */
- caps = gst_caps_new_simple ("audio/x-raw",
- "format", G_TYPE_STRING, FORMAT_STR,
- "layout", G_TYPE_STRING, "interleaved",
- "rate", G_TYPE_INT, dec->header->rate,
- "channels", G_TYPE_INT, dec->header->nb_channels, NULL);
-
- if (dec->header->nb_channels == 2) {
- gst_caps_set_simple (caps, "channel-mask", GST_TYPE_BITMASK,
- GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_LEFT) |
- GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_RIGHT), NULL);
- }
+ gst_audio_info_init (&info);
+ gst_audio_info_set_format (&info,
+ GST_AUDIO_FORMAT_S16,
+ dec->header->rate,
+ dec->header->nb_channels, chan_pos[dec->header->nb_channels - 1]);
- if (!gst_pad_set_caps (GST_AUDIO_DECODER_SRC_PAD (dec), caps))
+ if (!gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (dec), &info))
goto nego_failed;
- gst_caps_unref (caps);
return GST_FLOW_OK;
/* ERRORS */
@@ -272,7 +270,6 @@ nego_failed:
{
GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
(NULL), ("couldn't negotiate format"));
- gst_caps_unref (caps);
return GST_FLOW_NOT_NEGOTIATED;
}
}
diff --git a/ext/speex/gstspeexenc.c b/ext/speex/gstspeexenc.c
index d0c5b15..9023ec5 100644
--- a/ext/speex/gstspeexenc.c
+++ b/ext/speex/gstspeexenc.c
@@ -717,7 +717,7 @@ gst_speex_enc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
/* negotiate with these caps */
GST_DEBUG_OBJECT (enc, "here are the caps: %" GST_PTR_FORMAT, caps);
- gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc), caps);
+ gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (enc), caps);
gst_caps_unref (caps);
/* push out buffers */
More information about the gstreamer-commits
mailing list