f5a5416fba1018ec960fe4686fbf12953216eb64
[platform/upstream/gst-plugins-good.git] / ext / jack / gstjack.h
1 /* -*- Mode: C; c-basic-offset: 4 -*- */
2 /*
3     Copyright (C) 2002 Andy Wingo <wingo@pobox.com>
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public
16     License along with this library; if not, write to the Free
17     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __GST_JACK_H__
21 #define __GST_JACK_H__
22
23 #include <jack/jack.h>
24 #include <gst/gst.h>
25 #include <gst/bytestream/bytestream.h>
26
27 //#define JACK_DEBUG(str, a...) g_message (str, ##a)
28 #define JACK_DEBUG(str, a...)
29
30 #define GST_JACK(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_JACK, GstJack)
31 #define GST_JACK_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_JACK, GstJackClass)
32 #define GST_IS_JACK(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_JACK)
33 #define GST_IS_JACK_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_JACK)
34 #define GST_TYPE_JACK gst_jack_get_type()
35
36 #define GST_JACK_SINK(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_JACK_SINK, GstJack)
37 #define GST_JACK_SINK_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_JACK_SINK, GstJackClass)
38 #define GST_IS_JACK_SINK(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_JACK_SINK)
39 #define GST_IS_JACK_SINK_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_JACK_SINK)
40 #define GST_TYPE_JACK_SINK gst_jack_sink_get_type()
41
42 #define GST_JACK_SRC(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_JACK_SRC, GstJack)
43 #define GST_JACK_SRC_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_JACK_SRC, GstJackClass)
44 #define GST_IS_JACK_SRC(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_JACK_SRC)
45 #define GST_IS_JACK_SRC_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_JACK_SRC)
46 #define GST_TYPE_JACK_SRC gst_jack_src_get_type()
47
48 #define GST_JACK_BIN(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, GST_TYPE_JACK_BIN, GstJackBin)
49 #define GST_JACK_BIN_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, GST_TYPE_JACK_BIN, GstJackClass)
50 #define GST_IS_JACK_BIN(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, GST_TYPE_JACK_BIN)
51 #define GST_IS_JACK_BIN_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_JACK_BIN)
52 #define GST_TYPE_JACK_BIN gst_jack_bin_get_type()
53
54 #define GST_JACK_PAD(l) ((GstJackPad*)l->data)  /* l is a GList */
55
56
57 typedef struct _GstJack GstJack;
58 typedef struct _GstJackClass GstJackClass;
59 typedef struct _GstJackBin GstJackBin;
60 typedef struct _GstJackBinClass GstJackBinClass;
61 typedef GstJack GstJackSink;
62 typedef GstJackClass GstJackSinkClass;
63 typedef GstJack GstJackSrc;
64 typedef GstJackClass GstJackSrcClass;
65
66
67 enum
68 {
69   GST_JACK_OPEN = GST_BIN_FLAG_LAST,
70   GST_JACK_ACTIVE,
71   GST_JACK_FLAG_LAST = GST_BIN_FLAG_LAST + 3,
72 };
73
74
75 typedef jack_default_audio_sample_t sample_t;
76
77 typedef struct
78 {
79   GstPad *pad;
80   void *data;
81   const gchar *name;
82   const gchar *peer_name;
83   jack_port_t *port;
84 } GstJackPad;
85
86 struct _GstJack
87 {
88   GstElement element;
89
90   /* list of GstJackPads */
91   GList *pads;
92
93   /* for convenience */
94   GstPadDirection direction;
95
96   gchar *port_name_prefix;
97
98   GstJackBin *bin;
99 };
100
101 struct _GstJackClass
102 {
103   GstElementClass parent_class;
104 };
105
106 struct _GstJackBin
107 {
108   GstBin bin;
109
110   jack_client_t *client;
111   gint default_new_port_number;
112
113   /* lists of GstJackPads */
114   GList *sink_pads;
115   GList *src_pads;
116
117   gchar *client_name;
118
119   guint rate;
120   jack_nframes_t nframes;
121 };
122
123 struct _GstJackBinClass
124 {
125   GstBinClass parent_class;
126 };
127
128
129 GType gst_jack_get_type (void);
130 GType gst_jack_bin_get_type (void);
131 GType gst_jack_sink_get_type (void);
132 GType gst_jack_src_get_type (void);
133
134
135 #endif /* __GST_JACK_H__ */