mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 13:36:39 +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 \
|
voaacenc apexsink bz2 cdaudio celt cog curl dc1394 dirac directfb resindvd \
|
||||||
gsettings gsm jp2k ladspa modplug mpeg2enc mplex mimic \
|
gsettings gsm jp2k ladspa modplug mpeg2enc mplex mimic \
|
||||||
musepack musicbrainz nas neon ofa openal opencv rsvg schro sdl smooth sndfile soundtouch spandsp timidity \
|
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)
|
AC_SUBST(GST_PLUGINS_NONPORTED)
|
||||||
|
|
||||||
dnl these are all the gst plug-ins, compilable without additional libs
|
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",
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"width = (int) 16, "
|
"format = (string) S16LE, "
|
||||||
"depth = (int) 16, "
|
"layout = (string) interleaved, "
|
||||||
"signed = (boolean) TRUE, "
|
|
||||||
"endianness = (int) BYTE_ORDER, "
|
|
||||||
"rate = (int) 16000, " "channels = (int) 1")
|
"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,
|
static GstFlowReturn gst_voamrwbenc_handle_frame (GstAudioEncoder * enc,
|
||||||
GstBuffer * in_buf);
|
GstBuffer * in_buf);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstVoAmrWbEnc, gst_voamrwbenc, GstAudioEncoder,
|
G_DEFINE_TYPE (GstVoAmrWbEnc, gst_voamrwbenc, GST_TYPE_AUDIO_ENCODER);
|
||||||
GST_TYPE_AUDIO_ENCODER);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_voamrwbenc_set_property (GObject * object, guint prop_id,
|
gst_voamrwbenc_set_property (GObject * object, guint prop_id,
|
||||||
|
@ -156,9 +153,14 @@ gst_voamrwbenc_get_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
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_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&sink_template));
|
gst_static_pad_template_get (&sink_template));
|
||||||
|
@ -169,16 +171,6 @@ gst_voamrwbenc_base_init (gpointer klass)
|
||||||
"Codec/Encoder/Audio",
|
"Codec/Encoder/Audio",
|
||||||
"Adaptive Multi-Rate Wideband audio encoder",
|
"Adaptive Multi-Rate Wideband audio encoder",
|
||||||
"Renato Araujo <renato.filho@indt.org.br>");
|
"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->start = GST_DEBUG_FUNCPTR (gst_voamrwbenc_start);
|
||||||
base_class->stop = GST_DEBUG_FUNCPTR (gst_voamrwbenc_stop);
|
base_class->stop = GST_DEBUG_FUNCPTR (gst_voamrwbenc_stop);
|
||||||
|
@ -193,7 +185,7 @@ gst_voamrwbenc_class_init (GstVoAmrWbEncClass * klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_voamrwbenc_init (GstVoAmrWbEnc * amrwbenc, GstVoAmrWbEncClass * klass)
|
gst_voamrwbenc_init (GstVoAmrWbEnc * amrwbenc)
|
||||||
{
|
{
|
||||||
/* init rest */
|
/* init rest */
|
||||||
amrwbenc->handle = NULL;
|
amrwbenc->handle = NULL;
|
||||||
|
@ -276,6 +268,8 @@ gst_voamrwbenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buffer)
|
||||||
const int buffer_size = sizeof (short) * L_FRAME16k;
|
const int buffer_size = sizeof (short) * L_FRAME16k;
|
||||||
GstBuffer *out;
|
GstBuffer *out;
|
||||||
gint outsize;
|
gint outsize;
|
||||||
|
gsize size;
|
||||||
|
guint8 *data, *outdata;
|
||||||
|
|
||||||
amrwbenc = GST_VOAMRWBENC (benc);
|
amrwbenc = GST_VOAMRWBENC (benc);
|
||||||
|
|
||||||
|
@ -287,21 +281,24 @@ gst_voamrwbenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buffer)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_UNLIKELY (GST_BUFFER_SIZE (buffer) < buffer_size)) {
|
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||||
GST_DEBUG_OBJECT (amrwbenc, "discarding trailing data %d",
|
|
||||||
buffer ? GST_BUFFER_SIZE (buffer) : 0);
|
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);
|
ret = gst_audio_encoder_finish_frame (benc, NULL, -1);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
out = gst_buffer_new_and_alloc (buffer_size);
|
out = gst_buffer_new_and_alloc (buffer_size);
|
||||||
|
outdata = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
|
||||||
/* encode */
|
/* encode */
|
||||||
outsize = E_IF_encode (amrwbenc->handle, amrwbenc->bandmode,
|
outsize = E_IF_encode (amrwbenc->handle, amrwbenc->bandmode,
|
||||||
(const short *) GST_BUFFER_DATA (buffer),
|
(const short *) data, (unsigned char *) outdata, 0);
|
||||||
(unsigned char *) GST_BUFFER_DATA (out), 0);
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (amrwbenc, "encoded to %d bytes", outsize);
|
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);
|
ret = gst_audio_encoder_finish_frame (benc, out, L_FRAME16k);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue