1 #ifndef foochannelmaphfoo
2 #define foochannelmaphfoo
5 This file is part of PulseAudio.
7 Copyright 2005-2006 Lennart Poettering
8 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
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.
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.
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
26 #include <pulse/sample.h>
27 #include <pulse/cdecl.h>
28 #include <pulse/gccmacro.h>
30 /** \page channelmap Channel Maps
32 * \section overv_sec Overview
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.
38 * \section init_sec Initialisation
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.
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:
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.
55 * \section conv_sec Convenience Functions
57 * The library contains a number of convenience functions for dealing with
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
67 * Constants and routines for channel mapping handling */
71 /** A list of channel labels */
72 typedef enum pa_channel_position
{
73 PA_CHANNEL_POSITION_INVALID
= -1,
74 PA_CHANNEL_POSITION_MONO
= 0,
76 PA_CHANNEL_POSITION_LEFT
,
77 PA_CHANNEL_POSITION_RIGHT
,
78 PA_CHANNEL_POSITION_CENTER
,
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
,
84 PA_CHANNEL_POSITION_REAR_CENTER
,
85 PA_CHANNEL_POSITION_REAR_LEFT
,
86 PA_CHANNEL_POSITION_REAR_RIGHT
,
88 PA_CHANNEL_POSITION_LFE
,
89 PA_CHANNEL_POSITION_SUBWOOFER
= PA_CHANNEL_POSITION_LFE
,
91 PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER
,
92 PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER
,
94 PA_CHANNEL_POSITION_SIDE_LEFT
,
95 PA_CHANNEL_POSITION_SIDE_RIGHT
,
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
,
130 PA_CHANNEL_POSITION_TOP_CENTER
,
132 PA_CHANNEL_POSITION_TOP_FRONT_LEFT
,
133 PA_CHANNEL_POSITION_TOP_FRONT_RIGHT
,
134 PA_CHANNEL_POSITION_TOP_FRONT_CENTER
,
136 PA_CHANNEL_POSITION_TOP_REAR_LEFT
,
137 PA_CHANNEL_POSITION_TOP_REAR_RIGHT
,
138 PA_CHANNEL_POSITION_TOP_REAR_CENTER
,
140 PA_CHANNEL_POSITION_MAX
141 } pa_channel_position_t
;
143 /** A list of channel mapping definitions for pa_channel_map_init_auto() */
144 typedef enum pa_channel_map_def
{
146 /**< The mapping from RFC3551, which is based on AIFF-C */
149 /**< The default mapping used by ALSA */
152 /**< Only aux channels */
154 PA_CHANNEL_MAP_WAVEEX
,
155 /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
158 /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
160 PA_CHANNEL_MAP_DEFAULT
= PA_CHANNEL_MAP_AIFF
161 /**< The default channel map */
162 } pa_channel_map_def_t
;
164 /** A channel map which can be used to attach labels to specific
165 * channels of a stream. These values are relevant for conversion and
166 * mixing of streams */
167 typedef struct pa_channel_map
{
169 /**< Number of channels */
171 pa_channel_position_t map
[PA_CHANNELS_MAX
];
172 /**< Channel labels */
175 /** Initialize the specified channel map and return a pointer to it */
176 pa_channel_map
* pa_channel_map_init(pa_channel_map
*m
);
178 /** Initialize the specified channel map for monoaural audio and return a pointer to it */
179 pa_channel_map
* pa_channel_map_init_mono(pa_channel_map
*m
);
181 /** Initialize the specified channel map for stereophonic audio and return a pointer to it */
182 pa_channel_map
* pa_channel_map_init_stereo(pa_channel_map
*m
);
184 /** Initialize the specified channel map for the specified number of
185 * channels using default labels and return a pointer to it. This call
186 * will fail (return NULL) if there is no default channel map known for this
187 * specific number of channels and mapping. */
188 pa_channel_map
* pa_channel_map_init_auto(pa_channel_map
*m
, unsigned channels
, pa_channel_map_def_t def
);
190 /** Similar to pa_channel_map_init_auto() but instead of failing if no
191 * default mapping is known with the specified parameters it will
192 * synthesize a mapping based on a known mapping with fewer channels
193 * and fill up the rest with AUX0...AUX31 channels \since 0.9.11 */
194 pa_channel_map
* pa_channel_map_init_extend(pa_channel_map
*m
, unsigned channels
, pa_channel_map_def_t def
);
196 /** Return a text label for the specified channel position */
197 const char* pa_channel_position_to_string(pa_channel_position_t pos
) PA_GCC_PURE
;
199 /** Return a human readable text label for the specified channel position. \since 0.9.7 */
200 const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos
);
202 /** The maximum length of strings returned by pa_channel_map_snprint() */
203 #define PA_CHANNEL_MAP_SNPRINT_MAX 336
205 /** Make a humand readable string from the specified channel map */
206 char* pa_channel_map_snprint(char *s
, size_t l
, const pa_channel_map
*map
);
208 /** Parse a channel position list into a channel map structure. */
209 pa_channel_map
*pa_channel_map_parse(pa_channel_map
*map
, const char *s
);
211 /** Compare two channel maps. Return 1 if both match. */
212 int pa_channel_map_equal(const pa_channel_map
*a
, const pa_channel_map
*b
) PA_GCC_PURE
;
214 /** Return non-zero of the specified channel map is considered valid */
215 int pa_channel_map_valid(const pa_channel_map
*map
) PA_GCC_PURE
;
217 /** Return non-zero if the specified channel map is compatible with
218 * the specified sample spec. \since 0.9.12 */
219 int pa_channel_map_compatible(const pa_channel_map
*map
, const pa_sample_spec
*ss
) PA_GCC_PURE
;