diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5314aa8a3..63bfea992 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -142,7 +142,7 @@ trigger: stage: container-base variables: FDO_DISTRIBUTION_PACKAGES: >- - build-essential cmake curl python3-setuptools libglib2.0-dev libxml2-dev + build-essential cmake curl glslc python3-setuptools libglib2.0-dev libxml2-dev libdrm-dev libegl1-mesa-dev libgl1-mesa-dev libgbm-dev libgles2-mesa-dev libgl1-mesa-dri libegl-dev libgl-dev libgles-dev libglx-dev libssl-dev git wget ca-certificates ninja-build python3-pip flex bison @@ -151,13 +151,13 @@ trigger: libgraphene-1.0-dev libjpeg-dev libwayland-dev wayland-protocols python3-gi libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libswscale-dev yasm libx264-dev libfontconfig-dev libfreetype-dev - libxkbcommon-dev libxi-dev libxcb-render0-dev libxcb-shm0-dev + libxkbcommon-dev libxkbcommon-x11-dev libxi-dev libxcb-render0-dev libxcb-shm0-dev libxcb1-dev libxext-dev libxrender-dev libxrandr-dev libxcursor-dev libxdamage-dev libxfixes-dev libxinerama-dev libgudev-1.0-dev libpango1.0-dev libcairo2-dev libjson-glib-dev libgdk-pixbuf-2.0-dev libtiff-dev libpng-dev libjpeg-dev libepoxy-dev libsass-dev sassc libcsound64-dev llvm clang nasm libsodium-dev libwebp-dev - libflac-dev libmysofa-dev libgtk-4-dev libdav1d-dev libclang-dev + libflac-dev libmysofa-dev libgtk-4-dev libdav1d-dev libclang-dev libvulkan-dev FDO_DISTRIBUTION_EXEC: >- bash ci/install-gst.sh && bash ci/install-vvdec.sh && diff --git a/Cargo.lock b/Cargo.lock index 565cb3352..4971a8fcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,6 +60,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" +[[package]] +name = "ash" +version = "0.38.0+1.3.281" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" +dependencies = [ + "libloading", +] + [[package]] name = "async-channel" version = "2.5.0" @@ -535,6 +544,9 @@ dependencies = [ "gstreamer-rtsp-server", "gstreamer-sdp", "gstreamer-video", + "gstreamer-vulkan", + "gstreamer-vulkan-wayland", + "gstreamer-vulkan-xcb", "image", "memfd", "memmap2", @@ -1611,6 +1623,86 @@ dependencies = [ "tempfile", ] +[[package]] +name = "gstreamer-vulkan" +version = "0.23.0" +dependencies = [ + "gir-format-check", + "glib", + "gstreamer", + "gstreamer-base", + "gstreamer-video", + "gstreamer-vulkan-sys", + "libc", + "once_cell", + "serde", + "serde_json", +] + +[[package]] +name = "gstreamer-vulkan-sys" +version = "0.23.0" +dependencies = [ + "ash", + "glib-sys", + "gobject-sys", + "gstreamer-base-sys", + "gstreamer-sys", + "gstreamer-video-sys", + "libc", + "shell-words", + "system-deps", + "tempfile", +] + +[[package]] +name = "gstreamer-vulkan-wayland" +version = "0.23.0" +dependencies = [ + "gir-format-check", + "glib", + "gstreamer", + "gstreamer-vulkan", + "gstreamer-vulkan-wayland-sys", + "libc", +] + +[[package]] +name = "gstreamer-vulkan-wayland-sys" +version = "0.23.0" +dependencies = [ + "glib-sys", + "gstreamer-vulkan-sys", + "libc", + "shell-words", + "system-deps", + "tempfile", +] + +[[package]] +name = "gstreamer-vulkan-xcb" +version = "0.23.0" +dependencies = [ + "gir-format-check", + "glib", + "gstreamer", + "gstreamer-vulkan", + "gstreamer-vulkan-xcb-sys", + "libc", +] + +[[package]] +name = "gstreamer-vulkan-xcb-sys" +version = "0.23.0" +dependencies = [ + "glib-sys", + "gstreamer-vulkan-sys", + "libc", + "shell-words", + "system-deps", + "tempfile", +] + [[package]] name = "gstreamer-webrtc" version = "0.25.0" diff --git a/Cargo.toml b/Cargo.toml index 2b467127f..e8338b17d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,6 +75,9 @@ members = [ "gstreamer-sdp/sys", "gstreamer-tag/sys", "gstreamer-video/sys", + "gstreamer-vulkan/sys", + "gstreamer-vulkan/wayland/sys", + "gstreamer-vulkan/xcb/sys", "gstreamer-webrtc/sys", "gstreamer-allocators/sys", "gstreamer", @@ -103,6 +106,9 @@ members = [ "gstreamer-tag", "gstreamer-validate", "gstreamer-video", + "gstreamer-vulkan", + "gstreamer-vulkan/wayland", + "gstreamer-vulkan/xcb", "gstreamer-webrtc", "gstreamer-allocators", "gstreamer-utils", @@ -157,6 +163,9 @@ gstreamer-sys = { path = "./gstreamer/sys"} gstreamer-validate-sys = { path = "./gstreamer-validate/sys" } gstreamer-video-sys = { path = "./gstreamer-video/sys"} gstreamer-webrtc-sys = { path = "./gstreamer-webrtc/sys" } +gstreamer-vulkan-sys = { path = "./gstreamer-vulkan/sys"} +gstreamer-vulkan-wayland-sys = { path = "./gstreamer-vulkan/wayland/sys"} +gstreamer-vulkan-xcb-sys = { path = "./gstreamer-vulkan/xcb/sys"} ges = { package = "gstreamer-editing-services", path = "./gstreamer-editing-services" } gst = { package = "gstreamer", path = "./gstreamer" } gst-allocators = { package = "gstreamer-allocators", path = "./gstreamer-allocators" } @@ -177,3 +186,6 @@ gst-rtsp = { package = "gstreamer-rtsp", path = "./gstreamer-rtsp" } gst-rtsp-server = { package = "gstreamer-rtsp-server", path = "./gstreamer-rtsp-server" } gst-sdp = { package = "gstreamer-sdp", path = "./gstreamer-sdp" } gst-video = { package = "gstreamer-video", path = "./gstreamer-video" } +gst-vulkan = { package = "gstreamer-vulkan", path = "./gstreamer-vulkan" } +gst-vulkan-wayland = { package = "gstreamer-vulkan-wayland", path = "./gstreamer-vulkan/wayland" } +gst-vulkan-xcb = { package = "gstreamer-vulkan-xcb", path = "./gstreamer-vulkan/xcb" } diff --git a/ci/run-cargo-test.sh b/ci/run-cargo-test.sh index d34dda4d2..1809a78bf 100755 --- a/ci/run-cargo-test.sh +++ b/ci/run-cargo-test.sh @@ -11,7 +11,7 @@ CARGO_NEXTEST_FLAGS="--profile=ci --no-tests=pass" parent="${CI_PROJECT_DIR:-$(pwd)}" -for crate in gstreamer* gstreamer-gl/{egl,wayland,x11}; do +for crate in gstreamer* gstreamer-gl/{egl,wayland,x11} gstreamer-vulkan/{wayland,xcb}; do if [[ "$crate" == gstreamer-d3d12* ]]; then echo "Skipping $crate" continue diff --git a/ci/run-sys-cargo-test.sh b/ci/run-sys-cargo-test.sh index 5d844e5e5..ed516ec4e 100755 --- a/ci/run-sys-cargo-test.sh +++ b/ci/run-sys-cargo-test.sh @@ -11,7 +11,7 @@ CARGO_NEXTEST_FLAGS="--profile=ci --no-tests=pass" parent="${CI_PROJECT_DIR:-$(pwd)}" -for crate in gstreamer*/sys gstreamer-gl/*/sys; do +for crate in gstreamer*/sys gstreamer-gl/*/sys gstreamer-vulkan/*/sys; do if [[ "$crate" == gstreamer-d3d12* ]]; then echo "Skipping $crate" continue @@ -48,6 +48,9 @@ for crate in gstreamer/sys \ gstreamer-tag/sys \ gstreamer-validate/sys \ gstreamer-video/sys \ + gstreamer-vulkan/sys \ + gstreamer-vulkan/wayland/sys \ + gstreamer-vulkan/xcb/sys \ gstreamer-webrtc/sys; do echo "Testing $crate with --all-features)" RUST_BACKTRACE=1 cargo nextest run $CARGO_NEXTEST_FLAGS $CARGO_FLAGS --locked --manifest-path $crate/Cargo.toml --all-features diff --git a/gstreamer-vulkan/CHANGELOG.md b/gstreamer-vulkan/CHANGELOG.md new file mode 120000 index 000000000..670919a56 --- /dev/null +++ b/gstreamer-vulkan/CHANGELOG.md @@ -0,0 +1 @@ +../gstreamer/CHANGELOG.md \ No newline at end of file diff --git a/gstreamer-vulkan/COPYRIGHT b/gstreamer-vulkan/COPYRIGHT new file mode 120000 index 000000000..dc5f40a22 --- /dev/null +++ b/gstreamer-vulkan/COPYRIGHT @@ -0,0 +1 @@ +../COPYRIGHT \ No newline at end of file diff --git a/gstreamer-vulkan/Cargo.toml b/gstreamer-vulkan/Cargo.toml new file mode 100644 index 000000000..5e168b5c1 --- /dev/null +++ b/gstreamer-vulkan/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "gstreamer-vulkan" +authors = ["Matthew Waters "] +description = "Rust bindings for GStreamer Vulkan library" +license = "MIT OR Apache-2.0" +readme = "README.md" +documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_vulkan/" +keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"] +version.workspace = true +categories.workspace = true +repository.workspace = true +homepage.workspace = true +edition.workspace = true +rust-version.workspace = true + +[dependencies] +libc = "0.2" +ffi = { package = "gstreamer-vulkan-sys", path = "sys" } +glib.workspace = true +gst.workspace = true +gst-base.workspace = true +gst-video.workspace = true +serde = { version = "1.0", optional = true } +once_cell = "1" + +[dev-dependencies] +gir-format-check = "0.1" +serde_json = "1.0" + +[features] +default = ["v1_18"] +v1_18 = ["gst/v1_18", "gst-base/v1_18", "gst-video/v1_18", "ffi/v1_18"] +v1_20 = ["gst/v1_20", "gst-base/v1_20", "gst-video/v1_20", "ffi/v1_20", "v1_18"] +v1_22 = ["gst/v1_22", "gst-base/v1_22", "gst-video/v1_22", "ffi/v1_22", "v1_20"] +v1_24 = ["gst/v1_24", "gst-base/v1_24", "gst-video/v1_24", "ffi/v1_24", "v1_22"] +v1_26 = ["gst/v1_26", "gst-base/v1_26", "gst-video/v1_26", "ffi/v1_26", "v1_24"] +serde = ["dep:serde", "gst/serde", "gst-video/serde"] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/gstreamer-vulkan/Gir.toml b/gstreamer-vulkan/Gir.toml new file mode 100644 index 000000000..40743af3b --- /dev/null +++ b/gstreamer-vulkan/Gir.toml @@ -0,0 +1,118 @@ +[options] +girs_directories = ["../gir-files", "../gst-gir-files"] +library = "GstVulkan" +version = "1.0" +min_cfg_version = "1.18" +work_mode = "normal" +concurrency = "send+sync" +generate_safety_asserts = true +single_version_file = true +generate_display_trait = false +trust_return_value_nullability = true + +external_libraries = [ + "GLib", + "GObject", + "Gst", + "GstBase", + "GstVideo", +] + +generate = [ + #"GstVulkan.VulkanBufferMemory", + "GstVulkan.VulkanBufferMemoryAllocator", + "GstVulkan.VulkanBufferPool", + "GstVulkan.VulkanCommandBuffer", + "GstVulkan.VulkanCommandPool", + #"GstVulkan.VulkanDecoder", + "GstVulkan.VulkanDescriptorSet", + "GstVulkan.VulkanDevice", + "GstVulkan.VulkanDisplay", + "GstVulkan.VulkanDisplayType", + #"GstVulkan.VulkanEncoder", + "GstVulkan.VulkanFence", + #"GstVulkan.VulkanFullScreenQuad", + "GstVulkan.VulkanHandlePool", + "GstVulkan.VulkanImageBufferPool", + #"GstVulkan.VulkanImageMemory", + "GstVulkan.VulkanImageMemoryAllocator", + "GstVulkan.VulkanImageView", + "GstVulkan.VulkanInstance", + #"GstVulkan.VulkanMemory", + "GstVulkan.VulkanOperation", + "GstVulkan.VulkanPhysicalDevice", + "GstVulkan.VulkanQueue", + "GstVulkan.VulkanSwapper", + "GstVulkan.VulkanTrash", + "GstVulkan.VulkanVideoFilter", + "GstVulkan.VulkanWindow", +] + +manual = [ + "GLib.Error", + "GLib.Thread", + "GObject.Object", + "GObject.Value", + "Gst.AllocationParams", + "Gst.Allocator", + "Gst.BufferPool", + "Gst.Context", + "Gst.Element", + "Gst.FlowReturn", + "Gst.Fraction", + "Gst.Memory", + "Gst.Object", + "Gst.PadDirection", + "GstBase.BaseSrc", + "GstBase.BaseTransform", + "GstBase.PushSrc", + "GstVideo.VideoAlignment", + "GstVideo.VideoInfo", + "GstVideo.VideoMultiviewFlags", + "GstVideo.VideoMultiviewMode", + "GstVideo.VideoOverlay", +] + +[[object]] +name = "Gst.Buffer" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Caps" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Query" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Structure" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "GstVulkan.VulkanFullScreenQuad" +status = "generate" +concurrency = "none" + +[[object]] +name = "GstVulkan.VulkanHandle" +status = "generate" +ref_mode = "ref" + +[[object]] +name = "GstVulkan.VulkanDescriptorPool" +status = "generate" + [[object.function]] + name = "create" + ignore = true + +[[object]] +name = "GstVulkan.VulkanDescriptorCache" +status = "generate" + [[object.function]] + name = "new" + ignore = true diff --git a/gstreamer-vulkan/LICENSE-APACHE b/gstreamer-vulkan/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/gstreamer-vulkan/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/gstreamer-vulkan/LICENSE-MIT b/gstreamer-vulkan/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/gstreamer-vulkan/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/gstreamer-vulkan/README.md b/gstreamer-vulkan/README.md new file mode 100644 index 000000000..978dd2c6d --- /dev/null +++ b/gstreamer-vulkan/README.md @@ -0,0 +1,215 @@ +# gstreamer-rs [![crates.io](https://img.shields.io/crates/v/gstreamer-gl.svg)](https://crates.io/crates/gstreamer-gl) [![pipeline status](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/badges/main/pipeline.svg)](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/commits/main) + +[GStreamer](https://gstreamer.freedesktop.org/) (OpenGL library) +bindings for Rust. Documentation can be found +[here](https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_gl/). + +These bindings are providing a safe API that can be used to interface with +GStreamer, e.g. for writing GStreamer-based applications and GStreamer plugins. + +The bindings are mostly autogenerated with [gir](https://github.com/gtk-rs/gir/) +based on the [GObject-Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection/) +API metadata provided by the GStreamer project. + +## Table of Contents +1. [Installation](#installation) + 1. [Linux/BSDs](#installation-linux) + 1. [macOS](#installation-macos) + 1. [Windows](#installation-windows) +1. [Getting Started](#getting-started) +1. [License](#license) +1. [Contribution](#contribution) + + + +## Installation + +To build the GStreamer bindings or anything depending on them, you need to +have at least GStreamer 1.14 and gst-plugins-base 1.14 installed. In addition, +some of the examples/tutorials require various GStreamer plugins to be +available, which can be found in gst-plugins-base, gst-plugins-good, +gst-plugins-bad, gst-plugins-ugly and/or gst-libav. + + + +### Linux/BSDs + +You need to install the above mentioned packages with your distributions +package manager, or build them from source. + +On Debian/Ubuntu they can be installed with + +```console +$ apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \ + gstreamer1.0-libav libgstrtspserver-1.0-dev libges-1.0-dev +``` + +The minimum required version of the above libraries is >= 1.14. If you +build the gstreamer-player sub-crate, or any of the examples that +depend on gstreamer-player, you must ensure that in addition to the above +packages, `libgstreamer-plugins-bad1.0-dev` is installed. See the `Cargo.toml` +files for the full details, + +```console +$ apt-get install libgstreamer-plugins-bad1.0-dev +``` + +Package names on other distributions should be similar. +Please submit a pull request with instructions for yours. + + + +### macOS + +You can install GStreamer and the plugins via [Homebrew](https://brew.sh/) or +by installing the [binaries](https://gstreamer.freedesktop.org/data/pkg/osx/) +provided by the GStreamer project. + +We recommend using the official GStreamer binaries over Homebrew, especially +as GStreamer in Homebrew is [currently broken](https://github.com/orgs/Homebrew/discussions/3740#discussioncomment-3804964). + +#### GStreamer Binaries + +You need to download the *two* `.pkg` files from the GStreamer website and +install them, e.g. `gstreamer-1.0-1.20.4-universal.pkg` and +`gstreamer-1.0-devel-1.20.4-universal.pkg`. + +After installation, you also need to set the `PATH` environment variable as +follows + +```console +$ export PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/bin${PATH:+:$PATH}" +``` + +Also note that the `pkg-config` from GStreamer should be the first one in +the `PATH` as other versions have all kinds of quirks that will cause +problems. + +#### Homebrew + +Homebrew only installs various plugins if explicitly enabled, so some extra +`--with-*` flags may be required. + +```console +$ brew install gstreamer gst-plugins-base gst-plugins-good \ + gst-plugins-bad gst-plugins-ugly gst-libav gst-rtsp-server \ + gst-editing-services --with-orc --with-libogg --with-opus \ + --with-pango --with-theora --with-libvorbis --with-libvpx \ + --enable-gtk3 +``` + +Make sure the version of these libraries is >= 1.14. + + + +### Windows + +You can install GStreamer and the plugins via [MSYS2](http://www.msys2.org/) +with `pacman` or by installing the +[binaries](https://gstreamer.freedesktop.org/data/pkg/windows/) provided by +the GStreamer project. + +We recommend using the official GStreamer binaries over MSYS2. + +#### GStreamer Binaries + +You need to download the *two* `.msi` files for your platform from the +GStreamer website and install them, e.g. `gstreamer-1.0-x86_64-1.20.4.msi` and +`gstreamer-1.0-devel-x86_64-1.20.4.msi`. Make sure to select the version that +matches your Rust toolchain, i.e. MinGW or MSVC. + +After installation set the ``PATH` environment variable as follows: + +```console +# For a UNIX-style shell: +$ export PATH="c:/gstreamer/1.0/msvc_x86_64/bin${PATH:+:$PATH}" + +# For cmd.exe: +$ set PATH=C:\gstreamer\1.0\msvc_x86_64\bin;%PATH% +``` + +Make sure to update the path to where you have actually installed GStreamer +and for the corresponding toolchain. + +Also note that the `pkg-config.exe` from GStreamer should be the first one in +the `PATH` as other versions have all kinds of quirks that will cause +problems. + +#### MSYS2 / pacman + +```console +$ pacman -S glib2-devel pkg-config \ + mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gst-plugins-base \ + mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad \ + mingw-w64-x86_64-gst-plugins-ugly mingw-w64-x86_64-gst-libav \ + mingw-w64-x86_64-gst-rtsp-server +``` + +Make sure the version of these libraries is >= 1.14. + +Note that the version of `pkg-config` included in `MSYS2` is +[known to have problems](https://github.com/rust-lang/pkg-config-rs/issues/51#issuecomment-346300858) +compiling GStreamer, so you may need to install another version. One option +would be [`pkg-config-lite`](https://sourceforge.net/projects/pkgconfiglite/). + + + +## Getting Started + +The API reference can be found +[here](https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer/), however it is +only the Rust API reference and does not explain any of the concepts. + +For getting started with GStreamer development, the best would be to follow +the [documentation](https://gstreamer.freedesktop.org/documentation/) on the +GStreamer website, especially the [Application Development +Manual](https://gstreamer.freedesktop.org/documentation/application-development/). +While being C-centric, it explains all the fundamental concepts of GStreamer +and the code examples should be relatively easily translatable to Rust. The +API is basically the same, function/struct names are the same and everything +is only more convenient (hopefully) and safer. + +In addition there are +[tutorials](https://gstreamer.freedesktop.org/documentation/tutorials/) on the +GStreamer website. Many of them were ported to Rust already and the code can +be found in the +[tutorials](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/tree/main/tutorials) +directory. + +Some further examples for various aspects of GStreamer and how to use it from +Rust can be found in the +[examples](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/tree/main/examples) +directory. + +Various GStreamer plugins written in Rust can be found in the +[gst-plugins-rs](https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs) +repository. + + + +## LICENSE + +gstreamer-rs and all crates contained in here are licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +GStreamer itself is licensed under the Lesser General Public License version +2.1 or (at your option) any later version: +https://www.gnu.org/licenses/lgpl-2.1.html + + + +## Contribution + +Any kinds of contributions are welcome as a pull request. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in gstreamer-rs by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/gstreamer-vulkan/src/auto/flags.rs b/gstreamer-vulkan/src/auto/flags.rs new file mode 100644 index 000000000..1d31a2a55 --- /dev/null +++ b/gstreamer-vulkan/src/auto/flags.rs @@ -0,0 +1,116 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use glib::{bitflags::bitflags, prelude::*, translate::*}; + +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + #[doc(alias = "GstVulkanDisplayType")] + pub struct VulkanDisplayType: u32 { + #[doc(alias = "GST_VULKAN_DISPLAY_TYPE_NONE")] + const NONE = ffi::GST_VULKAN_DISPLAY_TYPE_NONE as _; + #[doc(alias = "GST_VULKAN_DISPLAY_TYPE_XCB")] + const XCB = ffi::GST_VULKAN_DISPLAY_TYPE_XCB as _; + #[doc(alias = "GST_VULKAN_DISPLAY_TYPE_WAYLAND")] + const WAYLAND = ffi::GST_VULKAN_DISPLAY_TYPE_WAYLAND as _; + #[doc(alias = "GST_VULKAN_DISPLAY_TYPE_COCOA")] + const COCOA = ffi::GST_VULKAN_DISPLAY_TYPE_COCOA as _; + #[doc(alias = "GST_VULKAN_DISPLAY_TYPE_IOS")] + const IOS = ffi::GST_VULKAN_DISPLAY_TYPE_IOS as _; + #[doc(alias = "GST_VULKAN_DISPLAY_TYPE_WIN32")] + const WIN32 = ffi::GST_VULKAN_DISPLAY_TYPE_WIN32 as _; + #[doc(alias = "GST_VULKAN_DISPLAY_TYPE_ANDROID")] + const ANDROID = ffi::GST_VULKAN_DISPLAY_TYPE_ANDROID as _; + #[doc(alias = "GST_VULKAN_DISPLAY_TYPE_ANY")] + const ANY = ffi::GST_VULKAN_DISPLAY_TYPE_ANY as _; + } +} + +impl VulkanDisplayType { + #[doc(alias = "gst_vulkan_display_type_to_extension_string")] + pub fn to_extension_string(self) -> Option { + assert_initialized_main_thread!(); + unsafe { + from_glib_none(ffi::gst_vulkan_display_type_to_extension_string( + self.into_glib(), + )) + } + } +} + +#[doc(hidden)] +impl IntoGlib for VulkanDisplayType { + type GlibType = ffi::GstVulkanDisplayType; + + #[inline] + fn into_glib(self) -> ffi::GstVulkanDisplayType { + self.bits() + } +} + +#[doc(hidden)] +impl FromGlib for VulkanDisplayType { + #[inline] + unsafe fn from_glib(value: ffi::GstVulkanDisplayType) -> Self { + skip_assert_initialized!(); + Self::from_bits_truncate(value) + } +} + +impl StaticType for VulkanDisplayType { + #[inline] + #[doc(alias = "gst_vulkan_display_type_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::gst_vulkan_display_type_get_type()) } + } +} + +impl glib::HasParamSpec for VulkanDisplayType { + type ParamSpec = glib::ParamSpecFlags; + type SetValue = Self; + type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder + } +} + +impl glib::value::ValueType for VulkanDisplayType { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for VulkanDisplayType { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + skip_assert_initialized!(); + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + } +} + +impl ToValue for VulkanDisplayType { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: VulkanDisplayType) -> Self { + skip_assert_initialized!(); + ToValue::to_value(&v) + } +} diff --git a/gstreamer-vulkan/src/auto/mod.rs b/gstreamer-vulkan/src/auto/mod.rs new file mode 100644 index 000000000..f675c9fd3 --- /dev/null +++ b/gstreamer-vulkan/src/auto/mod.rs @@ -0,0 +1,102 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +mod vulkan_buffer_memory_allocator; +pub use self::vulkan_buffer_memory_allocator::VulkanBufferMemoryAllocator; + +mod vulkan_buffer_pool; +pub use self::vulkan_buffer_pool::VulkanBufferPool; + +mod vulkan_command_pool; +pub use self::vulkan_command_pool::VulkanCommandPool; + +mod vulkan_descriptor_cache; +pub use self::vulkan_descriptor_cache::VulkanDescriptorCache; + +mod vulkan_descriptor_pool; +pub use self::vulkan_descriptor_pool::VulkanDescriptorPool; + +mod vulkan_device; +pub use self::vulkan_device::VulkanDevice; + +mod vulkan_display; +pub use self::vulkan_display::VulkanDisplay; + +mod vulkan_full_screen_quad; +pub use self::vulkan_full_screen_quad::VulkanFullScreenQuad; + +mod vulkan_handle_pool; +pub use self::vulkan_handle_pool::VulkanHandlePool; + +mod vulkan_image_buffer_pool; +pub use self::vulkan_image_buffer_pool::VulkanImageBufferPool; + +mod vulkan_image_memory_allocator; +pub use self::vulkan_image_memory_allocator::VulkanImageMemoryAllocator; + +mod vulkan_instance; +pub use self::vulkan_instance::VulkanInstance; + +#[cfg(feature = "v1_24")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +mod vulkan_operation; +#[cfg(feature = "v1_24")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +pub use self::vulkan_operation::VulkanOperation; + +mod vulkan_physical_device; +pub use self::vulkan_physical_device::VulkanPhysicalDevice; + +mod vulkan_queue; +pub use self::vulkan_queue::VulkanQueue; + +mod vulkan_swapper; +pub use self::vulkan_swapper::VulkanSwapper; + +mod vulkan_video_filter; +pub use self::vulkan_video_filter::VulkanVideoFilter; + +mod vulkan_window; +pub use self::vulkan_window::VulkanWindow; + +mod vulkan_command_buffer; +pub use self::vulkan_command_buffer::VulkanCommandBuffer; + +mod vulkan_descriptor_set; +pub use self::vulkan_descriptor_set::VulkanDescriptorSet; + +mod vulkan_fence; +pub use self::vulkan_fence::VulkanFence; + +mod vulkan_handle; +pub use self::vulkan_handle::VulkanHandle; + +mod vulkan_image_view; +pub use self::vulkan_image_view::VulkanImageView; + +mod vulkan_trash; +pub use self::vulkan_trash::VulkanTrash; + +mod flags; +pub use self::flags::VulkanDisplayType; + +pub(crate) mod traits { + pub use super::vulkan_command_pool::VulkanCommandPoolExt; + pub use super::vulkan_descriptor_cache::VulkanDescriptorCacheExt; + pub use super::vulkan_descriptor_pool::VulkanDescriptorPoolExt; + pub use super::vulkan_device::VulkanDeviceExt; + pub use super::vulkan_display::VulkanDisplayExt; + pub use super::vulkan_full_screen_quad::VulkanFullScreenQuadExt; + pub use super::vulkan_handle_pool::VulkanHandlePoolExt; + pub use super::vulkan_instance::VulkanInstanceExt; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub use super::vulkan_operation::VulkanOperationExt; + pub use super::vulkan_physical_device::VulkanPhysicalDeviceExt; + pub use super::vulkan_queue::VulkanQueueExt; + pub use super::vulkan_swapper::VulkanSwapperExt; + pub use super::vulkan_video_filter::VulkanVideoFilterExt; + pub use super::vulkan_window::VulkanWindowExt; +} diff --git a/gstreamer-vulkan/src/auto/versions.txt b/gstreamer-vulkan/src/auto/versions.txt new file mode 100644 index 000000000..5753ee763 --- /dev/null +++ b/gstreamer-vulkan/src/auto/versions.txt @@ -0,0 +1,3 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 5223ce91b97a) +from gir-files (https://github.com/gtk-rs/gir-files @ 6cd7b656acd6) +from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ d62956d67216+) diff --git a/gstreamer-vulkan/src/auto/vulkan_buffer_memory_allocator.rs b/gstreamer-vulkan/src/auto/vulkan_buffer_memory_allocator.rs new file mode 100644 index 000000000..84da5d8d6 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_buffer_memory_allocator.rs @@ -0,0 +1,20 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +glib::wrapper! { + #[doc(alias = "GstVulkanBufferMemoryAllocator")] + pub struct VulkanBufferMemoryAllocator(Object) @extends gst::Allocator, gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_buffer_memory_allocator_get_type(), + } +} + +impl VulkanBufferMemoryAllocator { + pub const NONE: Option<&'static VulkanBufferMemoryAllocator> = None; +} + +unsafe impl Send for VulkanBufferMemoryAllocator {} +unsafe impl Sync for VulkanBufferMemoryAllocator {} diff --git a/gstreamer-vulkan/src/auto/vulkan_buffer_pool.rs b/gstreamer-vulkan/src/auto/vulkan_buffer_pool.rs new file mode 100644 index 000000000..ff65a4f3d --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_buffer_pool.rs @@ -0,0 +1,41 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::VulkanDevice; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanBufferPool")] + pub struct VulkanBufferPool(Object) @extends gst::BufferPool, gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_buffer_pool_get_type(), + } +} + +impl VulkanBufferPool { + pub const NONE: Option<&'static VulkanBufferPool> = None; + + #[doc(alias = "gst_vulkan_buffer_pool_new")] + pub fn new(device: &impl IsA) -> VulkanBufferPool { + skip_assert_initialized!(); + unsafe { + gst::BufferPool::from_glib_full(ffi::gst_vulkan_buffer_pool_new( + device.as_ref().to_glib_none().0, + )) + .unsafe_cast() + } + } + + //#[cfg(feature = "v1_24")] + //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + //#[doc(alias = "gst_vulkan_buffer_pool_config_set_allocation_params")] + //pub fn config_set_allocation_params(config: &gst::Structure, usage: /*Ignored*/&vulkan::BufferUsageFlags, mem_properties: /*Ignored*/&vulkan::MemoryPropertyFlags) { + // unsafe { TODO: call ffi:gst_vulkan_buffer_pool_config_set_allocation_params() } + //} +} + +unsafe impl Send for VulkanBufferPool {} +unsafe impl Sync for VulkanBufferPool {} diff --git a/gstreamer-vulkan/src/auto/vulkan_command_buffer.rs b/gstreamer-vulkan/src/auto/vulkan_command_buffer.rs new file mode 100644 index 000000000..0c30d1bd8 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_command_buffer.rs @@ -0,0 +1,25 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +glib::wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct VulkanCommandBuffer(Boxed); + + match fn { + copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_vulkan_command_buffer_get_type(), ptr as *mut _) as *mut ffi::GstVulkanCommandBuffer, + free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_vulkan_command_buffer_get_type(), ptr as *mut _), + type_ => || ffi::gst_vulkan_command_buffer_get_type(), + } +} + +impl VulkanCommandBuffer { + //#[doc(alias = "gst_vulkan_command_buffer_new_wrapped")] + //pub fn new_wrapped(cmd: /*Ignored*/&vulkan::CommandBuffer, level: /*Ignored*/&vulkan::CommandBufferLevel) -> VulkanCommandBuffer { + // unsafe { TODO: call ffi:gst_vulkan_command_buffer_new_wrapped() } + //} +} + +unsafe impl Send for VulkanCommandBuffer {} +unsafe impl Sync for VulkanCommandBuffer {} diff --git a/gstreamer-vulkan/src/auto/vulkan_command_pool.rs b/gstreamer-vulkan/src/auto/vulkan_command_pool.rs new file mode 100644 index 000000000..1b872defe --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_command_pool.rs @@ -0,0 +1,70 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanCommandBuffer, VulkanQueue}; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanCommandPool")] + pub struct VulkanCommandPool(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_command_pool_get_type(), + } +} + +impl VulkanCommandPool { + pub const NONE: Option<&'static VulkanCommandPool> = None; +} + +unsafe impl Send for VulkanCommandPool {} +unsafe impl Sync for VulkanCommandPool {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanCommandPoolExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_command_pool_create")] + fn create(&self) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = + ffi::gst_vulkan_command_pool_create(self.as_ref().to_glib_none().0, &mut error); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_command_pool_get_queue")] + #[doc(alias = "get_queue")] + fn queue(&self) -> VulkanQueue { + unsafe { + from_glib_full(ffi::gst_vulkan_command_pool_get_queue( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_command_pool_lock")] + fn lock(&self) { + unsafe { + ffi::gst_vulkan_command_pool_lock(self.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "gst_vulkan_command_pool_unlock")] + fn unlock(&self) { + unsafe { + ffi::gst_vulkan_command_pool_unlock(self.as_ref().to_glib_none().0); + } + } +} + +impl> VulkanCommandPoolExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_descriptor_cache.rs b/gstreamer-vulkan/src/auto/vulkan_descriptor_cache.rs new file mode 100644 index 000000000..87f4490a5 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_descriptor_cache.rs @@ -0,0 +1,48 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanDescriptorSet, VulkanHandlePool}; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanDescriptorCache")] + pub struct VulkanDescriptorCache(Object) @extends VulkanHandlePool, gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_descriptor_cache_get_type(), + } +} + +impl VulkanDescriptorCache { + pub const NONE: Option<&'static VulkanDescriptorCache> = None; +} + +unsafe impl Send for VulkanDescriptorCache {} +unsafe impl Sync for VulkanDescriptorCache {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanDescriptorCacheExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_descriptor_cache_acquire")] + fn acquire(&self) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::gst_vulkan_descriptor_cache_acquire( + self.as_ref().to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } +} + +impl> VulkanDescriptorCacheExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_descriptor_pool.rs b/gstreamer-vulkan/src/auto/vulkan_descriptor_pool.rs new file mode 100644 index 000000000..fd139df59 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_descriptor_pool.rs @@ -0,0 +1,53 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::VulkanDevice; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanDescriptorPool")] + pub struct VulkanDescriptorPool(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_descriptor_pool_get_type(), + } +} + +impl VulkanDescriptorPool { + pub const NONE: Option<&'static VulkanDescriptorPool> = None; + + //#[doc(alias = "gst_vulkan_descriptor_pool_new_wrapped")] + //pub fn new_wrapped(device: &impl IsA, pool: /*Ignored*/vulkan::DescriptorPool, max_sets: usize) -> VulkanDescriptorPool { + // unsafe { TODO: call ffi:gst_vulkan_descriptor_pool_new_wrapped() } + //} +} + +unsafe impl Send for VulkanDescriptorPool {} +unsafe impl Sync for VulkanDescriptorPool {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanDescriptorPoolExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_descriptor_pool_get_device")] + #[doc(alias = "get_device")] + fn device(&self) -> VulkanDevice { + unsafe { + from_glib_full(ffi::gst_vulkan_descriptor_pool_get_device( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_descriptor_pool_get_max_sets")] + #[doc(alias = "get_max_sets")] + fn max_sets(&self) -> usize { + unsafe { ffi::gst_vulkan_descriptor_pool_get_max_sets(self.as_ref().to_glib_none().0) } + } +} + +impl> VulkanDescriptorPoolExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_descriptor_set.rs b/gstreamer-vulkan/src/auto/vulkan_descriptor_set.rs new file mode 100644 index 000000000..03d0ba069 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_descriptor_set.rs @@ -0,0 +1,25 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +glib::wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct VulkanDescriptorSet(Boxed); + + match fn { + copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_vulkan_descriptor_set_get_type(), ptr as *mut _) as *mut ffi::GstVulkanDescriptorSet, + free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_vulkan_descriptor_set_get_type(), ptr as *mut _), + type_ => || ffi::gst_vulkan_descriptor_set_get_type(), + } +} + +impl VulkanDescriptorSet { + //#[doc(alias = "gst_vulkan_descriptor_set_new_wrapped")] + //pub fn new_wrapped(pool: &impl IsA, set: /*Ignored*/&vulkan::DescriptorSet, layouts: &[VulkanHandle]) -> VulkanDescriptorSet { + // unsafe { TODO: call ffi:gst_vulkan_descriptor_set_new_wrapped() } + //} +} + +unsafe impl Send for VulkanDescriptorSet {} +unsafe impl Sync for VulkanDescriptorSet {} diff --git a/gstreamer-vulkan/src/auto/vulkan_device.rs b/gstreamer-vulkan/src/auto/vulkan_device.rs new file mode 100644 index 000000000..8c987e7e5 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_device.rs @@ -0,0 +1,270 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanFence, VulkanInstance, VulkanPhysicalDevice, VulkanQueue}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GstVulkanDevice")] + pub struct VulkanDevice(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_device_get_type(), + } +} + +impl VulkanDevice { + pub const NONE: Option<&'static VulkanDevice> = None; + + #[doc(alias = "gst_vulkan_device_new")] + pub fn new(physical_device: &impl IsA) -> VulkanDevice { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_device_new( + physical_device.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_device_new_with_index")] + #[doc(alias = "new_with_index")] + pub fn with_index(instance: &impl IsA, device_index: u32) -> VulkanDevice { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_device_new_with_index( + instance.as_ref().to_glib_none().0, + device_index, + )) + } + } + + #[doc(alias = "gst_vulkan_device_handle_context_query")] + pub fn handle_context_query( + element: &impl IsA, + query: &gst::Query, + device: &impl IsA, + ) -> bool { + skip_assert_initialized!(); + unsafe { + from_glib(ffi::gst_vulkan_device_handle_context_query( + element.as_ref().to_glib_none().0, + query.to_glib_none().0, + device.as_ref().to_glib_none().0, + )) + } + } + + //#[doc(alias = "gst_vulkan_device_run_context_query")] + //pub fn run_context_query(element: &impl IsA, device: impl IsA) -> bool { + // unsafe { TODO: call ffi:gst_vulkan_device_run_context_query() } + //} +} + +unsafe impl Send for VulkanDevice {} +unsafe impl Sync for VulkanDevice {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanDeviceExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_device_create_fence")] + fn create_fence(&self) -> Result, glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = + ffi::gst_vulkan_device_create_fence(self.as_ref().to_glib_none().0, &mut error); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_device_disable_extension")] + fn disable_extension(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_device_disable_extension( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_device_enable_extension")] + fn enable_extension(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_device_enable_extension( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_device_enable_layer")] + fn enable_layer(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_device_enable_layer( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_device_foreach_queue")] + fn foreach_queue(&self, func: Option<&mut dyn (FnMut(&VulkanDevice, &VulkanQueue) -> bool)>) { + let func_data: Option<&mut dyn (FnMut(&VulkanDevice, &VulkanQueue) -> bool)> = func; + unsafe extern "C" fn func_func( + device: *mut ffi::GstVulkanDevice, + queue: *mut ffi::GstVulkanQueue, + user_data: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { + let device = from_glib_borrow(device); + let queue = from_glib_borrow(queue); + let callback = + user_data as *mut Option<&mut dyn (FnMut(&VulkanDevice, &VulkanQueue) -> bool)>; + if let Some(ref mut callback) = *callback { + callback(&device, &queue) + } else { + panic!("cannot get closure...") + } + .into_glib() + } + let func = if func_data.is_some() { + Some(func_func as _) + } else { + None + }; + let super_callback0: &Option<&mut dyn (FnMut(&VulkanDevice, &VulkanQueue) -> bool)> = + &func_data; + unsafe { + ffi::gst_vulkan_device_foreach_queue( + self.as_ref().to_glib_none().0, + func, + super_callback0 as *const _ as *mut _, + ); + } + } + + #[doc(alias = "gst_vulkan_device_get_instance")] + #[doc(alias = "get_instance")] + fn instance(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_vulkan_device_get_instance( + self.as_ref().to_glib_none().0, + )) + } + } + + //#[doc(alias = "gst_vulkan_device_get_physical_device")] + //#[doc(alias = "get_physical_device")] + //fn physical_device(&self) -> /*Ignored*/vulkan::PhysicalDevice { + // unsafe { TODO: call ffi:gst_vulkan_device_get_physical_device() } + //} + + //#[doc(alias = "gst_vulkan_device_get_proc_address")] + //#[doc(alias = "get_proc_address")] + //fn proc_address(&self, name: &str) -> /*Unimplemented*/Option { + // unsafe { TODO: call ffi:gst_vulkan_device_get_proc_address() } + //} + + #[doc(alias = "gst_vulkan_device_get_queue")] + #[doc(alias = "get_queue")] + fn queue(&self, queue_family: u32, queue_i: u32) -> VulkanQueue { + unsafe { + from_glib_full(ffi::gst_vulkan_device_get_queue( + self.as_ref().to_glib_none().0, + queue_family, + queue_i, + )) + } + } + + #[doc(alias = "gst_vulkan_device_is_extension_enabled")] + fn is_extension_enabled(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_device_is_extension_enabled( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_device_is_layer_enabled")] + fn is_layer_enabled(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_device_is_layer_enabled( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_device_open")] + fn open(&self) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_device_open(self.as_ref().to_glib_none().0, &mut error); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + //#[cfg(feature = "v1_24")] + //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + //#[doc(alias = "gst_vulkan_device_queue_family_indices")] + //fn queue_family_indices(&self) -> /*Unknown conversion*//*Unimplemented*/Array TypeId { ns_id: 0, id: 7 } { + // unsafe { TODO: call ffi:gst_vulkan_device_queue_family_indices() } + //} + + //#[cfg(feature = "v1_24")] + //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + //#[doc(alias = "gst_vulkan_device_select_queue")] + //fn select_queue(&self, expected_flags: /*Ignored*/&vulkan::QueueFlagBits) -> VulkanQueue { + // unsafe { TODO: call ffi:gst_vulkan_device_select_queue() } + //} + + #[doc(alias = "instance")] + fn connect_instance_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_instance_trampoline< + P: IsA, + F: Fn(&P) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanDevice, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(VulkanDevice::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::instance\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + notify_instance_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> VulkanDeviceExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_display.rs b/gstreamer-vulkan/src/auto/vulkan_display.rs new file mode 100644 index 000000000..3d0726697 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_display.rs @@ -0,0 +1,128 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanDisplayType, VulkanInstance, VulkanWindow}; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanDisplay")] + pub struct VulkanDisplay(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_display_get_type(), + } +} + +impl VulkanDisplay { + pub const NONE: Option<&'static VulkanDisplay> = None; + + #[doc(alias = "gst_vulkan_display_new")] + pub fn new(instance: &impl IsA) -> VulkanDisplay { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_display_new( + instance.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_display_new_with_type")] + #[doc(alias = "new_with_type")] + pub fn with_type( + instance: &impl IsA, + type_: VulkanDisplayType, + ) -> Option { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_display_new_with_type( + instance.as_ref().to_glib_none().0, + type_.into_glib(), + )) + } + } + + #[doc(alias = "gst_vulkan_display_choose_type")] + pub fn choose_type(instance: &impl IsA) -> VulkanDisplayType { + skip_assert_initialized!(); + unsafe { + from_glib(ffi::gst_vulkan_display_choose_type( + instance.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_display_handle_context_query")] + pub fn handle_context_query( + element: &impl IsA, + query: &gst::Query, + display: Option<&impl IsA>, + ) -> bool { + assert_initialized_main_thread!(); + unsafe { + from_glib(ffi::gst_vulkan_display_handle_context_query( + element.as_ref().to_glib_none().0, + query.to_glib_none().0, + display.map(|p| p.as_ref()).to_glib_none().0, + )) + } + } + + //#[doc(alias = "gst_vulkan_display_run_context_query")] + //pub fn run_context_query(element: &impl IsA, display: impl IsA) -> bool { + // unsafe { TODO: call ffi:gst_vulkan_display_run_context_query() } + //} +} + +unsafe impl Send for VulkanDisplay {} +unsafe impl Sync for VulkanDisplay {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanDisplayExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_display_create_window")] + fn create_window(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_vulkan_display_create_window( + self.as_ref().to_glib_none().0, + )) + } + } + + //#[doc(alias = "gst_vulkan_display_find_window")] + //fn find_window(&self, data: /*Unimplemented*/Option, compare_func: /*Unimplemented*/FnMut(/*Unimplemented*/Option) -> i32) -> Option { + // unsafe { TODO: call ffi:gst_vulkan_display_find_window() } + //} + + //#[doc(alias = "gst_vulkan_display_get_handle")] + //#[doc(alias = "get_handle")] + //fn handle(&self) -> /*Unimplemented*/Option { + // unsafe { TODO: call ffi:gst_vulkan_display_get_handle() } + //} + + #[doc(alias = "gst_vulkan_display_get_handle_type")] + #[doc(alias = "get_handle_type")] + fn handle_type(&self) -> VulkanDisplayType { + unsafe { + from_glib(ffi::gst_vulkan_display_get_handle_type( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_display_remove_window")] + fn remove_window(&self, window: &impl IsA) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_display_remove_window( + self.as_ref().to_glib_none().0, + window.as_ref().to_glib_none().0, + )) + } + } +} + +impl> VulkanDisplayExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_fence.rs b/gstreamer-vulkan/src/auto/vulkan_fence.rs new file mode 100644 index 000000000..2de86a1cd --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_fence.rs @@ -0,0 +1,59 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::VulkanDevice; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct VulkanFence(Boxed); + + match fn { + copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_vulkan_fence_get_type(), ptr as *mut _) as *mut ffi::GstVulkanFence, + free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_vulkan_fence_get_type(), ptr as *mut _), + type_ => || ffi::gst_vulkan_fence_get_type(), + } +} + +impl VulkanFence { + #[doc(alias = "gst_vulkan_fence_new")] + pub fn new(device: &impl IsA) -> Result { + skip_assert_initialized!(); + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::gst_vulkan_fence_new(device.as_ref().to_glib_none().0, &mut error); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_fence_new_always_signalled")] + pub fn new_always_signalled(device: &impl IsA) -> VulkanFence { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_fence_new_always_signalled( + device.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_fence_is_signaled")] + pub fn is_signaled(&mut self) -> bool { + unsafe { from_glib(ffi::gst_vulkan_fence_is_signaled(self.to_glib_none_mut().0)) } + } + + #[doc(alias = "gst_vulkan_fence_reset")] + pub fn reset(&mut self) { + unsafe { + ffi::gst_vulkan_fence_reset(self.to_glib_none_mut().0); + } + } +} + +unsafe impl Send for VulkanFence {} +unsafe impl Sync for VulkanFence {} diff --git a/gstreamer-vulkan/src/auto/vulkan_full_screen_quad.rs b/gstreamer-vulkan/src/auto/vulkan_full_screen_quad.rs new file mode 100644 index 000000000..157a3665c --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_full_screen_quad.rs @@ -0,0 +1,287 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanCommandBuffer, VulkanFence, VulkanHandle, VulkanQueue}; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanFullScreenQuad")] + pub struct VulkanFullScreenQuad(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_full_screen_quad_get_type(), + } +} + +impl VulkanFullScreenQuad { + pub const NONE: Option<&'static VulkanFullScreenQuad> = None; + + #[doc(alias = "gst_vulkan_full_screen_quad_new")] + pub fn new(queue: &impl IsA) -> VulkanFullScreenQuad { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_full_screen_quad_new( + queue.as_ref().to_glib_none().0, + )) + } + } +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanFullScreenQuadExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_full_screen_quad_draw")] + fn draw(&self) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = + ffi::gst_vulkan_full_screen_quad_draw(self.as_ref().to_glib_none().0, &mut error); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[cfg(feature = "v1_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + #[doc(alias = "gst_vulkan_full_screen_quad_enable_blend")] + fn enable_blend(&self, enable_blend: bool) { + unsafe { + ffi::gst_vulkan_full_screen_quad_enable_blend( + self.as_ref().to_glib_none().0, + enable_blend.into_glib(), + ); + } + } + + #[cfg(feature = "v1_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + #[doc(alias = "gst_vulkan_full_screen_quad_enable_clear")] + fn enable_clear(&self, enable_clear: bool) { + unsafe { + ffi::gst_vulkan_full_screen_quad_enable_clear( + self.as_ref().to_glib_none().0, + enable_clear.into_glib(), + ); + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_fill_command_buffer")] + fn fill_command_buffer( + &self, + cmd: &mut VulkanCommandBuffer, + fence: &mut VulkanFence, + ) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_full_screen_quad_fill_command_buffer( + self.as_ref().to_glib_none().0, + cmd.to_glib_none_mut().0, + fence.to_glib_none_mut().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_get_last_fence")] + #[doc(alias = "get_last_fence")] + fn last_fence(&self) -> VulkanFence { + unsafe { + from_glib_full(ffi::gst_vulkan_full_screen_quad_get_last_fence( + self.as_ref().to_glib_none().0, + )) + } + } + + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + #[doc(alias = "gst_vulkan_full_screen_quad_get_queue")] + #[doc(alias = "get_queue")] + fn queue(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_vulkan_full_screen_quad_get_queue( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_prepare_draw")] + fn prepare_draw(&self, fence: &mut VulkanFence) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_full_screen_quad_prepare_draw( + self.as_ref().to_glib_none().0, + fence.to_glib_none_mut().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + //#[cfg(feature = "v1_22")] + //#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + //#[doc(alias = "gst_vulkan_full_screen_quad_set_blend_factors")] + //fn set_blend_factors(&self, src_blend_factor: /*Ignored*/&vulkan::BlendFactor, dst_blend_factor: /*Ignored*/&vulkan::BlendFactor, src_alpha_blend_factor: /*Ignored*/&vulkan::BlendFactor, dst_alpha_blend_factor: /*Ignored*/&vulkan::BlendFactor) { + // unsafe { TODO: call ffi:gst_vulkan_full_screen_quad_set_blend_factors() } + //} + + //#[cfg(feature = "v1_22")] + //#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + //#[doc(alias = "gst_vulkan_full_screen_quad_set_blend_operation")] + //fn set_blend_operation(&self, colour_blend_op: /*Ignored*/&vulkan::BlendOp, alpha_blend_op: /*Ignored*/&vulkan::BlendOp) { + // unsafe { TODO: call ffi:gst_vulkan_full_screen_quad_set_blend_operation() } + //} + + #[doc(alias = "gst_vulkan_full_screen_quad_set_index_buffer")] + fn set_index_buffer(&self, indices: &gst::Memory, n_indices: usize) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_full_screen_quad_set_index_buffer( + self.as_ref().to_glib_none().0, + indices.to_glib_none().0, + n_indices, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_set_info")] + fn set_info(&self, in_info: &gst_video::VideoInfo, out_info: &gst_video::VideoInfo) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_full_screen_quad_set_info( + self.as_ref().to_glib_none().0, + in_info.to_glib_none().0, + out_info.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_set_input_buffer")] + fn set_input_buffer(&self, buffer: Option<&gst::Buffer>) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_full_screen_quad_set_input_buffer( + self.as_ref().to_glib_none().0, + buffer.to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_set_output_buffer")] + fn set_output_buffer(&self, buffer: Option<&gst::Buffer>) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_full_screen_quad_set_output_buffer( + self.as_ref().to_glib_none().0, + buffer.to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_set_shaders")] + fn set_shaders(&self, vert: &VulkanHandle, frag: &VulkanHandle) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_full_screen_quad_set_shaders( + self.as_ref().to_glib_none().0, + vert.to_glib_none().0, + frag.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_set_uniform_buffer")] + fn set_uniform_buffer(&self, uniforms: &gst::Memory) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_full_screen_quad_set_uniform_buffer( + self.as_ref().to_glib_none().0, + uniforms.to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_set_vertex_buffer")] + fn set_vertex_buffer(&self, vertices: &gst::Memory) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_full_screen_quad_set_vertex_buffer( + self.as_ref().to_glib_none().0, + vertices.to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_full_screen_quad_submit")] + fn submit(&self, cmd: VulkanCommandBuffer, fence: &mut VulkanFence) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_full_screen_quad_submit( + self.as_ref().to_glib_none().0, + cmd.into_glib_ptr(), + fence.to_glib_none_mut().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } +} + +impl> VulkanFullScreenQuadExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_handle.rs b/gstreamer-vulkan/src/auto/vulkan_handle.rs new file mode 100644 index 000000000..8a65c9365 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_handle.rs @@ -0,0 +1,88 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanDevice, VulkanDisplay, VulkanInstance}; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct VulkanHandle(Boxed); + + match fn { + copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_vulkan_handle_get_type(), ptr as *mut _) as *mut ffi::GstVulkanHandle, + free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_vulkan_handle_get_type(), ptr as *mut _), + type_ => || ffi::gst_vulkan_handle_get_type(), + } +} + +impl VulkanHandle { + //#[doc(alias = "gst_vulkan_handle_new_wrapped")] + //pub fn new_wrapped(device: &impl IsA, type_: /*Ignored*/VulkanHandleType, handle: VulkanHandleTypedef, notify: P) -> VulkanHandle { + // unsafe { TODO: call ffi:gst_vulkan_handle_new_wrapped() } + //} + + //#[doc(alias = "gst_vulkan_handle_free_descriptor_set_layout")] + //pub fn free_descriptor_set_layout(&self, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_handle_free_descriptor_set_layout() } + //} + + //#[doc(alias = "gst_vulkan_handle_free_framebuffer")] + //pub fn free_framebuffer(&self, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_handle_free_framebuffer() } + //} + + //#[doc(alias = "gst_vulkan_handle_free_pipeline")] + //pub fn free_pipeline(&self, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_handle_free_pipeline() } + //} + + //#[doc(alias = "gst_vulkan_handle_free_pipeline_layout")] + //pub fn free_pipeline_layout(&self, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_handle_free_pipeline_layout() } + //} + + //#[doc(alias = "gst_vulkan_handle_free_render_pass")] + //pub fn free_render_pass(&self, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_handle_free_render_pass() } + //} + + //#[doc(alias = "gst_vulkan_handle_free_sampler")] + //pub fn free_sampler(&self, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_handle_free_sampler() } + //} + + //#[doc(alias = "gst_vulkan_handle_free_shader")] + //pub fn free_shader(&self, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_handle_free_shader() } + //} + + #[doc(alias = "gst_vulkan_handle_context_query")] + pub fn context_query( + element: &impl IsA, + query: &gst::Query, + display: Option<&impl IsA>, + instance: Option<&impl IsA>, + device: Option<&impl IsA>, + ) -> bool { + assert_initialized_main_thread!(); + unsafe { + from_glib(ffi::gst_vulkan_handle_context_query( + element.as_ref().to_glib_none().0, + query.to_glib_none().0, + display.map(|p| p.as_ref()).to_glib_none().0, + instance.map(|p| p.as_ref()).to_glib_none().0, + device.map(|p| p.as_ref()).to_glib_none().0, + )) + } + } + + //#[doc(alias = "gst_vulkan_handle_set_context")] + //pub fn set_context(element: &impl IsA, context: &gst::Context, display: impl IsA, instance: impl IsA) -> bool { + // unsafe { TODO: call ffi:gst_vulkan_handle_set_context() } + //} +} + +unsafe impl Send for VulkanHandle {} +unsafe impl Sync for VulkanHandle {} diff --git a/gstreamer-vulkan/src/auto/vulkan_handle_pool.rs b/gstreamer-vulkan/src/auto/vulkan_handle_pool.rs new file mode 100644 index 000000000..6001cec93 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_handle_pool.rs @@ -0,0 +1,46 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use glib::prelude::*; + +glib::wrapper! { + #[doc(alias = "GstVulkanHandlePool")] + pub struct VulkanHandlePool(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_handle_pool_get_type(), + } +} + +impl VulkanHandlePool { + pub const NONE: Option<&'static VulkanHandlePool> = None; +} + +unsafe impl Send for VulkanHandlePool {} +unsafe impl Sync for VulkanHandlePool {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanHandlePoolExt: IsA + sealed::Sealed + 'static { + //#[doc(alias = "gst_vulkan_handle_pool_acquire")] + //fn acquire(&self) -> Result, glib::Error> { + // unsafe { TODO: call ffi:gst_vulkan_handle_pool_acquire() } + //} + + //#[doc(alias = "gst_vulkan_handle_pool_alloc")] + //fn alloc(&self) -> Result, glib::Error> { + // unsafe { TODO: call ffi:gst_vulkan_handle_pool_alloc() } + //} + + //#[doc(alias = "gst_vulkan_handle_pool_release")] + //fn release(&self, handle: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_handle_pool_release() } + //} +} + +impl> VulkanHandlePoolExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_image_buffer_pool.rs b/gstreamer-vulkan/src/auto/vulkan_image_buffer_pool.rs new file mode 100644 index 000000000..2fb6789cb --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_image_buffer_pool.rs @@ -0,0 +1,67 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::VulkanDevice; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanImageBufferPool")] + pub struct VulkanImageBufferPool(Object) @extends gst::BufferPool, gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_image_buffer_pool_get_type(), + } +} + +impl VulkanImageBufferPool { + pub const NONE: Option<&'static VulkanImageBufferPool> = None; + + #[doc(alias = "gst_vulkan_image_buffer_pool_new")] + pub fn new(device: &impl IsA) -> VulkanImageBufferPool { + skip_assert_initialized!(); + unsafe { + gst::BufferPool::from_glib_full(ffi::gst_vulkan_image_buffer_pool_new( + device.as_ref().to_glib_none().0, + )) + .unsafe_cast() + } + } + + //#[cfg(feature = "v1_24")] + //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + //#[doc(alias = "gst_vulkan_image_buffer_pool_config_set_allocation_params")] + //pub fn config_set_allocation_params(config: &gst::Structure, usage: /*Ignored*/&vulkan::ImageUsageFlags, mem_properties: /*Ignored*/&vulkan::MemoryPropertyFlags, initial_layout: /*Ignored*/&vulkan::ImageLayout, initial_access: u64) { + // unsafe { TODO: call ffi:gst_vulkan_image_buffer_pool_config_set_allocation_params() } + //} + + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + #[doc(alias = "gst_vulkan_image_buffer_pool_config_set_decode_caps")] + pub fn config_set_decode_caps(config: &gst::Structure, caps: &gst::Caps) { + assert_initialized_main_thread!(); + unsafe { + ffi::gst_vulkan_image_buffer_pool_config_set_decode_caps( + config.to_glib_none().0, + caps.to_glib_none().0, + ); + } + } + + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + #[doc(alias = "gst_vulkan_image_buffer_pool_config_set_encode_caps")] + pub fn config_set_encode_caps(config: &gst::Structure, caps: &gst::Caps) { + assert_initialized_main_thread!(); + unsafe { + ffi::gst_vulkan_image_buffer_pool_config_set_encode_caps( + config.to_glib_none().0, + caps.to_glib_none().0, + ); + } + } +} + +unsafe impl Send for VulkanImageBufferPool {} +unsafe impl Sync for VulkanImageBufferPool {} diff --git a/gstreamer-vulkan/src/auto/vulkan_image_memory_allocator.rs b/gstreamer-vulkan/src/auto/vulkan_image_memory_allocator.rs new file mode 100644 index 000000000..e297e65df --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_image_memory_allocator.rs @@ -0,0 +1,20 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +glib::wrapper! { + #[doc(alias = "GstVulkanImageMemoryAllocator")] + pub struct VulkanImageMemoryAllocator(Object) @extends gst::Allocator, gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_image_memory_allocator_get_type(), + } +} + +impl VulkanImageMemoryAllocator { + pub const NONE: Option<&'static VulkanImageMemoryAllocator> = None; +} + +unsafe impl Send for VulkanImageMemoryAllocator {} +unsafe impl Sync for VulkanImageMemoryAllocator {} diff --git a/gstreamer-vulkan/src/auto/vulkan_image_view.rs b/gstreamer-vulkan/src/auto/vulkan_image_view.rs new file mode 100644 index 000000000..efdfabff5 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_image_view.rs @@ -0,0 +1,25 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +glib::wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct VulkanImageView(Boxed); + + match fn { + copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_vulkan_image_view_get_type(), ptr as *mut _) as *mut ffi::GstVulkanImageView, + free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_vulkan_image_view_get_type(), ptr as *mut _), + type_ => || ffi::gst_vulkan_image_view_get_type(), + } +} + +impl VulkanImageView { + //#[doc(alias = "gst_vulkan_image_view_new")] + //pub fn new(image: /*Ignored*/&mut VulkanImageMemory, create_info: /*Ignored*/&vulkan::ImageViewCreateInfo) -> VulkanImageView { + // unsafe { TODO: call ffi:gst_vulkan_image_view_new() } + //} +} + +unsafe impl Send for VulkanImageView {} +unsafe impl Sync for VulkanImageView {} diff --git a/gstreamer-vulkan/src/auto/vulkan_instance.rs b/gstreamer-vulkan/src/auto/vulkan_instance.rs new file mode 100644 index 000000000..4fec60847 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_instance.rs @@ -0,0 +1,352 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::VulkanDevice; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GstVulkanInstance")] + pub struct VulkanInstance(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_instance_get_type(), + } +} + +impl VulkanInstance { + pub const NONE: Option<&'static VulkanInstance> = None; + + #[doc(alias = "gst_vulkan_instance_new")] + pub fn new() -> VulkanInstance { + assert_initialized_main_thread!(); + unsafe { from_glib_full(ffi::gst_vulkan_instance_new()) } + } + + #[doc(alias = "gst_vulkan_instance_handle_context_query")] + pub fn handle_context_query( + element: &impl IsA, + query: &gst::Query, + instance: Option<&impl IsA>, + ) -> bool { + assert_initialized_main_thread!(); + unsafe { + from_glib(ffi::gst_vulkan_instance_handle_context_query( + element.as_ref().to_glib_none().0, + query.to_glib_none().0, + instance.map(|p| p.as_ref()).to_glib_none().0, + )) + } + } + + //#[doc(alias = "gst_vulkan_instance_run_context_query")] + //pub fn run_context_query(element: &impl IsA, instance: impl IsA) -> bool { + // unsafe { TODO: call ffi:gst_vulkan_instance_run_context_query() } + //} +} + +impl Default for VulkanInstance { + fn default() -> Self { + Self::new() + } +} + +unsafe impl Send for VulkanInstance {} +unsafe impl Sync for VulkanInstance {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanInstanceExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_instance_check_version")] + fn check_version(&self, major: u32, minor: u32, patch: u32) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_instance_check_version( + self.as_ref().to_glib_none().0, + major, + minor, + patch, + )) + } + } + + #[doc(alias = "gst_vulkan_instance_create_device")] + fn create_device(&self) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = + ffi::gst_vulkan_instance_create_device(self.as_ref().to_glib_none().0, &mut error); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_instance_disable_extension")] + fn disable_extension(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_instance_disable_extension( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_instance_enable_extension")] + fn enable_extension(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_instance_enable_extension( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_instance_enable_layer")] + fn enable_layer(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_instance_enable_layer( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_instance_fill_info")] + fn fill_info(&self) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = + ffi::gst_vulkan_instance_fill_info(self.as_ref().to_glib_none().0, &mut error); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_instance_get_extension_info")] + #[doc(alias = "get_extension_info")] + fn extension_info(&self, name: &str) -> Option { + unsafe { + let mut spec_version = std::mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_vulkan_instance_get_extension_info( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + spec_version.as_mut_ptr(), + )); + if ret { + Some(spec_version.assume_init()) + } else { + None + } + } + } + + #[doc(alias = "gst_vulkan_instance_get_layer_info")] + #[doc(alias = "get_layer_info")] + fn layer_info(&self, name: &str) -> Option<(Option, u32, u32)> { + unsafe { + let mut description = std::ptr::null_mut(); + let mut spec_version = std::mem::MaybeUninit::uninit(); + let mut implementation_version = std::mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_vulkan_instance_get_layer_info( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + &mut description, + spec_version.as_mut_ptr(), + implementation_version.as_mut_ptr(), + )); + if ret { + Some(( + from_glib_full(description), + spec_version.assume_init(), + implementation_version.assume_init(), + )) + } else { + None + } + } + } + + //#[doc(alias = "gst_vulkan_instance_get_proc_address")] + //#[doc(alias = "get_proc_address")] + //fn proc_address(&self, name: &str) -> /*Unimplemented*/Option { + // unsafe { TODO: call ffi:gst_vulkan_instance_get_proc_address() } + //} + + #[doc(alias = "gst_vulkan_instance_get_version")] + #[doc(alias = "get_version")] + fn version(&self) -> (u32, u32, u32) { + unsafe { + let mut major = std::mem::MaybeUninit::uninit(); + let mut minor = std::mem::MaybeUninit::uninit(); + let mut patch = std::mem::MaybeUninit::uninit(); + ffi::gst_vulkan_instance_get_version( + self.as_ref().to_glib_none().0, + major.as_mut_ptr(), + minor.as_mut_ptr(), + patch.as_mut_ptr(), + ); + ( + major.assume_init(), + minor.assume_init(), + patch.assume_init(), + ) + } + } + + #[doc(alias = "gst_vulkan_instance_is_extension_enabled")] + fn is_extension_enabled(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_instance_is_extension_enabled( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_instance_is_layer_enabled")] + fn is_layer_enabled(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_instance_is_layer_enabled( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_instance_open")] + fn open(&self) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_instance_open(self.as_ref().to_glib_none().0, &mut error); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "requested-api-major")] + fn requested_api_major(&self) -> u32 { + ObjectExt::property(self.as_ref(), "requested-api-major") + } + + #[doc(alias = "requested-api-major")] + fn set_requested_api_major(&self, requested_api_major: u32) { + ObjectExt::set_property(self.as_ref(), "requested-api-major", requested_api_major) + } + + #[doc(alias = "requested-api-minor")] + fn requested_api_minor(&self) -> u32 { + ObjectExt::property(self.as_ref(), "requested-api-minor") + } + + #[doc(alias = "requested-api-minor")] + fn set_requested_api_minor(&self, requested_api_minor: u32) { + ObjectExt::set_property(self.as_ref(), "requested-api-minor", requested_api_minor) + } + + #[doc(alias = "create-device")] + fn connect_create_device VulkanDevice + Send + Sync + 'static>( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn create_device_trampoline< + P: IsA, + F: Fn(&P) -> VulkanDevice + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanInstance, + f: glib::ffi::gpointer, + ) -> *mut ffi::GstVulkanDevice { + let f: &F = &*(f as *const F); + f(VulkanInstance::from_glib_borrow(this).unsafe_cast_ref()).to_glib_full() + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"create-device\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + create_device_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "requested-api-major")] + fn connect_requested_api_major_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_requested_api_major_trampoline< + P: IsA, + F: Fn(&P) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanInstance, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(VulkanInstance::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::requested-api-major\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + notify_requested_api_major_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "requested-api-minor")] + fn connect_requested_api_minor_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_requested_api_minor_trampoline< + P: IsA, + F: Fn(&P) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanInstance, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(VulkanInstance::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::requested-api-minor\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + notify_requested_api_minor_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> VulkanInstanceExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_operation.rs b/gstreamer-vulkan/src/auto/vulkan_operation.rs new file mode 100644 index 000000000..aca88900b --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_operation.rs @@ -0,0 +1,185 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::VulkanCommandPool; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanOperation")] + pub struct VulkanOperation(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_operation_get_type(), + } +} + +impl VulkanOperation { + pub const NONE: Option<&'static VulkanOperation> = None; + + #[doc(alias = "gst_vulkan_operation_new")] + pub fn new(cmd_pool: &impl IsA) -> VulkanOperation { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_operation_new( + cmd_pool.as_ref().to_glib_none().0, + )) + } + } +} + +unsafe impl Send for VulkanOperation {} +unsafe impl Sync for VulkanOperation {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanOperationExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_operation_add_dependency_frame")] + fn add_dependency_frame( + &self, + frame: &gst::Buffer, + wait_stage: u64, + signal_stage: u64, + ) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_operation_add_dependency_frame( + self.as_ref().to_glib_none().0, + frame.to_glib_none().0, + wait_stage, + signal_stage, + )) + } + } + + //#[doc(alias = "gst_vulkan_operation_add_extra_image_barriers")] + //fn add_extra_image_barriers(&self, extra_barriers: /*Unknown conversion*//*Unimplemented*/Array TypeId { ns_id: 0, id: 25 }) { + // unsafe { TODO: call ffi:gst_vulkan_operation_add_extra_image_barriers() } + //} + + //#[doc(alias = "gst_vulkan_operation_add_frame_barrier")] + //fn add_frame_barrier(&self, frame: &gst::Buffer, dst_stage: u64, new_access: u64, new_layout: /*Ignored*/&vulkan::ImageLayout, new_queue: Option<&impl IsA>) -> bool { + // unsafe { TODO: call ffi:gst_vulkan_operation_add_frame_barrier() } + //} + + #[doc(alias = "gst_vulkan_operation_begin")] + fn begin(&self) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_operation_begin(self.as_ref().to_glib_none().0, &mut error); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_operation_begin_query")] + fn begin_query(&self, id: u32) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_operation_begin_query( + self.as_ref().to_glib_none().0, + id, + )) + } + } + + #[doc(alias = "gst_vulkan_operation_discard_dependencies")] + fn discard_dependencies(&self) { + unsafe { + ffi::gst_vulkan_operation_discard_dependencies(self.as_ref().to_glib_none().0); + } + } + + //#[doc(alias = "gst_vulkan_operation_enable_query")] + //fn enable_query(&self, query_type: u32, n_queries: u32, pnext: /*Unimplemented*/Option) -> Result<(), glib::Error> { + // unsafe { TODO: call ffi:gst_vulkan_operation_enable_query() } + //} + + #[doc(alias = "gst_vulkan_operation_end")] + fn end(&self) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_operation_end(self.as_ref().to_glib_none().0, &mut error); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_operation_end_query")] + fn end_query(&self, id: u32) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_operation_end_query( + self.as_ref().to_glib_none().0, + id, + )) + } + } + + //#[doc(alias = "gst_vulkan_operation_get_query")] + //#[doc(alias = "get_query")] + //fn query(&self, data: /*Unimplemented*/&mut Option) -> Result<(), glib::Error> { + // unsafe { TODO: call ffi:gst_vulkan_operation_get_query() } + //} + + //#[doc(alias = "gst_vulkan_operation_new_extra_image_barriers")] + //fn new_extra_image_barriers(&self) -> /*Unknown conversion*//*Unimplemented*/Array TypeId { ns_id: 0, id: 25 } { + // unsafe { TODO: call ffi:gst_vulkan_operation_new_extra_image_barriers() } + //} + + //#[doc(alias = "gst_vulkan_operation_pipeline_barrier2")] + //fn pipeline_barrier2(&self, dependency_info: /*Unimplemented*/Option) -> bool { + // unsafe { TODO: call ffi:gst_vulkan_operation_pipeline_barrier2() } + //} + + #[doc(alias = "gst_vulkan_operation_reset")] + fn reset(&self) { + unsafe { + ffi::gst_vulkan_operation_reset(self.as_ref().to_glib_none().0); + } + } + + //#[doc(alias = "gst_vulkan_operation_retrieve_image_barriers")] + //fn retrieve_image_barriers(&self) -> /*Unknown conversion*//*Unimplemented*/Array TypeId { ns_id: 0, id: 25 } { + // unsafe { TODO: call ffi:gst_vulkan_operation_retrieve_image_barriers() } + //} + + //#[doc(alias = "gst_vulkan_operation_update_frame")] + //fn update_frame(&self, frame: &gst::Buffer, dst_stage: u64, new_access: u64, new_layout: /*Ignored*/&vulkan::ImageLayout, new_queue: Option<&impl IsA>) { + // unsafe { TODO: call ffi:gst_vulkan_operation_update_frame() } + //} + + #[doc(alias = "gst_vulkan_operation_use_sync2")] + fn use_sync2(&self) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_operation_use_sync2( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_operation_wait")] + fn wait(&self) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_operation_wait( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "command-pool")] + fn command_pool(&self) -> Option { + ObjectExt::property(self.as_ref(), "command-pool") + } +} + +impl> VulkanOperationExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_physical_device.rs b/gstreamer-vulkan/src/auto/vulkan_physical_device.rs new file mode 100644 index 000000000..fff5a527b --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_physical_device.rs @@ -0,0 +1,113 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::VulkanInstance; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanPhysicalDevice")] + pub struct VulkanPhysicalDevice(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_physical_device_get_type(), + } +} + +impl VulkanPhysicalDevice { + pub const NONE: Option<&'static VulkanPhysicalDevice> = None; + + #[doc(alias = "gst_vulkan_physical_device_new")] + pub fn new(instance: &impl IsA, device_index: u32) -> VulkanPhysicalDevice { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_physical_device_new( + instance.as_ref().to_glib_none().0, + device_index, + )) + } + } + + //#[doc(alias = "gst_vulkan_physical_device_type_to_string")] + //pub fn type_to_string(type_: /*Ignored*/&vulkan::PhysicalDeviceType) -> glib::GString { + // unsafe { TODO: call ffi:gst_vulkan_physical_device_type_to_string() } + //} +} + +unsafe impl Send for VulkanPhysicalDevice {} +unsafe impl Sync for VulkanPhysicalDevice {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanPhysicalDeviceExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_physical_device_get_extension_info")] + #[doc(alias = "get_extension_info")] + fn extension_info(&self, name: &str) -> Option { + unsafe { + let mut spec_version = std::mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_vulkan_physical_device_get_extension_info( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + spec_version.as_mut_ptr(), + )); + if ret { + Some(spec_version.assume_init()) + } else { + None + } + } + } + + //#[doc(alias = "gst_vulkan_physical_device_get_handle")] + //#[doc(alias = "get_handle")] + //fn handle(&self) -> /*Ignored*/vulkan::PhysicalDevice { + // unsafe { TODO: call ffi:gst_vulkan_physical_device_get_handle() } + //} + + #[doc(alias = "gst_vulkan_physical_device_get_instance")] + #[doc(alias = "get_instance")] + fn instance(&self) -> VulkanInstance { + unsafe { + from_glib_full(ffi::gst_vulkan_physical_device_get_instance( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_physical_device_get_layer_info")] + #[doc(alias = "get_layer_info")] + fn layer_info(&self, name: &str) -> Option<(Option, u32, u32)> { + unsafe { + let mut description = std::ptr::null_mut(); + let mut spec_version = std::mem::MaybeUninit::uninit(); + let mut implementation_version = std::mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_vulkan_physical_device_get_layer_info( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + &mut description, + spec_version.as_mut_ptr(), + implementation_version.as_mut_ptr(), + )); + if ret { + Some(( + from_glib_full(description), + spec_version.assume_init(), + implementation_version.assume_init(), + )) + } else { + None + } + } + } + + #[doc(alias = "device-index")] + fn device_index(&self) -> u32 { + ObjectExt::property(self.as_ref(), "device-index") + } +} + +impl> VulkanPhysicalDeviceExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_queue.rs b/gstreamer-vulkan/src/auto/vulkan_queue.rs new file mode 100644 index 000000000..e978adb97 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_queue.rs @@ -0,0 +1,98 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanCommandPool, VulkanDevice}; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GstVulkanQueue")] + pub struct VulkanQueue(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_queue_get_type(), + } +} + +impl VulkanQueue { + pub const NONE: Option<&'static VulkanQueue> = None; + + //#[doc(alias = "gst_vulkan_queue_flags_to_string")] + //pub fn flags_to_string(queue_bits: /*Ignored*/&vulkan::QueueFlags) -> glib::GString { + // unsafe { TODO: call ffi:gst_vulkan_queue_flags_to_string() } + //} + + #[doc(alias = "gst_vulkan_queue_handle_context_query")] + pub fn handle_context_query( + element: &impl IsA, + query: &gst::Query, + queue: Option<&impl IsA>, + ) -> bool { + assert_initialized_main_thread!(); + unsafe { + from_glib(ffi::gst_vulkan_queue_handle_context_query( + element.as_ref().to_glib_none().0, + query.to_glib_none().0, + queue.map(|p| p.as_ref()).to_glib_none().0, + )) + } + } + + //#[doc(alias = "gst_vulkan_queue_run_context_query")] + //pub fn run_context_query(element: &impl IsA, queue: impl IsA) -> bool { + // unsafe { TODO: call ffi:gst_vulkan_queue_run_context_query() } + //} +} + +unsafe impl Send for VulkanQueue {} +unsafe impl Sync for VulkanQueue {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanQueueExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_queue_create_command_pool")] + fn create_command_pool(&self) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::gst_vulkan_queue_create_command_pool( + self.as_ref().to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_queue_get_device")] + #[doc(alias = "get_device")] + fn device(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_vulkan_queue_get_device( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_queue_submit_lock")] + fn submit_lock(&self) { + unsafe { + ffi::gst_vulkan_queue_submit_lock(self.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "gst_vulkan_queue_submit_unlock")] + fn submit_unlock(&self) { + unsafe { + ffi::gst_vulkan_queue_submit_unlock(self.as_ref().to_glib_none().0); + } + } +} + +impl> VulkanQueueExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_swapper.rs b/gstreamer-vulkan/src/auto/vulkan_swapper.rs new file mode 100644 index 000000000..db915c5c1 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_swapper.rs @@ -0,0 +1,206 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanDevice, VulkanQueue, VulkanWindow}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GstVulkanSwapper")] + pub struct VulkanSwapper(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_swapper_get_type(), + } +} + +impl VulkanSwapper { + pub const NONE: Option<&'static VulkanSwapper> = None; + + #[doc(alias = "gst_vulkan_swapper_new")] + pub fn new(device: &impl IsA, window: &impl IsA) -> VulkanSwapper { + skip_assert_initialized!(); + unsafe { + from_glib_none(ffi::gst_vulkan_swapper_new( + device.as_ref().to_glib_none().0, + window.as_ref().to_glib_none().0, + )) + } + } +} + +unsafe impl Send for VulkanSwapper {} +unsafe impl Sync for VulkanSwapper {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanSwapperExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_swapper_choose_queue")] + fn choose_queue( + &self, + available_queue: Option<&impl IsA>, + ) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_swapper_choose_queue( + self.as_ref().to_glib_none().0, + available_queue.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_swapper_get_supported_caps")] + #[doc(alias = "get_supported_caps")] + fn supported_caps(&self) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::gst_vulkan_swapper_get_supported_caps( + self.as_ref().to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } + + //#[doc(alias = "gst_vulkan_swapper_get_surface_rectangles")] + //#[doc(alias = "get_surface_rectangles")] + //fn surface_rectangles(&self, input_image: /*Ignored*/Option, surface_location: /*Ignored*/Option, display_rect: /*Ignored*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_swapper_get_surface_rectangles() } + //} + + #[doc(alias = "gst_vulkan_swapper_render_buffer")] + fn render_buffer(&self, buffer: &gst::Buffer) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_swapper_render_buffer( + self.as_ref().to_glib_none().0, + buffer.to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_swapper_set_caps")] + fn set_caps(&self, caps: &gst::Caps) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_swapper_set_caps( + self.as_ref().to_glib_none().0, + caps.to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "force-aspect-ratio")] + fn is_force_aspect_ratio(&self) -> bool { + ObjectExt::property(self.as_ref(), "force-aspect-ratio") + } + + #[doc(alias = "force-aspect-ratio")] + fn set_force_aspect_ratio(&self, force_aspect_ratio: bool) { + ObjectExt::set_property(self.as_ref(), "force-aspect-ratio", force_aspect_ratio) + } + + #[doc(alias = "pixel-aspect-ratio")] + fn pixel_aspect_ratio(&self) -> Option { + ObjectExt::property(self.as_ref(), "pixel-aspect-ratio") + } + + #[doc(alias = "pixel-aspect-ratio")] + fn set_pixel_aspect_ratio(&self, pixel_aspect_ratio: Option<&gst::Fraction>) { + ObjectExt::set_property(self.as_ref(), "pixel-aspect-ratio", pixel_aspect_ratio) + } + + #[doc(alias = "force-aspect-ratio")] + fn connect_force_aspect_ratio_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_force_aspect_ratio_trampoline< + P: IsA, + F: Fn(&P) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanSwapper, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(VulkanSwapper::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::force-aspect-ratio\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + notify_force_aspect_ratio_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "pixel-aspect-ratio")] + fn connect_pixel_aspect_ratio_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_pixel_aspect_ratio_trampoline< + P: IsA, + F: Fn(&P) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanSwapper, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(VulkanSwapper::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::pixel-aspect-ratio\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + notify_pixel_aspect_ratio_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> VulkanSwapperExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_trash.rs b/gstreamer-vulkan/src/auto/vulkan_trash.rs new file mode 100644 index 000000000..28cfd087a --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_trash.rs @@ -0,0 +1,72 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanDevice, VulkanFence}; +use glib::translate::*; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct VulkanTrash(Boxed); + + match fn { + copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_vulkan_trash_get_type(), ptr as *mut _) as *mut ffi::GstVulkanTrash, + free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_vulkan_trash_get_type(), ptr as *mut _), + type_ => || ffi::gst_vulkan_trash_get_type(), + } +} + +impl VulkanTrash { + #[doc(alias = "gst_vulkan_trash_new")] + pub fn new( + fence: &mut VulkanFence, + notify: Option>, + ) -> VulkanTrash { + assert_initialized_main_thread!(); + let notify_data: Box_>> = + Box_::new(notify); + unsafe extern "C" fn notify_func( + device: *mut ffi::GstVulkanDevice, + user_data: glib::ffi::gpointer, + ) { + let device = from_glib_borrow(device); + let callback = + Box_::from_raw(user_data as *mut Option>); + let callback = (*callback).expect("cannot get closure..."); + callback(&device) + } + let notify = if notify_data.is_some() { + Some(notify_func as _) + } else { + None + }; + let super_callback0: Box_>> = notify_data; + unsafe { + from_glib_full(ffi::gst_vulkan_trash_new( + fence.to_glib_none_mut().0, + notify, + Box_::into_raw(super_callback0) as *mut _, + )) + } + } + + //#[doc(alias = "gst_vulkan_trash_new_free_semaphore")] + //pub fn new_free_semaphore(fence: &mut VulkanFence, semaphore: /*Ignored*/&vulkan::Semaphore) -> VulkanTrash { + // unsafe { TODO: call ffi:gst_vulkan_trash_new_free_semaphore() } + //} + + //#[doc(alias = "gst_vulkan_trash_mini_object_unref")] + //pub fn mini_object_unref(device: &impl IsA, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_trash_mini_object_unref() } + //} + + //#[doc(alias = "gst_vulkan_trash_object_unref")] + //pub fn object_unref(device: &impl IsA, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:gst_vulkan_trash_object_unref() } + //} +} + +unsafe impl Send for VulkanTrash {} +unsafe impl Sync for VulkanTrash {} diff --git a/gstreamer-vulkan/src/auto/vulkan_video_filter.rs b/gstreamer-vulkan/src/auto/vulkan_video_filter.rs new file mode 100644 index 000000000..3e14ae983 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_video_filter.rs @@ -0,0 +1,73 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#[cfg(feature = "v1_26")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] +use crate::{VulkanDevice, VulkanInstance, VulkanQueue}; +use glib::prelude::*; +#[cfg(feature = "v1_26")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] +use glib::translate::*; + +glib::wrapper! { + #[doc(alias = "GstVulkanVideoFilter")] + pub struct VulkanVideoFilter(Object) @extends gst_base::BaseTransform, gst::Element, gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_video_filter_get_type(), + } +} + +impl VulkanVideoFilter { + pub const NONE: Option<&'static VulkanVideoFilter> = None; +} + +unsafe impl Send for VulkanVideoFilter {} +unsafe impl Sync for VulkanVideoFilter {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanVideoFilterExt: IsA + sealed::Sealed + 'static { + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + #[doc(alias = "gst_vulkan_video_filter_get_device")] + #[doc(alias = "get_device")] + fn device(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_vulkan_video_filter_get_device( + self.as_ref().to_glib_none().0, + )) + } + } + + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + #[doc(alias = "gst_vulkan_video_filter_get_instance")] + #[doc(alias = "get_instance")] + fn instance(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_vulkan_video_filter_get_instance( + self.as_ref().to_glib_none().0, + )) + } + } + + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + #[doc(alias = "gst_vulkan_video_filter_get_queue")] + #[doc(alias = "get_queue")] + fn queue(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_vulkan_video_filter_get_queue( + self.as_ref().to_glib_none().0, + )) + } + } +} + +impl> VulkanVideoFilterExt for O {} diff --git a/gstreamer-vulkan/src/auto/vulkan_window.rs b/gstreamer-vulkan/src/auto/vulkan_window.rs new file mode 100644 index 000000000..d52fa60c7 --- /dev/null +++ b/gstreamer-vulkan/src/auto/vulkan_window.rs @@ -0,0 +1,353 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::{VulkanDevice, VulkanDisplay}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GstVulkanWindow")] + pub struct VulkanWindow(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_window_get_type(), + } +} + +impl VulkanWindow { + pub const NONE: Option<&'static VulkanWindow> = None; + + #[doc(alias = "gst_vulkan_window_new")] + pub fn new(display: &impl IsA) -> VulkanWindow { + skip_assert_initialized!(); + unsafe { + from_glib_full(ffi::gst_vulkan_window_new( + display.as_ref().to_glib_none().0, + )) + } + } +} + +unsafe impl Send for VulkanWindow {} +unsafe impl Sync for VulkanWindow {} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanWindowExt: IsA + sealed::Sealed + 'static { + #[doc(alias = "gst_vulkan_window_close")] + fn close(&self) { + unsafe { + ffi::gst_vulkan_window_close(self.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "gst_vulkan_window_get_display")] + #[doc(alias = "get_display")] + fn display(&self) -> VulkanDisplay { + unsafe { + from_glib_full(ffi::gst_vulkan_window_get_display( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "gst_vulkan_window_get_presentation_support")] + #[doc(alias = "get_presentation_support")] + fn is_presentation_support( + &self, + device: &impl IsA, + queue_family_idx: u32, + ) -> bool { + unsafe { + from_glib(ffi::gst_vulkan_window_get_presentation_support( + self.as_ref().to_glib_none().0, + device.as_ref().to_glib_none().0, + queue_family_idx, + )) + } + } + + //#[doc(alias = "gst_vulkan_window_get_surface")] + //#[doc(alias = "get_surface")] + //fn surface(&self) -> Result { + // unsafe { TODO: call ffi:gst_vulkan_window_get_surface() } + //} + + #[doc(alias = "gst_vulkan_window_get_surface_dimensions")] + #[doc(alias = "get_surface_dimensions")] + fn surface_dimensions(&self) -> (u32, u32) { + unsafe { + let mut width = std::mem::MaybeUninit::uninit(); + let mut height = std::mem::MaybeUninit::uninit(); + ffi::gst_vulkan_window_get_surface_dimensions( + self.as_ref().to_glib_none().0, + width.as_mut_ptr(), + height.as_mut_ptr(), + ); + (width.assume_init(), height.assume_init()) + } + } + + #[doc(alias = "gst_vulkan_window_handle_events")] + fn handle_events(&self, handle_events: bool) { + unsafe { + ffi::gst_vulkan_window_handle_events( + self.as_ref().to_glib_none().0, + handle_events.into_glib(), + ); + } + } + + #[doc(alias = "gst_vulkan_window_open")] + fn open(&self) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::gst_vulkan_window_open(self.as_ref().to_glib_none().0, &mut error); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gst_vulkan_window_redraw")] + fn redraw(&self) { + unsafe { + ffi::gst_vulkan_window_redraw(self.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "gst_vulkan_window_resize")] + fn resize(&self, width: i32, height: i32) { + unsafe { + ffi::gst_vulkan_window_resize(self.as_ref().to_glib_none().0, width, height); + } + } + + #[doc(alias = "gst_vulkan_window_send_key_event")] + fn send_key_event(&self, event_type: &str, key_str: &str) { + unsafe { + ffi::gst_vulkan_window_send_key_event( + self.as_ref().to_glib_none().0, + event_type.to_glib_none().0, + key_str.to_glib_none().0, + ); + } + } + + #[doc(alias = "gst_vulkan_window_send_mouse_event")] + fn send_mouse_event(&self, event_type: &str, button: i32, posx: f64, posy: f64) { + unsafe { + ffi::gst_vulkan_window_send_mouse_event( + self.as_ref().to_glib_none().0, + event_type.to_glib_none().0, + button, + posx, + posy, + ); + } + } + + //#[doc(alias = "gst_vulkan_window_set_window_handle")] + //fn set_window_handle(&self, handle: /*Unimplemented*/Basic: UIntPtr) { + // unsafe { TODO: call ffi:gst_vulkan_window_set_window_handle() } + //} + + #[doc(alias = "close")] + fn connect_close bool + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn close_trampoline< + P: IsA, + F: Fn(&P) -> bool + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanWindow, + f: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { + let f: &F = &*(f as *const F); + f(VulkanWindow::from_glib_borrow(this).unsafe_cast_ref()).into_glib() + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"close\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + close_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "draw")] + fn connect_draw(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn draw_trampoline< + P: IsA, + F: Fn(&P) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanWindow, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(VulkanWindow::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"draw\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + draw_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "key-event")] + fn connect_key_event( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn key_event_trampoline< + P: IsA, + F: Fn(&P, &str, &str) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanWindow, + id: *mut libc::c_char, + key: *mut libc::c_char, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f( + VulkanWindow::from_glib_borrow(this).unsafe_cast_ref(), + &glib::GString::from_glib_borrow(id), + &glib::GString::from_glib_borrow(key), + ) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"key-event\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + key_event_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "mouse-event")] + fn connect_mouse_event( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn mouse_event_trampoline< + P: IsA, + F: Fn(&P, &str, i32, f64, f64) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanWindow, + id: *mut libc::c_char, + button: libc::c_int, + x: libc::c_double, + y: libc::c_double, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f( + VulkanWindow::from_glib_borrow(this).unsafe_cast_ref(), + &glib::GString::from_glib_borrow(id), + button, + x, + y, + ) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"mouse-event\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + mouse_event_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "resize")] + fn connect_resize( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn resize_trampoline< + P: IsA, + F: Fn(&P, u32, u32) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanWindow, + object: libc::c_uint, + p0: libc::c_uint, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f( + VulkanWindow::from_glib_borrow(this).unsafe_cast_ref(), + object, + p0, + ) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"resize\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + resize_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "display")] + fn connect_display_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_display_trampoline< + P: IsA, + F: Fn(&P) + Send + Sync + 'static, + >( + this: *mut ffi::GstVulkanWindow, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(VulkanWindow::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::display\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + notify_display_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> VulkanWindowExt for O {} diff --git a/gstreamer-vulkan/src/caps_features.rs b/gstreamer-vulkan/src/caps_features.rs new file mode 100644 index 000000000..0a3b6293a --- /dev/null +++ b/gstreamer-vulkan/src/caps_features.rs @@ -0,0 +1,9 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use gst::CapsFeatures; +use once_cell::sync::Lazy; + +pub static CAPS_FEATURE_MEMORY_VULKAN_IMAGE: &glib::GStr = + unsafe { glib::GStr::from_utf8_with_nul_unchecked(ffi::GST_CAPS_FEATURE_MEMORY_VULKAN_IMAGE) }; +pub static CAPS_FEATURES_MEMORY_VULKAN_IMAGE: Lazy = + Lazy::new(|| CapsFeatures::new([CAPS_FEATURE_MEMORY_VULKAN_IMAGE])); diff --git a/gstreamer-vulkan/src/lib.rs b/gstreamer-vulkan/src/lib.rs new file mode 100644 index 000000000..30c8e23f8 --- /dev/null +++ b/gstreamer-vulkan/src/lib.rs @@ -0,0 +1,43 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +#![cfg_attr(docsrs, feature(doc_cfg))] +#![allow(clippy::missing_safety_doc)] +#![doc = include_str!("../README.md")] + +pub use ffi; +pub use glib; +pub use gst; +pub use gst_base; +pub use gst_video; + +macro_rules! assert_initialized_main_thread { + () => { + if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) { + gst::assert_initialized(); + } + }; +} + +macro_rules! skip_assert_initialized { + () => {}; +} + +mod auto; +pub use crate::auto::*; + +mod vulkan_device; +mod vulkan_full_screen_quad; + +// Re-export all the traits in a prelude module, so that applications +// can always "use gst_vulkan::prelude::*" without getting conflicts +pub mod prelude { + #[doc(hidden)] + pub use gst_video::prelude::*; + + pub use super::vulkan_device::VulkanDeviceExtManual; + pub use super::vulkan_full_screen_quad::VulkanFullScreenQuadExtManual; + pub use crate::auto::traits::*; +} + +mod caps_features; +pub use caps_features::*; diff --git a/gstreamer-vulkan/src/vulkan_device.rs b/gstreamer-vulkan/src/vulkan_device.rs new file mode 100644 index 000000000..3879a18ba --- /dev/null +++ b/gstreamer-vulkan/src/vulkan_device.rs @@ -0,0 +1,33 @@ +use crate::VulkanDevice; + +use glib::prelude::*; +use glib::translate::*; + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanDeviceExtManual: sealed::Sealed + IsA + 'static { + fn create_shader( + &self, + code: [u8; N], + ) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let shader = crate::ffi::gst_vulkan_create_shader( + self.as_ref().to_glib_none().0, + code.as_ptr() as *const i8, + code.len(), + &mut error, + ); + debug_assert_eq!(shader.is_null(), !error.is_null()); + if error.is_null() { + Ok(crate::VulkanHandle::from_glib_full(shader)) + } else { + Err(from_glib_full(error)) + } + } + } +} +impl> VulkanDeviceExtManual for O {} diff --git a/gstreamer-vulkan/src/vulkan_full_screen_quad.rs b/gstreamer-vulkan/src/vulkan_full_screen_quad.rs new file mode 100644 index 000000000..6f11d3986 --- /dev/null +++ b/gstreamer-vulkan/src/vulkan_full_screen_quad.rs @@ -0,0 +1,24 @@ +use crate::VulkanFullScreenQuad; + +use crate::traits::VulkanFullScreenQuadExt; + +use glib::prelude::*; +use glib::translate::*; + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait VulkanFullScreenQuadExtManual: + sealed::Sealed + IsA + 'static +{ + fn draw_into_output(&self, outbuf: &mut gst::BufferRef) -> Result<(), glib::Error> { + let out = unsafe { gst::Buffer::from_glib_none(outbuf.as_ptr()) }; + self.set_output_buffer(Some(&out))?; + let ret = self.draw(); + self.set_output_buffer(None)?; + ret + } +} +impl> VulkanFullScreenQuadExtManual for O {} diff --git a/gstreamer-vulkan/sys/CHANGELOG.md b/gstreamer-vulkan/sys/CHANGELOG.md new file mode 120000 index 000000000..d6a7bdb06 --- /dev/null +++ b/gstreamer-vulkan/sys/CHANGELOG.md @@ -0,0 +1 @@ +../../gstreamer/CHANGELOG.md \ No newline at end of file diff --git a/gstreamer-vulkan/sys/COPYRIGHT b/gstreamer-vulkan/sys/COPYRIGHT new file mode 120000 index 000000000..8b0161cc9 --- /dev/null +++ b/gstreamer-vulkan/sys/COPYRIGHT @@ -0,0 +1 @@ +../../COPYRIGHT \ No newline at end of file diff --git a/gstreamer-vulkan/sys/Cargo.toml b/gstreamer-vulkan/sys/Cargo.toml new file mode 100644 index 000000000..09dd3a23a --- /dev/null +++ b/gstreamer-vulkan/sys/Cargo.toml @@ -0,0 +1,92 @@ +[build-dependencies] +system-deps = "6" + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +workspace = true + +[dependencies.gobject-sys] +workspace = true + +[dependencies.gstreamer-sys] +workspace = true + +[dependencies.gstreamer-base-sys] +workspace = true + +[dependencies.gstreamer-video-sys] +workspace = true + +[dependencies.ash] +version = "0.38" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] +v1_18 = [] +v1_20 = [] +v1_22 = ["v1_20"] +v1_24 = ["v1_22"] +v1_26 = ["v1_24"] + +[lib] +name = "gstreamer_vulkan_sys" + +[package] +authors = ["Matthew Waters "] +build = "build.rs" +description = "FFI bindings to libgstvulkan-1.0" +documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_vulkan_sys/" +keywords = ["ffi", "gstreamer", "gnome", "multimedia"] +license = "MIT" +name = "gstreamer-vulkan-sys" +readme = "README.md" + +[package.version] +workspace = true + +[package.categories] +workspace = true + +[package.repository] +workspace = true + +[package.homepage] +workspace = true + +[package.edition] +workspace = true + +[package.rust-version] +workspace = true + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] + +[package.metadata.system-deps.gstreamer_vulkan_1_0] +name = "gstreamer-vulkan-1.0" +version = "1.14" + +[package.metadata.system-deps.gstreamer_vulkan_1_0.v1_16] +version = "1.16" + +[package.metadata.system-deps.gstreamer_vulkan_1_0.v1_18] +version = "1.18" + +[package.metadata.system-deps.gstreamer_vulkan_1_0.v1_20] +version = "1.20" + +[package.metadata.system-deps.gstreamer_vulkan_1_0.v1_22] +version = "1.22" + +[package.metadata.system-deps.gstreamer_vulkan_1_0.v1_24] +version = "1.24" + +[package.metadata.system-deps.gstreamer_vulkan_1_0.v1_26] +version = "1.25" diff --git a/gstreamer-vulkan/sys/Gir.toml b/gstreamer-vulkan/sys/Gir.toml new file mode 100644 index 000000000..7f5eefa98 --- /dev/null +++ b/gstreamer-vulkan/sys/Gir.toml @@ -0,0 +1,40 @@ +[options] +girs_directories = ["../../gir-files", "../../gst-gir-files"] +library = "GstVulkan" +version = "1.0" +min_cfg_version = "1.18" +work_mode = "sys" +single_version_file = true + +extra_versions = [ + "1.24", + "1.22", + "1.20", +] + +ignore = [ +] + +external_libraries = [ + "GLib", + "GObject", +] + +[external_libraries] +gstreamer="Gst" +gstreamer-base="GstBase" +gstreamer-video="GstVideo" + +[[object]] +name = "GstVulkan.VulkanBufferMemory" +status = "generate" + [[object.function]] + name = "get_type" + version = "1.18" + +[[object]] +name = "GstVulkan.VulkanImageMemory" +status = "generate" + [[object.function]] + name = "get_type" + version = "1.18" diff --git a/gstreamer-vulkan/sys/LICENSE b/gstreamer-vulkan/sys/LICENSE new file mode 120000 index 000000000..b2cfbdc7b --- /dev/null +++ b/gstreamer-vulkan/sys/LICENSE @@ -0,0 +1 @@ +../../LICENSE-MIT \ No newline at end of file diff --git a/gstreamer-vulkan/sys/README.md b/gstreamer-vulkan/sys/README.md new file mode 100644 index 000000000..fb52329d4 --- /dev/null +++ b/gstreamer-vulkan/sys/README.md @@ -0,0 +1,31 @@ +# gstreamer-sys [![crates.io](https://img.shields.io/crates/v/gstreamer-gl-sys.svg)](https://crates.io/crates/gstreamer-gl-sys) [![pipeline status](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/badges/main/pipeline.svg)](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/commits/main) + +[GStreamer](https://gstreamer.freedesktop.org/) (OpenGL library) FFI bindings for Rust. + +These bindings are providing unsafe FFI API that can be used to interface with +GStreamer. Generally they are meant to be used as the building block for +higher-level abstractions like: + + * Bindings for GStreamer applications and plugins: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs + * Various GStreamer plugins written in Rust: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs + +The bindings are autogenerated with [gir](https://github.com/gtk-rs/gir/) +based on the [GObject-Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection/) +API metadata provided by the GStreamer project. + +## LICENSE + +gstreamer-sys and all crates contained here are licensed under the MIT +license ([LICENSE](LICENSE) or http://opensource.org/licenses/MIT). + +GStreamer itself is licensed under the Lesser General Public License version +2.1 or (at your option) any later version: +https://www.gnu.org/licenses/lgpl-2.1.html + +## Contribution + +Any kinds of contributions are welcome as a pull request. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in gstreamer-rs by you shall be licensed under the MIT license as above, +without any additional terms or conditions. diff --git a/gstreamer-vulkan/sys/build.rs b/gstreamer-vulkan/sys/build.rs new file mode 100644 index 000000000..29420c9ee --- /dev/null +++ b/gstreamer-vulkan/sys/build.rs @@ -0,0 +1,18 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#[cfg(not(docsrs))] +use std::process; + +#[cfg(docsrs)] +fn main() {} // prevent linking libraries to avoid documentation failure + +#[cfg(not(docsrs))] +fn main() { + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + process::exit(1); + } +} diff --git a/gstreamer-vulkan/sys/src/auto/versions.txt b/gstreamer-vulkan/sys/src/auto/versions.txt new file mode 100644 index 000000000..5753ee763 --- /dev/null +++ b/gstreamer-vulkan/sys/src/auto/versions.txt @@ -0,0 +1,3 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 5223ce91b97a) +from gir-files (https://github.com/gtk-rs/gir-files @ 6cd7b656acd6) +from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ d62956d67216+) diff --git a/gstreamer-vulkan/sys/src/lib.rs b/gstreamer-vulkan/sys/src/lib.rs new file mode 100644 index 000000000..b8a80af4c --- /dev/null +++ b/gstreamer-vulkan/sys/src/lib.rs @@ -0,0 +1,2366 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use glib_sys as glib; +use gobject_sys as gobject; +use gstreamer_base_sys as gst_base; +use gstreamer_sys as gst; +use gstreamer_video_sys as gst_video; + +mod manual; + +pub use manual::*; + +#[allow(unused_imports)] +use libc::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, + intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE, +}; +#[cfg(unix)] +#[allow(unused_imports)] +use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Aliases +pub type GstVulkanHandleTypedef = u64; + +// Enums +pub type GstVulkanBarrierFlags = c_int; +pub const GST_VULKAN_BARRIER_FLAG_NONE: GstVulkanBarrierFlags = 0; + +pub type GstVulkanBarrierType = c_int; +pub const GST_VULKAN_BARRIER_NONE: GstVulkanBarrierType = 0; +pub const GST_VULKAN_BARRIER_TYPE_MEMORY: GstVulkanBarrierType = 1; +pub const GST_VULKAN_BARRIER_TYPE_BUFFER: GstVulkanBarrierType = 2; +pub const GST_VULKAN_BARRIER_TYPE_IMAGE: GstVulkanBarrierType = 3; + +pub type GstVulkanError = c_int; +pub const GST_VULKAN_FAILED: GstVulkanError = 0; + +pub type GstVulkanFormatScaling = c_int; +pub const GST_VULKAN_FORMAT_SCALING_UNORM: GstVulkanFormatScaling = 1; +pub const GST_VULKAN_FORMAT_SCALING_SNORM: GstVulkanFormatScaling = 2; +pub const GST_VULKAN_FORMAT_SCALING_USCALED: GstVulkanFormatScaling = 3; +pub const GST_VULKAN_FORMAT_SCALING_SSCALED: GstVulkanFormatScaling = 4; +pub const GST_VULKAN_FORMAT_SCALING_UINT: GstVulkanFormatScaling = 5; +pub const GST_VULKAN_FORMAT_SCALING_SINT: GstVulkanFormatScaling = 6; +pub const GST_VULKAN_FORMAT_SCALING_SRGB: GstVulkanFormatScaling = 7; + +pub type GstVulkanHandleType = c_int; +pub const GST_VULKAN_HANDLE_TYPE_DESCRIPTOR_SET_LAYOUT: GstVulkanHandleType = 1; +pub const GST_VULKAN_HANDLE_TYPE_PIPELINE_LAYOUT: GstVulkanHandleType = 2; +pub const GST_VULKAN_HANDLE_TYPE_PIPELINE: GstVulkanHandleType = 3; +pub const GST_VULKAN_HANDLE_TYPE_RENDER_PASS: GstVulkanHandleType = 4; +pub const GST_VULKAN_HANDLE_TYPE_SAMPLER: GstVulkanHandleType = 5; +pub const GST_VULKAN_HANDLE_TYPE_FRAMEBUFFER: GstVulkanHandleType = 6; +pub const GST_VULKAN_HANDLE_TYPE_SHADER: GstVulkanHandleType = 7; +#[cfg(feature = "v1_24")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +pub const GST_VULKAN_HANDLE_TYPE_VIDEO_SESSION: GstVulkanHandleType = 8; +#[cfg(feature = "v1_24")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +pub const GST_VULKAN_HANDLE_TYPE_VIDEO_SESSION_PARAMETERS: GstVulkanHandleType = 9; +#[cfg(feature = "v1_24")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +pub const GST_VULKAN_HANDLE_TYPE_SAMPLER_YCBCR_CONVERSION: GstVulkanHandleType = 10; + +pub type GstVulkanVideoOperation = c_int; +pub const GST_VULKAN_VIDEO_OPERATION_DECODE: GstVulkanVideoOperation = 0; +pub const GST_VULKAN_VIDEO_OPERATION_ENCODE: GstVulkanVideoOperation = 1; +pub const GST_VULKAN_VIDEO_OPERATION_UNKNOWN: GstVulkanVideoOperation = 2; + +pub type GstVulkanWindowError = c_int; +pub const GST_VULKAN_WINDOW_ERROR_FAILED: GstVulkanWindowError = 0; +pub const GST_VULKAN_WINDOW_ERROR_OLD_LIBS: GstVulkanWindowError = 1; +pub const GST_VULKAN_WINDOW_ERROR_RESOURCE_UNAVAILABLE: GstVulkanWindowError = 2; + +// Constants +pub const GST_CAPS_FEATURE_MEMORY_VULKAN_BUFFER: &[u8] = b"memory:VulkanBuffer\0"; +pub const GST_CAPS_FEATURE_MEMORY_VULKAN_IMAGE: &[u8] = b"memory:VulkanImage\0"; +pub const GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_NAME: &[u8] = b"VulkanBuffer\0"; +pub const GST_VULKAN_DEVICE_CONTEXT_TYPE_STR: &[u8] = b"gst.vulkan.device\0"; +pub const GST_VULKAN_DISPLAY_CONTEXT_TYPE_STR: &[u8] = b"gst.vulkan.display\0"; +pub const GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_NAME: &[u8] = b"VulkanImage\0"; +pub const GST_VULKAN_INSTANCE_CONTEXT_TYPE_STR: &[u8] = b"gst.vulkan.instance\0"; +pub const GST_VULKAN_MAX_COMPONENTS: c_int = 4; +pub const GST_VULKAN_MEMORY_ALLOCATOR_NAME: &[u8] = b"Vulkan\0"; +pub const GST_VULKAN_QUEUE_CONTEXT_TYPE_STR: &[u8] = b"gst.vulkan.queue\0"; +pub const GST_VULKAN_SWAPPER_VIDEO_FORMATS: &[u8] = b" { RGBA, BGRA, RGB, BGR } \0"; + +// Flags +pub type GstVulkanDisplayType = c_uint; +pub const GST_VULKAN_DISPLAY_TYPE_NONE: GstVulkanDisplayType = 0; +pub const GST_VULKAN_DISPLAY_TYPE_XCB: GstVulkanDisplayType = 1; +pub const GST_VULKAN_DISPLAY_TYPE_WAYLAND: GstVulkanDisplayType = 2; +pub const GST_VULKAN_DISPLAY_TYPE_COCOA: GstVulkanDisplayType = 4; +pub const GST_VULKAN_DISPLAY_TYPE_IOS: GstVulkanDisplayType = 8; +pub const GST_VULKAN_DISPLAY_TYPE_WIN32: GstVulkanDisplayType = 16; +pub const GST_VULKAN_DISPLAY_TYPE_ANDROID: GstVulkanDisplayType = 32; +pub const GST_VULKAN_DISPLAY_TYPE_ANY: GstVulkanDisplayType = 4294967295; + +pub type GstVulkanFormatFlags = c_uint; +pub const GST_VULKAN_FORMAT_FLAG_YUV: GstVulkanFormatFlags = 1; +pub const GST_VULKAN_FORMAT_FLAG_RGB: GstVulkanFormatFlags = 2; +pub const GST_VULKAN_FORMAT_FLAG_ALPHA: GstVulkanFormatFlags = 4; +pub const GST_VULKAN_FORMAT_FLAG_LE: GstVulkanFormatFlags = 8; +pub const GST_VULKAN_FORMAT_FLAG_COMPLEX: GstVulkanFormatFlags = 16; + +// Callbacks +pub type GstVulkanDeviceForEachQueueFunc = + Option gboolean>; +pub type GstVulkanHandleDestroyNotify = + Option; +pub type GstVulkanImageMemoryFindViewFunc = + Option gboolean>; +pub type GstVulkanTrashListAdd = + Option gboolean>; +pub type GstVulkanTrashListGC = Option; +pub type GstVulkanTrashListWait = + Option gboolean>; +pub type GstVulkanTrashNotify = Option; + +// Records +#[repr(C)] +pub struct GstVulkanBarrierBufferInfo { + _truncated_record_marker: c_void, + // /*Ignored*/field parent has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanBarrierBufferInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanBarrierBufferInfo @ {self:p}")) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanBarrierImageInfo { + _truncated_record_marker: c_void, + // /*Ignored*/field parent has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanBarrierImageInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanBarrierImageInfo @ {self:p}")) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanBarrierMemoryInfo { + pub type_: GstVulkanBarrierType, + pub flags: GstVulkanBarrierFlags, + pub queue: *mut GstVulkanQueue, + pub pipeline_stages: u64, + pub access_flags: u64, + _truncated_record_marker: c_void, + // /*Ignored*/field semaphore has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanBarrierMemoryInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanBarrierMemoryInfo @ {self:p}")) + .field("type_", &self.type_) + .field("flags", &self.flags) + .field("queue", &self.queue) + .field("pipeline_stages", &self.pipeline_stages) + .field("access_flags", &self.access_flags) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanBufferMemory { + pub parent: gst::GstMemory, + pub device: *mut GstVulkanDevice, + _truncated_record_marker: c_void, + // /*Ignored*/field buffer has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanBufferMemory { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanBufferMemory @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanBufferMemoryAllocatorClass { + pub parent_class: gst::GstAllocatorClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanBufferMemoryAllocatorClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanBufferMemoryAllocatorClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanBufferPoolClass { + pub parent_class: gst::GstBufferPoolClass, + pub _padding: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanBufferPoolClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanBufferPoolClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanBufferPoolPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanBufferPoolPrivate = _GstVulkanBufferPoolPrivate; + +#[repr(C)] +pub struct GstVulkanCommandBuffer { + pub parent: gst::GstMiniObject, + _truncated_record_marker: c_void, + // /*Ignored*/field cmd has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanCommandBuffer { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanCommandBuffer @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanCommandPoolClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanCommandPoolClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanCommandPoolClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanCommandPoolPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanCommandPoolPrivate = _GstVulkanCommandPoolPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDescriptorCacheClass { + pub parent_class: GstVulkanHandlePoolClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanDescriptorCacheClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDescriptorCacheClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanDescriptorCachePrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanDescriptorCachePrivate = _GstVulkanDescriptorCachePrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDescriptorPoolClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanDescriptorPoolClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDescriptorPoolClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanDescriptorPoolPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanDescriptorPoolPrivate = _GstVulkanDescriptorPoolPrivate; + +#[repr(C)] +pub struct GstVulkanDescriptorSet { + pub parent: gst::GstMiniObject, + _truncated_record_marker: c_void, + // /*Ignored*/field set has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanDescriptorSet { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDescriptorSet @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDeviceClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanDeviceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDeviceClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanDevicePrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanDevicePrivate = _GstVulkanDevicePrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDisplayClass { + pub object_class: gst::GstObjectClass, + pub get_handle: Option gpointer>, + pub create_window: Option *mut GstVulkanWindow>, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanDisplayClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDisplayClass @ {self:p}")) + .field("object_class", &self.object_class) + .field("get_handle", &self.get_handle) + .field("create_window", &self.create_window) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanDisplayPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanDisplayPrivate = _GstVulkanDisplayPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanEncodeQueryResult { + pub offset: u32, + pub data_size: u32, + pub status: u32, +} + +impl ::std::fmt::Debug for GstVulkanEncodeQueryResult { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanEncodeQueryResult @ {self:p}")) + .field("offset", &self.offset) + .field("data_size", &self.data_size) + .field("status", &self.status) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanFence { + pub parent: gst::GstMiniObject, + pub device: *mut GstVulkanDevice, + pub cache: *mut GstVulkanFenceCache, + _truncated_record_marker: c_void, + // /*Ignored*/field fence has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanFence { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanFence @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .field("cache", &self.cache) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanFenceCacheClass { + pub parent_class: GstVulkanHandlePoolClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanFenceCacheClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanFenceCacheClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanFormatInfo { + _truncated_record_marker: c_void, + // /*Ignored*/field format has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanFormatInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanFormatInfo @ {self:p}")) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanFullScreenQuadClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanFullScreenQuadClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanFullScreenQuadClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanFullScreenQuadPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanFullScreenQuadPrivate = _GstVulkanFullScreenQuadPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanHandle { + pub parent: gst::GstMiniObject, + pub device: *mut GstVulkanDevice, + pub type_: GstVulkanHandleType, + pub handle: GstVulkanHandleTypedef, + pub notify: GstVulkanHandleDestroyNotify, + pub user_data: gpointer, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanHandle { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanHandle @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .field("type_", &self.type_) + .field("handle", &self.handle) + .field("notify", &self.notify) + .field("user_data", &self.user_data) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanHandlePoolClass { + pub parent: gst::GstObjectClass, + pub alloc: + Option gpointer>, + pub acquire: + Option gpointer>, + pub release: Option, + pub free: Option, + pub _padding: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanHandlePoolClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanHandlePoolClass @ {self:p}")) + .field("parent", &self.parent) + .field("alloc", &self.alloc) + .field("acquire", &self.acquire) + .field("release", &self.release) + .field("free", &self.free) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanImageBufferPoolClass { + pub parent_class: gst::GstBufferPoolClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanImageBufferPoolClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanImageBufferPoolClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanImageBufferPoolPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanImageBufferPoolPrivate = _GstVulkanImageBufferPoolPrivate; + +#[repr(C)] +pub struct GstVulkanImageMemory { + pub parent: gst::GstMemory, + pub device: *mut GstVulkanDevice, + _truncated_record_marker: c_void, + // /*Ignored*/field image has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanImageMemory { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanImageMemory @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanImageMemoryAllocatorClass { + pub parent_class: gst::GstAllocatorClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanImageMemoryAllocatorClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanImageMemoryAllocatorClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanImageView { + pub parent: gst::GstMiniObject, + pub device: *mut GstVulkanDevice, + pub image: *mut GstVulkanImageMemory, + _truncated_record_marker: c_void, + // /*Ignored*/field view has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanImageView { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanImageView @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .field("image", &self.image) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanInstanceClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanInstanceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanInstanceClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanInstancePrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanInstancePrivate = _GstVulkanInstancePrivate; + +#[repr(C)] +pub struct GstVulkanMemory { + pub mem: gst::GstMemory, + pub device: *mut GstVulkanDevice, + _truncated_record_marker: c_void, + // /*Ignored*/field mem_ptr has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanMemory { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanMemory @ {self:p}")) + .field("mem", &self.mem) + .field("device", &self.device) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanMemoryAllocatorClass { + pub parent_class: gst::GstAllocatorClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanMemoryAllocatorClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanMemoryAllocatorClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanOperationClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanOperationClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanOperationClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanOperationPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanOperationPrivate = _GstVulkanOperationPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanPhysicalDeviceClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanPhysicalDeviceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanPhysicalDeviceClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanPhysicalDevicePrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanPhysicalDevicePrivate = _GstVulkanPhysicalDevicePrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanQueueClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanQueueClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanQueueClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanQueueFamilyOps { + pub video: u32, + pub query: gboolean, +} + +impl ::std::fmt::Debug for GstVulkanQueueFamilyOps { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanQueueFamilyOps @ {self:p}")) + .field("video", &self.video) + .field("query", &self.query) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanQueuePrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanQueuePrivate = _GstVulkanQueuePrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanSwapperClass { + pub parent_class: gst::GstObjectClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanSwapperClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanSwapperClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanSwapperPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanSwapperPrivate = _GstVulkanSwapperPrivate; + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanTrash { + pub parent: gst::GstMiniObject, + pub cache: *mut GstVulkanTrashList, + pub fence: *mut GstVulkanFence, + pub notify: GstVulkanTrashNotify, + pub user_data: gpointer, + pub _padding: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanTrash { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanTrash @ {self:p}")) + .field("parent", &self.parent) + .field("cache", &self.cache) + .field("fence", &self.fence) + .field("notify", &self.notify) + .field("user_data", &self.user_data) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanTrashFenceListClass { + pub parent_class: GstVulkanTrashListClass, +} + +impl ::std::fmt::Debug for GstVulkanTrashFenceListClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanTrashFenceListClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanTrashListClass { + pub parent_class: GstVulkanHandlePoolClass, + pub add_func: GstVulkanTrashListAdd, + pub gc_func: GstVulkanTrashListGC, + pub wait_func: GstVulkanTrashListWait, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanTrashListClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanTrashListClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("add_func", &self.add_func) + .field("gc_func", &self.gc_func) + .field("wait_func", &self.wait_func) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanVideoFilterClass { + pub parent_class: gst_base::GstBaseTransformClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanVideoFilterClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanVideoFilterClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanWindowClass { + pub parent_class: gst::GstObjectClass, + pub open: + Option gboolean>, + pub close: Option, + pub get_surface: Option< + unsafe extern "C" fn(*mut GstVulkanWindow, *mut *mut glib::GError) -> vulkan::VkSurfaceKHR, + >, + pub get_presentation_support: + Option gboolean>, + pub set_window_handle: Option, + pub get_surface_dimensions: + Option, + pub handle_events: Option, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanWindowClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanWindowClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("open", &self.open) + .field("close", &self.close) + .field("get_surface", &self.get_surface) + .field("get_presentation_support", &self.get_presentation_support) + .field("set_window_handle", &self.set_window_handle) + .field("get_surface_dimensions", &self.get_surface_dimensions) + .field("handle_events", &self.handle_events) + .finish() + } +} + +#[repr(C)] +pub struct _GstVulkanWindowPrivate { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GstVulkanWindowPrivate = _GstVulkanWindowPrivate; + +// Classes +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanBufferMemoryAllocator { + pub parent: gst::GstAllocator, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanBufferMemoryAllocator { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanBufferMemoryAllocator @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanBufferPool { + pub bufferpool: gst::GstBufferPool, + pub device: *mut GstVulkanDevice, + pub _padding: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanBufferPool { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanBufferPool @ {self:p}")) + .field("bufferpool", &self.bufferpool) + .field("device", &self.device) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanCommandPool { + pub parent: gst::GstObject, + pub queue: *mut GstVulkanQueue, + _truncated_record_marker: c_void, + // /*Ignored*/field pool has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanCommandPool { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanCommandPool @ {self:p}")) + .field("parent", &self.parent) + .field("queue", &self.queue) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDescriptorCache { + pub parent: GstVulkanHandlePool, + pub pool: *mut GstVulkanDescriptorPool, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanDescriptorCache { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDescriptorCache @ {self:p}")) + .field("parent", &self.parent) + .field("pool", &self.pool) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanDescriptorPool { + pub parent: gst::GstObject, + pub device: *mut GstVulkanDevice, + _truncated_record_marker: c_void, + // /*Ignored*/field pool has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanDescriptorPool { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDescriptorPool @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanDevice { + pub parent: gst::GstObject, + pub instance: *mut GstVulkanInstance, + pub physical_device: *mut GstVulkanPhysicalDevice, + _truncated_record_marker: c_void, + // /*Ignored*/field device has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanDevice { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDevice @ {self:p}")) + .field("parent", &self.parent) + .field("instance", &self.instance) + .field("physical_device", &self.physical_device) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDisplay { + pub object: gst::GstObject, + pub type_: GstVulkanDisplayType, + pub instance: *mut GstVulkanInstance, + pub windows: *mut glib::GList, + pub main_context: *mut glib::GMainContext, + pub main_loop: *mut glib::GMainLoop, + pub event_source: *mut glib::GSource, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanDisplay { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDisplay @ {self:p}")) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanFenceCache { + pub parent: GstVulkanHandlePool, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanFenceCache { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanFenceCache @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanFullScreenQuad { + pub parent: gst::GstObject, + pub out_info: gst_video::GstVideoInfo, + pub in_info: gst_video::GstVideoInfo, + pub queue: *mut GstVulkanQueue, + pub render_pass: *mut GstVulkanHandle, + pub pipeline_layout: *mut GstVulkanHandle, + pub graphics_pipeline: *mut GstVulkanHandle, + pub descriptor_set_layout: *mut GstVulkanHandle, + pub descriptor_cache: *mut GstVulkanDescriptorCache, + pub descriptor_set: *mut GstVulkanDescriptorSet, + pub framebuffer: *mut GstVulkanHandle, + pub sampler: *mut GstVulkanHandle, + pub cmd_pool: *mut GstVulkanCommandPool, + pub trash_list: *mut GstVulkanTrashList, + pub last_fence: *mut GstVulkanFence, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanFullScreenQuad { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanFullScreenQuad @ {self:p}")) + .field("parent", &self.parent) + .field("out_info", &self.out_info) + .field("in_info", &self.in_info) + .field("queue", &self.queue) + .field("render_pass", &self.render_pass) + .field("pipeline_layout", &self.pipeline_layout) + .field("graphics_pipeline", &self.graphics_pipeline) + .field("descriptor_set_layout", &self.descriptor_set_layout) + .field("descriptor_cache", &self.descriptor_cache) + .field("descriptor_set", &self.descriptor_set) + .field("framebuffer", &self.framebuffer) + .field("sampler", &self.sampler) + .field("cmd_pool", &self.cmd_pool) + .field("trash_list", &self.trash_list) + .field("last_fence", &self.last_fence) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanHandlePool { + pub parent: gst::GstObject, + pub device: *mut GstVulkanDevice, + pub outstanding: *mut glib::GPtrArray, + pub available: *mut glib::GPtrArray, + pub _padding: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanHandlePool { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanHandlePool @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .field("outstanding", &self.outstanding) + .field("available", &self.available) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanImageBufferPool { + pub bufferpool: gst::GstBufferPool, + pub device: *mut GstVulkanDevice, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanImageBufferPool { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanImageBufferPool @ {self:p}")) + .field("bufferpool", &self.bufferpool) + .field("device", &self.device) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanImageMemoryAllocator { + pub parent: gst::GstAllocator, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanImageMemoryAllocator { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanImageMemoryAllocator @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanInstance { + pub parent: gst::GstObject, + _truncated_record_marker: c_void, + // /*Ignored*/field instance has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanInstance { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanInstance @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanMemoryAllocator { + pub parent: gst::GstAllocator, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanMemoryAllocator { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanMemoryAllocator @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanOperation { + pub parent: gst::GstObject, + pub cmd_buf: *mut GstVulkanCommandBuffer, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanOperation { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanOperation @ {self:p}")) + .field("parent", &self.parent) + .field("cmd_buf", &self.cmd_buf) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanPhysicalDevice { + pub parent: gst::GstObject, + pub instance: *mut GstVulkanInstance, + pub device_index: c_uint, + _truncated_record_marker: c_void, + // /*Ignored*/field device has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanPhysicalDevice { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanPhysicalDevice @ {self:p}")) + .field("parent", &self.parent) + .field("instance", &self.instance) + .field("device_index", &self.device_index) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanQueue { + pub parent: gst::GstObject, + pub device: *mut GstVulkanDevice, + _truncated_record_marker: c_void, + // /*Ignored*/field queue has incomplete type +} + +impl ::std::fmt::Debug for GstVulkanQueue { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanQueue @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanSwapper { + pub parent: gst::GstObject, + pub device: *mut GstVulkanDevice, + pub window: *mut GstVulkanWindow, + pub queue: *mut GstVulkanQueue, + pub cmd_pool: *mut GstVulkanCommandPool, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanSwapper { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanSwapper @ {self:p}")) + .field("parent", &self.parent) + .field("device", &self.device) + .field("window", &self.window) + .field("queue", &self.queue) + .field("cmd_pool", &self.cmd_pool) + .finish() + } +} + +#[repr(C)] +pub struct GstVulkanTrashFenceList { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GstVulkanTrashFenceList { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanTrashFenceList @ {self:p}")) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanTrashList { + pub parent: GstVulkanHandlePool, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanTrashList { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanTrashList @ {self:p}")) + .field("parent", &self.parent) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanVideoFilter { + pub parent: gst_base::GstBaseTransform, + pub instance: *mut GstVulkanInstance, + pub device: *mut GstVulkanDevice, + pub queue: *mut GstVulkanQueue, + pub in_caps: *mut gst::GstCaps, + pub in_info: gst_video::GstVideoInfo, + pub out_caps: *mut gst::GstCaps, + pub out_info: gst_video::GstVideoInfo, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanVideoFilter { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanVideoFilter @ {self:p}")) + .field("parent", &self.parent) + .field("instance", &self.instance) + .field("device", &self.device) + .field("queue", &self.queue) + .field("in_caps", &self.in_caps) + .field("in_info", &self.in_info) + .field("out_caps", &self.out_caps) + .field("out_info", &self.out_info) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanWindow { + pub parent: gst::GstObject, + pub display: *mut GstVulkanDisplay, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanWindow { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanWindow @ {self:p}")) + .finish() + } +} + +#[link(name = "gstvulkan-1.0")] +extern "C" { + + //========================================================================= + // GstVulkanBarrierFlags + //========================================================================= + pub fn gst_vulkan_barrier_flags_get_type() -> GType; + + //========================================================================= + // GstVulkanBarrierType + //========================================================================= + pub fn gst_vulkan_barrier_type_get_type() -> GType; + + //========================================================================= + // GstVulkanError + //========================================================================= + pub fn gst_vulkan_error_get_type() -> GType; + pub fn gst_vulkan_error_quark() -> glib::GQuark; + pub fn gst_vulkan_error_to_g_error( + result: vulkan::VkResult, + error: *mut *mut glib::GError, + format: *const c_char, + ... + ) -> vulkan::VkResult; + + //========================================================================= + // GstVulkanFormatScaling + //========================================================================= + pub fn gst_vulkan_format_scaling_get_type() -> GType; + + //========================================================================= + // GstVulkanHandleType + //========================================================================= + pub fn gst_vulkan_handle_type_get_type() -> GType; + + //========================================================================= + // GstVulkanVideoOperation + //========================================================================= + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_video_operation_get_type() -> GType; + + //========================================================================= + // GstVulkanWindowError + //========================================================================= + pub fn gst_vulkan_window_error_get_type() -> GType; + pub fn gst_vulkan_window_error_quark() -> glib::GQuark; + + //========================================================================= + // GstVulkanDisplayType + //========================================================================= + pub fn gst_vulkan_display_type_get_type() -> GType; + pub fn gst_vulkan_display_type_to_extension_string( + type_: GstVulkanDisplayType, + ) -> *const c_char; + + //========================================================================= + // GstVulkanFormatFlags + //========================================================================= + pub fn gst_vulkan_format_flags_get_type() -> GType; + + //========================================================================= + // GstVulkanBufferMemory + //========================================================================= + pub fn gst_vulkan_buffer_memory_alloc( + device: *mut GstVulkanDevice, + size: size_t, + usage: vulkan::VkBufferUsageFlags, + mem_prop_flags: vulkan::VkMemoryPropertyFlags, + ) -> *mut gst::GstMemory; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_buffer_memory_alloc_with_buffer_info( + device: *mut GstVulkanDevice, + buffer_info: *mut vulkan::VkBufferCreateInfo, + mem_prop_flags: vulkan::VkMemoryPropertyFlags, + ) -> *mut gst::GstMemory; + pub fn gst_vulkan_buffer_memory_init_once(); + pub fn gst_vulkan_buffer_memory_wrapped( + device: *mut GstVulkanDevice, + buffer: vulkan::VkBuffer, + usage: vulkan::VkBufferUsageFlags, + user_data: gpointer, + notify: glib::GDestroyNotify, + ) -> *mut gst::GstMemory; + + //========================================================================= + // GstVulkanCommandBuffer + //========================================================================= + pub fn gst_vulkan_command_buffer_get_type() -> GType; + pub fn gst_vulkan_command_buffer_new_wrapped( + cmd: vulkan::VkCommandBuffer, + level: vulkan::VkCommandBufferLevel, + ) -> *mut GstVulkanCommandBuffer; + pub fn gst_vulkan_command_buffer_ref( + cmd: *mut GstVulkanCommandBuffer, + ) -> *mut GstVulkanCommandBuffer; + + //========================================================================= + // GstVulkanDescriptorSet + //========================================================================= + pub fn gst_vulkan_descriptor_set_get_type() -> GType; + pub fn gst_vulkan_descriptor_set_new_wrapped( + pool: *mut GstVulkanDescriptorPool, + set: vulkan::VkDescriptorSet, + n_layouts: c_uint, + layouts: *mut *mut GstVulkanHandle, + ) -> *mut GstVulkanDescriptorSet; + pub fn gst_vulkan_descriptor_set_ref( + set: *mut GstVulkanDescriptorSet, + ) -> *mut GstVulkanDescriptorSet; + + //========================================================================= + // GstVulkanFence + //========================================================================= + pub fn gst_vulkan_fence_get_type() -> GType; + pub fn gst_vulkan_fence_new( + device: *mut GstVulkanDevice, + error: *mut *mut glib::GError, + ) -> *mut GstVulkanFence; + pub fn gst_vulkan_fence_new_always_signalled( + device: *mut GstVulkanDevice, + ) -> *mut GstVulkanFence; + pub fn gst_vulkan_fence_is_signaled(fence: *mut GstVulkanFence) -> gboolean; + pub fn gst_vulkan_fence_reset(fence: *mut GstVulkanFence); + + //========================================================================= + // GstVulkanHandle + //========================================================================= + pub fn gst_vulkan_handle_get_type() -> GType; + pub fn gst_vulkan_handle_new_wrapped( + device: *mut GstVulkanDevice, + type_: GstVulkanHandleType, + handle: GstVulkanHandleTypedef, + notify: GstVulkanHandleDestroyNotify, + user_data: gpointer, + ) -> *mut GstVulkanHandle; + pub fn gst_vulkan_handle_free_descriptor_set_layout( + handle: *mut GstVulkanHandle, + user_data: gpointer, + ); + pub fn gst_vulkan_handle_free_framebuffer(handle: *mut GstVulkanHandle, user_data: gpointer); + pub fn gst_vulkan_handle_free_pipeline(handle: *mut GstVulkanHandle, user_data: gpointer); + pub fn gst_vulkan_handle_free_pipeline_layout( + handle: *mut GstVulkanHandle, + user_data: gpointer, + ); + pub fn gst_vulkan_handle_free_render_pass(handle: *mut GstVulkanHandle, user_data: gpointer); + pub fn gst_vulkan_handle_free_sampler(handle: *mut GstVulkanHandle, user_data: gpointer); + pub fn gst_vulkan_handle_free_shader(handle: *mut GstVulkanHandle, user_data: gpointer); + pub fn gst_vulkan_handle_ref(handle: *mut GstVulkanHandle) -> *mut GstVulkanHandle; + pub fn gst_vulkan_handle_context_query( + element: *mut gst::GstElement, + query: *mut gst::GstQuery, + display: *mut GstVulkanDisplay, + instance: *mut GstVulkanInstance, + device: *mut GstVulkanDevice, + ) -> gboolean; + pub fn gst_vulkan_handle_set_context( + element: *mut gst::GstElement, + context: *mut gst::GstContext, + display: *mut *mut GstVulkanDisplay, + instance: *mut *mut GstVulkanInstance, + ) -> gboolean; + + //========================================================================= + // GstVulkanImageMemory + //========================================================================= + pub fn gst_vulkan_image_memory_add_view( + image: *mut GstVulkanImageMemory, + view: *mut GstVulkanImageView, + ); + pub fn gst_vulkan_image_memory_find_view( + image: *mut GstVulkanImageMemory, + find_func: GstVulkanImageMemoryFindViewFunc, + user_data: gpointer, + ) -> *mut GstVulkanImageView; + pub fn gst_vulkan_image_memory_get_height(image: *mut GstVulkanImageMemory) -> u32; + pub fn gst_vulkan_image_memory_get_width(image: *mut GstVulkanImageMemory) -> u32; + pub fn gst_vulkan_image_memory_init( + mem: *mut GstVulkanImageMemory, + allocator: *mut gst::GstAllocator, + parent: *mut gst::GstMemory, + device: *mut GstVulkanDevice, + format: vulkan::VkFormat, + usage: vulkan::VkImageUsageFlags, + initial_layout: vulkan::VkImageLayout, + params: *mut gst::GstAllocationParams, + size: size_t, + user_data: gpointer, + notify: glib::GDestroyNotify, + ) -> gboolean; + pub fn gst_vulkan_image_memory_alloc( + device: *mut GstVulkanDevice, + format: vulkan::VkFormat, + width: size_t, + height: size_t, + tiling: vulkan::VkImageTiling, + usage: vulkan::VkImageUsageFlags, + mem_prop_flags: vulkan::VkMemoryPropertyFlags, + ) -> *mut gst::GstMemory; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_image_memory_alloc_with_image_info( + device: *mut GstVulkanDevice, + image_info: *mut vulkan::VkImageCreateInfo, + mem_prop_flags: vulkan::VkMemoryPropertyFlags, + ) -> *mut gst::GstMemory; + pub fn gst_vulkan_image_memory_init_once(); + pub fn gst_vulkan_image_memory_wrapped( + device: *mut GstVulkanDevice, + image: vulkan::VkImage, + format: vulkan::VkFormat, + width: size_t, + height: size_t, + tiling: vulkan::VkImageTiling, + usage: vulkan::VkImageUsageFlags, + user_data: gpointer, + notify: glib::GDestroyNotify, + ) -> *mut gst::GstMemory; + + //========================================================================= + // GstVulkanImageView + //========================================================================= + pub fn gst_vulkan_image_view_get_type() -> GType; + pub fn gst_vulkan_image_view_new( + image: *mut GstVulkanImageMemory, + create_info: *const vulkan::VkImageViewCreateInfo, + ) -> *mut GstVulkanImageView; + pub fn gst_vulkan_image_view_ref(trash: *mut GstVulkanImageView) -> *mut GstVulkanImageView; + + //========================================================================= + // GstVulkanMemory + //========================================================================= + pub fn gst_vulkan_memory_alloc( + device: *mut GstVulkanDevice, + memory_type_index: u32, + params: *mut gst::GstAllocationParams, + size: size_t, + mem_prop_flags: vulkan::VkMemoryPropertyFlags, + ) -> *mut gst::GstMemory; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_memory_find_memory_type_index_with_requirements( + device: *mut GstVulkanDevice, + req: *mut vulkan::VkMemoryRequirements, + properties: vulkan::VkMemoryPropertyFlags, + type_index: *mut u32, + ) -> gboolean; + pub fn gst_vulkan_memory_heap_flags_to_string( + prop_bits: vulkan::VkMemoryHeapFlags, + ) -> *mut c_char; + pub fn gst_vulkan_memory_init_once(); + pub fn gst_vulkan_memory_property_flags_to_string( + prop_bits: vulkan::VkMemoryPropertyFlags, + ) -> *mut c_char; + + //========================================================================= + // GstVulkanTrash + //========================================================================= + pub fn gst_vulkan_trash_get_type() -> GType; + pub fn gst_vulkan_trash_new( + fence: *mut GstVulkanFence, + notify: GstVulkanTrashNotify, + user_data: gpointer, + ) -> *mut GstVulkanTrash; + pub fn gst_vulkan_trash_new_free_semaphore( + fence: *mut GstVulkanFence, + semaphore: vulkan::VkSemaphore, + ) -> *mut GstVulkanTrash; + pub fn gst_vulkan_trash_ref(trash: *mut GstVulkanTrash) -> *mut GstVulkanTrash; + pub fn gst_vulkan_trash_mini_object_unref(device: *mut GstVulkanDevice, user_data: gpointer); + pub fn gst_vulkan_trash_object_unref(device: *mut GstVulkanDevice, user_data: gpointer); + + //========================================================================= + // GstVulkanBufferMemoryAllocator + //========================================================================= + pub fn gst_vulkan_buffer_memory_allocator_get_type() -> GType; + + //========================================================================= + // GstVulkanBufferPool + //========================================================================= + pub fn gst_vulkan_buffer_pool_get_type() -> GType; + pub fn gst_vulkan_buffer_pool_new(device: *mut GstVulkanDevice) -> *mut gst::GstBufferPool; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_buffer_pool_config_set_allocation_params( + config: *mut gst::GstStructure, + usage: vulkan::VkBufferUsageFlags, + mem_properties: vulkan::VkMemoryPropertyFlags, + ); + + //========================================================================= + // GstVulkanCommandPool + //========================================================================= + pub fn gst_vulkan_command_pool_get_type() -> GType; + pub fn gst_vulkan_command_pool_create( + pool: *mut GstVulkanCommandPool, + error: *mut *mut glib::GError, + ) -> *mut GstVulkanCommandBuffer; + pub fn gst_vulkan_command_pool_get_queue( + pool: *mut GstVulkanCommandPool, + ) -> *mut GstVulkanQueue; + pub fn gst_vulkan_command_pool_lock(pool: *mut GstVulkanCommandPool); + pub fn gst_vulkan_command_pool_unlock(pool: *mut GstVulkanCommandPool); + + //========================================================================= + // GstVulkanDescriptorCache + //========================================================================= + pub fn gst_vulkan_descriptor_cache_get_type() -> GType; + pub fn gst_vulkan_descriptor_cache_new( + pool: *mut GstVulkanDescriptorPool, + n_layouts: c_uint, + layouts: *mut *mut GstVulkanHandle, + ) -> *mut GstVulkanDescriptorCache; + pub fn gst_vulkan_descriptor_cache_acquire( + cache: *mut GstVulkanDescriptorCache, + error: *mut *mut glib::GError, + ) -> *mut GstVulkanDescriptorSet; + + //========================================================================= + // GstVulkanDescriptorPool + //========================================================================= + pub fn gst_vulkan_descriptor_pool_get_type() -> GType; + pub fn gst_vulkan_descriptor_pool_new_wrapped( + device: *mut GstVulkanDevice, + pool: vulkan::VkDescriptorPool, + max_sets: size_t, + ) -> *mut GstVulkanDescriptorPool; + pub fn gst_vulkan_descriptor_pool_create( + pool: *mut GstVulkanDescriptorPool, + n_layouts: c_uint, + layouts: *mut *mut GstVulkanHandle, + error: *mut *mut glib::GError, + ) -> *mut GstVulkanDescriptorSet; + pub fn gst_vulkan_descriptor_pool_get_device( + pool: *mut GstVulkanDescriptorPool, + ) -> *mut GstVulkanDevice; + pub fn gst_vulkan_descriptor_pool_get_max_sets(pool: *mut GstVulkanDescriptorPool) -> size_t; + + //========================================================================= + // GstVulkanDevice + //========================================================================= + pub fn gst_vulkan_device_get_type() -> GType; + pub fn gst_vulkan_device_new( + physical_device: *mut GstVulkanPhysicalDevice, + ) -> *mut GstVulkanDevice; + pub fn gst_vulkan_device_new_with_index( + instance: *mut GstVulkanInstance, + device_index: c_uint, + ) -> *mut GstVulkanDevice; + pub fn gst_vulkan_device_handle_context_query( + element: *mut gst::GstElement, + query: *mut gst::GstQuery, + device: *mut GstVulkanDevice, + ) -> gboolean; + pub fn gst_vulkan_device_run_context_query( + element: *mut gst::GstElement, + device: *mut *mut GstVulkanDevice, + ) -> gboolean; + pub fn gst_vulkan_device_create_fence( + device: *mut GstVulkanDevice, + error: *mut *mut glib::GError, + ) -> *mut GstVulkanFence; + pub fn gst_vulkan_device_disable_extension( + device: *mut GstVulkanDevice, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_device_enable_extension( + device: *mut GstVulkanDevice, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_device_enable_layer( + device: *mut GstVulkanDevice, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_device_foreach_queue( + device: *mut GstVulkanDevice, + func: GstVulkanDeviceForEachQueueFunc, + user_data: gpointer, + ); + pub fn gst_vulkan_device_get_instance(device: *mut GstVulkanDevice) -> *mut GstVulkanInstance; + pub fn gst_vulkan_device_get_physical_device( + device: *mut GstVulkanDevice, + ) -> vulkan::VkPhysicalDevice; + pub fn gst_vulkan_device_get_proc_address( + device: *mut GstVulkanDevice, + name: *const c_char, + ) -> gpointer; + pub fn gst_vulkan_device_get_queue( + device: *mut GstVulkanDevice, + queue_family: u32, + queue_i: u32, + ) -> *mut GstVulkanQueue; + pub fn gst_vulkan_device_is_extension_enabled( + device: *mut GstVulkanDevice, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_device_is_layer_enabled( + device: *mut GstVulkanDevice, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_device_open( + device: *mut GstVulkanDevice, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_device_queue_family_indices( + device: *mut GstVulkanDevice, + ) -> *mut glib::GArray; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_device_select_queue( + device: *mut GstVulkanDevice, + expected_flags: vulkan::VkQueueFlagBits, + ) -> *mut GstVulkanQueue; + + //========================================================================= + // GstVulkanDisplay + //========================================================================= + pub fn gst_vulkan_display_get_type() -> GType; + pub fn gst_vulkan_display_new(instance: *mut GstVulkanInstance) -> *mut GstVulkanDisplay; + pub fn gst_vulkan_display_new_with_type( + instance: *mut GstVulkanInstance, + type_: GstVulkanDisplayType, + ) -> *mut GstVulkanDisplay; + pub fn gst_vulkan_display_choose_type(instance: *mut GstVulkanInstance) + -> GstVulkanDisplayType; + pub fn gst_vulkan_display_handle_context_query( + element: *mut gst::GstElement, + query: *mut gst::GstQuery, + display: *mut GstVulkanDisplay, + ) -> gboolean; + pub fn gst_vulkan_display_run_context_query( + element: *mut gst::GstElement, + display: *mut *mut GstVulkanDisplay, + ) -> gboolean; + pub fn gst_vulkan_display_create_window(display: *mut GstVulkanDisplay) + -> *mut GstVulkanWindow; + pub fn gst_vulkan_display_find_window( + display: *mut GstVulkanDisplay, + data: gpointer, + compare_func: glib::GCompareFunc, + ) -> *mut GstVulkanWindow; + pub fn gst_vulkan_display_get_handle(display: *mut GstVulkanDisplay) -> gpointer; + pub fn gst_vulkan_display_get_handle_type( + display: *mut GstVulkanDisplay, + ) -> GstVulkanDisplayType; + pub fn gst_vulkan_display_remove_window( + display: *mut GstVulkanDisplay, + window: *mut GstVulkanWindow, + ) -> gboolean; + + //========================================================================= + // GstVulkanFenceCache + //========================================================================= + pub fn gst_vulkan_fence_cache_get_type() -> GType; + pub fn gst_vulkan_fence_cache_new(device: *mut GstVulkanDevice) -> *mut GstVulkanFenceCache; + + //========================================================================= + // GstVulkanFullScreenQuad + //========================================================================= + pub fn gst_vulkan_full_screen_quad_get_type() -> GType; + pub fn gst_vulkan_full_screen_quad_new( + queue: *mut GstVulkanQueue, + ) -> *mut GstVulkanFullScreenQuad; + pub fn gst_vulkan_full_screen_quad_draw( + self_: *mut GstVulkanFullScreenQuad, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v1_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + pub fn gst_vulkan_full_screen_quad_enable_blend( + self_: *mut GstVulkanFullScreenQuad, + enable_blend: gboolean, + ); + #[cfg(feature = "v1_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + pub fn gst_vulkan_full_screen_quad_enable_clear( + self_: *mut GstVulkanFullScreenQuad, + enable_clear: gboolean, + ); + pub fn gst_vulkan_full_screen_quad_fill_command_buffer( + self_: *mut GstVulkanFullScreenQuad, + cmd: *mut GstVulkanCommandBuffer, + fence: *mut GstVulkanFence, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_full_screen_quad_get_last_fence( + self_: *mut GstVulkanFullScreenQuad, + ) -> *mut GstVulkanFence; + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + pub fn gst_vulkan_full_screen_quad_get_queue( + self_: *mut GstVulkanFullScreenQuad, + ) -> *mut GstVulkanQueue; + pub fn gst_vulkan_full_screen_quad_prepare_draw( + self_: *mut GstVulkanFullScreenQuad, + fence: *mut GstVulkanFence, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v1_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + pub fn gst_vulkan_full_screen_quad_set_blend_factors( + self_: *mut GstVulkanFullScreenQuad, + src_blend_factor: vulkan::VkBlendFactor, + dst_blend_factor: vulkan::VkBlendFactor, + src_alpha_blend_factor: vulkan::VkBlendFactor, + dst_alpha_blend_factor: vulkan::VkBlendFactor, + ); + #[cfg(feature = "v1_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + pub fn gst_vulkan_full_screen_quad_set_blend_operation( + self_: *mut GstVulkanFullScreenQuad, + colour_blend_op: vulkan::VkBlendOp, + alpha_blend_op: vulkan::VkBlendOp, + ); + pub fn gst_vulkan_full_screen_quad_set_index_buffer( + self_: *mut GstVulkanFullScreenQuad, + indices: *mut gst::GstMemory, + n_indices: size_t, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_full_screen_quad_set_info( + self_: *mut GstVulkanFullScreenQuad, + in_info: *const gst_video::GstVideoInfo, + out_info: *const gst_video::GstVideoInfo, + ) -> gboolean; + pub fn gst_vulkan_full_screen_quad_set_input_buffer( + self_: *mut GstVulkanFullScreenQuad, + buffer: *mut gst::GstBuffer, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_full_screen_quad_set_output_buffer( + self_: *mut GstVulkanFullScreenQuad, + buffer: *mut gst::GstBuffer, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_full_screen_quad_set_shaders( + self_: *mut GstVulkanFullScreenQuad, + vert: *mut GstVulkanHandle, + frag: *mut GstVulkanHandle, + ) -> gboolean; + pub fn gst_vulkan_full_screen_quad_set_uniform_buffer( + self_: *mut GstVulkanFullScreenQuad, + uniforms: *mut gst::GstMemory, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_full_screen_quad_set_vertex_buffer( + self_: *mut GstVulkanFullScreenQuad, + vertices: *mut gst::GstMemory, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_full_screen_quad_submit( + self_: *mut GstVulkanFullScreenQuad, + cmd: *mut GstVulkanCommandBuffer, + fence: *mut GstVulkanFence, + error: *mut *mut glib::GError, + ) -> gboolean; + + //========================================================================= + // GstVulkanHandlePool + //========================================================================= + pub fn gst_vulkan_handle_pool_get_type() -> GType; + pub fn gst_vulkan_handle_pool_acquire( + pool: *mut GstVulkanHandlePool, + error: *mut *mut glib::GError, + ) -> gpointer; + pub fn gst_vulkan_handle_pool_alloc( + pool: *mut GstVulkanHandlePool, + error: *mut *mut glib::GError, + ) -> gpointer; + pub fn gst_vulkan_handle_pool_release(pool: *mut GstVulkanHandlePool, handle: gpointer); + + //========================================================================= + // GstVulkanImageBufferPool + //========================================================================= + pub fn gst_vulkan_image_buffer_pool_get_type() -> GType; + pub fn gst_vulkan_image_buffer_pool_new( + device: *mut GstVulkanDevice, + ) -> *mut gst::GstBufferPool; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_image_buffer_pool_config_set_allocation_params( + config: *mut gst::GstStructure, + usage: vulkan::VkImageUsageFlags, + mem_properties: vulkan::VkMemoryPropertyFlags, + initial_layout: vulkan::VkImageLayout, + initial_access: u64, + ); + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_image_buffer_pool_config_set_decode_caps( + config: *mut gst::GstStructure, + caps: *mut gst::GstCaps, + ); + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + pub fn gst_vulkan_image_buffer_pool_config_set_encode_caps( + config: *mut gst::GstStructure, + caps: *mut gst::GstCaps, + ); + + //========================================================================= + // GstVulkanImageMemoryAllocator + //========================================================================= + pub fn gst_vulkan_image_memory_allocator_get_type() -> GType; + + //========================================================================= + // GstVulkanInstance + //========================================================================= + pub fn gst_vulkan_instance_get_type() -> GType; + pub fn gst_vulkan_instance_new() -> *mut GstVulkanInstance; + pub fn gst_vulkan_instance_handle_context_query( + element: *mut gst::GstElement, + query: *mut gst::GstQuery, + instance: *mut GstVulkanInstance, + ) -> gboolean; + pub fn gst_vulkan_instance_run_context_query( + element: *mut gst::GstElement, + instance: *mut *mut GstVulkanInstance, + ) -> gboolean; + pub fn gst_vulkan_instance_check_version( + instance: *mut GstVulkanInstance, + major: c_uint, + minor: c_uint, + patch: c_uint, + ) -> gboolean; + pub fn gst_vulkan_instance_create_device( + instance: *mut GstVulkanInstance, + error: *mut *mut glib::GError, + ) -> *mut GstVulkanDevice; + pub fn gst_vulkan_instance_disable_extension( + instance: *mut GstVulkanInstance, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_instance_enable_extension( + instance: *mut GstVulkanInstance, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_instance_enable_layer( + instance: *mut GstVulkanInstance, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_instance_fill_info( + instance: *mut GstVulkanInstance, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_instance_get_extension_info( + instance: *mut GstVulkanInstance, + name: *const c_char, + spec_version: *mut u32, + ) -> gboolean; + pub fn gst_vulkan_instance_get_layer_info( + instance: *mut GstVulkanInstance, + name: *const c_char, + description: *mut *mut c_char, + spec_version: *mut u32, + implementation_version: *mut u32, + ) -> gboolean; + pub fn gst_vulkan_instance_get_proc_address( + instance: *mut GstVulkanInstance, + name: *const c_char, + ) -> gpointer; + pub fn gst_vulkan_instance_get_version( + instance: *mut GstVulkanInstance, + major: *mut c_uint, + minor: *mut c_uint, + patch: *mut c_uint, + ); + pub fn gst_vulkan_instance_is_extension_enabled( + instance: *mut GstVulkanInstance, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_instance_is_layer_enabled( + instance: *mut GstVulkanInstance, + name: *const c_char, + ) -> gboolean; + pub fn gst_vulkan_instance_open( + instance: *mut GstVulkanInstance, + error: *mut *mut glib::GError, + ) -> gboolean; + + //========================================================================= + // GstVulkanMemoryAllocator + //========================================================================= + pub fn gst_vulkan_memory_allocator_get_type() -> GType; + + //========================================================================= + // GstVulkanOperation + //========================================================================= + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_get_type() -> GType; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_new(cmd_pool: *mut GstVulkanCommandPool) + -> *mut GstVulkanOperation; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_add_dependency_frame( + self_: *mut GstVulkanOperation, + frame: *mut gst::GstBuffer, + wait_stage: u64, + signal_stage: u64, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_add_extra_image_barriers( + self_: *mut GstVulkanOperation, + extra_barriers: *mut glib::GArray, + ); + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_add_frame_barrier( + self_: *mut GstVulkanOperation, + frame: *mut gst::GstBuffer, + dst_stage: u64, + new_access: u64, + new_layout: vulkan::VkImageLayout, + new_queue: *mut GstVulkanQueue, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_begin( + self_: *mut GstVulkanOperation, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_begin_query(self_: *mut GstVulkanOperation, id: u32) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_discard_dependencies(self_: *mut GstVulkanOperation); + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_enable_query( + self_: *mut GstVulkanOperation, + query_type: u32, + n_queries: c_uint, + pnext: gpointer, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_end( + self_: *mut GstVulkanOperation, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_end_query(self_: *mut GstVulkanOperation, id: u32) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_get_query( + self_: *mut GstVulkanOperation, + data: *mut gpointer, + error: *mut *mut glib::GError, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_new_extra_image_barriers( + self_: *mut GstVulkanOperation, + ) -> *mut glib::GArray; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_pipeline_barrier2( + self_: *mut GstVulkanOperation, + dependency_info: gpointer, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_reset(self_: *mut GstVulkanOperation); + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_retrieve_image_barriers( + self_: *mut GstVulkanOperation, + ) -> *mut glib::GArray; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_update_frame( + self_: *mut GstVulkanOperation, + frame: *mut gst::GstBuffer, + dst_stage: u64, + new_access: u64, + new_layout: vulkan::VkImageLayout, + new_queue: *mut GstVulkanQueue, + ); + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_use_sync2(self_: *mut GstVulkanOperation) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_operation_wait(self_: *mut GstVulkanOperation) -> gboolean; + + //========================================================================= + // GstVulkanPhysicalDevice + //========================================================================= + pub fn gst_vulkan_physical_device_get_type() -> GType; + pub fn gst_vulkan_physical_device_new( + instance: *mut GstVulkanInstance, + device_index: c_uint, + ) -> *mut GstVulkanPhysicalDevice; + pub fn gst_vulkan_physical_device_type_to_string( + type_: vulkan::VkPhysicalDeviceType, + ) -> *const c_char; + pub fn gst_vulkan_physical_device_get_extension_info( + device: *mut GstVulkanPhysicalDevice, + name: *const c_char, + spec_version: *mut u32, + ) -> gboolean; + pub fn gst_vulkan_physical_device_get_handle( + device: *mut GstVulkanPhysicalDevice, + ) -> vulkan::VkPhysicalDevice; + pub fn gst_vulkan_physical_device_get_instance( + device: *mut GstVulkanPhysicalDevice, + ) -> *mut GstVulkanInstance; + pub fn gst_vulkan_physical_device_get_layer_info( + device: *mut GstVulkanPhysicalDevice, + name: *const c_char, + description: *mut *mut c_char, + spec_version: *mut u32, + implementation_version: *mut u32, + ) -> gboolean; + + //========================================================================= + // GstVulkanQueue + //========================================================================= + pub fn gst_vulkan_queue_get_type() -> GType; + pub fn gst_vulkan_queue_flags_to_string(queue_bits: vulkan::VkQueueFlags) -> *mut c_char; + pub fn gst_vulkan_queue_handle_context_query( + element: *mut gst::GstElement, + query: *mut gst::GstQuery, + queue: *mut GstVulkanQueue, + ) -> gboolean; + pub fn gst_vulkan_queue_run_context_query( + element: *mut gst::GstElement, + queue: *mut *mut GstVulkanQueue, + ) -> gboolean; + pub fn gst_vulkan_queue_create_command_pool( + queue: *mut GstVulkanQueue, + error: *mut *mut glib::GError, + ) -> *mut GstVulkanCommandPool; + pub fn gst_vulkan_queue_get_device(queue: *mut GstVulkanQueue) -> *mut GstVulkanDevice; + pub fn gst_vulkan_queue_submit_lock(queue: *mut GstVulkanQueue); + pub fn gst_vulkan_queue_submit_unlock(queue: *mut GstVulkanQueue); + + //========================================================================= + // GstVulkanSwapper + //========================================================================= + pub fn gst_vulkan_swapper_get_type() -> GType; + pub fn gst_vulkan_swapper_new( + device: *mut GstVulkanDevice, + window: *mut GstVulkanWindow, + ) -> *mut GstVulkanSwapper; + pub fn gst_vulkan_swapper_choose_queue( + swapper: *mut GstVulkanSwapper, + available_queue: *mut GstVulkanQueue, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_swapper_get_supported_caps( + swapper: *mut GstVulkanSwapper, + error: *mut *mut glib::GError, + ) -> *mut gst::GstCaps; + pub fn gst_vulkan_swapper_get_surface_rectangles( + swapper: *mut GstVulkanSwapper, + input_image: *mut gst_video::GstVideoRectangle, + surface_location: *mut gst_video::GstVideoRectangle, + display_rect: *mut gst_video::GstVideoRectangle, + ); + pub fn gst_vulkan_swapper_render_buffer( + swapper: *mut GstVulkanSwapper, + buffer: *mut gst::GstBuffer, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_swapper_set_caps( + swapper: *mut GstVulkanSwapper, + caps: *mut gst::GstCaps, + error: *mut *mut glib::GError, + ) -> gboolean; + + //========================================================================= + // GstVulkanTrashFenceList + //========================================================================= + pub fn gst_vulkan_trash_fence_list_get_type() -> GType; + pub fn gst_vulkan_trash_fence_list_new() -> *mut GstVulkanTrashList; + + //========================================================================= + // GstVulkanTrashList + //========================================================================= + pub fn gst_vulkan_trash_list_get_type() -> GType; + pub fn gst_vulkan_trash_list_acquire( + trash_list: *mut GstVulkanTrashList, + fence: *mut GstVulkanFence, + notify: GstVulkanTrashNotify, + user_data: gpointer, + ) -> *mut GstVulkanTrash; + pub fn gst_vulkan_trash_list_add( + trash_list: *mut GstVulkanTrashList, + trash: *mut GstVulkanTrash, + ) -> gboolean; + pub fn gst_vulkan_trash_list_gc(trash_list: *mut GstVulkanTrashList); + pub fn gst_vulkan_trash_list_wait( + trash_list: *mut GstVulkanTrashList, + timeout: u64, + ) -> gboolean; + + //========================================================================= + // GstVulkanVideoFilter + //========================================================================= + pub fn gst_vulkan_video_filter_get_type() -> GType; + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + pub fn gst_vulkan_video_filter_get_device( + filter: *mut GstVulkanVideoFilter, + ) -> *mut GstVulkanDevice; + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + pub fn gst_vulkan_video_filter_get_instance( + filter: *mut GstVulkanVideoFilter, + ) -> *mut GstVulkanInstance; + #[cfg(feature = "v1_26")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] + pub fn gst_vulkan_video_filter_get_queue( + filter: *mut GstVulkanVideoFilter, + ) -> *mut GstVulkanQueue; + + //========================================================================= + // GstVulkanWindow + //========================================================================= + pub fn gst_vulkan_window_get_type() -> GType; + pub fn gst_vulkan_window_new(display: *mut GstVulkanDisplay) -> *mut GstVulkanWindow; + pub fn gst_vulkan_window_close(window: *mut GstVulkanWindow); + pub fn gst_vulkan_window_get_display(window: *mut GstVulkanWindow) -> *mut GstVulkanDisplay; + pub fn gst_vulkan_window_get_presentation_support( + window: *mut GstVulkanWindow, + device: *mut GstVulkanDevice, + queue_family_idx: u32, + ) -> gboolean; + pub fn gst_vulkan_window_get_surface( + window: *mut GstVulkanWindow, + error: *mut *mut glib::GError, + ) -> vulkan::VkSurfaceKHR; + pub fn gst_vulkan_window_get_surface_dimensions( + window: *mut GstVulkanWindow, + width: *mut c_uint, + height: *mut c_uint, + ); + pub fn gst_vulkan_window_handle_events(window: *mut GstVulkanWindow, handle_events: gboolean); + pub fn gst_vulkan_window_open( + window: *mut GstVulkanWindow, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_vulkan_window_redraw(window: *mut GstVulkanWindow); + pub fn gst_vulkan_window_resize(window: *mut GstVulkanWindow, width: c_int, height: c_int); + pub fn gst_vulkan_window_send_key_event( + window: *mut GstVulkanWindow, + event_type: *const c_char, + key_str: *const c_char, + ); + pub fn gst_vulkan_window_send_mouse_event( + window: *mut GstVulkanWindow, + event_type: *const c_char, + button: c_int, + posx: c_double, + posy: c_double, + ); + pub fn gst_vulkan_window_set_window_handle(window: *mut GstVulkanWindow, handle: uintptr_t); + + //========================================================================= + // Other functions + //========================================================================= + pub fn gst_context_get_vulkan_device( + context: *mut gst::GstContext, + device: *mut *mut GstVulkanDevice, + ) -> gboolean; + pub fn gst_context_get_vulkan_display( + context: *mut gst::GstContext, + display: *mut *mut GstVulkanDisplay, + ) -> gboolean; + pub fn gst_context_get_vulkan_instance( + context: *mut gst::GstContext, + instance: *mut *mut GstVulkanInstance, + ) -> gboolean; + pub fn gst_context_get_vulkan_queue( + context: *mut gst::GstContext, + queue: *mut *mut GstVulkanQueue, + ) -> gboolean; + pub fn gst_context_set_vulkan_device( + context: *mut gst::GstContext, + device: *mut GstVulkanDevice, + ); + pub fn gst_context_set_vulkan_display( + context: *mut gst::GstContext, + display: *mut GstVulkanDisplay, + ); + pub fn gst_context_set_vulkan_instance( + context: *mut gst::GstContext, + instance: *mut GstVulkanInstance, + ); + pub fn gst_context_set_vulkan_queue(context: *mut gst::GstContext, queue: *mut GstVulkanQueue); + pub fn gst_is_vulkan_buffer_memory(mem: *mut gst::GstMemory) -> gboolean; + pub fn gst_is_vulkan_image_memory(mem: *mut gst::GstMemory) -> gboolean; + pub fn gst_is_vulkan_memory(mem: *mut gst::GstMemory) -> gboolean; + pub fn gst_vulkan_create_shader( + device: *mut GstVulkanDevice, + code: *const c_char, + size: size_t, + error: *mut *mut glib::GError, + ) -> *mut GstVulkanHandle; + pub fn gst_vulkan_ensure_element_data( + element: *mut gst::GstElement, + display_ptr: *mut *mut GstVulkanDisplay, + instance_ptr: *mut *mut GstVulkanInstance, + ) -> gboolean; + pub fn gst_vulkan_format_from_video_info( + v_info: *mut gst_video::GstVideoInfo, + plane: c_uint, + ) -> vulkan::VkFormat; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_format_from_video_info_2( + physical_device: *mut GstVulkanPhysicalDevice, + info: *mut gst_video::GstVideoInfo, + tiling: vulkan::VkImageTiling, + no_multiplane: gboolean, + requested_usage: vulkan::VkImageUsageFlags, + fmts: *mut [vulkan::VkFormat; 4], + n_imgs: *mut c_int, + usage: *mut vulkan::VkImageUsageFlags, + ) -> gboolean; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_format_get_aspect(format: vulkan::VkFormat) -> c_uint; + pub fn gst_vulkan_format_get_info(format: vulkan::VkFormat) -> *const GstVulkanFormatInfo; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_format_to_video_format( + vk_format: vulkan::VkFormat, + ) -> gst_video::GstVideoFormat; + pub fn gst_vulkan_get_or_create_image_view( + image: *mut GstVulkanImageMemory, + ) -> *mut GstVulkanImageView; + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + pub fn gst_vulkan_get_or_create_image_view_with_info( + image: *mut GstVulkanImageMemory, + create_info: *mut vulkan::VkImageViewCreateInfo, + ) -> *mut GstVulkanImageView; + pub fn gst_vulkan_global_context_query( + element: *mut gst::GstElement, + context_type: *const c_char, + ); + pub fn gst_vulkan_local_context_query( + element: *mut gst::GstElement, + context_type: *const c_char, + ) -> *mut gst::GstQuery; + #[cfg(feature = "v1_20")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] + pub fn gst_vulkan_present_mode_to_string( + present_mode: vulkan::VkPresentModeKHR, + ) -> *const c_char; + #[cfg(feature = "v1_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + pub fn gst_vulkan_result_to_string(result: vulkan::VkResult) -> *const c_char; + pub fn gst_vulkan_run_query( + element: *mut gst::GstElement, + query: *mut gst::GstQuery, + direction: gst::GstPadDirection, + ) -> gboolean; + pub fn gst_vulkan_sample_count_flags_to_string( + sample_count_bits: vulkan::VkSampleCountFlags, + ) -> *mut c_char; + +} diff --git a/gstreamer-vulkan/sys/src/manual.rs b/gstreamer-vulkan/sys/src/manual.rs new file mode 100644 index 000000000..913c4d6d6 --- /dev/null +++ b/gstreamer-vulkan/sys/src/manual.rs @@ -0,0 +1,31 @@ +pub mod vulkan { + pub use ash::vk::BlendFactor as VkBlendFactor; + pub use ash::vk::BlendOp as VkBlendOp; + pub use ash::vk::Buffer as VkBuffer; + pub use ash::vk::BufferCreateInfo as VkBufferCreateInfo; + pub use ash::vk::BufferUsageFlags as VkBufferUsageFlags; + pub use ash::vk::CommandBuffer as VkCommandBuffer; + pub use ash::vk::CommandBufferLevel as VkCommandBufferLevel; + pub use ash::vk::DescriptorPool as VkDescriptorPool; + pub use ash::vk::DescriptorSet as VkDescriptorSet; + pub use ash::vk::Format as VkFormat; + pub use ash::vk::Image as VkImage; + pub use ash::vk::ImageCreateInfo as VkImageCreateInfo; + pub use ash::vk::ImageLayout as VkImageLayout; + pub use ash::vk::ImageTiling as VkImageTiling; + pub use ash::vk::ImageUsageFlags as VkImageUsageFlags; + pub use ash::vk::ImageViewCreateInfo as VkImageViewCreateInfo; + pub use ash::vk::MemoryHeapFlags as VkMemoryHeapFlags; + pub use ash::vk::MemoryPropertyFlags as VkMemoryPropertyFlags; + pub use ash::vk::MemoryRequirements as VkMemoryRequirements; + pub use ash::vk::PhysicalDevice as VkPhysicalDevice; + pub use ash::vk::PhysicalDeviceType as VkPhysicalDeviceType; + pub use ash::vk::PresentModeKHR as VkPresentModeKHR; + pub use ash::vk::Queue as VkQueue; + pub use ash::vk::QueueFlags as VkQueueFlags; + pub type VkQueueFlagBits = u32; + pub use ash::vk::Result as VkResult; + pub use ash::vk::SampleCountFlags as VkSampleCountFlags; + pub use ash::vk::Semaphore as VkSemaphore; + pub use ash::vk::SurfaceKHR as VkSurfaceKHR; +} diff --git a/gstreamer-vulkan/sys/tests/abi.rs b/gstreamer-vulkan/sys/tests/abi.rs new file mode 100644 index 000000000..c8b8e4cc1 --- /dev/null +++ b/gstreamer-vulkan/sys/tests/abi.rs @@ -0,0 +1,633 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#![cfg(unix)] + +use gstreamer_vulkan_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["gstreamer-vulkan-1.0"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec, +} + +impl Compiler { + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result, Box> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "GstVulkanBarrierFlags", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanBarrierType", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanBufferMemoryAllocator", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanBufferMemoryAllocatorClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanBufferPool", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanBufferPoolClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanCommandPoolClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanDescriptorCache", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanDescriptorCacheClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanDescriptorPoolClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanDeviceClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanDisplay", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanDisplayClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanDisplayType", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanEncodeQueryResult", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanError", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanFenceCache", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanFenceCacheClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanFormatFlags", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanFormatScaling", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanFullScreenQuad", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanFullScreenQuadClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanHandle", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanHandlePool", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanHandlePoolClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanHandleType", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanHandleTypedef", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanImageBufferPool", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanImageBufferPoolClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanImageMemoryAllocator", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanImageMemoryAllocatorClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanInstanceClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanMemoryAllocator", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanMemoryAllocatorClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanOperation", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanOperationClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanPhysicalDeviceClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanQueueClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanQueueFamilyOps", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanSwapper", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanSwapperClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanTrash", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanTrashFenceListClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanTrashList", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanTrashListClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanVideoFilter", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanVideoFilterClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanVideoOperation", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanWindow", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanWindowClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanWindowError", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ( + "GST_CAPS_FEATURE_MEMORY_VULKAN_BUFFER", + "memory:VulkanBuffer", + ), + ("GST_CAPS_FEATURE_MEMORY_VULKAN_IMAGE", "memory:VulkanImage"), + ("(gint) GST_VULKAN_BARRIER_FLAG_NONE", "0"), + ("(gint) GST_VULKAN_BARRIER_NONE", "0"), + ("(gint) GST_VULKAN_BARRIER_TYPE_BUFFER", "2"), + ("(gint) GST_VULKAN_BARRIER_TYPE_IMAGE", "3"), + ("(gint) GST_VULKAN_BARRIER_TYPE_MEMORY", "1"), + ("GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_NAME", "VulkanBuffer"), + ("GST_VULKAN_DEVICE_CONTEXT_TYPE_STR", "gst.vulkan.device"), + ("GST_VULKAN_DISPLAY_CONTEXT_TYPE_STR", "gst.vulkan.display"), + ("(guint) GST_VULKAN_DISPLAY_TYPE_ANDROID", "32"), + ("(guint) GST_VULKAN_DISPLAY_TYPE_ANY", "4294967295"), + ("(guint) GST_VULKAN_DISPLAY_TYPE_COCOA", "4"), + ("(guint) GST_VULKAN_DISPLAY_TYPE_IOS", "8"), + ("(guint) GST_VULKAN_DISPLAY_TYPE_NONE", "0"), + ("(guint) GST_VULKAN_DISPLAY_TYPE_WAYLAND", "2"), + ("(guint) GST_VULKAN_DISPLAY_TYPE_WIN32", "16"), + ("(guint) GST_VULKAN_DISPLAY_TYPE_XCB", "1"), + ("(gint) GST_VULKAN_FAILED", "0"), + ("(guint) GST_VULKAN_FORMAT_FLAG_ALPHA", "4"), + ("(guint) GST_VULKAN_FORMAT_FLAG_COMPLEX", "16"), + ("(guint) GST_VULKAN_FORMAT_FLAG_LE", "8"), + ("(guint) GST_VULKAN_FORMAT_FLAG_RGB", "2"), + ("(guint) GST_VULKAN_FORMAT_FLAG_YUV", "1"), + ("(gint) GST_VULKAN_FORMAT_SCALING_SINT", "6"), + ("(gint) GST_VULKAN_FORMAT_SCALING_SNORM", "2"), + ("(gint) GST_VULKAN_FORMAT_SCALING_SRGB", "7"), + ("(gint) GST_VULKAN_FORMAT_SCALING_SSCALED", "4"), + ("(gint) GST_VULKAN_FORMAT_SCALING_UINT", "5"), + ("(gint) GST_VULKAN_FORMAT_SCALING_UNORM", "1"), + ("(gint) GST_VULKAN_FORMAT_SCALING_USCALED", "3"), + ("(gint) GST_VULKAN_HANDLE_TYPE_DESCRIPTOR_SET_LAYOUT", "1"), + ("(gint) GST_VULKAN_HANDLE_TYPE_FRAMEBUFFER", "6"), + ("(gint) GST_VULKAN_HANDLE_TYPE_PIPELINE", "3"), + ("(gint) GST_VULKAN_HANDLE_TYPE_PIPELINE_LAYOUT", "2"), + ("(gint) GST_VULKAN_HANDLE_TYPE_RENDER_PASS", "4"), + ("(gint) GST_VULKAN_HANDLE_TYPE_SAMPLER", "5"), + ( + "(gint) GST_VULKAN_HANDLE_TYPE_SAMPLER_YCBCR_CONVERSION", + "10", + ), + ("(gint) GST_VULKAN_HANDLE_TYPE_SHADER", "7"), + ("(gint) GST_VULKAN_HANDLE_TYPE_VIDEO_SESSION", "8"), + ( + "(gint) GST_VULKAN_HANDLE_TYPE_VIDEO_SESSION_PARAMETERS", + "9", + ), + ("GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_NAME", "VulkanImage"), + ( + "GST_VULKAN_INSTANCE_CONTEXT_TYPE_STR", + "gst.vulkan.instance", + ), + ("GST_VULKAN_MAX_COMPONENTS", "4"), + ("GST_VULKAN_MEMORY_ALLOCATOR_NAME", "Vulkan"), + ("GST_VULKAN_QUEUE_CONTEXT_TYPE_STR", "gst.vulkan.queue"), + ( + "GST_VULKAN_SWAPPER_VIDEO_FORMATS", + " { RGBA, BGRA, RGB, BGR } ", + ), + ("(gint) GST_VULKAN_VIDEO_OPERATION_DECODE", "0"), + ("(gint) GST_VULKAN_VIDEO_OPERATION_ENCODE", "1"), + ("(gint) GST_VULKAN_VIDEO_OPERATION_UNKNOWN", "2"), + ("(gint) GST_VULKAN_WINDOW_ERROR_FAILED", "0"), + ("(gint) GST_VULKAN_WINDOW_ERROR_OLD_LIBS", "1"), + ("(gint) GST_VULKAN_WINDOW_ERROR_RESOURCE_UNAVAILABLE", "2"), +]; diff --git a/gstreamer-vulkan/sys/tests/constant.c b/gstreamer-vulkan/sys/tests/constant.c new file mode 100644 index 000000000..c86900148 --- /dev/null +++ b/gstreamer-vulkan/sys/tests/constant.c @@ -0,0 +1,86 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#include "manual.h" +#include + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((CONSTANT_NAME), \ + char *: "%s", \ + const char *: "%s", \ + char: "%c", \ + signed char: "%hhd", \ + unsigned char: "%hhu", \ + short int: "%hd", \ + unsigned short int: "%hu", \ + int: "%d", \ + unsigned int: "%u", \ + long: "%ld", \ + unsigned long: "%lu", \ + long long: "%lld", \ + unsigned long long: "%llu", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + PRINT_CONSTANT(GST_CAPS_FEATURE_MEMORY_VULKAN_BUFFER); + PRINT_CONSTANT(GST_CAPS_FEATURE_MEMORY_VULKAN_IMAGE); + PRINT_CONSTANT((gint) GST_VULKAN_BARRIER_FLAG_NONE); + PRINT_CONSTANT((gint) GST_VULKAN_BARRIER_NONE); + PRINT_CONSTANT((gint) GST_VULKAN_BARRIER_TYPE_BUFFER); + PRINT_CONSTANT((gint) GST_VULKAN_BARRIER_TYPE_IMAGE); + PRINT_CONSTANT((gint) GST_VULKAN_BARRIER_TYPE_MEMORY); + PRINT_CONSTANT(GST_VULKAN_BUFFER_MEMORY_ALLOCATOR_NAME); + PRINT_CONSTANT(GST_VULKAN_DEVICE_CONTEXT_TYPE_STR); + PRINT_CONSTANT(GST_VULKAN_DISPLAY_CONTEXT_TYPE_STR); + PRINT_CONSTANT((guint) GST_VULKAN_DISPLAY_TYPE_ANDROID); + PRINT_CONSTANT((guint) GST_VULKAN_DISPLAY_TYPE_ANY); + PRINT_CONSTANT((guint) GST_VULKAN_DISPLAY_TYPE_COCOA); + PRINT_CONSTANT((guint) GST_VULKAN_DISPLAY_TYPE_IOS); + PRINT_CONSTANT((guint) GST_VULKAN_DISPLAY_TYPE_NONE); + PRINT_CONSTANT((guint) GST_VULKAN_DISPLAY_TYPE_WAYLAND); + PRINT_CONSTANT((guint) GST_VULKAN_DISPLAY_TYPE_WIN32); + PRINT_CONSTANT((guint) GST_VULKAN_DISPLAY_TYPE_XCB); + PRINT_CONSTANT((gint) GST_VULKAN_FAILED); + PRINT_CONSTANT((guint) GST_VULKAN_FORMAT_FLAG_ALPHA); + PRINT_CONSTANT((guint) GST_VULKAN_FORMAT_FLAG_COMPLEX); + PRINT_CONSTANT((guint) GST_VULKAN_FORMAT_FLAG_LE); + PRINT_CONSTANT((guint) GST_VULKAN_FORMAT_FLAG_RGB); + PRINT_CONSTANT((guint) GST_VULKAN_FORMAT_FLAG_YUV); + PRINT_CONSTANT((gint) GST_VULKAN_FORMAT_SCALING_SINT); + PRINT_CONSTANT((gint) GST_VULKAN_FORMAT_SCALING_SNORM); + PRINT_CONSTANT((gint) GST_VULKAN_FORMAT_SCALING_SRGB); + PRINT_CONSTANT((gint) GST_VULKAN_FORMAT_SCALING_SSCALED); + PRINT_CONSTANT((gint) GST_VULKAN_FORMAT_SCALING_UINT); + PRINT_CONSTANT((gint) GST_VULKAN_FORMAT_SCALING_UNORM); + PRINT_CONSTANT((gint) GST_VULKAN_FORMAT_SCALING_USCALED); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_DESCRIPTOR_SET_LAYOUT); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_FRAMEBUFFER); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_PIPELINE); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_PIPELINE_LAYOUT); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_RENDER_PASS); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_SAMPLER); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_SAMPLER_YCBCR_CONVERSION); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_SHADER); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_VIDEO_SESSION); + PRINT_CONSTANT((gint) GST_VULKAN_HANDLE_TYPE_VIDEO_SESSION_PARAMETERS); + PRINT_CONSTANT(GST_VULKAN_IMAGE_MEMORY_ALLOCATOR_NAME); + PRINT_CONSTANT(GST_VULKAN_INSTANCE_CONTEXT_TYPE_STR); + PRINT_CONSTANT(GST_VULKAN_MAX_COMPONENTS); + PRINT_CONSTANT(GST_VULKAN_MEMORY_ALLOCATOR_NAME); + PRINT_CONSTANT(GST_VULKAN_QUEUE_CONTEXT_TYPE_STR); + PRINT_CONSTANT(GST_VULKAN_SWAPPER_VIDEO_FORMATS); + PRINT_CONSTANT((gint) GST_VULKAN_VIDEO_OPERATION_DECODE); + PRINT_CONSTANT((gint) GST_VULKAN_VIDEO_OPERATION_ENCODE); + PRINT_CONSTANT((gint) GST_VULKAN_VIDEO_OPERATION_UNKNOWN); + PRINT_CONSTANT((gint) GST_VULKAN_WINDOW_ERROR_FAILED); + PRINT_CONSTANT((gint) GST_VULKAN_WINDOW_ERROR_OLD_LIBS); + PRINT_CONSTANT((gint) GST_VULKAN_WINDOW_ERROR_RESOURCE_UNAVAILABLE); + return 0; +} diff --git a/gstreamer-vulkan/sys/tests/layout.c b/gstreamer-vulkan/sys/tests/layout.c new file mode 100644 index 000000000..2406054b2 --- /dev/null +++ b/gstreamer-vulkan/sys/tests/layout.c @@ -0,0 +1,63 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%s;%zu;%zu\n", "GstVulkanBarrierFlags", sizeof(GstVulkanBarrierFlags), alignof(GstVulkanBarrierFlags)); + printf("%s;%zu;%zu\n", "GstVulkanBarrierType", sizeof(GstVulkanBarrierType), alignof(GstVulkanBarrierType)); + printf("%s;%zu;%zu\n", "GstVulkanBufferMemoryAllocator", sizeof(GstVulkanBufferMemoryAllocator), alignof(GstVulkanBufferMemoryAllocator)); + printf("%s;%zu;%zu\n", "GstVulkanBufferMemoryAllocatorClass", sizeof(GstVulkanBufferMemoryAllocatorClass), alignof(GstVulkanBufferMemoryAllocatorClass)); + printf("%s;%zu;%zu\n", "GstVulkanBufferPool", sizeof(GstVulkanBufferPool), alignof(GstVulkanBufferPool)); + printf("%s;%zu;%zu\n", "GstVulkanBufferPoolClass", sizeof(GstVulkanBufferPoolClass), alignof(GstVulkanBufferPoolClass)); + printf("%s;%zu;%zu\n", "GstVulkanCommandPoolClass", sizeof(GstVulkanCommandPoolClass), alignof(GstVulkanCommandPoolClass)); + printf("%s;%zu;%zu\n", "GstVulkanDescriptorCache", sizeof(GstVulkanDescriptorCache), alignof(GstVulkanDescriptorCache)); + printf("%s;%zu;%zu\n", "GstVulkanDescriptorCacheClass", sizeof(GstVulkanDescriptorCacheClass), alignof(GstVulkanDescriptorCacheClass)); + printf("%s;%zu;%zu\n", "GstVulkanDescriptorPoolClass", sizeof(GstVulkanDescriptorPoolClass), alignof(GstVulkanDescriptorPoolClass)); + printf("%s;%zu;%zu\n", "GstVulkanDeviceClass", sizeof(GstVulkanDeviceClass), alignof(GstVulkanDeviceClass)); + printf("%s;%zu;%zu\n", "GstVulkanDisplay", sizeof(GstVulkanDisplay), alignof(GstVulkanDisplay)); + printf("%s;%zu;%zu\n", "GstVulkanDisplayClass", sizeof(GstVulkanDisplayClass), alignof(GstVulkanDisplayClass)); + printf("%s;%zu;%zu\n", "GstVulkanDisplayType", sizeof(GstVulkanDisplayType), alignof(GstVulkanDisplayType)); + printf("%s;%zu;%zu\n", "GstVulkanEncodeQueryResult", sizeof(GstVulkanEncodeQueryResult), alignof(GstVulkanEncodeQueryResult)); + printf("%s;%zu;%zu\n", "GstVulkanError", sizeof(GstVulkanError), alignof(GstVulkanError)); + printf("%s;%zu;%zu\n", "GstVulkanFenceCache", sizeof(GstVulkanFenceCache), alignof(GstVulkanFenceCache)); + printf("%s;%zu;%zu\n", "GstVulkanFenceCacheClass", sizeof(GstVulkanFenceCacheClass), alignof(GstVulkanFenceCacheClass)); + printf("%s;%zu;%zu\n", "GstVulkanFormatFlags", sizeof(GstVulkanFormatFlags), alignof(GstVulkanFormatFlags)); + printf("%s;%zu;%zu\n", "GstVulkanFormatScaling", sizeof(GstVulkanFormatScaling), alignof(GstVulkanFormatScaling)); + printf("%s;%zu;%zu\n", "GstVulkanFullScreenQuad", sizeof(GstVulkanFullScreenQuad), alignof(GstVulkanFullScreenQuad)); + printf("%s;%zu;%zu\n", "GstVulkanFullScreenQuadClass", sizeof(GstVulkanFullScreenQuadClass), alignof(GstVulkanFullScreenQuadClass)); + printf("%s;%zu;%zu\n", "GstVulkanHandle", sizeof(GstVulkanHandle), alignof(GstVulkanHandle)); + printf("%s;%zu;%zu\n", "GstVulkanHandlePool", sizeof(GstVulkanHandlePool), alignof(GstVulkanHandlePool)); + printf("%s;%zu;%zu\n", "GstVulkanHandlePoolClass", sizeof(GstVulkanHandlePoolClass), alignof(GstVulkanHandlePoolClass)); + printf("%s;%zu;%zu\n", "GstVulkanHandleType", sizeof(GstVulkanHandleType), alignof(GstVulkanHandleType)); + printf("%s;%zu;%zu\n", "GstVulkanHandleTypedef", sizeof(GstVulkanHandleTypedef), alignof(GstVulkanHandleTypedef)); + printf("%s;%zu;%zu\n", "GstVulkanImageBufferPool", sizeof(GstVulkanImageBufferPool), alignof(GstVulkanImageBufferPool)); + printf("%s;%zu;%zu\n", "GstVulkanImageBufferPoolClass", sizeof(GstVulkanImageBufferPoolClass), alignof(GstVulkanImageBufferPoolClass)); + printf("%s;%zu;%zu\n", "GstVulkanImageMemoryAllocator", sizeof(GstVulkanImageMemoryAllocator), alignof(GstVulkanImageMemoryAllocator)); + printf("%s;%zu;%zu\n", "GstVulkanImageMemoryAllocatorClass", sizeof(GstVulkanImageMemoryAllocatorClass), alignof(GstVulkanImageMemoryAllocatorClass)); + printf("%s;%zu;%zu\n", "GstVulkanInstanceClass", sizeof(GstVulkanInstanceClass), alignof(GstVulkanInstanceClass)); + printf("%s;%zu;%zu\n", "GstVulkanMemoryAllocator", sizeof(GstVulkanMemoryAllocator), alignof(GstVulkanMemoryAllocator)); + printf("%s;%zu;%zu\n", "GstVulkanMemoryAllocatorClass", sizeof(GstVulkanMemoryAllocatorClass), alignof(GstVulkanMemoryAllocatorClass)); + printf("%s;%zu;%zu\n", "GstVulkanOperation", sizeof(GstVulkanOperation), alignof(GstVulkanOperation)); + printf("%s;%zu;%zu\n", "GstVulkanOperationClass", sizeof(GstVulkanOperationClass), alignof(GstVulkanOperationClass)); + printf("%s;%zu;%zu\n", "GstVulkanPhysicalDeviceClass", sizeof(GstVulkanPhysicalDeviceClass), alignof(GstVulkanPhysicalDeviceClass)); + printf("%s;%zu;%zu\n", "GstVulkanQueueClass", sizeof(GstVulkanQueueClass), alignof(GstVulkanQueueClass)); + printf("%s;%zu;%zu\n", "GstVulkanQueueFamilyOps", sizeof(GstVulkanQueueFamilyOps), alignof(GstVulkanQueueFamilyOps)); + printf("%s;%zu;%zu\n", "GstVulkanSwapper", sizeof(GstVulkanSwapper), alignof(GstVulkanSwapper)); + printf("%s;%zu;%zu\n", "GstVulkanSwapperClass", sizeof(GstVulkanSwapperClass), alignof(GstVulkanSwapperClass)); + printf("%s;%zu;%zu\n", "GstVulkanTrash", sizeof(GstVulkanTrash), alignof(GstVulkanTrash)); + printf("%s;%zu;%zu\n", "GstVulkanTrashFenceListClass", sizeof(GstVulkanTrashFenceListClass), alignof(GstVulkanTrashFenceListClass)); + printf("%s;%zu;%zu\n", "GstVulkanTrashList", sizeof(GstVulkanTrashList), alignof(GstVulkanTrashList)); + printf("%s;%zu;%zu\n", "GstVulkanTrashListClass", sizeof(GstVulkanTrashListClass), alignof(GstVulkanTrashListClass)); + printf("%s;%zu;%zu\n", "GstVulkanVideoFilter", sizeof(GstVulkanVideoFilter), alignof(GstVulkanVideoFilter)); + printf("%s;%zu;%zu\n", "GstVulkanVideoFilterClass", sizeof(GstVulkanVideoFilterClass), alignof(GstVulkanVideoFilterClass)); + printf("%s;%zu;%zu\n", "GstVulkanVideoOperation", sizeof(GstVulkanVideoOperation), alignof(GstVulkanVideoOperation)); + printf("%s;%zu;%zu\n", "GstVulkanWindow", sizeof(GstVulkanWindow), alignof(GstVulkanWindow)); + printf("%s;%zu;%zu\n", "GstVulkanWindowClass", sizeof(GstVulkanWindowClass), alignof(GstVulkanWindowClass)); + printf("%s;%zu;%zu\n", "GstVulkanWindowError", sizeof(GstVulkanWindowError), alignof(GstVulkanWindowError)); + return 0; +} diff --git a/gstreamer-vulkan/sys/tests/manual.h b/gstreamer-vulkan/sys/tests/manual.h new file mode 100644 index 000000000..e961e4c33 --- /dev/null +++ b/gstreamer-vulkan/sys/tests/manual.h @@ -0,0 +1,3 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +#include diff --git a/gstreamer-vulkan/tests/check_gir.rs b/gstreamer-vulkan/tests/check_gir.rs new file mode 100644 index 000000000..2ccf5ff05 --- /dev/null +++ b/gstreamer-vulkan/tests/check_gir.rs @@ -0,0 +1,8 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +#[test] +fn check_gir_file() { + let res = gir_format_check::check_gir_file("Gir.toml"); + println!("{res}"); + assert_eq!(res.nb_errors, 0); +} diff --git a/gstreamer-vulkan/wayland/CHANGELOG.md b/gstreamer-vulkan/wayland/CHANGELOG.md new file mode 120000 index 000000000..d6a7bdb06 --- /dev/null +++ b/gstreamer-vulkan/wayland/CHANGELOG.md @@ -0,0 +1 @@ +../../gstreamer/CHANGELOG.md \ No newline at end of file diff --git a/gstreamer-vulkan/wayland/COPYRIGHT b/gstreamer-vulkan/wayland/COPYRIGHT new file mode 120000 index 000000000..8b0161cc9 --- /dev/null +++ b/gstreamer-vulkan/wayland/COPYRIGHT @@ -0,0 +1 @@ +../../COPYRIGHT \ No newline at end of file diff --git a/gstreamer-vulkan/wayland/Cargo.toml b/gstreamer-vulkan/wayland/Cargo.toml new file mode 100644 index 000000000..1d7107250 --- /dev/null +++ b/gstreamer-vulkan/wayland/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "gstreamer-vulkan-wayland" +authors = ["Matthew Waters "] +description = "Rust bindings for GStreamer Vulkan library (Wayland support)" +license = "MIT OR Apache-2.0" +readme = "README.md" +documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_vulkan_wayland/" +keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"] +version.workspace = true +categories.workspace = true +repository.workspace = true +homepage.workspace = true +edition.workspace = true +rust-version.workspace = true + +[dependencies] +libc = "0.2" +ffi = { package = "gstreamer-vulkan-wayland-sys", path = "sys" } +glib.workspace = true +gst.workspace = true +gst-vulkan.workspace = true + +[dev-dependencies] +gir-format-check = "0.1" + +[features] +default = [] +v1_20 = ["gst/v1_20", "gst-vulkan/v1_20", "ffi/v1_20"] +v1_22 = ["gst/v1_22", "gst-vulkan/v1_22", "ffi/v1_22", "v1_20"] +v1_24 = ["gst/v1_24", "gst-vulkan/v1_24", "ffi/v1_24", "v1_22"] +v1_26 = ["gst/v1_26", "gst-vulkan/v1_26", "ffi/v1_26", "v1_24"] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/gstreamer-vulkan/wayland/Gir.toml b/gstreamer-vulkan/wayland/Gir.toml new file mode 100644 index 000000000..352b05e1d --- /dev/null +++ b/gstreamer-vulkan/wayland/Gir.toml @@ -0,0 +1,59 @@ +[options] +girs_directories = ["../../gir-files", "../../gst-gir-files"] +library = "GstVulkanWayland" +version = "1.0" +min_cfg_version = "1.18" +work_mode = "normal" +concurrency = "send+sync" +generate_safety_asserts = true +single_version_file = true +generate_display_trait = false +trust_return_value_nullability = true + +external_libraries = [ + "GLib", + "GObject", + "Gst", + "GstBase", + "GstVideo", + "GstVulkan", +] + +generate = [] + +manual = [ + "GLib.Error", + "GLib.Thread", + "GObject.Object", + "Gst.FlowReturn", + "Gst.Object", + "Gst.PadDirection", +] + +[[object]] +name = "Gst.Buffer" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Caps" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Query" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Structure" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "GstVulkanWayland.VulkanDisplayWayland" +status = "generate" + [[object.function]] + name = "new" + [object.function.return] + nullable_return_is_error = "Failed to create Wayland display" diff --git a/gstreamer-vulkan/wayland/LICENSE-APACHE b/gstreamer-vulkan/wayland/LICENSE-APACHE new file mode 120000 index 000000000..1cd601d0a --- /dev/null +++ b/gstreamer-vulkan/wayland/LICENSE-APACHE @@ -0,0 +1 @@ +../../LICENSE-APACHE \ No newline at end of file diff --git a/gstreamer-vulkan/wayland/LICENSE-MIT b/gstreamer-vulkan/wayland/LICENSE-MIT new file mode 120000 index 000000000..b2cfbdc7b --- /dev/null +++ b/gstreamer-vulkan/wayland/LICENSE-MIT @@ -0,0 +1 @@ +../../LICENSE-MIT \ No newline at end of file diff --git a/gstreamer-vulkan/wayland/README.md b/gstreamer-vulkan/wayland/README.md new file mode 100644 index 000000000..49ee41a87 --- /dev/null +++ b/gstreamer-vulkan/wayland/README.md @@ -0,0 +1,215 @@ +# gstreamer-rs [![crates.io](https://img.shields.io/crates/v/gstreamer-gl-wayland.svg)](https://crates.io/crates/gstreamer-gl-wayland) [![pipeline status](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/badges/main/pipeline.svg)](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/commits/main) + +[GStreamer](https://gstreamer.freedesktop.org/) (OpenGL library, Wayland support) +bindings for Rust. Documentation can be found +[here](https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_gl_wayland/). + +These bindings are providing a safe API that can be used to interface with +GStreamer, e.g. for writing GStreamer-based applications and GStreamer plugins. + +The bindings are mostly autogenerated with [gir](https://github.com/gtk-rs/gir/) +based on the [GObject-Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection/) +API metadata provided by the GStreamer project. + +## Table of Contents +1. [Installation](#installation) + 1. [Linux/BSDs](#installation-linux) + 1. [macOS](#installation-macos) + 1. [Windows](#installation-windows) +1. [Getting Started](#getting-started) +1. [License](#license) +1. [Contribution](#contribution) + + + +## Installation + +To build the GStreamer bindings or anything depending on them, you need to +have at least GStreamer 1.14 and gst-plugins-base 1.14 installed. In addition, +some of the examples/tutorials require various GStreamer plugins to be +available, which can be found in gst-plugins-base, gst-plugins-good, +gst-plugins-bad, gst-plugins-ugly and/or gst-libav. + + + +### Linux/BSDs + +You need to install the above mentioned packages with your distributions +package manager, or build them from source. + +On Debian/Ubuntu they can be installed with + +```console +$ apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \ + gstreamer1.0-libav libgstrtspserver-1.0-dev libges-1.0-dev +``` + +The minimum required version of the above libraries is >= 1.14. If you +build the gstreamer-player sub-crate, or any of the examples that +depend on gstreamer-player, you must ensure that in addition to the above +packages, `libgstreamer-plugins-bad1.0-dev` is installed. See the `Cargo.toml` +files for the full details, + +```console +$ apt-get install libgstreamer-plugins-bad1.0-dev +``` + +Package names on other distributions should be similar. +Please submit a pull request with instructions for yours. + + + +### macOS + +You can install GStreamer and the plugins via [Homebrew](https://brew.sh/) or +by installing the [binaries](https://gstreamer.freedesktop.org/data/pkg/osx/) +provided by the GStreamer project. + +We recommend using the official GStreamer binaries over Homebrew, especially +as GStreamer in Homebrew is [currently broken](https://github.com/orgs/Homebrew/discussions/3740#discussioncomment-3804964). + +#### GStreamer Binaries + +You need to download the *two* `.pkg` files from the GStreamer website and +install them, e.g. `gstreamer-1.0-1.20.4-universal.pkg` and +`gstreamer-1.0-devel-1.20.4-universal.pkg`. + +After installation, you also need to set the `PATH` environment variable as +follows + +```console +$ export PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/bin${PATH:+:$PATH}" +``` + +Also note that the `pkg-config` from GStreamer should be the first one in +the `PATH` as other versions have all kinds of quirks that will cause +problems. + +#### Homebrew + +Homebrew only installs various plugins if explicitly enabled, so some extra +`--with-*` flags may be required. + +```console +$ brew install gstreamer gst-plugins-base gst-plugins-good \ + gst-plugins-bad gst-plugins-ugly gst-libav gst-rtsp-server \ + gst-editing-services --with-orc --with-libogg --with-opus \ + --with-pango --with-theora --with-libvorbis --with-libvpx \ + --enable-gtk3 +``` + +Make sure the version of these libraries is >= 1.14. + + + +### Windows + +You can install GStreamer and the plugins via [MSYS2](http://www.msys2.org/) +with `pacman` or by installing the +[binaries](https://gstreamer.freedesktop.org/data/pkg/windows/) provided by +the GStreamer project. + +We recommend using the official GStreamer binaries over MSYS2. + +#### GStreamer Binaries + +You need to download the *two* `.msi` files for your platform from the +GStreamer website and install them, e.g. `gstreamer-1.0-x86_64-1.20.4.msi` and +`gstreamer-1.0-devel-x86_64-1.20.4.msi`. Make sure to select the version that +matches your Rust toolchain, i.e. MinGW or MSVC. + +After installation set the ``PATH` environment variable as follows: + +```console +# For a UNIX-style shell: +$ export PATH="c:/gstreamer/1.0/msvc_x86_64/bin${PATH:+:$PATH}" + +# For cmd.exe: +$ set PATH=C:\gstreamer\1.0\msvc_x86_64\bin;%PATH% +``` + +Make sure to update the path to where you have actually installed GStreamer +and for the corresponding toolchain. + +Also note that the `pkg-config.exe` from GStreamer should be the first one in +the `PATH` as other versions have all kinds of quirks that will cause +problems. + +#### MSYS2 / pacman + +```console +$ pacman -S glib2-devel pkg-config \ + mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gst-plugins-base \ + mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad \ + mingw-w64-x86_64-gst-plugins-ugly mingw-w64-x86_64-gst-libav \ + mingw-w64-x86_64-gst-rtsp-server +``` + +Make sure the version of these libraries is >= 1.14. + +Note that the version of `pkg-config` included in `MSYS2` is +[known to have problems](https://github.com/rust-lang/pkg-config-rs/issues/51#issuecomment-346300858) +compiling GStreamer, so you may need to install another version. One option +would be [`pkg-config-lite`](https://sourceforge.net/projects/pkgconfiglite/). + + + +## Getting Started + +The API reference can be found +[here](https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer/), however it is +only the Rust API reference and does not explain any of the concepts. + +For getting started with GStreamer development, the best would be to follow +the [documentation](https://gstreamer.freedesktop.org/documentation/) on the +GStreamer website, especially the [Application Development +Manual](https://gstreamer.freedesktop.org/documentation/application-development/). +While being C-centric, it explains all the fundamental concepts of GStreamer +and the code examples should be relatively easily translatable to Rust. The +API is basically the same, function/struct names are the same and everything +is only more convenient (hopefully) and safer. + +In addition there are +[tutorials](https://gstreamer.freedesktop.org/documentation/tutorials/) on the +GStreamer website. Many of them were ported to Rust already and the code can +be found in the +[tutorials](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/tree/main/tutorials) +directory. + +Some further examples for various aspects of GStreamer and how to use it from +Rust can be found in the +[examples](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/tree/main/examples) +directory. + +Various GStreamer plugins written in Rust can be found in the +[gst-plugins-rs](https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs) +repository. + + + +## LICENSE + +gstreamer-rs and all crates contained in here are licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +GStreamer itself is licensed under the Lesser General Public License version +2.1 or (at your option) any later version: +https://www.gnu.org/licenses/lgpl-2.1.html + + + +## Contribution + +Any kinds of contributions are welcome as a pull request. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in gstreamer-rs by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/gstreamer-vulkan/wayland/src/auto/mod.rs b/gstreamer-vulkan/wayland/src/auto/mod.rs new file mode 100644 index 000000000..36a9e1f41 --- /dev/null +++ b/gstreamer-vulkan/wayland/src/auto/mod.rs @@ -0,0 +1,7 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +mod vulkan_display_wayland; +pub use self::vulkan_display_wayland::VulkanDisplayWayland; diff --git a/gstreamer-vulkan/wayland/src/auto/versions.txt b/gstreamer-vulkan/wayland/src/auto/versions.txt new file mode 100644 index 000000000..5753ee763 --- /dev/null +++ b/gstreamer-vulkan/wayland/src/auto/versions.txt @@ -0,0 +1,3 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 5223ce91b97a) +from gir-files (https://github.com/gtk-rs/gir-files @ 6cd7b656acd6) +from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ d62956d67216+) diff --git a/gstreamer-vulkan/wayland/src/auto/vulkan_display_wayland.rs b/gstreamer-vulkan/wayland/src/auto/vulkan_display_wayland.rs new file mode 100644 index 000000000..d08bb0ade --- /dev/null +++ b/gstreamer-vulkan/wayland/src/auto/vulkan_display_wayland.rs @@ -0,0 +1,37 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use glib::translate::*; + +glib::wrapper! { + #[doc(alias = "GstVulkanDisplayWayland")] + pub struct VulkanDisplayWayland(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_display_wayland_get_type(), + } +} + +impl VulkanDisplayWayland { + pub const NONE: Option<&'static VulkanDisplayWayland> = None; + + #[doc(alias = "gst_vulkan_display_wayland_new")] + pub fn new(name: Option<&str>) -> Result { + assert_initialized_main_thread!(); + unsafe { + Option::<_>::from_glib_full(ffi::gst_vulkan_display_wayland_new(name.to_glib_none().0)) + .ok_or_else(|| glib::bool_error!("Failed to create Wayland display")) + } + } + + //#[doc(alias = "gst_vulkan_display_wayland_new_with_display")] + //#[doc(alias = "new_with_display")] + //pub fn with_display(display: /*Unimplemented*/Option) -> VulkanDisplayWayland { + // unsafe { TODO: call ffi:gst_vulkan_display_wayland_new_with_display() } + //} +} + +unsafe impl Send for VulkanDisplayWayland {} +unsafe impl Sync for VulkanDisplayWayland {} diff --git a/gstreamer-vulkan/wayland/src/lib.rs b/gstreamer-vulkan/wayland/src/lib.rs new file mode 100644 index 000000000..98148f0c7 --- /dev/null +++ b/gstreamer-vulkan/wayland/src/lib.rs @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![cfg_attr(docsrs, feature(doc_cfg))] +#![allow(clippy::missing_safety_doc)] + +pub use ffi; +pub use gst_vulkan; + +macro_rules! assert_initialized_main_thread { + () => { + if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) { + gst::assert_initialized(); + } + }; +} + +mod auto; +pub use auto::*; + +mod vulkan_display_wayland; diff --git a/gstreamer-vulkan/wayland/src/vulkan_display_wayland.rs b/gstreamer-vulkan/wayland/src/vulkan_display_wayland.rs new file mode 100644 index 000000000..5040d4a71 --- /dev/null +++ b/gstreamer-vulkan/wayland/src/vulkan_display_wayland.rs @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Matthew Waters +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use glib::{ffi::gpointer, translate::*}; +use libc::uintptr_t; + +use crate::VulkanDisplayWayland; + +impl VulkanDisplayWayland { + pub unsafe fn with_display( + display: uintptr_t, + ) -> Result { + from_glib_full::<_, Option>( + ffi::gst_vulkan_display_wayland_new_with_display(display as gpointer), + ) + .ok_or_else(|| glib::bool_error!("Failed to create new Wayland Vulkan display")) + } +} diff --git a/gstreamer-vulkan/wayland/sys/CHANGELOG.md b/gstreamer-vulkan/wayland/sys/CHANGELOG.md new file mode 120000 index 000000000..ba8c4d72f --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/CHANGELOG.md @@ -0,0 +1 @@ +../../../gstreamer/CHANGELOG.md \ No newline at end of file diff --git a/gstreamer-vulkan/wayland/sys/COPYRIGHT b/gstreamer-vulkan/wayland/sys/COPYRIGHT new file mode 120000 index 000000000..9c6cf1d41 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/COPYRIGHT @@ -0,0 +1 @@ +../../../COPYRIGHT \ No newline at end of file diff --git a/gstreamer-vulkan/wayland/sys/Cargo.toml b/gstreamer-vulkan/wayland/sys/Cargo.toml new file mode 100644 index 000000000..20bea1781 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/Cargo.toml @@ -0,0 +1,73 @@ +[package] +authors = ["Matthew Waters "] +build = "build.rs" +description = "FFI bindings to libgstvulkan-1.0 (Wayland support)" +documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_vulkan_wayland_sys/" +keywords = ["ffi", "gstreamer", "gnome", "multimedia"] +license = "MIT" +name = "gstreamer-vulkan-wayland-sys" +readme = "README.md" + +[package.version] +workspace = true + +[package.categories] +workspace = true + +[package.repository] +workspace = true + +[package.homepage] +workspace = true + +[package.edition] +workspace = true + +[package.rust-version] +workspace = true + +[package.metadata.system-deps.gstreamer_vulkan_wayland_1_0] +name = "gstreamer-vulkan-wayland-1.0" +version = "1.20" + +[package.metadata.system-deps.gstreamer_vulkan_wayland_1_0.v1_22] +version = "1.22" + +[package.metadata.system-deps.gstreamer_vulkan_wayland_1_0.v1_24] +version = "1.24" + +[package.metadata.system-deps.gstreamer_vulkan_wayland_1_0.v1_26] +version = "1.25" + +[package.metadata.system-deps.gstreamer_vulkan_wayland_1_0.v1_20] +version = "1.20" + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] + +[lib] +name = "gstreamer_vulkan_wayland_sys" + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +workspace = true + +[dependencies.gstreamer-vulkan-sys] +workspace = true + +[build-dependencies] +system-deps = "6" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] +v1_20 = [] +v1_22 = ["v1_20"] +v1_24 = ["v1_22"] +v1_26 = ["v1_24"] diff --git a/gstreamer-vulkan/wayland/sys/Gir.toml b/gstreamer-vulkan/wayland/sys/Gir.toml new file mode 100644 index 000000000..8cf8cbed9 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/Gir.toml @@ -0,0 +1,24 @@ +[options] +girs_directories = ["../../../gir-files", "../../../gst-gir-files"] +library = "GstVulkanWayland" +min_cfg_version = "1.18" +version = "1.0" +work_mode = "sys" +single_version_file = true + +extra_versions = [ + "1.24", + "1.22", + "1.20", +] + +external_libraries = [ + "GLib", +] + +generate = [ + "GstVulkanWayland.VulkanDisplayWayland", +] + +[external_libraries] +gstreamer-vulkan = "GstVulkan" diff --git a/gstreamer-vulkan/wayland/sys/LICENSE b/gstreamer-vulkan/wayland/sys/LICENSE new file mode 120000 index 000000000..98cefa6a6 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/LICENSE @@ -0,0 +1 @@ +../../../LICENSE-MIT \ No newline at end of file diff --git a/gstreamer-vulkan/wayland/sys/README.md b/gstreamer-vulkan/wayland/sys/README.md new file mode 100644 index 000000000..d43481bfc --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/README.md @@ -0,0 +1,31 @@ +# gstreamer-sys [![crates.io](https://img.shields.io/crates/v/gstreamer-gl-wayland-sys.svg)](https://crates.io/crates/gstreamer-gl-wayland-sys) [![pipeline status](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/badges/main/pipeline.svg)](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/commits/main) + +[GStreamer](https://gstreamer.freedesktop.org/) (OpenGL library, Wayland support) FFI bindings for Rust. + +These bindings are providing unsafe FFI API that can be used to interface with +GStreamer. Generally they are meant to be used as the building block for +higher-level abstractions like: + + * Bindings for GStreamer applications and plugins: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs + * Various GStreamer plugins written in Rust: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs + +The bindings are autogenerated with [gir](https://github.com/gtk-rs/gir/) +based on the [GObject-Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection/) +API metadata provided by the GStreamer project. + +## LICENSE + +gstreamer-sys and all crates contained here are licensed under the MIT +license ([LICENSE](LICENSE) or http://opensource.org/licenses/MIT). + +GStreamer itself is licensed under the Lesser General Public License version +2.1 or (at your option) any later version: +https://www.gnu.org/licenses/lgpl-2.1.html + +## Contribution + +Any kinds of contributions are welcome as a pull request. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in gstreamer-rs by you shall be licensed under the MIT license as above, +without any additional terms or conditions. diff --git a/gstreamer-vulkan/wayland/sys/build.rs b/gstreamer-vulkan/wayland/sys/build.rs new file mode 100644 index 000000000..29420c9ee --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/build.rs @@ -0,0 +1,18 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#[cfg(not(docsrs))] +use std::process; + +#[cfg(docsrs)] +fn main() {} // prevent linking libraries to avoid documentation failure + +#[cfg(not(docsrs))] +fn main() { + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + process::exit(1); + } +} diff --git a/gstreamer-vulkan/wayland/sys/src/auto/versions.txt b/gstreamer-vulkan/wayland/sys/src/auto/versions.txt new file mode 100644 index 000000000..5753ee763 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/src/auto/versions.txt @@ -0,0 +1,3 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 5223ce91b97a) +from gir-files (https://github.com/gtk-rs/gir-files @ 6cd7b656acd6) +from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ d62956d67216+) diff --git a/gstreamer-vulkan/wayland/sys/src/lib.rs b/gstreamer-vulkan/wayland/sys/src/lib.rs new file mode 100644 index 000000000..9e809b6a9 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/src/lib.rs @@ -0,0 +1,83 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use glib_sys as glib; +use gstreamer_vulkan_sys as gst_vulkan; + +#[allow(unused_imports)] +use libc::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, + intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE, +}; +#[cfg(unix)] +#[allow(unused_imports)] +use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Records +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDisplayWaylandClass { + pub object_class: gst_vulkan::GstVulkanDisplayClass, +} + +impl ::std::fmt::Debug for GstVulkanDisplayWaylandClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDisplayWaylandClass @ {self:p}")) + .field("object_class", &self.object_class) + .finish() + } +} + +// Classes +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDisplayWayland { + pub parent: gst_vulkan::GstVulkanDisplay, + pub display: gpointer, + pub registry: gpointer, + pub compositor: gpointer, + pub subcompositor: gpointer, + pub shell: gpointer, + pub foreign_display: gboolean, +} + +impl ::std::fmt::Debug for GstVulkanDisplayWayland { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDisplayWayland @ {self:p}")) + .field("parent", &self.parent) + .field("display", &self.display) + .field("registry", &self.registry) + .field("compositor", &self.compositor) + .field("subcompositor", &self.subcompositor) + .field("shell", &self.shell) + .finish() + } +} + +#[link(name = "gstvulkan-1.0")] +extern "C" { + + //========================================================================= + // GstVulkanDisplayWayland + //========================================================================= + pub fn gst_vulkan_display_wayland_get_type() -> GType; + pub fn gst_vulkan_display_wayland_new(name: *const c_char) -> *mut GstVulkanDisplayWayland; + pub fn gst_vulkan_display_wayland_new_with_display( + display: gpointer, + ) -> *mut GstVulkanDisplayWayland; + +} diff --git a/gstreamer-vulkan/wayland/sys/tests/abi.rs b/gstreamer-vulkan/wayland/sys/tests/abi.rs new file mode 100644 index 000000000..0922d4bd9 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/tests/abi.rs @@ -0,0 +1,221 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#![cfg(unix)] + +use gstreamer_vulkan_wayland_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["gstreamer-vulkan-wayland-1.0"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec, +} + +impl Compiler { + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result, Box> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "GstVulkanDisplayWayland", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstVulkanDisplayWaylandClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[]; diff --git a/gstreamer-vulkan/wayland/sys/tests/constant.c b/gstreamer-vulkan/wayland/sys/tests/constant.c new file mode 100644 index 000000000..d37bc26f5 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/tests/constant.c @@ -0,0 +1,33 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#include "manual.h" +#include + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((CONSTANT_NAME), \ + char *: "%s", \ + const char *: "%s", \ + char: "%c", \ + signed char: "%hhd", \ + unsigned char: "%hhu", \ + short int: "%hd", \ + unsigned short int: "%hu", \ + int: "%d", \ + unsigned int: "%u", \ + long: "%ld", \ + unsigned long: "%lu", \ + long long: "%lld", \ + unsigned long long: "%llu", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + return 0; +} diff --git a/gstreamer-vulkan/wayland/sys/tests/layout.c b/gstreamer-vulkan/wayland/sys/tests/layout.c new file mode 100644 index 000000000..e1602c7e5 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/tests/layout.c @@ -0,0 +1,14 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%s;%zu;%zu\n", "GstVulkanDisplayWayland", sizeof(GstVulkanDisplayWayland), alignof(GstVulkanDisplayWayland)); + printf("%s;%zu;%zu\n", "GstVulkanDisplayWaylandClass", sizeof(GstVulkanDisplayWaylandClass), alignof(GstVulkanDisplayWaylandClass)); + return 0; +} diff --git a/gstreamer-vulkan/wayland/sys/tests/manual.h b/gstreamer-vulkan/wayland/sys/tests/manual.h new file mode 100644 index 000000000..f5dcdf6c6 --- /dev/null +++ b/gstreamer-vulkan/wayland/sys/tests/manual.h @@ -0,0 +1,3 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +#include diff --git a/gstreamer-vulkan/wayland/tests/check_gir.rs b/gstreamer-vulkan/wayland/tests/check_gir.rs new file mode 100644 index 000000000..2ccf5ff05 --- /dev/null +++ b/gstreamer-vulkan/wayland/tests/check_gir.rs @@ -0,0 +1,8 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +#[test] +fn check_gir_file() { + let res = gir_format_check::check_gir_file("Gir.toml"); + println!("{res}"); + assert_eq!(res.nb_errors, 0); +} diff --git a/gstreamer-vulkan/xcb/CHANGELOG.md b/gstreamer-vulkan/xcb/CHANGELOG.md new file mode 120000 index 000000000..d6a7bdb06 --- /dev/null +++ b/gstreamer-vulkan/xcb/CHANGELOG.md @@ -0,0 +1 @@ +../../gstreamer/CHANGELOG.md \ No newline at end of file diff --git a/gstreamer-vulkan/xcb/COPYRIGHT b/gstreamer-vulkan/xcb/COPYRIGHT new file mode 120000 index 000000000..8b0161cc9 --- /dev/null +++ b/gstreamer-vulkan/xcb/COPYRIGHT @@ -0,0 +1 @@ +../../COPYRIGHT \ No newline at end of file diff --git a/gstreamer-vulkan/xcb/Cargo.toml b/gstreamer-vulkan/xcb/Cargo.toml new file mode 100644 index 000000000..f37196f80 --- /dev/null +++ b/gstreamer-vulkan/xcb/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "gstreamer-vulkan-xcb" +authors = ["Matthew Waters "] +description = "Rust bindings for GStreamer Vulkan library (XCB support)" +license = "MIT OR Apache-2.0" +readme = "README.md" +documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_vulkan_xcb/" +keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"] +version.workspace = true +categories.workspace = true +repository.workspace = true +homepage.workspace = true +edition.workspace = true +rust-version.workspace = true + +[dependencies] +libc = "0.2" +ffi = { package = "gstreamer-vulkan-xcb-sys", path = "sys" } +glib.workspace = true +gst.workspace = true +gst-vulkan.workspace = true + +[dev-dependencies] +gir-format-check = "0.1" + +[features] +default = [] +v1_20 = ["gst/v1_20", "gst-vulkan/v1_20", "ffi/v1_20"] +v1_22 = ["gst/v1_22", "gst-vulkan/v1_22", "ffi/v1_22", "v1_20"] +v1_24 = ["gst/v1_24", "gst-vulkan/v1_24", "ffi/v1_24", "v1_22"] +v1_26 = ["gst/v1_26", "gst-vulkan/v1_26", "ffi/v1_26", "v1_24"] + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/gstreamer-vulkan/xcb/Gir.toml b/gstreamer-vulkan/xcb/Gir.toml new file mode 100644 index 000000000..49afdc721 --- /dev/null +++ b/gstreamer-vulkan/xcb/Gir.toml @@ -0,0 +1,59 @@ +[options] +girs_directories = ["../../gir-files", "../../gst-gir-files"] +library = "GstVulkanXCB" +version = "1.0" +min_cfg_version = "1.18" +work_mode = "normal" +concurrency = "send+sync" +generate_safety_asserts = true +single_version_file = true +generate_display_trait = false +trust_return_value_nullability = true + +external_libraries = [ + "GLib", + "GObject", + "Gst", + "GstBase", + "GstVideo", + "GstVulkan", +] + +generate = [] + +manual = [ + "GLib.Error", + "GLib.Thread", + "GObject.Object", + "Gst.FlowReturn", + "Gst.Object", + "Gst.PadDirection", +] + +[[object]] +name = "Gst.Buffer" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Caps" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Query" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Structure" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "GstVulkanXCB.VulkanDisplayXCB" +status = "generate" + [[object.function]] + name = "new" + [object.function.return] + nullable_return_is_error = "Failed to create XCB display" diff --git a/gstreamer-vulkan/xcb/LICENSE-APACHE b/gstreamer-vulkan/xcb/LICENSE-APACHE new file mode 120000 index 000000000..1cd601d0a --- /dev/null +++ b/gstreamer-vulkan/xcb/LICENSE-APACHE @@ -0,0 +1 @@ +../../LICENSE-APACHE \ No newline at end of file diff --git a/gstreamer-vulkan/xcb/LICENSE-MIT b/gstreamer-vulkan/xcb/LICENSE-MIT new file mode 120000 index 000000000..b2cfbdc7b --- /dev/null +++ b/gstreamer-vulkan/xcb/LICENSE-MIT @@ -0,0 +1 @@ +../../LICENSE-MIT \ No newline at end of file diff --git a/gstreamer-vulkan/xcb/README.md b/gstreamer-vulkan/xcb/README.md new file mode 100644 index 000000000..768734c3c --- /dev/null +++ b/gstreamer-vulkan/xcb/README.md @@ -0,0 +1,215 @@ +# gstreamer-rs [![crates.io](https://img.shields.io/crates/v/gstreamer-gl-x11.svg)](https://crates.io/crates/gstreamer-gl-x11) [![pipeline status](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/badges/main/pipeline.svg)](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/commits/main) + +[GStreamer](https://gstreamer.freedesktop.org/) (OpenGL library, X11 support) +bindings for Rust. Documentation can be found +[here](https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_gl_x11/). + +These bindings are providing a safe API that can be used to interface with +GStreamer, e.g. for writing GStreamer-based applications and GStreamer plugins. + +The bindings are mostly autogenerated with [gir](https://github.com/gtk-rs/gir/) +based on the [GObject-Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection/) +API metadata provided by the GStreamer project. + +## Table of Contents +1. [Installation](#installation) + 1. [Linux/BSDs](#installation-linux) + 1. [macOS](#installation-macos) + 1. [Windows](#installation-windows) +1. [Getting Started](#getting-started) +1. [License](#license) +1. [Contribution](#contribution) + + + +## Installation + +To build the GStreamer bindings or anything depending on them, you need to +have at least GStreamer 1.14 and gst-plugins-base 1.14 installed. In addition, +some of the examples/tutorials require various GStreamer plugins to be +available, which can be found in gst-plugins-base, gst-plugins-good, +gst-plugins-bad, gst-plugins-ugly and/or gst-libav. + + + +### Linux/BSDs + +You need to install the above mentioned packages with your distributions +package manager, or build them from source. + +On Debian/Ubuntu they can be installed with + +```console +$ apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \ + gstreamer1.0-libav libgstrtspserver-1.0-dev libges-1.0-dev +``` + +The minimum required version of the above libraries is >= 1.14. If you +build the gstreamer-player sub-crate, or any of the examples that +depend on gstreamer-player, you must ensure that in addition to the above +packages, `libgstreamer-plugins-bad1.0-dev` is installed. See the `Cargo.toml` +files for the full details, + +```console +$ apt-get install libgstreamer-plugins-bad1.0-dev +``` + +Package names on other distributions should be similar. +Please submit a pull request with instructions for yours. + + + +### macOS + +You can install GStreamer and the plugins via [Homebrew](https://brew.sh/) or +by installing the [binaries](https://gstreamer.freedesktop.org/data/pkg/osx/) +provided by the GStreamer project. + +We recommend using the official GStreamer binaries over Homebrew, especially +as GStreamer in Homebrew is [currently broken](https://github.com/orgs/Homebrew/discussions/3740#discussioncomment-3804964). + +#### GStreamer Binaries + +You need to download the *two* `.pkg` files from the GStreamer website and +install them, e.g. `gstreamer-1.0-1.20.4-universal.pkg` and +`gstreamer-1.0-devel-1.20.4-universal.pkg`. + +After installation, you also need to set the `PATH` environment variable as +follows + +```console +$ export PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/bin${PATH:+:$PATH}" +``` + +Also note that the `pkg-config` from GStreamer should be the first one in +the `PATH` as other versions have all kinds of quirks that will cause +problems. + +#### Homebrew + +Homebrew only installs various plugins if explicitly enabled, so some extra +`--with-*` flags may be required. + +```console +$ brew install gstreamer gst-plugins-base gst-plugins-good \ + gst-plugins-bad gst-plugins-ugly gst-libav gst-rtsp-server \ + gst-editing-services --with-orc --with-libogg --with-opus \ + --with-pango --with-theora --with-libvorbis --with-libvpx \ + --enable-gtk3 +``` + +Make sure the version of these libraries is >= 1.14. + + + +### Windows + +You can install GStreamer and the plugins via [MSYS2](http://www.msys2.org/) +with `pacman` or by installing the +[binaries](https://gstreamer.freedesktop.org/data/pkg/windows/) provided by +the GStreamer project. + +We recommend using the official GStreamer binaries over MSYS2. + +#### GStreamer Binaries + +You need to download the *two* `.msi` files for your platform from the +GStreamer website and install them, e.g. `gstreamer-1.0-x86_64-1.20.4.msi` and +`gstreamer-1.0-devel-x86_64-1.20.4.msi`. Make sure to select the version that +matches your Rust toolchain, i.e. MinGW or MSVC. + +After installation set the ``PATH` environment variable as follows: + +```console +# For a UNIX-style shell: +$ export PATH="c:/gstreamer/1.0/msvc_x86_64/bin${PATH:+:$PATH}" + +# For cmd.exe: +$ set PATH=C:\gstreamer\1.0\msvc_x86_64\bin;%PATH% +``` + +Make sure to update the path to where you have actually installed GStreamer +and for the corresponding toolchain. + +Also note that the `pkg-config.exe` from GStreamer should be the first one in +the `PATH` as other versions have all kinds of quirks that will cause +problems. + +#### MSYS2 / pacman + +```console +$ pacman -S glib2-devel pkg-config \ + mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gst-plugins-base \ + mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad \ + mingw-w64-x86_64-gst-plugins-ugly mingw-w64-x86_64-gst-libav \ + mingw-w64-x86_64-gst-rtsp-server +``` + +Make sure the version of these libraries is >= 1.14. + +Note that the version of `pkg-config` included in `MSYS2` is +[known to have problems](https://github.com/rust-lang/pkg-config-rs/issues/51#issuecomment-346300858) +compiling GStreamer, so you may need to install another version. One option +would be [`pkg-config-lite`](https://sourceforge.net/projects/pkgconfiglite/). + + + +## Getting Started + +The API reference can be found +[here](https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer/), however it is +only the Rust API reference and does not explain any of the concepts. + +For getting started with GStreamer development, the best would be to follow +the [documentation](https://gstreamer.freedesktop.org/documentation/) on the +GStreamer website, especially the [Application Development +Manual](https://gstreamer.freedesktop.org/documentation/application-development/). +While being C-centric, it explains all the fundamental concepts of GStreamer +and the code examples should be relatively easily translatable to Rust. The +API is basically the same, function/struct names are the same and everything +is only more convenient (hopefully) and safer. + +In addition there are +[tutorials](https://gstreamer.freedesktop.org/documentation/tutorials/) on the +GStreamer website. Many of them were ported to Rust already and the code can +be found in the +[tutorials](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/tree/main/tutorials) +directory. + +Some further examples for various aspects of GStreamer and how to use it from +Rust can be found in the +[examples](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/tree/main/examples) +directory. + +Various GStreamer plugins written in Rust can be found in the +[gst-plugins-rs](https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs) +repository. + + + +## LICENSE + +gstreamer-rs and all crates contained in here are licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) + +at your option. + +GStreamer itself is licensed under the Lesser General Public License version +2.1 or (at your option) any later version: +https://www.gnu.org/licenses/lgpl-2.1.html + + + +## Contribution + +Any kinds of contributions are welcome as a pull request. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in gstreamer-rs by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/gstreamer-vulkan/xcb/src/auto/mod.rs b/gstreamer-vulkan/xcb/src/auto/mod.rs new file mode 100644 index 000000000..197325642 --- /dev/null +++ b/gstreamer-vulkan/xcb/src/auto/mod.rs @@ -0,0 +1,7 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +mod vulkan_display_xcb; +pub use self::vulkan_display_xcb::VulkanDisplayXCB; diff --git a/gstreamer-vulkan/xcb/src/auto/versions.txt b/gstreamer-vulkan/xcb/src/auto/versions.txt new file mode 100644 index 000000000..5753ee763 --- /dev/null +++ b/gstreamer-vulkan/xcb/src/auto/versions.txt @@ -0,0 +1,3 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 5223ce91b97a) +from gir-files (https://github.com/gtk-rs/gir-files @ 6cd7b656acd6) +from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ d62956d67216+) diff --git a/gstreamer-vulkan/xcb/src/auto/vulkan_display_xcb.rs b/gstreamer-vulkan/xcb/src/auto/vulkan_display_xcb.rs new file mode 100644 index 000000000..e9263c8b8 --- /dev/null +++ b/gstreamer-vulkan/xcb/src/auto/vulkan_display_xcb.rs @@ -0,0 +1,29 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use glib::translate::*; + +glib::wrapper! { + #[doc(alias = "GstVulkanDisplayXCB")] + pub struct VulkanDisplayXCB(Object) @extends gst::Object; + + match fn { + type_ => || ffi::gst_vulkan_display_xcb_get_type(), + } +} + +impl VulkanDisplayXCB { + #[doc(alias = "gst_vulkan_display_xcb_new")] + pub fn new(name: Option<&str>) -> Result { + assert_initialized_main_thread!(); + unsafe { + Option::<_>::from_glib_full(ffi::gst_vulkan_display_xcb_new(name.to_glib_none().0)) + .ok_or_else(|| glib::bool_error!("Failed to create XCB display")) + } + } +} + +unsafe impl Send for VulkanDisplayXCB {} +unsafe impl Sync for VulkanDisplayXCB {} diff --git a/gstreamer-vulkan/xcb/src/lib.rs b/gstreamer-vulkan/xcb/src/lib.rs new file mode 100644 index 000000000..be6904541 --- /dev/null +++ b/gstreamer-vulkan/xcb/src/lib.rs @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Matthew Waters +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![cfg_attr(docsrs, feature(doc_cfg))] +#![allow(clippy::missing_safety_doc)] + +pub use ffi; +pub use gst_vulkan; + +macro_rules! assert_initialized_main_thread { + () => { + if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) { + gst::assert_initialized(); + } + }; +} + +mod auto; +pub use auto::*; diff --git a/gstreamer-vulkan/xcb/sys/CHANGELOG.md b/gstreamer-vulkan/xcb/sys/CHANGELOG.md new file mode 120000 index 000000000..ba8c4d72f --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/CHANGELOG.md @@ -0,0 +1 @@ +../../../gstreamer/CHANGELOG.md \ No newline at end of file diff --git a/gstreamer-vulkan/xcb/sys/COPYRIGHT b/gstreamer-vulkan/xcb/sys/COPYRIGHT new file mode 120000 index 000000000..9c6cf1d41 --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/COPYRIGHT @@ -0,0 +1 @@ +../../../COPYRIGHT \ No newline at end of file diff --git a/gstreamer-vulkan/xcb/sys/Cargo.toml b/gstreamer-vulkan/xcb/sys/Cargo.toml new file mode 100644 index 000000000..2e0e72364 --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/Cargo.toml @@ -0,0 +1,78 @@ +[package] +authors = ["Matthew Waters "] +build = "build.rs" +description = "FFI bindings to libgstvulkan-1.0 (XCB support)" +documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_vulkan_xcb_sys/" +keywords = ["ffi", "gstreamer", "gnome", "multimedia"] +license = "MIT" +name = "gstreamer-vulkan-xcb-sys" +readme = "README.md" + +[package.version] +workspace = true + +[package.categories] +workspace = true + +[package.repository] +workspace = true + +[package.homepage] +workspace = true + +[package.edition] +workspace = true + +[package.rust-version] +workspace = true + +[package.metadata.system-deps.gstreamer_vulkan_xcb_1_0] +name = "gstreamer-vulkan-xcb-1.0" +version = "1.18" + +[package.metadata.system-deps.gstreamer_vulkan_xcb_1_0.v1_18] +name = "gstreamer-vulkan-xcb-1.0" +version = "1.18" + +[package.metadata.system-deps.gstreamer_vulkan_xcb_1_0.v1_20] +version = "1.20" + +[package.metadata.system-deps.gstreamer_vulkan_xcb_1_0.v1_22] +version = "1.22" + +[package.metadata.system-deps.gstreamer_vulkan_xcb_1_0.v1_24] +version = "1.24" + +[package.metadata.system-deps.gstreamer_vulkan_xcb_1_0.v1_26] +version = "1.25" + +[package.metadata.docs.rs] +all-features = true +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] + +[lib] +name = "gstreamer_vulkan_xcb_sys" + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +workspace = true + +[dependencies.gstreamer-vulkan-sys] +workspace = true + +[build-dependencies] +system-deps = "6" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] +v1_18 = [] +v1_20 = [] +v1_22 = ["v1_20"] +v1_24 = ["v1_22"] +v1_26 = ["v1_24"] diff --git a/gstreamer-vulkan/xcb/sys/Gir.toml b/gstreamer-vulkan/xcb/sys/Gir.toml new file mode 100644 index 000000000..979211e4e --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/Gir.toml @@ -0,0 +1,24 @@ +[options] +girs_directories = ["../../../gir-files", "../../../gst-gir-files"] +library = "GstVulkanXCB" +min_cfg_version = "1.18" +version = "1.0" +work_mode = "sys" +single_version_file = true + +extra_versions = [ + "1.24", + "1.22", + "1.20", +] + +external_libraries = [ + "GLib", +] + +generate = [ + "GstVulkanXCB.VulkanDisplayXCB", +] + +[external_libraries] +gstreamer-vulkan = "GstVulkan" diff --git a/gstreamer-vulkan/xcb/sys/LICENSE b/gstreamer-vulkan/xcb/sys/LICENSE new file mode 120000 index 000000000..98cefa6a6 --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/LICENSE @@ -0,0 +1 @@ +../../../LICENSE-MIT \ No newline at end of file diff --git a/gstreamer-vulkan/xcb/sys/README.md b/gstreamer-vulkan/xcb/sys/README.md new file mode 100644 index 000000000..d73cc4024 --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/README.md @@ -0,0 +1,31 @@ +# gstreamer-sys [![crates.io](https://img.shields.io/crates/v/gstreamer-gl-x11-sys.svg)](https://crates.io/crates/gstreamer-gl-x11-sys) [![pipeline status](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/badges/main/pipeline.svg)](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/commits/main) + +[GStreamer](https://gstreamer.freedesktop.org/) (OpenGL library, X11 support) FFI bindings for Rust. + +These bindings are providing unsafe FFI API that can be used to interface with +GStreamer. Generally they are meant to be used as the building block for +higher-level abstractions like: + + * Bindings for GStreamer applications and plugins: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs + * Various GStreamer plugins written in Rust: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs + +The bindings are autogenerated with [gir](https://github.com/gtk-rs/gir/) +based on the [GObject-Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection/) +API metadata provided by the GStreamer project. + +## LICENSE + +gstreamer-sys and all crates contained here are licensed under the MIT +license ([LICENSE](LICENSE) or http://opensource.org/licenses/MIT). + +GStreamer itself is licensed under the Lesser General Public License version +2.1 or (at your option) any later version: +https://www.gnu.org/licenses/lgpl-2.1.html + +## Contribution + +Any kinds of contributions are welcome as a pull request. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in gstreamer-rs by you shall be licensed under the MIT license as above, +without any additional terms or conditions. diff --git a/gstreamer-vulkan/xcb/sys/build.rs b/gstreamer-vulkan/xcb/sys/build.rs new file mode 100644 index 000000000..29420c9ee --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/build.rs @@ -0,0 +1,18 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#[cfg(not(docsrs))] +use std::process; + +#[cfg(docsrs)] +fn main() {} // prevent linking libraries to avoid documentation failure + +#[cfg(not(docsrs))] +fn main() { + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + process::exit(1); + } +} diff --git a/gstreamer-vulkan/xcb/sys/src/auto/versions.txt b/gstreamer-vulkan/xcb/sys/src/auto/versions.txt new file mode 100644 index 000000000..5753ee763 --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/src/auto/versions.txt @@ -0,0 +1,3 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 5223ce91b97a) +from gir-files (https://github.com/gtk-rs/gir-files @ 6cd7b656acd6) +from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ d62956d67216+) diff --git a/gstreamer-vulkan/xcb/sys/src/lib.rs b/gstreamer-vulkan/xcb/sys/src/lib.rs new file mode 100644 index 000000000..c202a1833 --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/src/lib.rs @@ -0,0 +1,69 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use glib_sys as glib; +use gstreamer_vulkan_sys as gst_vulkan; + +#[allow(unused_imports)] +use libc::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, + intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE, +}; +#[cfg(unix)] +#[allow(unused_imports)] +use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Records +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstVulkanDisplayXCBClass { + pub object_class: gst_vulkan::GstVulkanDisplayClass, + pub _reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstVulkanDisplayXCBClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDisplayXCBClass @ {self:p}")) + .field("object_class", &self.object_class) + .finish() + } +} + +// Classes +#[repr(C)] +pub struct GstVulkanDisplayXCB { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GstVulkanDisplayXCB { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstVulkanDisplayXCB @ {self:p}")) + .finish() + } +} + +#[link(name = "gstvulkan-1.0")] +extern "C" { + + //========================================================================= + // GstVulkanDisplayXCB + //========================================================================= + pub fn gst_vulkan_display_xcb_get_type() -> GType; + pub fn gst_vulkan_display_xcb_new(name: *const c_char) -> *mut GstVulkanDisplayXCB; + +} diff --git a/gstreamer-vulkan/xcb/sys/tests/abi.rs b/gstreamer-vulkan/xcb/sys/tests/abi.rs new file mode 100644 index 000000000..470cf0d41 --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/tests/abi.rs @@ -0,0 +1,212 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#![cfg(unix)] + +use gstreamer_vulkan_xcb_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["gstreamer-vulkan-xcb-1.0"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec, +} + +impl Compiler { + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result, Box> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[( + "GstVulkanDisplayXCBClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, +)]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[]; diff --git a/gstreamer-vulkan/xcb/sys/tests/constant.c b/gstreamer-vulkan/xcb/sys/tests/constant.c new file mode 100644 index 000000000..d37bc26f5 --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/tests/constant.c @@ -0,0 +1,33 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#include "manual.h" +#include + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((CONSTANT_NAME), \ + char *: "%s", \ + const char *: "%s", \ + char: "%c", \ + signed char: "%hhd", \ + unsigned char: "%hhu", \ + short int: "%hd", \ + unsigned short int: "%hu", \ + int: "%d", \ + unsigned int: "%u", \ + long: "%ld", \ + unsigned long: "%lu", \ + long long: "%lld", \ + unsigned long long: "%llu", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + return 0; +} diff --git a/gstreamer-vulkan/xcb/sys/tests/layout.c b/gstreamer-vulkan/xcb/sys/tests/layout.c new file mode 100644 index 000000000..1ac31125c --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/tests/layout.c @@ -0,0 +1,13 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%s;%zu;%zu\n", "GstVulkanDisplayXCBClass", sizeof(GstVulkanDisplayXCBClass), alignof(GstVulkanDisplayXCBClass)); + return 0; +} diff --git a/gstreamer-vulkan/xcb/sys/tests/manual.h b/gstreamer-vulkan/xcb/sys/tests/manual.h new file mode 100644 index 000000000..f7e76e0cc --- /dev/null +++ b/gstreamer-vulkan/xcb/sys/tests/manual.h @@ -0,0 +1,13 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +// FIXME These types should be defined but are not +#include + +struct rsgstvulkanxcbconnection; +typedef struct rsgstvulkanxcbconnection xcb_connection_t; +typedef guint32 xcb_window_t; +struct rsgstvulkanxcbvisualid; +typedef struct rsgstvulkanxcbvisualid xcb_visualid_t; +struct rsgstvulkanxcbscreen; +typedef struct rsgstvulkanxcbscreen xcb_screen_t; +#include diff --git a/gstreamer-vulkan/xcb/tests/check_gir.rs b/gstreamer-vulkan/xcb/tests/check_gir.rs new file mode 100644 index 000000000..2ccf5ff05 --- /dev/null +++ b/gstreamer-vulkan/xcb/tests/check_gir.rs @@ -0,0 +1,8 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +#[test] +fn check_gir_file() { + let res = gir_format_check::check_gir_file("Gir.toml"); + println!("{res}"); + assert_eq!(res.nb_errors, 0); +}