speex: Use new audio encoder/decoder base class API for srcpad caps
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 1 Feb 2012 15:11:14 +0000 (16:11 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 1 Feb 2012 15:27:47 +0000 (16:27 +0100)
ext/speex/gstspeexdec.c
ext/speex/gstspeexenc.c

index 6ec7d5b..b0dfa8b 100644 (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);
-
-  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;
   }
 }
index d0c5b15..9023ec5 100644 (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 */