[0.11] gst-plugins-bad: voamrwbenc: port to 0.11

Mark Nauwelaerts mnauw at kemper.freedesktop.org
Wed Jan 11 03:32:24 PST 2012


Module: gst-plugins-bad
Branch: 0.11
Commit: 76811c2181b79c17df9686f19943974935cc7244
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=76811c2181b79c17df9686f19943974935cc7244

Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date:   Wed Jan 11 12:24:15 2012 +0100

voamrwbenc: port to 0.11

---

 configure.ac                   |    2 +-
 ext/voamrwbenc/gstvoamrwbenc.c |   47 ++++++++++++++++++---------------------
 2 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/configure.ac b/configure.ac
index 707121e..72dec6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -308,7 +308,7 @@ GST_PLUGINS_NONPORTED=" adpcmdec adpcmenc aiff asfmux \
  voaacenc apexsink bz2 cdaudio celt cog curl dc1394 dirac directfb resindvd \
  gsettings gsm jp2k ladspa modplug mpeg2enc mplex mimic \
  musepack musicbrainz nas neon ofa openal opencv rsvg schro sdl smooth sndfile soundtouch spandsp timidity \
- wildmidi xvid apple_media voamrwbenc lv2 teletextdec"
+ wildmidi xvid apple_media lv2 teletextdec"
 AC_SUBST(GST_PLUGINS_NONPORTED)
 
 dnl these are all the gst plug-ins, compilable without additional libs
diff --git a/ext/voamrwbenc/gstvoamrwbenc.c b/ext/voamrwbenc/gstvoamrwbenc.c
index 4647b84..7452fe4 100644
--- a/ext/voamrwbenc/gstvoamrwbenc.c
+++ b/ext/voamrwbenc/gstvoamrwbenc.c
@@ -91,11 +91,9 @@ enum
 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS ("audio/x-raw-int, "
-        "width = (int) 16, "
-        "depth = (int) 16, "
-        "signed = (boolean) TRUE, "
-        "endianness = (int) BYTE_ORDER, "
+    GST_STATIC_CAPS ("audio/x-raw, "
+        "format = (string) S16LE, "
+        "layout = (string) interleaved, "
         "rate = (int) 16000, " "channels = (int) 1")
     );
 
@@ -116,8 +114,7 @@ static gboolean gst_voamrwbenc_set_format (GstAudioEncoder * enc,
 static GstFlowReturn gst_voamrwbenc_handle_frame (GstAudioEncoder * enc,
     GstBuffer * in_buf);
 
-GST_BOILERPLATE (GstVoAmrWbEnc, gst_voamrwbenc, GstAudioEncoder,
-    GST_TYPE_AUDIO_ENCODER);
+G_DEFINE_TYPE (GstVoAmrWbEnc, gst_voamrwbenc, GST_TYPE_AUDIO_ENCODER);
 
 static void
 gst_voamrwbenc_set_property (GObject * object, guint prop_id,
@@ -156,9 +153,14 @@ gst_voamrwbenc_get_property (GObject * object, guint prop_id,
 }
 
 static void
-gst_voamrwbenc_base_init (gpointer klass)
+gst_voamrwbenc_class_init (GstVoAmrWbEncClass * klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstAudioEncoderClass *base_class = GST_AUDIO_ENCODER_CLASS (klass);
+
+  object_class->set_property = gst_voamrwbenc_set_property;
+  object_class->get_property = gst_voamrwbenc_get_property;
 
   gst_element_class_add_pad_template (element_class,
       gst_static_pad_template_get (&sink_template));
@@ -169,16 +171,6 @@ gst_voamrwbenc_base_init (gpointer klass)
       "Codec/Encoder/Audio",
       "Adaptive Multi-Rate Wideband audio encoder",
       "Renato Araujo <renato.filho at indt.org.br>");
-}
-
-static void
-gst_voamrwbenc_class_init (GstVoAmrWbEncClass * klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  GstAudioEncoderClass *base_class = GST_AUDIO_ENCODER_CLASS (klass);
-
-  object_class->set_property = gst_voamrwbenc_set_property;
-  object_class->get_property = gst_voamrwbenc_get_property;
 
   base_class->start = GST_DEBUG_FUNCPTR (gst_voamrwbenc_start);
   base_class->stop = GST_DEBUG_FUNCPTR (gst_voamrwbenc_stop);
@@ -193,7 +185,7 @@ gst_voamrwbenc_class_init (GstVoAmrWbEncClass * klass)
 }
 
 static void
-gst_voamrwbenc_init (GstVoAmrWbEnc * amrwbenc, GstVoAmrWbEncClass * klass)
+gst_voamrwbenc_init (GstVoAmrWbEnc * amrwbenc)
 {
   /* init rest */
   amrwbenc->handle = NULL;
@@ -276,6 +268,8 @@ gst_voamrwbenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buffer)
   const int buffer_size = sizeof (short) * L_FRAME16k;
   GstBuffer *out;
   gint outsize;
+  gsize size;
+  guint8 *data, *outdata;
 
   amrwbenc = GST_VOAMRWBENC (benc);
 
@@ -287,21 +281,24 @@ gst_voamrwbenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buffer)
     goto done;
   }
 
-  if (G_UNLIKELY (GST_BUFFER_SIZE (buffer) < buffer_size)) {
-    GST_DEBUG_OBJECT (amrwbenc, "discarding trailing data %d",
-        buffer ? GST_BUFFER_SIZE (buffer) : 0);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  if (G_UNLIKELY (size < buffer_size)) {
+    GST_DEBUG_OBJECT (amrwbenc, "discarding trailing data %d", (gint) size);
+    gst_buffer_unmap (buffer, data, -1);
     ret = gst_audio_encoder_finish_frame (benc, NULL, -1);
     goto done;
   }
 
   out = gst_buffer_new_and_alloc (buffer_size);
+  outdata = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
   /* encode */
   outsize = E_IF_encode (amrwbenc->handle, amrwbenc->bandmode,
-      (const short *) GST_BUFFER_DATA (buffer),
-      (unsigned char *) GST_BUFFER_DATA (out), 0);
+      (const short *) data, (unsigned char *) outdata, 0);
 
   GST_LOG_OBJECT (amrwbenc, "encoded to %d bytes", outsize);
-  GST_BUFFER_SIZE (out) = outsize;
+  gst_buffer_unmap (out, outdata, outsize);
+  gst_buffer_unmap (buffer, data, -1);
 
   ret = gst_audio_encoder_finish_frame (benc, out, L_FRAME16k);
 



More information about the gstreamer-commits mailing list