From 5a1ffa183199333b8f4080c63d784f5d6363ee45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 2 Aug 2008 17:39:13 +0000 Subject: [PATCH 01/31] [MOVED FROM BAD] Add TwoLAME MP2 encoding element, based on the LAME element. Original commit message from CVS: * configure.ac: * ext/Makefile.am: * ext/twolame/Makefile.am: * ext/twolame/gsttwolame.c: (gst_two_lame_mode_get_type), (gst_two_lame_padding_get_type), (gst_two_lame_emphasis_get_type), (gst_two_lame_release_memory), (gst_two_lame_finalize), (gst_two_lame_base_init), (gst_two_lame_class_init), (gst_two_lame_src_setcaps), (gst_two_lame_sink_setcaps), (gst_two_lame_init), (gst_two_lame_set_property), (gst_two_lame_get_property), (gst_two_lame_sink_event), (gst_two_lame_chain), (gst_two_lame_setup), (gst_two_lame_change_state), (gst_two_lame_get_default_settings), (plugin_init): * ext/twolame/gsttwolame.h: Add TwoLAME MP2 encoding element, based on the LAME element. --- ext/twolame/Makefile.am | 8 + ext/twolame/gsttwolame.c | 1013 ++++++++++++++++++++++++++++++++++++++ ext/twolame/gsttwolame.h | 95 ++++ 3 files changed, 1116 insertions(+) create mode 100644 ext/twolame/Makefile.am create mode 100644 ext/twolame/gsttwolame.c create mode 100644 ext/twolame/gsttwolame.h diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am new file mode 100644 index 0000000000..4bc6e712cb --- /dev/null +++ b/ext/twolame/Makefile.am @@ -0,0 +1,8 @@ +plugin_LTLIBRARIES = libgsttwolame.la + +libgsttwolame_la_SOURCES = gsttwolame.c +libgsttwolame_la_CFLAGS = $(GST_CFLAGS) $(TWOLAME_CFLAGS) +libgsttwolame_la_LIBADD = $(TWOLAME_LIBS) $(GST_LIBS) +libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) + +noinst_HEADERS = gsttwolame.h diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c new file mode 100644 index 0000000000..53acf20d25 --- /dev/null +++ b/ext/twolame/gsttwolame.c @@ -0,0 +1,1013 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2004> Wim Taymans + * Copyright (C) <2005> Thomas Vander Stichele + * Copyright (C) <2008> Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Based on the lame element. + */ + +/** + * SECTION:element-twolame + * @see_also: mad, lame + * + * This element encodes raw integer audio into an MPEG-1 layer 2 (MP2) stream. + * + * + * Example pipelines + * |[ + * gst-launch -v audiotestsrc wave=sine num-buffers=100 ! audioconvert ! twolame ! filesink location=sine.mp2 + * ]| Encode a test sine signal to MP2. + * |[ + * gst-launch -v alsasrc ! audioconvert ! twolame bitrate=192 ! filesink location=alsasrc.mp2 + * ]| Record from a sound card using ALSA and encode to MP2 + * |[ + * gst-launch -v filesrc location=music.wav ! decodebin ! audioconvert ! audioresample ! twolame bitrate=192 ! id3v2mux ! filesink location=music.mp2 + * ]| Transcode from a .wav file to MP2 (the id3v2mux element is optional) + * |[ + * gst-launch -v cdda://5 ! audioconvert ! twolame bitrate=192 ! filesink location=track5.mp2 + * ]| Encode Audio CD track 5 to MP2 + * + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "string.h" +#include "gsttwolame.h" +#include "gst/gst-i18n-plugin.h" + +GST_DEBUG_CATEGORY_STATIC (debug); +#define GST_CAT_DEFAULT debug + +/* TwoLAME can do MPEG-1, MPEG-2 so it has 6 possible + * sample rates it supports */ +static GstStaticPadTemplate gst_two_lame_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-int, " + "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " + "signed = (boolean) true, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, " + "channels = (int) [ 1, 2 ]") + ); + +static GstStaticPadTemplate gst_two_lame_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/mpeg, " + "mpegversion = (int) 1, " + "layer = (int) 2, " + "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, " + "channels = (int) [ 1, 2 ]") + ); + +static struct +{ + gint mode; + gint psymodel; + gint bitrate; + gint padding; + gboolean energy_level_extension; + gint emphasis; + gboolean error_protection; + gboolean copyright; + gboolean original; + gboolean vbr; + gfloat vbr_level; + gfloat ath_level; + gint vbr_max_bitrate; + gboolean quick_mode; + gint quick_mode_count; +} gst_two_lame_default_settings; + +/********** Define useful types for non-programmatic interfaces **********/ +#define GST_TYPE_TWO_LAME_MODE (gst_two_lame_mode_get_type()) +static GType +gst_two_lame_mode_get_type (void) +{ + static GType two_lame_mode_type = 0; + static GEnumValue two_lame_modes[] = { + {TWOLAME_AUTO_MODE, "Auto", "auto"}, + {TWOLAME_STEREO, "Stereo", "stereo"}, + {TWOLAME_JOINT_STEREO, "Joint Stereo", "joint"}, + {TWOLAME_DUAL_CHANNEL, "Dual Channel", "dual"}, + {TWOLAME_MONO, "Mono", "mono"}, + {0, NULL, NULL} + }; + + if (!two_lame_mode_type) { + two_lame_mode_type = + g_enum_register_static ("GstTwoLameMode", two_lame_modes); + } + return two_lame_mode_type; +} + +#define GST_TYPE_TWO_LAME_PADDING (gst_two_lame_padding_get_type()) +static GType +gst_two_lame_padding_get_type (void) +{ + static GType two_lame_padding_type = 0; + static GEnumValue two_lame_padding[] = { + {TWOLAME_PAD_NO, "No Padding", "never"}, + {TWOLAME_PAD_ALL, "Always Pad", "always"}, + {0, NULL, NULL} + }; + + if (!two_lame_padding_type) { + two_lame_padding_type = + g_enum_register_static ("GstTwoLamePadding", two_lame_padding); + } + return two_lame_padding_type; +} + +#define GST_TYPE_TWO_LAME_EMPHASIS (gst_two_lame_emphasis_get_type()) +static GType +gst_two_lame_emphasis_get_type (void) +{ + static GType two_lame_emphasis_type = 0; + static GEnumValue two_lame_emphasis[] = { + {TWOLAME_EMPHASIS_N, "No emphasis", "none"}, + {TWOLAME_EMPHASIS_5, "50/15 ms", "5"}, + {TWOLAME_EMPHASIS_C, "CCIT J.17", "ccit"}, + {0, NULL, NULL} + }; + + if (!two_lame_emphasis_type) { + two_lame_emphasis_type = + g_enum_register_static ("GstTwoLameEmphasis", two_lame_emphasis); + } + + return two_lame_emphasis_type; +} + +/********** Standard stuff for signals and arguments **********/ + +enum +{ + ARG_0, + ARG_MODE, + ARG_PSYMODEL, + ARG_BITRATE, + ARG_PADDING, + ARG_ENERGY_LEVEL_EXTENSION, + ARG_EMPHASIS, + ARG_ERROR_PROTECTION, + ARG_COPYRIGHT, + ARG_ORIGINAL, + ARG_VBR, + ARG_VBR_LEVEL, + ARG_ATH_LEVEL, + ARG_VBR_MAX_BITRATE, + ARG_QUICK_MODE, + ARG_QUICK_MODE_COUNT +}; + +static void gst_two_lame_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_two_lame_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static gboolean gst_two_lame_sink_event (GstPad * pad, GstEvent * event); +static GstFlowReturn gst_two_lame_chain (GstPad * pad, GstBuffer * buf); +static gboolean gst_two_lame_setup (GstTwoLame * twolame); +static GstStateChangeReturn gst_two_lame_change_state (GstElement * element, + GstStateChange transition); + + +GST_BOILERPLATE (GstTwoLame, gst_two_lame, GstElement, GST_TYPE_ELEMENT); + +static void +gst_two_lame_release_memory (GstTwoLame * twolame) +{ + if (twolame->glopts) { + twolame_close (&twolame->glopts); + twolame->glopts = NULL; + } +} + +static void +gst_two_lame_finalize (GObject * obj) +{ + gst_two_lame_release_memory (GST_TWO_LAME (obj)); + + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + +static void +gst_two_lame_base_init (gpointer g_class) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_two_lame_src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&gst_two_lame_sink_template)); + gst_element_class_set_details_simple (element_class, "TwoLAME mp2 encoder", + "Codec/Encoder/Audio", + "High-quality free MP2 encoder", + "Sebastian Dröge "); +} + +static void +gst_two_lame_class_init (GstTwoLameClass * klass) +{ + GObjectClass *gobject_class; + GstElementClass *gstelement_class; + + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + + parent_class = g_type_class_peek_parent (klass); + + gobject_class->set_property = gst_two_lame_set_property; + gobject_class->get_property = gst_two_lame_get_property; + gobject_class->finalize = gst_two_lame_finalize; + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE, + g_param_spec_enum ("mode", "Mode", "Encoding mode", + GST_TYPE_TWO_LAME_MODE, gst_two_lame_default_settings.mode, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PSYMODEL, + g_param_spec_int ("psymodel", "Psychoacoustic Model", + "Psychoacoustic model used to encode the audio", + -1, 4, gst_two_lame_default_settings.psymodel, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE, + g_param_spec_int ("bitrate", "Bitrate (kb/s)", + "Bitrate in kbit/sec (8, 16, 24, 32, 40, 48, 56, 64, 80, 96, " + "112, 128, 144, 160, 192, 224, 256, 320, 384)", + 8, 384, gst_two_lame_default_settings.bitrate, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PADDING, + g_param_spec_enum ("padding", "Padding", "Padding type", + GST_TYPE_TWO_LAME_PADDING, gst_two_lame_default_settings.padding, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_ENERGY_LEVEL_EXTENSION, + g_param_spec_boolean ("energy-level-extension", "Energy Level Extension", + "Write peak PCM level to each frame", + gst_two_lame_default_settings.energy_level_extension, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EMPHASIS, + g_param_spec_enum ("emphasis", "Emphasis", + "Pre-emphasis to apply to the decoded audio", + GST_TYPE_TWO_LAME_EMPHASIS, gst_two_lame_default_settings.emphasis, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_PROTECTION, + g_param_spec_boolean ("error-protection", "Error protection", + "Adds checksum to every frame", + gst_two_lame_default_settings.error_protection, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COPYRIGHT, + g_param_spec_boolean ("copyright", "Copyright", "Mark as copyright", + gst_two_lame_default_settings.copyright, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ORIGINAL, + g_param_spec_boolean ("original", "Original", "Mark as original", + gst_two_lame_default_settings.original, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR, + g_param_spec_boolean ("vbr", "VBR", "Enable variable bitrate mode", + gst_two_lame_default_settings.vbr, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_LEVEL, + g_param_spec_float ("vbr-level", "VBR Level", "VBR Level", + -10.0, 10.0, gst_two_lame_default_settings.vbr_level, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_LEVEL, + g_param_spec_float ("ath-level", "ATH Level", "ATH Level in dB", + -G_MAXFLOAT, G_MAXFLOAT, gst_two_lame_default_settings.ath_level, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MAX_BITRATE, + g_param_spec_int ("vbr-max-bitrate", "VBR max bitrate", + "Specify maximum VBR bitrate (0=off, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, " + "112, 128, 144, 160, 192, 224, 256, 320, 384)", + 0, 384, gst_two_lame_default_settings.vbr_max_bitrate, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUICK_MODE, + g_param_spec_boolean ("quick-mode", "Quick mode", + "Calculate Psymodel every frames", + gst_two_lame_default_settings.quick_mode, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUICK_MODE_COUNT, + g_param_spec_int ("quick-mode-count", "Quick mode count", + "Calculate Psymodel every n frames", + 0, G_MAXINT, gst_two_lame_default_settings.quick_mode_count, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_two_lame_change_state); +} + +static gboolean +gst_two_lame_src_setcaps (GstPad * pad, GstCaps * caps) +{ + GST_DEBUG_OBJECT (pad, "caps: %" GST_PTR_FORMAT, caps); + return TRUE; +} + +static gboolean +gst_two_lame_sink_setcaps (GstPad * pad, GstCaps * caps) +{ + GstTwoLame *twolame; + gint out_samplerate; + gint version; + GstStructure *structure; + GstCaps *othercaps; + + twolame = GST_TWO_LAME (GST_PAD_PARENT (pad)); + structure = gst_caps_get_structure (caps, 0); + + if (!gst_structure_get_int (structure, "rate", &twolame->samplerate)) + goto no_rate; + if (!gst_structure_get_int (structure, "channels", &twolame->num_channels)) + goto no_channels; + + GST_DEBUG_OBJECT (twolame, "setting up twolame"); + if (!gst_two_lame_setup (twolame)) + goto setup_failed; + + out_samplerate = twolame_get_out_samplerate (twolame->glopts); + if (out_samplerate == 0) + goto zero_output_rate; + + if (out_samplerate != twolame->samplerate) { + GST_WARNING_OBJECT (twolame, + "output samplerate %d is different from incoming samplerate %d", + out_samplerate, twolame->samplerate); + } + + version = twolame_get_version (twolame->glopts); + if (version == TWOLAME_MPEG2) + version = 2; + else + version = 1; + + othercaps = + gst_caps_new_simple ("audio/mpeg", + "mpegversion", G_TYPE_INT, 1, + "mpegaudioversion", G_TYPE_INT, version, + "layer", G_TYPE_INT, 2, + "channels", G_TYPE_INT, + twolame->mode == TWOLAME_MONO ? 1 : twolame->num_channels, "rate", + G_TYPE_INT, out_samplerate, NULL); + + /* and use these caps */ + gst_pad_set_caps (twolame->srcpad, othercaps); + gst_caps_unref (othercaps); + + return TRUE; + +no_rate: + { + GST_ERROR_OBJECT (twolame, "input caps have no sample rate field"); + return FALSE; + } +no_channels: + { + GST_ERROR_OBJECT (twolame, "input caps have no channels field"); + return FALSE; + } +zero_output_rate: + { + GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS, (NULL), + ("TwoLAME decided on a zero sample rate")); + return FALSE; + } +setup_failed: + { + GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS, + (_("Failed to configure TwoLAME encoder. Check your encoding parameters.")), (NULL)); + return FALSE; + } +} + +static void +gst_two_lame_init (GstTwoLame * twolame, GstTwoLameClass * klass) +{ + GST_DEBUG_OBJECT (twolame, "starting initialization"); + + twolame->sinkpad = + gst_pad_new_from_static_template (&gst_two_lame_sink_template, "sink"); + gst_pad_set_event_function (twolame->sinkpad, + GST_DEBUG_FUNCPTR (gst_two_lame_sink_event)); + gst_pad_set_chain_function (twolame->sinkpad, + GST_DEBUG_FUNCPTR (gst_two_lame_chain)); + gst_pad_set_setcaps_function (twolame->sinkpad, + GST_DEBUG_FUNCPTR (gst_two_lame_sink_setcaps)); + gst_element_add_pad (GST_ELEMENT (twolame), twolame->sinkpad); + + twolame->srcpad = + gst_pad_new_from_static_template (&gst_two_lame_src_template, "src"); + gst_pad_set_setcaps_function (twolame->srcpad, + GST_DEBUG_FUNCPTR (gst_two_lame_src_setcaps)); + gst_element_add_pad (GST_ELEMENT (twolame), twolame->srcpad); + + twolame->samplerate = 44100; + twolame->num_channels = 2; + twolame->setup = FALSE; + + twolame->mode = gst_two_lame_default_settings.mode; + twolame->psymodel = gst_two_lame_default_settings.psymodel; + twolame->bitrate = gst_two_lame_default_settings.bitrate; + twolame->padding = gst_two_lame_default_settings.padding; + twolame->energy_level_extension = + gst_two_lame_default_settings.energy_level_extension; + twolame->emphasis = gst_two_lame_default_settings.emphasis; + twolame->error_protection = gst_two_lame_default_settings.error_protection; + twolame->copyright = gst_two_lame_default_settings.copyright; + twolame->original = gst_two_lame_default_settings.original; + twolame->vbr = gst_two_lame_default_settings.vbr; + twolame->vbr_level = gst_two_lame_default_settings.vbr_level; + twolame->ath_level = gst_two_lame_default_settings.ath_level; + twolame->vbr_max_bitrate = gst_two_lame_default_settings.vbr_max_bitrate; + twolame->quick_mode = gst_two_lame_default_settings.quick_mode; + twolame->quick_mode_count = gst_two_lame_default_settings.quick_mode_count; + + GST_DEBUG_OBJECT (twolame, "done initializing"); +} + +/* three underscores for ___rate is really really really + * private as opposed to one underscore */ +/* call this MACRO outside of the NULL state so that we have a higher chance + * of actually having a pipeline and bus to get the message through */ + +#define CHECK_AND_FIXUP_BITRATE(obj,param,rate) \ +G_STMT_START { \ + gint ___rate = rate; \ + gint maxrate = 320; \ + gint multiplier = 64; \ + if (rate <= 64) { \ + maxrate = 64; multiplier = 8; \ + if ((rate % 8) != 0) ___rate = GST_ROUND_UP_8 (rate); \ + } else if (rate <= 144) { \ + maxrate = 144; multiplier = 16; \ + if ((rate % 16) != 0) ___rate = GST_ROUND_UP_16 (rate); \ + } else if (rate <= 256) { \ + maxrate = 256; multiplier = 32; \ + if ((rate % 32) != 0) ___rate = GST_ROUND_UP_32 (rate); \ + } else if (rate <= 384) { \ + maxrate = 384; multiplier = 64; \ + if ((rate % 64) != 0) ___rate = GST_ROUND_UP_64 (rate); \ + } \ + if (___rate != rate) { \ + GST_ELEMENT_WARNING (obj, LIBRARY, SETTINGS, \ + (_("The requested bitrate %d kbit/s for property '%s' " \ + "is not allowed. " \ + "The bitrate was changed to %d kbit/s."), rate, \ + param, ___rate), \ + ("A bitrate below %d should be a multiple of %d.", \ + maxrate, multiplier)); \ + rate = ___rate; \ + } \ +} G_STMT_END + +static void +gst_two_lame_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstTwoLame *twolame = GST_TWO_LAME (object); + + switch (prop_id) { + case ARG_MODE: + twolame->mode = g_value_get_enum (value); + break; + case ARG_PSYMODEL: + twolame->psymodel = g_value_get_int (value); + break; + case ARG_BITRATE: + twolame->bitrate = g_value_get_int (value); + break; + case ARG_PADDING: + twolame->padding = g_value_get_enum (value); + break; + case ARG_ENERGY_LEVEL_EXTENSION: + twolame->energy_level_extension = g_value_get_boolean (value); + break; + case ARG_EMPHASIS: + twolame->emphasis = g_value_get_enum (value); + break; + case ARG_ERROR_PROTECTION: + twolame->error_protection = g_value_get_boolean (value); + break; + case ARG_COPYRIGHT: + twolame->copyright = g_value_get_boolean (value); + break; + case ARG_ORIGINAL: + twolame->original = g_value_get_boolean (value); + break; + case ARG_VBR: + twolame->vbr = g_value_get_boolean (value); + break; + case ARG_VBR_LEVEL: + twolame->vbr_level = g_value_get_float (value); + break; + case ARG_ATH_LEVEL: + twolame->ath_level = g_value_get_float (value); + break; + case ARG_VBR_MAX_BITRATE: + twolame->vbr_max_bitrate = g_value_get_int (value); + break; + case ARG_QUICK_MODE: + twolame->quick_mode = g_value_get_boolean (value); + break; + case ARG_QUICK_MODE_COUNT: + twolame->quick_mode_count = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_two_lame_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ + GstTwoLame *twolame = GST_TWO_LAME (object); + + switch (prop_id) { + case ARG_MODE: + g_value_set_enum (value, twolame->mode); + break; + case ARG_PSYMODEL: + g_value_set_int (value, twolame->psymodel); + break; + case ARG_BITRATE: + g_value_set_int (value, twolame->bitrate); + break; + case ARG_PADDING: + g_value_set_enum (value, twolame->padding); + break; + case ARG_ENERGY_LEVEL_EXTENSION: + g_value_set_boolean (value, twolame->energy_level_extension); + break; + case ARG_EMPHASIS: + g_value_set_enum (value, twolame->emphasis); + break; + case ARG_ERROR_PROTECTION: + g_value_set_boolean (value, twolame->error_protection); + break; + case ARG_COPYRIGHT: + g_value_set_boolean (value, twolame->copyright); + break; + case ARG_ORIGINAL: + g_value_set_boolean (value, twolame->original); + break; + case ARG_VBR: + g_value_set_boolean (value, twolame->vbr); + break; + case ARG_VBR_LEVEL: + g_value_set_float (value, twolame->vbr_level); + break; + case ARG_ATH_LEVEL: + g_value_set_float (value, twolame->ath_level); + break; + case ARG_VBR_MAX_BITRATE: + g_value_set_int (value, twolame->vbr_max_bitrate); + break; + case ARG_QUICK_MODE: + g_value_set_boolean (value, twolame->quick_mode); + break; + case ARG_QUICK_MODE_COUNT: + g_value_set_int (value, twolame->quick_mode_count); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static gboolean +gst_two_lame_sink_event (GstPad * pad, GstEvent * event) +{ + gboolean ret; + GstTwoLame *twolame; + + twolame = GST_TWO_LAME (gst_pad_get_parent (pad)); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_EOS:{ + GST_DEBUG_OBJECT (twolame, "handling EOS event"); + + if (twolame->glopts != NULL) { + GstBuffer *buf; + gint size; + + buf = gst_buffer_new_and_alloc (16384); + size = + twolame_encode_flush (twolame->glopts, GST_BUFFER_DATA (buf), + 16394); + + if (size > 0 && twolame->last_flow == GST_FLOW_OK) { + gint64 duration; + + duration = gst_util_uint64_scale (size, 8 * GST_SECOND, + 1000 * twolame->bitrate); + + if (twolame->last_ts == GST_CLOCK_TIME_NONE) { + twolame->last_ts = twolame->eos_ts; + twolame->last_duration = duration; + } else { + twolame->last_duration += duration; + } + + GST_BUFFER_TIMESTAMP (buf) = twolame->last_ts; + GST_BUFFER_DURATION (buf) = twolame->last_duration; + twolame->last_ts = GST_CLOCK_TIME_NONE; + GST_BUFFER_SIZE (buf) = size; + GST_DEBUG_OBJECT (twolame, "pushing final packet of %u bytes", size); + gst_buffer_set_caps (buf, GST_PAD_CAPS (twolame->srcpad)); + gst_pad_push (twolame->srcpad, buf); + } else { + GST_DEBUG_OBJECT (twolame, "no final packet (size=%d, last_flow=%s)", + size, gst_flow_get_name (twolame->last_flow)); + gst_buffer_unref (buf); + } + } + + ret = gst_pad_event_default (pad, event); + break; + } + case GST_EVENT_FLUSH_START: + GST_DEBUG_OBJECT (twolame, "handling FLUSH start event"); + /* forward event */ + ret = gst_pad_push_event (twolame->srcpad, event); + break; + case GST_EVENT_FLUSH_STOP: + { + guchar *mp3_data = NULL; + gint mp3_buffer_size, mp3_size = 0; + + GST_DEBUG_OBJECT (twolame, "handling FLUSH stop event"); + + /* clear buffers */ + mp3_buffer_size = 16384; + mp3_data = g_malloc (mp3_buffer_size); + mp3_size = + twolame_encode_flush (twolame->glopts, mp3_data, mp3_buffer_size); + + ret = gst_pad_push_event (twolame->srcpad, event); + + g_free (mp3_data); + break; + } + default: + ret = gst_pad_event_default (pad, event); + break; + } + gst_object_unref (twolame); + + return ret; +} + +static GstFlowReturn +gst_two_lame_chain (GstPad * pad, GstBuffer * buf) +{ + GstTwoLame *twolame; + guchar *mp3_data; + gint mp3_buffer_size, mp3_size; + gint64 duration; + GstFlowReturn result; + gint num_samples; + guint8 *data; + guint size; + + twolame = GST_TWO_LAME (GST_PAD_PARENT (pad)); + + GST_LOG_OBJECT (twolame, "entered chain"); + + if (!twolame->setup) + goto not_setup; + + data = GST_BUFFER_DATA (buf); + size = GST_BUFFER_SIZE (buf); + + num_samples = size / 2; + + /* allocate space for output */ + mp3_buffer_size = 1.25 * num_samples + 16384; + mp3_data = g_malloc (mp3_buffer_size); + + if (twolame->num_channels == 1) { + mp3_size = twolame_encode_buffer (twolame->glopts, + (short int *) data, + (short int *) data, num_samples, mp3_data, mp3_buffer_size); + } else { + mp3_size = twolame_encode_buffer_interleaved (twolame->glopts, + (short int *) data, + num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); + } + + GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3", + size, mp3_size); + + duration = gst_util_uint64_scale_int (size, GST_SECOND, + 2 * twolame->samplerate * twolame->num_channels); + + if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE && + GST_BUFFER_DURATION (buf) != duration) { + GST_DEBUG_OBJECT (twolame, "incoming buffer had incorrect duration %" + GST_TIME_FORMAT ", outgoing buffer will have correct duration %" + GST_TIME_FORMAT, + GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_TIME_ARGS (duration)); + } + + if (twolame->last_ts == GST_CLOCK_TIME_NONE) { + twolame->last_ts = GST_BUFFER_TIMESTAMP (buf); + twolame->last_offs = GST_BUFFER_OFFSET (buf); + twolame->last_duration = duration; + } else { + twolame->last_duration += duration; + } + + gst_buffer_unref (buf); + + if (mp3_size < 0) { + g_warning ("error %d", mp3_size); + } + + if (mp3_size > 0) { + GstBuffer *outbuf; + + outbuf = gst_buffer_new (); + GST_BUFFER_DATA (outbuf) = mp3_data; + GST_BUFFER_MALLOCDATA (outbuf) = mp3_data; + GST_BUFFER_SIZE (outbuf) = mp3_size; + GST_BUFFER_TIMESTAMP (outbuf) = twolame->last_ts; + GST_BUFFER_OFFSET (outbuf) = twolame->last_offs; + GST_BUFFER_DURATION (outbuf) = twolame->last_duration; + gst_buffer_set_caps (outbuf, GST_PAD_CAPS (twolame->srcpad)); + + result = gst_pad_push (twolame->srcpad, outbuf); + twolame->last_flow = result; + if (result != GST_FLOW_OK) { + GST_DEBUG_OBJECT (twolame, "flow return: %s", gst_flow_get_name (result)); + } + + if (GST_CLOCK_TIME_IS_VALID (twolame->last_ts)) + twolame->eos_ts = twolame->last_ts + twolame->last_duration; + else + twolame->eos_ts = GST_CLOCK_TIME_NONE; + twolame->last_ts = GST_CLOCK_TIME_NONE; + } else { + g_free (mp3_data); + result = GST_FLOW_OK; + } + + return result; + + /* ERRORS */ +not_setup: + { + gst_buffer_unref (buf); + GST_ELEMENT_ERROR (twolame, CORE, NEGOTIATION, (NULL), + ("encoder not initialized (input is not audio?)")); + return GST_FLOW_ERROR; + } +} + +/* set up the encoder state */ +static gboolean +gst_two_lame_setup (GstTwoLame * twolame) +{ + +#define CHECK_ERROR(command) G_STMT_START {\ + if ((command) < 0) { \ + GST_ERROR_OBJECT (twolame, "setup failed: " G_STRINGIFY (command)); \ + return FALSE; \ + } \ +}G_STMT_END + + int retval; + GstCaps *allowed_caps; + + GST_DEBUG_OBJECT (twolame, "starting setup"); + + /* check if we're already setup; if we are, we might want to check + * if this initialization is compatible with the previous one */ + /* FIXME: do this */ + if (twolame->setup) { + GST_WARNING_OBJECT (twolame, "already setup"); + twolame->setup = FALSE; + } + + twolame->glopts = twolame_init (); + + if (twolame->glopts == NULL) + return FALSE; + + /* copy the parameters over */ + twolame_set_in_samplerate (twolame->glopts, twolame->samplerate); + + /* let twolame choose default samplerate unless outgoing sample rate is fixed */ + allowed_caps = gst_pad_get_allowed_caps (twolame->srcpad); + + if (allowed_caps != NULL) { + GstStructure *structure; + gint samplerate; + + structure = gst_caps_get_structure (allowed_caps, 0); + + if (gst_structure_get_int (structure, "rate", &samplerate)) { + GST_DEBUG_OBJECT (twolame, + "Setting sample rate to %d as fixed in src caps", samplerate); + twolame_set_out_samplerate (twolame->glopts, samplerate); + } else { + GST_DEBUG_OBJECT (twolame, "Letting twolame choose sample rate"); + twolame_set_out_samplerate (twolame->glopts, 0); + } + gst_caps_unref (allowed_caps); + allowed_caps = NULL; + } else { + GST_DEBUG_OBJECT (twolame, + "No peer yet, letting twolame choose sample rate"); + twolame_set_out_samplerate (twolame->glopts, 0); + } + + /* force mono encoding if we only have one channel */ + if (twolame->num_channels == 1) + twolame->mode = 3; + + /* Fix bitrates and MPEG version */ + + CHECK_ERROR (twolame_set_num_channels (twolame->glopts, + twolame->num_channels)); + + CHECK_ERROR (twolame_set_mode (twolame->glopts, twolame->mode)); + CHECK_ERROR (twolame_set_psymodel (twolame->glopts, twolame->psymodel)); + CHECK_AND_FIXUP_BITRATE (twolame, "bitrate", twolame->bitrate); + CHECK_ERROR (twolame_set_bitrate (twolame->glopts, twolame->bitrate)); + CHECK_ERROR (twolame_set_padding (twolame->glopts, twolame->padding)); + CHECK_ERROR (twolame_set_energy_levels (twolame->glopts, + twolame->energy_level_extension)); + CHECK_ERROR (twolame_set_emphasis (twolame->glopts, twolame->emphasis)); + CHECK_ERROR (twolame_set_error_protection (twolame->glopts, + twolame->error_protection)); + CHECK_ERROR (twolame_set_copyright (twolame->glopts, twolame->copyright)); + CHECK_ERROR (twolame_set_original (twolame->glopts, twolame->original)); + CHECK_ERROR (twolame_set_VBR (twolame->glopts, twolame->vbr)); + CHECK_ERROR (twolame_set_VBR_level (twolame->glopts, twolame->vbr_level)); + CHECK_ERROR (twolame_set_ATH_level (twolame->glopts, twolame->ath_level)); + CHECK_AND_FIXUP_BITRATE (twolame, "vbr-max-bitrate", + twolame->vbr_max_bitrate); + CHECK_ERROR (twolame_set_VBR_max_bitrate_kbps (twolame->glopts, + twolame->vbr_max_bitrate)); + CHECK_ERROR (twolame_set_quick_mode (twolame->glopts, twolame->quick_mode)); + CHECK_ERROR (twolame_set_quick_count (twolame->glopts, + twolame->quick_mode_count)); + + /* initialize the twolame encoder */ + if ((retval = twolame_init_params (twolame->glopts)) >= 0) { + twolame->setup = TRUE; + /* FIXME: it would be nice to print out the mode here */ + GST_INFO ("twolame encoder setup (%d kbit/s, %d Hz, %d channels)", + twolame->bitrate, twolame->samplerate, twolame->num_channels); + } else { + GST_ERROR_OBJECT (twolame, "twolame_init_params returned %d", retval); + } + + GST_DEBUG_OBJECT (twolame, "done with setup"); + + return twolame->setup; +#undef CHECK_ERROR +} + +static GstStateChangeReturn +gst_two_lame_change_state (GstElement * element, GstStateChange transition) +{ + GstTwoLame *twolame; + GstStateChangeReturn result; + + twolame = GST_TWO_LAME (element); + + switch (transition) { + case GST_STATE_CHANGE_READY_TO_PAUSED: + twolame->last_flow = GST_FLOW_OK; + twolame->last_ts = GST_CLOCK_TIME_NONE; + twolame->eos_ts = GST_CLOCK_TIME_NONE; + break; + default: + break; + } + + result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + + switch (transition) { + case GST_STATE_CHANGE_READY_TO_NULL: + gst_two_lame_release_memory (twolame); + break; + default: + break; + } + + return result; +} + +static gboolean +gst_two_lame_get_default_settings (void) +{ + twolame_options *glopts = NULL; + + glopts = twolame_init (); + if (glopts == NULL) { + GST_ERROR ("Couldn't initialize TwoLAME"); + return FALSE; + } + + twolame_set_num_channels (glopts, 2); + twolame_set_in_samplerate (glopts, 44100); + + if (twolame_init_params (glopts) != 0) { + GST_ERROR ("Couldn't set default parameters"); + return FALSE; + } + + gst_two_lame_default_settings.mode = TWOLAME_JOINT_STEREO; /* twolame_get_mode (glopts); */ + gst_two_lame_default_settings.psymodel = twolame_get_psymodel (glopts); + gst_two_lame_default_settings.bitrate = twolame_get_bitrate (glopts); + gst_two_lame_default_settings.padding = twolame_get_padding (glopts); + gst_two_lame_default_settings.energy_level_extension = + twolame_get_energy_levels (glopts); + gst_two_lame_default_settings.emphasis = twolame_get_emphasis (glopts); + gst_two_lame_default_settings.error_protection = + twolame_get_error_protection (glopts); + gst_two_lame_default_settings.copyright = twolame_get_copyright (glopts); + gst_two_lame_default_settings.original = twolame_get_original (glopts); + gst_two_lame_default_settings.vbr = twolame_get_VBR (glopts); + gst_two_lame_default_settings.vbr_level = twolame_get_VBR_level (glopts); + gst_two_lame_default_settings.ath_level = twolame_get_ATH_level (glopts); + gst_two_lame_default_settings.vbr_max_bitrate = + twolame_get_VBR_max_bitrate_kbps (glopts); + gst_two_lame_default_settings.quick_mode = twolame_get_quick_mode (glopts); + gst_two_lame_default_settings.quick_mode_count = + twolame_get_quick_count (glopts); + + twolame_close (&glopts); + + return TRUE; +} + +static gboolean +plugin_init (GstPlugin * plugin) +{ + GST_DEBUG_CATEGORY_INIT (debug, "twolame", 0, "twolame mp2 encoder"); + + if (!gst_two_lame_get_default_settings ()) + return FALSE; + +#ifdef ENABLE_NLS + GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, + LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); +#endif /* ENABLE_NLS */ + + if (!gst_element_register (plugin, "twolame", GST_RANK_NONE, + GST_TYPE_TWO_LAME)) + return FALSE; + + return TRUE; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "twolame", + "Encode MP2s with TwoLAME", + plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); diff --git a/ext/twolame/gsttwolame.h b/ext/twolame/gsttwolame.h new file mode 100644 index 0000000000..53c003f523 --- /dev/null +++ b/ext/twolame/gsttwolame.h @@ -0,0 +1,95 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2008> Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#ifndef __GST_TWO_LAME_H__ +#define __GST_TWO_LAME_H__ + + +#include + +G_BEGIN_DECLS + +#include + +#define GST_TYPE_TWO_LAME \ + (gst_two_lame_get_type()) +#define GST_TWO_LAME(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TWO_LAME,GstTwoLame)) +#define GST_TWO_LAME_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TWO_LAME,GstTwoLameClass)) +#define GST_IS_TWO_LAME(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TWO_LAME)) +#define GST_IS_TWO_LAME_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TWO_LAME)) + +typedef struct _GstTwoLame GstTwoLame; +typedef struct _GstTwoLameClass GstTwoLameClass; + +/** + * GstTwoLame: + * + * Opaque data structure. + */ +struct _GstTwoLame { + GstElement element; + + /*< private >*/ + GstPad *srcpad, *sinkpad; + + gint samplerate; + gint num_channels; + gboolean setup; + + gint mode; + gint psymodel; + gint bitrate; + gint padding; + gboolean energy_level_extension; + gint emphasis; + gboolean error_protection; + gboolean copyright; + gboolean original; + gboolean vbr; + gfloat vbr_level; + gfloat ath_level; + gint vbr_max_bitrate; + gboolean quick_mode; + gint quick_mode_count; + + /* track this so we don't send a last buffer in eos handler after error */ + GstFlowReturn last_flow; + + twolame_options *glopts; + + /* time tracker */ + guint64 last_ts, last_offs, last_duration, eos_ts; +}; + +struct _GstTwoLameClass { + GstElementClass parent_class; +}; + +GType gst_two_lame_get_type(void); + +G_END_DECLS + + +#endif /* __GST_TWO_LAME_H__ */ From 80fa4b2a85d7428aa7e78f86dfa93b14389ee1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 7 Aug 2008 14:34:03 +0000 Subject: [PATCH 02/31] [MOVED FROM BAD] ext/twolame/gsttwolame.*: Allow raw float samples as input for encoding. Original commit message from CVS: * ext/twolame/gsttwolame.c: (gst_two_lame_sink_setcaps), (gst_two_lame_chain): * ext/twolame/gsttwolame.h: Allow raw float samples as input for encoding. --- ext/twolame/gsttwolame.c | 51 ++++++++++++++++++++++++++++++---------- ext/twolame/gsttwolame.h | 1 + 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 53acf20d25..3700aa35a7 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -62,11 +62,16 @@ GST_DEBUG_CATEGORY_STATIC (debug); /* TwoLAME can do MPEG-1, MPEG-2 so it has 6 possible * sample rates it supports */ static GstStaticPadTemplate gst_two_lame_sink_template = -GST_STATIC_PAD_TEMPLATE ("sink", + GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-int, " - "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " + GST_STATIC_CAPS ("audio/x-raw-float, " + "endianness = (int) BYTE_ORDER, " + "width = (int) 32, " + "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, " + "channels = (int) [ 1, 2 ]; " + "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " "signed = (boolean) true, " "width = (int) 16, " "depth = (int) 16, " @@ -355,6 +360,11 @@ gst_two_lame_sink_setcaps (GstPad * pad, GstCaps * caps) twolame = GST_TWO_LAME (GST_PAD_PARENT (pad)); structure = gst_caps_get_structure (caps, 0); + if (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0) + twolame->float_input = FALSE; + else + twolame->float_input = TRUE; + if (!gst_structure_get_int (structure, "rate", &twolame->samplerate)) goto no_rate; if (!gst_structure_get_int (structure, "channels", &twolame->num_channels)) @@ -720,27 +730,44 @@ gst_two_lame_chain (GstPad * pad, GstBuffer * buf) data = GST_BUFFER_DATA (buf); size = GST_BUFFER_SIZE (buf); - num_samples = size / 2; + if (twolame->float_input) + num_samples = size / 4; + else + num_samples = size / 2; /* allocate space for output */ mp3_buffer_size = 1.25 * num_samples + 16384; mp3_data = g_malloc (mp3_buffer_size); if (twolame->num_channels == 1) { - mp3_size = twolame_encode_buffer (twolame->glopts, - (short int *) data, - (short int *) data, num_samples, mp3_data, mp3_buffer_size); + if (twolame->float_input) + mp3_size = twolame_encode_buffer_float32 (twolame->glopts, + (float *) data, + (float *) data, num_samples, mp3_data, mp3_buffer_size); + else + mp3_size = twolame_encode_buffer (twolame->glopts, + (short int *) data, + (short int *) data, num_samples, mp3_data, mp3_buffer_size); } else { - mp3_size = twolame_encode_buffer_interleaved (twolame->glopts, - (short int *) data, - num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); + if (twolame->float_input) + mp3_size = twolame_encode_buffer_float32_interleaved (twolame->glopts, + (float *) data, + num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); + else + mp3_size = twolame_encode_buffer_interleaved (twolame->glopts, + (short int *) data, + num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); } GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3", size, mp3_size); - duration = gst_util_uint64_scale_int (size, GST_SECOND, - 2 * twolame->samplerate * twolame->num_channels); + if (twolame->float_input) + duration = gst_util_uint64_scale_int (size, GST_SECOND, + 4 * twolame->samplerate * twolame->num_channels); + else + duration = gst_util_uint64_scale_int (size, GST_SECOND, + 2 * twolame->samplerate * twolame->num_channels); if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE && GST_BUFFER_DURATION (buf) != duration) { diff --git a/ext/twolame/gsttwolame.h b/ext/twolame/gsttwolame.h index 53c003f523..d8630c2388 100644 --- a/ext/twolame/gsttwolame.h +++ b/ext/twolame/gsttwolame.h @@ -56,6 +56,7 @@ struct _GstTwoLame { gint samplerate; gint num_channels; + gboolean float_input; gboolean setup; gint mode; From 327ba10120b2d6f85b8bee5a43fda4cfd13c0184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 2 Sep 2008 09:56:44 +0000 Subject: [PATCH 03/31] [MOVED FROM BAD] Enable/fix up translations for these plugins. Original commit message from CVS: * ext/resindvd/plugin.c: (plugin_init): * ext/resindvd/resindvdsrc.c: * ext/twolame/gsttwolame.c: (plugin_init): * gst/aiffparse/aiffparse.c: (plugin_init): Enable/fix up translations for these plugins. * po/LINGUAS: Add 'ca' to LINGUAS. * po/POTFILES.in: * po/POTFILES.skip: Add more files for translation and more files which tools should skip. --- ext/twolame/gsttwolame.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 3700aa35a7..81b865bf01 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -1024,6 +1024,7 @@ plugin_init (GstPlugin * plugin) GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, LOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif /* ENABLE_NLS */ if (!gst_element_register (plugin, "twolame", GST_RANK_NONE, From dda2d09a902f4fa65d0513196879db35ff7ec65c Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Tue, 4 Nov 2008 12:42:30 +0000 Subject: [PATCH 04/31] [MOVED FROM BAD] Don't install static libs for plugins. Fixes #550851 for -bad. Original commit message from CVS: * ext/alsaspdif/Makefile.am: * ext/amrwb/Makefile.am: * ext/apexsink/Makefile.am: * ext/arts/Makefile.am: * ext/artsd/Makefile.am: * ext/audiofile/Makefile.am: * ext/audioresample/Makefile.am: * ext/bz2/Makefile.am: * ext/cdaudio/Makefile.am: * ext/celt/Makefile.am: * ext/dc1394/Makefile.am: * ext/dirac/Makefile.am: * ext/directfb/Makefile.am: * ext/divx/Makefile.am: * ext/dts/Makefile.am: * ext/faac/Makefile.am: * ext/faad/Makefile.am: * ext/gsm/Makefile.am: * ext/hermes/Makefile.am: * ext/ivorbis/Makefile.am: * ext/jack/Makefile.am: * ext/jp2k/Makefile.am: * ext/ladspa/Makefile.am: * ext/lcs/Makefile.am: * ext/libfame/Makefile.am: * ext/libmms/Makefile.am: * ext/metadata/Makefile.am: * ext/mpeg2enc/Makefile.am: * ext/mplex/Makefile.am: * ext/musepack/Makefile.am: * ext/musicbrainz/Makefile.am: * ext/mythtv/Makefile.am: * ext/nas/Makefile.am: * ext/neon/Makefile.am: * ext/ofa/Makefile.am: * ext/polyp/Makefile.am: * ext/resindvd/Makefile.am: * ext/sdl/Makefile.am: * ext/shout/Makefile.am: * ext/snapshot/Makefile.am: * ext/sndfile/Makefile.am: * ext/soundtouch/Makefile.am: * ext/spc/Makefile.am: * ext/swfdec/Makefile.am: * ext/tarkin/Makefile.am: * ext/theora/Makefile.am: * ext/timidity/Makefile.am: * ext/twolame/Makefile.am: * ext/x264/Makefile.am: * ext/xine/Makefile.am: * ext/xvid/Makefile.am: * gst-libs/gst/app/Makefile.am: * gst-libs/gst/dshow/Makefile.am: * gst/aiffparse/Makefile.am: * gst/app/Makefile.am: * gst/audiobuffer/Makefile.am: * gst/bayer/Makefile.am: * gst/cdxaparse/Makefile.am: * gst/chart/Makefile.am: * gst/colorspace/Makefile.am: * gst/dccp/Makefile.am: * gst/deinterlace/Makefile.am: * gst/deinterlace2/Makefile.am: * gst/dvdspu/Makefile.am: * gst/festival/Makefile.am: * gst/filter/Makefile.am: * gst/flacparse/Makefile.am: * gst/flv/Makefile.am: * gst/games/Makefile.am: * gst/h264parse/Makefile.am: * gst/librfb/Makefile.am: * gst/mixmatrix/Makefile.am: * gst/modplug/Makefile.am: * gst/mpeg1sys/Makefile.am: * gst/mpeg4videoparse/Makefile.am: * gst/mpegdemux/Makefile.am: * gst/mpegtsmux/Makefile.am: * gst/mpegvideoparse/Makefile.am: * gst/mve/Makefile.am: * gst/nsf/Makefile.am: * gst/nuvdemux/Makefile.am: * gst/overlay/Makefile.am: * gst/passthrough/Makefile.am: * gst/pcapparse/Makefile.am: * gst/playondemand/Makefile.am: * gst/rawparse/Makefile.am: * gst/real/Makefile.am: * gst/rtjpeg/Makefile.am: * gst/rtpmanager/Makefile.am: * gst/scaletempo/Makefile.am: * gst/sdp/Makefile.am: * gst/selector/Makefile.am: * gst/smooth/Makefile.am: * gst/smoothwave/Makefile.am: * gst/speed/Makefile.am: * gst/speexresample/Makefile.am: * gst/stereo/Makefile.am: * gst/subenc/Makefile.am: * gst/tta/Makefile.am: * gst/vbidec/Makefile.am: * gst/videodrop/Makefile.am: * gst/videosignal/Makefile.am: * gst/virtualdub/Makefile.am: * gst/vmnc/Makefile.am: * gst/y4m/Makefile.am: * sys/acmenc/Makefile.am: * sys/cdrom/Makefile.am: * sys/dshowdecwrapper/Makefile.am: * sys/dshowsrcwrapper/Makefile.am: * sys/dvb/Makefile.am: * sys/dxr3/Makefile.am: * sys/fbdev/Makefile.am: * sys/oss4/Makefile.am: * sys/qcam/Makefile.am: * sys/qtwrapper/Makefile.am: * sys/vcd/Makefile.am: * sys/wininet/Makefile.am: * win32/common/config.h: Don't install static libs for plugins. Fixes #550851 for -bad. --- ext/twolame/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am index 4bc6e712cb..74b6c0e5e4 100644 --- a/ext/twolame/Makefile.am +++ b/ext/twolame/Makefile.am @@ -4,5 +4,6 @@ libgsttwolame_la_SOURCES = gsttwolame.c libgsttwolame_la_CFLAGS = $(GST_CFLAGS) $(TWOLAME_CFLAGS) libgsttwolame_la_LIBADD = $(TWOLAME_LIBS) $(GST_LIBS) libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libgsttwolame_la_LIBTOOLFLAGS = --tag=disable-static noinst_HEADERS = gsttwolame.h From 0886152a41fbb77565bd86e9031321400dd349da Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sun, 19 Apr 2009 14:03:38 +0200 Subject: [PATCH 05/31] twolame: Remove unneeded variable, value assigned was never read. --- ext/twolame/gsttwolame.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 81b865bf01..face347bee 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -684,15 +684,14 @@ gst_two_lame_sink_event (GstPad * pad, GstEvent * event) case GST_EVENT_FLUSH_STOP: { guchar *mp3_data = NULL; - gint mp3_buffer_size, mp3_size = 0; + gint mp3_buffer_size; GST_DEBUG_OBJECT (twolame, "handling FLUSH stop event"); /* clear buffers */ mp3_buffer_size = 16384; mp3_data = g_malloc (mp3_buffer_size); - mp3_size = - twolame_encode_flush (twolame->glopts, mp3_data, mp3_buffer_size); + twolame_encode_flush (twolame->glopts, mp3_data, mp3_buffer_size); ret = gst_pad_push_event (twolame->srcpad, event); From eea2538684bdd9d7b7d4b3d65fad67cf8b81a69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 4 May 2009 12:47:03 +0200 Subject: [PATCH 06/31] twolame: Implement preset interface --- ext/twolame/gsttwolame.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index face347bee..5b3fe7a8a4 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -201,8 +201,21 @@ static gboolean gst_two_lame_setup (GstTwoLame * twolame); static GstStateChangeReturn gst_two_lame_change_state (GstElement * element, GstStateChange transition); +static void +_do_init (GType object_type) +{ + const GInterfaceInfo preset_interface_info = { + NULL, /* interface_init */ + NULL, /* interface_finalize */ + NULL /* interface_data */ + }; -GST_BOILERPLATE (GstTwoLame, gst_two_lame, GstElement, GST_TYPE_ELEMENT); + g_type_add_interface_static (object_type, GST_TYPE_PRESET, + &preset_interface_info); +} + +GST_BOILERPLATE_FULL (GstTwoLame, gst_two_lame, GstElement, GST_TYPE_ELEMENT, + _do_init); static void gst_two_lame_release_memory (GstTwoLame * twolame) From 5769c9dc30f941effad31e43ed332d2d83b58fe5 Mon Sep 17 00:00:00 2001 From: Christian Schaller Date: Thu, 7 May 2009 17:59:52 +0100 Subject: [PATCH 07/31] Add ranks to mp3 encoders --- ext/twolame/gsttwolame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 5b3fe7a8a4..0f8094f217 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -1039,7 +1039,7 @@ plugin_init (GstPlugin * plugin) bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif /* ENABLE_NLS */ - if (!gst_element_register (plugin, "twolame", GST_RANK_NONE, + if (!gst_element_register (plugin, "twolame", GST_RANK_SECONDARY, GST_TYPE_TWO_LAME)) return FALSE; From 442d99387722e8bf24a3abdd92b4c70c73a0e6c6 Mon Sep 17 00:00:00 2001 From: Christian Schaller Date: Fri, 8 May 2009 14:24:47 +0100 Subject: [PATCH 08/31] Switch twolame to primary rank --- ext/twolame/gsttwolame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 0f8094f217..2cabc13a20 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -1039,7 +1039,7 @@ plugin_init (GstPlugin * plugin) bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif /* ENABLE_NLS */ - if (!gst_element_register (plugin, "twolame", GST_RANK_SECONDARY, + if (!gst_element_register (plugin, "twolame", GST_RANK_PRIMARY, GST_TYPE_TWO_LAME)) return FALSE; From 8f58c2cbab5ddc0910632ae86143f1aaf68edbb1 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Mon, 26 Sep 2011 11:56:23 +0200 Subject: [PATCH 09/31] twolame: port to audioencoder --- ext/twolame/Makefile.am | 7 +- ext/twolame/gsttwolame.c | 333 +++++++++++---------------------------- ext/twolame/gsttwolame.h | 14 +- 3 files changed, 97 insertions(+), 257 deletions(-) diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am index 74b6c0e5e4..1b32aae345 100644 --- a/ext/twolame/Makefile.am +++ b/ext/twolame/Makefile.am @@ -1,8 +1,11 @@ plugin_LTLIBRARIES = libgsttwolame.la libgsttwolame_la_SOURCES = gsttwolame.c -libgsttwolame_la_CFLAGS = $(GST_CFLAGS) $(TWOLAME_CFLAGS) -libgsttwolame_la_LIBADD = $(TWOLAME_LIBS) $(GST_LIBS) +libgsttwolame_la_CFLAGS = -DGST_USE_UNSTABLE_API \ + $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(TWOLAME_CFLAGS) +libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ + -lgstaudio-@GST_MAJORMINOR@ -lgstpbutils-@GST_MAJORMINOR@ \ + $(GST_LIBS) $(TWOLAME_LIBS) libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgsttwolame_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 2cabc13a20..3006f1aa27 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -191,31 +191,22 @@ enum ARG_QUICK_MODE_COUNT }; +static gboolean gst_two_lame_start (GstAudioEncoder * enc); +static gboolean gst_two_lame_stop (GstAudioEncoder * enc); +static gboolean gst_two_lame_set_format (GstAudioEncoder * enc, + GstAudioInfo * info); +static GstFlowReturn gst_two_lame_handle_frame (GstAudioEncoder * enc, + GstBuffer * in_buf); +static void gst_two_lame_flush (GstAudioEncoder * enc); + static void gst_two_lame_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_two_lame_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static gboolean gst_two_lame_sink_event (GstPad * pad, GstEvent * event); -static GstFlowReturn gst_two_lame_chain (GstPad * pad, GstBuffer * buf); static gboolean gst_two_lame_setup (GstTwoLame * twolame); -static GstStateChangeReturn gst_two_lame_change_state (GstElement * element, - GstStateChange transition); -static void -_do_init (GType object_type) -{ - const GInterfaceInfo preset_interface_info = { - NULL, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - g_type_add_interface_static (object_type, GST_TYPE_PRESET, - &preset_interface_info); -} - -GST_BOILERPLATE_FULL (GstTwoLame, gst_two_lame, GstElement, GST_TYPE_ELEMENT, - _do_init); +GST_BOILERPLATE (GstTwoLame, gst_two_lame, GstAudioEncoder, + GST_TYPE_AUDIO_ENCODER); static void gst_two_lame_release_memory (GstTwoLame * twolame) @@ -254,9 +245,11 @@ gst_two_lame_class_init (GstTwoLameClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; + GstAudioEncoderClass *gstbase_class; gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; + gstbase_class = (GstAudioEncoderClass *) klass; parent_class = g_type_class_peek_parent (klass); @@ -264,6 +257,12 @@ gst_two_lame_class_init (GstTwoLameClass * klass) gobject_class->get_property = gst_two_lame_get_property; gobject_class->finalize = gst_two_lame_finalize; + gstbase_class->start = GST_DEBUG_FUNCPTR (gst_two_lame_start); + gstbase_class->stop = GST_DEBUG_FUNCPTR (gst_two_lame_stop); + gstbase_class->set_format = GST_DEBUG_FUNCPTR (gst_two_lame_set_format); + gstbase_class->handle_frame = GST_DEBUG_FUNCPTR (gst_two_lame_handle_frame); + gstbase_class->flush = GST_DEBUG_FUNCPTR (gst_two_lame_flush); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE, g_param_spec_enum ("mode", "Mode", "Encoding mode", GST_TYPE_TWO_LAME_MODE, gst_two_lame_default_settings.mode, @@ -349,39 +348,25 @@ gst_two_lame_class_init (GstTwoLameClass * klass) "Calculate Psymodel every n frames", 0, G_MAXINT, gst_two_lame_default_settings.quick_mode_count, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - gstelement_class->change_state = - GST_DEBUG_FUNCPTR (gst_two_lame_change_state); } static gboolean -gst_two_lame_src_setcaps (GstPad * pad, GstCaps * caps) -{ - GST_DEBUG_OBJECT (pad, "caps: %" GST_PTR_FORMAT, caps); - return TRUE; -} - -static gboolean -gst_two_lame_sink_setcaps (GstPad * pad, GstCaps * caps) +gst_two_lame_set_format (GstAudioEncoder * enc, GstAudioInfo * info) { GstTwoLame *twolame; gint out_samplerate; gint version; - GstStructure *structure; GstCaps *othercaps; - twolame = GST_TWO_LAME (GST_PAD_PARENT (pad)); - structure = gst_caps_get_structure (caps, 0); + twolame = GST_TWO_LAME (enc); - if (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0) - twolame->float_input = FALSE; - else - twolame->float_input = TRUE; + /* parameters already parsed for us */ + twolame->samplerate = GST_AUDIO_INFO_RATE (info); + twolame->num_channels = GST_AUDIO_INFO_CHANNELS (info); + twolame->float_input = !GST_AUDIO_INFO_IS_INTEGER (info); - if (!gst_structure_get_int (structure, "rate", &twolame->samplerate)) - goto no_rate; - if (!gst_structure_get_int (structure, "channels", &twolame->num_channels)) - goto no_channels; + /* but we might be asked to reconfigure, so reset */ + gst_two_lame_release_memory (twolame); GST_DEBUG_OBJECT (twolame, "setting up twolame"); if (!gst_two_lame_setup (twolame)) @@ -413,21 +398,14 @@ gst_two_lame_sink_setcaps (GstPad * pad, GstCaps * caps) G_TYPE_INT, out_samplerate, NULL); /* and use these caps */ - gst_pad_set_caps (twolame->srcpad, othercaps); + gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (twolame), othercaps); gst_caps_unref (othercaps); + /* not much base class feedback: + * - we will handle buffers, just hand us all available */ + return TRUE; -no_rate: - { - GST_ERROR_OBJECT (twolame, "input caps have no sample rate field"); - return FALSE; - } -no_channels: - { - GST_ERROR_OBJECT (twolame, "input caps have no channels field"); - return FALSE; - } zero_output_rate: { GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS, (NULL), @@ -447,26 +425,6 @@ gst_two_lame_init (GstTwoLame * twolame, GstTwoLameClass * klass) { GST_DEBUG_OBJECT (twolame, "starting initialization"); - twolame->sinkpad = - gst_pad_new_from_static_template (&gst_two_lame_sink_template, "sink"); - gst_pad_set_event_function (twolame->sinkpad, - GST_DEBUG_FUNCPTR (gst_two_lame_sink_event)); - gst_pad_set_chain_function (twolame->sinkpad, - GST_DEBUG_FUNCPTR (gst_two_lame_chain)); - gst_pad_set_setcaps_function (twolame->sinkpad, - GST_DEBUG_FUNCPTR (gst_two_lame_sink_setcaps)); - gst_element_add_pad (GST_ELEMENT (twolame), twolame->sinkpad); - - twolame->srcpad = - gst_pad_new_from_static_template (&gst_two_lame_src_template, "src"); - gst_pad_set_setcaps_function (twolame->srcpad, - GST_DEBUG_FUNCPTR (gst_two_lame_src_setcaps)); - gst_element_add_pad (GST_ELEMENT (twolame), twolame->srcpad); - - twolame->samplerate = 44100; - twolame->num_channels = 2; - twolame->setup = FALSE; - twolame->mode = gst_two_lame_default_settings.mode; twolame->psymodel = gst_two_lame_default_settings.psymodel; twolame->bitrate = gst_two_lame_default_settings.bitrate; @@ -487,6 +445,26 @@ gst_two_lame_init (GstTwoLame * twolame, GstTwoLameClass * klass) GST_DEBUG_OBJECT (twolame, "done initializing"); } +static gboolean +gst_two_lame_start (GstAudioEncoder * enc) +{ + GstTwoLame *twolame = GST_TWO_LAME (enc); + + GST_DEBUG_OBJECT (twolame, "start"); + return TRUE; +} + +static gboolean +gst_two_lame_stop (GstAudioEncoder * enc) +{ + GstTwoLame *twolame = GST_TWO_LAME (enc); + + GST_DEBUG_OBJECT (twolame, "stop"); + + gst_two_lame_release_memory (twolame); + return TRUE; +} + /* three underscores for ___rate is really really really * private as opposed to one underscore */ /* call this MACRO outside of the NULL state so that we have a higher chance @@ -638,106 +616,54 @@ gst_two_lame_get_property (GObject * object, guint prop_id, GValue * value, } } -static gboolean -gst_two_lame_sink_event (GstPad * pad, GstEvent * event) +static GstFlowReturn +gst_two_lame_flush_full (GstTwoLame * lame, gboolean push) { - gboolean ret; - GstTwoLame *twolame; + GstBuffer *buf; + gint size; + GstFlowReturn result = GST_FLOW_OK; - twolame = GST_TWO_LAME (gst_pad_get_parent (pad)); + if (!lame->glopts) + return GST_FLOW_OK; - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_EOS:{ - GST_DEBUG_OBJECT (twolame, "handling EOS event"); + buf = gst_buffer_new_and_alloc (16384); + size = twolame_encode_flush (lame->glopts, GST_BUFFER_DATA (buf), 16384); - if (twolame->glopts != NULL) { - GstBuffer *buf; - gint size; - - buf = gst_buffer_new_and_alloc (16384); - size = - twolame_encode_flush (twolame->glopts, GST_BUFFER_DATA (buf), - 16394); - - if (size > 0 && twolame->last_flow == GST_FLOW_OK) { - gint64 duration; - - duration = gst_util_uint64_scale (size, 8 * GST_SECOND, - 1000 * twolame->bitrate); - - if (twolame->last_ts == GST_CLOCK_TIME_NONE) { - twolame->last_ts = twolame->eos_ts; - twolame->last_duration = duration; - } else { - twolame->last_duration += duration; - } - - GST_BUFFER_TIMESTAMP (buf) = twolame->last_ts; - GST_BUFFER_DURATION (buf) = twolame->last_duration; - twolame->last_ts = GST_CLOCK_TIME_NONE; - GST_BUFFER_SIZE (buf) = size; - GST_DEBUG_OBJECT (twolame, "pushing final packet of %u bytes", size); - gst_buffer_set_caps (buf, GST_PAD_CAPS (twolame->srcpad)); - gst_pad_push (twolame->srcpad, buf); - } else { - GST_DEBUG_OBJECT (twolame, "no final packet (size=%d, last_flow=%s)", - size, gst_flow_get_name (twolame->last_flow)); - gst_buffer_unref (buf); - } - } - - ret = gst_pad_event_default (pad, event); - break; - } - case GST_EVENT_FLUSH_START: - GST_DEBUG_OBJECT (twolame, "handling FLUSH start event"); - /* forward event */ - ret = gst_pad_push_event (twolame->srcpad, event); - break; - case GST_EVENT_FLUSH_STOP: - { - guchar *mp3_data = NULL; - gint mp3_buffer_size; - - GST_DEBUG_OBJECT (twolame, "handling FLUSH stop event"); - - /* clear buffers */ - mp3_buffer_size = 16384; - mp3_data = g_malloc (mp3_buffer_size); - twolame_encode_flush (twolame->glopts, mp3_data, mp3_buffer_size); - - ret = gst_pad_push_event (twolame->srcpad, event); - - g_free (mp3_data); - break; - } - default: - ret = gst_pad_event_default (pad, event); - break; + if (size > 0 && push) { + GST_BUFFER_SIZE (buf) = size; + GST_DEBUG_OBJECT (lame, "pushing final packet of %u bytes", size); + result = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (lame), buf, -1); + } else { + GST_DEBUG_OBJECT (lame, "no final packet (size=%d, push=%d)", size, push); + gst_buffer_unref (buf); + result = GST_FLOW_OK; } - gst_object_unref (twolame); + return result; +} - return ret; +static void +gst_two_lame_flush (GstAudioEncoder * enc) +{ + gst_two_lame_flush_full (GST_TWO_LAME (enc), FALSE); } static GstFlowReturn -gst_two_lame_chain (GstPad * pad, GstBuffer * buf) +gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf) { GstTwoLame *twolame; guchar *mp3_data; gint mp3_buffer_size, mp3_size; - gint64 duration; + GstBuffer *mp3_buf; GstFlowReturn result; gint num_samples; guint8 *data; guint size; - twolame = GST_TWO_LAME (GST_PAD_PARENT (pad)); + twolame = GST_TWO_LAME (enc); - GST_LOG_OBJECT (twolame, "entered chain"); - - if (!twolame->setup) - goto not_setup; + /* squeeze remaining and push */ + if (G_UNLIKELY (buf == NULL)) + return gst_two_lame_flush_full (twolame, TRUE); data = GST_BUFFER_DATA (buf); size = GST_BUFFER_SIZE (buf); @@ -749,7 +675,8 @@ gst_two_lame_chain (GstPad * pad, GstBuffer * buf) /* allocate space for output */ mp3_buffer_size = 1.25 * num_samples + 16384; - mp3_data = g_malloc (mp3_buffer_size); + mp3_buf = gst_buffer_new_and_alloc (mp3_buffer_size); + mp3_data = GST_BUFFER_DATA (mp3_buf); if (twolame->num_channels == 1) { if (twolame->float_input) @@ -774,73 +701,22 @@ gst_two_lame_chain (GstPad * pad, GstBuffer * buf) GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3", size, mp3_size); - if (twolame->float_input) - duration = gst_util_uint64_scale_int (size, GST_SECOND, - 4 * twolame->samplerate * twolame->num_channels); - else - duration = gst_util_uint64_scale_int (size, GST_SECOND, - 2 * twolame->samplerate * twolame->num_channels); - - if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE && - GST_BUFFER_DURATION (buf) != duration) { - GST_DEBUG_OBJECT (twolame, "incoming buffer had incorrect duration %" - GST_TIME_FORMAT ", outgoing buffer will have correct duration %" - GST_TIME_FORMAT, - GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_TIME_ARGS (duration)); - } - - if (twolame->last_ts == GST_CLOCK_TIME_NONE) { - twolame->last_ts = GST_BUFFER_TIMESTAMP (buf); - twolame->last_offs = GST_BUFFER_OFFSET (buf); - twolame->last_duration = duration; - } else { - twolame->last_duration += duration; - } - - gst_buffer_unref (buf); - if (mp3_size < 0) { - g_warning ("error %d", mp3_size); } if (mp3_size > 0) { - GstBuffer *outbuf; - - outbuf = gst_buffer_new (); - GST_BUFFER_DATA (outbuf) = mp3_data; - GST_BUFFER_MALLOCDATA (outbuf) = mp3_data; - GST_BUFFER_SIZE (outbuf) = mp3_size; - GST_BUFFER_TIMESTAMP (outbuf) = twolame->last_ts; - GST_BUFFER_OFFSET (outbuf) = twolame->last_offs; - GST_BUFFER_DURATION (outbuf) = twolame->last_duration; - gst_buffer_set_caps (outbuf, GST_PAD_CAPS (twolame->srcpad)); - - result = gst_pad_push (twolame->srcpad, outbuf); - twolame->last_flow = result; - if (result != GST_FLOW_OK) { - GST_DEBUG_OBJECT (twolame, "flow return: %s", gst_flow_get_name (result)); - } - - if (GST_CLOCK_TIME_IS_VALID (twolame->last_ts)) - twolame->eos_ts = twolame->last_ts + twolame->last_duration; - else - twolame->eos_ts = GST_CLOCK_TIME_NONE; - twolame->last_ts = GST_CLOCK_TIME_NONE; + GST_BUFFER_SIZE (mp3_buf) = mp3_size; + result = gst_audio_encoder_finish_frame (enc, mp3_buf, -1); } else { - g_free (mp3_data); + if (mp3_size < 0) { + /* eat error ? */ + g_warning ("error %d", mp3_size); + } + gst_buffer_unref (mp3_buf); result = GST_FLOW_OK; } return result; - - /* ERRORS */ -not_setup: - { - gst_buffer_unref (buf); - GST_ELEMENT_ERROR (twolame, CORE, NEGOTIATION, (NULL), - ("encoder not initialized (input is not audio?)")); - return GST_FLOW_ERROR; - } } /* set up the encoder state */ @@ -877,7 +753,7 @@ gst_two_lame_setup (GstTwoLame * twolame) twolame_set_in_samplerate (twolame->glopts, twolame->samplerate); /* let twolame choose default samplerate unless outgoing sample rate is fixed */ - allowed_caps = gst_pad_get_allowed_caps (twolame->srcpad); + allowed_caps = gst_pad_get_allowed_caps (GST_AUDIO_ENCODER_SRC_PAD (twolame)); if (allowed_caps != NULL) { GstStructure *structure; @@ -949,37 +825,6 @@ gst_two_lame_setup (GstTwoLame * twolame) #undef CHECK_ERROR } -static GstStateChangeReturn -gst_two_lame_change_state (GstElement * element, GstStateChange transition) -{ - GstTwoLame *twolame; - GstStateChangeReturn result; - - twolame = GST_TWO_LAME (element); - - switch (transition) { - case GST_STATE_CHANGE_READY_TO_PAUSED: - twolame->last_flow = GST_FLOW_OK; - twolame->last_ts = GST_CLOCK_TIME_NONE; - twolame->eos_ts = GST_CLOCK_TIME_NONE; - break; - default: - break; - } - - result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); - - switch (transition) { - case GST_STATE_CHANGE_READY_TO_NULL: - gst_two_lame_release_memory (twolame); - break; - default: - break; - } - - return result; -} - static gboolean gst_two_lame_get_default_settings (void) { diff --git a/ext/twolame/gsttwolame.h b/ext/twolame/gsttwolame.h index d8630c2388..deb3cf41db 100644 --- a/ext/twolame/gsttwolame.h +++ b/ext/twolame/gsttwolame.h @@ -24,6 +24,7 @@ #include +#include G_BEGIN_DECLS @@ -49,10 +50,7 @@ typedef struct _GstTwoLameClass GstTwoLameClass; * Opaque data structure. */ struct _GstTwoLame { - GstElement element; - - /*< private >*/ - GstPad *srcpad, *sinkpad; + GstAudioEncoder element; gint samplerate; gint num_channels; @@ -75,17 +73,11 @@ struct _GstTwoLame { gboolean quick_mode; gint quick_mode_count; - /* track this so we don't send a last buffer in eos handler after error */ - GstFlowReturn last_flow; - twolame_options *glopts; - - /* time tracker */ - guint64 last_ts, last_offs, last_duration, eos_ts; }; struct _GstTwoLameClass { - GstElementClass parent_class; + GstAudioEncoderClass parent_class; }; GType gst_two_lame_get_type(void); From f2011f15f1b2d180bc797dcb3fe5989d87ecdb57 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Mon, 26 Sep 2011 12:07:15 +0200 Subject: [PATCH 10/31] twolame: improve output framing and timestamping ... which simply comes down to requesting one frame of input data at a time, since the encoder nicely turns this into 1 encoded frame. --- ext/twolame/gsttwolame.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 3006f1aa27..bc2c07c5e1 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -401,8 +401,12 @@ gst_two_lame_set_format (GstAudioEncoder * enc, GstAudioInfo * info) gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (twolame), othercaps); gst_caps_unref (othercaps); - /* not much base class feedback: - * - we will handle buffers, just hand us all available */ + /* report needs to base class: + * hand one frame at a time, if we are pretty sure what a frame is */ + if (out_samplerate == twolame->samplerate) { + gst_audio_encoder_set_frame_samples (enc, 1152); + gst_audio_encoder_set_frame_max (enc, 1); + } return TRUE; From 2045f7baa2c640f0c5d1ee443e544dd8b869e832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 26 Sep 2011 16:28:08 +0200 Subject: [PATCH 11/31] twolame: Fix variable 'gstelement_class' set but not used compiler warning --- ext/twolame/gsttwolame.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index bc2c07c5e1..1677ff37ec 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -244,11 +244,9 @@ static void gst_two_lame_class_init (GstTwoLameClass * klass) { GObjectClass *gobject_class; - GstElementClass *gstelement_class; GstAudioEncoderClass *gstbase_class; gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass *) klass; gstbase_class = (GstAudioEncoderClass *) klass; parent_class = g_type_class_peek_parent (klass); From 1375f9887917eebc21cd68d38ab2cf19d19890c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 26 Sep 2011 16:29:12 +0200 Subject: [PATCH 12/31] twolame: Simple fix for GstAudioEncoder API change --- ext/twolame/gsttwolame.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 1677ff37ec..7d7fdc63cf 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -402,7 +402,8 @@ gst_two_lame_set_format (GstAudioEncoder * enc, GstAudioInfo * info) /* report needs to base class: * hand one frame at a time, if we are pretty sure what a frame is */ if (out_samplerate == twolame->samplerate) { - gst_audio_encoder_set_frame_samples (enc, 1152); + gst_audio_encoder_set_frame_samples_min (enc, 1152); + gst_audio_encoder_set_frame_samples_max (enc, 1152); gst_audio_encoder_set_frame_max (enc, 1); } From ac240ac3494bb93f62774055feec870fb6d18cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 11 Nov 2011 00:51:34 +0000 Subject: [PATCH 13/31] twolame: port to 0.11 --- ext/twolame/gsttwolame.c | 68 ++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 7d7fdc63cf..8839a424e4 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -62,19 +62,11 @@ GST_DEBUG_CATEGORY_STATIC (debug); /* TwoLAME can do MPEG-1, MPEG-2 so it has 6 possible * sample rates it supports */ static GstStaticPadTemplate gst_two_lame_sink_template = - GST_STATIC_PAD_TEMPLATE ("sink", +GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " - "endianness = (int) BYTE_ORDER, " - "width = (int) 32, " - "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, " - "channels = (int) [ 1, 2 ]; " - "audio/x-raw-int, " - "endianness = (int) BYTE_ORDER, " - "signed = (boolean) true, " - "width = (int) 16, " - "depth = (int) 16, " + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) { " GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (S16) " }, " "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, " "channels = (int) [ 1, 2 ]") ); @@ -205,8 +197,7 @@ static void gst_two_lame_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static gboolean gst_two_lame_setup (GstTwoLame * twolame); -GST_BOILERPLATE (GstTwoLame, gst_two_lame, GstAudioEncoder, - GST_TYPE_AUDIO_ENCODER); +G_DEFINE_TYPE (GstTwoLame, gst_two_lame, GST_TYPE_AUDIO_ENCODER); static void gst_two_lame_release_memory (GstTwoLame * twolame) @@ -222,22 +213,7 @@ gst_two_lame_finalize (GObject * obj) { gst_two_lame_release_memory (GST_TWO_LAME (obj)); - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -static void -gst_two_lame_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_two_lame_src_template)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_two_lame_sink_template)); - gst_element_class_set_details_simple (element_class, "TwoLAME mp2 encoder", - "Codec/Encoder/Audio", - "High-quality free MP2 encoder", - "Sebastian Dröge "); + G_OBJECT_CLASS (gst_two_lame_parent_class)->finalize (obj); } static void @@ -249,8 +225,6 @@ gst_two_lame_class_init (GstTwoLameClass * klass) gobject_class = (GObjectClass *) klass; gstbase_class = (GstAudioEncoderClass *) klass; - parent_class = g_type_class_peek_parent (klass); - gobject_class->set_property = gst_two_lame_set_property; gobject_class->get_property = gst_two_lame_get_property; gobject_class->finalize = gst_two_lame_finalize; @@ -346,6 +320,16 @@ gst_two_lame_class_init (GstTwoLameClass * klass) "Calculate Psymodel every n frames", 0, G_MAXINT, gst_two_lame_default_settings.quick_mode_count, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass), + gst_static_pad_template_get (&gst_two_lame_src_template)); + gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass), + gst_static_pad_template_get (&gst_two_lame_sink_template)); + + gst_element_class_set_details_simple (GST_ELEMENT_CLASS (klass), + "TwoLAME mp2 encoder", "Codec/Encoder/Audio", + "High-quality free MP2 encoder", + "Sebastian Dröge "); } static gboolean @@ -424,7 +408,7 @@ setup_failed: } static void -gst_two_lame_init (GstTwoLame * twolame, GstTwoLameClass * klass) +gst_two_lame_init (GstTwoLame * twolame) { GST_DEBUG_OBJECT (twolame, "starting initialization"); @@ -623,6 +607,7 @@ static GstFlowReturn gst_two_lame_flush_full (GstTwoLame * lame, gboolean push) { GstBuffer *buf; + guint8 *data; gint size; GstFlowReturn result = GST_FLOW_OK; @@ -630,10 +615,12 @@ gst_two_lame_flush_full (GstTwoLame * lame, gboolean push) return GST_FLOW_OK; buf = gst_buffer_new_and_alloc (16384); - size = twolame_encode_flush (lame->glopts, GST_BUFFER_DATA (buf), 16384); + data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE); + size = twolame_encode_flush (lame->glopts, data, 16384); + gst_buffer_unmap (buf, data, 16384); if (size > 0 && push) { - GST_BUFFER_SIZE (buf) = size; + gst_buffer_set_size (buf, size); GST_DEBUG_OBJECT (lame, "pushing final packet of %u bytes", size); result = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (lame), buf, -1); } else { @@ -660,7 +647,7 @@ gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf) GstFlowReturn result; gint num_samples; guint8 *data; - guint size; + gsize size; twolame = GST_TWO_LAME (enc); @@ -668,8 +655,7 @@ gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf) if (G_UNLIKELY (buf == NULL)) return gst_two_lame_flush_full (twolame, TRUE); - data = GST_BUFFER_DATA (buf); - size = GST_BUFFER_SIZE (buf); + data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); if (twolame->float_input) num_samples = size / 4; @@ -679,7 +665,7 @@ gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf) /* allocate space for output */ mp3_buffer_size = 1.25 * num_samples + 16384; mp3_buf = gst_buffer_new_and_alloc (mp3_buffer_size); - mp3_data = GST_BUFFER_DATA (mp3_buf); + mp3_data = gst_buffer_map (mp3_buf, NULL, NULL, GST_MAP_WRITE); if (twolame->num_channels == 1) { if (twolame->float_input) @@ -704,11 +690,11 @@ gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf) GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3", size, mp3_size); - if (mp3_size < 0) { - } + gst_buffer_unmap (buf, data, -1); + gst_buffer_unmap (mp3_buf, mp3_data, -1); if (mp3_size > 0) { - GST_BUFFER_SIZE (mp3_buf) = mp3_size; + gst_buffer_set_size (mp3_buf, mp3_size); result = gst_audio_encoder_finish_frame (enc, mp3_buf, -1); } else { if (mp3_size < 0) { From 848103c8610ccebae36fddb56a7a57e82ecfa677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 11 Nov 2011 00:58:24 +0000 Subject: [PATCH 14/31] twolame: rename to twolamemp2enc --- ext/twolame/Makefile.am | 4 ++-- ext/twolame/{gsttwolame.c => gsttwolamemp2enc.c} | 4 ++-- ext/twolame/{gsttwolame.h => gsttwolamemp2enc.h} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename ext/twolame/{gsttwolame.c => gsttwolamemp2enc.c} (99%) rename ext/twolame/{gsttwolame.h => gsttwolamemp2enc.h} (100%) diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am index 1b32aae345..ff048e50da 100644 --- a/ext/twolame/Makefile.am +++ b/ext/twolame/Makefile.am @@ -1,6 +1,6 @@ plugin_LTLIBRARIES = libgsttwolame.la -libgsttwolame_la_SOURCES = gsttwolame.c +libgsttwolame_la_SOURCES = gsttwolamemp2enc.c libgsttwolame_la_CFLAGS = -DGST_USE_UNSTABLE_API \ $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(TWOLAME_CFLAGS) libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ @@ -9,4 +9,4 @@ libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgsttwolame_la_LIBTOOLFLAGS = --tag=disable-static -noinst_HEADERS = gsttwolame.h +noinst_HEADERS = gsttwolamemp2enc.h diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolamemp2enc.c similarity index 99% rename from ext/twolame/gsttwolame.c rename to ext/twolame/gsttwolamemp2enc.c index 8839a424e4..9c8b874d10 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -53,7 +53,7 @@ #endif #include "string.h" -#include "gsttwolame.h" +#include "gsttwolamemp2enc.h" #include "gst/gst-i18n-plugin.h" GST_DEBUG_CATEGORY_STATIC (debug); @@ -873,7 +873,7 @@ plugin_init (GstPlugin * plugin) bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif /* ENABLE_NLS */ - if (!gst_element_register (plugin, "twolame", GST_RANK_PRIMARY, + if (!gst_element_register (plugin, "twolamemp2enc", GST_RANK_PRIMARY, GST_TYPE_TWO_LAME)) return FALSE; diff --git a/ext/twolame/gsttwolame.h b/ext/twolame/gsttwolamemp2enc.h similarity index 100% rename from ext/twolame/gsttwolame.h rename to ext/twolame/gsttwolamemp2enc.h From 9cb748ee21bcdb81e2f8f42eb8ef2d25e3e58d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 23 Nov 2011 23:29:03 +0000 Subject: [PATCH 15/31] ext: fix more printf format warnings in debug messages --- ext/twolame/gsttwolamemp2enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index 9c8b874d10..7e4882e46b 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -687,8 +687,8 @@ gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf) num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); } - GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3", - size, mp3_size); + GST_LOG_OBJECT (twolame, "encoded %" G_GSIZE_FORMAT " bytes of audio " + "to %d bytes of mp3", size, mp3_size); gst_buffer_unmap (buf, data, -1); gst_buffer_unmap (mp3_buf, mp3_data, -1); From 59f3ceff480e293d21f90930ddac2ad4ed845317 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 28 Nov 2011 13:10:01 +0000 Subject: [PATCH 16/31] various: fix pad template ref leaks https://bugzilla.gnome.org/show_bug.cgi?id=662664 --- ext/twolame/gsttwolame.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/twolame/gsttwolame.c b/ext/twolame/gsttwolame.c index 7d7fdc63cf..a1b1579dd6 100644 --- a/ext/twolame/gsttwolame.c +++ b/ext/twolame/gsttwolame.c @@ -230,10 +230,10 @@ gst_two_lame_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_two_lame_src_template)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_two_lame_sink_template)); + gst_element_class_add_static_pad_template (element_class, + &gst_two_lame_src_template); + gst_element_class_add_static_pad_template (element_class, + &gst_two_lame_sink_template); gst_element_class_set_details_simple (element_class, "TwoLAME mp2 encoder", "Codec/Encoder/Audio", "High-quality free MP2 encoder", From 9b2d493e76e2379d6d939ebb97a9e5ba165ea4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 4 Jan 2012 15:44:37 +0100 Subject: [PATCH 17/31] twolamemp2enc: Update for the new raw audio caps --- ext/twolame/gsttwolamemp2enc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index 7e4882e46b..67f91d75cb 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -62,13 +62,19 @@ GST_DEBUG_CATEGORY_STATIC (debug); /* TwoLAME can do MPEG-1, MPEG-2 so it has 6 possible * sample rates it supports */ static GstStaticPadTemplate gst_two_lame_sink_template = -GST_STATIC_PAD_TEMPLATE ("sink", + GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw, " "format = (string) { " GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (S16) " }, " + "layout = (string) interleaved, " "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, " - "channels = (int) [ 1, 2 ]") + "channels = (int) 1; " + "audio/x-raw, " + "format = (string) { " GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (S16) " }, " + "layout = (string) interleaved, " + "rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, " + "channels = (int) 2," "channel-mask = (bitmask) 0x3") ); static GstStaticPadTemplate gst_two_lame_src_template = From 966ebb5bf9e0cafc70d06f51c890cdcb8da45d97 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 25 Jan 2012 07:24:59 +0100 Subject: [PATCH 18/31] port to new memory API --- ext/twolame/gsttwolamemp2enc.c | 42 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index 67f91d75cb..c879edb802 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -613,7 +613,7 @@ static GstFlowReturn gst_two_lame_flush_full (GstTwoLame * lame, gboolean push) { GstBuffer *buf; - guint8 *data; + GstMapInfo map; gint size; GstFlowReturn result = GST_FLOW_OK; @@ -621,9 +621,9 @@ gst_two_lame_flush_full (GstTwoLame * lame, gboolean push) return GST_FLOW_OK; buf = gst_buffer_new_and_alloc (16384); - data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE); - size = twolame_encode_flush (lame->glopts, data, 16384); - gst_buffer_unmap (buf, data, 16384); + gst_buffer_map (buf, &map, GST_MAP_WRITE); + size = twolame_encode_flush (lame->glopts, map.data, 16384); + gst_buffer_unmap (buf, &map); if (size > 0 && push) { gst_buffer_set_size (buf, size); @@ -647,13 +647,11 @@ static GstFlowReturn gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf) { GstTwoLame *twolame; - guchar *mp3_data; gint mp3_buffer_size, mp3_size; GstBuffer *mp3_buf; GstFlowReturn result; gint num_samples; - guint8 *data; - gsize size; + GstMapInfo map, mp3_map; twolame = GST_TWO_LAME (enc); @@ -661,43 +659,43 @@ gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf) if (G_UNLIKELY (buf == NULL)) return gst_two_lame_flush_full (twolame, TRUE); - data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); + gst_buffer_map (buf, &map, GST_MAP_READ); if (twolame->float_input) - num_samples = size / 4; + num_samples = map.size / 4; else - num_samples = size / 2; + num_samples = map.size / 2; /* allocate space for output */ mp3_buffer_size = 1.25 * num_samples + 16384; mp3_buf = gst_buffer_new_and_alloc (mp3_buffer_size); - mp3_data = gst_buffer_map (mp3_buf, NULL, NULL, GST_MAP_WRITE); + gst_buffer_map (mp3_buf, &mp3_map, GST_MAP_WRITE); if (twolame->num_channels == 1) { if (twolame->float_input) mp3_size = twolame_encode_buffer_float32 (twolame->glopts, - (float *) data, - (float *) data, num_samples, mp3_data, mp3_buffer_size); + (float *) map.data, + (float *) map.data, num_samples, mp3_map.data, mp3_buffer_size); else mp3_size = twolame_encode_buffer (twolame->glopts, - (short int *) data, - (short int *) data, num_samples, mp3_data, mp3_buffer_size); + (short int *) map.data, + (short int *) map.data, num_samples, mp3_map.data, mp3_buffer_size); } else { if (twolame->float_input) mp3_size = twolame_encode_buffer_float32_interleaved (twolame->glopts, - (float *) data, - num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); + (float *) map.data, + num_samples / twolame->num_channels, mp3_map.data, mp3_buffer_size); else mp3_size = twolame_encode_buffer_interleaved (twolame->glopts, - (short int *) data, - num_samples / twolame->num_channels, mp3_data, mp3_buffer_size); + (short int *) map.data, + num_samples / twolame->num_channels, mp3_map.data, mp3_buffer_size); } GST_LOG_OBJECT (twolame, "encoded %" G_GSIZE_FORMAT " bytes of audio " - "to %d bytes of mp3", size, mp3_size); + "to %d bytes of mp3", map.size, mp3_size); - gst_buffer_unmap (buf, data, -1); - gst_buffer_unmap (mp3_buf, mp3_data, -1); + gst_buffer_unmap (buf, &map); + gst_buffer_unmap (mp3_buf, &mp3_map); if (mp3_size > 0) { gst_buffer_set_size (mp3_buf, mp3_size); From 3a70f716a0b8cf10ff5523d3a3137ec68affe2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 1 Feb 2012 16:20:46 +0100 Subject: [PATCH 19/31] twolame: Use new audio encoder/decoder base class API for srcpad caps --- ext/twolame/gsttwolamemp2enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index c879edb802..2101c143db 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -386,7 +386,7 @@ gst_two_lame_set_format (GstAudioEncoder * enc, GstAudioInfo * info) G_TYPE_INT, out_samplerate, NULL); /* and use these caps */ - gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (twolame), othercaps); + gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (twolame), othercaps); gst_caps_unref (othercaps); /* report needs to base class: From ff5b079a17cbd45aacf80cf146fc621afe738932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 4 Apr 2012 14:38:53 +0200 Subject: [PATCH 20/31] gst: Update versioning --- ext/twolame/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am index ff048e50da..785fd8f8d1 100644 --- a/ext/twolame/Makefile.am +++ b/ext/twolame/Makefile.am @@ -4,7 +4,7 @@ libgsttwolame_la_SOURCES = gsttwolamemp2enc.c libgsttwolame_la_CFLAGS = -DGST_USE_UNSTABLE_API \ $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(TWOLAME_CFLAGS) libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ - -lgstaudio-@GST_MAJORMINOR@ -lgstpbutils-@GST_MAJORMINOR@ \ + -lgstaudio-@GST_API_VERSION@ -lgstpbutils-@GST_API_VERSION@ \ $(GST_LIBS) $(TWOLAME_LIBS) libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgsttwolame_la_LIBTOOLFLAGS = --tag=disable-static From b27c88c93d2a256583bf66e0e005542cfc406f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 5 Apr 2012 17:40:12 +0200 Subject: [PATCH 21/31] gst: Update for GST_PLUGIN_DEFINE() API changes --- ext/twolame/gsttwolamemp2enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index 2101c143db..f309581829 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -886,6 +886,6 @@ plugin_init (GstPlugin * plugin) GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, - "twolame", + twolame, "Encode MP2s with TwoLAME", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); From 3e2ca1a0d9b235d2345bcba47a983d5af3eaf61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 10 Apr 2012 00:47:44 +0100 Subject: [PATCH 22/31] Use new gst_element_class_set_static_metadata() --- ext/twolame/gsttwolamemp2enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index f309581829..0b8b4c2cdc 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -332,7 +332,7 @@ gst_two_lame_class_init (GstTwoLameClass * klass) gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass), gst_static_pad_template_get (&gst_two_lame_sink_template)); - gst_element_class_set_details_simple (GST_ELEMENT_CLASS (klass), + gst_element_class_set_static_metadata (GST_ELEMENT_CLASS (klass), "TwoLAME mp2 encoder", "Codec/Encoder/Audio", "High-quality free MP2 encoder", "Sebastian Dröge "); From 6533141626660774fa7f35a1069a623b17cff955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 17 Sep 2012 16:57:30 +0100 Subject: [PATCH 23/31] Remove -DGST_USE_UNSTABLE_API --- ext/twolame/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am index 785fd8f8d1..75035153c7 100644 --- a/ext/twolame/Makefile.am +++ b/ext/twolame/Makefile.am @@ -1,7 +1,7 @@ plugin_LTLIBRARIES = libgsttwolame.la libgsttwolame_la_SOURCES = gsttwolamemp2enc.c -libgsttwolame_la_CFLAGS = -DGST_USE_UNSTABLE_API \ +libgsttwolame_la_CFLAGS = \ $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(TWOLAME_CFLAGS) libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ -lgstaudio-@GST_API_VERSION@ -lgstpbutils-@GST_API_VERSION@ \ From adc0d470ec1eb591c4b6282dbd3f8d43f7e801aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 3 Nov 2012 20:40:37 +0000 Subject: [PATCH 24/31] Fix FSF address https://bugzilla.gnome.org/show_bug.cgi?id=687520 --- ext/twolame/gsttwolamemp2enc.c | 4 ++-- ext/twolame/gsttwolamemp2enc.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index 0b8b4c2cdc..12b6f5ab0e 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -16,8 +16,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ /* diff --git a/ext/twolame/gsttwolamemp2enc.h b/ext/twolame/gsttwolamemp2enc.h index deb3cf41db..72a6beaec8 100644 --- a/ext/twolame/gsttwolamemp2enc.h +++ b/ext/twolame/gsttwolamemp2enc.h @@ -14,8 +14,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ From aa0c5c2a8499758bdc24741f75cac799dc3ac588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 24 Oct 2012 12:15:54 +0200 Subject: [PATCH 25/31] gst: Add better support for static plugins --- ext/twolame/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am index 75035153c7..b6de82c174 100644 --- a/ext/twolame/Makefile.am +++ b/ext/twolame/Makefile.am @@ -7,6 +7,6 @@ libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ -lgstaudio-@GST_API_VERSION@ -lgstpbutils-@GST_API_VERSION@ \ $(GST_LIBS) $(TWOLAME_LIBS) libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -libgsttwolame_la_LIBTOOLFLAGS = --tag=disable-static +libgsttwolame_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) noinst_HEADERS = gsttwolamemp2enc.h From db8ee7e7e0b1ca878ebde09cbc9ca6185c10fe38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 21 Jan 2015 09:56:41 +0100 Subject: [PATCH 26/31] Constify some static arrays everywhere --- ext/twolame/gsttwolamemp2enc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index 12b6f5ab0e..63f1fd33c0 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -113,7 +113,7 @@ static GType gst_two_lame_mode_get_type (void) { static GType two_lame_mode_type = 0; - static GEnumValue two_lame_modes[] = { + static const GEnumValue two_lame_modes[] = { {TWOLAME_AUTO_MODE, "Auto", "auto"}, {TWOLAME_STEREO, "Stereo", "stereo"}, {TWOLAME_JOINT_STEREO, "Joint Stereo", "joint"}, @@ -134,7 +134,7 @@ static GType gst_two_lame_padding_get_type (void) { static GType two_lame_padding_type = 0; - static GEnumValue two_lame_padding[] = { + static const GEnumValue two_lame_padding[] = { {TWOLAME_PAD_NO, "No Padding", "never"}, {TWOLAME_PAD_ALL, "Always Pad", "always"}, {0, NULL, NULL} @@ -152,7 +152,7 @@ static GType gst_two_lame_emphasis_get_type (void) { static GType two_lame_emphasis_type = 0; - static GEnumValue two_lame_emphasis[] = { + static const GEnumValue two_lame_emphasis[] = { {TWOLAME_EMPHASIS_N, "No emphasis", "none"}, {TWOLAME_EMPHASIS_5, "50/15 ms", "5"}, {TWOLAME_EMPHASIS_C, "CCIT J.17", "ccit"}, From f7661aae4bd40786d97fe93b21426ed14b3ff714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 10 May 2015 11:34:33 +0100 Subject: [PATCH 27/31] docs: update example pipelines in element docs Mostly gst-launch -> gst-launch-1.0, but also use autoaudiosink/autovideosink in more places and update pipelines a little or flesh out descriptions. --- ext/twolame/gsttwolamemp2enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index 63f1fd33c0..85438769cf 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -33,16 +33,16 @@ * * Example pipelines * |[ - * gst-launch -v audiotestsrc wave=sine num-buffers=100 ! audioconvert ! twolame ! filesink location=sine.mp2 + * gst-launch-1.0 -v audiotestsrc wave=sine num-buffers=100 ! audioconvert ! twolame ! filesink location=sine.mp2 * ]| Encode a test sine signal to MP2. * |[ - * gst-launch -v alsasrc ! audioconvert ! twolame bitrate=192 ! filesink location=alsasrc.mp2 + * gst-launch-1.0 -v alsasrc ! audioconvert ! twolame bitrate=192 ! filesink location=alsasrc.mp2 * ]| Record from a sound card using ALSA and encode to MP2 * |[ - * gst-launch -v filesrc location=music.wav ! decodebin ! audioconvert ! audioresample ! twolame bitrate=192 ! id3v2mux ! filesink location=music.mp2 + * gst-launch-1.0 -v filesrc location=music.wav ! decodebin ! audioconvert ! audioresample ! twolame bitrate=192 ! id3v2mux ! filesink location=music.mp2 * ]| Transcode from a .wav file to MP2 (the id3v2mux element is optional) * |[ - * gst-launch -v cdda://5 ! audioconvert ! twolame bitrate=192 ! filesink location=track5.mp2 + * gst-launch-1.0 -v cdda://5 ! audioconvert ! twolame bitrate=192 ! filesink location=track5.mp2 * ]| Encode Audio CD track 5 to MP2 * * From ef773697a893990083dc8f40c81d7b7e44d5c802 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Sat, 15 Aug 2015 22:15:26 -0300 Subject: [PATCH 28/31] audioencoders: use template subset check for accept-caps It is faster than doing a query that propagates downstream and should be enough Elements: amrnbenc, lamemp3enc, twolamemp2enc --- ext/twolame/gsttwolamemp2enc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index 85438769cf..a5e1b55e75 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -418,6 +418,8 @@ gst_two_lame_init (GstTwoLame * twolame) { GST_DEBUG_OBJECT (twolame, "starting initialization"); + GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_ENCODER_SINK_PAD (twolame)); + twolame->mode = gst_two_lame_default_settings.mode; twolame->psymodel = gst_two_lame_default_settings.psymodel; twolame->bitrate = gst_two_lame_default_settings.bitrate; From ab281e60385c5fbd77387f91f4d9920ec2c30a2f Mon Sep 17 00:00:00 2001 From: Vineeth TM Date: Fri, 4 Mar 2016 16:14:44 +0900 Subject: [PATCH 29/31] ugly: use new gst_element_class_add_static_pad_template() https://bugzilla.gnome.org/show_bug.cgi?id=763082 --- ext/twolame/gsttwolamemp2enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/twolame/gsttwolamemp2enc.c b/ext/twolame/gsttwolamemp2enc.c index a5e1b55e75..31bec6b78c 100644 --- a/ext/twolame/gsttwolamemp2enc.c +++ b/ext/twolame/gsttwolamemp2enc.c @@ -327,10 +327,10 @@ gst_two_lame_class_init (GstTwoLameClass * klass) 0, G_MAXINT, gst_two_lame_default_settings.quick_mode_count, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass), - gst_static_pad_template_get (&gst_two_lame_src_template)); - gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass), - gst_static_pad_template_get (&gst_two_lame_sink_template)); + gst_element_class_add_static_pad_template (GST_ELEMENT_CLASS (klass), + &gst_two_lame_src_template); + gst_element_class_add_static_pad_template (GST_ELEMENT_CLASS (klass), + &gst_two_lame_sink_template); gst_element_class_set_static_metadata (GST_ELEMENT_CLASS (klass), "TwoLAME mp2 encoder", "Codec/Encoder/Audio", From 364d70149e35b93b69186f674db31fa87b4a7fe9 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Fri, 12 Aug 2016 21:25:34 +0530 Subject: [PATCH 30/31] Add support for Meson as alternative/parallel build system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/mesonbuild/meson With contributions from: Tim-Philipp Müller Jussi Pakkanen (original port) Highlights of the features provided are: * Faster builds on Linux (~40-50% faster) * The ability to build with MSVC on Windows * Generate Visual Studio project files * Generate XCode project files * Much faster builds on Windows (on-par with Linux) * Seriously fast configure and building on embedded ... and many more. For more details see: http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html Building with Meson should work on both Linux and Windows, but may need a few more tweaks on other operating systems. --- ext/twolame/meson.build | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 ext/twolame/meson.build diff --git a/ext/twolame/meson.build b/ext/twolame/meson.build new file mode 100644 index 0000000000..029a00eb4b --- /dev/null +++ b/ext/twolame/meson.build @@ -0,0 +1,12 @@ +twolame_dep = dependency('twolame', version : '>= 0.3.10', required : false) + +if twolame_dep.found() + twolame = library('gsttwolame', + ['gsttwolamemp2enc.c'], + c_args : ugly_args, + include_directories : [configinc, libsinc], + dependencies : [gstaudio_dep, twolame_dep], + install : true, + install_dir : plugins_install_dir, + ) +endif From 0751b10ab95fc509a379da9cfba2671649e04172 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 16 May 2017 14:07:56 -0400 Subject: [PATCH 31/31] Remove plugin specific static build option Static and dynamic plugins now have the same interface. The standard --enable-static/--enable-shared toggle are sufficient. --- ext/twolame/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/twolame/Makefile.am b/ext/twolame/Makefile.am index b6de82c174..362ee20f65 100644 --- a/ext/twolame/Makefile.am +++ b/ext/twolame/Makefile.am @@ -7,6 +7,5 @@ libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ -lgstaudio-@GST_API_VERSION@ -lgstpbutils-@GST_API_VERSION@ \ $(GST_LIBS) $(TWOLAME_LIBS) libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -libgsttwolame_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) noinst_HEADERS = gsttwolamemp2enc.h