]> code.delx.au - pulseaudio/blob - src/polyp/channelmap.h
645a8a3885e352bfd1d7fdbeb100db8eb0c35961
[pulseaudio] / src / polyp / channelmap.h
1 #ifndef foochannelmaphfoo
2 #define foochannelmaphfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of polypaudio.
8
9 polypaudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
13
14 polypaudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with polypaudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #include <polyp/sample.h>
26 #include <polyp/cdecl.h>
27
28 /** \page channelmap Channel Maps
29 *
30 * \section overv_sec Overview
31 *
32 * Channel maps provide a way to associate channels in a stream with a
33 * specific speaker position. This relieves applications of having to
34 * make sure their channel order is identical to the final output.
35 *
36 * \section init_sec Initialisation
37 *
38 * A channel map consists of an array of \ref pa_channel_position values,
39 * one for each channel. This array is stored together with a channel count
40 * in a pa_channel_map structure.
41 *
42 * Before filling the structure, the application must initialise it using
43 * pa_channel_map_init(). There are also a number of convenience functions
44 * for standard channel mappings:
45 *
46 * \li pa_channel_map_init_mono() - Create a channel map with only mono audio.
47 * \li pa_channel_map_init_stereo() - Create a standard stereo mapping.
48 * \li pa_channel_map_init_auto() - Create a standard channel map for up to
49 * six channels.
50 *
51 * \section conv_sec Convenience Functions
52 *
53 * The library contains a number of convenience functions for dealing with
54 * channel maps:
55 *
56 * \li pa_channel_map_valid() - Tests if a channel map is valid.
57 * \li pa_channel_map_equal() - Tests if two channel maps are identical.
58 * \li pa_channel_map_snprint() - Creates a textual description of a channel
59 * map.
60 */
61
62 /** \file
63 * Constants and routines for channel mapping handling */
64
65 PA_C_DECL_BEGIN
66
67 /** A list of channel labels */
68 typedef enum pa_channel_position {
69 PA_CHANNEL_POSITION_INVALID = -1,
70 PA_CHANNEL_POSITION_MONO = 0,
71
72 PA_CHANNEL_POSITION_LEFT,
73 PA_CHANNEL_POSITION_RIGHT,
74 PA_CHANNEL_POSITION_CENTER,
75
76 PA_CHANNEL_POSITION_FRONT_LEFT = PA_CHANNEL_POSITION_LEFT,
77 PA_CHANNEL_POSITION_FRONT_RIGHT = PA_CHANNEL_POSITION_RIGHT,
78 PA_CHANNEL_POSITION_FRONT_CENTER = PA_CHANNEL_POSITION_CENTER,
79
80 PA_CHANNEL_POSITION_REAR_CENTER,
81 PA_CHANNEL_POSITION_REAR_LEFT,
82 PA_CHANNEL_POSITION_REAR_RIGHT,
83
84 PA_CHANNEL_POSITION_LFE,
85 PA_CHANNEL_POSITION_SUBWOOFER = PA_CHANNEL_POSITION_LFE,
86
87 PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
88 PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
89
90 PA_CHANNEL_POSITION_SIDE_LEFT,
91 PA_CHANNEL_POSITION_SIDE_RIGHT,
92
93 PA_CHANNEL_POSITION_AUX0,
94 PA_CHANNEL_POSITION_AUX1,
95 PA_CHANNEL_POSITION_AUX2,
96 PA_CHANNEL_POSITION_AUX3,
97 PA_CHANNEL_POSITION_AUX4,
98 PA_CHANNEL_POSITION_AUX5,
99 PA_CHANNEL_POSITION_AUX6,
100 PA_CHANNEL_POSITION_AUX7,
101 PA_CHANNEL_POSITION_AUX8,
102 PA_CHANNEL_POSITION_AUX9,
103 PA_CHANNEL_POSITION_AUX10,
104 PA_CHANNEL_POSITION_AUX11,
105 PA_CHANNEL_POSITION_AUX12,
106 PA_CHANNEL_POSITION_AUX13,
107 PA_CHANNEL_POSITION_AUX14,
108 PA_CHANNEL_POSITION_AUX15,
109 PA_CHANNEL_POSITION_AUX16,
110 PA_CHANNEL_POSITION_AUX17,
111 PA_CHANNEL_POSITION_AUX18,
112 PA_CHANNEL_POSITION_AUX19,
113 PA_CHANNEL_POSITION_AUX20,
114 PA_CHANNEL_POSITION_AUX21,
115 PA_CHANNEL_POSITION_AUX22,
116 PA_CHANNEL_POSITION_AUX23,
117 PA_CHANNEL_POSITION_AUX24,
118 PA_CHANNEL_POSITION_AUX25,
119 PA_CHANNEL_POSITION_AUX26,
120 PA_CHANNEL_POSITION_AUX27,
121 PA_CHANNEL_POSITION_AUX28,
122 PA_CHANNEL_POSITION_AUX29,
123 PA_CHANNEL_POSITION_AUX30,
124 PA_CHANNEL_POSITION_AUX31,
125
126 PA_CHANNEL_POSITION_TOP_CENTER,
127
128 PA_CHANNEL_POSITION_TOP_FRONT_LEFT,
129 PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,
130 PA_CHANNEL_POSITION_TOP_FRONT_CENTER,
131
132 PA_CHANNEL_POSITION_TOP_REAR_LEFT,
133 PA_CHANNEL_POSITION_TOP_REAR_RIGHT,
134 PA_CHANNEL_POSITION_TOP_REAR_CENTER,
135
136 PA_CHANNEL_POSITION_MAX
137 } pa_channel_position_t;
138
139 /** A list of channel mapping definitions for pa_channel_map_init_auto() */
140 typedef enum pa_channel_map_def {
141 PA_CHANNEL_MAP_AIFF, /**< The mapping from RFC3551, which is based on AIFF-C */
142 PA_CHANNEL_MAP_ALSA, /**< The default mapping used by ALSA */
143 PA_CHANNEL_MAP_AUX, /**< Only aux channels */
144 PA_CHANNEL_MAP_WAVEEX, /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
145 PA_CHANNEL_MAP_OSS, /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
146
147 PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF /**< The default channel map */
148 } pa_channel_map_def_t;
149
150 /** A channel map which can be used to attach labels to specific
151 * channels of a stream. These values are relevant for conversion and
152 * mixing of streams */
153 typedef struct pa_channel_map {
154 uint8_t channels; /**< Number of channels */
155 pa_channel_position_t map[PA_CHANNELS_MAX]; /**< Channel labels */
156 } pa_channel_map;
157
158 /** Initialize the specified channel map and return a pointer to it */
159 pa_channel_map* pa_channel_map_init(pa_channel_map *m);
160
161 /** Initialize the specified channel map for monoaural audio and return a pointer to it */
162 pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m);
163
164 /** Initialize the specified channel map for stereophonic audio and return a pointer to it */
165 pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m);
166
167 /** Initialize the specified channel map for the specified number
168 * of channels using default labels and return a pointer to it. */
169 pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
170
171 /** Return a text label for the specified channel position */
172 const char* pa_channel_position_to_string(pa_channel_position_t pos);
173
174 /** The maximum length of strings returned by pa_channel_map_snprint() */
175 #define PA_CHANNEL_MAP_SNPRINT_MAX 336
176
177 /** Make a humand readable string from the specified channel map */
178 char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map);
179
180 /** Parse a channel position list into a channel map structure. \since 0.8.1 */
181 pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s);
182
183 /** Compare two channel maps. Return 1 if both match. */
184 int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b);
185
186 /** Return non-zero of the specified channel map is considered valid */
187 int pa_channel_map_valid(const pa_channel_map *map);
188
189 PA_C_DECL_END
190
191 #endif