]> code.delx.au - pulseaudio/blob - src/pulse/proplist.h
Merge commit 'elmarco/shave'
[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 PA_C_DECL_BEGIN
32
33 /** For streams: localized media name, formatted as UTF-8. e.g. "Guns'N'Roses: Civil War".*/
34 #define PA_PROP_MEDIA_NAME "media.name"
35
36 /** For streams: localized media title if applicable, formatted as UTF-8. e.g. "Civil War" */
37 #define PA_PROP_MEDIA_TITLE "media.title"
38
39 /** For streams: localized media artist if applicable, formatted as UTF-8. e.g. "Guns'N'Roses" */
40 #define PA_PROP_MEDIA_ARTIST "media.artist"
41
42 /** For streams: media language if applicable, in standard POSIX format. e.g. "de_DE" */
43 #define PA_PROP_MEDIA_LANGUAGE "media.language"
44
45 /** For streams: source filename if applicable, in URI format or local path. e.g. "/home/lennart/music/foobar.ogg" */
46 #define PA_PROP_MEDIA_FILENAME "media.filename"
47
48 /** For streams: icon for the media. A binary blob containing PNG image data */
49 #define PA_PROP_MEDIA_ICON "media.icon"
50
51 /** For streams: an XDG icon name for the media. e.g. "audio-x-mp3" */
52 #define PA_PROP_MEDIA_ICON_NAME "media.icon_name"
53
54 /** For streams: logic role of this media. One of the strings "video", "music", "game", "event", "phone", "animation", "production", "a11y" */
55 #define PA_PROP_MEDIA_ROLE "media.role"
56
57 /** For event sound streams: XDG event sound name. e.g. "message-new-email" (Event sound streams are those with media.role set to "event") */
58 #define PA_PROP_EVENT_ID "event.id"
59
60 /** 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." */
61 #define PA_PROP_EVENT_DESCRIPTION "event.description"
62
63 /** 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" */
64 #define PA_PROP_EVENT_MOUSE_X "event.mouse.x"
65
66 /** 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" */
67 #define PA_PROP_EVENT_MOUSE_Y "event.mouse.y"
68
69 /** 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" */
70 #define PA_PROP_EVENT_MOUSE_HPOS "event.mouse.hpos"
71
72 /** 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" */
73 #define PA_PROP_EVENT_MOUSE_VPOS "event.mouse.vpos"
74
75 /** 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" */
76 #define PA_PROP_EVENT_MOUSE_BUTTON "event.mouse.button"
77
78 /** For streams that belong to a window on the screen: localized window title. e.g. "Totem Music Player" */
79 #define PA_PROP_WINDOW_NAME "window.name"
80
81 /** For streams that belong to a window on the screen: a textual id for identifying a window logically. e.g. "org.gnome.Totem.MainWindow" */
82 #define PA_PROP_WINDOW_ID "window.id"
83
84 /** For streams that belong to a window on the screen: window icon. A binary blob containing PNG image data */
85 #define PA_PROP_WINDOW_ICON "window.icon"
86
87 /** For streams that belong to a window on the screen: an XDG icon name for the window. e.g. "totem" */
88 #define PA_PROP_WINDOW_ICON_NAME "window.icon_name"
89
90 /** For streams that belong to an X11 window on the screen: the X11 display string. e.g. ":0.0" */
91 #define PA_PROP_WINDOW_X11_DISPLAY "window.x11.display"
92
93 /** 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" */
94 #define PA_PROP_WINDOW_X11_SCREEN "window.x11.screen"
95
96 /** 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" */
97 #define PA_PROP_WINDOW_X11_MONITOR "window.x11.monitor"
98
99 /** For streams that belong to an X11 window on the screen: the window XID, an integer formatted as string. e.g. "25632" */
100 #define PA_PROP_WINDOW_X11_XID "window.x11.xid"
101
102 /** For clients/streams: localized human readable application name. e.g. "Totem Music Player" */
103 #define PA_PROP_APPLICATION_NAME "application.name"
104
105 /** For clients/streams: a textual id for identifying an application logically. e.g. "org.gnome.Totem" */
106 #define PA_PROP_APPLICATION_ID "application.id"
107
108 /** For clients/streams: a version string e.g. "0.6.88" */
109 #define PA_PROP_APPLICATION_VERSION "application.version"
110
111 /** For clients/streams: application icon. A binary blob containing PNG image data */
112 #define PA_PROP_APPLICATION_ICON "application.icon"
113
114 /** For clients/streams: an XDG icon name for the application. e.g. "totem" */
115 #define PA_PROP_APPLICATION_ICON_NAME "application.icon_name"
116
117 /** For clients/streams: application language if applicable, in standard POSIX format. e.g. "de_DE" */
118 #define PA_PROP_APPLICATION_LANGUAGE "application.language"
119
120 /** For clients/streams on UNIX: application process PID, an integer formatted as string. e.g. "4711" */
121 #define PA_PROP_APPLICATION_PROCESS_ID "application.process.id"
122
123 /** For clients/streams: application process name. e.g. "totem" */
124 #define PA_PROP_APPLICATION_PROCESS_BINARY "application.process.binary"
125
126 /** For clients/streams: application user name. e.g. "lennart" */
127 #define PA_PROP_APPLICATION_PROCESS_USER "application.process.user"
128
129 /** For clients/streams: host name the application runs on. e.g. "omega" */
130 #define PA_PROP_APPLICATION_PROCESS_HOST "application.process.host"
131
132 /** For clients/streams: the D-Bus host id the application runs on. e.g. "543679e7b01393ed3e3e650047d78f6e" */
133 #define PA_PROP_APPLICATION_PROCESS_MACHINE_ID "application.process.machine_id"
134
135 /** For clients/streams: an id for the login session the application runs in. On Unix the value of $XDG_SESSION_COOKIE. e.g. "543679e7b01393ed3e3e650047d78f6e-1235159798.76193-190367717" */
136 #define PA_PROP_APPLICATION_PROCESS_SESSION_ID "application.process.session_id"
137
138 /** For devices: device string in the underlying audio layer's format. e.g. "surround51:0" */
139 #define PA_PROP_DEVICE_STRING "device.string"
140
141 /** For devices: API this device is access with. e.g. "alsa" */
142 #define PA_PROP_DEVICE_API "device.api"
143
144 /** For devices: localized human readable device one-line description, e.g. "Foobar Industries USB Headset 2000+ Ultra" */
145 #define PA_PROP_DEVICE_DESCRIPTION "device.description"
146
147 /** For devices: bus path to the device in the OS' format. e.g. "/sys/bus/pci/devices/0000:00:1f.2" */
148 #define PA_PROP_DEVICE_BUS_PATH "device.bus_path"
149
150 /** For devices: serial number if applicable. e.g. "4711-0815-1234" */
151 #define PA_PROP_DEVICE_SERIAL "device.serial"
152
153 /** For devices: vendor/product ID if applicable. e.g. 1274:1371 */
154 #define PA_PROP_DEVICE_VENDOR_PRODUCT_ID "device.vendor_product_id"
155
156 /** For devices: device class. One of "sound", "modem", "monitor", "filter" */
157 #define PA_PROP_DEVICE_CLASS "device.class"
158
159 /** For devices: form factor if applicable. One of "laptop-speakers", "external-speakers", "telephone", "tv-capture", "webcam-capture", "microphone-capture", "headset", "headphones", "hands-free", "car", "hifi", "computer", "portable" */
160 #define PA_PROP_DEVICE_FORM_FACTOR "device.form_factor"
161
162 /** For devices: connector of the device if applicable. One of "isa", "pci", "usb", "firewire", "bluetooth" */
163 #define PA_PROP_DEVICE_CONNECTOR "device.connector"
164
165 /** For devices: access mode of the device if applicable. One of "mmap", "mmap_rewrite", "serial" */
166 #define PA_PROP_DEVICE_ACCESS_MODE "device.access_mode"
167
168 /** For filter devices: master device id if applicable. */
169 #define PA_PROP_DEVICE_MASTER_DEVICE "device.master_device"
170
171 /** For devices: buffer size in bytes, integer formatted as string.. */
172 #define PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE "device.buffering.buffer_size"
173
174 /** For devices: fragment size in bytes, integer formatted as string. */
175 #define PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE "device.buffering.fragment_size"
176
177 /** For devices: profile identifier for the profile this devices is in. e.g. "analog-stereo", "analog-surround-40", "iec958-stereo", ...*/
178 #define PA_PROP_DEVICE_PROFILE_NAME "device.profile.name"
179
180 /** For devices: human readable one-line description of the profile this device is in. e.g. "Analog Stereo", ... */
181 #define PA_PROP_DEVICE_PROFILE_DESCRIPTION "device.profile.description"
182
183 /** For modules: the author's name, formatted as UTF-8 string. e.g. "Lennart Poettering" */
184 #define PA_PROP_MODULE_AUTHOR "module.author"
185
186 /** 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" */
187 #define PA_PROP_MODULE_DESCRIPTION "module.description"
188
189 /** For modules: a human readable usage description of the module's arguments formatted as UTF-8. */
190 #define PA_PROP_MODULE_USAGE "module.usage"
191
192 /** For modules: a version string for the module. e.g. "0.9.15" */
193 #define PA_PROP_MODULE_VERSION "module.version"
194
195 /** A property list object. Basically a dictionary with ASCII strings
196 * as keys and arbitrary data as values. \since 0.9.11 */
197 typedef struct pa_proplist pa_proplist;
198
199 /** Allocate a property list. \since 0.9.11 */
200 pa_proplist* pa_proplist_new(void);
201
202 /** Free the property list. \since 0.9.11 */
203 void pa_proplist_free(pa_proplist* p);
204
205 /** Append a new string entry to the property list, possibly
206 * overwriting an already existing entry with the same key. An
207 * internal copy of the data passed is made. Will accept only valid
208 * UTF-8. \since 0.9.11 */
209 int pa_proplist_sets(pa_proplist *p, const char *key, const char *value);
210
211 /** Append a new string entry to the property list, possibly
212 * overwriting an already existing entry with the same key. An
213 * internal copy of the data passed is made. Will accept only valid
214 * UTF-8. The data can be passed as printf()-style format string with
215 * arguments. \since 0.9.11 */
216 int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) PA_GCC_PRINTF_ATTR(3,4);
217
218 /** Append a new arbitrary data entry to the property list, possibly
219 * overwriting an already existing entry with the same key. An
220 * internal copy of the data passed is made. \since 0.9.11 */
221 int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nbytes);
222
223 /** Return a string entry for the specified key. Will return NULL if
224 * the data is not valid UTF-8. Will return a NUL-terminated string in
225 * an internally allocated buffer. The caller should make a copy of
226 * the data before accessing the property list again. \since 0.9.11 */
227 const char *pa_proplist_gets(pa_proplist *p, const char *key);
228
229 /** Return the the value for the specified key. Will return a
230 * NUL-terminated string for string entries. The pointer returned will
231 * point to an internally allocated buffer. The caller should make a
232 * copy of the data before the property list is accessed again. \since
233 * 0.9.11 */
234 int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes);
235
236 /** Update mode enum for pa_proplist_update(). \since 0.9.11 */
237 typedef enum pa_update_mode {
238 PA_UPDATE_SET
239 /**< Replace the entirey property list with the new one. Don't keep
240 * any of the old data around */,
241
242 PA_UPDATE_MERGE
243 /**< Merge new property list into the existing one, not replacing
244 * any old entries if they share a common key with the new
245 * property list. */,
246
247 PA_UPDATE_REPLACE
248 /**< Merge new property list into the existing one, replacing all
249 * old entries that share a common key with the new property
250 * list. */
251 } pa_update_mode_t;
252
253 /** \cond fulldocs */
254 #define PA_UPDATE_SET PA_UPDATE_SET
255 #define PA_UPDATE_MERGE PA_UPDATE_MERGE
256 #define PA_UPDATE_REPLACE PA_UPDATE_REPLACE
257 /** \endcond */
258
259 /** Merge property list "other" into "p", adhering the merge mode as
260 * specified in "mode". \since 0.9.11 */
261 void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, pa_proplist *other);
262
263 /** Removes a single entry from the property list, identified be the
264 * specified key name. \since 0.9.11 */
265 int pa_proplist_unset(pa_proplist *p, const char *key);
266
267 /** Similar to pa_proplist_remove() but takes an array of keys to
268 * remove. The array should be terminated by a NULL pointer. Return -1
269 * on failure, otherwise the number of entries actually removed (which
270 * might even be 0, if there where no matching entries to
271 * remove). \since 0.9.11 */
272 int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]);
273
274 /** Iterate through the property list. The user should allocate a
275 * state variable of type void* and initialize it with NULL. A pointer
276 * to this variable should then be passed to pa_proplist_iterate()
277 * which should be called in a loop until it returns NULL which
278 * signifies EOL. The property list should not be modified during
279 * iteration through the list -- except for deleting the current
280 * looked at entry. On each invication this function will return the
281 * key string for the next entry. The keys in the property list do not
282 * have any particular order. \since 0.9.11 */
283 const char *pa_proplist_iterate(pa_proplist *p, void **state);
284
285 /** Format the property list nicely as a human readable string. This
286 * works very much like pa_proplist_to_string_sep() and uses a newline
287 * as seperator and appends one final one. Call pa_xfree() on the
288 * result. \since 0.9.11 */
289 char *pa_proplist_to_string(pa_proplist *p);
290
291 /** Format the property list nicely as a human readable string and
292 * choose the seperator. Call pa_xfree() on the result. \since
293 * 0.9.15 */
294 char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep);
295
296 /** Allocate a new property list and assign key/value from a human
297 * readable string. \since 0.9.15 */
298 pa_proplist *pa_proplist_from_string(const char *str);
299
300 /** Returns 1 if an entry for the specified key is existant in the
301 * property list. \since 0.9.11 */
302 int pa_proplist_contains(pa_proplist *p, const char *key);
303
304 /** Remove all entries from the property list object. \since 0.9.11 */
305 void pa_proplist_clear(pa_proplist *p);
306
307 /** Allocate a new property list and copy over every single entry from
308 * the specific list. \since 0.9.11 */
309 pa_proplist* pa_proplist_copy(pa_proplist *t);
310
311 /** Return the number of entries on the property list. \since 0.9.15 */
312 unsigned pa_proplist_size(pa_proplist *t);
313
314 /** Returns 0 when the proplist is empty, positive otherwise \since 0.9.15 */
315 int pa_proplist_isempty(pa_proplist *t);
316
317 PA_C_DECL_END
318
319 #endif