2001-12-23 15:26:43 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* <2001> Steve Baker <stevebaker_org@yahoo.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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
2002-04-20 13:57:00 +00:00
|
|
|
#include <gst/control/control.h>
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
#include "gstladspa.h"
|
2002-06-04 15:57:42 +00:00
|
|
|
#include <ladspa.h> /* main ladspa sdk include file */
|
2002-01-22 04:42:11 +00:00
|
|
|
#include "utils.h" /* ladspa sdk utility functions */
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
GST_PAD_TEMPLATE_FACTORY (ladspa_sink_factory,
|
|
|
|
"sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_CAPS_NEW (
|
|
|
|
"ladspa_sink",
|
|
|
|
"audio/raw",
|
|
|
|
"rate", GST_PROPS_INT_RANGE (4000, 96000),
|
|
|
|
"format", GST_PROPS_STRING ("float"),
|
|
|
|
"layout", GST_PROPS_STRING ("gfloat"),
|
|
|
|
"intercept", GST_PROPS_FLOAT(0.0),
|
|
|
|
"slope", GST_PROPS_FLOAT(1.0),
|
|
|
|
"channels", GST_PROPS_INT (1)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
GST_PAD_TEMPLATE_FACTORY (ladspa_src_factory,
|
|
|
|
"src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_CAPS_NEW (
|
2001-12-23 15:26:43 +00:00
|
|
|
"ladspa_src",
|
2002-04-20 13:57:00 +00:00
|
|
|
"audio/raw",
|
|
|
|
"rate", GST_PROPS_INT_RANGE (4000, 96000),
|
|
|
|
"format", GST_PROPS_STRING ("float"),
|
|
|
|
"layout", GST_PROPS_STRING ("gfloat"),
|
|
|
|
"intercept", GST_PROPS_FLOAT (0.0),
|
|
|
|
"slope", GST_PROPS_FLOAT (1.0),
|
|
|
|
"channels", GST_PROPS_INT (1)
|
|
|
|
)
|
|
|
|
);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
static GstPadTemplate *srctempl, *sinktempl;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
ARG_SAMPLERATE,
|
|
|
|
ARG_BUFFERSIZE,
|
|
|
|
ARG_LAST,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void gst_ladspa_class_init (GstLADSPAClass *klass);
|
|
|
|
static void gst_ladspa_init (GstLADSPA *ladspa);
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
static void gst_ladspa_update_int(const GValue *value, gpointer data);
|
2002-01-22 04:42:11 +00:00
|
|
|
static GstPadConnectReturn gst_ladspa_connect (GstPad *pad, GstCaps *caps);
|
|
|
|
static GstPadConnectReturn gst_ladspa_connect_get (GstPad *pad, GstCaps *caps);
|
|
|
|
static void gst_ladspa_force_src_caps (GstLADSPA *ladspa, GstPad *pad);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
static void gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
|
|
|
static void gst_ladspa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
static gboolean gst_ladspa_instantiate (GstLADSPA *ladspa);
|
|
|
|
static void gst_ladspa_activate (GstLADSPA *ladspa);
|
|
|
|
static void gst_ladspa_deactivate (GstLADSPA *ladspa);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
static GstElementStateReturn gst_ladspa_change_state (GstElement *element);
|
|
|
|
static void gst_ladspa_loop (GstElement *element);
|
2002-04-20 13:57:00 +00:00
|
|
|
static void gst_ladspa_chain (GstPad *pad,GstBuffer *buf);
|
2002-01-22 04:42:11 +00:00
|
|
|
static GstBuffer * gst_ladspa_get (GstPad *pad);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2002-01-22 04:42:11 +00:00
|
|
|
/* static guint gst_ladspa_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
static GstPlugin *ladspa_plugin;
|
|
|
|
static GHashTable *ladspa_descriptors;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
static GstBufferPool*
|
|
|
|
gst_ladspa_get_bufferpool (GstPad *pad)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GstBufferPool *bp;
|
2002-03-30 17:06:26 +00:00
|
|
|
GstLADSPA *ladspa = (GstLADSPA *) gst_pad_get_parent (pad);
|
2002-01-22 04:42:11 +00:00
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
|
|
|
|
|
|
|
|
if (oclass->numsrcpads > 0)
|
|
|
|
for (i=0;i<oclass->numsrcpads;i++)
|
2002-04-20 13:57:00 +00:00
|
|
|
if ((bp = gst_pad_get_bufferpool(ladspa->srcpads[i])) != NULL)
|
2002-01-22 04:42:11 +00:00
|
|
|
return bp;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
static void
|
|
|
|
gst_ladspa_class_init (GstLADSPAClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
LADSPA_Descriptor *desc;
|
|
|
|
gint i,current_portnum,sinkcount,srccount,controlcount;
|
|
|
|
gint hintdesc;
|
|
|
|
gint argtype,argperms;
|
|
|
|
GParamSpec *paramspec = NULL;
|
2002-01-22 04:42:11 +00:00
|
|
|
gchar *argname, *tempstr, *paren;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
gobject_class = (GObjectClass*)klass;
|
|
|
|
gstelement_class = (GstElementClass*)klass;
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_ladspa_set_property;
|
|
|
|
gobject_class->get_property = gst_ladspa_get_property;
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_ladspa_change_state;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* look up and store the ladspa descriptor */
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->descriptor = g_hash_table_lookup(ladspa_descriptors,GINT_TO_POINTER(G_TYPE_FROM_CLASS(klass)));
|
|
|
|
desc = klass->descriptor;
|
|
|
|
|
|
|
|
klass->numports = desc->PortCount;
|
|
|
|
|
|
|
|
klass->numsinkpads = 0;
|
|
|
|
klass->numsrcpads = 0;
|
|
|
|
klass->numcontrols = 0;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* walk through the ports, count the input, output and control ports */
|
2001-12-23 15:26:43 +00:00
|
|
|
for (i=0;i<desc->PortCount;i++) {
|
|
|
|
if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i]) &&
|
|
|
|
LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i])){
|
|
|
|
klass->numsinkpads++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i]) &&
|
|
|
|
LADSPA_IS_PORT_OUTPUT(desc->PortDescriptors[i])){
|
|
|
|
klass->numsrcpads++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LADSPA_IS_PORT_CONTROL(desc->PortDescriptors[i]) &&
|
|
|
|
LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i])){
|
|
|
|
klass->numcontrols++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
klass->srcpad_portnums = g_new0(gint,klass->numsrcpads);
|
|
|
|
klass->sinkpad_portnums = g_new0(gint,klass->numsinkpads);
|
|
|
|
klass->control_portnums = g_new0(gint,klass->numcontrols);
|
|
|
|
sinkcount = 0;
|
|
|
|
srccount = 0;
|
|
|
|
controlcount = 0;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* walk through the ports, note the portnums for srcpads, sinkpads and control
|
|
|
|
params */
|
2001-12-23 15:26:43 +00:00
|
|
|
for (i=0;i<desc->PortCount;i++) {
|
|
|
|
if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i]) &&
|
|
|
|
LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i])){
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "input port %d", i);
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->sinkpad_portnums[sinkcount++] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i]) &&
|
|
|
|
LADSPA_IS_PORT_OUTPUT(desc->PortDescriptors[i])){
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "output port %d", i);
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->srcpad_portnums[srccount++] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LADSPA_IS_PORT_CONTROL(desc->PortDescriptors[i]) &&
|
|
|
|
LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i])){
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "control port %d", i);
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->control_portnums[controlcount++] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* no sink pads - we'll use get mode and add params for samplerate and
|
|
|
|
buffersize */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (klass->numsinkpads == 0 && klass->numsrcpads > 0){
|
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SAMPLERATE,
|
|
|
|
g_param_spec_int("samplerate","samplerate","samplerate",
|
|
|
|
0,G_MAXINT,44100,G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFFERSIZE,
|
|
|
|
g_param_spec_int("buffersize","buffersize","buffersize",
|
|
|
|
0,G_MAXINT,64,G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* now build the contorl info from the control ports */
|
2001-12-23 15:26:43 +00:00
|
|
|
klass->control_info = g_new0(ladspa_control_info,klass->numcontrols);
|
|
|
|
|
|
|
|
for (i=0;i<klass->numcontrols;i++) {
|
|
|
|
current_portnum = klass->control_portnums[i];
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* short name for hint descriptor */
|
2001-12-23 15:26:43 +00:00
|
|
|
hintdesc = desc->PortRangeHints[current_portnum].HintDescriptor;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* get the various bits */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (LADSPA_IS_HINT_TOGGLED(hintdesc))
|
|
|
|
klass->control_info[i].toggled = TRUE;
|
|
|
|
if (LADSPA_IS_HINT_LOGARITHMIC(hintdesc))
|
|
|
|
klass->control_info[i].logarithmic = TRUE;
|
|
|
|
if (LADSPA_IS_HINT_INTEGER(hintdesc))
|
|
|
|
klass->control_info[i].integer = TRUE;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* figure out the argument details */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (klass->control_info[i].toggled) argtype = G_TYPE_BOOLEAN;
|
|
|
|
else if (klass->control_info[i].integer) argtype = G_TYPE_INT;
|
|
|
|
else argtype = G_TYPE_FLOAT;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* grab the bounds */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (LADSPA_IS_HINT_BOUNDED_BELOW(hintdesc)) {
|
|
|
|
klass->control_info[i].lower = TRUE;
|
|
|
|
klass->control_info[i].lowerbound =
|
|
|
|
desc->PortRangeHints[current_portnum].LowerBound;
|
|
|
|
} else {
|
|
|
|
if (argtype==G_TYPE_INT) klass->control_info[i].lowerbound = (gfloat)G_MININT;
|
2002-04-20 15:11:00 +00:00
|
|
|
if (argtype==G_TYPE_FLOAT) klass->control_info[i].lowerbound = -G_MAXFLOAT;
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (LADSPA_IS_HINT_BOUNDED_ABOVE(hintdesc)) {
|
|
|
|
klass->control_info[i].upper = TRUE;
|
|
|
|
klass->control_info[i].upperbound =
|
|
|
|
desc->PortRangeHints[current_portnum].UpperBound;
|
|
|
|
if (LADSPA_IS_HINT_SAMPLE_RATE(hintdesc))
|
|
|
|
klass->control_info[i].samplerate = TRUE;
|
|
|
|
} else {
|
|
|
|
if (argtype==G_TYPE_INT) klass->control_info[i].upperbound = (gfloat)G_MAXINT;
|
|
|
|
if (argtype==G_TYPE_FLOAT) klass->control_info[i].upperbound = G_MAXFLOAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[current_portnum])) {
|
|
|
|
argperms = G_PARAM_READWRITE;
|
|
|
|
klass->control_info[i].writable = TRUE;
|
|
|
|
} else {
|
|
|
|
argperms = G_PARAM_READABLE;
|
|
|
|
klass->control_info[i].writable = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
klass->control_info[i].name = g_strdup(desc->PortNames[current_portnum]);
|
|
|
|
argname = g_strdup(klass->control_info[i].name);
|
2002-01-22 04:42:11 +00:00
|
|
|
/* find out if there is a (unitname) at the end of the argname and get rid
|
|
|
|
of it */
|
|
|
|
paren = g_strrstr (argname, " (");
|
|
|
|
if (paren != NULL) {
|
|
|
|
*paren = '\0';
|
|
|
|
}
|
2002-01-10 01:17:29 +00:00
|
|
|
/* this is the same thing that param_spec_* will do */
|
2001-12-23 15:26:43 +00:00
|
|
|
g_strcanon (argname, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
|
2002-01-10 01:17:29 +00:00
|
|
|
/* satisfy glib2 (argname[0] must be [A-Za-z]) */
|
|
|
|
if (!((argname[0] >= 'a' && argname[0] <= 'z') || (argname[0] >= 'A' && argname[0] <= 'Z'))) {
|
|
|
|
tempstr = argname;
|
|
|
|
argname = g_strconcat("param-", argname, NULL);
|
|
|
|
g_free (tempstr);
|
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-10 01:17:29 +00:00
|
|
|
/* check for duplicate property names */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (g_object_class_find_property(G_OBJECT_CLASS(klass), argname) != NULL){
|
|
|
|
gint numarg=1;
|
|
|
|
gchar *numargname = g_strdup_printf("%s_%d",argname,numarg++);
|
|
|
|
while (g_object_class_find_property(G_OBJECT_CLASS(klass), numargname) != NULL){
|
|
|
|
g_free(numargname);
|
|
|
|
numargname = g_strdup_printf("%s_%d",argname,numarg++);
|
|
|
|
}
|
|
|
|
argname = numargname;
|
|
|
|
}
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
klass->control_info[i].param_name = argname;
|
|
|
|
|
|
|
|
GST_DEBUG (0, "adding arg %s from %s",argname, klass->control_info[i].name);
|
2002-01-10 01:17:29 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
if (argtype==G_TYPE_BOOLEAN){
|
|
|
|
paramspec = g_param_spec_boolean(argname,argname,argname, FALSE, argperms);
|
|
|
|
} else if (argtype==G_TYPE_INT){
|
|
|
|
paramspec = g_param_spec_int(argname,argname,argname,
|
2002-04-20 13:57:00 +00:00
|
|
|
(gint)klass->control_info[i].lowerbound,
|
|
|
|
(gint)klass->control_info[i].upperbound,
|
|
|
|
(gint)klass->control_info[i].lowerbound, argperms);
|
|
|
|
} else if (klass->control_info[i].samplerate){
|
|
|
|
paramspec = g_param_spec_float(argname,argname,argname,
|
|
|
|
0.0, G_MAXFLOAT,
|
|
|
|
0.0, argperms);
|
2001-12-23 15:26:43 +00:00
|
|
|
} else {
|
|
|
|
paramspec = g_param_spec_float(argname,argname,argname,
|
|
|
|
klass->control_info[i].lowerbound, klass->control_info[i].upperbound,
|
2002-04-20 13:57:00 +00:00
|
|
|
klass->control_info[i].lowerbound, argperms);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2002-01-10 01:17:29 +00:00
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), i+ARG_LAST, paramspec);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ladspa_init (GstLADSPA *ladspa)
|
|
|
|
{
|
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS(ladspa));
|
2002-04-20 13:57:00 +00:00
|
|
|
ladspa_control_info cinfo;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
LADSPA_Descriptor *desc;
|
|
|
|
gint i,sinkcount,srccount,controlcount;
|
|
|
|
|
|
|
|
desc = oclass->descriptor;
|
|
|
|
ladspa->descriptor = oclass->descriptor;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* allocate the various arrays */
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->srcpads = g_new0(GstPad*,oclass->numsrcpads);
|
|
|
|
ladspa->sinkpads = g_new0(GstPad*,oclass->numsinkpads);
|
|
|
|
ladspa->controls = g_new(gfloat,oclass->numcontrols);
|
2002-04-20 13:57:00 +00:00
|
|
|
ladspa->dpman = gst_dpman_new ("ladspa_dpman", GST_ELEMENT(ladspa));
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* walk through the ports and add all the pads */
|
2001-12-23 15:26:43 +00:00
|
|
|
sinkcount = 0;
|
|
|
|
srccount = 0;
|
|
|
|
controlcount = 0;
|
|
|
|
for (i=0;i<desc->PortCount;i++) {
|
2002-04-20 13:57:00 +00:00
|
|
|
|
|
|
|
if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i])){
|
|
|
|
gchar *canon_port_name = g_strdup((gchar *)desc->PortNames[i]);
|
|
|
|
g_strcanon (canon_port_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
|
|
|
|
if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i])) {
|
|
|
|
ladspa->sinkpads[sinkcount] = gst_pad_new_from_template (sinktempl, canon_port_name);
|
|
|
|
gst_element_add_pad(GST_ELEMENT(ladspa),ladspa->sinkpads[sinkcount]);
|
|
|
|
sinkcount++;
|
|
|
|
}
|
|
|
|
if (LADSPA_IS_PORT_OUTPUT(desc->PortDescriptors[i])) {
|
|
|
|
ladspa->srcpads[srccount] = gst_pad_new_from_template (srctempl, canon_port_name);
|
|
|
|
gst_element_add_pad(GST_ELEMENT(ladspa),ladspa->srcpads[srccount]);
|
|
|
|
srccount++;
|
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
if (LADSPA_IS_PORT_CONTROL(desc->PortDescriptors[i]) &&
|
|
|
|
LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i])) {
|
2002-04-20 13:57:00 +00:00
|
|
|
cinfo = oclass->control_info[controlcount];
|
2002-01-22 04:42:11 +00:00
|
|
|
/* use the lowerbound as the default value if it exists */
|
2002-04-20 13:57:00 +00:00
|
|
|
if (cinfo.lower){
|
|
|
|
ladspa->controls[controlcount]=cinfo.lowerbound;
|
2001-12-23 15:26:43 +00:00
|
|
|
} else {
|
|
|
|
ladspa->controls[controlcount] = 0.0;
|
|
|
|
}
|
2002-04-20 13:57:00 +00:00
|
|
|
|
|
|
|
/* set up dparams for this instance */
|
|
|
|
if (cinfo.toggled){
|
|
|
|
gst_dpman_add_required_dparam_callback (
|
|
|
|
ladspa->dpman,
|
|
|
|
g_param_spec_int(cinfo.param_name, cinfo.name, cinfo.name,
|
|
|
|
0, 1, (gint)(ladspa->controls[controlcount]), G_PARAM_READWRITE),
|
|
|
|
"int", gst_ladspa_update_int, &(ladspa->controls[controlcount])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (cinfo.integer){
|
|
|
|
gst_dpman_add_required_dparam_callback (
|
|
|
|
ladspa->dpman,
|
|
|
|
g_param_spec_int(cinfo.param_name, cinfo.name, cinfo.name,
|
|
|
|
(gint)cinfo.lowerbound, (gint)cinfo.upperbound,
|
|
|
|
(gint)ladspa->controls[controlcount], G_PARAM_READWRITE),
|
|
|
|
"int", gst_ladspa_update_int, &(ladspa->controls[controlcount])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (cinfo.samplerate){
|
|
|
|
gst_dpman_add_required_dparam_direct (
|
|
|
|
ladspa->dpman,
|
|
|
|
g_param_spec_float(cinfo.param_name, cinfo.name, cinfo.name,
|
|
|
|
cinfo.lowerbound, cinfo.upperbound,
|
|
|
|
ladspa->controls[controlcount], G_PARAM_READWRITE),
|
|
|
|
"hertz-rate-bound", &(ladspa->controls[controlcount])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gst_dpman_add_required_dparam_direct (
|
|
|
|
ladspa->dpman,
|
|
|
|
g_param_spec_float(cinfo.param_name, cinfo.name, cinfo.name,
|
|
|
|
cinfo.lowerbound, cinfo.upperbound,
|
|
|
|
ladspa->controls[controlcount], G_PARAM_READWRITE),
|
|
|
|
"float", &(ladspa->controls[controlcount])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
controlcount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ladspa->samplerate = 0;
|
2002-01-22 04:42:11 +00:00
|
|
|
ladspa->buffersize = 64;
|
|
|
|
ladspa->numbuffers = 16;
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->newcaps = FALSE;
|
|
|
|
ladspa->activated = FALSE;
|
2002-01-22 04:42:11 +00:00
|
|
|
ladspa->bufpool = NULL;
|
2002-04-20 21:42:51 +00:00
|
|
|
ladspa->inplace_broken = LADSPA_IS_INPLACE_BROKEN(ladspa->descriptor->Properties);
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
if (sinkcount==0 && srccount == 1) {
|
2002-01-22 04:42:11 +00:00
|
|
|
/* get mode (no sink pads) */
|
2002-04-20 13:57:00 +00:00
|
|
|
GST_DEBUG (0, "mono get mode with 1 src pad");
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->newcaps = TRUE;
|
|
|
|
ladspa->samplerate = 44100;
|
|
|
|
ladspa->buffersize = 64;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
gst_pad_set_connect_function (ladspa->srcpads[0], gst_ladspa_connect_get);
|
|
|
|
gst_pad_set_get_function (ladspa->srcpads[0], gst_ladspa_get);
|
|
|
|
|
|
|
|
} else if (sinkcount==1){
|
|
|
|
/* with one sink we can use the chain function */
|
|
|
|
GST_DEBUG (0, "chain mode");
|
2002-01-22 04:42:11 +00:00
|
|
|
|
|
|
|
gst_pad_set_connect_function (ladspa->sinkpads[0], gst_ladspa_connect);
|
2002-04-20 13:57:00 +00:00
|
|
|
gst_pad_set_chain_function (ladspa->sinkpads[0], gst_ladspa_chain);
|
2002-01-22 04:42:11 +00:00
|
|
|
gst_pad_set_bufferpool_function (ladspa->sinkpads[0], gst_ladspa_get_bufferpool);
|
2002-04-20 13:57:00 +00:00
|
|
|
} else if (sinkcount > 1){
|
|
|
|
/* more than one sink pad needs loop mode */
|
|
|
|
GST_DEBUG (0, "loop mode with %d sink pads and %d src pads", sinkcount, srccount);
|
2002-01-22 04:42:11 +00:00
|
|
|
|
|
|
|
for (i=0;i<sinkcount;i++) {
|
|
|
|
gst_pad_set_connect_function (ladspa->sinkpads[i], gst_ladspa_connect);
|
|
|
|
gst_pad_set_bufferpool_function (ladspa->sinkpads[i], gst_ladspa_get_bufferpool);
|
|
|
|
}
|
2002-03-30 17:06:26 +00:00
|
|
|
gst_element_set_loop_function (GST_ELEMENT (ladspa), gst_ladspa_loop);
|
2002-04-20 13:57:00 +00:00
|
|
|
}
|
|
|
|
else if (sinkcount==0 && srccount == 0){
|
|
|
|
/* for some reason these plugins exist - we'll just ignore them */
|
|
|
|
} else {
|
|
|
|
g_warning("%d sink pads, %d src pads not yet supported", sinkcount, srccount);
|
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
|
|
|
gst_ladspa_instantiate(ladspa);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
static void
|
|
|
|
gst_ladspa_update_int(const GValue *value, gpointer data)
|
|
|
|
{
|
|
|
|
gfloat *target = (gfloat*) data;
|
|
|
|
*target = (gfloat)g_value_get_int(value);
|
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
static GstPadConnectReturn
|
|
|
|
gst_ladspa_connect (GstPad *pad, GstCaps *caps)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2002-01-22 04:42:11 +00:00
|
|
|
GstLADSPA *ladspa = (GstLADSPA *) GST_PAD_PARENT (pad);
|
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
|
|
|
|
guint i;
|
2002-03-30 17:06:26 +00:00
|
|
|
gint rate;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (caps != NULL, GST_PAD_CONNECT_DELAYED);
|
|
|
|
g_return_val_if_fail (pad != NULL, GST_PAD_CONNECT_DELAYED);
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
if (gst_caps_get_int (caps, "rate", &rate)){
|
|
|
|
/* have to instantiate ladspa plugin when samplerate changes (groan) */
|
|
|
|
if (ladspa->samplerate != rate){
|
|
|
|
ladspa->samplerate = rate;
|
|
|
|
|
|
|
|
if (! gst_ladspa_instantiate(ladspa))
|
|
|
|
return GST_PAD_CONNECT_REFUSED;
|
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* if the caps are fixed, we are going to try to set all srcpads using this
|
|
|
|
one caps object. if any of the pads barfs, we'll refuse the connection. i'm
|
|
|
|
not sure if this is correct. */
|
|
|
|
if (GST_CAPS_IS_FIXED (caps)) {
|
|
|
|
for (i=0;i<oclass->numsrcpads;i++) {
|
|
|
|
if (! gst_pad_try_set_caps (ladspa->srcpads[i], caps))
|
|
|
|
return GST_PAD_CONNECT_REFUSED;
|
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
return GST_PAD_CONNECT_OK;
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
static GstPadConnectReturn
|
|
|
|
gst_ladspa_connect_get (GstPad *pad, GstCaps *caps)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2002-01-22 04:42:11 +00:00
|
|
|
GstLADSPA *ladspa = (GstLADSPA*)GST_OBJECT_PARENT (pad);
|
2002-03-30 17:06:26 +00:00
|
|
|
gint rate;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (caps != NULL, GST_PAD_CONNECT_DELAYED);
|
|
|
|
g_return_val_if_fail (pad != NULL, GST_PAD_CONNECT_DELAYED);
|
2002-04-20 13:57:00 +00:00
|
|
|
|
|
|
|
if (gst_caps_get_int (caps, "rate", &rate)){
|
|
|
|
if (ladspa->samplerate != rate) {
|
|
|
|
ladspa->samplerate = rate;
|
|
|
|
if (! gst_ladspa_instantiate(ladspa))
|
|
|
|
return GST_PAD_CONNECT_REFUSED;
|
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
return GST_PAD_CONNECT_OK;
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-01-22 04:42:11 +00:00
|
|
|
gst_ladspa_force_src_caps(GstLADSPA *ladspa, GstPad *pad)
|
|
|
|
{
|
2002-04-20 13:57:00 +00:00
|
|
|
GST_DEBUG (0, "forcing caps with rate %d", ladspa->samplerate);
|
2002-01-13 22:27:25 +00:00
|
|
|
gst_pad_try_set_caps (pad, gst_caps_new (
|
2001-12-23 15:26:43 +00:00
|
|
|
"ladspa_src_caps",
|
|
|
|
"audio/raw",
|
|
|
|
gst_props_new (
|
|
|
|
"format", GST_PROPS_STRING ("float"),
|
|
|
|
"layout", GST_PROPS_STRING ("gfloat"),
|
|
|
|
"intercept", GST_PROPS_FLOAT(0.0),
|
|
|
|
"slope", GST_PROPS_FLOAT(1.0),
|
|
|
|
"rate", GST_PROPS_INT (ladspa->samplerate),
|
|
|
|
"channels", GST_PROPS_INT (1),
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
));
|
|
|
|
ladspa->newcaps=FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GstLADSPA *ladspa = (GstLADSPA*)object;
|
|
|
|
gint cid = prop_id - ARG_LAST;
|
|
|
|
GstLADSPAClass *oclass;
|
|
|
|
ladspa_control_info *control_info;
|
|
|
|
gfloat val=0.0;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* these are only registered in get mode */
|
2001-12-23 15:26:43 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_SAMPLERATE:
|
|
|
|
ladspa->samplerate = g_value_get_int (value);
|
|
|
|
ladspa->newcaps=TRUE;
|
|
|
|
break;
|
|
|
|
case ARG_BUFFERSIZE:
|
|
|
|
ladspa->buffersize = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* is it a ladspa plugin arg? */
|
|
|
|
if (cid < 0) return;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (object));
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* verify it exists and is a control (not a port) */
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_if_fail(cid < oclass->numcontrols);
|
|
|
|
|
|
|
|
control_info = &(oclass->control_info[cid]);
|
|
|
|
g_return_if_fail (control_info->name != NULL);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* check to see if it's writable */
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_if_fail (control_info->writable);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* now see what type it is */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (control_info->toggled) {
|
|
|
|
if (g_value_get_boolean (value))
|
|
|
|
ladspa->controls[cid] = 1.0;
|
|
|
|
else
|
|
|
|
ladspa->controls[cid] = 0.0;
|
|
|
|
} else if (control_info->integer) {
|
|
|
|
val = (gfloat)g_value_get_int (value);
|
|
|
|
ladspa->controls[cid] = val;
|
|
|
|
} else {
|
|
|
|
val = g_value_get_float (value);
|
|
|
|
ladspa->controls[cid] = val;
|
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "set arg %s to %f", control_info->name, ladspa->controls[cid]);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ladspa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GstLADSPA *ladspa = (GstLADSPA*)object;
|
|
|
|
gint cid = prop_id - ARG_LAST;
|
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (object));
|
|
|
|
ladspa_control_info *control_info;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* these are only registered in get mode */
|
2001-12-23 15:26:43 +00:00
|
|
|
switch (prop_id){
|
|
|
|
case ARG_SAMPLERATE:
|
|
|
|
g_value_set_int (value, ladspa->samplerate);
|
|
|
|
break;
|
|
|
|
case ARG_BUFFERSIZE:
|
|
|
|
g_value_set_int (value, ladspa->buffersize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
if (cid < 0) return;
|
|
|
|
|
|
|
|
/* verify it exists and is a control (not a port) */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (cid >= oclass->numcontrols) return;
|
|
|
|
control_info = &(oclass->control_info[cid]);
|
|
|
|
if (control_info->name == NULL) return;
|
|
|
|
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "got arg %s as %f", control_info->name, ladspa->controls[cid]);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* now see what type it is */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (control_info->toggled) {
|
|
|
|
if (ladspa->controls[cid] == 1.0)
|
|
|
|
g_value_set_boolean (value, TRUE);
|
|
|
|
else
|
|
|
|
g_value_set_boolean (value, FALSE);
|
|
|
|
} else if (control_info->integer) {
|
|
|
|
g_value_set_int (value, (gint)ladspa->controls[cid]);
|
|
|
|
} else {
|
|
|
|
g_value_set_float (value, ladspa->controls[cid]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_ladspa_instantiate (GstLADSPA *ladspa)
|
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
|
|
|
int i;
|
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (ladspa));
|
|
|
|
gboolean was_activated;
|
|
|
|
|
|
|
|
desc = ladspa->descriptor;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* check for old handle */
|
2001-12-23 15:26:43 +00:00
|
|
|
was_activated = ladspa->activated;
|
|
|
|
if (ladspa->handle != NULL){
|
|
|
|
gst_ladspa_deactivate(ladspa);
|
|
|
|
desc->cleanup(ladspa->handle);
|
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* instantiate the plugin */
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "instantiating the plugin");
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->handle = desc->instantiate(desc,ladspa->samplerate);
|
|
|
|
g_return_val_if_fail (ladspa->handle != NULL, FALSE);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* walk through the ports and add all the arguments */
|
2001-12-23 15:26:43 +00:00
|
|
|
for (i=0;i<oclass->numcontrols;i++) {
|
2002-01-22 04:42:11 +00:00
|
|
|
/* connect the argument to the plugin */
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "added control port %d", oclass->control_portnums[i]);
|
2001-12-23 15:26:43 +00:00
|
|
|
desc->connect_port(ladspa->handle,
|
|
|
|
oclass->control_portnums[i],
|
|
|
|
&(ladspa->controls[i]));
|
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* reactivate if it was activated before the reinstantiation */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (was_activated){
|
|
|
|
gst_ladspa_activate(ladspa);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
|
|
|
gst_ladspa_change_state (GstElement *element)
|
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
|
|
|
GstLADSPA *ladspa = (GstLADSPA*)element;
|
|
|
|
desc = ladspa->descriptor;
|
|
|
|
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "changing state");
|
2001-12-23 15:26:43 +00:00
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
gst_ladspa_activate(ladspa);
|
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_NULL:
|
|
|
|
gst_ladspa_deactivate(ladspa);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ladspa_activate(GstLADSPA *ladspa)
|
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
|
|
|
desc = ladspa->descriptor;
|
|
|
|
|
|
|
|
if (ladspa->activated){
|
|
|
|
gst_ladspa_deactivate(ladspa);
|
|
|
|
}
|
|
|
|
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "activating");
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* activate the plugin (function might be null) */
|
|
|
|
if (desc->activate != NULL) {
|
2001-12-23 15:26:43 +00:00
|
|
|
desc->activate(ladspa->handle);
|
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->activated = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ladspa_deactivate(GstLADSPA *ladspa)
|
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
|
|
|
desc = ladspa->descriptor;
|
|
|
|
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "deactivating");
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* deactivate the plugin (function might be null) */
|
|
|
|
if (ladspa->activated && (desc->deactivate != NULL)) {
|
2001-12-23 15:26:43 +00:00
|
|
|
desc->deactivate(ladspa->handle);
|
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
ladspa->activated = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-20 13:57:00 +00:00
|
|
|
gst_ladspa_loop(GstElement *element)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
2002-04-20 13:57:00 +00:00
|
|
|
guint bufferbytesize, i, numsrcpads, numsinkpads, num_empty_pads;
|
|
|
|
guint num_processed, num_to_process;
|
2002-01-22 04:42:11 +00:00
|
|
|
GstEvent *event = NULL;
|
|
|
|
guint32 waiting;
|
2002-05-15 19:08:49 +00:00
|
|
|
guint32 got_bytes;
|
2002-04-20 13:57:00 +00:00
|
|
|
LADSPA_Data **data_in, **data_out;
|
|
|
|
GstBuffer **buffers_in, **buffers_out;
|
|
|
|
GstBufferPool *bufpool;
|
|
|
|
GstByteStream **bytestreams;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
GstLADSPA *ladspa = (GstLADSPA *)element;
|
|
|
|
GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (ladspa));
|
|
|
|
LADSPA_Descriptor *desc = ladspa->descriptor;
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
numsinkpads = oclass->numsinkpads;
|
|
|
|
numsrcpads = oclass->numsrcpads;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
data_in = g_new0(LADSPA_Data*, numsinkpads);
|
|
|
|
data_out = g_new0(LADSPA_Data*, numsrcpads);
|
|
|
|
buffers_in = g_new0(GstBuffer*, numsinkpads);
|
|
|
|
buffers_out = g_new0(GstBuffer*, numsrcpads);
|
|
|
|
bytestreams = g_new0(GstByteStream*, numsinkpads);
|
|
|
|
|
|
|
|
bufferbytesize = sizeof (LADSPA_Data) * ladspa->buffersize;
|
|
|
|
|
|
|
|
/* find a bufferpool */
|
|
|
|
bufpool = gst_buffer_pool_get_default (bufferbytesize, ladspa->numbuffers);
|
|
|
|
|
|
|
|
/* get the bytestreams for each pad */
|
|
|
|
for (i=0 ; i<numsinkpads ; i++){
|
|
|
|
bytestreams[i] = gst_bytestream_new (ladspa->sinkpads[i]);
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* since this is a loop element, we just loop here til things fall apart. */
|
|
|
|
do {
|
2002-04-20 13:57:00 +00:00
|
|
|
num_empty_pads = 0;
|
2002-01-22 04:42:11 +00:00
|
|
|
/* first get all the necessary data from the input ports */
|
2002-04-20 13:57:00 +00:00
|
|
|
for (i=0 ; i<numsinkpads ; i++){
|
|
|
|
GST_DEBUG (0, "pulling %u bytes through channel %d'sbytestream", bufferbytesize, i);
|
2002-05-15 19:08:49 +00:00
|
|
|
got_bytes = gst_bytestream_read (bytestreams[i], buffers_in + i, bufferbytesize);
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-05-15 19:08:49 +00:00
|
|
|
if (got_bytes != bufferbytesize) {
|
2002-01-22 04:42:11 +00:00
|
|
|
/* we need to check for an event. */
|
2002-04-20 13:57:00 +00:00
|
|
|
gst_bytestream_get_status (bytestreams[i], &waiting, &event);
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
if (event && GST_EVENT_TYPE(event) == GST_EVENT_EOS) {
|
|
|
|
/* if we get an EOS event from one of our sink pads, we assume that
|
|
|
|
pad's finished handling data. delete the bytestream, free up the
|
|
|
|
pad, and free up the memory associated with the input channel. */
|
|
|
|
GST_DEBUG (0, "got an EOS event on sinkpad %d", i);
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
2002-04-20 13:57:00 +00:00
|
|
|
/* CHECKME should maybe check for other events and try to pull more data here */
|
|
|
|
num_empty_pads++;
|
|
|
|
} else {
|
|
|
|
data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA(buffers_in[i]);
|
|
|
|
GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp;
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
if (num_empty_pads > 0){
|
|
|
|
if (num_empty_pads < numsinkpads){
|
|
|
|
/* only some pads have EOS, need to create some empty buffers */
|
|
|
|
for (i=0 ; i<numsinkpads ; i++){
|
|
|
|
if (buffers_in[i] == NULL){
|
|
|
|
int x;
|
|
|
|
LADSPA_Data *data;
|
|
|
|
buffers_in[i] = gst_buffer_new_from_pool (ladspa->bufpool, 0, 0);
|
|
|
|
GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp;
|
|
|
|
data_in[i] = data = (LADSPA_Data *) GST_BUFFER_DATA(buffers_in[i]);
|
|
|
|
for (x=0 ; x < ladspa->buffersize ; x++)
|
|
|
|
data[x] = 0.0F;
|
|
|
|
|
|
|
|
data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA(buffers_in[i]);
|
|
|
|
GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* all pads have EOS, time to quit */
|
|
|
|
/* CHECKME do I have to push EOS events here? */
|
|
|
|
GST_DEBUG (0, "All sink pads have EOS, finishing.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we now have a full set of buffers_in.
|
|
|
|
* now share or create the buffers_out */
|
|
|
|
for (i=0 ; i<numsrcpads ; i++){
|
2002-04-20 21:42:51 +00:00
|
|
|
if (i <= numsinkpads && !ladspa->inplace_broken){
|
2002-04-20 13:57:00 +00:00
|
|
|
/* we can share buffers */
|
|
|
|
buffers_out[i] = buffers_in[i];
|
|
|
|
data_out[i] = data_in[i];
|
|
|
|
} else {
|
|
|
|
buffers_out[i] = gst_buffer_new_from_pool (bufpool, 0, 0);
|
|
|
|
GST_BUFFER_TIMESTAMP(buffers_out[i]) = ladspa->timestamp;
|
|
|
|
data_out[i] = (LADSPA_Data *) GST_BUFFER_DATA(buffers_out[i]);
|
|
|
|
}
|
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-05-29 18:54:17 +00:00
|
|
|
GST_DPMAN_PREPROCESS(ladspa->dpman, ladspa->buffersize, ladspa->timestamp);
|
2002-04-20 13:57:00 +00:00
|
|
|
num_processed = 0;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
/* split up processing of the buffer into chunks so that dparams can
|
|
|
|
* be updated when required.
|
|
|
|
* In many cases the buffer will be processed in one chunk anyway.
|
|
|
|
*/
|
2002-05-29 18:54:17 +00:00
|
|
|
while(GST_DPMAN_PROCESS(ladspa->dpman, num_processed)) {
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-05-29 18:54:17 +00:00
|
|
|
num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
|
2002-04-20 13:57:00 +00:00
|
|
|
for (i=0 ; i<numsinkpads ; i++){
|
|
|
|
desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[i], data_in[i]);
|
|
|
|
}
|
|
|
|
for (i=0 ; i<numsrcpads ; i++){
|
|
|
|
desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i], data_out[i]);
|
|
|
|
}
|
|
|
|
desc->run(ladspa->handle, num_to_process);
|
|
|
|
for (i=0 ; i<numsinkpads ; i++){
|
|
|
|
data_in[i] += num_to_process;
|
|
|
|
}
|
|
|
|
for (i=0 ; i<numsrcpads ; i++){
|
|
|
|
data_out[i] += num_to_process;
|
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-05-29 18:54:17 +00:00
|
|
|
num_processed += num_to_process;
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
2002-04-20 13:57:00 +00:00
|
|
|
|
|
|
|
for (i=0 ; i<numsrcpads ; i++) {
|
2002-03-24 22:07:03 +00:00
|
|
|
GST_DEBUG (0, "pushing buffer (%p) on src pad %d", buffers_out[i], i);
|
2002-01-22 04:42:11 +00:00
|
|
|
gst_pad_push (ladspa->srcpads[i], buffers_out[i]);
|
2002-04-20 13:57:00 +00:00
|
|
|
|
|
|
|
data_out[i] = NULL;
|
2002-01-22 04:42:11 +00:00
|
|
|
buffers_out[i] = NULL;
|
|
|
|
}
|
2002-04-20 13:57:00 +00:00
|
|
|
for (i=0 ; i<numsinkpads ; i++) {
|
2002-04-20 21:42:51 +00:00
|
|
|
if (i > numsrcpads || ladspa->inplace_broken){
|
2002-04-20 13:57:00 +00:00
|
|
|
/* we have some buffers to unref */
|
|
|
|
gst_buffer_unref(buffers_in[i]);
|
|
|
|
}
|
|
|
|
data_in[i] = NULL;
|
|
|
|
buffers_in[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ladspa->timestamp += ladspa->buffersize * 10^9 / ladspa->samplerate;
|
2002-01-22 04:42:11 +00:00
|
|
|
} while (TRUE);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-04-20 15:11:00 +00:00
|
|
|
gst_buffer_pool_unref(bufpool);
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
for (i=0 ; i<numsinkpads ; i++){
|
|
|
|
gst_bytestream_destroy (bytestreams[i]);
|
|
|
|
}
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
g_free (buffers_out);
|
2002-04-20 13:57:00 +00:00
|
|
|
g_free (buffers_in);
|
|
|
|
g_free (data_out);
|
|
|
|
g_free (data_in);
|
|
|
|
g_free (bytestreams);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-20 13:57:00 +00:00
|
|
|
gst_ladspa_chain (GstPad *pad, GstBuffer *buf)
|
2001-12-23 15:26:43 +00:00
|
|
|
{
|
|
|
|
LADSPA_Descriptor *desc;
|
2002-04-20 21:42:51 +00:00
|
|
|
LADSPA_Data *data_in, **data_out = NULL;
|
|
|
|
GstBuffer **buffers_out = NULL;
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
unsigned long num_samples;
|
2002-04-20 13:57:00 +00:00
|
|
|
guint num_to_process, num_processed, i, numsrcpads;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
GstLADSPA *ladspa;
|
|
|
|
GstLADSPAClass *oclass;
|
|
|
|
|
|
|
|
g_return_if_fail(pad != NULL);
|
|
|
|
g_return_if_fail(GST_IS_PAD(pad));
|
|
|
|
g_return_if_fail(buf != NULL);
|
|
|
|
|
|
|
|
ladspa = (GstLADSPA *)gst_pad_get_parent (pad);
|
|
|
|
g_return_if_fail(ladspa != NULL);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* this might happen if caps nego hasn't happened */
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_if_fail(ladspa->handle != NULL);
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
|
|
|
|
|
|
|
|
if (GST_IS_EVENT (buf)) {
|
|
|
|
/* push the event out all the src pads */
|
|
|
|
for (i=0 ; i<oclass->numsrcpads ; i++){
|
|
|
|
gst_pad_push (ladspa->srcpads[0], buf);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
data_in = (LADSPA_Data *) GST_BUFFER_DATA(buf);
|
|
|
|
num_samples = GST_BUFFER_SIZE(buf) / sizeof(gfloat);
|
|
|
|
numsrcpads = oclass->numsrcpads;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
desc = ladspa->descriptor;
|
|
|
|
|
|
|
|
if (numsrcpads > 0){
|
|
|
|
guint num_created_buffers = 0;
|
|
|
|
buffers_out = g_new(GstBuffer*, numsrcpads);
|
|
|
|
data_out = g_new(LADSPA_Data*, numsrcpads);
|
|
|
|
|
2002-04-20 21:42:51 +00:00
|
|
|
if (ladspa->inplace_broken){
|
2002-04-20 13:57:00 +00:00
|
|
|
num_created_buffers = numsrcpads;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* we can share the buffer for input and output */
|
|
|
|
buffers_out[0] = buf;
|
|
|
|
data_out[0] = (LADSPA_Data *)GST_BUFFER_DATA(buf);
|
|
|
|
num_created_buffers = numsrcpads - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_created_buffers > 0){
|
|
|
|
GstBufferPool *bufpool;
|
|
|
|
bufpool = gst_buffer_pool_get_default (sizeof (LADSPA_Data) * GST_BUFFER_SIZE(buf), ladspa->numbuffers);
|
|
|
|
|
|
|
|
for (i = numsrcpads - num_created_buffers ; i<numsrcpads ; i++){
|
|
|
|
buffers_out[i] = gst_buffer_new_from_pool (ladspa->bufpool, 0, 0);
|
|
|
|
GST_BUFFER_TIMESTAMP(buffers_out[i]) = GST_BUFFER_TIMESTAMP(buf);
|
|
|
|
data_out[i] = (LADSPA_Data *) GST_BUFFER_DATA(buffers_out[i]);
|
|
|
|
}
|
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-05-29 18:54:17 +00:00
|
|
|
GST_DPMAN_PREPROCESS(ladspa->dpman, num_samples, GST_BUFFER_TIMESTAMP(buf));
|
2002-04-20 13:57:00 +00:00
|
|
|
num_processed = 0;
|
|
|
|
|
|
|
|
/* split up processing of the buffer into chunks so that dparams can
|
|
|
|
* be updated when required.
|
|
|
|
* In many cases the buffer will be processed in one chunk anyway.
|
|
|
|
*/
|
2002-05-29 18:54:17 +00:00
|
|
|
while(GST_DPMAN_PROCESS(ladspa->dpman, num_processed)) {
|
|
|
|
num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
desc->connect_port(ladspa->handle,oclass->sinkpad_portnums[0],data_in);
|
|
|
|
for (i=0 ; i<numsrcpads ; i++){
|
|
|
|
desc->connect_port(ladspa->handle,oclass->srcpad_portnums[i],data_out[i]);
|
|
|
|
}
|
|
|
|
desc->run(ladspa->handle, num_to_process);
|
|
|
|
|
|
|
|
data_in += num_to_process;
|
|
|
|
for (i=0 ; i<numsrcpads ; i++){
|
|
|
|
data_out[i] += num_to_process;
|
|
|
|
}
|
|
|
|
num_processed += num_to_process;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numsrcpads > 0){
|
|
|
|
for (i=0 ; i<numsrcpads ; i++){
|
|
|
|
gst_pad_push (ladspa->srcpads[i], buffers_out[i]);
|
|
|
|
}
|
|
|
|
g_free(buffers_out);
|
|
|
|
g_free(data_out);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we have reached here, there are no src pads */
|
|
|
|
gst_buffer_unref(buf);
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstBuffer *
|
2002-01-22 04:42:11 +00:00
|
|
|
gst_ladspa_get(GstPad *pad)
|
2002-04-20 13:57:00 +00:00
|
|
|
{
|
2001-12-23 15:26:43 +00:00
|
|
|
GstLADSPA *ladspa;
|
|
|
|
GstLADSPAClass *oclass;
|
2002-04-20 13:57:00 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
GstBuffer *buf;
|
2002-04-20 13:57:00 +00:00
|
|
|
LADSPA_Data *data;
|
|
|
|
LADSPA_Descriptor *desc;
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
guint num_to_process, num_processed;
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_val_if_fail(pad != NULL, NULL);
|
|
|
|
g_return_val_if_fail(GST_IS_PAD(pad), NULL);
|
|
|
|
|
|
|
|
ladspa = (GstLADSPA *)gst_pad_get_parent (pad);
|
|
|
|
g_return_val_if_fail(ladspa != NULL, NULL);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* this might happen if caps nego hasn't happened */
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_val_if_fail(ladspa->handle != NULL, NULL);
|
|
|
|
|
|
|
|
oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS(ladspa));
|
2002-01-22 04:42:11 +00:00
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
/* force src pad to set caps */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (ladspa->newcaps) {
|
2002-04-20 13:57:00 +00:00
|
|
|
gst_ladspa_force_src_caps(ladspa, ladspa->srcpads[0]);
|
2002-01-22 04:42:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get a bufferpool */
|
|
|
|
if (ladspa->bufpool == NULL) {
|
2002-04-20 13:57:00 +00:00
|
|
|
ladspa->bufpool = gst_pad_get_bufferpool (ladspa->srcpads[0]);
|
|
|
|
if (ladspa->bufpool == NULL) {
|
|
|
|
ladspa->bufpool = gst_buffer_pool_get_default (sizeof (LADSPA_Data) * ladspa->buffersize, ladspa->numbuffers);
|
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
}
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
buf = gst_buffer_new_from_pool (ladspa->bufpool, 0, 0);
|
2002-01-22 04:42:11 +00:00
|
|
|
GST_BUFFER_TIMESTAMP(buf) = ladspa->timestamp;
|
2002-04-20 13:57:00 +00:00
|
|
|
data = (LADSPA_Data *) GST_BUFFER_DATA(buf);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
desc = ladspa->descriptor;
|
2002-05-29 18:54:17 +00:00
|
|
|
GST_DPMAN_PREPROCESS(ladspa->dpman, ladspa->buffersize, ladspa->timestamp);
|
2002-04-20 13:57:00 +00:00
|
|
|
num_processed = 0;
|
|
|
|
|
|
|
|
/* split up processing of the buffer into chunks so that dparams can
|
|
|
|
* be updated when required.
|
|
|
|
* In many cases the buffer will be processed in one chunk anyway.
|
|
|
|
*/
|
2002-05-29 18:54:17 +00:00
|
|
|
while(GST_DPMAN_PROCESS(ladspa->dpman, num_processed)) {
|
|
|
|
num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
|
|
|
|
|
2002-05-30 04:16:34 +00:00
|
|
|
/* update timestamp */
|
|
|
|
ladspa->timestamp += num_to_process * GST_SECOND / ladspa->samplerate;
|
|
|
|
|
2002-04-20 13:57:00 +00:00
|
|
|
desc->connect_port(ladspa->handle,oclass->srcpad_portnums[0],data);
|
|
|
|
desc->run(ladspa->handle, num_to_process);
|
|
|
|
|
|
|
|
data += num_to_process;
|
|
|
|
num_processed = num_to_process;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ladspa_describe_plugin(const char *pcFullFilename,
|
|
|
|
void *pvPluginHandle,
|
|
|
|
LADSPA_Descriptor_Function pfDescriptorFunction)
|
|
|
|
{
|
|
|
|
const LADSPA_Descriptor *desc;
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
GstElementDetails *details;
|
|
|
|
GTypeInfo typeinfo = {
|
2002-01-22 04:42:11 +00:00
|
|
|
sizeof(GstLADSPAClass),
|
|
|
|
NULL,
|
2001-12-23 15:26:43 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc)gst_ladspa_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstLADSPA),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc)gst_ladspa_init,
|
|
|
|
};
|
|
|
|
GType type;
|
|
|
|
GstElementFactory *factory;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* walk through all the plugins in this pluginlibrary */
|
2001-12-23 15:26:43 +00:00
|
|
|
i = 0;
|
|
|
|
while ((desc = pfDescriptorFunction(i++))) {
|
|
|
|
gchar *type_name;
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* construct the type */
|
2001-12-23 15:26:43 +00:00
|
|
|
type_name = g_strdup_printf("ladspa_%s",desc->Label);
|
|
|
|
g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-_+", '-');
|
2002-01-22 04:42:11 +00:00
|
|
|
/* if it's already registered, drop it */
|
2001-12-23 15:26:43 +00:00
|
|
|
if (g_type_from_name(type_name)) {
|
|
|
|
g_free(type_name);
|
|
|
|
continue;
|
|
|
|
}
|
2002-01-22 04:42:11 +00:00
|
|
|
/* create the type now */
|
|
|
|
type = g_type_register_static(GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
|
2001-12-23 15:26:43 +00:00
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* construct the element details struct */
|
2001-12-23 15:26:43 +00:00
|
|
|
details = g_new0(GstElementDetails,1);
|
|
|
|
details->longname = g_strdup(desc->Name);
|
2002-04-20 21:42:51 +00:00
|
|
|
details->klass = "Filter/Audio/LADSPA";
|
2001-12-23 15:26:43 +00:00
|
|
|
details->description = details->longname;
|
|
|
|
details->version = g_strdup_printf("%ld",desc->UniqueID);
|
|
|
|
details->author = g_strdup(desc->Maker);
|
|
|
|
details->copyright = g_strdup(desc->Copyright);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* register the plugin with gstreamer */
|
2002-04-11 20:42:26 +00:00
|
|
|
factory = gst_element_factory_new(type_name,type,details);
|
2001-12-23 15:26:43 +00:00
|
|
|
g_return_if_fail(factory != NULL);
|
|
|
|
gst_plugin_add_feature (ladspa_plugin, GST_PLUGIN_FEATURE (factory));
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* add this plugin to the hash */
|
2001-12-23 15:26:43 +00:00
|
|
|
g_hash_table_insert(ladspa_descriptors,
|
|
|
|
GINT_TO_POINTER(type),
|
|
|
|
(gpointer)desc);
|
|
|
|
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
/* only add sink padtemplate if there are sinkpads */
|
2001-12-23 15:26:43 +00:00
|
|
|
for (j=0;j<desc->PortCount;j++) {
|
|
|
|
if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[j]) &&
|
|
|
|
LADSPA_IS_PORT_INPUT(desc->PortDescriptors[j])) {
|
|
|
|
sinktempl = ladspa_sink_factory();
|
2002-04-11 20:42:26 +00:00
|
|
|
gst_element_factory_add_pad_template (factory, sinktempl);
|
2001-12-23 15:26:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-04-20 13:57:00 +00:00
|
|
|
|
|
|
|
/* only add src padtemplate if there are srcpads */
|
|
|
|
for (j=0;j<desc->PortCount;j++) {
|
|
|
|
if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[j]) &&
|
|
|
|
LADSPA_IS_PORT_OUTPUT(desc->PortDescriptors[j])) {
|
|
|
|
srctempl = ladspa_src_factory();
|
|
|
|
gst_element_factory_add_pad_template (factory, srctempl);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-12-23 15:26:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_init (GModule *module, GstPlugin *plugin)
|
|
|
|
{
|
|
|
|
ladspa_descriptors = g_hash_table_new(NULL,NULL);
|
|
|
|
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
|
|
|
|
|
|
|
ladspa_plugin = plugin;
|
|
|
|
|
|
|
|
LADSPAPluginSearch(ladspa_describe_plugin);
|
|
|
|
|
2002-01-22 04:42:11 +00:00
|
|
|
if (! gst_library_load ("gstbytestream")) {
|
|
|
|
gst_info ("gstladspa: could not load support library: 'gstbytestream'\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-04-20 13:57:00 +00:00
|
|
|
|
|
|
|
if (! gst_library_load ("gstcontrol")) {
|
|
|
|
gst_info ("gstladspa: could not load support library: 'gstcontrol'\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-12-23 15:26:43 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GstPluginDesc plugin_desc = {
|
|
|
|
GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"ladspa",
|
|
|
|
plugin_init
|
|
|
|
};
|
|
|
|
|