2 * Copyright (C) 2016 Sebastian Dröge <sebastian@centricular.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
24 #include "gstfdkaac.h"
25 #include "gstfdkaacenc.h"
27 #include <gst/pbutils/pbutils.h>
32 * - Add support for other AOT / profiles
33 * - Signal encoder delay
34 * - LOAS / LATM support
47 #define DEFAULT_BITRATE (0)
48 #define DEFAULT_PEAK_BITRATE (0)
49 #define DEFAULT_RATE_CONTROL (GST_FDK_AAC_RATE_CONTROL_CONSTANT_BITRATE)
50 #define DEFAULT_VBR_PRESET (GST_FDK_AAC_VBR_PRESET_MEDIUM)
52 #define SAMPLE_RATES " 8000, " \
65 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
68 GST_STATIC_CAPS ("audio/x-raw, "
69 "format = (string) " GST_AUDIO_NE (S16) ", "
70 "layout = (string) interleaved, "
71 "rate = (int) { " SAMPLE_RATES " }, "
72 "channels = (int) {1, 2, 3, 4, 5, 6, 8}")
75 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
78 GST_STATIC_CAPS ("audio/mpeg, "
79 "mpegversion = (int) 4, "
80 "rate = (int) { " SAMPLE_RATES " }, "
81 "channels = (int) {1, 2, 3, 4, 5, 6, 8}, "
82 "stream-format = (string) { adts, adif, raw }, "
83 "profile = (string) { lc, he-aac-v1, he-aac-v2, ld }, "
84 "framed = (boolean) true")
87 GST_DEBUG_CATEGORY_STATIC (gst_fdkaacenc_debug);
88 #define GST_CAT_DEFAULT gst_fdkaacenc_debug
90 static void gst_fdkaacenc_set_property (GObject * object, guint prop_id,
91 const GValue * value, GParamSpec * pspec);
92 static void gst_fdkaacenc_get_property (GObject * object, guint prop_id,
93 GValue * value, GParamSpec * pspec);
94 static gboolean gst_fdkaacenc_start (GstAudioEncoder * enc);
95 static gboolean gst_fdkaacenc_stop (GstAudioEncoder * enc);
96 static gboolean gst_fdkaacenc_set_format (GstAudioEncoder * enc,
98 static GstFlowReturn gst_fdkaacenc_handle_frame (GstAudioEncoder * enc,
100 static GstCaps *gst_fdkaacenc_get_caps (GstAudioEncoder * enc,
102 static void gst_fdkaacenc_flush (GstAudioEncoder * enc);
104 G_DEFINE_TYPE (GstFdkAacEnc, gst_fdkaacenc, GST_TYPE_AUDIO_ENCODER);
105 GST_ELEMENT_REGISTER_DEFINE (fdkaacenc, "fdkaacenc", GST_RANK_PRIMARY,
108 #define GST_FDK_AAC_VBR_PRESET (gst_fdk_aac_vbr_preset_get_type ())
110 gst_fdk_aac_vbr_preset_get_type (void)
112 static GType fdk_aac_vbr_preset_type = 0;
113 static const GEnumValue vbr_preset_types[] = {
114 {GST_FDK_AAC_VBR_PRESET_VERY_LOW, "Very Low Variable Bitrate", "very-low"},
115 {GST_FDK_AAC_VBR_PRESET_LOW, "Low Variable Bitrate", "low"},
116 {GST_FDK_AAC_VBR_PRESET_MEDIUM, "Medium Variable Bitrate", "medium"},
117 {GST_FDK_AAC_VBR_PRESET_HIGH, "High Variable Bitrate", "high"},
118 {GST_FDK_AAC_VBR_PRESET_VERY_HIGH, "Very High Variable Bitrate",
123 if (!fdk_aac_vbr_preset_type)
124 fdk_aac_vbr_preset_type =
125 g_enum_register_static ("GstFdkAacVbrPreset", vbr_preset_types);
127 return fdk_aac_vbr_preset_type;
130 #define GST_FDK_AAC_RATE_CONTROL (gst_fdk_aac_rate_control_get_type ())
132 gst_fdk_aac_rate_control_get_type (void)
134 static GType fdk_aac_rate_control_type = 0;
135 static const GEnumValue rate_control_types[] = {
136 {GST_FDK_AAC_RATE_CONTROL_CONSTANT_BITRATE, "Constant Bitrate", "cbr"},
137 {GST_FDK_AAC_RATE_CONTROL_VARIABLE_BITRATE, "Variable Bitrate", "vbr"},
141 if (!fdk_aac_rate_control_type)
142 fdk_aac_rate_control_type =
143 g_enum_register_static ("GstFdkAacRateControl", rate_control_types);
145 return fdk_aac_rate_control_type;
149 gst_fdkaacenc_set_property (GObject * object, guint prop_id,
150 const GValue * value, GParamSpec * pspec)
152 GstFdkAacEnc *self = GST_FDKAACENC (object);
156 self->bitrate = g_value_get_int (value);
158 case PROP_AFTERBURNER:
159 self->afterburner = g_value_get_boolean (value);
161 case PROP_PEAK_BITRATE:
162 self->peak_bitrate = g_value_get_int (value);
164 case PROP_RATE_CONTROL:
165 self->rate_control = g_value_get_enum (value);
167 case PROP_VBR_PRESET:
168 self->vbr_preset = g_value_get_enum (value);
171 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
178 gst_fdkaacenc_get_property (GObject * object, guint prop_id,
179 GValue * value, GParamSpec * pspec)
181 GstFdkAacEnc *self = GST_FDKAACENC (object);
185 g_value_set_int (value, self->bitrate);
187 case PROP_AFTERBURNER:
188 g_value_set_boolean (value, self->afterburner);
190 case PROP_PEAK_BITRATE:
191 g_value_set_int (value, self->peak_bitrate);
193 case PROP_RATE_CONTROL:
194 g_value_set_enum (value, self->rate_control);
196 case PROP_VBR_PRESET:
197 g_value_set_enum (value, self->vbr_preset);
200 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
207 gst_fdkaacenc_start (GstAudioEncoder * enc)
209 GstFdkAacEnc *self = GST_FDKAACENC (enc);
211 GST_DEBUG_OBJECT (self, "start");
217 gst_fdkaacenc_stop (GstAudioEncoder * enc)
219 GstFdkAacEnc *self = GST_FDKAACENC (enc);
221 GST_DEBUG_OBJECT (self, "stop");
224 aacEncClose (&self->enc);
228 self->is_drained = TRUE;
233 gst_fdkaacenc_get_caps (GstAudioEncoder * enc, GstCaps * filter)
235 const GstFdkAacChannelLayout *layout;
236 GstCaps *res, *caps, *allowed_caps;
237 gboolean allow_mono = TRUE;
239 allowed_caps = gst_pad_get_allowed_caps (GST_AUDIO_ENCODER_SRC_PAD (enc));
240 GST_DEBUG_OBJECT (enc, "allowed caps %" GST_PTR_FORMAT, allowed_caps);
242 /* We need at least 2 channels if Parametric Stereo is in use. */
243 if (allowed_caps && gst_caps_get_size (allowed_caps) > 0) {
244 GstStructure *s = gst_caps_get_structure (allowed_caps, 0);
245 const gchar *profile = NULL;
247 if ((profile = gst_structure_get_string (s, "profile"))
248 && strcmp (profile, "he-aac-v2") == 0) {
252 gst_clear_caps (&allowed_caps);
254 caps = gst_caps_new_empty ();
256 for (layout = channel_layouts; layout->channels; layout++) {
258 gint channels = layout->channels;
260 if (channels == 1 && !allow_mono)
263 tmp = gst_caps_make_writable (gst_pad_get_pad_template_caps
264 (GST_AUDIO_ENCODER_SINK_PAD (enc)));
267 gst_caps_set_simple (tmp, "channels", G_TYPE_INT, channels, NULL);
269 guint64 channel_mask;
270 gst_audio_channel_positions_to_mask (layout->positions, channels, FALSE,
272 gst_caps_set_simple (tmp, "channels", G_TYPE_INT, channels,
273 "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL);
276 gst_caps_append (caps, tmp);
279 res = gst_audio_encoder_proxy_getcaps (enc, caps, filter);
280 gst_caps_unref (caps);
286 gst_fdkaacenc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
288 GstFdkAacEnc *self = GST_FDKAACENC (enc);
289 gboolean ret = FALSE;
290 GstCaps *allowed_caps;
294 gint mpegversion = 4;
295 gint aot = AOT_AAC_LC;
296 const gchar *profile_str = "lc";
297 CHANNEL_MODE channel_mode;
298 AACENC_InfoStruct enc_info = { 0 };
299 gint bitrate, signaling_mode;
302 if (self->enc && !self->is_drained) {
304 gst_fdkaacenc_handle_frame (enc, NULL);
305 aacEncClose (&self->enc);
306 self->is_drained = TRUE;
309 allowed_caps = gst_pad_get_allowed_caps (GST_AUDIO_ENCODER_SRC_PAD (self));
311 GST_DEBUG_OBJECT (self, "allowed caps: %" GST_PTR_FORMAT, allowed_caps);
313 if (allowed_caps && gst_caps_get_size (allowed_caps) > 0) {
314 GstStructure *s = gst_caps_get_structure (allowed_caps, 0);
315 const gchar *str = NULL;
317 if ((str = gst_structure_get_string (s, "stream-format"))) {
318 if (strcmp (str, "adts") == 0) {
319 GST_DEBUG_OBJECT (self, "use ADTS format for output");
321 } else if (strcmp (str, "adif") == 0) {
322 GST_DEBUG_OBJECT (self, "use ADIF format for output");
324 } else if (strcmp (str, "raw") == 0) {
325 GST_DEBUG_OBJECT (self, "use RAW format for output");
330 if ((str = gst_structure_get_string (s, "profile"))) {
331 if (strcmp (str, "lc") == 0) {
332 GST_DEBUG_OBJECT (self, "using AAC-LC profile for output");
335 } else if (strcmp (str, "he-aac-v1") == 0) {
336 GST_DEBUG_OBJECT (self, "using SBR (HE-AACv1) profile for output");
338 profile_str = "he-aac-v1";
339 } else if (strcmp (str, "he-aac-v2") == 0) {
340 GST_DEBUG_OBJECT (self, "using PS (HE-AACv2) profile for output");
342 profile_str = "he-aac-v2";
343 } else if (strcmp (str, "ld") == 0) {
344 GST_DEBUG_OBJECT (self, "using AAC-LD profile for output");
350 gst_structure_get_int (s, "mpegversion", &mpegversion);
353 gst_caps_unref (allowed_caps);
355 err = aacEncOpen (&self->enc, 0, GST_AUDIO_INFO_CHANNELS (info));
356 if (err != AACENC_OK) {
357 GST_ERROR_OBJECT (self, "Unable to open encoder: %d", err);
361 if ((err = aacEncoder_SetParam (self->enc, AACENC_AOT, aot)) != AACENC_OK) {
362 GST_ERROR_OBJECT (self, "Unable to set AOT %d: %d", aot, err);
366 /* Use explicit hierarchical signaling (2) with raw output stream-format
367 * and implicit signaling (0) with ADTS/ADIF */
373 if ((err = aacEncoder_SetParam (self->enc, AACENC_SIGNALING_MODE,
374 signaling_mode)) != AACENC_OK) {
375 GST_ERROR_OBJECT (self, "Unable to set signaling mode %d: %d",
376 signaling_mode, err);
380 if ((err = aacEncoder_SetParam (self->enc, AACENC_SAMPLERATE,
381 GST_AUDIO_INFO_RATE (info))) != AACENC_OK) {
382 GST_ERROR_OBJECT (self, "Unable to set sample rate %d: %d",
383 GST_AUDIO_INFO_RATE (info), err);
387 if (GST_AUDIO_INFO_CHANNELS (info) == 1) {
388 channel_mode = MODE_1;
389 self->need_reorder = FALSE;
390 self->aac_positions = NULL;
392 gint in_channels = GST_AUDIO_INFO_CHANNELS (info);
393 const GstAudioChannelPosition *in_positions =
394 &GST_AUDIO_INFO_POSITION (info, 0);
395 guint64 in_channel_mask;
396 const GstFdkAacChannelLayout *layout;
398 gst_audio_channel_positions_to_mask (in_positions, in_channels, FALSE,
401 for (layout = channel_layouts; layout->channels; layout++) {
402 gint channels = layout->channels;
403 const GstAudioChannelPosition *positions = layout->positions;
404 guint64 channel_mask;
406 if (channels != in_channels)
409 gst_audio_channel_positions_to_mask (positions, channels, FALSE,
411 if (channel_mask != in_channel_mask)
414 channel_mode = layout->mode;
415 self->need_reorder = memcmp (positions, in_positions,
416 channels * sizeof *positions) != 0;
417 self->aac_positions = positions;
421 if (!layout->channels) {
422 GST_ERROR_OBJECT (self, "Couldn't find a valid channel layout");
427 if ((err = aacEncoder_SetParam (self->enc, AACENC_CHANNELMODE,
428 channel_mode)) != AACENC_OK) {
429 GST_ERROR_OBJECT (self, "Unable to set channel mode %d: %d", channel_mode,
434 /* MPEG channel order */
435 if ((err = aacEncoder_SetParam (self->enc, AACENC_CHANNELORDER,
437 GST_ERROR_OBJECT (self, "Unable to set channel order %d: %d", channel_mode,
442 bitrate = self->bitrate;
444 * http://wiki.hydrogenaud.io/index.php?title=Fraunhofer_FDK_AAC#Recommended_Sampling_Rate_and_Bitrate_Combinations
447 if (GST_AUDIO_INFO_CHANNELS (info) == 1) {
448 if (GST_AUDIO_INFO_RATE (info) < 16000) {
450 } else if (GST_AUDIO_INFO_RATE (info) == 16000) {
452 } else if (GST_AUDIO_INFO_RATE (info) < 32000) {
454 } else if (GST_AUDIO_INFO_RATE (info) == 32000) {
456 } else if (GST_AUDIO_INFO_RATE (info) <= 44100) {
461 } else if (GST_AUDIO_INFO_CHANNELS (info) == 2) {
462 if (GST_AUDIO_INFO_RATE (info) < 16000) {
464 } else if (GST_AUDIO_INFO_RATE (info) == 16000) {
466 } else if (GST_AUDIO_INFO_RATE (info) < 22050) {
468 } else if (GST_AUDIO_INFO_RATE (info) < 32000) {
470 } else if (GST_AUDIO_INFO_RATE (info) == 32000) {
472 } else if (GST_AUDIO_INFO_RATE (info) <= 44100) {
479 if (GST_AUDIO_INFO_RATE (info) < 32000) {
481 } else if (GST_AUDIO_INFO_RATE (info) <= 44100) {
489 if ((err = aacEncoder_SetParam (self->enc, AACENC_TRANSMUX,
490 transmux)) != AACENC_OK) {
491 GST_ERROR_OBJECT (self, "Unable to set transmux %d: %d", transmux, err);
495 if ((err = aacEncoder_SetParam (self->enc, AACENC_BITRATE,
496 bitrate)) != AACENC_OK) {
497 GST_ERROR_OBJECT (self, "Unable to set bitrate %d: %d", bitrate, err);
501 if (self->rate_control == GST_FDK_AAC_RATE_CONTROL_CONSTANT_BITRATE) {
503 * Note that the `bitrate` property is honoured only when using
506 bitrate_mode = 0; // Constant Bitrate
508 bitrate_mode = self->vbr_preset;
511 if ((err = aacEncoder_SetParam (self->enc, AACENC_BITRATEMODE,
512 bitrate_mode)) != AACENC_OK) {
513 GST_ERROR_OBJECT (self, "Unable to set bitrate mode %d: %d",
518 if (self->peak_bitrate) {
519 if ((err = aacEncoder_SetParam (self->enc, AACENC_PEAK_BITRATE,
520 self->peak_bitrate)) != AACENC_OK) {
521 GST_ERROR_OBJECT (self, "Unable to set peak bitrate %d: %d",
522 self->peak_bitrate, err);
526 GST_INFO_OBJECT (self, "Setting peak bitrate to %d", self->peak_bitrate);
529 if (self->afterburner) {
531 aacEncoder_SetParam (self->enc, AACENC_AFTERBURNER,
533 GST_ERROR_OBJECT (self, "Could not enable afterburner: %d", err);
537 GST_INFO_OBJECT (self, "Afterburner enabled");
539 if ((err = aacEncEncode (self->enc, NULL, NULL, NULL, NULL)) != AACENC_OK) {
540 GST_ERROR_OBJECT (self, "Unable to initialize encoder: %d", err);
544 if ((err = aacEncInfo (self->enc, &enc_info)) != AACENC_OK) {
545 GST_ERROR_OBJECT (self, "Unable to get encoder info: %d", err);
549 gst_audio_encoder_set_frame_max (enc, 1);
550 gst_audio_encoder_set_frame_samples_min (enc, enc_info.frameLength);
551 gst_audio_encoder_set_frame_samples_max (enc, enc_info.frameLength);
552 gst_audio_encoder_set_hard_min (enc, FALSE);
553 self->outbuf_size = enc_info.maxOutBufBytes;
554 self->samples_per_frame = enc_info.frameLength;
556 src_caps = gst_caps_new_simple ("audio/mpeg",
557 "mpegversion", G_TYPE_INT, mpegversion,
558 "channels", G_TYPE_INT, GST_AUDIO_INFO_CHANNELS (info),
559 "framed", G_TYPE_BOOLEAN, TRUE,
560 "rate", G_TYPE_INT, GST_AUDIO_INFO_RATE (info), NULL);
564 GstBuffer *codec_data =
565 gst_buffer_new_memdup (enc_info.confBuf, enc_info.confSize);
566 gst_caps_set_simple (src_caps, "codec_data", GST_TYPE_BUFFER, codec_data,
567 "stream-format", G_TYPE_STRING, "raw", NULL);
568 gst_buffer_unref (codec_data);
569 } else if (transmux == 1) {
570 gst_caps_set_simple (src_caps, "stream-format", G_TYPE_STRING, "adif",
572 } else if (transmux == 2) {
573 gst_caps_set_simple (src_caps, "stream-format", G_TYPE_STRING, "adts",
576 g_assert_not_reached ();
579 gst_codec_utils_aac_caps_set_level_and_profile (src_caps, enc_info.confBuf,
582 /* The above only parses the "base" profile, which is always going to be LC.
583 * Set actual profile. */
584 gst_caps_set_simple (src_caps, "profile", G_TYPE_STRING, profile_str, NULL);
586 /* An AAC-LC-only decoder will not decode a stream that uses explicit
587 * hierarchical signaling */
588 if (signaling_mode == 2 && aot != AOT_AAC_LC) {
589 gst_structure_remove_field (gst_caps_get_structure (src_caps, 0),
593 ret = gst_audio_encoder_set_output_format (enc, src_caps);
594 gst_caps_unref (src_caps);
600 gst_fdkaacenc_handle_frame (GstAudioEncoder * enc, GstBuffer * inbuf)
602 GstFdkAacEnc *self = GST_FDKAACENC (enc);
603 GstFlowReturn ret = GST_FLOW_OK;
605 GstMapInfo imap, omap;
607 AACENC_BufDesc in_desc = { 0 };
608 AACENC_BufDesc out_desc = { 0 };
609 AACENC_InArgs in_args = { 0 };
610 AACENC_OutArgs out_args = { 0 };
611 gint in_id = IN_AUDIO_DATA, out_id = OUT_BITSTREAM_DATA;
612 gint in_sizes, out_sizes;
613 gint in_el_sizes, out_el_sizes;
616 info = gst_audio_encoder_get_audio_info (enc);
619 if (self->need_reorder) {
620 inbuf = gst_buffer_copy (inbuf);
621 gst_buffer_map (inbuf, &imap, GST_MAP_READWRITE);
622 gst_audio_reorder_channels (imap.data, imap.size,
623 GST_AUDIO_INFO_FORMAT (info), GST_AUDIO_INFO_CHANNELS (info),
624 &GST_AUDIO_INFO_POSITION (info, 0), self->aac_positions);
626 gst_buffer_map (inbuf, &imap, GST_MAP_READ);
629 in_args.numInSamples = imap.size / GST_AUDIO_INFO_BPS (info);
631 in_sizes = imap.size;
632 in_el_sizes = GST_AUDIO_INFO_BPS (info);
635 in_args.numInSamples = -1;
641 /* We unset is_drained even if there's no inbuf. Basically this is a
642 * workaround for aacEncEncode always producing 1024 bytes even without any
643 * input, thus messing up with the base class counting */
644 self->is_drained = FALSE;
646 in_desc.bufferIdentifiers = &in_id;
647 in_desc.bufs = (void *) &imap.data;
648 in_desc.bufSizes = &in_sizes;
649 in_desc.bufElSizes = &in_el_sizes;
651 outbuf = gst_audio_encoder_allocate_output_buffer (enc, self->outbuf_size);
653 ret = GST_FLOW_ERROR;
657 gst_buffer_map (outbuf, &omap, GST_MAP_WRITE);
658 out_sizes = omap.size;
660 out_desc.bufferIdentifiers = &out_id;
661 out_desc.numBufs = 1;
662 out_desc.bufs = (void *) &omap.data;
663 out_desc.bufSizes = &out_sizes;
664 out_desc.bufElSizes = &out_el_sizes;
666 err = aacEncEncode (self->enc, &in_desc, &out_desc, &in_args, &out_args);
667 if (err == AACENC_ENCODE_EOF && !inbuf)
669 else if (err != AACENC_OK) {
670 GST_ERROR_OBJECT (self, "Failed to encode data: %d", err);
671 ret = GST_FLOW_ERROR;
676 gst_buffer_unmap (inbuf, &imap);
677 if (self->need_reorder)
678 gst_buffer_unref (inbuf);
682 if (!out_args.numOutBytes)
685 gst_buffer_unmap (outbuf, &omap);
686 gst_buffer_set_size (outbuf, out_args.numOutBytes);
688 ret = gst_audio_encoder_finish_frame (enc, outbuf, self->samples_per_frame);
693 gst_buffer_unmap (outbuf, &omap);
694 gst_buffer_unref (outbuf);
697 gst_buffer_unmap (inbuf, &imap);
698 if (self->need_reorder)
699 gst_buffer_unref (inbuf);
706 gst_fdkaacenc_flush (GstAudioEncoder * enc)
708 GstFdkAacEnc *self = GST_FDKAACENC (enc);
709 GstAudioInfo *info = gst_audio_encoder_get_audio_info (enc);
711 aacEncClose (&self->enc);
713 self->is_drained = TRUE;
715 if (GST_AUDIO_INFO_IS_VALID (info))
716 gst_fdkaacenc_set_format (enc, info);
720 gst_fdkaacenc_init (GstFdkAacEnc * self)
722 self->bitrate = DEFAULT_BITRATE;
724 self->is_drained = TRUE;
725 self->afterburner = FALSE;
726 self->peak_bitrate = DEFAULT_PEAK_BITRATE;
727 self->rate_control = DEFAULT_RATE_CONTROL;
728 self->vbr_preset = DEFAULT_VBR_PRESET;
730 gst_audio_encoder_set_drainable (GST_AUDIO_ENCODER (self), TRUE);
734 gst_fdkaacenc_class_init (GstFdkAacEncClass * klass)
736 GObjectClass *object_class = G_OBJECT_CLASS (klass);
737 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
738 GstAudioEncoderClass *base_class = GST_AUDIO_ENCODER_CLASS (klass);
740 object_class->set_property = GST_DEBUG_FUNCPTR (gst_fdkaacenc_set_property);
741 object_class->get_property = GST_DEBUG_FUNCPTR (gst_fdkaacenc_get_property);
743 base_class->start = GST_DEBUG_FUNCPTR (gst_fdkaacenc_start);
744 base_class->stop = GST_DEBUG_FUNCPTR (gst_fdkaacenc_stop);
745 base_class->set_format = GST_DEBUG_FUNCPTR (gst_fdkaacenc_set_format);
746 base_class->getcaps = GST_DEBUG_FUNCPTR (gst_fdkaacenc_get_caps);
747 base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_fdkaacenc_handle_frame);
748 base_class->flush = GST_DEBUG_FUNCPTR (gst_fdkaacenc_flush);
750 g_object_class_install_property (object_class, PROP_BITRATE,
751 g_param_spec_int ("bitrate",
753 "Target Audio Bitrate. Only applicable if rate-control=cbr. "
754 "(0 = fixed value based on sample rate and channel count)",
755 0, G_MAXINT, DEFAULT_BITRATE,
756 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
759 * GstFdkAacEnc:peak-bitrate:
761 * Peak Bitrate to adjust maximum bits per audio frame.
765 g_object_class_install_property (object_class, PROP_PEAK_BITRATE,
766 g_param_spec_int ("peak-bitrate",
768 "Peak Bitrate to adjust maximum bits per audio frame. "
769 "Bitrate is in bits/second. Only applicable if rate-control=vbr. (0 = Not set)",
770 0, G_MAXINT, DEFAULT_PEAK_BITRATE,
771 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
774 * GstFdkAacEnc:afterburner:
776 * Afterburner - Quality Parameter.
780 g_object_class_install_property (object_class, PROP_AFTERBURNER,
781 g_param_spec_boolean ("afterburner", "Afterburner - Quality Parameter",
782 "Additional quality control parameter. Can cause workload increase.",
783 FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
786 * GstFdkAacEnc:rate-control:
792 g_object_class_install_property (object_class, PROP_RATE_CONTROL,
793 g_param_spec_enum ("rate-control", "Rate Control",
794 "Whether Constant or Variable Bitrate should be used.",
795 GST_FDK_AAC_RATE_CONTROL, DEFAULT_RATE_CONTROL,
796 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
799 * GstFdkAacEnc:vbr-preset:
801 * AAC Variable Bitrate configurations.
805 g_object_class_install_property (object_class, PROP_VBR_PRESET,
806 g_param_spec_enum ("vbr-preset", "Variable Bitrate Preset",
807 "AAC Variable Bitrate configurations. Requires rate-control as vbr.",
808 GST_FDK_AAC_VBR_PRESET, DEFAULT_VBR_PRESET,
809 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
811 gst_element_class_add_static_pad_template (element_class, &sink_template);
812 gst_element_class_add_static_pad_template (element_class, &src_template);
814 gst_element_class_set_static_metadata (element_class, "FDK AAC audio encoder",
815 "Codec/Encoder/Audio/Converter", "FDK AAC audio encoder",
816 "Sebastian Dröge <sebastian@centricular.com>");
818 GST_DEBUG_CATEGORY_INIT (gst_fdkaacenc_debug, "fdkaacenc", 0,
821 gst_type_mark_as_plugin_api (GST_FDK_AAC_VBR_PRESET, 0);
822 gst_type_mark_as_plugin_api (GST_FDK_AAC_RATE_CONTROL, 0);