libpulse_sys/
proplist.rs

1// Copyright 2017 Lyndon Brown
2//
3// This file is part of the PulseAudio Rust language linking library.
4//
5// Licensed under the MIT license or the Apache license (version 2.0), at your option. You may not
6// copy, modify, or distribute this file except in compliance with said license. You can find copies
7// of these licenses either in the LICENSE-MIT and LICENSE-APACHE files, or alternatively at
8// <http://opensource.org/licenses/MIT> and <http://www.apache.org/licenses/LICENSE-2.0>
9// respectively.
10//
11// Portions of documentation are copied from the LGPL 2.1+ licensed PulseAudio C headers on a
12// fair-use basis, as discussed in the overall project readme (available in the git repository).
13
14//! Property list constants and functions.
15
16use std::os::raw::{c_char, c_void};
17use num_derive::{FromPrimitive, ToPrimitive};
18
19/// For streams: localized media name, formatted as UTF-8. E.g. "Guns'N'Roses: Civil War".
20pub const PA_PROP_MEDIA_NAME: &str = "media.name";
21
22/// For streams: localized media title if applicable, formatted as UTF-8. E.g. "Civil War".
23pub const PA_PROP_MEDIA_TITLE: &str = "media.title";
24
25/// For streams: localized media artist if applicable, formatted as UTF-8. E.g. "Guns'N'Roses".
26pub const PA_PROP_MEDIA_ARTIST: &str = "media.artist";
27
28/// For streams: localized media copyright string if applicable, formatted as UTF-8.
29/// E.g. "Evil Record Corp.".
30pub const PA_PROP_MEDIA_COPYRIGHT: &str = "media.copyright";
31
32/// For streams: localized media generator software string if applicable, formatted as UTF-8.
33/// E.g. "Foocrop AudioFrobnicator".
34pub const PA_PROP_MEDIA_SOFTWARE: &str = "media.software";
35
36/// For streams: media language if applicable, in standard POSIX format. E.g. "de_DE".
37pub const PA_PROP_MEDIA_LANGUAGE: &str = "media.language";
38
39/// For streams: source filename if applicable, in URI format or local path.
40/// E.g. "/home/lennart/music/foobar.ogg".
41pub const PA_PROP_MEDIA_FILENAME: &str = "media.filename";
42
43/// For streams: icon for the media. A binary blob containing PNG image data.
44pub const PA_PROP_MEDIA_ICON: &str = "media.icon";
45
46/// For streams: an XDG icon name for the media. E.g. "audio-x-mp3".
47pub const PA_PROP_MEDIA_ICON_NAME: &str = "media.icon_name";
48
49/// For streams: logic role of this media.
50/// One of the strings "video", "music", "game", "event", "phone", "animation", "production",
51/// "a11y", "test".
52pub const PA_PROP_MEDIA_ROLE: &str = "media.role";
53
54/// For streams: the name of a filter that is desired, e.g. "echo-cancel" or "equalizer-sink".
55/// PulseAudio may choose to not apply the filter if it does not make sense (for example, applying
56/// echo-cancellation on a Bluetooth headset probably does not make sense.
57pub const PA_PROP_FILTER_WANT: &str = "filter.want";
58
59/// For streams: the name of a filter that is desired, e.g. "echo-cancel" or "equalizer-sink".
60/// Differs from PA_PROP_FILTER_WANT in that it forces PulseAudio to apply the filter, regardless of
61/// whether PulseAudio thinks it makes sense to do so or not. If this is set, PA_PROP_FILTER_WANT
62/// is ignored. In other words, you almost certainly do not want to use this.
63pub const PA_PROP_FILTER_APPLY: &str = "filter.apply";
64
65/// For streams: the name of a filter that should specifically be suppressed (i.e. overrides
66/// PA_PROP_FILTER_WANT). Useful for the times that PA_PROP_FILTER_WANT is automatically added (e.g.
67/// echo-cancellation for phone streams when $VOIP_APP does its own, internal AEC).
68pub const PA_PROP_FILTER_SUPPRESS: &str = "filter.suppress";
69
70/// For event sound streams: XDG event sound name. e.g. "message-new-email" (Event sound streams are
71/// those with media.role set to "event").
72pub const PA_PROP_EVENT_ID: &str = "event.id";
73
74/// For event sound streams: localized human readable one-line description of the event, formatted
75/// as UTF-8. E.g. "Email from lennart\@example.com received."
76pub const PA_PROP_EVENT_DESCRIPTION: &str = "event.description";
77
78/// For event sound streams: absolute horizontal mouse position on the screen if the event sound was
79/// triggered by a mouse click, integer formatted as text string. E.g. "865".
80pub const PA_PROP_EVENT_MOUSE_X: &str = "event.mouse.x";
81
82/// For event sound streams: absolute vertical mouse position on the screen if the event sound was
83/// triggered by a mouse click, integer formatted as text string. E.g. "432".
84pub const PA_PROP_EVENT_MOUSE_Y: &str = "event.mouse.y";
85
86/// For event sound streams: relative horizontal mouse position on the screen if the event sound was
87/// triggered by a mouse click, float formatted as text string, ranging from 0.0 (left side of the
88/// screen) to 1.0 (right side of the screen). E.g. "0.65".
89pub const PA_PROP_EVENT_MOUSE_HPOS: &str = "event.mouse.hpos";
90
91/// For event sound streams: relative vertical mouse position on the screen if the event sound was
92/// triggered by a mouse click, float formatted as text string, ranging from 0.0 (top of the screen)
93/// to 1.0 (bottom of the screen). E.g. "0.43".
94pub const PA_PROP_EVENT_MOUSE_VPOS: &str = "event.mouse.vpos";
95
96/// For event sound streams: mouse button that triggered the event if applicable, integer formatted
97/// as string with 0=left, 1=middle, 2=right. E.g. "0".
98pub const PA_PROP_EVENT_MOUSE_BUTTON: &str = "event.mouse.button";
99
100/// For streams that belong to a window on the screen: localized window title.
101/// E.g. "Totem Music Player".
102pub const PA_PROP_WINDOW_NAME: &str = "window.name";
103
104/// For streams that belong to a window on the screen: a textual id for identifying a window
105/// logically. E.g. "org.gnome.Totem.MainWindow".
106pub const PA_PROP_WINDOW_ID: &str = "window.id";
107
108/// For streams that belong to a window on the screen: window icon. A binary blob containing PNG
109/// image data.
110pub const PA_PROP_WINDOW_ICON: &str = "window.icon";
111
112/// For streams that belong to a window on the screen: an XDG icon name for the window. E.g.
113/// "totem".
114pub const PA_PROP_WINDOW_ICON_NAME: &str = "window.icon_name";
115
116/// For streams that belong to a window on the screen: absolute horizontal window position on the
117/// screen, integer formatted as text string. E.g. "865".
118pub const PA_PROP_WINDOW_X: &str = "window.x";
119
120/// For streams that belong to a window on the screen: absolute vertical window position on the
121/// screen, integer formatted as text string. E.g. "343".
122pub const PA_PROP_WINDOW_Y: &str = "window.y";
123
124/// For streams that belong to a window on the screen: window width on the screen, integer
125/// formatted as text string. e.g. "365".
126pub const PA_PROP_WINDOW_WIDTH: &str = "window.width";
127
128/// For streams that belong to a window on the screen: window height on the screen, integer
129/// formatted as text string. E.g. "643".
130pub const PA_PROP_WINDOW_HEIGHT: &str = "window.height";
131
132/// For streams that belong to a window on the screen: relative position of the window center on the
133/// screen, float formatted as text string, ranging from 0.0 (left side of the screen) to 1.0 (right
134/// side of the screen). E.g. "0.65".
135pub const PA_PROP_WINDOW_HPOS: &str = "window.hpos";
136
137/// For streams that belong to a window on the screen: relative position of the window center on the
138/// screen, float formatted as text string, ranging from 0.0 (top of the screen) to 1.0 (bottom of
139/// the screen). E.g. "0.43".
140pub const PA_PROP_WINDOW_VPOS: &str = "window.vpos";
141
142/// For streams that belong to a window on the screen: if the windowing system supports multiple
143/// desktops, a comma separated list of indexes of the desktops this window is visible on. If this
144/// property is an empty string, it is visible on all desktops (i.e. ‘sticky’). The first desktop is
145/// zero. E.g. "0,2,3".
146pub const PA_PROP_WINDOW_DESKTOP: &str = "window.desktop";
147
148/// For streams that belong to an X11 window on the screen: the X11 display string. E.g. ":0.0".
149pub const PA_PROP_WINDOW_X11_DISPLAY: &str = "window.x11.display";
150
151/// For streams that belong to an X11 window on the screen: the X11 screen the window is on, an
152/// integer formatted as string. E.g. "0".
153pub const PA_PROP_WINDOW_X11_SCREEN: &str = "window.x11.screen";
154
155/// For streams that belong to an X11 window on the screen: the X11 monitor the window is on, an
156/// integer formatted as string. E.g. "0".
157pub const PA_PROP_WINDOW_X11_MONITOR: &str = "window.x11.monitor";
158
159/// For streams that belong to an X11 window on the screen: the window XID, an integer formatted as
160/// string. E.g. "25632".
161pub const PA_PROP_WINDOW_X11_XID: &str = "window.x11.xid";
162
163/// For clients/streams: localized human readable application name. E.g. "Totem Music Player".
164pub const PA_PROP_APPLICATION_NAME: &str = "application.name";
165
166/// For clients/streams: a textual id for identifying an application logically.
167/// E.g. "org.gnome.Totem".
168pub const PA_PROP_APPLICATION_ID: &str = "application.id";
169
170/// For clients/streams: a version string, e.g. "0.6.88".
171pub const PA_PROP_APPLICATION_VERSION: &str = "application.version";
172
173/// For clients/streams: application icon. A binary blob containing PNG image data.
174pub const PA_PROP_APPLICATION_ICON: &str = "application.icon";
175
176/// For clients/streams: an XDG icon name for the application. E.g. "totem".
177pub const PA_PROP_APPLICATION_ICON_NAME: &str = "application.icon_name";
178
179/// For clients/streams: application language if applicable, in standard POSIX format. E.g. "de_DE".
180pub const PA_PROP_APPLICATION_LANGUAGE: &str = "application.language";
181
182/// For clients/streams on UNIX: application process PID, an integer formatted as string. E.g.
183/// "4711".
184pub const PA_PROP_APPLICATION_PROCESS_ID: &str = "application.process.id";
185
186/// For clients/streams: application process name. E.g. "totem".
187pub const PA_PROP_APPLICATION_PROCESS_BINARY: &str = "application.process.binary";
188
189/// For clients/streams: application user name. E.g. "lennart".
190pub const PA_PROP_APPLICATION_PROCESS_USER: &str = "application.process.user";
191
192/// For clients/streams: host name the application runs on. E.g. "omega".
193pub const PA_PROP_APPLICATION_PROCESS_HOST: &str = "application.process.host";
194
195/// For clients/streams: the D-Bus host id the application runs on.
196/// E.g. "543679e7b01393ed3e3e650047d78f6e".
197pub const PA_PROP_APPLICATION_PROCESS_MACHINE_ID: &str = "application.process.machine_id";
198
199/// For clients/streams: an id for the login session the application runs in. On Unix the value of
200/// $XDG_SESSION_ID. E.g. "5".
201pub const PA_PROP_APPLICATION_PROCESS_SESSION_ID: &str = "application.process.session_id";
202
203/// For devices: device string in the underlying audio layer’s format. E.g. "surround51:0".
204pub const PA_PROP_DEVICE_STRING: &str = "device.string";
205
206/// For devices: API this device is accessed with. E.g. "alsa".
207pub const PA_PROP_DEVICE_API: &str = "device.api";
208
209/// For devices: localized human readable device one-line description.
210/// E.g. "Foobar Industries USB Headset 2000+ Ultra".
211pub const PA_PROP_DEVICE_DESCRIPTION: &str = "device.description";
212
213/// For devices: bus path to the device in the OS’ format.
214/// E.g. "/sys/bus/pci/devices/0000:00:1f.2".
215pub const PA_PROP_DEVICE_BUS_PATH: &str = "device.bus_path";
216
217/// For devices: serial number if applicable. E.g. "4711-0815-1234".
218pub const PA_PROP_DEVICE_SERIAL: &str = "device.serial";
219
220/// For devices: vendor ID if applicable. E.g. 1274.
221pub const PA_PROP_DEVICE_VENDOR_ID: &str = "device.vendor.id";
222
223/// For devices: vendor name if applicable. E.g. "Foocorp Heavy Industries".
224pub const PA_PROP_DEVICE_VENDOR_NAME: &str = "device.vendor.name";
225
226/// For devices: product ID if applicable. E.g. 4565.
227pub const PA_PROP_DEVICE_PRODUCT_ID: &str = "device.product.id";
228
229/// For devices: product name if applicable. E.g. "SuperSpeakers 2000 Pro".
230pub const PA_PROP_DEVICE_PRODUCT_NAME: &str = "device.product.name";
231
232/// For devices: device class. One of "sound", "modem", "monitor", "filter".
233pub const PA_PROP_DEVICE_CLASS: &str = "device.class";
234
235/// For devices: form factor if applicable. One of "internal", "speaker", "handset", "tv", "webcam",
236/// "microphone", "headset", "headphone", "hands-free", "car", "hifi", "computer", "portable".
237pub const PA_PROP_DEVICE_FORM_FACTOR: &str = "device.form_factor";
238
239/// For devices: bus of the device if applicable. One of "isa", "pci", "usb", "firewire",
240/// "bluetooth".
241pub const PA_PROP_DEVICE_BUS: &str = "device.bus";
242
243/// For devices: icon for the device. A binary blob containing PNG image data.
244pub const PA_PROP_DEVICE_ICON: &str = "device.icon";
245
246/// For devices: an XDG icon name for the device. E.g. "sound-card-speakers-usb".
247pub const PA_PROP_DEVICE_ICON_NAME: &str = "device.icon_name";
248
249/// For devices: access mode of the device if applicable. One of "mmap", "mmap_rewrite", "serial".
250pub const PA_PROP_DEVICE_ACCESS_MODE: &str = "device.access_mode";
251
252/// For filter devices: master device id if applicable.
253pub const PA_PROP_DEVICE_MASTER_DEVICE: &str = "device.master_device";
254
255/// For devices: buffer size in bytes, integer formatted as string.
256pub const PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE: &str = "device.buffering.buffer_size";
257
258/// For devices: fragment size in bytes, integer formatted as string.
259pub const PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE: &str = "device.buffering.fragment_size";
260
261/// For devices: profile identifier for the profile this devices is in.
262/// E.g. "analog-stereo", "analog-surround-40", "iec958-stereo", ...
263pub const PA_PROP_DEVICE_PROFILE_NAME: &str = "device.profile.name";
264
265/// For devices: intended use. A space separated list of roles (see PA_PROP_MEDIA_ROLE) this device
266/// is particularly well suited for, due to latency, quality or form factor.
267pub const PA_PROP_DEVICE_INTENDED_ROLES: &str = "device.intended_roles";
268
269/// For devices: human readable one-line description of the profile this device is in. E.g.
270/// "Analog Stereo", ...
271pub const PA_PROP_DEVICE_PROFILE_DESCRIPTION: &str = "device.profile.description";
272
273/// For modules: the author’s name, formatted as UTF-8 string. E.g. "Lennart Poettering".
274pub const PA_PROP_MODULE_AUTHOR: &str = "module.author";
275
276/// For modules: a human readable one-line description of the module’s purpose formatted as UTF-8.
277/// E.g. "Frobnicate sounds with a flux compensator".
278pub const PA_PROP_MODULE_DESCRIPTION: &str = "module.description";
279
280/// For modules: a human readable usage description of the module’s arguments formatted as UTF-8.
281pub const PA_PROP_MODULE_USAGE: &str = "module.usage";
282
283/// For modules: a version string for the module. E.g. "0.9.15".
284pub const PA_PROP_MODULE_VERSION: &str = "module.version";
285
286/// For PCM formats: the sample format used as returned by `pa_sample_format_to_string`.
287pub const PA_PROP_FORMAT_SAMPLE_FORMAT: &str = "format.sample_format";
288
289/// For all formats: the sample rate (unsigned integer).
290pub const PA_PROP_FORMAT_RATE: &str = "format.rate";
291
292/// For all formats: the number of channels (unsigned integer).
293pub const PA_PROP_FORMAT_CHANNELS: &str = "format.channels";
294
295/// For PCM formats: the channel map of the stream as returned by `pa_channel_map_snprint`.
296pub const PA_PROP_FORMAT_CHANNEL_MAP: &str = "format.channel_map";
297
298/// For context: whether to forcefully disable data transfer via POSIX or memfd shared memory.
299/// This property overrides any other client configuration which would otherwise enable SHM
300/// communication channels.
301//TODO: enable this feature gate once the passing of `--cfg doc` to dependencies is fixed (https://github.com/rust-lang/cargo/issues/8811)
302//#[cfg(any(doc, feature = "pa_v15"))]
303#[cfg_attr(docsrs, doc(cfg(feature = "pa_v15")))]
304pub const PA_PROP_CONTEXT_FORCE_DISABLE_SHM: &str = "context.force.disable.shm";
305
306/// For a bluez device: the currently selected codec name.
307//TODO: enable this feature gate once the passing of `--cfg doc` to dependencies is fixed (https://github.com/rust-lang/cargo/issues/8811)
308//#[cfg(any(doc, feature = "pa_v15"))]
309#[cfg_attr(docsrs, doc(cfg(feature = "pa_v15")))]
310pub const PA_PROP_BLUETOOTH_CODEC: &str = "bluetooth.codec";
311
312/// A property list object. Basically a dictionary with ASCII strings as keys and arbitrary data as
313/// values.
314#[repr(C)] pub struct pa_proplist { _private: [u8; 0] }
315
316/// Update mode.
317#[repr(C)]
318#[derive(Debug, Copy, Clone, PartialEq, Eq)]
319#[derive(FromPrimitive, ToPrimitive)]
320pub enum pa_update_mode_t {
321    /// Replace the entire property list with the new one. Don’t keep any of the old data around.
322    Set,
323
324    /// Merge new property list into the existing one, not replacing any old entries if they share a
325    /// common key with the new property list.
326    Merge,
327
328    /// Merge new property list into the existing one, replacing all old entries that share a common
329    /// key with the new property list.
330    Replace,
331}
332
333pub const PA_UPDATE_SET:     pa_update_mode_t = pa_update_mode_t::Set;
334pub const PA_UPDATE_MERGE:   pa_update_mode_t = pa_update_mode_t::Merge;
335pub const PA_UPDATE_REPLACE: pa_update_mode_t = pa_update_mode_t::Replace;
336
337#[rustfmt::skip]
338#[link(name = "pulse")]
339extern "C" {
340    pub fn pa_proplist_new() -> *mut pa_proplist;
341    pub fn pa_proplist_free(p: *mut pa_proplist);
342    pub fn pa_proplist_key_valid(key: *const c_char) -> i32;
343    pub fn pa_proplist_sets(p: *mut pa_proplist, key: *const c_char, value: *const c_char) -> i32;
344    pub fn pa_proplist_setp(p: *mut pa_proplist, pair: *const c_char) -> i32;
345    pub fn pa_proplist_setf(p: *mut pa_proplist, key: *const c_char, format: *const c_char, ...) -> i32;
346    pub fn pa_proplist_set(p: *mut pa_proplist, key: *const c_char, data: *const c_void, nbytes: usize) -> i32;
347    pub fn pa_proplist_gets(p: *const pa_proplist, key: *const c_char) -> *const c_char;
348    pub fn pa_proplist_get(p: *const pa_proplist, key: *const c_char, data: *mut *const c_void, nbytes: *mut usize) -> i32;
349    pub fn pa_proplist_update(p: *mut pa_proplist, mode: pa_update_mode_t, other: *const pa_proplist);
350    pub fn pa_proplist_unset(p: *mut pa_proplist, key: *const c_char) -> i32;
351    pub fn pa_proplist_unset_many(p: *mut pa_proplist, keys: *const *const c_char) -> i32;
352    pub fn pa_proplist_iterate(p: *const pa_proplist, state: *mut *mut c_void) -> *const c_char;
353    pub fn pa_proplist_to_string(p: *const pa_proplist) -> *mut c_char;
354    pub fn pa_proplist_to_string_sep(p: *const pa_proplist, sep: *const c_char) -> *mut c_char;
355    pub fn pa_proplist_from_string(s: *const c_char) -> *mut pa_proplist;
356    pub fn pa_proplist_contains(p: *const pa_proplist, key: *const c_char) -> i32;
357    pub fn pa_proplist_clear(p: *mut pa_proplist);
358    pub fn pa_proplist_copy(p: *const pa_proplist) -> *mut pa_proplist;
359    pub fn pa_proplist_size(p: *const pa_proplist) -> u32;
360    pub fn pa_proplist_isempty(p: *const pa_proplist) -> i32;
361    pub fn pa_proplist_equal(a: *const pa_proplist, b: *const pa_proplist) -> i32;
362}