ext/amrnb/amrnbenc.*: Add property to select the BandMode of the AMR encoder.

Original commit message from CVS:
Patch by: Daniel Charles <dcharles at ti dot com>
* ext/amrnb/amrnbenc.c: (gst_amrnbenc_bandmode_get_type),
(gst_amrnbenc_set_property), (gst_amrnbenc_get_property),
(gst_amrnbenc_base_init), (gst_amrnbenc_class_init),
(gst_amrnbenc_chain), (gst_amrnbenc_state_change):
* ext/amrnb/amrnbenc.h:
Add property to select the BandMode of the AMR encoder.
See #466442.
This commit is contained in:
Daniel Charles 2007-08-16 14:49:11 +00:00 committed by Wim Taymans
parent e37bf5005f
commit cabd62c45b
3 changed files with 90 additions and 4 deletions

View file

@ -1,3 +1,15 @@
2007-08-16 Wim Taymans <wim.taymans@gmail.com>
Patch by: Daniel Charles <dcharles at ti dot com>
* ext/amrnb/amrnbenc.c: (gst_amrnbenc_bandmode_get_type),
(gst_amrnbenc_set_property), (gst_amrnbenc_get_property),
(gst_amrnbenc_base_init), (gst_amrnbenc_class_init),
(gst_amrnbenc_chain), (gst_amrnbenc_state_change):
* ext/amrnb/amrnbenc.h:
Add property to select the BandMode of the AMR encoder.
See #466442.
2007-08-16 Stefan Kost <ensonic@users.sf.net> 2007-08-16 Stefan Kost <ensonic@users.sf.net>
* gst/realmedia/asmrules.c: * gst/realmedia/asmrules.c:

View file

@ -43,6 +43,38 @@
#include "amrnbenc.h" #include "amrnbenc.h"
static GType
gst_amrnbenc_bandmode_get_type ()
{
static GType gst_amrnbenc_bandmode_type = 0;
static const GEnumValue gst_amrnbenc_bandmode[] = {
{MR475, "MR475", "MR475"},
{MR515, "MR515", "MR515"},
{MR59, "MR59", "MR59"},
{MR67, "MR67", "MR67"},
{MR74, "MR74", "MR74"},
{MR795, "MR795", "MR795"},
{MR102, "MR102", "MR102"},
{MR122, "MR122", "MR122"},
{MRDTX, "MRDTX", "MRDTX"},
{0, NULL, NULL},
};
if (!gst_amrnbenc_bandmode_type) {
gst_amrnbenc_bandmode_type =
g_enum_register_static ("GstAmrnbEncBandMode", gst_amrnbenc_bandmode);
}
return gst_amrnbenc_bandmode_type;
}
#define GST_AMRNBENC_BANDMODE_TYPE (gst_amrnbenc_bandmode_get_type())
#define BANDMODE_DEFAULT MR122
enum
{
PROP_0,
PROP_BANDMODE
};
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
@ -76,6 +108,40 @@ static GstStateChangeReturn gst_amrnbenc_state_change (GstElement * element,
GST_BOILERPLATE_FULL (GstAmrnbEnc, gst_amrnbenc, GstElement, GST_TYPE_ELEMENT, GST_BOILERPLATE_FULL (GstAmrnbEnc, gst_amrnbenc, GstElement, GST_TYPE_ELEMENT,
_do_init); _do_init);
static void
gst_amrnbenc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstAmrnbEnc *self = GST_AMRNBENC (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_amrnbenc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstAmrnbEnc *self = GST_AMRNBENC (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 static void
gst_amrnbenc_base_init (gpointer klass) gst_amrnbenc_base_init (gpointer klass)
{ {
@ -84,7 +150,7 @@ gst_amrnbenc_base_init (gpointer klass)
"Codec/Encoder/Audio", "Codec/Encoder/Audio",
"Adaptive Multi-Rate Narrow-Band audio encoder", "Adaptive Multi-Rate Narrow-Band audio encoder",
"Ronald Bultje <rbultje@ronald.bitfreak.net>, " "Ronald Bultje <rbultje@ronald.bitfreak.net>, "
"Wim Taymans <wim@fluendo.com>"); "Wim Taymans <wim.taymans@gmail.com>");
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template)); gst_static_pad_template_get (&sink_template));
@ -100,8 +166,15 @@ gst_amrnbenc_class_init (GstAmrnbEncClass * klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
object_class->set_property = gst_amrnbenc_set_property;
object_class->get_property = gst_amrnbenc_get_property;
object_class->finalize = gst_amrnbenc_finalize; object_class->finalize = gst_amrnbenc_finalize;
g_object_class_install_property (object_class, PROP_BANDMODE,
g_param_spec_enum ("band-mode", "Band Mode",
"Encoding Band Mode (Kbps)", GST_AMRNBENC_BANDMODE_TYPE,
BANDMODE_DEFAULT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
element_class->change_state = GST_DEBUG_FUNCPTR (gst_amrnbenc_state_change); element_class->change_state = GST_DEBUG_FUNCPTR (gst_amrnbenc_state_change);
} }
@ -222,8 +295,9 @@ gst_amrnbenc_chain (GstPad * pad, GstBuffer * buffer)
data = gst_adapter_take (amrnbenc->adapter, 320); data = gst_adapter_take (amrnbenc->adapter, 320);
/* encode */ /* encode */
outsize = Encoder_Interface_Encode (amrnbenc->handle, MR122, (short *) data, outsize =
(guint8 *) GST_BUFFER_DATA (out), 0); Encoder_Interface_Encode (amrnbenc->handle, amrnbenc->bandmode,
(short *) data, (guint8 *) GST_BUFFER_DATA (out), 0);
g_free (data); g_free (data);
@ -276,6 +350,5 @@ gst_amrnbenc_state_change (GstElement * element, GstStateChange transition)
default: default:
break; break;
} }
return ret; return ret;
} }

View file

@ -53,6 +53,7 @@ struct _GstAmrnbEnc {
void *handle; void *handle;
/* input settings */ /* input settings */
enum Mode bandmode;
gint channels, rate; gint channels, rate;
gint duration; gint duration;
}; };