Commit 53ec4449 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller

Moving lame mp3 encoder plugin from -ugly

https://bugzilla.gnome.org/show_bug.cgi?id=774252
parents 97b58bd2 3169f86e
plugin_LTLIBRARIES = libgstlame.la
libgstlame_la_SOURCES = gstlamemp3enc.c plugin.c
libgstlame_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LAME_CFLAGS)
libgstlame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) \
$(GST_BASE_LIBS) $(GST_LIBS) $(LAME_LIBS)
libgstlame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstlamemp3enc.h
This diff is collapsed.
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2009> Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_LAMEMP3ENC_H__
#define __GST_LAMEMP3ENC_H__
#include <gst/gst.h>
#include <gst/audio/gstaudioencoder.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
#include <lame/lame.h>
#define GST_TYPE_LAMEMP3ENC \
(gst_lamemp3enc_get_type())
#define GST_LAMEMP3ENC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_LAMEMP3ENC,GstLameMP3Enc))
#define GST_LAMEMP3ENC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_LAMEMP3ENC,GstLameMP3EncClass))
#define GST_IS_LAMEMP3ENC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_LAMEMP3ENC))
#define GST_IS_LAMEMP3ENC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_LAMEMP3ENC))
typedef struct _GstLameMP3Enc GstLameMP3Enc;
typedef struct _GstLameMP3EncClass GstLameMP3EncClass;
/**
* GstLameMP3Enc:
*
* Opaque data structure.
*/
struct _GstLameMP3Enc {
GstAudioEncoder element;
/*< private >*/
gint samplerate;
gint out_samplerate;
gint num_channels;
/* properties */
gint target;
gint bitrate;
gboolean cbr;
gfloat quality;
gint encoding_engine_quality;
gboolean mono;
lame_global_flags *lgf;
GstAdapter *adapter;
};
struct _GstLameMP3EncClass {
GstAudioEncoderClass parent_class;
};
GType gst_lamemp3enc_get_type(void);
gboolean gst_lamemp3enc_register (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_LAMEMP3ENC_H__ */
lame_dep = cc.find_library('mp3lame', required : false)
if lame_dep.found() and cc.has_header_symbol('lame/lame.h', 'lame_init')
lame_extra_c_args = []
if cc.has_header_symbol('lame/lame.h', 'lame_set_VBR_quality')
lame_extra_c_args += ['-DHAVE_LAME_SET_VBR_QUALITY']
endif
if cc.has_header_symbol('lame/lame.h', 'MEDIUM')
lame_extra_c_args += ['-DGSTLAME_PRESET']
endif
lame = library('gstlame',
['gstlamemp3enc.c', 'plugin.c'],
c_args : ugly_args + lame_extra_c_args,
include_directories : [configinc, libsinc],
dependencies : [gstaudio_dep, lame_dep],
install : true,
install_dir : plugins_install_dir,
)
endif
/* GStreamer
* Copyright (C) <2009> Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/gst-i18n-plugin.h>
#include "gstlamemp3enc.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
return gst_lamemp3enc_register (plugin);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
lame,
"Encode MP3s with LAME",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
/* GStreamer
*
* unit test for lame
*
* Copyright (C) 2007 Thomas Vander Stichele <thomas at apestaart dot org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <gst/check/gstcheck.h>
#include <gst/check/gstbufferstraw.h>
#ifndef GST_DISABLE_PARSE
GST_START_TEST (test_format)
{
GstElement *bin;
GstPad *pad;
gchar *pipe_str;
GstBuffer *buffer;
GError *error = NULL;
pipe_str = g_strdup_printf ("audiotestsrc num-buffers=1 "
"! audio/x-raw, rate=22050, channels=1 "
"! lamemp3enc bitrate=24 ! audio/mpeg,rate=22050 ! fakesink");
bin = gst_parse_launch (pipe_str, &error);
fail_unless (bin != NULL, "Error parsing pipeline: %s",
error ? error->message : "(invalid error)");
g_free (pipe_str);
/* get the pad */
{
GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink0");
fail_unless (sink != NULL, "Could not get fakesink out of bin");
pad = gst_element_get_static_pad (sink, "sink");
fail_unless (pad != NULL, "Could not get pad out of fakesink");
gst_object_unref (sink);
}
gst_buffer_straw_start_pipeline (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
gst_buffer_straw_stop_pipeline (bin, pad);
gst_buffer_unref (buffer);
gst_object_unref (pad);
gst_object_unref (bin);
}
GST_END_TEST;
GST_START_TEST (test_caps_proxy)
{
GstElement *bin;
GstPad *pad;
gchar *pipe_str;
GstBuffer *buffer;
GError *error = NULL;
pipe_str = g_strdup_printf ("audiotestsrc num-buffers=1 "
"! audio/x-raw,rate=48000,channels=1 "
"! audioresample "
"! lamemp3enc ! audio/mpeg,rate=(int){22050,44100} ! fakesink");
bin = gst_parse_launch (pipe_str, &error);
fail_unless (bin != NULL, "Error parsing pipeline: %s",
error ? error->message : "(invalid error)");
g_free (pipe_str);
/* get the pad */
{
GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink0");
fail_unless (sink != NULL, "Could not get fakesink out of bin");
pad = gst_element_get_static_pad (sink, "sink");
fail_unless (pad != NULL, "Could not get pad out of fakesink");
gst_object_unref (sink);
}
gst_buffer_straw_start_pipeline (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
gst_buffer_straw_stop_pipeline (bin, pad);
gst_buffer_unref (buffer);
gst_object_unref (pad);
gst_object_unref (bin);
}
GST_END_TEST;
#endif /* #ifndef GST_DISABLE_PARSE */
Suite *
lame_suite (void)
{
Suite *s = suite_create ("lame");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
#ifndef GST_DISABLE_PARSE
tcase_add_test (tc_chain, test_format);
tcase_add_test (tc_chain, test_caps_proxy);
#endif
return s;
}
GST_CHECK_MAIN (lame);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment