speex: Use new audio encoder/decoder base class API for srcpad caps

This commit is contained in:
Sebastian Dröge 2012-02-01 16:11:14 +01:00
parent 161229a384
commit a67bd41d75
2 changed files with 13 additions and 16 deletions

View file

@ -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);
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 (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);
}
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;
}
}

View file

@ -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 */