And rename everything to voamrwbenc instead of amrwbenc.
AC_SUBST(ASSRENDER_CFLAGS)
AC_SUBST(ASSRENDER_LIBS)
-dnl *** amrwb ***
-translit(dnm, m, l) AM_CONDITIONAL(USE_AMRWB, true)
-AG_GST_CHECK_FEATURE(AMRWB, [amrwb library], amrwbenc, [
- AG_GST_CHECK_LIBHEADER(AMRWB, amrwb,
- GP3E_IF_encode, ,
- amrwb/enc.h,
- AMRWB_LIBS="-lamrwb"
- AC_SUBST(AMRWB_LIBS))
+dnl *** vo-amrwbenc ***
+translit(dnm, m, l) AM_CONDITIONAL(USE_VOAMRWBENC, true)
+AG_GST_CHECK_FEATURE(VOAMRWBENC, [vo-amrwbenc library], vo-amrwbenc, [
+ AG_GST_PKG_CHECK_MODULES(VOAMRWBENC, vo-amrwbenc >= 0.1.0)
])
-dnl *** aac-enc ***
+dnl *** vo-aacenc ***
translit(dnm, m, l) AM_CONDITIONAL(USE_VOAACENC, true)
AG_GST_CHECK_FEATURE(VOAACENC, [vo-aacenc library], vo-aacenc, [
AG_GST_PKG_CHECK_MODULES(VOAACENC, vo-aacenc >= 0.1.0)
dnl but we still need to set the conditionals
AM_CONDITIONAL(USE_ASSRENDER, false)
-AM_CONDITIONAL(USE_AMRWB, false)
+AM_CONDITIONAL(USE_VOAMRWBENC, false)
AM_CONDITIONAL(USE_VOAACENC, false)
AM_CONDITIONAL(USE_APEXSINK, false)
AM_CONDITIONAL(USE_BZ2, false)
tests/examples/mxf/Makefile
tests/examples/scaletempo/Makefile
tests/icles/Makefile
-ext/amrwbenc/Makefile
+ext/voamrwbenc/Makefile
ext/voaacenc/Makefile
ext/assrender/Makefile
ext/apexsink/Makefile
EXTRA_HFILES = \
$(top_srcdir)/ext/assrender/gstassrender.h \
- $(top_srcdir)/ext/amrwbenc/gstamrwbenc.h \
$(top_srcdir)/ext/celt/gstceltdec.h \
$(top_srcdir)/ext/celt/gstceltenc.h \
$(top_srcdir)/ext/curl/gstcurlsink.h \
$(top_srcdir)/ext/sdl/sdlvideosink.h \
$(top_srcdir)/ext/timidity/gsttimidity.h \
$(top_srcdir)/ext/timidity/gstwildmidi.h \
+ $(top_srcdir)/ext/voamrwbenc/gstvoamrwbenc.h \
$(top_srcdir)/ext/vp8/gstvp8enc.h \
$(top_srcdir)/ext/vp8/gstvp8dec.h \
$(top_srcdir)/ext/zbar/gstzbar.h \
<title>gst-plugins-bad Elements</title>
<xi:include href="xml/element-aiffparse.xml" />
<xi:include href="xml/element-aiffmux.xml" />
- <xi:include href="xml/element-amrwbenc.xml" />
<xi:include href="xml/element-assrender.xml" />
<xi:include href="xml/element-autoconvert.xml" />
<xi:include href="xml/element-bulge.xml" />
<xi:include href="xml/element-waterripple.xml" />
<xi:include href="xml/element-wildmidi.xml" />
<xi:include href="xml/element-zbar.xml" />
+ <xi:include href="xml/element-voamrwbenc.xml" />
<xi:include href="xml/element-vp8dec.xml" />
<xi:include href="xml/element-vp8enc.xml" />
</chapter>
<xi:include href="xml/plugin-aiff.xml" />
<xi:include href="xml/plugin-autoconvert.xml" />
<xi:include href="xml/plugin-legacyresample.xml" />
- <xi:include href="xml/plugin-amrwbenc.xml" />
<xi:include href="xml/plugin-assrender.xml" />
<xi:include href="xml/plugin-bayer.xml" />
<xi:include href="xml/plugin-bz2.xml" />
<xi:include href="xml/plugin-vmnc.xml" />
<xi:include href="xml/plugin-wildmidi.xml" />
<xi:include href="xml/plugin-xvid.xml" />
+ <xi:include href="xml/plugin-voamrwbenc.xml" />
<xi:include href="xml/plugin-vp8.xml" />
<xi:include href="xml/plugin-zbar.xml" />
</chapter>
</SECTION>
<SECTION>
-<FILE>element-amrwbenc</FILE>
-<TITLE>amrwbenc</TITLE>
-GstAmrwbEnc
-<SUBSECTION Standard>
-GstAmrwbEncClass
-GST_AMRWBENC
-GST_AMRWBENC_CLASS
-GST_IS_AMRWBENC
-GST_IS_AMRWBENC_CLASS
-GST_TYPE_AMRWBENC
-gst_amrwbenc_get_type
+<FILE>element-voamrwbenc</FILE>
+<TITLE>voamrwbenc</TITLE>
+GstVoAmrwbEnc
+<SUBSECTION Standard>
+GstVoAmrwbEncClass
+GST_VOAMRWBENC
+GST_VOAMRWBENC_CLASS
+GST_IS_VOAMRWBENC
+GST_IS_VOAMRWBENC_CLASS
+GST_TYPE_VOAMRWBENC
+gst_voamrwbenc_get_type
</SECTION>
<SECTION>
+++ /dev/null
-<plugin>
- <name>amrwbenc</name>
- <description>Adaptive Multi-Rate Wide-Band Encoder</description>
- <filename>../../ext/amrwbenc/.libs/libgstamrwbenc.so</filename>
- <basename>libgstamrwbenc.so</basename>
- <version>0.10.22.1</version>
- <license>unknown</license>
- <source>gst-plugins-bad</source>
- <package>GStreamer Bad Plug-ins git</package>
- <origin>Unknown package origin</origin>
- <elements>
- <element>
- <name>amrwbenc</name>
- <longname>AMR-WB audio encoder</longname>
- <class>Codec/Encoder/Audio</class>
- <description>Adaptive Multi-Rate Wideband audio encoder</description>
- <author>Renato Araujo <renato.filho@indt.org.br></author>
- <pads>
- <caps>
- <name>sink</name>
- <direction>sink</direction>
- <presence>always</presence>
- <details>audio/x-raw-int, width=(int)16, depth=(int)16, signed=(boolean)true, endianness=(int)1234, rate=(int)16000, channels=(int)1</details>
- </caps>
- <caps>
- <name>src</name>
- <direction>source</direction>
- <presence>always</presence>
- <details>audio/AMR-WB, rate=(int)16000, channels=(int)1</details>
- </caps>
- </pads>
- </element>
- </elements>
-</plugin>
\ No newline at end of file
ASSRENDER_DIR =
endif
-if USE_AMRWB
-AMRWB_DIR = amrwbenc
+if USE_VOAMRWBENC
+VOAMRWBENC_DIR = voamrwbenc
else
-AMRWB_DIR =
+VOAMRWBENC_DIR =
endif
if USE_APEXSINK
SUBDIRS=\
$(VOAACENC_DIR) \
$(ASSRENDER_DIR) \
- $(AMRWB_DIR) \
+ $(VOAMRWBENC_DIR) \
$(APEXSINK_DIR) \
$(ARTS_DIR) \
$(ARTSC_DIR) \
$(RTMP_DIR)
DIST_SUBDIRS = \
- amrwbenc \
assrender \
apexsink \
bz2 \
gme \
swfdec \
timidity \
+ voaacenc \
+ voamrwbenc \
vp8 \
xvid \
zbar \
+++ /dev/null
-[_presets_]
-version=0.10
-element-name=GstAmrwbEnc
-
-[enhance-size]
-_meta/comment=Maximize compression, lowest bitrate
-band-mode=0
-
-[enhance-quality]
-_meta/comment=Maximize quality, highest bitrate
-band-mode=8
+++ /dev/null
-plugin_LTLIBRARIES = libgstamrwbenc.la
-
-libgstamrwbenc_la_SOURCES = \
- gstamrwb.c \
- gstamrwbenc.c
-
-libgstamrwbenc_la_CFLAGS = $(GST_CFLAGS) $(AMRWB_CFLAGS)
-libgstamrwbenc_la_LIBADD = $(GST_BASE_LIBS) $(AMRWB_LIBS)
-libgstamrwbenc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-libgstamrwbenc_la_LIBTOOLFLAGS = --tag=disable-static
-
-noinst_HEADERS = \
- gstamrwbenc.h
-
-presetdir = $(datadir)/gstreamer-$(GST_MAJORMINOR)/presets
-preset_DATA = GstAmrwbEnc.prs
-
-EXTRA_DIST = $(preset_DATA)
-
+++ /dev/null
-Compiling AMRWB encoder:
-========================
-
-To compile the amrwb encoder, you need to download the source code from
-"http://www.3gpp.org/ftp/Specs/html-info/26204.htm" and uncompress the
-files inside an amrwb-code directory;
-
-or execute this commands:
-$cd amrwb-code
-$sh ./run.sh
-
-and run the "autogen" script again.
+++ /dev/null
-/* GStreamer Adaptive Multi-Rate Wide-Band (AMR-WB) Encoder plugin
- * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstamrwbenc.h"
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- return gst_element_register (plugin, "amrwbenc",
- GST_RANK_SECONDARY, GST_TYPE_AMRWBENC);
-}
-
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "amrwbenc",
- "Adaptive Multi-Rate Wide-Band Encoder",
- plugin_init, VERSION, GST_LICENSE_UNKNOWN, GST_PACKAGE_NAME,
- GST_PACKAGE_ORIGIN);
+++ /dev/null
-/* GStreamer Adaptive Multi-Rate Wide-Band (AMR-WB) plugin
- * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:element-amrwbenc
- * @see_also: #GstAmrwbDec, #GstAmrwbParse
- *
- * AMR wideband encoder based on the
- * <ulink url="http://www.penguin.cz/~utx/amr">reference codec implementation</ulink>.
- *
- * <refsect2>
- * <title>Example launch line</title>
- * |[
- * gst-launch filesrc location=abc.wav ! wavparse ! audioresample ! audioconvert ! amrwbenc ! filesink location=abc.amr
- * ]|
- * Please not that the above stream misses the header, that is needed to play
- * the stream.
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gstamrwbenc.h"
-
-/* these defines are not in all .h files */
-#ifndef MR660
-#define MR660 0
-#define MR885 1
-#define MR1265 2
-#define MR1425 2
-#define MR1585 3
-#define MR1825 4
-#define MR1985 5
-#define MR2305 6
-#define MR2385 7
-#define MRDTX 8
-#endif
-
-static GType
-gst_amrwbenc_bandmode_get_type (void)
-{
- static GType gst_amrwbenc_bandmode_type = 0;
- static GEnumValue gst_amrwbenc_bandmode[] = {
- {MR660, "MR660", "MR660"},
- {MR885, "MR885", "MR885"},
- {MR1265, "MR1265", "MR1265"},
- {MR1425, "MR1425", "MR1425"},
- {MR1585, "MR1585", "MR1585"},
- {MR1825, "MR1825", "MR1825"},
- {MR1985, "MR1985", "MR1985"},
- {MR2305, "MR2305", "MR2305"},
- {MR2385, "MR2385", "MR2385"},
- {MRDTX, "MRDTX", "MRDTX"},
- {0, NULL, NULL},
- };
- if (!gst_amrwbenc_bandmode_type) {
- gst_amrwbenc_bandmode_type =
- g_enum_register_static ("GstAmrWbEncBandMode", gst_amrwbenc_bandmode);
- }
- return gst_amrwbenc_bandmode_type;
-}
-
-#define GST_AMRWBENC_BANDMODE_TYPE (gst_amrwbenc_bandmode_get_type())
-
-#define BANDMODE_DEFAULT MR660
-
-enum
-{
- PROP_0,
- PROP_BANDMODE
-};
-
-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, "
- "rate = (int) 16000, " "channels = (int) 1")
- );
-
-static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/AMR-WB, "
- "rate = (int) 16000, " "channels = (int) 1")
- );
-
-GST_DEBUG_CATEGORY_STATIC (gst_amrwbenc_debug);
-#define GST_CAT_DEFAULT gst_amrwbenc_debug
-
-static void gst_amrwbenc_finalize (GObject * object);
-
-static GstFlowReturn gst_amrwbenc_chain (GstPad * pad, GstBuffer * buffer);
-static gboolean gst_amrwbenc_setcaps (GstPad * pad, GstCaps * caps);
-static GstStateChangeReturn gst_amrwbenc_state_change (GstElement * element,
- GstStateChange transition);
-
-static void
-_do_init (GType object_type)
-{
- const GInterfaceInfo preset_interface_info = {
- NULL, /* interface init */
- NULL, /* interface finalize */
- NULL /* interface_data */
- };
-
- g_type_add_interface_static (object_type, GST_TYPE_PRESET,
- &preset_interface_info);
-
- GST_DEBUG_CATEGORY_INIT (gst_amrwbenc_debug, "amrwbenc", 0,
- "AMR-WB audio encoder");
-}
-
-#define GstAmrWbEnc GstAmrwbEnc
-#define GstAmrWbEncClass GstAmrwbEncClass
-
-GST_BOILERPLATE_FULL (GstAmrWbEnc, gst_amrwbenc, GstElement, GST_TYPE_ELEMENT,
- _do_init);
-
-static void
-gst_amrwbenc_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstAmrwbEnc *self = GST_AMRWBENC (object);
-
- switch (prop_id) {
- case PROP_BANDMODE:
- self->bandmode = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
- return;
-}
-
-static void
-gst_amrwbenc_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstAmrwbEnc *self = GST_AMRWBENC (object);
-
- switch (prop_id) {
- case PROP_BANDMODE:
- g_value_set_enum (value, self->bandmode);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-
- return;
-}
-
-static void
-gst_amrwbenc_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
-
- gst_element_class_set_details_simple (element_class, "AMR-WB audio encoder",
- "Codec/Encoder/Audio",
- "Adaptive Multi-Rate Wideband audio encoder",
- "Renato Araujo <renato.filho@indt.org.br>");
-}
-
-static void
-gst_amrwbenc_class_init (GstAmrwbEncClass * klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- object_class->finalize = gst_amrwbenc_finalize;
- object_class->set_property = gst_amrwbenc_set_property;
- object_class->get_property = gst_amrwbenc_get_property;
-
- g_object_class_install_property (object_class, PROP_BANDMODE,
- g_param_spec_enum ("band-mode", "Band Mode",
- "Encoding Band Mode (Kbps)", GST_AMRWBENC_BANDMODE_TYPE,
- BANDMODE_DEFAULT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
-
- element_class->change_state = GST_DEBUG_FUNCPTR (gst_amrwbenc_state_change);
-}
-
-static void
-gst_amrwbenc_init (GstAmrwbEnc * amrwbenc, GstAmrwbEncClass * klass)
-{
- /* create the sink pad */
- amrwbenc->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
- gst_pad_set_setcaps_function (amrwbenc->sinkpad, gst_amrwbenc_setcaps);
- gst_pad_set_chain_function (amrwbenc->sinkpad, gst_amrwbenc_chain);
- gst_element_add_pad (GST_ELEMENT (amrwbenc), amrwbenc->sinkpad);
-
- /* create the src pad */
- amrwbenc->srcpad = gst_pad_new_from_static_template (&src_template, "src");
- gst_pad_use_fixed_caps (amrwbenc->srcpad);
- gst_element_add_pad (GST_ELEMENT (amrwbenc), amrwbenc->srcpad);
-
- amrwbenc->adapter = gst_adapter_new ();
-
- /* init rest */
- amrwbenc->handle = NULL;
- amrwbenc->channels = 0;
- amrwbenc->rate = 0;
- amrwbenc->ts = 0;
-}
-
-static void
-gst_amrwbenc_finalize (GObject * object)
-{
- GstAmrwbEnc *amrwbenc;
-
- amrwbenc = GST_AMRWBENC (object);
-
- g_object_unref (G_OBJECT (amrwbenc->adapter));
- amrwbenc->adapter = NULL;
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static gboolean
-gst_amrwbenc_setcaps (GstPad * pad, GstCaps * caps)
-{
- GstStructure *structure;
- GstAmrwbEnc *amrwbenc;
- GstCaps *copy;
-
- amrwbenc = GST_AMRWBENC (GST_PAD_PARENT (pad));
-
- structure = gst_caps_get_structure (caps, 0);
-
- /* get channel count */
- gst_structure_get_int (structure, "channels", &amrwbenc->channels);
- gst_structure_get_int (structure, "rate", &amrwbenc->rate);
-
- /* this is not wrong but will sound bad */
- if (amrwbenc->channels != 1) {
- GST_WARNING ("amrwbdec is only optimized for mono channels");
- }
- if (amrwbenc->rate != 16000) {
- GST_WARNING ("amrwbdec is only optimized for 16000 Hz samplerate");
- }
-
- /* create reverse caps */
- copy = gst_caps_new_simple ("audio/AMR-WB",
- "channels", G_TYPE_INT, amrwbenc->channels,
- "rate", G_TYPE_INT, amrwbenc->rate, NULL);
-
- gst_pad_set_caps (amrwbenc->srcpad, copy);
- gst_caps_unref (copy);
-
- return TRUE;
-}
-
-static GstFlowReturn
-gst_amrwbenc_chain (GstPad * pad, GstBuffer * buffer)
-{
- GstAmrwbEnc *amrwbenc;
- GstFlowReturn ret = GST_FLOW_OK;
- const int buffer_size = sizeof (Word16) * L_FRAME16k;
-
- amrwbenc = GST_AMRWBENC (gst_pad_get_parent (pad));
-
- g_return_val_if_fail (amrwbenc->handle, GST_FLOW_WRONG_STATE);
-
- if (amrwbenc->rate == 0 || amrwbenc->channels == 0) {
- ret = GST_FLOW_NOT_NEGOTIATED;
- goto done;
- }
-
- /* discontinuity clears adapter, FIXME, maybe we can set some
- * encoder flag to mask the discont. */
- if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
- gst_adapter_clear (amrwbenc->adapter);
- amrwbenc->ts = 0;
- amrwbenc->discont = TRUE;
- }
-
- if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
- amrwbenc->ts = GST_BUFFER_TIMESTAMP (buffer);
-
- ret = GST_FLOW_OK;
- gst_adapter_push (amrwbenc->adapter, buffer);
-
- /* Collect samples until we have enough for an output frame */
- while (gst_adapter_available (amrwbenc->adapter) >= buffer_size) {
- GstBuffer *out;
- guint8 *data;
- gint outsize;
-
- out = gst_buffer_new_and_alloc (buffer_size);
- GST_BUFFER_DURATION (out) = GST_SECOND * L_FRAME16k /
- (amrwbenc->rate * amrwbenc->channels);
- GST_BUFFER_TIMESTAMP (out) = amrwbenc->ts;
- if (amrwbenc->ts != -1) {
- amrwbenc->ts += GST_BUFFER_DURATION (out);
- }
- if (amrwbenc->discont) {
- GST_BUFFER_FLAG_SET (out, GST_BUFFER_FLAG_DISCONT);
- amrwbenc->discont = FALSE;
- }
- gst_buffer_set_caps (out, gst_pad_get_caps (amrwbenc->srcpad));
-
- data = (guint8 *) gst_adapter_peek (amrwbenc->adapter, buffer_size);
-
- /* encode */
- outsize =
- E_IF_encode (amrwbenc->handle, amrwbenc->bandmode, (Word16 *) data,
- (UWord8 *) GST_BUFFER_DATA (out), 0);
-
- gst_adapter_flush (amrwbenc->adapter, buffer_size);
- GST_BUFFER_SIZE (out) = outsize;
-
- /* play */
- if ((ret = gst_pad_push (amrwbenc->srcpad, out)) != GST_FLOW_OK)
- break;
- }
-
-done:
-
- gst_object_unref (amrwbenc);
- return ret;
-
-}
-
-static GstStateChangeReturn
-gst_amrwbenc_state_change (GstElement * element, GstStateChange transition)
-{
- GstAmrwbEnc *amrwbenc;
- GstStateChangeReturn ret;
-
- amrwbenc = GST_AMRWBENC (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- if (!(amrwbenc->handle = E_IF_init ()))
- return GST_STATE_CHANGE_FAILURE;
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- amrwbenc->rate = 0;
- amrwbenc->channels = 0;
- amrwbenc->ts = 0;
- amrwbenc->discont = FALSE;
- gst_adapter_clear (amrwbenc->adapter);
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_NULL:
- E_IF_exit (amrwbenc->handle);
- break;
- default:
- break;
- }
-
- return ret;
-}
+++ /dev/null
-/* GStreamer Adaptive Multi-Rate Wide-Band (AMR-WB) plugin
- * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_AMRWBENC_H__
-#define __GST_AMRWBENC_H__
-
-#include <gst/gst.h>
-#include <gst/base/gstadapter.h>
-#include <amrwb/enc_if.h>
-#include <amrwb/typedef.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_AMRWBENC \
- (gst_amrwbenc_get_type())
-#define GST_AMRWBENC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AMRWBENC, GstAmrwbEnc))
-#define GST_AMRWBENC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AMRWBENC, GstAmrwbEncClass))
-#define GST_IS_AMRWBENC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AMRWBENC))
-#define GST_IS_AMRWBENC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AMRWBENC))
-
-typedef struct _GstAmrwbEnc GstAmrwbEnc;
-typedef struct _GstAmrwbEncClass GstAmrwbEncClass;
-
-struct _GstAmrwbEnc {
- GstElement element;
-
- /* pads */
- GstPad *sinkpad, *srcpad;
- guint64 ts;
- gboolean discont;
-
- GstAdapter *adapter;
-
- /* library handle */
- void *handle;
-
- /* input settings */
- gint bandmode;
- gint channels, rate;
-};
-
-struct _GstAmrwbEncClass {
- GstElementClass parent_class;
-};
-
-GType gst_amrwbenc_get_type (void);
-
-G_END_DECLS
-
-#endif /* __GST_AMRWBENC_H__ */
--- /dev/null
+[_presets_]
+version=0.10
+element-name=GstVoAmrwbEnc
+
+[enhance-size]
+_meta/comment=Maximize compression, lowest bitrate
+band-mode=0
+
+[enhance-quality]
+_meta/comment=Maximize quality, highest bitrate
+band-mode=8
--- /dev/null
+plugin_LTLIBRARIES = libgstvoamrwbenc.la
+
+libgstvoamrwbenc_la_SOURCES = \
+ gstvoamrwb.c \
+ gstvoamrwbenc.c
+
+libgstvoamrwbenc_la_CFLAGS = $(GST_CFLAGS) $(VOAMRWBENC_CFLAGS)
+libgstvoamrwbenc_la_LIBADD = $(GST_BASE_LIBS) $(VOAMRWBENC_LIBS)
+libgstvoamrwbenc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstvoamrwbenc_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = \
+ gstvoamrwbenc.h
+
+presetdir = $(datadir)/gstreamer-$(GST_MAJORMINOR)/presets
+preset_DATA = GstVoAmrwbEnc.prs
+
+EXTRA_DIST = $(preset_DATA)
+
--- /dev/null
+/* GStreamer Adaptive Multi-Rate Wide-Band (AMR-WB) Encoder plugin
+ * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstvoamrwbenc.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ return gst_element_register (plugin, "voamrwbenc",
+ GST_RANK_SECONDARY, GST_TYPE_VOAMRWBENC);
+}
+
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "voamrwbenc",
+ "Adaptive Multi-Rate Wide-Band Encoder",
+ plugin_init, VERSION, GST_LICENSE_UNKNOWN, GST_PACKAGE_NAME,
+ GST_PACKAGE_ORIGIN);
--- /dev/null
+/* GStreamer Adaptive Multi-Rate Wide-Band (AMR-WB) plugin
+ * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-voamrwbenc
+ * @see_also: #GstAmrWbDec, #GstAmrWbParse
+ *
+ * AMR wideband encoder based on the
+ * <ulink url="http://www.penguin.cz/~utx/amr">reference codec implementation</ulink>.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch filesrc location=abc.wav ! wavparse ! audioresample ! audioconvert ! voamrwbenc ! filesink location=abc.amr
+ * ]|
+ * Please note that the above stream misses the header, that is needed to play
+ * the stream.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstvoamrwbenc.h"
+
+#define MR660 0
+#define MR885 1
+#define MR1265 2
+#define MR1425 2
+#define MR1585 3
+#define MR1825 4
+#define MR1985 5
+#define MR2305 6
+#define MR2385 7
+#define MRDTX 8
+
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+
+static GType
+gst_voamrwbenc_bandmode_get_type (void)
+{
+ static GType gst_voamrwbenc_bandmode_type = 0;
+ static GEnumValue gst_voamrwbenc_bandmode[] = {
+ {MR660, "MR660", "MR660"},
+ {MR885, "MR885", "MR885"},
+ {MR1265, "MR1265", "MR1265"},
+ {MR1425, "MR1425", "MR1425"},
+ {MR1585, "MR1585", "MR1585"},
+ {MR1825, "MR1825", "MR1825"},
+ {MR1985, "MR1985", "MR1985"},
+ {MR2305, "MR2305", "MR2305"},
+ {MR2385, "MR2385", "MR2385"},
+ {MRDTX, "MRDTX", "MRDTX"},
+ {0, NULL, NULL},
+ };
+ if (!gst_voamrwbenc_bandmode_type) {
+ gst_voamrwbenc_bandmode_type =
+ g_enum_register_static ("GstVoAmrWbEncBandMode",
+ gst_voamrwbenc_bandmode);
+ }
+ return gst_voamrwbenc_bandmode_type;
+}
+
+#define GST_VOAMRWBENC_BANDMODE_TYPE (gst_voamrwbenc_bandmode_get_type())
+
+#define BANDMODE_DEFAULT MR660
+
+enum
+{
+ PROP_0,
+ PROP_BANDMODE
+};
+
+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, "
+ "rate = (int) 16000, " "channels = (int) 1")
+ );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/AMR-WB, "
+ "rate = (int) 16000, " "channels = (int) 1")
+ );
+
+GST_DEBUG_CATEGORY_STATIC (gst_voamrwbenc_debug);
+#define GST_CAT_DEFAULT gst_voamrwbenc_debug
+
+static void gst_voamrwbenc_finalize (GObject * object);
+
+static GstFlowReturn gst_voamrwbenc_chain (GstPad * pad, GstBuffer * buffer);
+static gboolean gst_voamrwbenc_setcaps (GstPad * pad, GstCaps * caps);
+static GstStateChangeReturn gst_voamrwbenc_state_change (GstElement * element,
+ GstStateChange transition);
+
+static void
+_do_init (GType object_type)
+{
+ const GInterfaceInfo preset_interface_info = {
+ NULL, /* interface init */
+ NULL, /* interface finalize */
+ NULL /* interface_data */
+ };
+
+ g_type_add_interface_static (object_type, GST_TYPE_PRESET,
+ &preset_interface_info);
+
+ GST_DEBUG_CATEGORY_INIT (gst_voamrwbenc_debug, "amrwbenc", 0,
+ "AMR-WB audio encoder");
+}
+
+GST_BOILERPLATE_FULL (GstVoAmrWbEnc, gst_voamrwbenc, GstElement,
+ GST_TYPE_ELEMENT, _do_init);
+
+static void
+gst_voamrwbenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstVoAmrWbEnc *self = GST_VOAMRWBENC (object);
+
+ switch (prop_id) {
+ case PROP_BANDMODE:
+ self->bandmode = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+
+ return;
+}
+
+static void
+gst_voamrwbenc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstVoAmrWbEnc *self = GST_VOAMRWBENC (object);
+
+ switch (prop_id) {
+ case PROP_BANDMODE:
+ g_value_set_enum (value, self->bandmode);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+
+ return;
+}
+
+static void
+gst_voamrwbenc_base_init (gpointer klass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_template));
+
+ gst_element_class_set_details_simple (element_class, "AMR-WB audio encoder",
+ "Codec/Encoder/Audio",
+ "Adaptive Multi-Rate Wideband audio encoder",
+ "Renato Araujo <renato.filho@indt.org.br>");
+}
+
+static void
+gst_voamrwbenc_class_init (GstVoAmrWbEncClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+
+ object_class->finalize = gst_voamrwbenc_finalize;
+ object_class->set_property = gst_voamrwbenc_set_property;
+ object_class->get_property = gst_voamrwbenc_get_property;
+
+ g_object_class_install_property (object_class, PROP_BANDMODE,
+ g_param_spec_enum ("band-mode", "Band Mode",
+ "Encoding Band Mode (Kbps)", GST_VOAMRWBENC_BANDMODE_TYPE,
+ BANDMODE_DEFAULT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
+ element_class->change_state = GST_DEBUG_FUNCPTR (gst_voamrwbenc_state_change);
+}
+
+static void
+gst_voamrwbenc_init (GstVoAmrWbEnc * amrwbenc, GstVoAmrWbEncClass * klass)
+{
+ /* create the sink pad */
+ amrwbenc->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
+ gst_pad_set_setcaps_function (amrwbenc->sinkpad, gst_voamrwbenc_setcaps);
+ gst_pad_set_chain_function (amrwbenc->sinkpad, gst_voamrwbenc_chain);
+ gst_element_add_pad (GST_ELEMENT (amrwbenc), amrwbenc->sinkpad);
+
+ /* create the src pad */
+ amrwbenc->srcpad = gst_pad_new_from_static_template (&src_template, "src");
+ gst_pad_use_fixed_caps (amrwbenc->srcpad);
+ gst_element_add_pad (GST_ELEMENT (amrwbenc), amrwbenc->srcpad);
+
+ amrwbenc->adapter = gst_adapter_new ();
+
+ /* init rest */
+ amrwbenc->handle = NULL;
+ amrwbenc->channels = 0;
+ amrwbenc->rate = 0;
+ amrwbenc->ts = 0;
+}
+
+static void
+gst_voamrwbenc_finalize (GObject * object)
+{
+ GstVoAmrWbEnc *amrwbenc;
+
+ amrwbenc = GST_VOAMRWBENC (object);
+
+ g_object_unref (G_OBJECT (amrwbenc->adapter));
+ amrwbenc->adapter = NULL;
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static gboolean
+gst_voamrwbenc_setcaps (GstPad * pad, GstCaps * caps)
+{
+ GstStructure *structure;
+ GstVoAmrWbEnc *amrwbenc;
+ GstCaps *copy;
+
+ amrwbenc = GST_VOAMRWBENC (GST_PAD_PARENT (pad));
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ /* get channel count */
+ gst_structure_get_int (structure, "channels", &amrwbenc->channels);
+ gst_structure_get_int (structure, "rate", &amrwbenc->rate);
+
+ /* this is not wrong but will sound bad */
+ if (amrwbenc->channels != 1) {
+ GST_WARNING ("amrwbdec is only optimized for mono channels");
+ }
+ if (amrwbenc->rate != 16000) {
+ GST_WARNING ("amrwbdec is only optimized for 16000 Hz samplerate");
+ }
+
+ /* create reverse caps */
+ copy = gst_caps_new_simple ("audio/AMR-WB",
+ "channels", G_TYPE_INT, amrwbenc->channels,
+ "rate", G_TYPE_INT, amrwbenc->rate, NULL);
+
+ gst_pad_set_caps (amrwbenc->srcpad, copy);
+ gst_caps_unref (copy);
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_voamrwbenc_chain (GstPad * pad, GstBuffer * buffer)
+{
+ GstVoAmrWbEnc *amrwbenc;
+ GstFlowReturn ret = GST_FLOW_OK;
+ const int buffer_size = sizeof (short) * L_FRAME16k;
+
+ amrwbenc = GST_VOAMRWBENC (gst_pad_get_parent (pad));
+
+ g_return_val_if_fail (amrwbenc->handle, GST_FLOW_WRONG_STATE);
+
+ if (amrwbenc->rate == 0 || amrwbenc->channels == 0) {
+ ret = GST_FLOW_NOT_NEGOTIATED;
+ goto done;
+ }
+
+ /* discontinuity clears adapter, FIXME, maybe we can set some
+ * encoder flag to mask the discont. */
+ if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
+ gst_adapter_clear (amrwbenc->adapter);
+ amrwbenc->ts = 0;
+ amrwbenc->discont = TRUE;
+ }
+
+ if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
+ amrwbenc->ts = GST_BUFFER_TIMESTAMP (buffer);
+
+ ret = GST_FLOW_OK;
+ gst_adapter_push (amrwbenc->adapter, buffer);
+
+ /* Collect samples until we have enough for an output frame */
+ while (gst_adapter_available (amrwbenc->adapter) >= buffer_size) {
+ GstBuffer *out;
+ guint8 *data;
+ gint outsize;
+
+ out = gst_buffer_new_and_alloc (buffer_size);
+ GST_BUFFER_DURATION (out) = GST_SECOND * L_FRAME16k /
+ (amrwbenc->rate * amrwbenc->channels);
+ GST_BUFFER_TIMESTAMP (out) = amrwbenc->ts;
+ if (amrwbenc->ts != -1) {
+ amrwbenc->ts += GST_BUFFER_DURATION (out);
+ }
+ if (amrwbenc->discont) {
+ GST_BUFFER_FLAG_SET (out, GST_BUFFER_FLAG_DISCONT);
+ amrwbenc->discont = FALSE;
+ }
+ gst_buffer_set_caps (out, gst_pad_get_caps (amrwbenc->srcpad));
+
+ data = (guint8 *) gst_adapter_peek (amrwbenc->adapter, buffer_size);
+
+ /* encode */
+ outsize =
+ E_IF_encode (amrwbenc->handle, amrwbenc->bandmode, (const short *) data,
+ (unsigned char *) GST_BUFFER_DATA (out), 0);
+
+ gst_adapter_flush (amrwbenc->adapter, buffer_size);
+ GST_BUFFER_SIZE (out) = outsize;
+
+ /* play */
+ if ((ret = gst_pad_push (amrwbenc->srcpad, out)) != GST_FLOW_OK)
+ break;
+ }
+
+done:
+
+ gst_object_unref (amrwbenc);
+ return ret;
+
+}
+
+static GstStateChangeReturn
+gst_voamrwbenc_state_change (GstElement * element, GstStateChange transition)
+{
+ GstVoAmrWbEnc *amrwbenc;
+ GstStateChangeReturn ret;
+
+ amrwbenc = GST_VOAMRWBENC (element);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ if (!(amrwbenc->handle = E_IF_init ()))
+ return GST_STATE_CHANGE_FAILURE;
+ break;
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ amrwbenc->rate = 0;
+ amrwbenc->channels = 0;
+ amrwbenc->ts = 0;
+ amrwbenc->discont = FALSE;
+ gst_adapter_clear (amrwbenc->adapter);
+ break;
+ default:
+ break;
+ }
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_READY_TO_NULL:
+ E_IF_exit (amrwbenc->handle);
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
--- /dev/null
+/* GStreamer Adaptive Multi-Rate Wide-Band (AMR-WB) plugin
+ * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_VOAMRWBENC_H__
+#define __GST_VOAMRWBENC_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstadapter.h>
+#include <vo-amrwbenc/enc_if.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_VOAMRWBENC \
+ (gst_voamrwbenc_get_type())
+#define GST_VOAMRWBENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VOAMRWBENC, GstVoAmrWbEnc))
+#define GST_VOAMRWBENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VOAMRWBENC, GstVoAmrWbEncClass))
+#define GST_IS_VOAMRWBENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VOAMRWBENC))
+#define GST_IS_VOAMRWBENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VOAMRWBENC))
+
+typedef struct _GstVoAmrWbEnc GstVoAmrWbEnc;
+typedef struct _GstVoAmrWbEncClass GstVoAmrWbEncClass;
+
+struct _GstVoAmrWbEnc {
+ GstElement element;
+
+ /* pads */
+ GstPad *sinkpad, *srcpad;
+ guint64 ts;
+ gboolean discont;
+
+ GstAdapter *adapter;
+
+ /* library handle */
+ void *handle;
+
+ /* input settings */
+ gint bandmode;
+ gint channels, rate;
+};
+
+struct _GstVoAmrWbEncClass {
+ GstElementClass parent_class;
+};
+
+GType gst_voamrwbenc_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_VOAMRWBENC_H__ */