]> code.delx.au - pulseaudio/blob - src/pulse/format.h
format: Extend properties to handle lists/ranges
[pulseaudio] / src / pulse / format.h
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, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 USA.
25 ***/
26
27 #include <pulse/cdecl.h>
28 #include <pulse/proplist.h>
29
30 PA_C_DECL_BEGIN
31
32 /**< Represents the type of encoding used in a stream or accepted by a sink. \since 1.0 */
33 typedef enum pa_encoding {
34 PA_ENCODING_ANY,
35 /**< Any encoding format, PCM or compressed */
36
37 PA_ENCODING_PCM,
38 /**< Any PCM format */
39
40 PA_ENCODING_AC3_IEC61937,
41 /**< AC3 data encapsulated in IEC 61937 header/padding */
42
43 PA_ENCODING_EAC3_IEC61937,
44 /**< EAC3 data encapsulated in IEC 61937 header/padding */
45
46 PA_ENCODING_MPEG_IEC61937,
47 /**< MPEG-1 or MPEG-2 (Part 3, not AAC) data encapsulated in IEC 61937 header/padding */
48
49 PA_ENCODING_DTS_IEC61937,
50 /**< DTS data encapsulated in IEC 61937 header/padding */
51
52 PA_ENCODING_MAX,
53 /**< Valid encoding types must be less than this value */
54
55 PA_ENCODING_INVALID = -1,
56 /**< Represents an invalid encoding */
57 } pa_encoding_t;
58
59 /** Returns a printable string representing the given encoding type. \since 1.0 */
60 const char *pa_encoding_to_string(pa_encoding_t e) PA_GCC_CONST;
61
62 /**< Represents the format of data provided in a stream or processed by a sink. \since 1.0 */
63 typedef struct pa_format_info {
64 pa_encoding_t encoding;
65 /**< The encoding used for the format */
66
67 pa_proplist *plist;
68 /**< Additional encoding-specific properties such as sample rate, bitrate, etc. */
69 } pa_format_info;
70
71 /**< Allocates a new \a pa_format_info structure. Clients must initialise at least the encoding field themselves. */
72 pa_format_info* pa_format_info_new(void);
73
74 /**< Returns a new \a pa_format_info struct and representing the same format as \a src */
75 pa_format_info* pa_format_info_copy(const pa_format_info *src);
76
77 /**< Frees a \a pa_format_info structure */
78 void pa_format_info_free(pa_format_info *f);
79
80 /** Returns non-zero when the format info structure is valid */
81 int pa_format_info_valid(const pa_format_info *f);
82
83 /** Returns non-zero when the format info structure represents a PCM (i.e. uncompressed data) format */
84 int pa_format_info_is_pcm(const pa_format_info *f);
85
86 /** Returns non-zero if the format represented \a first is a subset of
87 * the format represented by \second. This means that \a second must
88 * have all the fields that \a first does, but the reverse need not
89 * be true. This is typically expected to be used to check if a
90 * stream's format is compatible with a given sink. In such a case,
91 * \a first would be the sink's format and \a second would be the
92 * stream's.*/
93 int pa_format_info_is_compatible(pa_format_info *first, pa_format_info *second);
94
95 /** Maximum required string length for
96 * pa_format_info_snprint(). Please note that this value can change
97 * with any release without warning and without being considered API
98 * or ABI breakage. You should not use this definition anywhere where
99 * it might become part of an ABI. \since 1.0 */
100 #define PA_FORMAT_INFO_SNPRINT_MAX 256
101
102 /** Return a human-readable string representing the given format. \since 1.0 */
103 char *pa_format_info_snprint(char *s, size_t l, const pa_format_info *f);
104
105 /** Sets an integer property on the given format info */
106 void pa_format_info_set_prop_int(pa_format_info *f, const char *key, int value);
107 /** Sets a property with a list of integer values on the given format info */
108 void pa_format_info_set_prop_int_array(pa_format_info *f, const char *key, const int *values, int n_values);
109 /** Sets a property which can have any value in a given integer range on the given format info */
110 void pa_format_info_set_prop_int_range(pa_format_info *f, const char *key, int min, int max);
111 /** Sets a string property on the given format info */
112 void pa_format_info_set_prop_string(pa_format_info *f, const char *key, const char *value);
113 /** Sets a property with a list of string values on the given format info */
114 void pa_format_info_set_prop_string_array(pa_format_info *f, const char *key, const char **values, int n_values);
115
116 PA_C_DECL_END
117
118 #endif