1 #ifndef foopulseproplisthfoo
2 #define foopulseproplisthfoo
7 This file is part of PulseAudio.
9 Copyright 2007 Lennart Poettering
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
13 published by the Free Software Foundation; either version 2.1 of the
14 License, or (at your option) any later version.
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 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public
22 License along with PulseAudio; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #include <pulse/cdecl.h>
28 #include <pulse/gccmacro.h>
32 /* Defined properties:
34 * media.name "Guns'N'Roses: Civil War"
35 * media.title "Civil War"
36 * media.artist "Guns'N'Roses"
37 * media.language "de_DE"
41 * media.role video, music, game, event, phone, production, filter, abstract, stream
42 * event.id button-click, session-login
48 * application.name "Rhythmbox Media Player"
49 * application.id "org.gnome.rhythmbox"
52 * application.icon_name
53 * application.process.id
54 * application.process.binary
55 * application.process.user
56 * application.process.host
58 * device.api oss, alsa, sunaudio
62 * device.vendor_product_id
63 * device.class sound, modem, monitor, filter
64 * device.form_factor laptop-speakers, external-speakers, telephone, tv-capture, webcam-capture, microphone-capture, headset
65 * device.connector isa, pci, usb, firewire, bluetooth
66 * device.access_mode mmap, mmap_rewrite, serial
67 * device.master_device
71 #define PA_PROP_MEDIA_NAME "media.name"
72 #define PA_PROP_MEDIA_TITLE "media.title"
73 #define PA_PROP_MEDIA_ARTIST "media.artist"
74 #define PA_PROP_MEDIA_LANGUAGE "media.language"
75 #define PA_PROP_MEDIA_FILENAME "media.filename"
76 #define PA_PROP_MEDIA_ICON "media.icon"
77 #define PA_PROP_MEDIA_ICON_NAME "media.icon_name"
78 #define PA_PROP_MEDIA_ROLE "media.role"
79 #define PA_PROP_EVENT_ID "event.id"
80 #define PA_PROP_EVENT_X11_DISPLAY "event.x11.display"
81 #define PA_PROP_EVENT_X11_XID "event.x11.xid"
82 #define PA_PROP_EVENT_MOUSE_X "event.mouse.x"
83 #define PA_PROP_EVENT_MOUSE_Y "event.mouse.y"
84 #define PA_PROP_EVENT_MOUSE_BUTTON "event.mouse.button"
85 #define PA_PROP_APPLICATION_NAME "application.name"
86 #define PA_PROP_APPLICATION_ID "application.id"
87 #define PA_PROP_APPLICATION_VERSION "application.version"
88 #define PA_PROP_APPLICATION_ICON "application.icon"
89 #define PA_PROP_APPLICATION_ICON_NAME "application.icon_name"
90 #define PA_PROP_APPLICATION_LANGUAGE "application.language"
91 #define PA_PROP_APPLICATION_PROCESS_ID "application.process.id"
92 #define PA_PROP_APPLICATION_PROCESS_BINARY "application.process.binary"
93 #define PA_PROP_APPLICATION_PROCESS_USER "application.process.user"
94 #define PA_PROP_APPLICATION_PROCESS_HOST "application.process.host"
95 #define PA_PROP_DEVICE_STRING "device.string"
96 #define PA_PROP_DEVICE_API "device.api"
97 #define PA_PROP_DEVICE_DESCRIPTION "device.description"
98 #define PA_PROP_DEVICE_BUS_PATH "device.bus_path"
99 #define PA_PROP_DEVICE_SERIAL "device.serial"
100 #define PA_PROP_DEVICE_VENDOR_PRODUCT_ID "device.vendor_product_id"
101 #define PA_PROP_DEVICE_CLASS "device.class"
102 #define PA_PROP_DEVICE_FORM_FACTOR "device.form_factor"
103 #define PA_PROP_DEVICE_CONNECTOR "device.connector"
104 #define PA_PROP_DEVICE_ACCESS_MODE "device.access_mode"
105 #define PA_PROP_DEVICE_MASTER_DEVICE "device.master_device"
106 #define PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE "device.buffering.buffer_size"
107 #define PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE "device.buffering.fragment_size"
109 /** A property list object. Basically a dictionary with UTF-8 strings
110 * as keys and arbitrary data as values. \since 0.9.11 */
111 typedef struct pa_proplist pa_proplist;
113 /** Allocate a property list. \since 0.9.11 */
114 pa_proplist* pa_proplist_new(void);
116 /** Free the property list. \since 0.9.11 */
117 void pa_proplist_free(pa_proplist* p);
119 /** Append a new string entry to the property list, possibly
120 * overwriting an already existing entry with the same key. An
121 * internal copy of the data passed is made. Will accept only valid
122 * UTF-8. \since 0.9.11 */
123 int pa_proplist_sets(pa_proplist *p, const char *key, const char *value);
125 /** Append a new string entry to the property list, possibly
126 * overwriting an already existing entry with the same key. An
127 * internal copy of the data passed is made. Will accept only valid
128 * UTF-8. The data can be passed as printf()-style format string with
129 * arguments. \since 0.9.11 */
130 int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) PA_GCC_PRINTF_ATTR(3,4);
132 /** Append a new arbitrary data entry to the property list, possibly
133 * overwriting an already existing entry with the same key. An
134 * internal copy of the data passed is made. \since 0.9.11 */
135 int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nbytes);
137 /* Return a string entry for the specified key. Will return NULL if
138 * the data is not valid UTF-8. Will return a NUL-terminated string in
139 * an internally allocated buffer. The caller should make a copy of
140 * the data before accessing the property list again. \since 0.9.11 */
141 const char *pa_proplist_gets(pa_proplist *p, const char *key);
143 /** Return the the value for the specified key. Will return a
144 * NUL-terminated string for string entries. The pointer returned will
145 * point to an internally allocated buffer. The caller should make a
146 * copy of the data before the property list is accessed again. \since
148 int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes);
150 /** Update mode enum for pa_proplist_update(). \since 0.9.11 */
151 typedef enum pa_update_mode {
152 PA_UPDATE_SET, /*< Replace the entirey property list with the new one. Don't keep any of the old data around */
153 PA_UPDATE_MERGE, /*< Merge new property list into the existing one, not replacing any old entries if they share a common key with the new property list. */
154 PA_UPDATE_REPLACE /*< Merge new property list into the existing one, replacing all old entries that share a common key with the new property list. */
157 /** Merge property list "other" into "p", adhering the merge mode as
158 * specified in "mode". \since 0.9.11 */
159 void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, pa_proplist *other);
161 /** Removes a single entry from the property list, identified be the
162 * specified key name. \since 0.9.11 */
163 int pa_proplist_unset(pa_proplist *p, const char *key);
165 /** Similar to pa_proplist_remove() but takes an array of keys to
166 * remove. The array should be terminated by a NULL pointer. Return -1
167 * on failure, otherwise the number of entries actually removed (which
168 * might even be 0, if there where no matching entries to
169 * remove). \since 0.9.11 */
170 int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]);
172 /** Iterate through the property list. The user should allocate a
173 * state variable of type void* and initialize it with NULL. A pointer
174 * to this variable should then be passed to pa_proplist_iterate()
175 * which should be called in a loop until it returns NULL which
176 * signifies EOL. The property list should not be modified during
177 * iteration through the list. On each invication this function will
178 * return the key string for the next entry. The keys in the property
179 * list do not have any particular order. \since 0.9.11 */
180 const char *pa_proplist_iterate(pa_proplist *p, void **state);
182 /** Format the property list nicely as a human readable string. Call pa_xfree() on the result. \since
184 char *pa_proplist_to_string(pa_proplist *p);
186 /** Returns 1 if an entry for the specified key is existant in the
187 * property list. \since 0.9.11 */
188 int pa_proplist_contains(pa_proplist *p, const char *key);
190 /** Remove all entries from the property list object. \since 0.9.11 */
191 void pa_proplist_clear(pa_proplist *p);
193 /** Allocate a new property list and copy over every single entry from
194 * the specific list. \since 0.9.11 */
195 pa_proplist* pa_proplist_copy(pa_proplist *t);