proplist.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. #ifndef foopulseproplisthfoo
  2. #define foopulseproplisthfoo
  3. /***
  4. This file is part of PulseAudio.
  5. Copyright 2007 Lennart Poettering
  6. PulseAudio is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU Lesser General Public License as
  8. published by the Free Software Foundation; either version 2.1 of the
  9. License, or (at your option) any later version.
  10. PulseAudio is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
  16. ***/
  17. #include <sys/types.h>
  18. #include <pulse/cdecl.h>
  19. #include <pulse/gccmacro.h>
  20. #include <pulse/version.h>
  21. /** \file
  22. * Property list constants and functions */
  23. PA_C_DECL_BEGIN
  24. /** For streams: localized media name, formatted as UTF-8. E.g. "Guns'N'Roses: Civil War".*/
  25. #define PA_PROP_MEDIA_NAME "media.name"
  26. /** For streams: localized media title if applicable, formatted as UTF-8. E.g. "Civil War" */
  27. #define PA_PROP_MEDIA_TITLE "media.title"
  28. /** For streams: localized media artist if applicable, formatted as UTF-8. E.g. "Guns'N'Roses" */
  29. #define PA_PROP_MEDIA_ARTIST "media.artist"
  30. /** For streams: localized media copyright string if applicable, formatted as UTF-8. E.g. "Evil Record Corp." */
  31. #define PA_PROP_MEDIA_COPYRIGHT "media.copyright"
  32. /** For streams: localized media generator software string if applicable, formatted as UTF-8. E.g. "Foocrop AudioFrobnicator" */
  33. #define PA_PROP_MEDIA_SOFTWARE "media.software"
  34. /** For streams: media language if applicable, in standard POSIX format. E.g. "de_DE" */
  35. #define PA_PROP_MEDIA_LANGUAGE "media.language"
  36. /** For streams: source filename if applicable, in URI format or local path. E.g. "/home/lennart/music/foobar.ogg" */
  37. #define PA_PROP_MEDIA_FILENAME "media.filename"
  38. /** \cond fulldocs */
  39. /** For streams: icon for the media. A binary blob containing PNG image data */
  40. #define PA_PROP_MEDIA_ICON "media.icon"
  41. /** \endcond */
  42. /** For streams: an XDG icon name for the media. E.g. "audio-x-mp3" */
  43. #define PA_PROP_MEDIA_ICON_NAME "media.icon_name"
  44. /** For streams: logic role of this media. One of the strings "video", "music", "game", "event", "phone", "animation", "production", "a11y", "test" */
  45. #define PA_PROP_MEDIA_ROLE "media.role"
  46. /** 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 */
  47. #define PA_PROP_FILTER_WANT "filter.want"
  48. /** 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 */
  49. #define PA_PROP_FILTER_APPLY "filter.apply"
  50. /** 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 its own, internal AEC) \since 1.0 */
  51. #define PA_PROP_FILTER_SUPPRESS "filter.suppress"
  52. /** For event sound streams: XDG event sound name. e.g.\ "message-new-email" (Event sound streams are those with media.role set to "event") */
  53. #define PA_PROP_EVENT_ID "event.id"
  54. /** 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." */
  55. #define PA_PROP_EVENT_DESCRIPTION "event.description"
  56. /** 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" */
  57. #define PA_PROP_EVENT_MOUSE_X "event.mouse.x"
  58. /** 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" */
  59. #define PA_PROP_EVENT_MOUSE_Y "event.mouse.y"
  60. /** 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" */
  61. #define PA_PROP_EVENT_MOUSE_HPOS "event.mouse.hpos"
  62. /** 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" */
  63. #define PA_PROP_EVENT_MOUSE_VPOS "event.mouse.vpos"
  64. /** 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" */
  65. #define PA_PROP_EVENT_MOUSE_BUTTON "event.mouse.button"
  66. /** For streams that belong to a window on the screen: localized window title. E.g. "Totem Music Player" */
  67. #define PA_PROP_WINDOW_NAME "window.name"
  68. /** For streams that belong to a window on the screen: a textual id for identifying a window logically. E.g. "org.gnome.Totem.MainWindow" */
  69. #define PA_PROP_WINDOW_ID "window.id"
  70. /** \cond fulldocs */
  71. /** For streams that belong to a window on the screen: window icon. A binary blob containing PNG image data */
  72. #define PA_PROP_WINDOW_ICON "window.icon"
  73. /** \endcond */
  74. /** For streams that belong to a window on the screen: an XDG icon name for the window. E.g. "totem" */
  75. #define PA_PROP_WINDOW_ICON_NAME "window.icon_name"
  76. /** 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 */
  77. #define PA_PROP_WINDOW_X "window.x"
  78. /** 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 */
  79. #define PA_PROP_WINDOW_Y "window.y"
  80. /** 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 */
  81. #define PA_PROP_WINDOW_WIDTH "window.width"
  82. /** 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 */
  83. #define PA_PROP_WINDOW_HEIGHT "window.height"
  84. /** 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 */
  85. #define PA_PROP_WINDOW_HPOS "window.hpos"
  86. /** 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 */
  87. #define PA_PROP_WINDOW_VPOS "window.vpos"
  88. /** 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 */
  89. #define PA_PROP_WINDOW_DESKTOP "window.desktop"
  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. /** 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" */
  93. #define PA_PROP_WINDOW_X11_SCREEN "window.x11.screen"
  94. /** 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" */
  95. #define PA_PROP_WINDOW_X11_MONITOR "window.x11.monitor"
  96. /** For streams that belong to an X11 window on the screen: the window XID, an integer formatted as string. E.g. "25632" */
  97. #define PA_PROP_WINDOW_X11_XID "window.x11.xid"
  98. /** For clients/streams: localized human readable application name. E.g. "Totem Music Player" */
  99. #define PA_PROP_APPLICATION_NAME "application.name"
  100. /** For clients/streams: a textual id for identifying an application logically. E.g. "org.gnome.Totem" */
  101. #define PA_PROP_APPLICATION_ID "application.id"
  102. /** For clients/streams: a version string, e.g.\ "0.6.88" */
  103. #define PA_PROP_APPLICATION_VERSION "application.version"
  104. /** \cond fulldocs */
  105. /** For clients/streams: application icon. A binary blob containing PNG image data */
  106. #define PA_PROP_APPLICATION_ICON "application.icon"
  107. /** \endcond */
  108. /** For clients/streams: an XDG icon name for the application. E.g. "totem" */
  109. #define PA_PROP_APPLICATION_ICON_NAME "application.icon_name"
  110. /** For clients/streams: application language if applicable, in standard POSIX format. E.g. "de_DE" */
  111. #define PA_PROP_APPLICATION_LANGUAGE "application.language"
  112. /** For clients/streams on UNIX: application process PID, an integer formatted as string. E.g. "4711" */
  113. #define PA_PROP_APPLICATION_PROCESS_ID "application.process.id"
  114. /** For clients/streams: application process name. E.g. "totem" */
  115. #define PA_PROP_APPLICATION_PROCESS_BINARY "application.process.binary"
  116. /** For clients/streams: application user name. E.g. "lennart" */
  117. #define PA_PROP_APPLICATION_PROCESS_USER "application.process.user"
  118. /** For clients/streams: host name the application runs on. E.g. "omega" */
  119. #define PA_PROP_APPLICATION_PROCESS_HOST "application.process.host"
  120. /** For clients/streams: the D-Bus host id the application runs on. E.g. "543679e7b01393ed3e3e650047d78f6e" */
  121. #define PA_PROP_APPLICATION_PROCESS_MACHINE_ID "application.process.machine_id"
  122. /** For clients/streams: an id for the login session the application runs in. On Unix the value of $XDG_SESSION_ID. E.g. "5" */
  123. #define PA_PROP_APPLICATION_PROCESS_SESSION_ID "application.process.session_id"
  124. /** For devices: device string in the underlying audio layer's format. E.g. "surround51:0" */
  125. #define PA_PROP_DEVICE_STRING "device.string"
  126. /** For devices: API this device is access with. E.g. "alsa" */
  127. #define PA_PROP_DEVICE_API "device.api"
  128. /** For devices: localized human readable device one-line description. E.g. "Foobar Industries USB Headset 2000+ Ultra" */
  129. #define PA_PROP_DEVICE_DESCRIPTION "device.description"
  130. /** For devices: bus path to the device in the OS' format. E.g. "/sys/bus/pci/devices/0000:00:1f.2" */
  131. #define PA_PROP_DEVICE_BUS_PATH "device.bus_path"
  132. /** For devices: serial number if applicable. E.g. "4711-0815-1234" */
  133. #define PA_PROP_DEVICE_SERIAL "device.serial"
  134. /** For devices: vendor ID if applicable. E.g. 1274 */
  135. #define PA_PROP_DEVICE_VENDOR_ID "device.vendor.id"
  136. /** For devices: vendor name if applicable. E.g. "Foocorp Heavy Industries" */
  137. #define PA_PROP_DEVICE_VENDOR_NAME "device.vendor.name"
  138. /** For devices: product ID if applicable. E.g. 4565 */
  139. #define PA_PROP_DEVICE_PRODUCT_ID "device.product.id"
  140. /** For devices: product name if applicable. E.g. "SuperSpeakers 2000 Pro" */
  141. #define PA_PROP_DEVICE_PRODUCT_NAME "device.product.name"
  142. /** For devices: device class. One of "sound", "modem", "monitor", "filter" */
  143. #define PA_PROP_DEVICE_CLASS "device.class"
  144. /** For devices: form factor if applicable. One of "internal", "speaker", "handset", "tv", "webcam", "microphone", "headset", "headphone", "hands-free", "car", "hifi", "computer", "portable" */
  145. #define PA_PROP_DEVICE_FORM_FACTOR "device.form_factor"
  146. /** For devices: bus of the device if applicable. One of "isa", "pci", "usb", "firewire", "bluetooth" */
  147. #define PA_PROP_DEVICE_BUS "device.bus"
  148. /** \cond fulldocs */
  149. /** For devices: icon for the device. A binary blob containing PNG image data */
  150. #define PA_PROP_DEVICE_ICON "device.icon"
  151. /** \endcond */
  152. /** For devices: an XDG icon name for the device. E.g. "sound-card-speakers-usb" */
  153. #define PA_PROP_DEVICE_ICON_NAME "device.icon_name"
  154. /** For devices: access mode of the device if applicable. One of "mmap", "mmap_rewrite", "serial" */
  155. #define PA_PROP_DEVICE_ACCESS_MODE "device.access_mode"
  156. /** For filter devices: master device id if applicable. */
  157. #define PA_PROP_DEVICE_MASTER_DEVICE "device.master_device"
  158. /** For devices: buffer size in bytes, integer formatted as string. */
  159. #define PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE "device.buffering.buffer_size"
  160. /** For devices: fragment size in bytes, integer formatted as string. */
  161. #define PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE "device.buffering.fragment_size"
  162. /** For devices: profile identifier for the profile this devices is in. E.g. "analog-stereo", "analog-surround-40", "iec958-stereo", ...*/
  163. #define PA_PROP_DEVICE_PROFILE_NAME "device.profile.name"
  164. /** 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 */
  165. #define PA_PROP_DEVICE_INTENDED_ROLES "device.intended_roles"
  166. /** For devices: human readable one-line description of the profile this device is in. E.g. "Analog Stereo", ... */
  167. #define PA_PROP_DEVICE_PROFILE_DESCRIPTION "device.profile.description"
  168. /** For modules: the author's name, formatted as UTF-8 string. E.g. "Lennart Poettering" */
  169. #define PA_PROP_MODULE_AUTHOR "module.author"
  170. /** 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" */
  171. #define PA_PROP_MODULE_DESCRIPTION "module.description"
  172. /** For modules: a human readable usage description of the module's arguments formatted as UTF-8. */
  173. #define PA_PROP_MODULE_USAGE "module.usage"
  174. /** For modules: a version string for the module. E.g. "0.9.15" */
  175. #define PA_PROP_MODULE_VERSION "module.version"
  176. /** For PCM formats: the sample format used as returned by pa_sample_format_to_string() \since 1.0 */
  177. #define PA_PROP_FORMAT_SAMPLE_FORMAT "format.sample_format"
  178. /** For all formats: the sample rate (unsigned integer) \since 1.0 */
  179. #define PA_PROP_FORMAT_RATE "format.rate"
  180. /** For all formats: the number of channels (unsigned integer) \since 1.0 */
  181. #define PA_PROP_FORMAT_CHANNELS "format.channels"
  182. /** For PCM formats: the channel map of the stream as returned by pa_channel_map_snprint() \since 1.0 */
  183. #define PA_PROP_FORMAT_CHANNEL_MAP "format.channel_map"
  184. /** A property list object. Basically a dictionary with ASCII strings
  185. * as keys and arbitrary data as values. \since 0.9.11 */
  186. typedef struct pa_proplist pa_proplist;
  187. /** Allocate a property list. \since 0.9.11 */
  188. pa_proplist* pa_proplist_new(void);
  189. /** Free the property list. \since 0.9.11 */
  190. void pa_proplist_free(pa_proplist* p);
  191. /** Returns a non-zero value if the key is valid. \since 3.0 */
  192. int pa_proplist_key_valid(const char *key);
  193. /** Append a new string entry to the property list, possibly
  194. * overwriting an already existing entry with the same key. An
  195. * internal copy of the data passed is made. Will accept only valid
  196. * UTF-8. \since 0.9.11 */
  197. int pa_proplist_sets(pa_proplist *p, const char *key, const char *value);
  198. /** Append a new string entry to the property list, possibly
  199. * overwriting an already existing entry with the same key. An
  200. * internal copy of the data passed is made. Will accept only valid
  201. * UTF-8. The string passed in must contain a '='. Left hand side of
  202. * the '=' is used as key name, the right hand side as string
  203. * data. \since 0.9.16 */
  204. int pa_proplist_setp(pa_proplist *p, const char *pair);
  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. The data can be passed as printf()-style format string with
  209. * arguments. \since 0.9.11 */
  210. int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) PA_GCC_PRINTF_ATTR(3,4);
  211. /** Append a new arbitrary data 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. \since 0.9.11 */
  214. int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nbytes);
  215. /** Return a string entry for the specified key. Will return NULL if
  216. * the data is not valid UTF-8. Will return a NUL-terminated string in
  217. * an internally allocated buffer. The caller should make a copy of
  218. * the data before accessing the property list again. \since 0.9.11 */
  219. const char *pa_proplist_gets(pa_proplist *p, const char *key);
  220. /** Store the value for the specified key in \a data. Will store a
  221. * NUL-terminated string for string entries. The \a data pointer returned will
  222. * point to an internally allocated buffer. The caller should make a
  223. * copy of the data before the property list is accessed again. \since
  224. * 0.9.11 */
  225. int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes);
  226. /** Update mode enum for pa_proplist_update(). \since 0.9.11 */
  227. typedef enum pa_update_mode {
  228. PA_UPDATE_SET
  229. /**< Replace the entire property list with the new one. Don't keep
  230. * any of the old data around. */,
  231. PA_UPDATE_MERGE
  232. /**< Merge new property list into the existing one, not replacing
  233. * any old entries if they share a common key with the new
  234. * property list. */,
  235. PA_UPDATE_REPLACE
  236. /**< Merge new property list into the existing one, replacing all
  237. * old entries that share a common key with the new property
  238. * list. */
  239. } pa_update_mode_t;
  240. /** \cond fulldocs */
  241. #define PA_UPDATE_SET PA_UPDATE_SET
  242. #define PA_UPDATE_MERGE PA_UPDATE_MERGE
  243. #define PA_UPDATE_REPLACE PA_UPDATE_REPLACE
  244. /** \endcond */
  245. /** Merge property list "other" into "p", adhering the merge mode as
  246. * specified in "mode". \since 0.9.11 */
  247. void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, const pa_proplist *other);
  248. /** Removes a single entry from the property list, identified be the
  249. * specified key name. \since 0.9.11 */
  250. int pa_proplist_unset(pa_proplist *p, const char *key);
  251. /** Similar to pa_proplist_unset() but takes an array of keys to
  252. * remove. The array should be terminated by a NULL pointer. Returns -1
  253. * on failure, otherwise the number of entries actually removed (which
  254. * might even be 0, if there were no matching entries to
  255. * remove). \since 0.9.11 */
  256. int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]);
  257. /** Iterate through the property list. The user should allocate a
  258. * state variable of type void* and initialize it with NULL. A pointer
  259. * to this variable should then be passed to pa_proplist_iterate()
  260. * which should be called in a loop until it returns NULL which
  261. * signifies EOL. The property list should not be modified during
  262. * iteration through the list -- with the exception of deleting the
  263. * current entry. On each invocation this function will return the
  264. * key string for the next entry. The keys in the property list do not
  265. * have any particular order. \since 0.9.11 */
  266. const char *pa_proplist_iterate(pa_proplist *p, void **state);
  267. /** Format the property list nicely as a human readable string. This
  268. * works very much like pa_proplist_to_string_sep() and uses a newline
  269. * as separator and appends one final one. Call pa_xfree() on the
  270. * result. \since 0.9.11 */
  271. char *pa_proplist_to_string(pa_proplist *p);
  272. /** Format the property list nicely as a human readable string and
  273. * choose the separator. Call pa_xfree() on the result. \since
  274. * 0.9.15 */
  275. char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep);
  276. /** Allocate a new property list and assign key/value from a human
  277. * readable string. \since 0.9.15 */
  278. pa_proplist *pa_proplist_from_string(const char *str);
  279. /** Returns 1 if an entry for the specified key exists in the
  280. * property list. \since 0.9.11 */
  281. int pa_proplist_contains(pa_proplist *p, const char *key);
  282. /** Remove all entries from the property list object. \since 0.9.11 */
  283. void pa_proplist_clear(pa_proplist *p);
  284. /** Allocate a new property list and copy over every single entry from
  285. * the specified list. \since 0.9.11 */
  286. pa_proplist* pa_proplist_copy(const pa_proplist *p);
  287. /** Return the number of entries in the property list. \since 0.9.15 */
  288. unsigned pa_proplist_size(pa_proplist *p);
  289. /** Returns 0 when the proplist is empty, positive otherwise \since 0.9.15 */
  290. int pa_proplist_isempty(pa_proplist *p);
  291. /** Return non-zero when a and b have the same keys and values.
  292. * \since 0.9.16 */
  293. int pa_proplist_equal(pa_proplist *a, pa_proplist *b);
  294. PA_C_DECL_END
  295. #endif