summaryrefslogtreecommitdiff
path: root/ext/lv2/gstlv2utils.h
blob: b179e36eea3ceb6c3f992c2f46a8eb55a84b043e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* GStreamer
 * Copyright (C) 2016 Thibault Saunier <thibault.saunier@collabora.com>
 *               2016 Stefan Sauer <ensonic@users.sf.net>
 *
 * gstlv2utils.h: Header for LV2 plugin utils
 *
 * 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_LV2_UTILS_H__
#define __GST_LV2_UTILS_H__

#include <gst/gst.h>
#include <gst/audio/audio.h>
#include <gst/audio/audio-channels.h>

#include <lilv/lilv.h>

G_BEGIN_DECLS

typedef struct _GstLV2Group GstLV2Group;
typedef struct _GstLV2Port GstLV2Port;

typedef struct _GstLV2 GstLV2;
typedef struct _GstLV2Class GstLV2Class;

struct _GstLV2Group
{
  gchar *uri; /**< RDF resource (URI or blank node) */
  guint pad; /**< Gst pad index */
  gchar *symbol; /**< Gst pad name / LV2 group symbol */
  GArray *ports; /**< Array of GstLV2Port */
  /* FIXME: not set as of now */
  gboolean has_roles; /**< TRUE iff all ports have a known role */
};

typedef enum {
  GST_LV2_PORT_AUDIO = 0,
  GST_LV2_PORT_CONTROL,
  GST_LV2_PORT_CV
} GstLV2PortType;

struct _GstLV2Port
{
  gint index; /**< LV2 port index (on LV2 plugin) */
  GstLV2PortType type; /**< Port type */
  /**< Gst pad index (iff not part of a group), only for audio ports */
  gint pad;
  /* FIXME: not set as of now */
  LilvNode *role; /**< Channel position / port role */
  GstAudioChannelPosition position; /**< Channel position */
};

struct _GstLV2
{
  GstLV2Class *klass;

  LilvInstance *instance;
  GHashTable *presets;

  gboolean activated;
  unsigned long rate;

  struct
  {
    struct
    {
      gfloat *in;
      gfloat *out;
    } control;
  } ports;
};

struct _GstLV2Class
{
  guint properties;

  const LilvPlugin *plugin;
  GHashTable *sym_to_name;

  gint num_control_in, num_control_out;
  gint num_cv_in, num_cv_out;

  GstLV2Group in_group; /**< Array of GstLV2Group */
  GstLV2Group out_group; /**< Array of GstLV2Group */
  GArray *control_in_ports; /**< Array of GstLV2Port */
  GArray *control_out_ports; /**< Array of GstLV2Port */
};

gboolean gst_lv2_check_required_features (const LilvPlugin * lv2plugin);

void gst_lv2_host_init (void);

gchar **gst_lv2_get_preset_names (GstLV2 * lv2, GstObject * obj);
gboolean gst_lv2_load_preset (GstLV2 * lv2, GstObject * obj, const gchar * name);
gboolean gst_lv2_save_preset (GstLV2 * lv2, GstObject * obj, const gchar * name);
gboolean gst_lv2_delete_preset (GstLV2 * lv2, GstObject * obj, const gchar * name);


void gst_lv2_init (GstLV2 * lv2, GstLV2Class * lv2_class);
void gst_lv2_finalize (GstLV2 * lv2);

gboolean gst_lv2_setup (GstLV2 * lv2, unsigned long rate);
gboolean gst_lv2_cleanup (GstLV2 * lv2, GstObject *obj);

void gst_lv2_object_set_property (GstLV2 * lv2, GObject * object,
    guint prop_id, const GValue * value, GParamSpec * pspec);
void gst_lv2_object_get_property (GstLV2 * lv2, GObject * object,
    guint prop_id, GValue * value, GParamSpec * pspec);

void gst_lv2_class_install_properties (GstLV2Class * lv2_class,
    GObjectClass * object_class, guint offset);
void gst_lv2_element_class_set_metadata (GstLV2Class * lv2_class,
    GstElementClass * elem_class, const gchar * lv2_class_tags);

void gst_lv2_class_init (GstLV2Class * lv2_class, GType type);
void gst_lv2_class_finalize (GstLV2Class * lv2_class);

G_END_DECLS

#endif /* __GST_LV2_UTILS_H__ */