conform to the buffer-frames props entry -- much nicer now...
[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     GST_JACK_OPEN = GST_BIN_FLAG_LAST,
69     GST_JACK_ACTIVE,
70     GST_JACK_FLAG_LAST = GST_BIN_FLAG_LAST + 3,
71 };
72
73
74 typedef jack_default_audio_sample_t sample_t;
75
76 typedef struct {
77     GstPad *pad;
78     void *data;
79     const gchar *name;
80     const gchar *peer_name;
81     jack_port_t *port;
82 } GstJackPad;
83
84 struct _GstJack {
85     GstElement element;
86
87     /* list of GstJackPads */
88     GList *pads;
89
90     /* for convenience */
91     GstPadDirection direction;
92
93     gchar *port_name_prefix;
94
95     GstJackBin *bin;
96 };
97
98 struct _GstJackClass {
99     GstElementClass parent_class;
100 };
101
102 struct _GstJackBin {
103     GstBin bin;
104
105     jack_client_t *client;
106     gint default_new_port_number;
107
108     /* lists of GstJackPads */
109     GList *sink_pads;
110     GList *src_pads;
111
112     gchar *client_name;
113
114     guint rate;
115     jack_nframes_t nframes;
116 };
117
118 struct _GstJackBinClass {
119     GstBinClass parent_class;
120 };
121
122
123 GType gst_jack_get_type (void);
124 GType gst_jack_bin_get_type (void);
125 GType gst_jack_sink_get_type (void);
126 GType gst_jack_src_get_type (void);
127
128
129 #endif /* __GST_JACK_H__ */