PulseAudio  14.0-rebootstrapped
format.h
Go to the documentation of this file.
1 #ifndef fooformathfoo
2 #define fooformathfoo
3 
4 /***
5  This file is part of PulseAudio.
6 
7  Copyright 2011 Intel Corporation
8  Copyright 2011 Collabora Multimedia
9  Copyright 2011 Arun Raghavan <arun.raghavan@collabora.co.uk>
10 
11  PulseAudio is free software; you can redistribute it and/or modify
12  it under the terms of the GNU Lesser General Public License as published
13  by the Free Software Foundation; either version 2.1 of the License,
14  or (at your option) any later version.
15 
16  PulseAudio is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public License
22  along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
23 ***/
24 
25 #include <pulse/cdecl.h>
26 #include <pulse/gccmacro.h>
27 #include <pulse/proplist.h>
28 #include <pulse/sample.h>
29 #include <pulse/channelmap.h>
30 
34 PA_C_DECL_BEGIN
35 
37 typedef enum pa_encoding {
65  /* Remeber to update
66  * https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SupportedAudioFormats/
67  * when adding new encodings! */
68 
75 
77 #define PA_ENCODING_ANY PA_ENCODING_ANY
78 #define PA_ENCODING_PCM PA_ENCODING_PCM
79 #define PA_ENCODING_AC3_IEC61937 PA_ENCODING_AC3_IEC61937
80 #define PA_ENCODING_EAC3_IEC61937 PA_ENCODING_EAC3_IEC61937
81 #define PA_ENCODING_MPEG_IEC61937 PA_ENCODING_MPEG_IEC61937
82 #define PA_ENCODING_DTS_IEC61937 PA_ENCODING_DTS_IEC61937
83 #define PA_ENCODING_MPEG2_AAC_IEC61937 PA_ENCODING_MPEG2_AAC_IEC61937
84 #define PA_ENCODING_TRUEHD_IEC61937 PA_ENCODING_TRUEHD_IEC61937
85 #define PA_ENCODING_DTSHD_IEC61937 PA_ENCODING_DTSHD_IEC61937
86 #define PA_ENCODING_MAX PA_ENCODING_MAX
87 #define PA_ENCODING_INVALID PA_ENCODING_INVALID
88 
92 
95 pa_encoding_t pa_encoding_from_string(const char *encoding);
96 
98 typedef struct pa_format_info {
105 
109 
112 
115 
118 
122 
130 int pa_format_info_is_compatible(const pa_format_info *first, const pa_format_info *second);
131 
137 #define PA_FORMAT_INFO_SNPRINT_MAX 256
138 
140 char *pa_format_info_snprint(char *s, size_t l, const pa_format_info *f);
141 
145 
159 
166 
168 typedef enum pa_prop_type_t {
187 
189 #define PA_PROP_TYPE_INT PA_PROP_TYPE_INT
190 #define PA_PROP_TYPE_INT_RANGE PA_PROP_TYPE_INT_RANGE
191 #define PA_PROP_TYPE_INT_ARRAY PA_PROP_TYPE_INT_ARRAY
192 #define PA_PROP_TYPE_STRING PA_PROP_TYPE_STRING
193 #define PA_PROP_TYPE_STRING_ARRAY PA_PROP_TYPE_STRING_ARRAY
194 #define PA_PROP_TYPE_INVALID PA_PROP_TYPE_INVALID
195 
199 
201 int pa_format_info_get_prop_int(const pa_format_info *f, const char *key, int *v);
204 int pa_format_info_get_prop_int_range(const pa_format_info *f, const char *key, int *min, int *max);
208 int pa_format_info_get_prop_int_array(const pa_format_info *f, const char *key, int **values, int *n_values);
211 int pa_format_info_get_prop_string(const pa_format_info *f, const char *key, char **v);
215 int pa_format_info_get_prop_string_array(const pa_format_info *f, const char *key, char ***values, int *n_values);
216 
218 void pa_format_info_free_string_array(char **values, int n_values);
219 
224 
228 int pa_format_info_get_rate(const pa_format_info *f, uint32_t *rate);
229 
233 int pa_format_info_get_channels(const pa_format_info *f, uint8_t *channels);
234 
239 
241 void pa_format_info_set_prop_int(pa_format_info *f, const char *key, int value);
243 void pa_format_info_set_prop_int_array(pa_format_info *f, const char *key, const int *values, int n_values);
245 void pa_format_info_set_prop_int_range(pa_format_info *f, const char *key, int min, int max);
247 void pa_format_info_set_prop_string(pa_format_info *f, const char *key, const char *value);
249 void pa_format_info_set_prop_string_array(pa_format_info *f, const char *key, const char **values, int n_values);
250 
261 
271 void pa_format_info_set_rate(pa_format_info *f, int rate);
272 
282 void pa_format_info_set_channels(pa_format_info *f, int channels);
283 
294 
295 PA_C_DECL_END
296 
297 #endif
pa_format_info * pa_format_info_from_string(const char *str)
Parse a human-readable string of the form generated by pa_format_info_snprint() into a pa_format_info...
pa_format_info * pa_format_info_copy(const pa_format_info *src)
Returns a new pa_format_info struct and representing the same format as src.
A sample format and attribute specification.
Definition: sample.h:252
pa_format_info * pa_format_info_from_sample_spec(const pa_sample_spec *ss, const pa_channel_map *map)
Utility function to take a pa_sample_spec and generate the corresponding pa_format_info.
DTS-HD Master Audio encapsulated in IEC 61937 header/padding.
Definition: format.h:62
MPEG-2 AAC data encapsulated in IEC 61937 header/padding.
Definition: format.h:56
void pa_format_info_set_channels(pa_format_info *f, int channels)
Convenience method to set the number of channels as a property on the given format.
EAC3 data encapsulated in IEC 61937 header/padding.
Definition: format.h:47
void pa_format_info_free(pa_format_info *f)
Frees a pa_format_info structure.
void pa_format_info_set_prop_string(pa_format_info *f, const char *key, const char *value)
Sets a string property on the given format info.
int pa_format_info_get_channel_map(const pa_format_info *f, pa_channel_map *map)
Gets the channel map stored in the format info.
pa_encoding_t encoding
The encoding used for the format.
Definition: format.h:99
Integer range property.
Definition: format.h:172
pa_encoding
Represents the type of encoding used in a stream or accepted by a sink.
Definition: format.h:37
pa_prop_type_t pa_format_info_get_prop_type(const pa_format_info *f, const char *key)
Gets the type of property key in a given pa_format_info.
int pa_format_info_get_prop_string(const pa_format_info *f, const char *key, char **v)
Gets a string property from the given format info.
#define PA_GCC_CONST
This function&#39;s return value depends only the arguments list (stricter version of PA_GCC_PURE) ...
Definition: gccmacro.h:82
enum pa_encoding pa_encoding_t
Represents the type of encoding used in a stream or accepted by a sink.
void pa_format_info_set_prop_int_array(pa_format_info *f, const char *key, const int *values, int n_values)
Sets a property with a list of integer values on the given format info.
Valid encoding types must be less than this value.
Definition: format.h:69
int pa_format_info_get_channels(const pa_format_info *f, uint8_t *channels)
Gets the channel count stored in the format info.
enum pa_sample_format pa_sample_format_t
Sample format.
pa_format_info * pa_format_info_new(void)
Allocates a new pa_format_info structure.
Represents an invalid type.
Definition: format.h:184
int pa_format_info_get_prop_int_array(const pa_format_info *f, const char *key, int **values, int *n_values)
Gets an integer array property from the given format info.
Constants and routines for channel mapping handling.
pa_prop_type_t
Represents the type of value type of a property on a pa_format_info.
Definition: format.h:168
void pa_format_info_set_channel_map(pa_format_info *f, const pa_channel_map *map)
Convenience method to set the channel map as a property on the given format.
int pa_format_info_get_prop_int(const pa_format_info *f, const char *key, int *v)
Gets an integer property from the given format info.
pa_proplist * plist
Additional encoding-specific properties such as sample rate, bitrate, etc.
Definition: format.h:102
String property.
Definition: format.h:178
GCC attribute macros.
Integer array property.
Definition: format.h:175
Represents an invalid encoding.
Definition: format.h:72
int pa_format_info_valid(const pa_format_info *f)
Returns non-zero when the format info structure is valid.
DTS data encapsulated in IEC 61937 header/padding.
Definition: format.h:53
int pa_format_info_get_prop_int_range(const pa_format_info *f, const char *key, int *min, int *max)
Gets an integer range property from the given format info.
int pa_format_info_get_sample_format(const pa_format_info *f, pa_sample_format_t *sf)
Gets the sample format stored in the format info.
void pa_format_info_free_string_array(char **values, int n_values)
Frees a string array returned by pa_format_info_get_prop_string_array.
MPEG-1 or MPEG-2 (Part 3, not AAC) data encapsulated in IEC 61937 header/padding. ...
Definition: format.h:50
int pa_format_info_get_prop_string_array(const pa_format_info *f, const char *key, char ***values, int *n_values)
Gets a string array property from the given format info.
Integer property.
Definition: format.h:169
int pa_format_info_get_rate(const pa_format_info *f, uint32_t *rate)
Gets the sample rate stored in the format info.
void pa_format_info_set_prop_string_array(pa_format_info *f, const char *key, const char **values, int n_values)
Sets a property with a list of string values on the given format info.
void pa_format_info_set_prop_int_range(pa_format_info *f, const char *key, int min, int max)
Sets a property which can have any value in a given integer range on the given format info...
Constants and routines for sample type handling.
char * pa_format_info_snprint(char *s, size_t l, const pa_format_info *f)
Make a human-readable string representing the given format.
int pa_format_info_is_compatible(const pa_format_info *first, const pa_format_info *second)
Returns non-zero if the format represented by first is a subset of the format represented by second...
int pa_format_info_to_sample_spec(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map)
Utility function to generate a pa_sample_spec and pa_channel_map corresponding to a given pa_format_i...
void pa_format_info_set_prop_int(pa_format_info *f, const char *key, int value)
Sets an integer property on the given format info.
int pa_format_info_is_pcm(const pa_format_info *f)
Returns non-zero when the format info structure represents a PCM (i.e. uncompressed data) format...
String array property.
Definition: format.h:181
Any PCM format.
Definition: format.h:41
const char * pa_encoding_to_string(pa_encoding_t e) PA_GCC_CONST
Returns a printable string representing the given encoding type.
Any encoding format, PCM or compressed.
Definition: format.h:38
Represents the format of data provided in a stream or processed by a sink.
Definition: format.h:98
A channel map which can be used to attach labels to specific channels of a stream.
Definition: channelmap.h:264
struct pa_proplist pa_proplist
A property list object.
Definition: proplist.h:272
Dolby TrueHD data encapsulated in IEC 61937 header/padding.
Definition: format.h:59
AC3 data encapsulated in IEC 61937 header/padding.
Definition: format.h:44
void pa_format_info_set_rate(pa_format_info *f, int rate)
Convenience method to set the sampling rate as a property on the given format.
Property list constants and functions.
struct pa_format_info pa_format_info
Represents the format of data provided in a stream or processed by a sink.
pa_encoding_t pa_encoding_from_string(const char *encoding)
Converts a string of the form returned by pa_encoding_to_string() back to a pa_encoding_t.
void pa_format_info_set_sample_format(pa_format_info *f, pa_sample_format_t sf)
Convenience method to set the sample format as a property on the given format.