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

This commit is contained in:
Sebastian Dröge 2012-02-01 16:19:55 +01:00
parent acde15adc3
commit 72d930b75c

View file

@ -233,7 +233,12 @@ gst_mad_check_caps_reset (GstMad * mad)
/* only set caps if they weren't already set for this continuous stream */ /* only set caps if they weren't already set for this continuous stream */
if (!gst_pad_has_current_caps (GST_AUDIO_DECODER_SRC_PAD (mad)) if (!gst_pad_has_current_caps (GST_AUDIO_DECODER_SRC_PAD (mad))
|| mad->channels != nchannels || mad->rate != rate) { || mad->channels != nchannels || mad->rate != rate) {
GstCaps *caps; 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}
};
if (mad->caps_set) { if (mad->caps_set) {
GST_DEBUG_OBJECT (mad, "Header changed from %d Hz/%d ch to %d Hz/%d ch, " GST_DEBUG_OBJECT (mad, "Header changed from %d Hz/%d ch to %d Hz/%d ch, "
@ -256,21 +261,11 @@ gst_mad_check_caps_reset (GstMad * mad)
/* we set the caps even when the pad is not connected so they /* we set the caps even when the pad is not connected so they
* can be gotten for streaminfo */ * can be gotten for streaminfo */
caps = gst_caps_new_simple ("audio/x-raw", gst_audio_info_init (&info);
"format", G_TYPE_STRING, GST_AUDIO_NE (S32), gst_audio_info_set_format (&info,
"layout", G_TYPE_STRING, "interleaved", GST_AUDIO_FORMAT_S32, rate, nchannels, chan_pos[nchannels - 1]);
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 32,
"depth", G_TYPE_INT, 32,
"rate", G_TYPE_INT, rate, "channels", G_TYPE_INT, nchannels, NULL);
if (nchannels > 1) gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (mad), &info);
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_decoder_set_outcaps (GST_AUDIO_DECODER (mad), caps);
gst_caps_unref (caps);
mad->caps_set = TRUE; mad->caps_set = TRUE;
mad->channels = nchannels; mad->channels = nchannels;