216c3052921550077186ebbac7c10d98de3a692e
[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 struct {
75     GstPad *pad;
76     void *data;
77     const gchar *name;
78     const gchar *peer_name;
79     GstByteStream *bs;
80     jack_port_t *port;
81 } GstJackPad;
82
83 struct _GstJack {
84     GstElement element;
85
86     /* list of GstJackPads */
87     GList *pads;
88
89     /* for convenience */
90     GstPadDirection direction;
91
92     gchar *port_name_prefix;
93
94     GstJackBin *bin;
95 };
96
97 struct _GstJackClass {
98     GstElementClass parent_class;
99 };
100
101 struct _GstJackBin {
102     GstBin bin;
103
104     jack_client_t *client;
105     gint default_new_port_number;
106
107     /* lists of GstJackPads */
108     GList *sink_pads;
109     GList *src_pads;
110
111     gchar *client_name;
112
113     guint rate;
114     jack_nframes_t nframes;
115 };
116
117 struct _GstJackBinClass {
118     GstBinClass parent_class;
119 };
120
121
122 GType gst_jack_get_type (void);
123 GType gst_jack_bin_get_type (void);
124 GType gst_jack_sink_get_type (void);
125 GType gst_jack_src_get_type (void);
126
127
128 #endif /* __GST_JACK_H__ */