Merge branch 'master' into 0.11
[platform/upstream/gst-plugins-base.git] / gst-libs / gst / audio / mixer.h
1 /* GStreamer Mixer
2  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  *
4  * mixer.h: mixer interface design
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __GST_MIXER_H__
23 #define __GST_MIXER_H__
24
25 #include <gst/gst.h>
26 #include <gst/audio/mixeroptions.h>
27 #include <gst/audio/mixertrack.h>
28
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_MIXER \
32   (gst_mixer_get_type ())
33 #define GST_MIXER(obj) \
34   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MIXER, GstMixer))
35 #define GST_IS_MIXER(obj) \
36   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MIXER))
37 #define GST_MIXER_GET_INTERFACE(inst) \
38   (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerInterface))
39
40 typedef struct _GstMixer GstMixer;
41 typedef struct _GstMixerInterface GstMixerInterface;
42
43 /**
44  * GstMixerType:
45  * @GST_MIXER_HARDWARE: mixing is implemented with dedicated hardware.
46  * @GST_MIXER_SOFTWARE: mixing is implemented via software processing.
47  *
48  * Mixer classification.
49  */
50 typedef enum
51 {
52   GST_MIXER_HARDWARE,
53   GST_MIXER_SOFTWARE
54 } GstMixerType;
55
56 /**
57  * GstMixerMessageType:
58  * @GST_MIXER_MESSAGE_INVALID: Not a GstMixer message
59  * @GST_MIXER_MESSAGE_MUTE_TOGGLED: A mute-toggled GstMixer message
60  * @GST_MIXER_MESSAGE_RECORD_TOGGLED: A record-toggled GstMixer message
61  * @GST_MIXER_MESSAGE_VOLUME_CHANGED: A volume-changed GstMixer message
62  * @GST_MIXER_MESSAGE_OPTION_CHANGED: An option-changed GstMixer message
63  * @GST_MIXER_MESSAGE_OPTIONS_LIST_CHANGED: An options-list-changed
64  *     GstMixer message, posted when the list of available options for a
65  *     GstMixerOptions object has changed (Since: 0.10.18)
66  * @GST_MIXER_MESSAGE_MIXER_CHANGED: A mixer-changed GstMixer message, posted
67  *     when the list of available mixer tracks has changed. The application
68  *     should re-build its interface in this case (Since: 0.10.18)
69  *
70  * An enumeration for the type of a GstMixer message received on the bus
71  *
72  * Since: 0.10.14
73  */
74 typedef enum
75 {
76   GST_MIXER_MESSAGE_INVALID,
77   GST_MIXER_MESSAGE_MUTE_TOGGLED,
78   GST_MIXER_MESSAGE_RECORD_TOGGLED,
79   GST_MIXER_MESSAGE_VOLUME_CHANGED,
80   GST_MIXER_MESSAGE_OPTION_CHANGED,
81   GST_MIXER_MESSAGE_OPTIONS_LIST_CHANGED,
82   GST_MIXER_MESSAGE_MIXER_CHANGED
83 } GstMixerMessageType;
84
85 /**
86  * GstMixerFlags:
87  * @GST_MIXER_FLAG_NONE: No flags
88  * @GST_MIXER_FLAG_AUTO_NOTIFICATIONS: The mixer implementation automatically
89  *    sends notification messages.
90  * @GST_MIXER_FLAG_HAS_WHITELIST: The mixer implementation flags tracks that
91  *    should be displayed by default (whitelisted). Since: 0.10.23
92  * @GST_MIXER_FLAG_GROUPING: The mixer implementation will leave some controls
93  *    marked without either input or output.  Controls marked as input or
94  *    output should be grouped with input & output sliders, even if they
95  *    are options or bare switches. Since: 0.10.23
96  *
97  * Flags indicating which optional features are supported by a mixer
98  * implementation.
99  *
100  * Since: 0.10.14
101  */
102 typedef enum
103 {
104   GST_MIXER_FLAG_NONE                = 0,
105   GST_MIXER_FLAG_AUTO_NOTIFICATIONS  = (1<<0),
106   GST_MIXER_FLAG_HAS_WHITELIST       = (1<<1),
107   GST_MIXER_FLAG_GROUPING            = (1<<2),
108 } GstMixerFlags;
109
110 struct _GstMixerInterface {
111   GTypeInterface iface;
112
113   /* virtual functions */
114   const GList *  (* list_tracks)   (GstMixer      *mixer);
115
116   void           (* set_volume)    (GstMixer      *mixer,
117                                     GstMixerTrack *track,
118                                     gint          *volumes);
119   void           (* get_volume)    (GstMixer      *mixer,
120                                     GstMixerTrack *track,
121                                     gint          *volumes);
122
123   void           (* set_mute)      (GstMixer      *mixer,
124                                     GstMixerTrack *track,
125                                     gboolean       mute);
126   void           (* set_record)    (GstMixer      *mixer,
127                                     GstMixerTrack *track,
128                                     gboolean       record);
129   void           (* set_option)    (GstMixer      *mixer,
130                                     GstMixerOptions *opts,
131                                     gchar         *value);
132   const gchar *  (* get_option)    (GstMixer      *mixer,
133                                     GstMixerOptions *opts);
134
135   GstMixerFlags (* get_mixer_flags) (GstMixer *mixer);
136
137   GstMixerType  (* get_mixer_type)  (GstMixer *mixer);
138 };
139
140 GType           gst_mixer_get_type      (void);
141
142 /* virtual class function wrappers */
143 const GList *   gst_mixer_list_tracks    (GstMixer      *mixer);
144 void            gst_mixer_set_volume     (GstMixer      *mixer,
145                                           GstMixerTrack *track,
146                                           gint          *volumes);
147 void            gst_mixer_get_volume     (GstMixer      *mixer,
148                                           GstMixerTrack *track,
149                                           gint          *volumes);
150 void            gst_mixer_set_mute       (GstMixer      *mixer,
151                                           GstMixerTrack *track,
152                                           gboolean       mute);
153 void            gst_mixer_set_record     (GstMixer      *mixer,
154                                           GstMixerTrack *track,
155                                           gboolean       record);
156 void            gst_mixer_set_option     (GstMixer      *mixer,
157                                           GstMixerOptions *opts,
158                                           gchar         *value);
159 const gchar *   gst_mixer_get_option     (GstMixer      *mixer,
160                                           GstMixerOptions *opts);
161
162 /* trigger bus messages */
163 void            gst_mixer_mute_toggled   (GstMixer      *mixer,
164                                           GstMixerTrack *track,
165                                           gboolean       mute);
166 void            gst_mixer_record_toggled (GstMixer      *mixer,
167                                           GstMixerTrack *track,
168                                           gboolean       record);
169 void            gst_mixer_volume_changed (GstMixer      *mixer,
170                                           GstMixerTrack *track,
171                                           gint          *volumes);
172 void            gst_mixer_option_changed (GstMixer      *mixer,
173                                           GstMixerOptions *opts,
174                                           const gchar   *value);
175
176 void            gst_mixer_mixer_changed   (GstMixer        *mixer);
177
178 void            gst_mixer_options_list_changed (GstMixer        *mixer,
179                                                 GstMixerOptions *opts);
180
181 GstMixerType    gst_mixer_get_mixer_type  (GstMixer *mixer);
182
183 GstMixerFlags   gst_mixer_get_mixer_flags (GstMixer *mixer);
184
185 /* Functions for recognising and parsing GstMixerMessages on the bus */
186 GstMixerMessageType gst_mixer_message_get_type (GstMessage *message);
187 void            gst_mixer_message_parse_mute_toggled (GstMessage *message,
188                                                       GstMixerTrack **track,
189                                                       gboolean *mute);
190 void            gst_mixer_message_parse_record_toggled (GstMessage *message,
191                                                         GstMixerTrack **track,
192                                                         gboolean *record);
193 void            gst_mixer_message_parse_volume_changed (GstMessage *message,
194                                                         GstMixerTrack **track,
195                                                         gint **volumes,
196                                                         gint *num_channels);
197 void            gst_mixer_message_parse_option_changed (GstMessage *message,
198                                                         GstMixerOptions **options,
199                                                         const gchar **value);
200 void            gst_mixer_message_parse_options_list_changed (GstMessage *message,
201                                                               GstMixerOptions **options);
202
203 G_END_DECLS
204
205 #endif /* __GST_MIXER_H__ */