mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
voamrwbenc: port to 0.11
This commit is contained in:
parent
545068efd8
commit
76811c2181
2 changed files with 23 additions and 26 deletions
|
@ -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
|
||||
|
|
|
@ -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@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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue