Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / ext / pulse / pulseprobe.h
1 /*-*- Mode: C; c-basic-offset: 2 -*-*/
2
3 /*
4  *  GStreamer pulseaudio plugin
5  *
6  *  Copyright (c) 2004-2008 Lennart Poettering
7  *
8  *  gst-pulse is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU Lesser General Public License as
10  *  published by the Free Software Foundation; either version 2.1 of the
11  *  License, or (at your option) any later version.
12  *
13  *  gst-pulse is distributed in the hope that it will be useful, but
14  *  WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  *  Lesser General Public License for more details.
17  *
18  *  You should have received a copy of the GNU Lesser General Public
19  *  License along with gst-pulse; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21  *  USA.
22  */
23
24 #ifndef __GST_PULSEPROBE_H__
25 #define __GST_PULSEPROBE_H__
26
27 #include <gst/gst.h>
28
29 G_BEGIN_DECLS
30
31 #include <gst/interfaces/propertyprobe.h>
32 #include <pulse/pulseaudio.h>
33 #include <pulse/thread-mainloop.h>
34
35 typedef struct _GstPulseProbe GstPulseProbe;
36
37 struct _GstPulseProbe
38 {
39   GObject *object;
40   gchar *server;
41
42   GList *devices;
43   gboolean devices_valid:1;
44
45   gboolean operation_success:1;
46
47   gboolean enumerate_sinks:1;
48   gboolean enumerate_sources:1;
49
50   pa_threaded_mainloop *mainloop;
51   pa_context *context;
52
53   GList *properties;
54   guint prop_id;
55 };
56
57 GstPulseProbe *gst_pulseprobe_new (GObject *object, GObjectClass * klass,
58     guint prop_id, const gchar * server, gboolean sinks, gboolean sources);
59 void gst_pulseprobe_free (GstPulseProbe * probe);
60
61 const GList *gst_pulseprobe_get_properties (GstPulseProbe * probe);
62
63 gboolean gst_pulseprobe_needs_probe (GstPulseProbe * probe, guint prop_id,
64     const GParamSpec * pspec);
65 void gst_pulseprobe_probe_property (GstPulseProbe * probe, guint prop_id,
66     const GParamSpec * pspec);
67 GValueArray *gst_pulseprobe_get_values (GstPulseProbe * probe, guint prop_id,
68     const GParamSpec * pspec);
69
70 void gst_pulseprobe_set_server (GstPulseProbe * c, const gchar * server);
71
72 #define GST_IMPLEMENT_PULSEPROBE_METHODS(Type, interface_as_function)           \
73 static const GList*                                                             \
74 interface_as_function ## _get_properties(GstPropertyProbe * probe)              \
75 {                                                                               \
76   Type *this = (Type*) probe;                                                   \
77                                                                                 \
78   g_return_val_if_fail(this != NULL, NULL);                                     \
79   g_return_val_if_fail(this->probe != NULL, NULL);                              \
80                                                                                 \
81   return gst_pulseprobe_get_properties(this->probe);                            \
82 }                                                                               \
83 static gboolean                                                                 \
84 interface_as_function ## _needs_probe(GstPropertyProbe *probe, guint prop_id,   \
85     const GParamSpec *pspec)                                                    \
86 {                                                                               \
87   Type *this = (Type*) probe;                                                   \
88                                                                                 \
89   g_return_val_if_fail(this != NULL, FALSE);                                    \
90   g_return_val_if_fail(this->probe != NULL, FALSE);                             \
91                                                                                 \
92   return gst_pulseprobe_needs_probe(this->probe, prop_id, pspec);               \
93 }                                                                               \
94 static void                                                                     \
95 interface_as_function ## _probe_property(GstPropertyProbe *probe,               \
96     guint prop_id, const GParamSpec *pspec)                                     \
97 {                                                                               \
98   Type *this = (Type*) probe;                                                   \
99                                                                                 \
100   g_return_if_fail(this != NULL);                                               \
101   g_return_if_fail(this->probe != NULL);                                        \
102                                                                                 \
103   gst_pulseprobe_probe_property(this->probe, prop_id, pspec);                   \
104 }                                                                               \
105 static GValueArray*                                                             \
106 interface_as_function ## _get_values(GstPropertyProbe *probe, guint prop_id,    \
107     const GParamSpec *pspec)                                                    \
108 {                                                                               \
109   Type *this = (Type*) probe;                                                   \
110                                                                                 \
111   g_return_val_if_fail(this != NULL, NULL);                                     \
112   g_return_val_if_fail(this->probe != NULL, NULL);                              \
113                                                                                 \
114   return gst_pulseprobe_get_values(this->probe, prop_id, pspec);                \
115 }                                                                               \
116 static void                                                                     \
117 interface_as_function ## _property_probe_interface_init(GstPropertyProbeInterface *iface)\
118 {                                                                               \
119   iface->get_properties = interface_as_function ## _get_properties;             \
120   iface->needs_probe = interface_as_function ## _needs_probe;                   \
121   iface->probe_property = interface_as_function ## _probe_property;             \
122   iface->get_values = interface_as_function ## _get_values;                     \
123 }
124
125 G_END_DECLS
126
127 #endif