2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-20 23:48:55 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2005-09-16 16:04:28 +00:00
|
|
|
* Copyright (C) <2004> Wim Taymans <wim@fluendo.com>
|
|
|
|
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
|
2001-12-20 23:48:55 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:09 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2003-07-05 22:48:58 +00:00
|
|
|
#include "string.h"
|
2001-12-20 23:48:55 +00:00
|
|
|
#include "gstlame.h"
|
|
|
|
|
2004-08-19 22:44:50 +00:00
|
|
|
#ifdef lame_set_preset
|
|
|
|
#define GST_LAME_PRESET
|
|
|
|
#endif
|
|
|
|
|
ext/lame/gstlame.c: add debugging category, add error checks like checking return values of setup calls, make sure it...
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_link), (gst_lame_init),
(gst_lame_chain), (gst_lame_setup), (gst_lame_change_state),
(plugin_init):
add debugging category, add error checks like checking return values
of setup calls, make sure it still works after
PLAYING=>NULL=>PLAYING, fix encoding of mono streams
2004-07-26 15:42:18 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (debug);
|
|
|
|
#define GST_CAT_DEFAULT debug
|
|
|
|
|
2002-09-18 19:02:46 +00:00
|
|
|
/* elementfactory information */
|
2004-03-14 22:34:30 +00:00
|
|
|
static GstElementDetails gst_lame_details = {
|
2001-12-20 23:48:55 +00:00
|
|
|
"L.A.M.E. mp3 encoder",
|
2004-05-09 14:37:15 +00:00
|
|
|
"Codec/Encoder/Audio",
|
2001-12-20 23:48:55 +00:00
|
|
|
"High-quality free MP3 encoder",
|
2005-08-16 16:12:15 +00:00
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>, " "Wim Taymans <wim@fluendo.com>",
|
2001-12-20 23:48:55 +00:00
|
|
|
};
|
|
|
|
|
2004-06-14 10:52:35 +00:00
|
|
|
/* LAME can do MPEG-1, MPEG-2, and MPEG-2.5, so it has 9 possible
|
|
|
|
* sample rates it supports */
|
2003-12-22 01:47:08 +00:00
|
|
|
static GstStaticPadTemplate gst_lame_sink_template =
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
2004-06-14 10:58:27 +00:00
|
|
|
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
2004-03-15 19:32:25 +00:00
|
|
|
"signed = (boolean) true, "
|
|
|
|
"width = (int) 16, "
|
|
|
|
"depth = (int) 16, "
|
|
|
|
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
|
|
|
|
"channels = (int) [ 1, 2 ]")
|
2004-03-14 22:34:30 +00:00
|
|
|
);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
static GstStaticPadTemplate gst_lame_src_template =
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/mpeg, "
|
2004-03-15 19:32:25 +00:00
|
|
|
"mpegversion = (int) 1, "
|
|
|
|
"layer = (int) 3, "
|
|
|
|
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
|
|
|
|
"channels = (int) [ 1, 2 ]")
|
2004-03-14 22:34:30 +00:00
|
|
|
);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
|
|
|
/********** Define useful types for non-programmatic interfaces **********/
|
|
|
|
#define GST_TYPE_LAME_MODE (gst_lame_mode_get_type())
|
|
|
|
static GType
|
|
|
|
gst_lame_mode_get_type (void)
|
|
|
|
{
|
|
|
|
static GType lame_mode_type = 0;
|
|
|
|
static GEnumValue lame_modes[] = {
|
2005-11-22 17:04:38 +00:00
|
|
|
{0, "Stereo", "stereo"},
|
|
|
|
{1, "Joint Stereo", "joint"},
|
|
|
|
{2, "Dual Channel", "dual"},
|
|
|
|
{3, "Mono", "mono"},
|
|
|
|
{4, "Auto", "auto"},
|
2004-08-13 15:22:49 +00:00
|
|
|
{0, NULL, NULL}
|
2001-12-20 23:48:55 +00:00
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
if (!lame_mode_type) {
|
|
|
|
lame_mode_type = g_enum_register_static ("GstLameMode", lame_modes);
|
|
|
|
}
|
|
|
|
return lame_mode_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_LAME_QUALITY (gst_lame_quality_get_type())
|
|
|
|
static GType
|
|
|
|
gst_lame_quality_get_type (void)
|
|
|
|
{
|
|
|
|
static GType lame_quality_type = 0;
|
|
|
|
static GEnumValue lame_quality[] = {
|
2005-11-22 17:15:25 +00:00
|
|
|
{0, "0 - Best", "0"},
|
2004-03-14 22:34:30 +00:00
|
|
|
{1, "1", "1"},
|
|
|
|
{2, "2", "2"},
|
|
|
|
{3, "3", "3"},
|
|
|
|
{4, "4", "4"},
|
2005-11-22 17:15:25 +00:00
|
|
|
{5, "5 - Default", "5"},
|
2004-03-14 22:34:30 +00:00
|
|
|
{6, "6", "6"},
|
|
|
|
{7, "7", "7"},
|
|
|
|
{8, "8", "8"},
|
2005-11-22 17:15:25 +00:00
|
|
|
{9, "9 - Worst", "9"},
|
2004-08-13 15:22:49 +00:00
|
|
|
{0, NULL, NULL}
|
2001-12-20 23:48:55 +00:00
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
if (!lame_quality_type) {
|
|
|
|
lame_quality_type = g_enum_register_static ("GstLameQuality", lame_quality);
|
|
|
|
}
|
|
|
|
return lame_quality_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_LAME_PADDING (gst_lame_padding_get_type())
|
|
|
|
static GType
|
|
|
|
gst_lame_padding_get_type (void)
|
|
|
|
{
|
|
|
|
static GType lame_padding_type = 0;
|
|
|
|
static GEnumValue lame_padding[] = {
|
2005-11-22 17:04:38 +00:00
|
|
|
{0, "No Padding", "never"},
|
|
|
|
{1, "Always Pad", "always"},
|
|
|
|
{2, "Adjust Padding", "adjust"},
|
2004-08-13 15:22:49 +00:00
|
|
|
{0, NULL, NULL}
|
2001-12-20 23:48:55 +00:00
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
if (!lame_padding_type) {
|
|
|
|
lame_padding_type = g_enum_register_static ("GstLamePadding", lame_padding);
|
|
|
|
}
|
|
|
|
return lame_padding_type;
|
|
|
|
}
|
|
|
|
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
#define GST_TYPE_LAME_VBRMODE (gst_lame_vbrmode_get_type())
|
|
|
|
static GType
|
|
|
|
gst_lame_vbrmode_get_type (void)
|
|
|
|
{
|
|
|
|
static GType lame_vbrmode_type = 0;
|
|
|
|
static GEnumValue lame_vbrmode[] = {
|
2005-11-22 17:04:38 +00:00
|
|
|
{vbr_off, "No VBR (Constant Bitrate)", "none"},
|
|
|
|
{vbr_rh, "Lame's old VBR algorithm", "old"},
|
|
|
|
{vbr_abr, "VBR Average Bitrate", "abr"},
|
|
|
|
{vbr_mtrh, "Lame's new VBR algorithm", "new"},
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
{0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!lame_vbrmode_type) {
|
|
|
|
lame_vbrmode_type = g_enum_register_static ("GstLameVbrmode", lame_vbrmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return lame_vbrmode_type;
|
|
|
|
}
|
|
|
|
|
2004-08-19 22:44:50 +00:00
|
|
|
#ifdef GSTLAME_PRESET
|
2004-08-13 15:22:49 +00:00
|
|
|
#define GST_TYPE_LAME_PRESET (gst_lame_preset_get_type())
|
|
|
|
static GType
|
|
|
|
gst_lame_preset_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_lame_preset = 0;
|
|
|
|
static GEnumValue gst_lame_presets[] = {
|
2005-11-22 17:04:38 +00:00
|
|
|
{0, "None", "none"},
|
|
|
|
{MEDIUM, "Medium", "medium"},
|
|
|
|
{STANDARD, "Standard", "standard"},
|
|
|
|
{EXTREME, "Extreme", "extreme"},
|
|
|
|
{INSANE, "Insane", "insane"},
|
2004-08-13 15:22:49 +00:00
|
|
|
{0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!gst_lame_preset) {
|
|
|
|
gst_lame_preset =
|
|
|
|
g_enum_register_static ("GstLamePreset", gst_lame_presets);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gst_lame_preset;
|
|
|
|
}
|
2004-08-19 22:44:50 +00:00
|
|
|
#endif
|
2004-08-13 15:22:49 +00:00
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
/********** Standard stuff for signals and arguments **********/
|
|
|
|
/* GstLame signals and args */
|
2004-03-14 22:34:30 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-20 23:48:55 +00:00
|
|
|
/* FILL_ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-20 23:48:55 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_BITRATE,
|
|
|
|
ARG_COMPRESSION_RATIO,
|
|
|
|
ARG_QUALITY,
|
|
|
|
ARG_MODE,
|
|
|
|
ARG_FORCE_MS,
|
|
|
|
ARG_FREE_FORMAT,
|
|
|
|
ARG_COPYRIGHT,
|
|
|
|
ARG_ORIGINAL,
|
|
|
|
ARG_ERROR_PROTECTION,
|
|
|
|
ARG_PADDING_TYPE,
|
|
|
|
ARG_EXTENSION,
|
|
|
|
ARG_STRICT_ISO,
|
|
|
|
ARG_DISABLE_RESERVOIR,
|
|
|
|
ARG_VBR,
|
|
|
|
ARG_VBR_MEAN_BITRATE,
|
|
|
|
ARG_VBR_MIN_BITRATE,
|
|
|
|
ARG_VBR_MAX_BITRATE,
|
|
|
|
ARG_VBR_HARD_MIN,
|
|
|
|
ARG_LOWPASS_FREQ,
|
|
|
|
ARG_LOWPASS_WIDTH,
|
|
|
|
ARG_HIGHPASS_FREQ,
|
|
|
|
ARG_HIGHPASS_WIDTH,
|
|
|
|
ARG_ATH_ONLY,
|
|
|
|
ARG_ATH_SHORT,
|
|
|
|
ARG_NO_ATH,
|
|
|
|
ARG_ATH_LOWER,
|
|
|
|
ARG_CWLIMIT,
|
|
|
|
ARG_ALLOW_DIFF_SHORT,
|
|
|
|
ARG_NO_SHORT_BLOCKS,
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
ARG_EMPHASIS,
|
|
|
|
ARG_VBR_QUALITY,
|
2004-08-19 22:44:50 +00:00
|
|
|
#ifdef GSTLAME_PRESET
|
2006-03-28 16:06:05 +00:00
|
|
|
ARG_XINGHEADER, /* FIXME: remove in 0.11 */
|
2004-08-13 15:22:49 +00:00
|
|
|
ARG_PRESET
|
2004-08-19 22:44:50 +00:00
|
|
|
#else
|
2006-03-28 16:06:05 +00:00
|
|
|
ARG_XINGHEADER /* FIXME: remove in 0.11 */
|
2004-08-19 22:44:50 +00:00
|
|
|
#endif
|
2001-12-20 23:48:55 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void gst_lame_base_init (gpointer g_class);
|
|
|
|
static void gst_lame_class_init (GstLameClass * klass);
|
|
|
|
static void gst_lame_init (GstLame * gst_lame);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void gst_lame_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_lame_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2005-08-16 16:12:15 +00:00
|
|
|
static gboolean gst_lame_sink_event (GstPad * pad, GstEvent * event);
|
|
|
|
static GstFlowReturn gst_lame_chain (GstPad * pad, GstBuffer * buf);
|
2004-03-14 22:34:30 +00:00
|
|
|
static gboolean gst_lame_setup (GstLame * lame);
|
2005-09-02 15:43:54 +00:00
|
|
|
static GstStateChangeReturn gst_lame_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2001-12-21 12:47:09 +00:00
|
|
|
/* static guint gst_lame_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-20 23:48:55 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
gst_lame_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_lame_type = 0;
|
|
|
|
|
|
|
|
if (!gst_lame_type) {
|
|
|
|
static const GTypeInfo gst_lame_info = {
|
2004-03-14 22:34:30 +00:00
|
|
|
sizeof (GstLameClass),
|
2003-11-02 00:13:26 +00:00
|
|
|
gst_lame_base_init,
|
2001-12-21 12:47:09 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_lame_class_init,
|
2001-12-20 23:48:55 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:30 +00:00
|
|
|
sizeof (GstLame),
|
2001-12-20 23:48:55 +00:00
|
|
|
0,
|
2001-12-21 12:47:09 +00:00
|
|
|
(GInstanceInitFunc) gst_lame_init,
|
2001-12-20 23:48:55 +00:00
|
|
|
};
|
2003-12-07 14:47:09 +00:00
|
|
|
|
|
|
|
static const GInterfaceInfo tag_setter_info = {
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_lame_type =
|
2004-03-15 19:32:25 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstLame", &gst_lame_info, 0);
|
2004-03-14 22:34:30 +00:00
|
|
|
g_type_add_interface_static (gst_lame_type, GST_TYPE_TAG_SETTER,
|
2004-03-15 19:32:25 +00:00
|
|
|
&tag_setter_info);
|
2003-12-07 14:47:09 +00:00
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
return gst_lame_type;
|
|
|
|
}
|
|
|
|
|
2006-01-23 18:37:16 +00:00
|
|
|
static void
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_lame_release_memory (GstLame * lame)
|
2006-01-23 18:37:16 +00:00
|
|
|
{
|
|
|
|
g_slist_foreach (lame->tag_strings, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free (lame->tag_strings);
|
|
|
|
lame->tag_strings = NULL;
|
|
|
|
|
2006-03-15 13:43:42 +00:00
|
|
|
if (lame->tags) {
|
|
|
|
gst_tag_list_free (lame->tags);
|
|
|
|
lame->tags = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lame->lgf) {
|
|
|
|
lame_close (lame->lgf);
|
|
|
|
lame->lgf = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_lame_finalize (GObject * obj)
|
|
|
|
{
|
|
|
|
gst_lame_release_memory (GST_LAME (obj));
|
|
|
|
|
2006-01-23 18:37:16 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
|
|
|
}
|
|
|
|
|
2003-11-02 00:13:26 +00:00
|
|
|
static void
|
|
|
|
gst_lame_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2003-12-22 01:47:08 +00:00
|
|
|
gst_static_pad_template_get (&gst_lame_src_template));
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2003-12-22 01:47:08 +00:00
|
|
|
gst_static_pad_template_get (&gst_lame_sink_template));
|
2003-11-02 00:13:26 +00:00
|
|
|
gst_element_class_set_details (element_class, &gst_lame_details);
|
|
|
|
}
|
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_lame_class_init (GstLameClass * klass)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2006-03-15 13:43:42 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
gobject_class->set_property = gst_lame_set_property;
|
|
|
|
gobject_class->get_property = gst_lame_get_property;
|
2006-01-23 18:37:16 +00:00
|
|
|
gobject_class->finalize = gst_lame_finalize;
|
2005-08-16 16:12:15 +00:00
|
|
|
|
2002-09-01 15:40:39 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("bitrate", "Bitrate (kb/s)", "Bitrate in kbit/sec",
|
2004-03-15 19:32:25 +00:00
|
|
|
8, 320, 128, G_PARAM_READWRITE));
|
2004-08-12 15:48:50 +00:00
|
|
|
/* compression ratio set to 0.0 by default otherwise it overrides the bitrate setting */
|
2004-03-14 22:34:30 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_COMPRESSION_RATIO, g_param_spec_float ("compression_ratio",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Compression Ratio",
|
2004-08-12 15:48:50 +00:00
|
|
|
"let lame choose bitrate to achieve selected compression ratio", 0.0,
|
|
|
|
200.0, 0.0, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
g_param_spec_enum ("quality", "Quality",
|
|
|
|
"Quality of algorithm used for encoding", GST_TYPE_LAME_QUALITY, 5,
|
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_enum ("mode", "Mode", "Encoding mode", GST_TYPE_LAME_MODE, 0,
|
2004-03-15 19:32:25 +00:00
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FORCE_MS,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("force_ms", "Force ms",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Force ms_stereo on all frames", TRUE, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FREE_FORMAT,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("free_format", "Free format",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Produce a free format bitstream", TRUE, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COPYRIGHT,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("copyright", "Copyright", "Mark as copyright", TRUE,
|
2004-03-15 19:32:25 +00:00
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:30 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ORIGINAL,
|
|
|
|
g_param_spec_boolean ("original", "Original", "Mark as non-original",
|
2004-03-15 19:32:25 +00:00
|
|
|
TRUE, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_PROTECTION,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("error_protection", "Error protection",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Adds 16 bit checksum to every frame", TRUE, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PADDING_TYPE,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_enum ("padding_type", "Padding type", "Padding type",
|
2004-03-15 19:32:25 +00:00
|
|
|
GST_TYPE_LAME_PADDING, 0, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EXTENSION,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("extension", "Extension", "Extension", TRUE,
|
2004-03-15 19:32:25 +00:00
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STRICT_ISO,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("strict_iso", "Strict ISO",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Comply as much as possible to ISO MPEG spec", TRUE,
|
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:30 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_DISABLE_RESERVOIR, g_param_spec_boolean ("disable_reservoir",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Disable reservoir", "Disable the bit reservoir", TRUE,
|
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR,
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
g_param_spec_enum ("vbr", "VBR", "Specify bitrate mode",
|
|
|
|
GST_TYPE_LAME_VBRMODE, vbr_off, G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_QUALITY,
|
|
|
|
g_param_spec_enum ("vbr_quality", "VBR Quality", "VBR Quality",
|
|
|
|
GST_TYPE_LAME_QUALITY, 5, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MEAN_BITRATE,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("vbr_mean_bitrate", "VBR mean bitrate",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Specify mean bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MIN_BITRATE,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("vbr_min_bitrate", "VBR min bitrate",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Specify min bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
|
2004-03-14 22:34:30 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MAX_BITRATE,
|
|
|
|
g_param_spec_int ("vbr_max_bitrate", "VBR max bitrate",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Specify max bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
|
2004-03-14 22:34:30 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_HARD_MIN,
|
|
|
|
g_param_spec_int ("vbr_hard_min", "VBR hard min",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Specify hard min bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOWPASS_FREQ,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("lowpass_freq", "Lowpass freq",
|
2004-03-15 19:32:25 +00:00
|
|
|
"frequency(kHz), lowpass filter cutoff above freq", 0, 50000, 0,
|
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOWPASS_WIDTH,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("lowpass_width", "Lowpass width",
|
2004-03-15 19:32:25 +00:00
|
|
|
"frequency(kHz) - default 15% of lowpass freq", 0, G_MAXINT, 0,
|
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HIGHPASS_FREQ,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("highpass_freq", "Highpass freq",
|
2004-03-15 19:32:25 +00:00
|
|
|
"frequency(kHz), highpass filter cutoff below freq", 0, 50000, 0,
|
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HIGHPASS_WIDTH,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("highpass_width", "Highpass width",
|
2004-03-15 19:32:25 +00:00
|
|
|
"frequency(kHz) - default 15% of highpass freq", 0, G_MAXINT, 0,
|
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_ONLY,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("ath_only", "ATH only",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Ignore GPSYCHO completely, use ATH only", TRUE, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_SHORT,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("ath_short", "ATH short",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Ignore GPSYCHO for short blocks, use ATH only", TRUE,
|
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NO_ATH,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("no_ath", "No ath",
|
2004-03-15 19:32:25 +00:00
|
|
|
"turns ATH down to a flat noise floor", TRUE, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_LOWER,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("ath_lower", "ATH lower", "lowers ATH by x dB",
|
2004-03-15 19:32:25 +00:00
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CWLIMIT,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_int ("cwlimit", "Cwlimit",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Compute tonality up to freq (in kHz) default 8.8717", 0, 50000, 0,
|
|
|
|
G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ALLOW_DIFF_SHORT,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("allow_diff_short", "Allow diff short",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Allow diff short", TRUE, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NO_SHORT_BLOCKS,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("no_short_blocks", "No short blocks",
|
2004-03-15 19:32:25 +00:00
|
|
|
"Do not use short blocks", TRUE, G_PARAM_READWRITE));
|
2002-12-08 02:44:00 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EMPHASIS,
|
2004-03-14 22:34:30 +00:00
|
|
|
g_param_spec_boolean ("emphasis", "Emphasis", "Emphasis", TRUE,
|
2004-03-15 19:32:25 +00:00
|
|
|
G_PARAM_READWRITE));
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_XINGHEADER,
|
|
|
|
g_param_spec_boolean ("xingheader", "Output Xing Header",
|
2006-03-12 11:00:33 +00:00
|
|
|
"Output Xing Header (BROKEN, use xingmux instead)",
|
|
|
|
FALSE, G_PARAM_READWRITE));
|
2004-08-19 22:44:50 +00:00
|
|
|
#ifdef GSTLAME_PRESET
|
2004-08-13 15:22:49 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PRESET,
|
|
|
|
g_param_spec_enum ("preset", "Lame Preset", "Lame Preset",
|
|
|
|
GST_TYPE_LAME_PRESET, 0, G_PARAM_READWRITE));
|
2004-08-19 22:44:50 +00:00
|
|
|
#endif
|
2001-12-21 12:47:09 +00:00
|
|
|
|
2006-03-15 13:43:42 +00:00
|
|
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_lame_change_state);
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
static gboolean
|
|
|
|
gst_lame_sink_setcaps (GstPad * pad, GstCaps * caps)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
|
|
|
GstLame *lame;
|
2003-09-30 19:48:39 +00:00
|
|
|
gint out_samplerate;
|
2003-12-22 01:47:08 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
GstCaps *othercaps;
|
2001-12-20 23:48:55 +00:00
|
|
|
|
|
|
|
lame = GST_LAME (gst_pad_get_parent (pad));
|
2003-12-22 01:47:08 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
if (!gst_structure_get_int (structure, "rate", &lame->samplerate))
|
|
|
|
goto no_rate;
|
|
|
|
if (!gst_structure_get_int (structure, "channels", &lame->num_channels))
|
|
|
|
goto no_channels;
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2005-09-16 16:04:28 +00:00
|
|
|
GST_DEBUG_OBJECT (lame, "sink_setcaps, setting up lame");
|
2005-08-16 16:12:15 +00:00
|
|
|
if (!gst_lame_setup (lame))
|
|
|
|
goto setup_failed;
|
2002-01-13 22:27:24 +00:00
|
|
|
|
2005-09-16 16:04:28 +00:00
|
|
|
|
2003-09-30 19:48:39 +00:00
|
|
|
out_samplerate = lame_get_out_samplerate (lame->lgf);
|
2005-09-16 16:04:28 +00:00
|
|
|
if (out_samplerate == 0)
|
|
|
|
goto zero_output_rate;
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
othercaps =
|
|
|
|
gst_caps_new_simple ("audio/mpeg",
|
|
|
|
"mpegversion", G_TYPE_INT, 1,
|
|
|
|
"layer", G_TYPE_INT, 3,
|
|
|
|
"channels", G_TYPE_INT, lame->num_channels,
|
|
|
|
"rate", G_TYPE_INT, out_samplerate, NULL);
|
2003-12-22 01:47:08 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
/* and use these caps */
|
|
|
|
gst_pad_set_caps (lame->srcpad, othercaps);
|
|
|
|
gst_caps_unref (othercaps);
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_object_unref (lame);
|
2005-08-16 16:12:15 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
no_rate:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
|
|
|
|
("no rate specified in input"));
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_object_unref (lame);
|
2005-08-16 16:12:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
no_channels:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
|
|
|
|
("no channels specified in input"));
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_object_unref (lame);
|
2005-08-16 16:12:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-09-16 16:04:28 +00:00
|
|
|
zero_output_rate:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
|
|
|
|
("lame decided on a zero sample rate"));
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_object_unref (lame);
|
2005-09-16 16:04:28 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-08-16 16:12:15 +00:00
|
|
|
setup_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
|
|
|
|
("could not initialize encoder (wrong parameters?)"));
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_object_unref (lame);
|
2005-08-16 16:12:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_lame_init (GstLame * lame)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
2003-06-29 19:46:09 +00:00
|
|
|
GST_DEBUG_OBJECT (lame, "starting initialization");
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
lame->sinkpad =
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_lame_sink_template, "sink");
|
|
|
|
gst_pad_set_event_function (lame->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_lame_sink_event));
|
|
|
|
gst_pad_set_chain_function (lame->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_lame_chain));
|
|
|
|
gst_pad_set_setcaps_function (lame->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_lame_sink_setcaps));
|
2005-08-16 16:12:15 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (lame), lame->sinkpad);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
lame->srcpad =
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_lame_src_template, "src");
|
2005-08-16 16:12:15 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (lame), lame->srcpad);
|
2002-02-19 17:29:55 +00:00
|
|
|
|
2005-09-16 16:04:28 +00:00
|
|
|
/* create an encoder state so we can ask about defaults */
|
2001-12-21 12:47:09 +00:00
|
|
|
lame->lgf = lame_init ();
|
2001-12-20 23:48:55 +00:00
|
|
|
|
|
|
|
lame->samplerate = 44100;
|
|
|
|
lame->num_channels = 2;
|
2005-09-16 16:04:28 +00:00
|
|
|
lame->setup = FALSE;
|
|
|
|
|
|
|
|
lame->bitrate = 128; /* lame_get_brate (lame->lgf);
|
|
|
|
* => 0/out of range */
|
|
|
|
lame->compression_ratio = 0.0; /* lame_get_compression_ratio (lame->lgf);
|
|
|
|
* => 0/out of range ...
|
|
|
|
* NOTE: 0.0 makes bitrate take precedence */
|
|
|
|
lame->quality = 5; /* lame_get_quality (lame->lgf);
|
|
|
|
* => -1/out of range */
|
2001-12-21 12:47:09 +00:00
|
|
|
lame->mode = lame_get_mode (lame->lgf);
|
|
|
|
lame->force_ms = lame_get_force_ms (lame->lgf);
|
|
|
|
lame->free_format = lame_get_free_format (lame->lgf);
|
|
|
|
lame->copyright = lame_get_copyright (lame->lgf);
|
|
|
|
lame->original = lame_get_original (lame->lgf);
|
|
|
|
lame->error_protection = lame_get_error_protection (lame->lgf);
|
|
|
|
lame->padding_type = lame_get_padding_type (lame->lgf);
|
|
|
|
lame->extension = lame_get_extension (lame->lgf);
|
|
|
|
lame->strict_iso = lame_get_strict_ISO (lame->lgf);
|
|
|
|
lame->disable_reservoir = lame_get_disable_reservoir (lame->lgf);
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
lame->vbr = vbr_off; /* lame_get_VBR (lame->lgf); */
|
|
|
|
lame->vbr_quality = 5;
|
2001-12-21 12:47:09 +00:00
|
|
|
lame->vbr_mean_bitrate = lame_get_VBR_mean_bitrate_kbps (lame->lgf);
|
|
|
|
lame->vbr_min_bitrate = lame_get_VBR_min_bitrate_kbps (lame->lgf);
|
2006-02-16 17:16:06 +00:00
|
|
|
lame->vbr_max_bitrate = 0; /* lame_get_VBR_max_bitrate_kbps (lame->lgf);
|
2005-09-16 16:04:28 +00:00
|
|
|
* => 0/no vbr possible */
|
2001-12-21 12:47:09 +00:00
|
|
|
lame->vbr_hard_min = lame_get_VBR_hard_min (lame->lgf);
|
2005-09-16 16:04:28 +00:00
|
|
|
/* lame->lowpass_freq = 50000; lame_get_lowpassfreq (lame->lgf);
|
|
|
|
* => 0/lowpass on everything ? */
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
lame->lowpass_freq = 0;
|
2005-09-16 16:04:28 +00:00
|
|
|
lame->lowpass_width = 0; /* lame_get_lowpasswidth (lame->lgf);
|
|
|
|
* => -1/out of range */
|
2001-12-21 12:47:09 +00:00
|
|
|
lame->highpass_freq = lame_get_highpassfreq (lame->lgf);
|
2005-09-16 16:04:28 +00:00
|
|
|
lame->highpass_width = 0; /* lame_get_highpasswidth (lame->lgf);
|
|
|
|
* => -1/out of range */
|
2001-12-21 12:47:09 +00:00
|
|
|
lame->ath_only = lame_get_ATHonly (lame->lgf);
|
|
|
|
lame->ath_short = lame_get_ATHshort (lame->lgf);
|
|
|
|
lame->no_ath = lame_get_noATH (lame->lgf);
|
|
|
|
/* lame->ath_type = lame_get_ATHtype (lame->lgf); */
|
|
|
|
lame->ath_lower = lame_get_ATHlower (lame->lgf);
|
2004-05-03 16:46:10 +00:00
|
|
|
lame->cwlimit = 8.8717; /* lame_get_cwlimit (lame->lgf); => 0 */
|
2001-12-21 12:47:09 +00:00
|
|
|
lame->allow_diff_short = lame_get_allow_diff_short (lame->lgf);
|
ext/lame/gstlame.c: add debugging category, add error checks like checking return values of setup calls, make sure it...
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_link), (gst_lame_init),
(gst_lame_chain), (gst_lame_setup), (gst_lame_change_state),
(plugin_init):
add debugging category, add error checks like checking return values
of setup calls, make sure it still works after
PLAYING=>NULL=>PLAYING, fix encoding of mono streams
2004-07-26 15:42:18 +00:00
|
|
|
lame->no_short_blocks = TRUE; /* lame_get_no_short_blocks (lame->lgf); */
|
2001-12-21 12:47:09 +00:00
|
|
|
lame->emphasis = lame_get_emphasis (lame->lgf);
|
2004-08-13 15:22:49 +00:00
|
|
|
lame->preset = 0;
|
2005-09-16 16:04:28 +00:00
|
|
|
lame_close (lame->lgf);
|
|
|
|
lame->lgf = NULL;
|
2006-01-23 18:37:16 +00:00
|
|
|
lame->tag_strings = NULL;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2003-06-29 19:46:09 +00:00
|
|
|
GST_DEBUG_OBJECT (lame, "done initializing");
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
|
2003-12-07 14:47:09 +00:00
|
|
|
typedef struct _GstLameTagMatch GstLameTagMatch;
|
2004-03-14 22:34:30 +00:00
|
|
|
typedef void (*GstLameTagFunc) (lame_global_flags * gfp, const char *value);
|
2003-12-07 14:47:09 +00:00
|
|
|
|
|
|
|
struct _GstLameTagMatch
|
2003-07-05 22:48:58 +00:00
|
|
|
{
|
2003-12-07 14:47:09 +00:00
|
|
|
gchar *gstreamer_tag;
|
|
|
|
GstLameTagFunc tag_func;
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static GstLameTagMatch tag_matches[] = {
|
|
|
|
{GST_TAG_TITLE, id3tag_set_title},
|
|
|
|
{GST_TAG_DATE, id3tag_set_year},
|
|
|
|
{GST_TAG_TRACK_NUMBER, id3tag_set_track},
|
|
|
|
{GST_TAG_COMMENT, id3tag_set_comment},
|
|
|
|
{GST_TAG_ARTIST, id3tag_set_artist},
|
|
|
|
{GST_TAG_ALBUM, id3tag_set_album},
|
|
|
|
{GST_TAG_GENRE, (GstLameTagFunc) id3tag_set_genre},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2003-12-07 14:47:09 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void
|
|
|
|
add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
|
2003-12-07 14:47:09 +00:00
|
|
|
{
|
|
|
|
GstLame *lame;
|
2006-01-23 15:02:04 +00:00
|
|
|
gchar *value = NULL;
|
2003-12-07 14:47:09 +00:00
|
|
|
int i = 0;
|
2003-07-05 22:48:58 +00:00
|
|
|
|
2003-12-07 14:47:09 +00:00
|
|
|
lame = GST_LAME (user_data);
|
|
|
|
g_return_if_fail (lame != NULL);
|
|
|
|
|
|
|
|
while (tag_matches[i].gstreamer_tag != NULL) {
|
|
|
|
if (strcmp (tag, tag_matches[i].gstreamer_tag) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2003-12-07 14:47:09 +00:00
|
|
|
if (tag_matches[i].tag_func == NULL) {
|
2005-09-16 16:04:28 +00:00
|
|
|
GST_WARNING_OBJECT (lame,
|
|
|
|
"Couldn't find matching gstreamer tag for \"%s\"", tag);
|
2003-07-05 22:48:58 +00:00
|
|
|
return;
|
2003-12-07 14:47:09 +00:00
|
|
|
}
|
2003-07-05 22:48:58 +00:00
|
|
|
|
2003-12-07 14:47:09 +00:00
|
|
|
switch (gst_tag_get_type (tag)) {
|
2004-03-14 22:34:30 +00:00
|
|
|
case G_TYPE_UINT:{
|
|
|
|
guint ivalue;
|
|
|
|
|
|
|
|
if (!gst_tag_list_get_uint (list, tag, &ivalue)) {
|
2005-09-16 16:04:28 +00:00
|
|
|
GST_WARNING_OBJECT (lame, "Error reading \"%s\" tag value", tag);
|
2004-03-15 19:32:25 +00:00
|
|
|
return;
|
2004-03-14 22:34:30 +00:00
|
|
|
}
|
|
|
|
value = g_strdup_printf ("%u", ivalue);
|
|
|
|
break;
|
2003-07-05 22:48:58 +00:00
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
case G_TYPE_STRING:
|
|
|
|
if (!gst_tag_list_get_string (list, tag, &value)) {
|
2005-09-16 16:04:28 +00:00
|
|
|
GST_WARNING_OBJECT (lame, "Error reading \"%s\" tag value", tag);
|
2004-03-15 19:32:25 +00:00
|
|
|
return;
|
2004-03-14 22:34:30 +00:00
|
|
|
};
|
|
|
|
break;
|
2006-01-23 15:02:04 +00:00
|
|
|
default:{
|
|
|
|
if (strcmp (tag, GST_TAG_DATE) == 0) {
|
|
|
|
GDate *date = NULL;
|
|
|
|
|
|
|
|
if (!gst_tag_list_get_date (list, tag, &date) || date == NULL) {
|
|
|
|
GST_WARNING_OBJECT (lame, "Error reading \"%s\" tag value", tag);
|
|
|
|
} else {
|
|
|
|
value = g_strdup_printf ("%u", g_date_get_year (date));
|
|
|
|
g_date_free (date);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (lame, "Couldn't write tag %s", tag);
|
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
break;
|
2006-01-23 15:02:04 +00:00
|
|
|
}
|
2003-12-07 14:47:09 +00:00
|
|
|
}
|
|
|
|
|
2006-01-23 15:02:04 +00:00
|
|
|
if (value != NULL && *value != '\0') {
|
|
|
|
GST_LOG_OBJECT (lame, "Adding tag %s:%s", tag, value);
|
|
|
|
tag_matches[i].tag_func (lame->lgf, value);
|
2003-07-05 22:48:58 +00:00
|
|
|
}
|
2006-01-23 15:02:04 +00:00
|
|
|
|
2006-01-23 18:37:16 +00:00
|
|
|
/* lame does not copy strings passed to it and expects them
|
|
|
|
* to be around later, but it does not free them for us either,
|
|
|
|
* so we just add them to a list and free it later when it's safe */
|
|
|
|
lame->tag_strings = g_slist_prepend (lame->tag_strings, value);
|
2003-07-05 22:48:58 +00:00
|
|
|
}
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2003-12-07 14:47:09 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_lame_set_metadata (GstLame * lame)
|
2003-12-07 14:47:09 +00:00
|
|
|
{
|
|
|
|
const GstTagList *user_tags;
|
|
|
|
GstTagList *copy;
|
|
|
|
|
|
|
|
g_return_if_fail (lame != NULL);
|
2005-09-16 16:04:28 +00:00
|
|
|
|
2005-11-22 12:39:29 +00:00
|
|
|
user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (lame));
|
2006-01-23 18:37:16 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (lame, "lame->tags = %" GST_PTR_FORMAT, lame->tags);
|
|
|
|
GST_DEBUG_OBJECT (lame, "user tags = %" GST_PTR_FORMAT, user_tags);
|
|
|
|
|
2003-12-07 14:47:09 +00:00
|
|
|
if ((lame->tags == NULL) && (user_tags == NULL)) {
|
|
|
|
return;
|
|
|
|
}
|
2006-01-23 18:37:16 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
copy = gst_tag_list_merge (user_tags, lame->tags,
|
2005-11-22 12:39:29 +00:00
|
|
|
gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (lame)));
|
2006-01-23 18:37:16 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (lame, "merged tags = %" GST_PTR_FORMAT, copy);
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_tag_list_foreach ((GstTagList *) copy, add_one_tag, lame);
|
2003-12-07 14:47:09 +00:00
|
|
|
|
|
|
|
gst_tag_list_free (copy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_lame_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
|
|
|
GstLame *lame;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_LAME (object));
|
|
|
|
|
|
|
|
lame = GST_LAME (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_BITRATE:
|
|
|
|
lame->bitrate = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_COMPRESSION_RATIO:
|
|
|
|
lame->compression_ratio = g_value_get_float (value);
|
|
|
|
break;
|
|
|
|
case ARG_QUALITY:
|
2002-03-27 04:02:38 +00:00
|
|
|
lame->quality = g_value_get_enum (value);
|
2001-12-20 23:48:55 +00:00
|
|
|
break;
|
|
|
|
case ARG_MODE:
|
2002-03-27 04:02:38 +00:00
|
|
|
lame->mode = g_value_get_enum (value);
|
2001-12-20 23:48:55 +00:00
|
|
|
break;
|
|
|
|
case ARG_FORCE_MS:
|
|
|
|
lame->force_ms = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_FREE_FORMAT:
|
|
|
|
lame->free_format = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_COPYRIGHT:
|
|
|
|
lame->copyright = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_ORIGINAL:
|
|
|
|
lame->original = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_ERROR_PROTECTION:
|
|
|
|
lame->error_protection = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_PADDING_TYPE:
|
|
|
|
lame->padding_type = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_EXTENSION:
|
|
|
|
lame->extension = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_STRICT_ISO:
|
|
|
|
lame->strict_iso = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_DISABLE_RESERVOIR:
|
|
|
|
lame->disable_reservoir = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_VBR:
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
lame->vbr = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case ARG_VBR_QUALITY:
|
|
|
|
lame->vbr_quality = g_value_get_enum (value);
|
2001-12-20 23:48:55 +00:00
|
|
|
break;
|
|
|
|
case ARG_VBR_MEAN_BITRATE:
|
|
|
|
lame->vbr_mean_bitrate = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_VBR_MIN_BITRATE:
|
|
|
|
lame->vbr_min_bitrate = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_VBR_MAX_BITRATE:
|
|
|
|
lame->vbr_max_bitrate = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_VBR_HARD_MIN:
|
|
|
|
lame->vbr_hard_min = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_LOWPASS_FREQ:
|
|
|
|
lame->lowpass_freq = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_LOWPASS_WIDTH:
|
|
|
|
lame->lowpass_width = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_HIGHPASS_FREQ:
|
|
|
|
lame->highpass_freq = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_HIGHPASS_WIDTH:
|
|
|
|
lame->highpass_width = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_ATH_ONLY:
|
|
|
|
lame->ath_only = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_ATH_SHORT:
|
|
|
|
lame->ath_short = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_NO_ATH:
|
|
|
|
lame->no_ath = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_ATH_LOWER:
|
|
|
|
lame->ath_lower = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_CWLIMIT:
|
|
|
|
lame->cwlimit = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_ALLOW_DIFF_SHORT:
|
|
|
|
lame->allow_diff_short = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_NO_SHORT_BLOCKS:
|
|
|
|
lame->no_short_blocks = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_EMPHASIS:
|
|
|
|
lame->emphasis = g_value_get_boolean (value);
|
|
|
|
break;
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
case ARG_XINGHEADER:
|
|
|
|
break;
|
2004-08-19 22:44:50 +00:00
|
|
|
#ifdef GSTLAME_PRESET
|
2004-08-13 15:22:49 +00:00
|
|
|
case ARG_PRESET:
|
|
|
|
lame->preset = g_value_get_enum (value);
|
|
|
|
break;
|
2004-08-19 22:44:50 +00:00
|
|
|
#endif
|
2001-12-20 23:48:55 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_lame_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
|
|
|
GstLame *lame;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_LAME (object));
|
|
|
|
|
|
|
|
lame = GST_LAME (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_BITRATE:
|
|
|
|
g_value_set_int (value, lame->bitrate);
|
|
|
|
break;
|
|
|
|
case ARG_COMPRESSION_RATIO:
|
|
|
|
g_value_set_float (value, lame->compression_ratio);
|
|
|
|
break;
|
|
|
|
case ARG_QUALITY:
|
|
|
|
g_value_set_enum (value, lame->quality);
|
|
|
|
break;
|
|
|
|
case ARG_MODE:
|
|
|
|
g_value_set_enum (value, lame->mode);
|
|
|
|
break;
|
|
|
|
case ARG_FORCE_MS:
|
|
|
|
g_value_set_boolean (value, lame->force_ms);
|
|
|
|
break;
|
|
|
|
case ARG_FREE_FORMAT:
|
|
|
|
g_value_set_boolean (value, lame->free_format);
|
|
|
|
break;
|
|
|
|
case ARG_COPYRIGHT:
|
|
|
|
g_value_set_boolean (value, lame->copyright);
|
|
|
|
break;
|
|
|
|
case ARG_ORIGINAL:
|
|
|
|
g_value_set_boolean (value, lame->original);
|
|
|
|
break;
|
|
|
|
case ARG_ERROR_PROTECTION:
|
|
|
|
g_value_set_boolean (value, lame->error_protection);
|
|
|
|
break;
|
|
|
|
case ARG_PADDING_TYPE:
|
|
|
|
g_value_set_enum (value, lame->padding_type);
|
|
|
|
break;
|
|
|
|
case ARG_EXTENSION:
|
|
|
|
g_value_set_boolean (value, lame->extension);
|
|
|
|
break;
|
|
|
|
case ARG_STRICT_ISO:
|
|
|
|
g_value_set_boolean (value, lame->strict_iso);
|
|
|
|
break;
|
|
|
|
case ARG_DISABLE_RESERVOIR:
|
|
|
|
g_value_set_boolean (value, lame->disable_reservoir);
|
|
|
|
break;
|
|
|
|
case ARG_VBR:
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
g_value_set_enum (value, lame->vbr);
|
|
|
|
break;
|
|
|
|
case ARG_VBR_QUALITY:
|
|
|
|
g_value_set_enum (value, lame->vbr_quality);
|
2001-12-20 23:48:55 +00:00
|
|
|
break;
|
|
|
|
case ARG_VBR_MEAN_BITRATE:
|
|
|
|
g_value_set_int (value, lame->vbr_mean_bitrate);
|
|
|
|
break;
|
|
|
|
case ARG_VBR_MIN_BITRATE:
|
|
|
|
g_value_set_int (value, lame->vbr_min_bitrate);
|
|
|
|
break;
|
|
|
|
case ARG_VBR_MAX_BITRATE:
|
|
|
|
g_value_set_int (value, lame->vbr_max_bitrate);
|
|
|
|
break;
|
|
|
|
case ARG_VBR_HARD_MIN:
|
|
|
|
g_value_set_int (value, lame->vbr_hard_min);
|
|
|
|
break;
|
|
|
|
case ARG_LOWPASS_FREQ:
|
|
|
|
g_value_set_int (value, lame->lowpass_freq);
|
|
|
|
break;
|
|
|
|
case ARG_LOWPASS_WIDTH:
|
|
|
|
g_value_set_int (value, lame->lowpass_width);
|
|
|
|
break;
|
|
|
|
case ARG_HIGHPASS_FREQ:
|
|
|
|
g_value_set_int (value, lame->highpass_freq);
|
|
|
|
break;
|
|
|
|
case ARG_HIGHPASS_WIDTH:
|
|
|
|
g_value_set_int (value, lame->highpass_width);
|
|
|
|
break;
|
|
|
|
case ARG_ATH_ONLY:
|
|
|
|
g_value_set_boolean (value, lame->ath_only);
|
|
|
|
break;
|
|
|
|
case ARG_ATH_SHORT:
|
|
|
|
g_value_set_boolean (value, lame->ath_short);
|
|
|
|
break;
|
|
|
|
case ARG_NO_ATH:
|
|
|
|
g_value_set_boolean (value, lame->no_ath);
|
|
|
|
break;
|
|
|
|
case ARG_ATH_LOWER:
|
|
|
|
g_value_set_int (value, lame->ath_lower);
|
|
|
|
break;
|
|
|
|
case ARG_CWLIMIT:
|
|
|
|
g_value_set_int (value, lame->cwlimit);
|
|
|
|
break;
|
|
|
|
case ARG_ALLOW_DIFF_SHORT:
|
|
|
|
g_value_set_boolean (value, lame->allow_diff_short);
|
|
|
|
break;
|
|
|
|
case ARG_NO_SHORT_BLOCKS:
|
|
|
|
g_value_set_boolean (value, lame->no_short_blocks);
|
|
|
|
break;
|
|
|
|
case ARG_EMPHASIS:
|
|
|
|
g_value_set_boolean (value, lame->emphasis);
|
|
|
|
break;
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
case ARG_XINGHEADER:
|
2004-08-13 14:55:27 +00:00
|
|
|
break;
|
2004-08-19 22:44:50 +00:00
|
|
|
#ifdef GSTLAME_PRESET
|
2004-08-13 15:22:49 +00:00
|
|
|
case ARG_PRESET:
|
|
|
|
g_value_set_enum (value, lame->preset);
|
|
|
|
break;
|
2004-08-19 22:44:50 +00:00
|
|
|
#endif
|
2001-12-20 23:48:55 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
static gboolean
|
|
|
|
gst_lame_sink_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
2006-03-28 15:10:18 +00:00
|
|
|
gboolean ret;
|
2005-08-16 16:12:15 +00:00
|
|
|
GstLame *lame;
|
|
|
|
|
|
|
|
lame = GST_LAME (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2006-03-28 15:10:18 +00:00
|
|
|
case GST_EVENT_EOS:{
|
|
|
|
GstBuffer *buf;
|
|
|
|
gint size;
|
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
GST_DEBUG_OBJECT (lame, "handling EOS event");
|
2006-03-28 15:10:18 +00:00
|
|
|
buf = gst_buffer_new_and_alloc (7200);
|
|
|
|
size = lame_encode_flush (lame->lgf, GST_BUFFER_DATA (buf), 7200);
|
|
|
|
if (size > 0) {
|
|
|
|
GST_BUFFER_SIZE (buf) = size;
|
|
|
|
GST_DEBUG_OBJECT (lame, "pushing final packet of %u bytes", size);
|
|
|
|
gst_buffer_set_caps (buf, GST_PAD_CAPS (lame->srcpad));
|
|
|
|
gst_pad_push (lame->srcpad, buf);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (lame, "no final packet (size=%d)", size);
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
}
|
2005-08-16 16:12:15 +00:00
|
|
|
|
2006-03-28 15:10:18 +00:00
|
|
|
ret = gst_pad_event_default (pad, event);
|
2005-08-16 16:12:15 +00:00
|
|
|
break;
|
2006-03-28 15:10:18 +00:00
|
|
|
}
|
2005-08-16 16:12:15 +00:00
|
|
|
case GST_EVENT_FLUSH_START:
|
|
|
|
GST_DEBUG_OBJECT (lame, "handling FLUSH start event");
|
|
|
|
/* forward event */
|
2006-03-28 15:10:18 +00:00
|
|
|
ret = gst_pad_push_event (lame->srcpad, event);
|
2005-08-16 16:12:15 +00:00
|
|
|
break;
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
|
|
|
{
|
|
|
|
guchar *mp3_data = NULL;
|
|
|
|
gint mp3_buffer_size, mp3_size = 0;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (lame, "handling FLUSH stop event");
|
|
|
|
|
|
|
|
/* clear buffers */
|
|
|
|
mp3_buffer_size = 7200;
|
|
|
|
mp3_data = g_malloc (mp3_buffer_size);
|
|
|
|
mp3_size = lame_encode_flush (lame->lgf, mp3_data, mp3_buffer_size);
|
|
|
|
|
2006-03-28 15:10:18 +00:00
|
|
|
ret = gst_pad_push_event (lame->srcpad, event);
|
2005-08-16 16:12:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_EVENT_TAG:
|
|
|
|
GST_DEBUG_OBJECT (lame, "handling TAG event");
|
|
|
|
if (lame->tags) {
|
|
|
|
GstTagList *taglist;
|
|
|
|
|
|
|
|
gst_event_parse_tag (event, &taglist),
|
|
|
|
gst_tag_list_insert (lame->tags, taglist,
|
2005-11-22 12:39:29 +00:00
|
|
|
gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (lame)));
|
2005-08-16 16:12:15 +00:00
|
|
|
} else {
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2006-03-28 15:10:18 +00:00
|
|
|
ret = gst_pad_push_event (lame->srcpad, event);
|
2005-08-16 16:12:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
2006-03-28 15:10:18 +00:00
|
|
|
ret = gst_pad_event_default (pad, event);
|
2005-08-16 16:12:15 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_object_unref (lame);
|
2006-03-28 15:10:18 +00:00
|
|
|
return ret;
|
2005-08-16 16:12:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_lame_chain (GstPad * pad, GstBuffer * buf)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
|
|
|
GstLame *lame;
|
2005-08-17 19:05:51 +00:00
|
|
|
guchar *mp3_data;
|
|
|
|
gint mp3_buffer_size, mp3_size;
|
2005-08-16 16:12:15 +00:00
|
|
|
gint64 duration;
|
|
|
|
GstFlowReturn result;
|
2005-08-17 19:05:51 +00:00
|
|
|
gint num_samples;
|
2006-02-16 17:16:06 +00:00
|
|
|
guint8 *data;
|
|
|
|
guint size;
|
2001-12-20 23:48:55 +00:00
|
|
|
|
|
|
|
lame = GST_LAME (gst_pad_get_parent (pad));
|
|
|
|
|
2004-08-09 09:22:12 +00:00
|
|
|
GST_LOG_OBJECT (lame, "entered chain");
|
2001-12-21 12:47:09 +00:00
|
|
|
|
2005-09-16 16:04:28 +00:00
|
|
|
if (!lame->setup)
|
|
|
|
goto not_setup;
|
2005-08-16 16:12:15 +00:00
|
|
|
|
2006-02-16 17:16:06 +00:00
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
|
|
|
|
|
|
|
num_samples = size / 2;
|
2005-08-17 19:05:51 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
/* allocate space for output */
|
2005-08-17 19:05:51 +00:00
|
|
|
mp3_buffer_size = 1.25 * num_samples + 7200;
|
2005-08-16 16:12:15 +00:00
|
|
|
mp3_data = g_malloc (mp3_buffer_size);
|
|
|
|
|
|
|
|
/* lame seems to be too stupid to get mono interleaved going */
|
|
|
|
if (lame->num_channels == 1) {
|
|
|
|
mp3_size = lame_encode_buffer (lame->lgf,
|
2006-02-16 17:16:06 +00:00
|
|
|
(short int *) data,
|
|
|
|
(short int *) data, num_samples, mp3_data, mp3_buffer_size);
|
2004-03-14 22:34:30 +00:00
|
|
|
} else {
|
2005-08-16 16:12:15 +00:00
|
|
|
mp3_size = lame_encode_buffer_interleaved (lame->lgf,
|
2006-02-16 17:16:06 +00:00
|
|
|
(short int *) data,
|
2005-08-17 19:05:51 +00:00
|
|
|
num_samples / lame->num_channels, mp3_data, mp3_buffer_size);
|
2005-08-16 16:12:15 +00:00
|
|
|
}
|
2003-06-07 00:34:51 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
GST_LOG_OBJECT (lame, "encoded %d bytes of audio to %d bytes of mp3",
|
|
|
|
GST_BUFFER_SIZE (buf), mp3_size);
|
2002-07-07 14:06:38 +00:00
|
|
|
|
2006-02-16 17:16:06 +00:00
|
|
|
duration = gst_util_uint64_scale_int (size, GST_SECOND,
|
|
|
|
2 * lame->samplerate * lame->num_channels);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE &&
|
|
|
|
GST_BUFFER_DURATION (buf) != duration)
|
|
|
|
GST_DEBUG_OBJECT (lame, "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));
|
2003-05-12 20:08:17 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
if (lame->last_ts == GST_CLOCK_TIME_NONE) {
|
|
|
|
lame->last_ts = GST_BUFFER_TIMESTAMP (buf);
|
|
|
|
lame->last_offs = GST_BUFFER_OFFSET (buf);
|
|
|
|
lame->last_duration = duration;
|
|
|
|
} else {
|
|
|
|
lame->last_duration += duration;
|
2001-12-21 12:47:09 +00:00
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
2005-08-17 19:05:51 +00:00
|
|
|
if (mp3_size < 0) {
|
|
|
|
g_warning ("error %d", mp3_size);
|
|
|
|
}
|
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
if (mp3_size > 0) {
|
2005-08-17 19:05:51 +00:00
|
|
|
GstBuffer *outbuf;
|
|
|
|
|
2001-12-20 23:48:55 +00:00
|
|
|
outbuf = gst_buffer_new ();
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_BUFFER_DATA (outbuf) = mp3_data;
|
2005-08-17 19:05:51 +00:00
|
|
|
GST_BUFFER_MALLOCDATA (outbuf) = mp3_data;
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_BUFFER_SIZE (outbuf) = mp3_size;
|
2003-05-13 12:28:16 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = lame->last_ts;
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_BUFFER_OFFSET (outbuf) = lame->last_offs;
|
|
|
|
GST_BUFFER_DURATION (outbuf) = lame->last_duration;
|
2005-09-19 11:07:40 +00:00
|
|
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (lame->srcpad));
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
result = gst_pad_push (lame->srcpad, outbuf);
|
2003-05-29 12:41:42 +00:00
|
|
|
|
|
|
|
lame->last_ts = GST_CLOCK_TIME_NONE;
|
2004-03-14 22:34:30 +00:00
|
|
|
} else {
|
2001-12-21 12:47:09 +00:00
|
|
|
g_free (mp3_data);
|
2005-08-16 16:12:15 +00:00
|
|
|
result = GST_FLOW_OK;
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
2005-08-16 16:12:15 +00:00
|
|
|
gst_object_unref (lame);
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
return result;
|
|
|
|
|
|
|
|
/* ERRORS */
|
2005-09-16 16:04:28 +00:00
|
|
|
not_setup:
|
2005-08-16 16:12:15 +00:00
|
|
|
{
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
|
|
|
|
("encoder not initialized (input is not audio?)"));
|
|
|
|
gst_object_unref (lame);
|
|
|
|
return GST_FLOW_ERROR;
|
2001-12-21 12:47:09 +00:00
|
|
|
}
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
|
2005-09-16 16:04:28 +00:00
|
|
|
/* set up the encoder state */
|
2001-12-20 23:48:55 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_lame_setup (GstLame * lame)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
ext/lame/gstlame.c: add debugging category, add error checks like checking return values of setup calls, make sure it...
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_link), (gst_lame_init),
(gst_lame_chain), (gst_lame_setup), (gst_lame_change_state),
(plugin_init):
add debugging category, add error checks like checking return values
of setup calls, make sure it still works after
PLAYING=>NULL=>PLAYING, fix encoding of mono streams
2004-07-26 15:42:18 +00:00
|
|
|
#define CHECK_ERROR(command) G_STMT_START {\
|
|
|
|
if ((command) < 0) { \
|
|
|
|
GST_ERROR_OBJECT (lame, "setup failed: " G_STRINGIFY (command)); \
|
|
|
|
return FALSE; \
|
|
|
|
} \
|
|
|
|
}G_STMT_END
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
int retval;
|
|
|
|
|
2003-06-29 19:46:09 +00:00
|
|
|
GST_DEBUG_OBJECT (lame, "starting setup");
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2005-09-16 16:04:28 +00:00
|
|
|
/* check if we're already setup; if we are, we might want to check
|
2002-10-02 08:04:00 +00:00
|
|
|
* if this initialization is compatible with the previous one */
|
|
|
|
/* FIXME: do this */
|
2005-09-16 16:04:28 +00:00
|
|
|
if (lame->setup) {
|
|
|
|
GST_WARNING_OBJECT (lame, "already setup");
|
|
|
|
lame->setup = FALSE;
|
ext/lame/gstlame.c: add debugging category, add error checks like checking return values of setup calls, make sure it...
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_link), (gst_lame_init),
(gst_lame_chain), (gst_lame_setup), (gst_lame_change_state),
(plugin_init):
add debugging category, add error checks like checking return values
of setup calls, make sure it still works after
PLAYING=>NULL=>PLAYING, fix encoding of mono streams
2004-07-26 15:42:18 +00:00
|
|
|
}
|
2002-02-19 12:55:16 +00:00
|
|
|
|
2005-09-16 16:04:28 +00:00
|
|
|
lame->lgf = lame_init ();
|
|
|
|
id3tag_init (lame->lgf);
|
|
|
|
|
|
|
|
/* let lame choose a default samplerate */
|
|
|
|
lame_set_out_samplerate (lame->lgf, 0);
|
|
|
|
|
2001-12-21 12:47:09 +00:00
|
|
|
/* copy the parameters over */
|
|
|
|
lame_set_in_samplerate (lame->lgf, lame->samplerate);
|
2002-02-19 12:55:16 +00:00
|
|
|
|
2001-12-21 12:47:09 +00:00
|
|
|
/* force mono encoding if we only have one channel */
|
2004-03-14 22:34:30 +00:00
|
|
|
if (lame->num_channels == 1)
|
2001-12-20 23:48:55 +00:00
|
|
|
lame->mode = 3;
|
|
|
|
|
ext/lame/gstlame.c: add debugging category, add error checks like checking return values of setup calls, make sure it...
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_link), (gst_lame_init),
(gst_lame_chain), (gst_lame_setup), (gst_lame_change_state),
(plugin_init):
add debugging category, add error checks like checking return values
of setup calls, make sure it still works after
PLAYING=>NULL=>PLAYING, fix encoding of mono streams
2004-07-26 15:42:18 +00:00
|
|
|
CHECK_ERROR (lame_set_num_channels (lame->lgf, lame->num_channels));
|
|
|
|
CHECK_ERROR (lame_set_brate (lame->lgf, lame->bitrate));
|
|
|
|
CHECK_ERROR (lame_set_compression_ratio (lame->lgf, lame->compression_ratio));
|
|
|
|
CHECK_ERROR (lame_set_quality (lame->lgf, lame->quality));
|
|
|
|
CHECK_ERROR (lame_set_mode (lame->lgf, lame->mode));
|
|
|
|
CHECK_ERROR (lame_set_force_ms (lame->lgf, lame->force_ms));
|
|
|
|
CHECK_ERROR (lame_set_free_format (lame->lgf, lame->free_format));
|
|
|
|
CHECK_ERROR (lame_set_copyright (lame->lgf, lame->copyright));
|
|
|
|
CHECK_ERROR (lame_set_original (lame->lgf, lame->original));
|
|
|
|
CHECK_ERROR (lame_set_error_protection (lame->lgf, lame->error_protection));
|
|
|
|
CHECK_ERROR (lame_set_padding_type (lame->lgf, lame->padding_type));
|
|
|
|
CHECK_ERROR (lame_set_extension (lame->lgf, lame->extension));
|
|
|
|
CHECK_ERROR (lame_set_strict_ISO (lame->lgf, lame->strict_iso));
|
|
|
|
CHECK_ERROR (lame_set_disable_reservoir (lame->lgf, lame->disable_reservoir));
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
CHECK_ERROR (lame_set_VBR (lame->lgf, lame->vbr));
|
|
|
|
CHECK_ERROR (lame_set_VBR_q (lame->lgf, lame->vbr_quality));
|
ext/lame/gstlame.c: add debugging category, add error checks like checking return values of setup calls, make sure it...
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_link), (gst_lame_init),
(gst_lame_chain), (gst_lame_setup), (gst_lame_change_state),
(plugin_init):
add debugging category, add error checks like checking return values
of setup calls, make sure it still works after
PLAYING=>NULL=>PLAYING, fix encoding of mono streams
2004-07-26 15:42:18 +00:00
|
|
|
CHECK_ERROR (lame_set_VBR_mean_bitrate_kbps (lame->lgf,
|
|
|
|
lame->vbr_mean_bitrate));
|
|
|
|
CHECK_ERROR (lame_set_VBR_min_bitrate_kbps (lame->lgf,
|
|
|
|
lame->vbr_min_bitrate));
|
|
|
|
CHECK_ERROR (lame_set_VBR_max_bitrate_kbps (lame->lgf,
|
|
|
|
lame->vbr_max_bitrate));
|
|
|
|
CHECK_ERROR (lame_set_VBR_hard_min (lame->lgf, lame->vbr_hard_min));
|
|
|
|
CHECK_ERROR (lame_set_lowpassfreq (lame->lgf, lame->lowpass_freq));
|
|
|
|
CHECK_ERROR (lame_set_lowpasswidth (lame->lgf, lame->lowpass_width));
|
|
|
|
CHECK_ERROR (lame_set_highpassfreq (lame->lgf, lame->highpass_freq));
|
|
|
|
CHECK_ERROR (lame_set_highpasswidth (lame->lgf, lame->highpass_width));
|
|
|
|
CHECK_ERROR (lame_set_ATHonly (lame->lgf, lame->ath_only));
|
|
|
|
CHECK_ERROR (lame_set_ATHshort (lame->lgf, lame->ath_short));
|
|
|
|
CHECK_ERROR (lame_set_noATH (lame->lgf, lame->no_ath));
|
|
|
|
CHECK_ERROR (lame_set_ATHlower (lame->lgf, lame->ath_lower));
|
|
|
|
CHECK_ERROR (lame_set_cwlimit (lame->lgf, lame->cwlimit));
|
|
|
|
CHECK_ERROR (lame_set_allow_diff_short (lame->lgf, lame->allow_diff_short));
|
|
|
|
CHECK_ERROR (lame_set_no_short_blocks (lame->lgf, lame->no_short_blocks));
|
|
|
|
CHECK_ERROR (lame_set_emphasis (lame->lgf, lame->emphasis));
|
2004-08-19 22:44:50 +00:00
|
|
|
#ifdef GSTLAME_PRESET
|
2004-08-13 15:22:49 +00:00
|
|
|
if (lame->preset > 0) {
|
|
|
|
CHECK_ERROR (lame_set_preset (lame->lgf, lame->preset));
|
|
|
|
}
|
2004-08-19 22:44:50 +00:00
|
|
|
#endif
|
2003-12-07 14:47:09 +00:00
|
|
|
gst_lame_set_metadata (lame);
|
2003-07-05 22:48:58 +00:00
|
|
|
|
2001-12-21 12:47:09 +00:00
|
|
|
/* initialize the lame encoder */
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
if ((retval = lame_init_params (lame->lgf)) >= 0) {
|
2005-09-16 16:04:28 +00:00
|
|
|
lame->setup = TRUE;
|
2002-02-21 17:20:35 +00:00
|
|
|
/* FIXME: it would be nice to print out the mode here */
|
2005-09-16 16:04:28 +00:00
|
|
|
GST_INFO ("lame encoder setup (%d kbit/s, %d Hz, %d channels)",
|
2004-03-15 19:32:25 +00:00
|
|
|
lame->bitrate, lame->samplerate, lame->num_channels);
|
ext/lame/gstlame.*: fix lame's broken vbr stuff, allow it to resample if need be, and also make xing header optional
Original commit message from CVS:
2004-08-13 Zaheer Abbas Merali <zaheerabbas at merali dot org>
* ext/lame/gstlame.c: (gst_lame_vbrmode_get_type),
(gst_lame_class_init), (gst_lame_src_getcaps),
(gst_lame_sink_link), (gst_lame_init), (gst_lame_set_property),
(gst_lame_get_property), (gst_lame_setup):
* ext/lame/gstlame.h:
fix lame's broken vbr stuff, allow it to resample if need be, and also
make xing header optional
2004-08-13 14:41:02 +00:00
|
|
|
} else {
|
|
|
|
GST_ERROR_OBJECT (lame, "lame_init_params returned %d", retval);
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
|
2003-06-29 19:46:09 +00:00
|
|
|
GST_DEBUG_OBJECT (lame, "done with setup");
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2005-09-16 16:04:28 +00:00
|
|
|
return lame->setup;
|
ext/lame/gstlame.c: add debugging category, add error checks like checking return values of setup calls, make sure it...
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_link), (gst_lame_init),
(gst_lame_chain), (gst_lame_setup), (gst_lame_change_state),
(plugin_init):
add debugging category, add error checks like checking return values
of setup calls, make sure it still works after
PLAYING=>NULL=>PLAYING, fix encoding of mono streams
2004-07-26 15:42:18 +00:00
|
|
|
#undef CHECK_ERROR
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_lame_change_state (GstElement * element, GstStateChange transition)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
2001-12-21 12:47:09 +00:00
|
|
|
GstLame *lame;
|
2005-09-02 15:43:54 +00:00
|
|
|
GstStateChangeReturn result;
|
2001-12-20 23:48:55 +00:00
|
|
|
|
2001-12-21 12:47:09 +00:00
|
|
|
lame = GST_LAME (element);
|
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
switch (transition) {
|
2005-09-16 16:04:28 +00:00
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
|
|
|
lame->tags = gst_tag_list_new ();
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2003-05-29 12:41:42 +00:00
|
|
|
lame->last_ts = GST_CLOCK_TIME_NONE;
|
2003-05-13 12:28:16 +00:00
|
|
|
break;
|
2005-08-16 16:12:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2005-08-16 16:12:15 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
2005-09-16 16:04:28 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2006-03-15 13:43:42 +00:00
|
|
|
gst_lame_release_memory (lame);
|
2001-12-21 12:47:09 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
|
2005-08-16 16:12:15 +00:00
|
|
|
return result;
|
2001-12-20 23:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:30 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-20 23:48:55 +00:00
|
|
|
{
|
2003-11-02 00:13:26 +00:00
|
|
|
if (!gst_element_register (plugin, "lame", GST_RANK_NONE, GST_TYPE_LAME))
|
|
|
|
return FALSE;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
ext/lame/gstlame.c: add debugging category, add error checks like checking return values of setup calls, make sure it...
Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_link), (gst_lame_init),
(gst_lame_chain), (gst_lame_setup), (gst_lame_change_state),
(plugin_init):
add debugging category, add error checks like checking return values
of setup calls, make sure it still works after
PLAYING=>NULL=>PLAYING, fix encoding of mono streams
2004-07-26 15:42:18 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (debug, "lame", 0, "lame mp3 encoder");
|
2001-12-20 23:48:55 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"lame",
|
|
|
|
"Encode MP3's with LAME",
|
2006-04-01 09:54:39 +00:00
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|