libspa-sys-0.8.0/.cargo_vcs_info.json0000644000000001500000000000100131230ustar { "git": { "sha1": "449bf53f5d5edc8d0be6c0c80bc19d882f712dd7" }, "path_in_vcs": "libspa-sys" }libspa-sys-0.8.0/Cargo.toml0000644000000027550000000000100111360ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "libspa-sys" version = "0.8.0" authors = [ "Tom Wagner ", ] links = "libspa-0.2" description = "Rust FFI bindings for libspa" homepage = "https://pipewire.org" documentation = "https://pipewire.pages.freedesktop.org/pipewire-rs/libspa_sys/" readme = "README.md" keywords = [ "ffi", "pipewire", "multimedia", "audio", "video", ] categories = [ "api-bindings", "multimedia", ] license = "MIT" repository = "https://gitlab.freedesktop.org/pipewire/pipewire-rs" [package.metadata.system-deps.libpipewire] name = "libpipewire-0.3" version = "0.3" [package.metadata.system-deps.libspa] name = "libspa-0.2" version = "0.2" [lib] doctest = false [dependencies] [build-dependencies.bindgen] version = "0.69" features = [ "experimental", "runtime", ] default-features = false [build-dependencies.cc] version = "1.0" [build-dependencies.system-deps] version = "6" [features] v0_3_65 = [] libspa-sys-0.8.0/Cargo.toml.orig000064400000000000000000000017231046102023000146110ustar 00000000000000[package] name = "libspa-sys" version = "0.8.0" authors = ["Tom Wagner "] edition = "2021" links = "libspa-0.2" categories = ["api-bindings", "multimedia"] description = "Rust FFI bindings for libspa" repository = "https://gitlab.freedesktop.org/pipewire/pipewire-rs" license = "MIT" readme = "README.md" homepage = "https://pipewire.org" documentation = "https://pipewire.pages.freedesktop.org/pipewire-rs/libspa_sys/" keywords = ["ffi", "pipewire", "multimedia", "audio", "video"] [dependencies] [build-dependencies] bindgen = { version = "0.69", default-features = false, features = ["experimental", "runtime"] } cc = "1.0" system-deps = "6" [package.metadata.system-deps] libspa = { name = "libspa-0.2", version = "0.2" } libpipewire = { name = "libpipewire-0.3", version = "0.3" } [lib] doctest = false # https://github.com/rust-lang/rust-bindgen/issues/1313 [features] v0_3_65 = []libspa-sys-0.8.0/LICENSE000064400000000000000000000021101046102023000127160ustar 00000000000000Copyright The pipewire-rs Contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. libspa-sys-0.8.0/README.md000064400000000000000000000012771046102023000132050ustar 00000000000000# libspa-sys [![](https://img.shields.io/crates/v/libspa-sys.svg)](https://crates.io/crates/libspa-sys) [![](https://docs.rs/libspa-sys/badge.svg)](https://docs.rs/libspa-sys) [Spa](https://pipewire.org) FFI bindings for Rust. These bindings are providing an unsafe API that can be used to interface with [libspa](https://pipewire.org). Generally they are meant to be used as the building block for higher-level abstractions like the [libspa safe bindings](https://crates.io/crates/libspa). The bindings are autogenerated using [rust-bindgen](https://github.com/rust-lang/rust-bindgen). ## Documentation See the [crate documentation](https://pipewire.pages.freedesktop.org/pipewire-rs/libspa_sys/).libspa-sys-0.8.0/build.rs000064400000000000000000000043431046102023000133700ustar 00000000000000// Copyright The pipewire-rs Contributors. // SPDX-License-Identifier: MIT use std::env; use std::path::PathBuf; fn main() { let libs = system_deps::Config::new() .probe() .expect("Cannot find libraries"); // Tell cargo to invalidate the built crate whenever the wrapper changes println!("cargo:rerun-if-changed=wrapper.h"); // Write bindings files to the $OUT_DIR/ directory. let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let builder = bindgen::builder() .header("wrapper.h") // Tell cargo to invalidate the built crate whenever any of the // included header files changed. .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) // Use `usize` for `size_t`. This behavior of bindgen changed because it is not // *technically* correct, but is the case in all architectures supported by Rust. .size_t_is_usize(true) .allowlist_function("spa_.*") .allowlist_type("spa_.*") .allowlist_var("SPA_.*") .prepend_enum_name(false) .derive_eq(true) // Create callable wrapper functions around SPAs `static inline` functions so they // can be called via FFI .wrap_static_fns(true) .wrap_static_fns_suffix("_libspa_rs") .wrap_static_fns_path(&out_path.join("static_fns")); let builder = libs .iter() .iter() .flat_map(|(_, lib)| lib.include_paths.iter()) .fold(builder, |builder, l| { let arg = format!("-I{}", l.to_string_lossy()); builder.clang_arg(arg) }); let bindings = builder.generate().expect("Unable to generate bindings"); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); const FILES: &[&str] = &["src/type-info.c"]; let cc_files = &[PathBuf::from(FILES[0]), out_path.join("static_fns.c")]; for file in FILES { println!("cargo:rerun-if-changed={file}"); } let mut cc = cc::Build::new(); cc.files(cc_files); cc.include(env!("CARGO_MANIFEST_DIR")); cc.includes(libs.all_include_paths()); #[cfg(feature = "v0_3_65")] cc.define("FEATURE_0_3_65", "1"); cc.compile("libspa-rs-reexports"); } libspa-sys-0.8.0/src/lib.rs000064400000000000000000000013531046102023000136240ustar 00000000000000// Copyright The pipewire-rs Contributors. // SPDX-License-Identifier: MIT #[allow(non_upper_case_globals)] #[allow(non_camel_case_types)] #[allow(non_snake_case)] #[allow(clippy::all)] /// bindgen-generated definitions mod bindings { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); } pub use bindings::*; // Manually defined symbols that are manually compiled into a C object file, as they need to be present at link-time. // // As SPA is a header-only library, global variables and functions are `static` / `static inline` // and we need to compile them into a C object ourselves. // // For functions, this is handled by bindgens "wrap_static_fns" feature. // // The rest is added in modules here. mod type_info; pub use type_info::*; libspa-sys-0.8.0/src/type-info.c000064400000000000000000000070711046102023000145710ustar 00000000000000#include #include // spa/utils const struct spa_type_info* libspa_rs_types = spa_types; const struct spa_type_info* libspa_rs_type_direction = spa_type_direction; const struct spa_type_info* libspa_rs_type_choice = spa_type_choice; // spa/monitor const struct spa_type_info* libspa_rs_type_device_event_id = spa_type_device_event_id; const struct spa_type_info* libspa_rs_type_device_event = spa_type_device_event; // spa/node const struct spa_type_info* libspa_rs_type_io = spa_type_io; const struct spa_type_info* libspa_rs_type_node_event_id = spa_type_node_event_id; const struct spa_type_info* libspa_rs_type_node_event = spa_type_node_event; const struct spa_type_info* libspa_rs_type_node_command_id = spa_type_node_command_id; const struct spa_type_info* libspa_rs_type_node_command = spa_type_node_command; // spa/buffer const struct spa_type_info* libspa_rs_type_data_type = spa_type_data_type; const struct spa_type_info* libspa_rs_type_meta_type = spa_type_meta_type; // spa/control const struct spa_type_info* libspa_rs_type_control = spa_type_control; // spa/param const struct spa_type_info* libspa_rs_type_param = spa_type_param; const struct spa_type_info* libspa_rs_type_prop_float_array = spa_type_prop_float_array; const struct spa_type_info* libspa_rs_type_prop_channel_map = spa_type_prop_channel_map; const struct spa_type_info* libspa_rs_type_prop_iec958_codec = spa_type_prop_iec958_codec; const struct spa_type_info* libspa_rs_type_param_bitorder = spa_type_param_bitorder; const struct spa_type_info* libspa_rs_type_props = spa_type_props; const struct spa_type_info* libspa_rs_type_prop_info = spa_type_prop_info; const struct spa_type_info* libspa_rs_type_param_meta = spa_type_param_meta; const struct spa_type_info* libspa_rs_type_param_io = spa_type_param_io; const struct spa_type_info* libspa_rs_type_media_type = spa_type_media_type; const struct spa_type_info* libspa_rs_type_media_subtype = spa_type_media_subtype; const struct spa_type_info* libspa_rs_type_format = spa_type_format; const struct spa_type_info* libspa_rs_type_param_buffers = spa_type_param_buffers; const struct spa_type_info* libspa_rs_type_param_availability = spa_type_param_availability; const struct spa_type_info* libspa_rs_type_param_profile = spa_type_param_profile; const struct spa_type_info* libspa_rs_type_param_port_config_mode = spa_type_param_port_config_mode; const struct spa_type_info* libspa_rs_type_param_port_config = spa_type_param_port_config; const struct spa_type_info* libspa_rs_type_param_route = spa_type_param_route; const struct spa_type_info* libspa_rs_type_profiler = spa_type_profiler; const struct spa_type_info* libspa_rs_type_param_latency = spa_type_param_latency; const struct spa_type_info* libspa_rs_type_param_process_latency = spa_type_param_process_latency; // spa/param/audio const struct spa_type_info* libspa_rs_type_audio_format = spa_type_audio_format; const struct spa_type_info* libspa_rs_type_audio_flags = spa_type_audio_flags; const struct spa_type_info* libspa_rs_type_audio_channel = spa_type_audio_channel; const struct spa_type_info* libspa_rs_type_audio_iec958_codec = spa_type_audio_iec958_codec; // spa/param/bluetooth const struct spa_type_info* libspa_rs_type_bluetooth_audio_codec = spa_type_bluetooth_audio_codec; // spa/param/video const struct spa_type_info* libspa_rs_type_video_format = spa_type_video_format; #ifdef FEATURE_0_3_65 const struct spa_type_info* libspa_rs_type_video_flags = spa_type_video_flags; const struct spa_type_info* libspa_rs_type_video_interlace_mode = spa_type_video_interlace_mode; #endif libspa-sys-0.8.0/src/type_info.rs000064400000000000000000000134611046102023000150550ustar 00000000000000use super::*; extern "C" { #[link_name = "libspa_rs_types"] pub static spa_types: *const spa_type_info; #[link_name = "libspa_rs_type_direction"] pub static spa_type_direction: *const spa_type_info; #[link_name = "libspa_rs_type_choice"] pub static spa_type_choice: *const spa_type_info; #[link_name = "libspa_rs_type_device_event_id"] pub static spa_type_device_event_id: *const spa_type_info; #[link_name = "libspa_rs_type_device_event"] pub static spa_type_device_event: *const spa_type_info; #[link_name = "libspa_rs_type_io"] pub static spa_type_io: *const spa_type_info; #[link_name = "libspa_rs_type_node_event_id"] pub static spa_type_node_event_id: *const spa_type_info; #[link_name = "libspa_rs_type_node_event"] pub static spa_type_node_event: *const spa_type_info; #[link_name = "libspa_rs_type_node_command_id"] pub static spa_type_node_command_id: *const spa_type_info; #[link_name = "libspa_rs_type_node_command"] pub static spa_type_node_command: *const spa_type_info; #[link_name = "libspa_rs_type_data_type"] pub static spa_type_data_type: *const spa_type_info; #[link_name = "libspa_rs_type_meta_type"] pub static spa_type_meta_type: *const spa_type_info; #[link_name = "libspa_rs_type_control"] pub static spa_type_control: *const spa_type_info; #[link_name = "libspa_rs_type_param"] pub static spa_type_param: *const spa_type_info; #[link_name = "libspa_rs_type_prop_float_array"] pub static spa_type_prop_float_array: *const spa_type_info; #[link_name = "libspa_rs_type_prop_channel_map"] pub static spa_type_prop_channel_map: *const spa_type_info; #[link_name = "libspa_rs_type_prop_iec958_codec"] pub static spa_type_prop_iec958_codec: *const spa_type_info; #[link_name = "libspa_rs_type_param_bitorder"] pub static spa_type_param_bitorder: *const spa_type_info; #[link_name = "libspa_rs_type_props"] pub static spa_type_props: *const spa_type_info; #[link_name = "libspa_rs_type_prop_info"] pub static spa_type_prop_info: *const spa_type_info; #[link_name = "libspa_rs_type_param_meta"] pub static spa_type_param_meta: *const spa_type_info; #[link_name = "libspa_rs_type_param_io"] pub static spa_type_param_io: *const spa_type_info; #[link_name = "libspa_rs_type_media_type"] pub static spa_type_media_type: *const spa_type_info; #[link_name = "libspa_rs_type_media_subtype"] pub static spa_type_media_subtype: *const spa_type_info; #[link_name = "libspa_rs_type_format"] pub static spa_type_format: *const spa_type_info; #[link_name = "libspa_rs_type_param_buffers"] pub static spa_type_param_buffers: *const spa_type_info; #[link_name = "libspa_rs_type_param_availability"] pub static spa_type_param_availability: *const spa_type_info; #[link_name = "libspa_rs_type_param_profile"] pub static spa_type_param_profile: *const spa_type_info; #[link_name = "libspa_rs_type_param_port_config_mode"] pub static spa_type_param_port_config_mode: *const spa_type_info; #[link_name = "libspa_rs_type_param_port_config"] pub static spa_type_param_port_config: *const spa_type_info; #[link_name = "libspa_rs_type_param_route"] pub static spa_type_param_route: *const spa_type_info; #[link_name = "libspa_rs_type_profiler"] pub static spa_type_profiler: *const spa_type_info; #[link_name = "libspa_rs_type_param_latency"] pub static spa_type_param_latency: *const spa_type_info; #[link_name = "libspa_rs_type_param_process_latency"] pub static spa_type_param_process_latency: *const spa_type_info; #[link_name = "libspa_rs_type_audio_format"] pub static spa_type_audio_format: *const spa_type_info; #[link_name = "libspa_rs_type_audio_flags"] pub static spa_type_audio_flags: *const spa_type_info; #[link_name = "libspa_rs_type_audio_channel"] pub static spa_type_audio_channel: *const spa_type_info; #[link_name = "libspa_rs_type_audio_iec958_codec"] pub static spa_type_audio_iec958_codec: *const spa_type_info; #[link_name = "libspa_rs_type_bluetooth_audio_codec"] pub static spa_type_bluetooth_audio_codec: *const spa_type_info; #[link_name = "libspa_rs_type_video_format"] pub static spa_type_video_format: *const spa_type_info; #[cfg(feature = "v0_3_65")] #[link_name = "libspa_rs_type_video_flags"] pub static spa_type_video_flags: *const spa_type_info; #[cfg(feature = "v0_3_65")] #[link_name = "libspa_rs_type_video_interlace_mode"] pub static spa_type_video_interlace_mode: *const spa_type_info; } #[cfg(test)] mod test { use crate::{spa_type_media_type, SPA_MEDIA_TYPE_audio}; use std::ffi; #[test] fn test_libspa_rs_debug_type_find() { unsafe { let type_info = super::spa_debug_type_find(spa_type_media_type, SPA_MEDIA_TYPE_audio); assert_eq!( ffi::CStr::from_ptr((*type_info).name), ffi::CString::new("Spa:Enum:MediaType:audio") .unwrap() .as_ref() ); } } #[test] fn test_libspa_rs_debug_type_find_name() { unsafe { let name = super::spa_debug_type_find_name(spa_type_media_type, SPA_MEDIA_TYPE_audio); assert_eq!( ffi::CStr::from_ptr(name), ffi::CString::new("Spa:Enum:MediaType:audio") .unwrap() .as_ref() ); } } #[test] fn test_libspa_rs_debug_type_find_short_name() { unsafe { let name = super::spa_debug_type_find_short_name(spa_type_media_type, SPA_MEDIA_TYPE_audio); assert_eq!( ffi::CStr::from_ptr(name), ffi::CString::new("audio").unwrap().as_ref() ); } } } libspa-sys-0.8.0/wrapper.h000064400000000000000000000057221046102023000135560ustar 00000000000000#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if PW_CHECK_VERSION(0,3,7) #include #endif #if PW_CHECK_VERSION(0,3,20) #include #endif #include #include #include #include #include #include #include #include #include #include #if PW_CHECK_VERSION(0,3,29) #include #endif #include #include #include #include #if PW_CHECK_VERSION(0,3,37) #include #endif #include #include #if PW_CHECK_VERSION(0,3,34) #include #endif #include #include #include #if PW_CHECK_VERSION(0,3,25) #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if PW_CHECK_VERSION(0,3,26) #include #endif #include #include #include #if PW_CHECK_VERSION(0,3,35) #include #endif #include #include #if PW_CHECK_VERSION(0,3,32) #include #endif #if PW_CHECK_VERSION(0,3,29) #include #endif #include #include #include #if PW_CHECK_VERSION(0,3,18) #include #endif #include #include #include #include #include #if PW_CHECK_VERSION(0,3,28) #include #endif #include #include