import version.h in all header files to make sure that version-based feature testing...
[profile/ivi/pulseaudio.git] / src / pulse / channelmap.h
1 #ifndef foochannelmaphfoo
2 #define foochannelmaphfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2005-2006 Lennart Poettering
8   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9
10   PulseAudio is free software; you can redistribute it and/or modify
11   it under the terms of the GNU Lesser General Public License as published
12   by the Free Software Foundation; either version 2 of the License,
13   or (at your option) any later version.
14
15   PulseAudio is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with PulseAudio; if not, write to the Free Software
22   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23   USA.
24 ***/
25
26 #include <pulse/sample.h>
27 #include <pulse/cdecl.h>
28 #include <pulse/gccmacro.h>
29 #include <pulse/version.h>
30
31 /** \page channelmap Channel Maps
32  *
33  * \section overv_sec Overview
34  *
35  * Channel maps provide a way to associate channels in a stream with a
36  * specific speaker position. This relieves applications of having to
37  * make sure their channel order is identical to the final output.
38  *
39  * \section init_sec Initialisation
40  *
41  * A channel map consists of an array of \ref pa_channel_position values,
42  * one for each channel. This array is stored together with a channel count
43  * in a pa_channel_map structure.
44  *
45  * Before filling the structure, the application must initialise it using
46  * pa_channel_map_init(). There are also a number of convenience functions
47  * for standard channel mappings:
48  *
49  * \li pa_channel_map_init_mono() - Create a channel map with only mono audio.
50  * \li pa_channel_map_init_stereo() - Create a standard stereo mapping.
51  * \li pa_channel_map_init_auto() - Create a standard channel map for a specific number of channels
52  * \li pa_channel_map_init_extend() - Similar to
53  * pa_channel_map_init_auto() but synthesize a channel map if noone
54  * predefined one is known for the specified number of channels.
55  *
56  * \section conv_sec Convenience Functions
57  *
58  * The library contains a number of convenience functions for dealing with
59  * channel maps:
60  *
61  * \li pa_channel_map_valid() - Tests if a channel map is valid.
62  * \li pa_channel_map_equal() - Tests if two channel maps are identical.
63  * \li pa_channel_map_snprint() - Creates a textual description of a channel
64  *                                map.
65  */
66
67 /** \file
68  * Constants and routines for channel mapping handling */
69
70 PA_C_DECL_BEGIN
71
72 /** A list of channel labels */
73 typedef enum pa_channel_position {
74     PA_CHANNEL_POSITION_INVALID = -1,
75     PA_CHANNEL_POSITION_MONO = 0,
76
77     PA_CHANNEL_POSITION_LEFT,
78     PA_CHANNEL_POSITION_RIGHT,
79     PA_CHANNEL_POSITION_CENTER,
80
81     PA_CHANNEL_POSITION_FRONT_LEFT = PA_CHANNEL_POSITION_LEFT,
82     PA_CHANNEL_POSITION_FRONT_RIGHT = PA_CHANNEL_POSITION_RIGHT,
83     PA_CHANNEL_POSITION_FRONT_CENTER = PA_CHANNEL_POSITION_CENTER,
84
85     PA_CHANNEL_POSITION_REAR_CENTER,
86     PA_CHANNEL_POSITION_REAR_LEFT,
87     PA_CHANNEL_POSITION_REAR_RIGHT,
88
89     PA_CHANNEL_POSITION_LFE,
90     PA_CHANNEL_POSITION_SUBWOOFER = PA_CHANNEL_POSITION_LFE,
91
92     PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
93     PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
94
95     PA_CHANNEL_POSITION_SIDE_LEFT,
96     PA_CHANNEL_POSITION_SIDE_RIGHT,
97
98     PA_CHANNEL_POSITION_AUX0,
99     PA_CHANNEL_POSITION_AUX1,
100     PA_CHANNEL_POSITION_AUX2,
101     PA_CHANNEL_POSITION_AUX3,
102     PA_CHANNEL_POSITION_AUX4,
103     PA_CHANNEL_POSITION_AUX5,
104     PA_CHANNEL_POSITION_AUX6,
105     PA_CHANNEL_POSITION_AUX7,
106     PA_CHANNEL_POSITION_AUX8,
107     PA_CHANNEL_POSITION_AUX9,
108     PA_CHANNEL_POSITION_AUX10,
109     PA_CHANNEL_POSITION_AUX11,
110     PA_CHANNEL_POSITION_AUX12,
111     PA_CHANNEL_POSITION_AUX13,
112     PA_CHANNEL_POSITION_AUX14,
113     PA_CHANNEL_POSITION_AUX15,
114     PA_CHANNEL_POSITION_AUX16,
115     PA_CHANNEL_POSITION_AUX17,
116     PA_CHANNEL_POSITION_AUX18,
117     PA_CHANNEL_POSITION_AUX19,
118     PA_CHANNEL_POSITION_AUX20,
119     PA_CHANNEL_POSITION_AUX21,
120     PA_CHANNEL_POSITION_AUX22,
121     PA_CHANNEL_POSITION_AUX23,
122     PA_CHANNEL_POSITION_AUX24,
123     PA_CHANNEL_POSITION_AUX25,
124     PA_CHANNEL_POSITION_AUX26,
125     PA_CHANNEL_POSITION_AUX27,
126     PA_CHANNEL_POSITION_AUX28,
127     PA_CHANNEL_POSITION_AUX29,
128     PA_CHANNEL_POSITION_AUX30,
129     PA_CHANNEL_POSITION_AUX31,
130
131     PA_CHANNEL_POSITION_TOP_CENTER,
132
133     PA_CHANNEL_POSITION_TOP_FRONT_LEFT,
134     PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,
135     PA_CHANNEL_POSITION_TOP_FRONT_CENTER,
136
137     PA_CHANNEL_POSITION_TOP_REAR_LEFT,
138     PA_CHANNEL_POSITION_TOP_REAR_RIGHT,
139     PA_CHANNEL_POSITION_TOP_REAR_CENTER,
140
141     PA_CHANNEL_POSITION_MAX
142 } pa_channel_position_t;
143
144 /** A list of channel mapping definitions for pa_channel_map_init_auto() */
145 typedef enum pa_channel_map_def {
146     PA_CHANNEL_MAP_AIFF,
147     /**< The mapping from RFC3551, which is based on AIFF-C */
148
149     PA_CHANNEL_MAP_ALSA,
150     /**< The default mapping used by ALSA */
151
152     PA_CHANNEL_MAP_AUX,
153     /**< Only aux channels */
154
155     PA_CHANNEL_MAP_WAVEEX,
156     /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
157
158     PA_CHANNEL_MAP_OSS,
159     /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
160
161     /**< Upper limit of valid channel mapping definitions */
162     PA_CHANNEL_MAP_DEF_MAX,
163
164     PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF
165     /**< The default channel map */
166 } pa_channel_map_def_t;
167
168 /** A channel map which can be used to attach labels to specific
169  * channels of a stream. These values are relevant for conversion and
170  * mixing of streams */
171 typedef struct pa_channel_map {
172     uint8_t channels;
173     /**< Number of channels */
174
175     pa_channel_position_t map[PA_CHANNELS_MAX];
176     /**< Channel labels */
177 } pa_channel_map;
178
179 /** Initialize the specified channel map and return a pointer to
180  * it. The channel map will have a defined state but
181  * pa_channel_map_valid() will fail for it. */
182 pa_channel_map* pa_channel_map_init(pa_channel_map *m);
183
184 /** Initialize the specified channel map for monoaural audio and return a pointer to it */
185 pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m);
186
187 /** Initialize the specified channel map for stereophonic audio and return a pointer to it */
188 pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m);
189
190 /** Initialize the specified channel map for the specified number of
191  * channels using default labels and return a pointer to it. This call
192  * will fail (return NULL) if there is no default channel map known for this
193  * specific number of channels and mapping. */
194 pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
195
196 /** Similar to pa_channel_map_init_auto() but instead of failing if no
197  * default mapping is known with the specified parameters it will
198  * synthesize a mapping based on a known mapping with fewer channels
199  * and fill up the rest with AUX0...AUX31 channels  \since 0.9.11 */
200 pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
201
202 /** Return a text label for the specified channel position */
203 const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE;
204
205 /** Return a human readable text label for the specified channel position. \since 0.9.7 */
206 const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos);
207
208 /** The maximum length of strings returned by
209  * pa_channel_map_snprint(). Please note that this value can change
210  * with any release without warning and without being considered API
211  * or ABI breakage. You should not use this definition anywhere where
212  * it might become part of an ABI. */
213 #define PA_CHANNEL_MAP_SNPRINT_MAX 336
214
215 /** Make a humand readable string from the specified channel map */
216 char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map);
217
218 /** Parse a channel position list or well-known mapping name into a
219  * channel map structure. This turns the output of
220  * pa_channel_map_snprint() and pa_channel_map_to_name() back into a
221  * pa_channel_map */
222 pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s);
223
224 /** Compare two channel maps. Return 1 if both match. */
225 int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE;
226
227 /** Return non-zero if the specified channel map is considered valid */
228 int pa_channel_map_valid(const pa_channel_map *map) PA_GCC_PURE;
229
230 /** Return non-zero if the specified channel map is compatible with
231  * the specified sample spec. \since 0.9.12 */
232 int pa_channel_map_compatible(const pa_channel_map *map, const pa_sample_spec *ss) PA_GCC_PURE;
233
234 /** Returns non-zero if every channel defined in b is also defined in a. \since 0.9.15 */
235 int pa_channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE;
236
237 /** Returns non-zero if it makes sense to apply a volume 'balance'
238  * with this mapping, i.e. if there are left/right channels
239  * available. \since 0.9.15 */
240 int pa_channel_map_can_balance(const pa_channel_map *map) PA_GCC_PURE;
241
242 /** Tries to find a well-known channel mapping name for this channel
243  * mapping. I.e. "stereo", "surround-71" and so on. If the channel
244  * mapping is unknown NULL will be returned. This name can be parsed
245  * with pa_channel_map_parse() \since 0.9.15 */
246 const char* pa_channel_map_to_name(const pa_channel_map *map) PA_GCC_PURE;
247
248 /** Tries to find a human readable text label for this channel
249 mapping. I.e. "Stereo", "Surround 7.1" and so on. If the channel
250 mapping is unknown NULL will be returned. \since 0.9.15 */
251 const char* pa_channel_map_to_pretty_name(const pa_channel_map *map) PA_GCC_PURE;
252
253 PA_C_DECL_END
254
255 #endif