]> code.delx.au - pulseaudio/blob - src/pulse/channelmap.h
Merge branch 'master' into master-tx
[pulseaudio] / 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
30 /** \page channelmap Channel Maps
31 *
32 * \section overv_sec Overview
33 *
34 * Channel maps provide a way to associate channels in a stream with a
35 * specific speaker position. This relieves applications of having to
36 * make sure their channel order is identical to the final output.
37 *
38 * \section init_sec Initialisation
39 *
40 * A channel map consists of an array of \ref pa_channel_position values,
41 * one for each channel. This array is stored together with a channel count
42 * in a pa_channel_map structure.
43 *
44 * Before filling the structure, the application must initialise it using
45 * pa_channel_map_init(). There are also a number of convenience functions
46 * for standard channel mappings:
47 *
48 * \li pa_channel_map_init_mono() - Create a channel map with only mono audio.
49 * \li pa_channel_map_init_stereo() - Create a standard stereo mapping.
50 * \li pa_channel_map_init_auto() - Create a standard channel map for a specific number of channels
51 * \li pa_channel_map_init_extend() - Similar to
52 * pa_channel_map_init_auto() but synthesize a channel map if noone
53 * predefined one is known for the specified number of channels.
54 *
55 * \section conv_sec Convenience Functions
56 *
57 * The library contains a number of convenience functions for dealing with
58 * channel maps:
59 *
60 * \li pa_channel_map_valid() - Tests if a channel map is valid.
61 * \li pa_channel_map_equal() - Tests if two channel maps are identical.
62 * \li pa_channel_map_snprint() - Creates a textual description of a channel
63 * map.
64 */
65
66 /** \file
67 * Constants and routines for channel mapping handling */
68
69 PA_C_DECL_BEGIN
70
71 /** A list of channel labels */
72 typedef enum pa_channel_position {
73 PA_CHANNEL_POSITION_INVALID = -1,
74 PA_CHANNEL_POSITION_MONO = 0,
75
76 PA_CHANNEL_POSITION_LEFT,
77 PA_CHANNEL_POSITION_RIGHT,
78 PA_CHANNEL_POSITION_CENTER,
79
80 PA_CHANNEL_POSITION_FRONT_LEFT = PA_CHANNEL_POSITION_LEFT,
81 PA_CHANNEL_POSITION_FRONT_RIGHT = PA_CHANNEL_POSITION_RIGHT,
82 PA_CHANNEL_POSITION_FRONT_CENTER = PA_CHANNEL_POSITION_CENTER,
83
84 PA_CHANNEL_POSITION_REAR_CENTER,
85 PA_CHANNEL_POSITION_REAR_LEFT,
86 PA_CHANNEL_POSITION_REAR_RIGHT,
87
88 PA_CHANNEL_POSITION_LFE,
89 PA_CHANNEL_POSITION_SUBWOOFER = PA_CHANNEL_POSITION_LFE,
90
91 PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
92 PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
93
94 PA_CHANNEL_POSITION_SIDE_LEFT,
95 PA_CHANNEL_POSITION_SIDE_RIGHT,
96
97 PA_CHANNEL_POSITION_AUX0,
98 PA_CHANNEL_POSITION_AUX1,
99 PA_CHANNEL_POSITION_AUX2,
100 PA_CHANNEL_POSITION_AUX3,
101 PA_CHANNEL_POSITION_AUX4,
102 PA_CHANNEL_POSITION_AUX5,
103 PA_CHANNEL_POSITION_AUX6,
104 PA_CHANNEL_POSITION_AUX7,
105 PA_CHANNEL_POSITION_AUX8,
106 PA_CHANNEL_POSITION_AUX9,
107 PA_CHANNEL_POSITION_AUX10,
108 PA_CHANNEL_POSITION_AUX11,
109 PA_CHANNEL_POSITION_AUX12,
110 PA_CHANNEL_POSITION_AUX13,
111 PA_CHANNEL_POSITION_AUX14,
112 PA_CHANNEL_POSITION_AUX15,
113 PA_CHANNEL_POSITION_AUX16,
114 PA_CHANNEL_POSITION_AUX17,
115 PA_CHANNEL_POSITION_AUX18,
116 PA_CHANNEL_POSITION_AUX19,
117 PA_CHANNEL_POSITION_AUX20,
118 PA_CHANNEL_POSITION_AUX21,
119 PA_CHANNEL_POSITION_AUX22,
120 PA_CHANNEL_POSITION_AUX23,
121 PA_CHANNEL_POSITION_AUX24,
122 PA_CHANNEL_POSITION_AUX25,
123 PA_CHANNEL_POSITION_AUX26,
124 PA_CHANNEL_POSITION_AUX27,
125 PA_CHANNEL_POSITION_AUX28,
126 PA_CHANNEL_POSITION_AUX29,
127 PA_CHANNEL_POSITION_AUX30,
128 PA_CHANNEL_POSITION_AUX31,
129
130 PA_CHANNEL_POSITION_TOP_CENTER,
131
132 PA_CHANNEL_POSITION_TOP_FRONT_LEFT,
133 PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,
134 PA_CHANNEL_POSITION_TOP_FRONT_CENTER,
135
136 PA_CHANNEL_POSITION_TOP_REAR_LEFT,
137 PA_CHANNEL_POSITION_TOP_REAR_RIGHT,
138 PA_CHANNEL_POSITION_TOP_REAR_CENTER,
139
140 PA_CHANNEL_POSITION_MAX
141 } pa_channel_position_t;
142
143 /** A list of channel mapping definitions for pa_channel_map_init_auto() */
144 typedef enum pa_channel_map_def {
145 PA_CHANNEL_MAP_AIFF,
146 /**< The mapping from RFC3551, which is based on AIFF-C */
147
148 PA_CHANNEL_MAP_ALSA,
149 /**< The default mapping used by ALSA */
150
151 PA_CHANNEL_MAP_AUX,
152 /**< Only aux channels */
153
154 PA_CHANNEL_MAP_WAVEEX,
155 /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
156
157 PA_CHANNEL_MAP_OSS,
158 /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
159
160 /**< Upper limit of valid channel mapping definitions */
161 PA_CHANNEL_MAP_DEF_MAX,
162
163 PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF
164 /**< The default channel map */
165 } pa_channel_map_def_t;
166
167 /** A channel map which can be used to attach labels to specific
168 * channels of a stream. These values are relevant for conversion and
169 * mixing of streams */
170 typedef struct pa_channel_map {
171 uint8_t channels;
172 /**< Number of channels */
173
174 pa_channel_position_t map[PA_CHANNELS_MAX];
175 /**< Channel labels */
176 } pa_channel_map;
177
178 /** Initialize the specified channel map and return a pointer to it */
179 pa_channel_map* pa_channel_map_init(pa_channel_map *m);
180
181 /** Initialize the specified channel map for monoaural audio and return a pointer to it */
182 pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m);
183
184 /** Initialize the specified channel map for stereophonic audio and return a pointer to it */
185 pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m);
186
187 /** Initialize the specified channel map for the specified number of
188 * channels using default labels and return a pointer to it. This call
189 * will fail (return NULL) if there is no default channel map known for this
190 * specific number of channels and mapping. */
191 pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
192
193 /** Similar to pa_channel_map_init_auto() but instead of failing if no
194 * default mapping is known with the specified parameters it will
195 * synthesize a mapping based on a known mapping with fewer channels
196 * and fill up the rest with AUX0...AUX31 channels \since 0.9.11 */
197 pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
198
199 /** Return a text label for the specified channel position */
200 const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE;
201
202 /** Return a human readable text label for the specified channel position. \since 0.9.7 */
203 const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos);
204
205 /** The maximum length of strings returned by pa_channel_map_snprint() */
206 #define PA_CHANNEL_MAP_SNPRINT_MAX 336
207
208 /** Make a humand readable string from the specified channel map */
209 char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map);
210
211 /** Parse a channel position list into a channel map structure. */
212 pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s);
213
214 /** Compare two channel maps. Return 1 if both match. */
215 int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE;
216
217 /** Return non-zero if the specified channel map is considered valid */
218 int pa_channel_map_valid(const pa_channel_map *map) PA_GCC_PURE;
219
220 /** Return non-zero if the specified channel map is compatible with
221 * the specified sample spec. \since 0.9.12 */
222 int pa_channel_map_compatible(const pa_channel_map *map, const pa_sample_spec *ss) PA_GCC_PURE;
223
224 PA_C_DECL_END
225
226 #endif