]> code.delx.au - pulseaudio/blob - src/pulse/proplist.h
proplist: Change proplist_name_valid() to be public function pa_proplist_key_valid().
[pulseaudio] / src / pulse / proplist.h
1 #ifndef foopulseproplisthfoo
2 #define foopulseproplisthfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2007 Lennart Poettering
8
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
13
14 PulseAudio 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 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with PulseAudio; 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 <sys/types.h>
26
27 #include <pulse/cdecl.h>
28 #include <pulse/gccmacro.h>
29 #include <pulse/version.h>
30
31 /** \file
32 * Property list constants and functions */
33
34 PA_C_DECL_BEGIN
35
36 /** For streams: localized media name, formatted as UTF-8. e.g. "Guns'N'Roses: Civil War".*/
37 #define PA_PROP_MEDIA_NAME "media.name"
38
39 /** For streams: localized media title if applicable, formatted as UTF-8. e.g. "Civil War" */
40 #define PA_PROP_MEDIA_TITLE "media.title"
41
42 /** For streams: localized media artist if applicable, formatted as UTF-8. e.g. "Guns'N'Roses" */
43 #define PA_PROP_MEDIA_ARTIST "media.artist"
44
45 /** For streams: localized media copyright string if applicable, formatted as UTF-8. e.g. "Evil Record Corp." */
46 #define PA_PROP_MEDIA_COPYRIGHT "media.copyright"
47
48 /** For streams: localized media generator software string if applicable, formatted as UTF-8. e.g. "Foocrop AudioFrobnicator" */
49 #define PA_PROP_MEDIA_SOFTWARE "media.software"
50
51 /** For streams: media language if applicable, in standard POSIX format. e.g. "de_DE" */
52 #define PA_PROP_MEDIA_LANGUAGE "media.language"
53
54 /** For streams: source filename if applicable, in URI format or local path. e.g. "/home/lennart/music/foobar.ogg" */
55 #define PA_PROP_MEDIA_FILENAME "media.filename"
56
57 /** \cond fulldocs */
58 /** For streams: icon for the media. A binary blob containing PNG image data */
59 #define PA_PROP_MEDIA_ICON "media.icon"
60 /** \endcond */
61
62 /** For streams: an XDG icon name for the media. e.g. "audio-x-mp3" */
63 #define PA_PROP_MEDIA_ICON_NAME "media.icon_name"
64
65 /** For streams: logic role of this media. One of the strings "video", "music", "game", "event", "phone", "animation", "production", "a11y", "test" */
66 #define PA_PROP_MEDIA_ROLE "media.role"
67
68 /** For streams: the name of a filter that is desired, e.g. "echo-cancel" or "equalizer-sink". PulseAudio may choose to not apply the filter if it does not make sense (for example, applying echo-cancellation on a Bluetooth headset probably does not make sense. \since 1.0 */
69 #define PA_PROP_FILTER_WANT "filter.want"
70
71 /** For streams: the name of a filter that is desired, e.g. "echo-cancel" or "equalizer-sink". Differs from PA_PROP_FILTER_WANT in that it forces PulseAudio to apply the filter, regardless of whether PulseAudio thinks it makes sense to do so or not. If this is set, PA_PROP_FILTER_WANT is ignored. In other words, you almost certainly do not want to use this. \since 1.0 */
72 #define PA_PROP_FILTER_APPLY "filter.apply"
73
74 /** For streams: the name of a filter that should specifically suppressed (i.e. overrides PA_PROP_FILTER_WANT). Useful for the times that PA_PROP_FILTER_WANT is automatically added (e.g. echo-cancellation for phone streams when $VOIP_APP does it's own, internal AEC) \since 1.0 */
75 #define PA_PROP_FILTER_SUPPRESS "filter.suppress"
76
77 /** For event sound streams: XDG event sound name. e.g. "message-new-email" (Event sound streams are those with media.role set to "event") */
78 #define PA_PROP_EVENT_ID "event.id"
79
80 /** For event sound streams: localized human readable one-line description of the event, formatted as UTF-8. e.g. "Email from lennart@example.com received." */
81 #define PA_PROP_EVENT_DESCRIPTION "event.description"
82
83 /** For event sound streams: absolute horizontal mouse position on the screen if the event sound was triggered by a mouse click, integer formatted as text string. e.g. "865" */
84 #define PA_PROP_EVENT_MOUSE_X "event.mouse.x"
85
86 /** For event sound streams: absolute vertical mouse position on the screen if the event sound was triggered by a mouse click, integer formatted as text string. e.g. "432" */
87 #define PA_PROP_EVENT_MOUSE_Y "event.mouse.y"
88
89 /** For event sound streams: relative horizontal mouse position on the screen if the event sound was triggered by a mouse click, float formatted as text string, ranging from 0.0 (left side of the screen) to 1.0 (right side of the screen). e.g. "0.65" */
90 #define PA_PROP_EVENT_MOUSE_HPOS "event.mouse.hpos"
91
92 /** For event sound streams: relative vertical mouse position on the screen if the event sound was triggered by a mouse click, float formatted as text string, ranging from 0.0 (top of the screen) to 1.0 (bottom of the screen). e.g. "0.43" */
93 #define PA_PROP_EVENT_MOUSE_VPOS "event.mouse.vpos"
94
95 /** For event sound streams: mouse button that triggered the event if applicable, integer formatted as string with 0=left, 1=middle, 2=right. e.g. "0" */
96 #define PA_PROP_EVENT_MOUSE_BUTTON "event.mouse.button"
97
98 /** For streams that belong to a window on the screen: localized window title. e.g. "Totem Music Player" */
99 #define PA_PROP_WINDOW_NAME "window.name"
100
101 /** For streams that belong to a window on the screen: a textual id for identifying a window logically. e.g. "org.gnome.Totem.MainWindow" */
102 #define PA_PROP_WINDOW_ID "window.id"
103
104 /** \cond fulldocs */
105 /** For streams that belong to a window on the screen: window icon. A binary blob containing PNG image data */
106 #define PA_PROP_WINDOW_ICON "window.icon"
107 /** \endcond */
108
109 /** For streams that belong to a window on the screen: an XDG icon name for the window. e.g. "totem" */
110 #define PA_PROP_WINDOW_ICON_NAME "window.icon_name"
111
112 /** For streams that belong to a window on the screen: absolute horizontal window position on the screen, integer formatted as text string. e.g. "865". \since 0.9.17 */
113 #define PA_PROP_WINDOW_X "window.x"
114
115 /** For streams that belong to a window on the screen: absolute vertical window position on the screen, integer formatted as text string. e.g. "343". \since 0.9.17 */
116 #define PA_PROP_WINDOW_Y "window.y"
117
118 /** For streams that belong to a window on the screen: window width on the screen, integer formatted as text string. e.g. "365". \since 0.9.17 */
119 #define PA_PROP_WINDOW_WIDTH "window.width"
120
121 /** For streams that belong to a window on the screen: window height on the screen, integer formatted as text string. e.g. "643". \since 0.9.17 */
122 #define PA_PROP_WINDOW_HEIGHT "window.height"
123
124 /** For streams that belong to a window on the screen: relative position of the window center on the screen, float formatted as text string, ranging from 0.0 (left side of the screen) to 1.0 (right side of the screen). e.g. "0.65". \since 0.9.17 */
125 #define PA_PROP_WINDOW_HPOS "window.hpos"
126
127 /** For streams that belong to a window on the screen: relative position of the window center on the screen, float formatted as text string, ranging from 0.0 (top of the screen) to 1.0 (bottom of the screen). e.g. "0.43". \since 0.9.17 */
128 #define PA_PROP_WINDOW_VPOS "window.vpos"
129
130 /** For streams that belong to a window on the screen: if the windowing system supports multiple desktops, a comma separated list of indexes of the desktops this window is visible on. If this property is an empty string, it is visible on all desktops (i.e. 'sticky'). The first desktop is 0. e.g. "0,2,3" \since 0.9.18 */
131 #define PA_PROP_WINDOW_DESKTOP "window.desktop"
132
133 /** For streams that belong to an X11 window on the screen: the X11 display string. e.g. ":0.0" */
134 #define PA_PROP_WINDOW_X11_DISPLAY "window.x11.display"
135
136 /** For streams that belong to an X11 window on the screen: the X11 screen the window is on, an integer formatted as string. e.g. "0" */
137 #define PA_PROP_WINDOW_X11_SCREEN "window.x11.screen"
138
139 /** For streams that belong to an X11 window on the screen: the X11 monitor the window is on, an integer formatted as string. e.g. "0" */
140 #define PA_PROP_WINDOW_X11_MONITOR "window.x11.monitor"
141
142 /** For streams that belong to an X11 window on the screen: the window XID, an integer formatted as string. e.g. "25632" */
143 #define PA_PROP_WINDOW_X11_XID "window.x11.xid"
144
145 /** For clients/streams: localized human readable application name. e.g. "Totem Music Player" */
146 #define PA_PROP_APPLICATION_NAME "application.name"
147
148 /** For clients/streams: a textual id for identifying an application logically. e.g. "org.gnome.Totem" */
149 #define PA_PROP_APPLICATION_ID "application.id"
150
151 /** For clients/streams: a version string e.g. "0.6.88" */
152 #define PA_PROP_APPLICATION_VERSION "application.version"
153
154 /** \cond fulldocs */
155 /** For clients/streams: application icon. A binary blob containing PNG image data */
156 #define PA_PROP_APPLICATION_ICON "application.icon"
157 /** \endcond */
158
159 /** For clients/streams: an XDG icon name for the application. e.g. "totem" */
160 #define PA_PROP_APPLICATION_ICON_NAME "application.icon_name"
161
162 /** For clients/streams: application language if applicable, in standard POSIX format. e.g. "de_DE" */
163 #define PA_PROP_APPLICATION_LANGUAGE "application.language"
164
165 /** For clients/streams on UNIX: application process PID, an integer formatted as string. e.g. "4711" */
166 #define PA_PROP_APPLICATION_PROCESS_ID "application.process.id"
167
168 /** For clients/streams: application process name. e.g. "totem" */
169 #define PA_PROP_APPLICATION_PROCESS_BINARY "application.process.binary"
170
171 /** For clients/streams: application user name. e.g. "lennart" */
172 #define PA_PROP_APPLICATION_PROCESS_USER "application.process.user"
173
174 /** For clients/streams: host name the application runs on. e.g. "omega" */
175 #define PA_PROP_APPLICATION_PROCESS_HOST "application.process.host"
176
177 /** For clients/streams: the D-Bus host id the application runs on. e.g. "543679e7b01393ed3e3e650047d78f6e" */
178 #define PA_PROP_APPLICATION_PROCESS_MACHINE_ID "application.process.machine_id"
179
180 /** For clients/streams: an id for the login session the application runs in. On Unix the value of $XDG_SESSION_ID. e.g. "5" */
181 #define PA_PROP_APPLICATION_PROCESS_SESSION_ID "application.process.session_id"
182
183 /** For devices: device string in the underlying audio layer's format. e.g. "surround51:0" */
184 #define PA_PROP_DEVICE_STRING "device.string"
185
186 /** For devices: API this device is access with. e.g. "alsa" */
187 #define PA_PROP_DEVICE_API "device.api"
188
189 /** For devices: localized human readable device one-line description, e.g. "Foobar Industries USB Headset 2000+ Ultra" */
190 #define PA_PROP_DEVICE_DESCRIPTION "device.description"
191
192 /** For devices: bus path to the device in the OS' format. e.g. "/sys/bus/pci/devices/0000:00:1f.2" */
193 #define PA_PROP_DEVICE_BUS_PATH "device.bus_path"
194
195 /** For devices: serial number if applicable. e.g. "4711-0815-1234" */
196 #define PA_PROP_DEVICE_SERIAL "device.serial"
197
198 /** For devices: vendor ID if applicable. e.g. 1274 */
199 #define PA_PROP_DEVICE_VENDOR_ID "device.vendor.id"
200
201 /** For devices: vendor name if applicable. e.g. "Foocorp Heavy Industries" */
202 #define PA_PROP_DEVICE_VENDOR_NAME "device.vendor.name"
203
204 /** For devices: product ID if applicable. e.g. 4565 */
205 #define PA_PROP_DEVICE_PRODUCT_ID "device.product.id"
206
207 /** For devices: product name if applicable. e.g. "SuperSpeakers 2000 Pro" */
208 #define PA_PROP_DEVICE_PRODUCT_NAME "device.product.name"
209
210 /** For devices: device class. One of "sound", "modem", "monitor", "filter" */
211 #define PA_PROP_DEVICE_CLASS "device.class"
212
213 /** For devices: form factor if applicable. One of "internal", "speaker", "handset", "tv", "webcam", "microphone", "headset", "headphone", "hands-free", "car", "hifi", "computer", "portable" */
214 #define PA_PROP_DEVICE_FORM_FACTOR "device.form_factor"
215
216 /** For devices: bus of the device if applicable. One of "isa", "pci", "usb", "firewire", "bluetooth" */
217 #define PA_PROP_DEVICE_BUS "device.bus"
218
219 /** \cond fulldocs */
220 /** For devices: icon for the device. A binary blob containing PNG image data */
221 #define PA_PROP_DEVICE_ICON "device.icon"
222 /** \endcond */
223
224 /** For devices: an XDG icon name for the device. e.g. "sound-card-speakers-usb" */
225 #define PA_PROP_DEVICE_ICON_NAME "device.icon_name"
226
227 /** For devices: access mode of the device if applicable. One of "mmap", "mmap_rewrite", "serial" */
228 #define PA_PROP_DEVICE_ACCESS_MODE "device.access_mode"
229
230 /** For filter devices: master device id if applicable. */
231 #define PA_PROP_DEVICE_MASTER_DEVICE "device.master_device"
232
233 /** For devices: buffer size in bytes, integer formatted as string. */
234 #define PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE "device.buffering.buffer_size"
235
236 /** For devices: fragment size in bytes, integer formatted as string. */
237 #define PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE "device.buffering.fragment_size"
238
239 /** For devices: profile identifier for the profile this devices is in. e.g. "analog-stereo", "analog-surround-40", "iec958-stereo", ...*/
240 #define PA_PROP_DEVICE_PROFILE_NAME "device.profile.name"
241
242 /** For devices: intended use. A space separated list of roles (see PA_PROP_MEDIA_ROLE) this device is particularly well suited for, due to latency, quality or form factor. \since 0.9.16 */
243 #define PA_PROP_DEVICE_INTENDED_ROLES "device.intended_roles"
244
245 /** For devices: human readable one-line description of the profile this device is in. e.g. "Analog Stereo", ... */
246 #define PA_PROP_DEVICE_PROFILE_DESCRIPTION "device.profile.description"
247
248 /** For modules: the author's name, formatted as UTF-8 string. e.g. "Lennart Poettering" */
249 #define PA_PROP_MODULE_AUTHOR "module.author"
250
251 /** For modules: a human readable one-line description of the module's purpose formatted as UTF-8. e.g. "Frobnicate sounds with a flux compensator" */
252 #define PA_PROP_MODULE_DESCRIPTION "module.description"
253
254 /** For modules: a human readable usage description of the module's arguments formatted as UTF-8. */
255 #define PA_PROP_MODULE_USAGE "module.usage"
256
257 /** For modules: a version string for the module. e.g. "0.9.15" */
258 #define PA_PROP_MODULE_VERSION "module.version"
259
260 /** For PCM formats: the sample format used as returned by pa_sample_format_to_string() \since 1.0 */
261 #define PA_PROP_FORMAT_SAMPLE_FORMAT "format.sample_format"
262
263 /** For all formats: the sample rate (unsigned integer) \since 1.0 */
264 #define PA_PROP_FORMAT_RATE "format.rate"
265
266 /** For all formats: the number of channels (unsigned integer) \since 1.0 */
267 #define PA_PROP_FORMAT_CHANNELS "format.channels"
268
269 /** For PCM formats: the channel map of the stream as returned by pa_channel_map_snprint() \since 1.0 */
270 #define PA_PROP_FORMAT_CHANNEL_MAP "format.channel_map"
271
272 /** A property list object. Basically a dictionary with ASCII strings
273 * as keys and arbitrary data as values. \since 0.9.11 */
274 typedef struct pa_proplist pa_proplist;
275
276 /** Allocate a property list. \since 0.9.11 */
277 pa_proplist* pa_proplist_new(void);
278
279 /** Free the property list. \since 0.9.11 */
280 void pa_proplist_free(pa_proplist* p);
281
282 /** Returns a non-zero value if the key is valid. \since 3.0 */
283 int pa_proplist_key_valid(const char *key);
284
285 /** Append a new string entry to the property list, possibly
286 * overwriting an already existing entry with the same key. An
287 * internal copy of the data passed is made. Will accept only valid
288 * UTF-8. \since 0.9.11 */
289 int pa_proplist_sets(pa_proplist *p, const char *key, const char *value);
290
291 /** Append a new string entry to the property list, possibly
292 * overwriting an already existing entry with the same key. An
293 * internal copy of the data passed is made. Will accept only valid
294 * UTF-8. The string passed in must contain a '='. Left hand side of
295 * the '=' is used as key name, the right hand side as string
296 * data. \since 0.9.16 */
297 int pa_proplist_setp(pa_proplist *p, const char *pair);
298
299 /** Append a new string entry to the property list, possibly
300 * overwriting an already existing entry with the same key. An
301 * internal copy of the data passed is made. Will accept only valid
302 * UTF-8. The data can be passed as printf()-style format string with
303 * arguments. \since 0.9.11 */
304 int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) PA_GCC_PRINTF_ATTR(3,4);
305
306 /** Append a new arbitrary data entry to the property list, possibly
307 * overwriting an already existing entry with the same key. An
308 * internal copy of the data passed is made. \since 0.9.11 */
309 int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nbytes);
310
311 /** Return a string entry for the specified key. Will return NULL if
312 * the data is not valid UTF-8. Will return a NUL-terminated string in
313 * an internally allocated buffer. The caller should make a copy of
314 * the data before accessing the property list again. \since 0.9.11 */
315 const char *pa_proplist_gets(pa_proplist *p, const char *key);
316
317 /** Store the value for the specified key in \a data. Will store a
318 * NUL-terminated string for string entries. The \a data pointer returned will
319 * point to an internally allocated buffer. The caller should make a
320 * copy of the data before the property list is accessed again. \since
321 * 0.9.11 */
322 int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes);
323
324 /** Update mode enum for pa_proplist_update(). \since 0.9.11 */
325 typedef enum pa_update_mode {
326 PA_UPDATE_SET
327 /**< Replace the entire property list with the new one. Don't keep
328 * any of the old data around. */,
329
330 PA_UPDATE_MERGE
331 /**< Merge new property list into the existing one, not replacing
332 * any old entries if they share a common key with the new
333 * property list. */,
334
335 PA_UPDATE_REPLACE
336 /**< Merge new property list into the existing one, replacing all
337 * old entries that share a common key with the new property
338 * list. */
339 } pa_update_mode_t;
340
341 /** \cond fulldocs */
342 #define PA_UPDATE_SET PA_UPDATE_SET
343 #define PA_UPDATE_MERGE PA_UPDATE_MERGE
344 #define PA_UPDATE_REPLACE PA_UPDATE_REPLACE
345 /** \endcond */
346
347 /** Merge property list "other" into "p", adhering the merge mode as
348 * specified in "mode". \since 0.9.11 */
349 void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, const pa_proplist *other);
350
351 /** Removes a single entry from the property list, identified be the
352 * specified key name. \since 0.9.11 */
353 int pa_proplist_unset(pa_proplist *p, const char *key);
354
355 /** Similar to pa_proplist_unset() but takes an array of keys to
356 * remove. The array should be terminated by a NULL pointer. Returns -1
357 * on failure, otherwise the number of entries actually removed (which
358 * might even be 0, if there were no matching entries to
359 * remove). \since 0.9.11 */
360 int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]);
361
362 /** Iterate through the property list. The user should allocate a
363 * state variable of type void* and initialize it with NULL. A pointer
364 * to this variable should then be passed to pa_proplist_iterate()
365 * which should be called in a loop until it returns NULL which
366 * signifies EOL. The property list should not be modified during
367 * iteration through the list -- with the exception of deleting the
368 * current entry. On each invocation this function will return the
369 * key string for the next entry. The keys in the property list do not
370 * have any particular order. \since 0.9.11 */
371 const char *pa_proplist_iterate(pa_proplist *p, void **state);
372
373 /** Format the property list nicely as a human readable string. This
374 * works very much like pa_proplist_to_string_sep() and uses a newline
375 * as separator and appends one final one. Call pa_xfree() on the
376 * result. \since 0.9.11 */
377 char *pa_proplist_to_string(pa_proplist *p);
378
379 /** Format the property list nicely as a human readable string and
380 * choose the separator. Call pa_xfree() on the result. \since
381 * 0.9.15 */
382 char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep);
383
384 /** Allocate a new property list and assign key/value from a human
385 * readable string. \since 0.9.15 */
386 pa_proplist *pa_proplist_from_string(const char *str);
387
388 /** Returns 1 if an entry for the specified key exists in the
389 * property list. \since 0.9.11 */
390 int pa_proplist_contains(pa_proplist *p, const char *key);
391
392 /** Remove all entries from the property list object. \since 0.9.11 */
393 void pa_proplist_clear(pa_proplist *p);
394
395 /** Allocate a new property list and copy over every single entry from
396 * the specified list. \since 0.9.11 */
397 pa_proplist* pa_proplist_copy(const pa_proplist *p);
398
399 /** Return the number of entries in the property list. \since 0.9.15 */
400 unsigned pa_proplist_size(pa_proplist *p);
401
402 /** Returns 0 when the proplist is empty, positive otherwise \since 0.9.15 */
403 int pa_proplist_isempty(pa_proplist *p);
404
405 /** Return non-zero when a and b have the same keys and values.
406 * \since 0.9.16 */
407 int pa_proplist_equal(pa_proplist *a, pa_proplist *b);
408
409 PA_C_DECL_END
410
411 #endif