2013-05-03 09:34:34 +00:00
|
|
|
/* GStreamer LADSPA plugin
|
2007-01-28 17:35:13 +00:00
|
|
|
* Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2001 Steve Baker <stevebaker_org@yahoo.co.uk>
|
2003-12-04 10:37:38 +00:00
|
|
|
* 2003 Andy Wingo <wingo at pobox.com>
|
2013-05-03 09:34:34 +00:00
|
|
|
* Copyright (C) 2013 Juan Manuel Borges Caño <juanmabcmail@gmail.com>
|
2001-12-23 15:26:43 +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
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2001-12-23 15:26:43 +00:00
|
|
|
*/
|
2013-05-03 09:34:34 +00:00
|
|
|
|
2009-07-22 15:01:12 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-ladspa
|
2017-03-08 18:01:13 +00:00
|
|
|
* @title: ladspa
|
2013-05-03 09:34:34 +00:00
|
|
|
* @short_description: bridge for LADSPA (Linux Audio Developer's Simple Plugin API)
|
|
|
|
* @see_also: #GstAudioConvert #GstAudioResample, #GstAudioTestSrc, #GstAutoAudioSink
|
2016-05-15 21:46:40 +00:00
|
|
|
*
|
2013-05-03 09:34:34 +00:00
|
|
|
* The LADSPA (Linux Audio Developer's Simple Plugin API) element is a bridge
|
|
|
|
* for plugins using the <ulink url="http://www.ladspa.org/">LADSPA</ulink> API.
|
|
|
|
* It scans all installed LADSPA plugins and registers them as gstreamer
|
|
|
|
* elements. If available it can also parse LRDF files and use the metadata for
|
|
|
|
* element classification. The functionality you get depends on the LADSPA plugins
|
|
|
|
* you have installed.
|
2016-05-15 21:46:40 +00:00
|
|
|
*
|
2017-03-08 18:01:13 +00:00
|
|
|
* ## Example LADSPA line without this plugins
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
|
|
|
* (padsp) listplugins
|
|
|
|
* (padsp) analyseplugin cmt.so amp_mono
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 -e filesrc location="$myfile" ! decodebin ! audioconvert ! audioresample ! "audio/x-raw,format=S16LE,rate=48000,channels=1" ! wavenc ! filesink location="testin.wav"
|
2016-05-15 21:46:40 +00:00
|
|
|
* (padsp) applyplugin testin.wav testout.wav cmt.so amp_mono 2
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 playbin uri=file://"$PWD"/testout.wav
|
2013-05-03 09:34:34 +00:00
|
|
|
* ]| Decode any audio file into wav with the format expected for the specific ladspa plugin to be applied, apply the ladspa filter and play it.
|
|
|
|
*
|
|
|
|
* Now with this plugin:
|
|
|
|
*
|
2017-03-08 18:01:13 +00:00
|
|
|
* ## Example LADSPA line with this plugins
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 autoaudiosrc ! ladspa-cmt-so-amp-mono gain=2 ! ladspa-caps-so-plate ! ladspa-tap-echo-so-tap-stereo-echo l-delay=500 r-haas-delay=500 ! tee name=myT myT. ! queue ! autoaudiosink myT. ! queue ! audioconvert ! goom ! videoconvert ! xvimagesink pixel-aspect-ratio=3/4
|
2013-05-03 09:34:34 +00:00
|
|
|
* ]| Get audio input, filter it through CAPS Plate and TAP Stereo Echo, play it and show a visualization (recommended hearphones).
|
|
|
|
*
|
|
|
|
* In case you wonder the plugin naming scheme, quoting ladspa.h:
|
|
|
|
* "Plugin types should be identified by file and label rather than by
|
|
|
|
* index or plugin name, which may be changed in new plugin versions."
|
|
|
|
* This is really the best way then, and so it is less prone to conflicts.
|
|
|
|
*
|
|
|
|
* Also it is worth noting that LADSPA provides a control in and out interface,
|
|
|
|
* on top of the audio in and out one, so some parameters are readable too.
|
|
|
|
*
|
|
|
|
* You can see the listing of plugins available with:
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
|
|
|
* ## Inspecting the plugins list
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
|
|
|
* gst-inspect ladspa
|
|
|
|
* ]| List available LADSPA plugins on gstreamer.
|
|
|
|
*
|
|
|
|
* You can see the parameters of any plugin with:
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
|
|
|
* ## Inspecting the plugins
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
2013-05-28 05:53:37 +00:00
|
|
|
* gst-inspect ladspa-retro-flange-1208-so-retroflange
|
2013-05-03 09:34:34 +00:00
|
|
|
* ]| List details of the plugin, parameters, range and defaults included.
|
|
|
|
*
|
2016-05-15 21:46:40 +00:00
|
|
|
* The elements categorize in:
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
|
|
|
* * Filter/Effect/Audio/LADSPA:
|
|
|
|
*
|
|
|
|
* ## Example Filter/Effect/Audio/LADSPA line with this plugins
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 filesrc location="$myfile" ! decodebin ! audioconvert ! audioresample ! ladspa-calf-so-reverb decay-time=15 high-frq-damp=20000 room-size=5 diffusion=1 wet-amount=2 dry-amount=2 pre-delay=50 bass-cut=20000 treble-cut=20000 ! ladspa-tap-echo-so-tap-stereo-echo l-delay=500 r-haas-delay=500 ! autoaudiosink
|
2013-05-03 09:34:34 +00:00
|
|
|
* ]| Decode any audio file, filter it through Calf Reverb LADSPA then TAP Stereo Echo, and play it.
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
|
|
|
* * Source/Audio/LADSPA:
|
|
|
|
*
|
|
|
|
* ## Example Source/Audio/LADSPA line with this plugins
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 ladspasrc-sine-so-sine-fcac frequency=220 amplitude=100 ! audioconvert ! autoaudiosink
|
2013-05-28 05:53:37 +00:00
|
|
|
* ]| Generate a sine wave with Sine Oscillator (Freq:control, Amp:control) and play it.
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
|
|
|
* ## Example Source/Audio/LADSPA line with this plugins
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 ladspasrc-caps-so-click bpm=240 volume=1 ! autoaudiosink
|
2013-05-03 09:34:34 +00:00
|
|
|
* ]| Generate clicks with CAPS Click - Metronome at 240 beats per minute and play it.
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
|
|
|
* ## Example Source/Audio/LADSPA line with this plugins
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 ladspasrc-random-1661-so-random-fcsc-oa ! ladspa-cmt-so-amp-mono gain=1.5 ! ladspa-caps-so-plate ! tee name=myT myT. ! queue ! autoaudiosink myT. ! queue ! audioconvert ! wavescope ! videoconvert ! autovideosink
|
2013-05-03 09:34:34 +00:00
|
|
|
* ]| Generate random wave, filter it trhough Mono Amplifier and Versatile Plate Reverb, and play, while showing, it.
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
|
|
|
* * Sink/Audio/LADSPA:
|
|
|
|
*
|
|
|
|
* ## Example Sink/Audio/LADSPA line with this plugins
|
2013-05-03 09:34:34 +00:00
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 autoaudiosrc ! ladspa-cmt-so-amp-mono gain=2 ! ladspa-caps-so-plate ! ladspa-tap-echo-so-tap-stereo-echo l-delay=500 r-haas-delay=500 ! tee name=myT myT. ! audioconvert ! audioresample ! queue ! ladspasink-cmt-so-null-ai myT. ! audioconvert ! audioresample ! queue ! goom ! videoconvert ! xvimagesink pixel-aspect-ratio=3/4
|
2013-05-28 05:53:37 +00:00
|
|
|
* ]| Get audio input, filter it trhough Mono Amplifier, CAPS Plate LADSPA and TAP Stereo Echo, explicitily anulate audio with Null (Audio Output), and play a visualization (recommended hearphones).
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
2009-07-22 15:01:12 +00:00
|
|
|
*/
|
2013-05-03 09:34:34 +00:00
|
|
|
|
2003-11-06 23:36:33 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2013-05-03 09:34:34 +00:00
|
|
|
#include "gstladspautils.h"
|
|
|
|
#include "gstladspafilter.h"
|
|
|
|
#include "gstladspasource.h"
|
|
|
|
#include "gstladspasink.h"
|
|
|
|
#include <gst/gst-i18n-plugin.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <ladspa.h>
|
2010-03-22 11:30:01 +00:00
|
|
|
#ifdef HAVE_LRDF
|
2009-03-05 20:37:52 +00:00
|
|
|
#include <lrdf.h>
|
|
|
|
#endif
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2013-05-03 09:34:34 +00:00
|
|
|
GST_DEBUG_CATEGORY (ladspa_debug);
|
|
|
|
#define GST_CAT_DEFAULT ladspa_debug
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 1.0 and the 1.1 preliminary headers don't define a version, but
|
|
|
|
* 1.1 finally does
|
|
|
|
*/
|
2003-12-04 10:37:38 +00:00
|
|
|
#ifndef LADSPA_VERSION
|
|
|
|
#define LADSPA_VERSION "1.0"
|
|
|
|
#endif
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2017-12-18 21:54:15 +00:00
|
|
|
#if defined (G_OS_WIN32)
|
|
|
|
#define GST_LADSPA_ENVVARS "APPDATA/LADSPA:COMMONPROGRAMFILES/LADSPA"
|
|
|
|
#define GST_LADSPA_DEFAULT_PATH ""
|
|
|
|
#elif defined (HAVE_OSX)
|
|
|
|
#define GST_LADSPA_ENVVARS "HOME/Library/Audio/Plug-Ins/LADSPA:HOME/.ladspa"
|
2009-03-04 13:05:48 +00:00
|
|
|
#define GST_LADSPA_DEFAULT_PATH \
|
2017-12-18 21:54:15 +00:00
|
|
|
"/usr/local/lib/ladspa:/usr/lib/ladspa:/Library/Audio/Plug-Ins/LADSPA"
|
|
|
|
#elif defined (G_OS_UNIX)
|
|
|
|
#define GST_LADSPA_ENVVARS "HOME/.ladspa"
|
|
|
|
#define GST_LADSPA_DEFAULT_PATH \
|
|
|
|
"/usr/lib/ladspa:" \
|
|
|
|
"/usr/lib64/ladspa:" \
|
|
|
|
"/usr/local/lib/ladspa:" \
|
|
|
|
"/usr/local/lib64/ladspa:" \
|
|
|
|
LIBDIR "/ladspa"
|
|
|
|
#else
|
|
|
|
#error "Unsupported OS"
|
|
|
|
#endif
|
2009-03-04 13:05:48 +00:00
|
|
|
|
2013-05-27 21:07:16 +00:00
|
|
|
GstStructure *ladspa_meta_all = NULL;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
static void
|
2013-05-27 21:07:16 +00:00
|
|
|
ladspa_plugin_register_element (GstPlugin * plugin, GstStructure * ladspa_meta)
|
|
|
|
{
|
|
|
|
guint audio_in, audio_out;
|
|
|
|
|
|
|
|
gst_structure_get_uint (ladspa_meta, "audio-in", &audio_in);
|
|
|
|
gst_structure_get_uint (ladspa_meta, "audio-out", &audio_out);
|
|
|
|
|
|
|
|
if (audio_in == 0) {
|
|
|
|
ladspa_register_source_element (plugin, ladspa_meta);
|
|
|
|
} else if (audio_out == 0) {
|
|
|
|
ladspa_register_sink_element (plugin, ladspa_meta);
|
|
|
|
} else {
|
|
|
|
ladspa_register_filter_element (plugin, ladspa_meta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ladspa_count_ports (const LADSPA_Descriptor * descriptor,
|
|
|
|
guint * audio_in, guint * audio_out, guint * control_in,
|
|
|
|
guint * control_out)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
*audio_in = *audio_out = *control_in = *control_out = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < descriptor->PortCount; i++) {
|
|
|
|
LADSPA_PortDescriptor p = descriptor->PortDescriptors[i];
|
|
|
|
|
|
|
|
if (LADSPA_IS_PORT_AUDIO (p)) {
|
|
|
|
if (LADSPA_IS_PORT_INPUT (p))
|
|
|
|
(*audio_in)++;
|
|
|
|
else
|
|
|
|
(*audio_out)++;
|
|
|
|
} else if (LADSPA_IS_PORT_CONTROL (p)) {
|
|
|
|
if (LADSPA_IS_PORT_INPUT (p))
|
|
|
|
(*control_in)++;
|
|
|
|
else
|
|
|
|
(*control_out)++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ladspa_describe_plugin (const gchar * file_name, const gchar * entry_name,
|
|
|
|
LADSPA_Descriptor_Function descriptor_function)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2013-05-03 09:34:34 +00:00
|
|
|
const LADSPA_Descriptor *desc;
|
2005-08-26 11:05:13 +00:00
|
|
|
guint i;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2013-05-03 09:34:34 +00:00
|
|
|
/* walk through all the plugins in this plugin library */
|
|
|
|
for (i = 0; (desc = descriptor_function (i)); i++) {
|
2013-05-27 21:07:16 +00:00
|
|
|
GstStructure *ladspa_meta = NULL;
|
|
|
|
GValue value = { 0, };
|
|
|
|
gchar *tmp;
|
|
|
|
gchar *type_name;
|
2013-05-03 09:34:34 +00:00
|
|
|
guint audio_in, audio_out, control_in, control_out;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2013-05-03 09:34:34 +00:00
|
|
|
/* count ports of this plugin */
|
|
|
|
ladspa_count_ports (desc, &audio_in, &audio_out, &control_in, &control_out);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2013-05-27 21:07:16 +00:00
|
|
|
/* categorize */
|
|
|
|
if (audio_in == 0 && audio_out == 0) {
|
|
|
|
GST_WARNING ("Skipping control only element (%s:%lu/%s)",
|
|
|
|
entry_name, desc->UniqueID, desc->Label);
|
|
|
|
continue;
|
|
|
|
} else if (audio_in == 0) {
|
|
|
|
tmp = g_strdup_printf ("ladspasrc-%s-%s", entry_name, desc->Label);
|
|
|
|
} else if (audio_out == 0) {
|
|
|
|
tmp = g_strdup_printf ("ladspasink-%s-%s", entry_name, desc->Label);
|
|
|
|
} else {
|
|
|
|
tmp = g_strdup_printf ("ladspa-%s-%s", entry_name, desc->Label);
|
|
|
|
}
|
|
|
|
type_name = g_ascii_strdown (tmp, -1);
|
|
|
|
g_free (tmp);
|
|
|
|
g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-');
|
|
|
|
|
|
|
|
/* check if the type is already registered */
|
|
|
|
if (g_type_from_name (type_name)) {
|
|
|
|
GST_WARNING ("Plugin identifier collision for %s (%s:%lu/%s)", type_name,
|
|
|
|
entry_name, desc->UniqueID, desc->Label);
|
|
|
|
g_free (type_name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-06-14 20:12:18 +00:00
|
|
|
ladspa_meta = gst_structure_new ("ladspa",
|
2013-05-27 21:07:16 +00:00
|
|
|
"plugin-filename", G_TYPE_STRING, file_name,
|
|
|
|
"element-ix", G_TYPE_UINT, i,
|
|
|
|
"element-type-name", G_TYPE_STRING, type_name,
|
|
|
|
"audio-in", G_TYPE_UINT, audio_in,
|
|
|
|
"audio-out", G_TYPE_UINT, audio_out,
|
|
|
|
"control-in", G_TYPE_UINT, control_in,
|
|
|
|
"control-out", G_TYPE_UINT, control_out, NULL);
|
|
|
|
|
|
|
|
g_value_init (&value, GST_TYPE_STRUCTURE);
|
|
|
|
g_value_set_boxed (&value, ladspa_meta);
|
|
|
|
gst_structure_set_value (ladspa_meta_all, type_name, &value);
|
|
|
|
g_value_unset (&value);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-22 11:30:01 +00:00
|
|
|
#ifdef HAVE_LRDF
|
2009-03-05 20:37:52 +00:00
|
|
|
static gboolean
|
|
|
|
ladspa_rdf_directory_search (const char *dir_name)
|
|
|
|
{
|
|
|
|
GDir *dir;
|
|
|
|
gchar *file_name, *file_uri;
|
|
|
|
const gchar *entry_name;
|
|
|
|
gint ok;
|
|
|
|
|
|
|
|
GST_INFO ("scanning directory for rdfs \"%s\"", dir_name);
|
|
|
|
|
|
|
|
dir = g_dir_open (dir_name, 0, NULL);
|
|
|
|
if (!dir)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
while ((entry_name = g_dir_read_name (dir))) {
|
|
|
|
file_name = g_build_filename (dir_name, entry_name, NULL);
|
|
|
|
file_uri = g_strconcat ("file://", file_name, NULL);
|
|
|
|
ok = lrdf_read_file (file_uri);
|
|
|
|
GST_INFO ("read %s : %d", file_uri, ok);
|
|
|
|
g_free (file_uri);
|
|
|
|
g_free (file_name);
|
|
|
|
}
|
|
|
|
g_dir_close (dir);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-05-03 09:34:34 +00:00
|
|
|
/* search just the one directory */
|
2009-03-04 13:05:48 +00:00
|
|
|
static gboolean
|
2013-05-03 09:34:34 +00:00
|
|
|
ladspa_plugin_directory_search (GstPlugin * ladspa_plugin, const char *dir_name)
|
2009-03-04 13:05:48 +00:00
|
|
|
{
|
|
|
|
GDir *dir;
|
|
|
|
gchar *file_name;
|
|
|
|
const gchar *entry_name;
|
|
|
|
LADSPA_Descriptor_Function descriptor_function;
|
|
|
|
GModule *plugin;
|
|
|
|
gboolean ok = FALSE;
|
|
|
|
|
2009-03-05 20:37:52 +00:00
|
|
|
GST_INFO ("scanning directory for plugins \"%s\"", dir_name);
|
2009-03-04 13:05:48 +00:00
|
|
|
|
|
|
|
dir = g_dir_open (dir_name, 0, NULL);
|
|
|
|
if (!dir)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
while ((entry_name = g_dir_read_name (dir))) {
|
2018-07-21 23:52:23 +00:00
|
|
|
/* Only attempt to open files with the module suffixes */
|
|
|
|
if (!g_str_has_suffix (entry_name, "." G_MODULE_SUFFIX)
|
|
|
|
#ifdef GST_EXTRA_MODULE_SUFFIX
|
|
|
|
&& !g_str_has_suffix (entry_name, GST_EXTRA_MODULE_SUFFIX)
|
|
|
|
#endif
|
|
|
|
) {
|
|
|
|
GST_TRACE ("Ignoring file %s as it has the wrong suffix for a plugin",
|
|
|
|
entry_name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-03-04 13:05:48 +00:00
|
|
|
file_name = g_build_filename (dir_name, entry_name, NULL);
|
2018-07-21 23:52:23 +00:00
|
|
|
GST_LOG ("Probing file %s as a LADSPA plugin", file_name);
|
2009-03-04 13:05:48 +00:00
|
|
|
plugin =
|
|
|
|
g_module_open (file_name, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
|
|
|
|
if (plugin) {
|
|
|
|
/* the file is a shared library */
|
|
|
|
if (g_module_symbol (plugin, "ladspa_descriptor",
|
|
|
|
(gpointer *) & descriptor_function)) {
|
|
|
|
/* we've found a ladspa_descriptor function, now introspect it. */
|
2018-07-22 00:34:06 +00:00
|
|
|
GST_INFO ("Found LADSPA descriptor in %s", file_name);
|
2013-05-27 21:07:16 +00:00
|
|
|
ladspa_describe_plugin (file_name, entry_name, descriptor_function);
|
2009-03-04 13:05:48 +00:00
|
|
|
ok = TRUE;
|
|
|
|
} else {
|
|
|
|
/* it was a library, but not a LADSPA one. Unload it. */
|
|
|
|
g_module_close (plugin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free (file_name);
|
|
|
|
}
|
|
|
|
g_dir_close (dir);
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2013-05-03 09:34:34 +00:00
|
|
|
/* search the plugin path */
|
2009-03-04 13:05:48 +00:00
|
|
|
static gboolean
|
2013-05-03 09:34:34 +00:00
|
|
|
ladspa_plugin_path_search (GstPlugin * plugin)
|
2009-03-04 13:05:48 +00:00
|
|
|
{
|
2017-12-18 21:54:15 +00:00
|
|
|
const gchar *search_path, *path;
|
|
|
|
GString *ladspa_path;
|
2009-03-04 13:05:48 +00:00
|
|
|
gchar **paths;
|
|
|
|
gint i, j, path_entries;
|
|
|
|
gboolean res = FALSE, skip;
|
2010-03-22 11:30:01 +00:00
|
|
|
#ifdef HAVE_LRDF
|
2009-03-05 20:37:52 +00:00
|
|
|
gchar *pos, *prefix, *rdf_path;
|
|
|
|
#endif
|
2009-03-04 13:05:48 +00:00
|
|
|
|
2017-12-18 21:54:15 +00:00
|
|
|
ladspa_path = g_string_new (NULL);
|
|
|
|
|
2009-03-04 13:05:48 +00:00
|
|
|
search_path = g_getenv ("LADSPA_PATH");
|
|
|
|
if (search_path) {
|
2017-12-18 21:54:15 +00:00
|
|
|
g_string_append_printf (ladspa_path,
|
|
|
|
"%s" G_SEARCHPATH_SEPARATOR_S GST_LADSPA_DEFAULT_PATH, search_path);
|
2009-03-04 13:05:48 +00:00
|
|
|
} else {
|
2017-12-18 21:54:15 +00:00
|
|
|
g_string_append_printf (ladspa_path, GST_LADSPA_DEFAULT_PATH);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
path = g_getenv ("APPDATA");
|
2018-03-23 03:45:38 +00:00
|
|
|
if (path) {
|
2018-07-22 00:34:06 +00:00
|
|
|
gchar *path_subdir = g_build_filename (path, "LADSPA", NULL);
|
2018-03-23 03:45:38 +00:00
|
|
|
if (ladspa_path->len)
|
2018-07-22 00:34:06 +00:00
|
|
|
g_string_append_printf (ladspa_path, G_SEARCHPATH_SEPARATOR_S "%s",
|
|
|
|
path_subdir);
|
2018-03-23 03:45:38 +00:00
|
|
|
else
|
2018-07-22 00:34:06 +00:00
|
|
|
g_string_append (ladspa_path, path_subdir);
|
|
|
|
g_free (path_subdir);
|
2018-03-23 03:45:38 +00:00
|
|
|
}
|
2017-12-18 21:54:15 +00:00
|
|
|
|
|
|
|
path = g_getenv ("COMMONPROGRAMFILES");
|
|
|
|
if (path) {
|
2018-07-22 00:34:06 +00:00
|
|
|
gchar *path_subdir = g_build_filename (path, "LADSPA", NULL);
|
2017-12-18 21:54:15 +00:00
|
|
|
if (ladspa_path->len)
|
2018-07-22 00:34:06 +00:00
|
|
|
g_string_append_printf (ladspa_path, G_SEARCHPATH_SEPARATOR_S "%s",
|
|
|
|
path_subdir);
|
2017-12-18 21:54:15 +00:00
|
|
|
else
|
2018-07-22 00:34:06 +00:00
|
|
|
g_string_append (ladspa_path, path_subdir);
|
|
|
|
g_free (path_subdir);
|
2017-12-18 21:54:15 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
path = g_getenv ("HOME");
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
if (ladspa_path->len)
|
|
|
|
g_string_append_printf (ladspa_path, ":%s/.ladspa", path);
|
|
|
|
else
|
|
|
|
g_string_append_printf (ladspa_path, "%s/.ladspa", path);
|
|
|
|
|
|
|
|
#if defined (HAVE_IOS) || defined (HAVE_OSX)
|
|
|
|
g_string_append_printf (ladspa_path, ":%s/Library/Audio/Plug-Ins/LADSPA",
|
|
|
|
path);
|
|
|
|
#endif
|
2009-03-04 13:05:48 +00:00
|
|
|
}
|
2017-12-18 21:54:15 +00:00
|
|
|
#endif
|
2009-03-04 13:05:48 +00:00
|
|
|
|
2017-12-18 21:54:15 +00:00
|
|
|
paths = g_strsplit (ladspa_path->str, G_SEARCHPATH_SEPARATOR_S, 0);
|
2009-03-04 13:05:48 +00:00
|
|
|
path_entries = g_strv_length (paths);
|
2017-12-18 21:54:15 +00:00
|
|
|
GST_INFO ("%d dirs in search paths \"%s\"", path_entries, ladspa_path->str);
|
2009-03-04 13:05:48 +00:00
|
|
|
|
2010-03-22 11:30:01 +00:00
|
|
|
#ifdef HAVE_LRDF
|
2009-03-05 20:37:52 +00:00
|
|
|
for (i = 0; i < path_entries; i++) {
|
|
|
|
skip = FALSE;
|
|
|
|
for (j = 0; j < i; j++) {
|
|
|
|
if (!strcmp (paths[i], paths[j])) {
|
|
|
|
skip = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (skip)
|
|
|
|
break;
|
2016-05-15 21:46:40 +00:00
|
|
|
/*
|
2013-05-03 09:34:34 +00:00
|
|
|
* transform path: /usr/lib/ladspa -> /usr/share/ladspa/rdf/
|
2009-03-05 20:37:52 +00:00
|
|
|
* yes, this is ugly, but lrdf has not searchpath
|
|
|
|
*/
|
|
|
|
if ((pos = strstr (paths[i], "/lib/ladspa"))) {
|
|
|
|
prefix = g_strndup (paths[i], (pos - paths[i]));
|
|
|
|
rdf_path = g_build_filename (prefix, "share", "ladspa", "rdf", NULL);
|
|
|
|
ladspa_rdf_directory_search (rdf_path);
|
|
|
|
g_free (rdf_path);
|
|
|
|
g_free (prefix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-03-04 13:05:48 +00:00
|
|
|
for (i = 0; i < path_entries; i++) {
|
|
|
|
skip = FALSE;
|
|
|
|
for (j = 0; j < i; j++) {
|
|
|
|
if (!strcmp (paths[i], paths[j])) {
|
|
|
|
skip = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (skip)
|
|
|
|
break;
|
2013-05-03 09:34:34 +00:00
|
|
|
res |= ladspa_plugin_directory_search (plugin, paths[i]);
|
2009-03-04 13:05:48 +00:00
|
|
|
}
|
|
|
|
g_strfreev (paths);
|
|
|
|
|
2017-12-18 21:54:15 +00:00
|
|
|
g_string_free (ladspa_path, TRUE);
|
2009-03-04 13:05:48 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2013-05-27 21:07:16 +00:00
|
|
|
gboolean res = FALSE;
|
|
|
|
gint n = 0;
|
|
|
|
|
2013-07-26 20:20:27 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (ladspa_debug, "ladspa", 0, "LADSPA plugins");
|
|
|
|
|
2013-05-03 09:34:34 +00:00
|
|
|
#ifdef ENABLE_NLS
|
2016-05-15 21:46:40 +00:00
|
|
|
GST_DEBUG_OBJECT (plugin, "binding text domain %s to locale dir %s",
|
|
|
|
GETTEXT_PACKAGE, LOCALEDIR);
|
2013-05-03 09:34:34 +00:00
|
|
|
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
#endif
|
|
|
|
|
2009-01-08 09:40:22 +00:00
|
|
|
gst_plugin_add_dependency_simple (plugin,
|
2017-12-18 21:54:15 +00:00
|
|
|
"LADSPA_PATH:" GST_LADSPA_ENVVARS,
|
2009-03-04 13:05:48 +00:00
|
|
|
GST_LADSPA_DEFAULT_PATH, NULL, GST_PLUGIN_DEPENDENCY_FLAG_NONE);
|
2009-01-08 09:40:22 +00:00
|
|
|
|
2010-03-22 11:30:01 +00:00
|
|
|
#ifdef HAVE_LRDF
|
2009-03-05 20:37:52 +00:00
|
|
|
lrdf_init ();
|
|
|
|
#endif
|
|
|
|
|
2013-05-27 21:07:16 +00:00
|
|
|
ladspa_meta_all = (GstStructure *) gst_plugin_get_cache_data (plugin);
|
|
|
|
if (ladspa_meta_all) {
|
|
|
|
n = gst_structure_n_fields (ladspa_meta_all);
|
|
|
|
}
|
2016-05-15 21:46:40 +00:00
|
|
|
GST_INFO_OBJECT (plugin, "%d entries in cache", n);
|
2013-05-27 21:07:16 +00:00
|
|
|
if (!n) {
|
|
|
|
ladspa_meta_all = gst_structure_new_empty ("ladspa");
|
2016-05-15 21:46:40 +00:00
|
|
|
if ((res = ladspa_plugin_path_search (plugin))) {
|
2013-05-27 21:07:16 +00:00
|
|
|
n = gst_structure_n_fields (ladspa_meta_all);
|
2016-05-15 21:46:40 +00:00
|
|
|
GST_INFO_OBJECT (plugin, "%d entries after scanning", n);
|
2013-05-27 21:07:16 +00:00
|
|
|
gst_plugin_set_cache_data (plugin, ladspa_meta_all);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
res = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n) {
|
|
|
|
gint i;
|
|
|
|
const gchar *name;
|
|
|
|
const GValue *value;
|
|
|
|
|
2016-05-15 21:46:40 +00:00
|
|
|
GST_INFO_OBJECT (plugin, "register types");
|
2013-05-27 21:07:16 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
name = gst_structure_nth_field_name (ladspa_meta_all, i);
|
|
|
|
value = gst_structure_get_value (ladspa_meta_all, name);
|
|
|
|
if (G_VALUE_TYPE (value) == GST_TYPE_STRUCTURE) {
|
|
|
|
GstStructure *ladspa_meta = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
ladspa_plugin_register_element (plugin, ladspa_meta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!res) {
|
2016-05-15 21:46:40 +00:00
|
|
|
GST_WARNING_OBJECT (plugin, "no LADSPA plugins found, check LADSPA_PATH");
|
2013-05-27 21:07:16 +00:00
|
|
|
}
|
2010-04-26 12:06:09 +00:00
|
|
|
|
|
|
|
/* we don't want to fail, even if there are no elements registered */
|
|
|
|
return TRUE;
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2012-04-05 16:02:56 +00:00
|
|
|
ladspa,
|
2013-05-03 09:34:34 +00:00
|
|
|
"LADSPA plugin",
|
2005-11-14 02:13:26 +00:00
|
|
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|