diff options
author | Daniel Charles <dcharles@ti.com> | 2007-09-16 07:28:18 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2007-09-16 07:28:18 +0000 |
commit | 51990d65dc103c9355bb83ef4bc75f7e1eae0ac4 (patch) | |
tree | 2456196d7c57202794139102026a86ef20028157 | |
parent | 6494828ef2e9aefb41822cf476afe4b306ceb42a (diff) | |
download | gst-plugins-bad-51990d65dc103c9355bb83ef4bc75f7e1eae0ac4.tar.gz gst-plugins-bad-51990d65dc103c9355bb83ef4bc75f7e1eae0ac4.tar.bz2 gst-plugins-bad-51990d65dc103c9355bb83ef4bc75f7e1eae0ac4.zip |
ext/amrwb/gstamrwbenc.*: Add property to control bandmode. Fixes #477306.
Original commit message from CVS:
Patch by: Daniel Charles <dcharles at ti dot com>
* ext/amrwb/gstamrwbenc.c: (gst_amrwbenc_bandmode_get_type),
(gst_amrwbenc_set_property), (gst_amrwbenc_get_property),
(gst_amrwbenc_class_init), (gst_amrwbenc_chain):
* ext/amrwb/gstamrwbenc.h:
Add property to control bandmode. Fixes #477306.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | ext/amrwb/gstamrwbenc.c | 94 | ||||
-rw-r--r-- | ext/amrwb/gstamrwbenc.h | 2 |
3 files changed, 104 insertions, 2 deletions
@@ -1,3 +1,13 @@ +2007-09-16 Wim Taymans <wim.taymans@gmail.com> + + Patch by: Daniel Charles <dcharles at ti dot com> + + * ext/amrwb/gstamrwbenc.c: (gst_amrwbenc_bandmode_get_type), + (gst_amrwbenc_set_property), (gst_amrwbenc_get_property), + (gst_amrwbenc_class_init), (gst_amrwbenc_chain): + * ext/amrwb/gstamrwbenc.h: + Add property to control bandmode. Fixes #477306. + 2007-09-15 Wim Taymans <wim.taymans@gmail.com> * gst/rtpmanager/gstrtpbin.c: (create_session): diff --git a/ext/amrwb/gstamrwbenc.c b/ext/amrwb/gstamrwbenc.c index 8e78de00..33b3dc73 100644 --- a/ext/amrwb/gstamrwbenc.c +++ b/ext/amrwb/gstamrwbenc.c @@ -43,6 +43,54 @@ #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 () +{ + 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, @@ -78,6 +126,42 @@ 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); @@ -101,6 +185,13 @@ gst_amrwbenc_class_init (GstAmrwbEncClass * 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)); element_class->change_state = GST_DEBUG_FUNCPTR (gst_amrwbenc_state_change); } @@ -213,7 +304,8 @@ gst_amrwbenc_chain (GstPad * pad, GstBuffer * buffer) data = (guint8 *) gst_adapter_peek (amrwbenc->adapter, buffer_size); /* encode */ - outsize = E_IF_encode (amrwbenc->handle, 0, (Word16 *) data, + outsize = + E_IF_encode (amrwbenc->handle, amrwbenc->bandmode, (Word16 *) data, (UWord8 *) GST_BUFFER_DATA (out), 0); gst_adapter_flush (amrwbenc->adapter, buffer_size); diff --git a/ext/amrwb/gstamrwbenc.h b/ext/amrwb/gstamrwbenc.h index 2c872de2..1f3fa2d0 100644 --- a/ext/amrwb/gstamrwbenc.h +++ b/ext/amrwb/gstamrwbenc.h @@ -25,7 +25,6 @@ #include <amrwb/enc_if.h> #include <amrwb/typedef.h> - G_BEGIN_DECLS #define GST_TYPE_AMRWBENC \ @@ -55,6 +54,7 @@ struct _GstAmrwbEnc { void *handle; /* input settings */ + gint bandmode; gint channels, rate; }; |