From c10176e03605b7a2dcbe7c7893c4b28863d90206 Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Fri, 8 Mar 2024 18:45:22 -0500 Subject: [PATCH 1/6] nvfbc-sys: Add Windows Support --- .editorconfig | 8 - Cargo.lock | 315 +++- nvfbc-sys/Cargo.toml | 5 + nvfbc-sys/bindgen | 10 - nvfbc-sys/build.rs | 75 +- nvfbc-sys/src/generated.rs | 3594 ------------------------------------ nvfbc-sys/src/lib.rs | 23 +- nvfbc-sys/wrapper.h | 4 + nvfbc/src/common.rs | 29 +- nvfbc/src/cuda.rs | 55 +- nvfbc/src/error.rs | 37 +- nvfbc/src/lib.rs | 4 +- nvfbc/src/system.rs | 42 +- nvfbc/src/types.rs | 9 +- rustfmt.toml | 2 + 15 files changed, 492 insertions(+), 3720 deletions(-) delete mode 100644 .editorconfig delete mode 100755 nvfbc-sys/bindgen delete mode 100644 nvfbc-sys/src/generated.rs create mode 100644 nvfbc-sys/wrapper.h diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index d1ddcc7..0000000 --- a/.editorconfig +++ /dev/null @@ -1,8 +0,0 @@ -root = true - -[*] -indent_style = tab -indent_size = 4 -end_of_line = lf -trim_trailing_whitespace = true -insert_final_newline = true diff --git a/Cargo.lock b/Cargo.lock index bf36db9..1d674e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,12 +8,43 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "bindgen" +version = "0.69.4" +source = "git+https://github.com/jbaublitz/rust-bindgen.git?branch=issue-rust-bindgen-753#76792cb1d2a163d4609cb0877ff39189f9105140" +dependencies = [ + "bitflags 2.4.2", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.52", + "which", +] + [[package]] name = "bit_field" version = "0.10.2" @@ -26,6 +57,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + [[package]] name = "bytemuck" version = "1.14.0" @@ -38,12 +75,32 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clang-sys" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -120,6 +177,16 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "exr" version = "1.71.0" @@ -189,6 +256,15 @@ dependencies = [ "crunchy", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys", +] + [[package]] name = "image" version = "0.24.7" @@ -208,6 +284,15 @@ dependencies = [ "tiff", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "jpeg-decoder" version = "0.3.0" @@ -217,12 +302,46 @@ dependencies = [ "rayon", ] +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "lebe" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "lock_api" version = "0.4.11" @@ -233,6 +352,24 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -243,6 +380,16 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -287,6 +434,15 @@ dependencies = [ [[package]] name = "nvfbc-sys" version = "0.1.5" +dependencies = [ + "bindgen", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "png" @@ -294,13 +450,23 @@ version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", "miniz_oxide", ] +[[package]] +name = "prettyplease" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" +dependencies = [ + "proc-macro2", + "syn 2.0.52", +] + [[package]] name = "proc-macro2" version = "1.0.76" @@ -348,13 +514,42 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + [[package]] name = "rustacuda" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47208516ab5338b592d63560e90eaef405d0ec880347eaf7742d893b0a31e228" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cuda-driver-sys", "rustacuda_core", "rustacuda_derive", @@ -374,7 +569,26 @@ checksum = "43ce8670a1a1d0fc2514a3b846dacdb65646f9bd494b6674cfacbb4ce430bd7e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", ] [[package]] @@ -383,6 +597,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "simd-adler32" version = "0.3.7" @@ -415,6 +635,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tiff" version = "0.9.0" @@ -438,6 +669,84 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" + [[package]] name = "zune-inflate" version = "0.2.54" diff --git a/nvfbc-sys/Cargo.toml b/nvfbc-sys/Cargo.toml index ccbfe5e..74f446d 100644 --- a/nvfbc-sys/Cargo.toml +++ b/nvfbc-sys/Cargo.toml @@ -8,3 +8,8 @@ license = "BSD-2-Clause" keywords = ["NVFBC"] categories = ["multimedia::video"] repository = "https://github.com/hgaiser/nvfbc-rs" + +[build-dependencies] +# https://github.com/rust-lang/rust-bindgen/issues/753 +bindgen = { git = "https://github.com/jbaublitz/rust-bindgen.git", branch = "issue-rust-bindgen-753" } + diff --git a/nvfbc-sys/bindgen b/nvfbc-sys/bindgen deleted file mode 100755 index 4144d71..0000000 --- a/nvfbc-sys/bindgen +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -cd "$(dirname "$0")" - -if ! command -v bindgen >/dev/null; then - echo "bindgen not found: you can install it by running: cargo install bindgen" - exit 1 -fi - -bindgen ./NvFBC.h -o src/generated.rs diff --git a/nvfbc-sys/build.rs b/nvfbc-sys/build.rs index 3d1a3a2..7095ce8 100644 --- a/nvfbc-sys/build.rs +++ b/nvfbc-sys/build.rs @@ -1,3 +1,76 @@ +use std::{env, path::PathBuf}; + +/* + * The Nvidia Frame Buffer Capture SDK (NvFBC) was deprecated for Windows 10 1803.17134 + * However, the last supported version v7.1.1 still works with the latest GPU drivers. + * It only works with enterprise Quadro cards, or with a driver patch for consumer cards. + * Linux is still supported with the latest version v8.0.8 + * + * The NVIDIA Capture SDK installer for Windows comes with the dynamic library and headers, + * While for Linux only the header file is provided, and the dynamic library is expected + * to be installed with the proprietary graphics driver. The header is included with this crate. + */ fn main() { - println!("cargo:rustc-link-lib=dylib=nvidia-fbc"); + let include_path = if cfg!(target_os = "windows") { + "C:\\Program Files (x86)\\NVIDIA Corporation\\NVIDIA Capture SDK\\inc\\NvFBC" + } else if cfg!(target_os = "linux") { + "." // Local header file + } else { + unimplemented!("Unsupported OS") + }; + + let library_name = if cfg!(target_os = "linux") { + "nvidia-fbc" // System library name + } else if cfg!(target_os = "windows") { + if cfg!(target_arch = "x86_64") { + "nvapi64" + } else if cfg!(target_arch = "x86") { + "nvapi" + } else { + unimplemented!("Unsupported Arch") + } + } else { + unimplemented!("Unsupported OS") + }; + + let library_path = if cfg!(target_os = "linux") { + "." + } else if cfg!(target_os = "windows") { + if cfg!(target_arch = "x86_64") { + "C:\\Program Files (x86)\\NVIDIA Corporation\\NVIDIA Capture SDK\\lib\\NvAPI\\amd64" + } else if cfg!(target_arch = "x86") { + "C:\\Program Files (x86)\\NVIDIA Corporation\\NVIDIA Capture SDK\\lib\\NvAPI\\x86" + } else { + unimplemented!("Unsupported Arch") + } + } else { + unimplemented!("Unsupported OS") + }; + + // Windows has multiple C++ header files + let header_name = if cfg!(target_os = "linux") { + "nvFBC.h" + } else if cfg!(target_os = "windows") { + "wrapper.h" + } else { + unimplemented!("Unsupported OS") + }; + + println!("cargo:rustc-link-search={library_path}"); + println!("cargo:rustc-link-lib={library_name}"); + println!("cargo:rerun-if-changed=wrapper.h"); + + let bindings = bindgen::Builder::default() + .header(header_name) + .clang_args(["-I", include_path]) + .clang_args(["-x", "c++"]) + .clang_macro_fallback() + .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) + .generate() + .expect("Unable to generate bindings"); + + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings!"); } diff --git a/nvfbc-sys/src/generated.rs b/nvfbc-sys/src/generated.rs deleted file mode 100644 index ebe4c8b..0000000 --- a/nvfbc-sys/src/generated.rs +++ /dev/null @@ -1,3594 +0,0 @@ -/* automatically generated by rust-bindgen 0.60.1 */ - -pub const _STDINT_H: u32 = 1; -pub const _FEATURES_H: u32 = 1; -pub const _DEFAULT_SOURCE: u32 = 1; -pub const __GLIBC_USE_ISOC2X: u32 = 0; -pub const __USE_ISOC11: u32 = 1; -pub const __USE_ISOC99: u32 = 1; -pub const __USE_ISOC95: u32 = 1; -pub const __USE_POSIX_IMPLICITLY: u32 = 1; -pub const _POSIX_SOURCE: u32 = 1; -pub const _POSIX_C_SOURCE: u32 = 200809; -pub const __USE_POSIX: u32 = 1; -pub const __USE_POSIX2: u32 = 1; -pub const __USE_POSIX199309: u32 = 1; -pub const __USE_POSIX199506: u32 = 1; -pub const __USE_XOPEN2K: u32 = 1; -pub const __USE_XOPEN2K8: u32 = 1; -pub const _ATFILE_SOURCE: u32 = 1; -pub const __WORDSIZE: u32 = 64; -pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; -pub const __SYSCALL_WORDSIZE: u32 = 64; -pub const __TIMESIZE: u32 = 64; -pub const __USE_MISC: u32 = 1; -pub const __USE_ATFILE: u32 = 1; -pub const __USE_FORTIFY_LEVEL: u32 = 0; -pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; -pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; -pub const _STDC_PREDEF_H: u32 = 1; -pub const __STDC_IEC_559__: u32 = 1; -pub const __STDC_IEC_60559_BFP__: u32 = 201404; -pub const __STDC_IEC_559_COMPLEX__: u32 = 1; -pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404; -pub const __STDC_ISO_10646__: u32 = 201706; -pub const __GNU_LIBRARY__: u32 = 6; -pub const __GLIBC__: u32 = 2; -pub const __GLIBC_MINOR__: u32 = 35; -pub const _SYS_CDEFS_H: u32 = 1; -pub const __glibc_c99_flexarr_available: u32 = 1; -pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; -pub const __HAVE_GENERIC_SELECTION: u32 = 1; -pub const __GLIBC_USE_LIB_EXT2: u32 = 0; -pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; -pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; -pub const __GLIBC_USE_IEC_60559_EXT: u32 = 0; -pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; -pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; -pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; -pub const _BITS_TYPES_H: u32 = 1; -pub const _BITS_TYPESIZES_H: u32 = 1; -pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; -pub const __INO_T_MATCHES_INO64_T: u32 = 1; -pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; -pub const __STATFS_MATCHES_STATFS64: u32 = 1; -pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64: u32 = 1; -pub const __FD_SETSIZE: u32 = 1024; -pub const _BITS_TIME64_H: u32 = 1; -pub const _BITS_WCHAR_H: u32 = 1; -pub const _BITS_STDINT_INTN_H: u32 = 1; -pub const _BITS_STDINT_UINTN_H: u32 = 1; -pub const INT8_MIN: i32 = -128; -pub const INT16_MIN: i32 = -32768; -pub const INT32_MIN: i32 = -2147483648; -pub const INT8_MAX: u32 = 127; -pub const INT16_MAX: u32 = 32767; -pub const INT32_MAX: u32 = 2147483647; -pub const UINT8_MAX: u32 = 255; -pub const UINT16_MAX: u32 = 65535; -pub const UINT32_MAX: u32 = 4294967295; -pub const INT_LEAST8_MIN: i32 = -128; -pub const INT_LEAST16_MIN: i32 = -32768; -pub const INT_LEAST32_MIN: i32 = -2147483648; -pub const INT_LEAST8_MAX: u32 = 127; -pub const INT_LEAST16_MAX: u32 = 32767; -pub const INT_LEAST32_MAX: u32 = 2147483647; -pub const UINT_LEAST8_MAX: u32 = 255; -pub const UINT_LEAST16_MAX: u32 = 65535; -pub const UINT_LEAST32_MAX: u32 = 4294967295; -pub const INT_FAST8_MIN: i32 = -128; -pub const INT_FAST16_MIN: i64 = -9223372036854775808; -pub const INT_FAST32_MIN: i64 = -9223372036854775808; -pub const INT_FAST8_MAX: u32 = 127; -pub const INT_FAST16_MAX: u64 = 9223372036854775807; -pub const INT_FAST32_MAX: u64 = 9223372036854775807; -pub const UINT_FAST8_MAX: u32 = 255; -pub const UINT_FAST16_MAX: i32 = -1; -pub const UINT_FAST32_MAX: i32 = -1; -pub const INTPTR_MIN: i64 = -9223372036854775808; -pub const INTPTR_MAX: u64 = 9223372036854775807; -pub const UINTPTR_MAX: i32 = -1; -pub const PTRDIFF_MIN: i64 = -9223372036854775808; -pub const PTRDIFF_MAX: u64 = 9223372036854775807; -pub const SIG_ATOMIC_MIN: i32 = -2147483648; -pub const SIG_ATOMIC_MAX: u32 = 2147483647; -pub const SIZE_MAX: i32 = -1; -pub const WINT_MIN: u32 = 0; -pub const WINT_MAX: u32 = 4294967295; -pub const NVFBC_VERSION_MAJOR: u32 = 1; -pub const NVFBC_VERSION_MINOR: u32 = 8; -pub const NVFBC_ERR_STR_LEN: u32 = 512; -pub const NVFBC_OUTPUT_MAX: u32 = 5; -pub const NVFBC_OUTPUT_NAME_LEN: u32 = 128; -pub const NVFBC_TOGL_TEXTURES_MAX: u32 = 2; -pub type __u_char = ::std::os::raw::c_uchar; -pub type __u_short = ::std::os::raw::c_ushort; -pub type __u_int = ::std::os::raw::c_uint; -pub type __u_long = ::std::os::raw::c_ulong; -pub type __int8_t = ::std::os::raw::c_schar; -pub type __uint8_t = ::std::os::raw::c_uchar; -pub type __int16_t = ::std::os::raw::c_short; -pub type __uint16_t = ::std::os::raw::c_ushort; -pub type __int32_t = ::std::os::raw::c_int; -pub type __uint32_t = ::std::os::raw::c_uint; -pub type __int64_t = ::std::os::raw::c_long; -pub type __uint64_t = ::std::os::raw::c_ulong; -pub type __int_least8_t = __int8_t; -pub type __uint_least8_t = __uint8_t; -pub type __int_least16_t = __int16_t; -pub type __uint_least16_t = __uint16_t; -pub type __int_least32_t = __int32_t; -pub type __uint_least32_t = __uint32_t; -pub type __int_least64_t = __int64_t; -pub type __uint_least64_t = __uint64_t; -pub type __quad_t = ::std::os::raw::c_long; -pub type __u_quad_t = ::std::os::raw::c_ulong; -pub type __intmax_t = ::std::os::raw::c_long; -pub type __uintmax_t = ::std::os::raw::c_ulong; -pub type __dev_t = ::std::os::raw::c_ulong; -pub type __uid_t = ::std::os::raw::c_uint; -pub type __gid_t = ::std::os::raw::c_uint; -pub type __ino_t = ::std::os::raw::c_ulong; -pub type __ino64_t = ::std::os::raw::c_ulong; -pub type __mode_t = ::std::os::raw::c_uint; -pub type __nlink_t = ::std::os::raw::c_ulong; -pub type __off_t = ::std::os::raw::c_long; -pub type __off64_t = ::std::os::raw::c_long; -pub type __pid_t = ::std::os::raw::c_int; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __fsid_t { - pub __val: [::std::os::raw::c_int; 2usize], -} -#[test] -fn bindgen_test_layout___fsid_t() { - assert_eq!( - ::std::mem::size_of::<__fsid_t>(), - 8usize, - concat!("Size of: ", stringify!(__fsid_t)) - ); - assert_eq!( - ::std::mem::align_of::<__fsid_t>(), - 4usize, - concat!("Alignment of ", stringify!(__fsid_t)) - ); - fn test_field___val() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<__fsid_t>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).__val) as usize - ptr as usize - }, - 0usize, - concat!("Offset of field: ", stringify!(__fsid_t), "::", stringify!(__val)) - ); - } - test_field___val(); -} -pub type __clock_t = ::std::os::raw::c_long; -pub type __rlim_t = ::std::os::raw::c_ulong; -pub type __rlim64_t = ::std::os::raw::c_ulong; -pub type __id_t = ::std::os::raw::c_uint; -pub type __time_t = ::std::os::raw::c_long; -pub type __useconds_t = ::std::os::raw::c_uint; -pub type __suseconds_t = ::std::os::raw::c_long; -pub type __suseconds64_t = ::std::os::raw::c_long; -pub type __daddr_t = ::std::os::raw::c_int; -pub type __key_t = ::std::os::raw::c_int; -pub type __clockid_t = ::std::os::raw::c_int; -pub type __timer_t = *mut ::std::os::raw::c_void; -pub type __blksize_t = ::std::os::raw::c_long; -pub type __blkcnt_t = ::std::os::raw::c_long; -pub type __blkcnt64_t = ::std::os::raw::c_long; -pub type __fsblkcnt_t = ::std::os::raw::c_ulong; -pub type __fsblkcnt64_t = ::std::os::raw::c_ulong; -pub type __fsfilcnt_t = ::std::os::raw::c_ulong; -pub type __fsfilcnt64_t = ::std::os::raw::c_ulong; -pub type __fsword_t = ::std::os::raw::c_long; -pub type __ssize_t = ::std::os::raw::c_long; -pub type __syscall_slong_t = ::std::os::raw::c_long; -pub type __syscall_ulong_t = ::std::os::raw::c_ulong; -pub type __loff_t = __off64_t; -pub type __caddr_t = *mut ::std::os::raw::c_char; -pub type __intptr_t = ::std::os::raw::c_long; -pub type __socklen_t = ::std::os::raw::c_uint; -pub type __sig_atomic_t = ::std::os::raw::c_int; -pub type int_least8_t = __int_least8_t; -pub type int_least16_t = __int_least16_t; -pub type int_least32_t = __int_least32_t; -pub type int_least64_t = __int_least64_t; -pub type uint_least8_t = __uint_least8_t; -pub type uint_least16_t = __uint_least16_t; -pub type uint_least32_t = __uint_least32_t; -pub type uint_least64_t = __uint_least64_t; -pub type int_fast8_t = ::std::os::raw::c_schar; -pub type int_fast16_t = ::std::os::raw::c_long; -pub type int_fast32_t = ::std::os::raw::c_long; -pub type int_fast64_t = ::std::os::raw::c_long; -pub type uint_fast8_t = ::std::os::raw::c_uchar; -pub type uint_fast16_t = ::std::os::raw::c_ulong; -pub type uint_fast32_t = ::std::os::raw::c_ulong; -pub type uint_fast64_t = ::std::os::raw::c_ulong; -pub type intmax_t = __intmax_t; -pub type uintmax_t = __uintmax_t; -#[doc = " This indicates that the API call returned with no errors."] -pub const _NVFBCSTATUS_NVFBC_SUCCESS: _NVFBCSTATUS = 0; -#[doc = " This indicates that the API version between the client and the library"] -#[doc = " is not compatible."] -pub const _NVFBCSTATUS_NVFBC_ERR_API_VERSION: _NVFBCSTATUS = 1; -#[doc = " An internal error occurred."] -pub const _NVFBCSTATUS_NVFBC_ERR_INTERNAL: _NVFBCSTATUS = 2; -#[doc = " This indicates that one or more of the parameter passed to the API call"] -#[doc = " is invalid."] -pub const _NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM: _NVFBCSTATUS = 3; -#[doc = " This indicates that one or more of the pointers passed to the API call"] -#[doc = " is invalid."] -pub const _NVFBCSTATUS_NVFBC_ERR_INVALID_PTR: _NVFBCSTATUS = 4; -#[doc = " This indicates that the handle passed to the API call to identify the"] -#[doc = " client is invalid."] -pub const _NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE: _NVFBCSTATUS = 5; -#[doc = " This indicates that the maximum number of threaded clients of the same"] -#[doc = " process has been reached. The limit is 10 threads per process."] -#[doc = " There is no limit on the number of process."] -pub const _NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS: _NVFBCSTATUS = 6; -#[doc = " This indicates that the requested feature is not currently supported"] -#[doc = " by the library."] -pub const _NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED: _NVFBCSTATUS = 7; -#[doc = " This indicates that the API call failed because it was unable to allocate"] -#[doc = " enough memory to perform the requested operation."] -pub const _NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY: _NVFBCSTATUS = 8; -#[doc = " This indicates that the API call was not expected. This happens when"] -#[doc = " API calls are performed in a wrong order, such as trying to capture"] -#[doc = " a frame prior to creating a new capture session; or trying to set up"] -#[doc = " a capture to video memory although a capture session to system memory"] -#[doc = " was created."] -pub const _NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST: _NVFBCSTATUS = 9; -#[doc = " This indicates an X error, most likely meaning that the X server has"] -#[doc = " been terminated. When this error is returned, the only resort is to"] -#[doc = " create another FBC handle using NvFBCCreateHandle()."] -#[doc = ""] -#[doc = " The previous handle should still be freed with NvFBCDestroyHandle(), but"] -#[doc = " it might leak resources, in particular X, GLX, and GL resources since"] -#[doc = " it is no longer possible to communicate with an X server to free them"] -#[doc = " through the driver."] -#[doc = ""] -#[doc = " The best course of action to eliminate this potential leak is to close"] -#[doc = " the OpenGL driver, close the forked process running the capture, or"] -#[doc = " restart the application."] -pub const _NVFBCSTATUS_NVFBC_ERR_X: _NVFBCSTATUS = 10; -#[doc = " This indicates a GLX error."] -pub const _NVFBCSTATUS_NVFBC_ERR_GLX: _NVFBCSTATUS = 11; -#[doc = " This indicates an OpenGL error."] -pub const _NVFBCSTATUS_NVFBC_ERR_GL: _NVFBCSTATUS = 12; -#[doc = " This indicates a CUDA error."] -pub const _NVFBCSTATUS_NVFBC_ERR_CUDA: _NVFBCSTATUS = 13; -#[doc = " This indicates a HW encoder error."] -pub const _NVFBCSTATUS_NVFBC_ERR_ENCODER: _NVFBCSTATUS = 14; -#[doc = " This indicates an NvFBC context error."] -pub const _NVFBCSTATUS_NVFBC_ERR_CONTEXT: _NVFBCSTATUS = 15; -#[doc = " This indicates that the application must recreate the capture session."] -#[doc = ""] -#[doc = " This error can be returned if a modeset event occurred while capturing"] -#[doc = " frames, and NVFBC_CREATE_HANDLE_PARAMS::bDisableAutoModesetRecovery"] -#[doc = " was set to NVFBC_TRUE."] -pub const _NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE: _NVFBCSTATUS = 16; -#[doc = " This indicates a Vulkan error."] -pub const _NVFBCSTATUS_NVFBC_ERR_VULKAN: _NVFBCSTATUS = 17; -#[doc = " Defines error codes."] -#[doc = ""] -#[doc = " \\see NvFBCGetLastErrorStr"] -pub type _NVFBCSTATUS = ::std::os::raw::c_uint; -#[doc = " Defines error codes."] -#[doc = ""] -#[doc = " \\see NvFBCGetLastErrorStr"] -pub use self::_NVFBCSTATUS as NVFBCSTATUS; -#[doc = " False value."] -pub const _NVFBC_BOOL_NVFBC_FALSE: _NVFBC_BOOL = 0; -#[doc = " True value."] -pub const _NVFBC_BOOL_NVFBC_TRUE: _NVFBC_BOOL = 1; -#[doc = " Defines boolean values."] -pub type _NVFBC_BOOL = ::std::os::raw::c_uint; -#[doc = " Defines boolean values."] -pub use self::_NVFBC_BOOL as NVFBC_BOOL; -#[doc = " Capture frames to a buffer in system memory."] -pub const _NVFBC_CAPTURE_TYPE_NVFBC_CAPTURE_TO_SYS: _NVFBC_CAPTURE_TYPE = 0; -#[doc = " Capture frames to a CUDA device in video memory."] -#[doc = ""] -#[doc = " Specifying this will dlopen() libcuda.so.1 and fail if not available."] -pub const _NVFBC_CAPTURE_TYPE_NVFBC_CAPTURE_SHARED_CUDA: _NVFBC_CAPTURE_TYPE = 1; -#[doc = " Capture frames to an OpenGL buffer in video memory."] -pub const _NVFBC_CAPTURE_TYPE_NVFBC_CAPTURE_TO_GL: _NVFBC_CAPTURE_TYPE = 3; -#[doc = " Capture type."] -pub type _NVFBC_CAPTURE_TYPE = ::std::os::raw::c_uint; -#[doc = " Capture type."] -pub use self::_NVFBC_CAPTURE_TYPE as NVFBC_CAPTURE_TYPE; -#[doc = " By default, NvFBC tries to track a connected primary output. If none is"] -#[doc = " found, then it tries to track the first connected output. If none is"] -#[doc = " found then it tracks the entire X screen."] -#[doc = ""] -#[doc = " If the XRandR extension is not available, this option has the same effect"] -#[doc = " as ::NVFBC_TRACKING_SCREEN."] -#[doc = ""] -#[doc = " This default behavior might be subject to changes in the future."] -pub const NVFBC_TRACKING_TYPE_NVFBC_TRACKING_DEFAULT: NVFBC_TRACKING_TYPE = 0; -#[doc = " Track an RandR output specified by its ID in the appropriate field."] -#[doc = ""] -#[doc = " The list of connected outputs can be queried via NvFBCGetStatus()."] -#[doc = " This list can also be obtained using e.g., xrandr(1)."] -#[doc = ""] -#[doc = " If the XRandR extension is not available, setting this option returns an"] -#[doc = " error."] -pub const NVFBC_TRACKING_TYPE_NVFBC_TRACKING_OUTPUT: NVFBC_TRACKING_TYPE = 1; -#[doc = " Track the entire X screen."] -pub const NVFBC_TRACKING_TYPE_NVFBC_TRACKING_SCREEN: NVFBC_TRACKING_TYPE = 2; -#[doc = " Tracking type."] -#[doc = ""] -#[doc = " NvFBC can track a specific region of the framebuffer to capture."] -#[doc = ""] -#[doc = " An X screen corresponds to the entire framebuffer."] -#[doc = ""] -#[doc = " An RandR CRTC is a component of the GPU that reads pixels from a region of"] -#[doc = " the X screen and sends them through a pipeline to an RandR output."] -#[doc = " A physical monitor can be connected to an RandR output. Tracking an RandR"] -#[doc = " output captures the region of the X screen that the RandR CRTC is sending to"] -#[doc = " the RandR output."] -pub type NVFBC_TRACKING_TYPE = ::std::os::raw::c_uint; -#[doc = " Data will be converted to ARGB8888 byte-order format. 32 bpp."] -pub const _NVFBC_BUFFER_FORMAT_NVFBC_BUFFER_FORMAT_ARGB: _NVFBC_BUFFER_FORMAT = 0; -#[doc = " Data will be converted to RGB888 byte-order format. 24 bpp."] -pub const _NVFBC_BUFFER_FORMAT_NVFBC_BUFFER_FORMAT_RGB: _NVFBC_BUFFER_FORMAT = 1; -#[doc = " Data will be converted to NV12 format using HDTV weights"] -#[doc = " according to ITU-R BT.709. 12 bpp."] -pub const _NVFBC_BUFFER_FORMAT_NVFBC_BUFFER_FORMAT_NV12: _NVFBC_BUFFER_FORMAT = 2; -#[doc = " Data will be converted to YUV 444 planar format using HDTV weights"] -#[doc = " according to ITU-R BT.709. 24 bpp"] -pub const _NVFBC_BUFFER_FORMAT_NVFBC_BUFFER_FORMAT_YUV444P: _NVFBC_BUFFER_FORMAT = 3; -#[doc = " Data will be converted to RGBA8888 byte-order format. 32 bpp."] -pub const _NVFBC_BUFFER_FORMAT_NVFBC_BUFFER_FORMAT_RGBA: _NVFBC_BUFFER_FORMAT = 4; -#[doc = " Native format. No pixel conversion needed."] -#[doc = " BGRA8888 byte-order format. 32 bpp."] -pub const _NVFBC_BUFFER_FORMAT_NVFBC_BUFFER_FORMAT_BGRA: _NVFBC_BUFFER_FORMAT = 5; -#[doc = " Buffer format."] -pub type _NVFBC_BUFFER_FORMAT = ::std::os::raw::c_uint; -#[doc = " Buffer format."] -pub use self::_NVFBC_BUFFER_FORMAT as NVFBC_BUFFER_FORMAT; -#[doc = " Handle used to identify an NvFBC session."] -pub type NVFBC_SESSION_HANDLE = u64; -#[doc = " Box used to describe an area of the tracked region to capture."] -#[doc = ""] -#[doc = " The coordinates are relative to the tracked region."] -#[doc = ""] -#[doc = " E.g., if the size of the X screen is 3520x1200 and the tracked RandR output"] -#[doc = " scans a region of 1600x1200+1920+0, then setting a capture box of"] -#[doc = " 800x600+100+50 effectively captures a region of 800x600+2020+50 relative to"] -#[doc = " the X screen."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_BOX { - #[doc = " [in] X offset of the box."] - pub x: u32, - #[doc = " [in] Y offset of the box."] - pub y: u32, - #[doc = " [in] Width of the box."] - pub w: u32, - #[doc = " [in] Height of the box."] - pub h: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_BOX() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_BOX>(), - 16usize, - concat!("Size of: ", stringify!(_NVFBC_BOX)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_BOX>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_BOX)) - ); - fn test_field_x() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_BOX>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize - }, - 0usize, - concat!("Offset of field: ", stringify!(_NVFBC_BOX), "::", stringify!(x)) - ); - } - test_field_x(); - fn test_field_y() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_BOX>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize - }, - 4usize, - concat!("Offset of field: ", stringify!(_NVFBC_BOX), "::", stringify!(y)) - ); - } - test_field_y(); - fn test_field_w() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_BOX>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).w) as usize - ptr as usize - }, - 8usize, - concat!("Offset of field: ", stringify!(_NVFBC_BOX), "::", stringify!(w)) - ); - } - test_field_w(); - fn test_field_h() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_BOX>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).h) as usize - ptr as usize - }, - 12usize, - concat!("Offset of field: ", stringify!(_NVFBC_BOX), "::", stringify!(h)) - ); - } - test_field_h(); -} -#[doc = " Box used to describe an area of the tracked region to capture."] -#[doc = ""] -#[doc = " The coordinates are relative to the tracked region."] -#[doc = ""] -#[doc = " E.g., if the size of the X screen is 3520x1200 and the tracked RandR output"] -#[doc = " scans a region of 1600x1200+1920+0, then setting a capture box of"] -#[doc = " 800x600+100+50 effectively captures a region of 800x600+2020+50 relative to"] -#[doc = " the X screen."] -pub type NVFBC_BOX = _NVFBC_BOX; -#[doc = " Size used to describe the size of a frame."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_SIZE { - #[doc = " [in] Width."] - pub w: u32, - #[doc = " [in] Height."] - pub h: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_SIZE() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_SIZE>(), - 8usize, - concat!("Size of: ", stringify!(_NVFBC_SIZE)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_SIZE>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_SIZE)) - ); - fn test_field_w() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_SIZE>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).w) as usize - ptr as usize - }, - 0usize, - concat!("Offset of field: ", stringify!(_NVFBC_SIZE), "::", stringify!(w)) - ); - } - test_field_w(); - fn test_field_h() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_SIZE>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).h) as usize - ptr as usize - }, - 4usize, - concat!("Offset of field: ", stringify!(_NVFBC_SIZE), "::", stringify!(h)) - ); - } - test_field_h(); -} -#[doc = " Size used to describe the size of a frame."] -pub type NVFBC_SIZE = _NVFBC_SIZE; -#[doc = " Describes information about a captured frame."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_FRAME_GRAB_INFO { - #[doc = " [out] Width of the captured frame."] - pub dwWidth: u32, - #[doc = " [out] Height of the captured frame."] - pub dwHeight: u32, - #[doc = " [out] Size of the frame in bytes."] - pub dwByteSize: u32, - #[doc = " [out] Incremental ID of the current frame."] - #[doc = ""] - #[doc = " This can be used to identify a frame."] - pub dwCurrentFrame: u32, - #[doc = " [out] Whether the captured frame is a new frame."] - #[doc = ""] - #[doc = " When using non blocking calls it is possible to capture a frame"] - #[doc = " that was already captured before if the display server did not"] - #[doc = " render a new frame in the meantime. In that case, this flag"] - #[doc = " will be set to NVFBC_FALSE."] - #[doc = ""] - #[doc = " When using blocking calls each captured frame will have"] - #[doc = " this flag set to NVFBC_TRUE since the blocking mechanism waits for"] - #[doc = " the display server to render a new frame."] - #[doc = ""] - #[doc = " Note that this flag does not guarantee that the content of"] - #[doc = " the frame will be different compared to the previous captured frame."] - #[doc = ""] - #[doc = " In particular, some compositing managers report the entire"] - #[doc = " framebuffer as damaged when an application refreshes its content."] - #[doc = ""] - #[doc = " Consider a single X screen spanned across physical displays A and B"] - #[doc = " and an NvFBC application tracking display A. Depending on the"] - #[doc = " compositing manager, it is possible that an application refreshing"] - #[doc = " itself on display B will trigger a frame capture on display A."] - #[doc = ""] - #[doc = " Workarounds include:"] - #[doc = " - Using separate X screens"] - #[doc = " - Disabling the composite extension"] - #[doc = " - Using a compositing manager that properly reports what regions"] - #[doc = " are damaged"] - #[doc = " - Using NvFBC's diffmaps to find out if the frame changed"] - pub bIsNewFrame: NVFBC_BOOL, - #[doc = " [out] Frame timestamp"] - #[doc = ""] - #[doc = " Time in micro seconds when the display server started rendering the"] - #[doc = " frame."] - #[doc = ""] - #[doc = " This does not account for when the frame was captured. If capturing an"] - #[doc = " old frame (e.g., bIsNewFrame is NVFBC_FALSE) the reported timestamp"] - #[doc = " will reflect the time when the old frame was rendered by the display"] - #[doc = " server."] - pub ulTimestampUs: u64, - pub dwMissedFrames: u32, - pub bRequiredPostProcessing: NVFBC_BOOL, - pub bDirectCapture: NVFBC_BOOL, -} -#[test] -fn bindgen_test_layout__NVFBC_FRAME_GRAB_INFO() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_FRAME_GRAB_INFO>(), - 48usize, - concat!("Size of: ", stringify!(_NVFBC_FRAME_GRAB_INFO)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_FRAME_GRAB_INFO>(), - 8usize, - concat!("Alignment of ", stringify!(_NVFBC_FRAME_GRAB_INFO)) - ); - fn test_field_dwWidth() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwWidth) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(dwWidth) - ) - ); - } - test_field_dwWidth(); - fn test_field_dwHeight() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwHeight) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(dwHeight) - ) - ); - } - test_field_dwHeight(); - fn test_field_dwByteSize() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwByteSize) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(dwByteSize) - ) - ); - } - test_field_dwByteSize(); - fn test_field_dwCurrentFrame() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwCurrentFrame) as usize - ptr as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(dwCurrentFrame) - ) - ); - } - test_field_dwCurrentFrame(); - fn test_field_bIsNewFrame() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bIsNewFrame) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(bIsNewFrame) - ) - ); - } - test_field_bIsNewFrame(); - fn test_field_ulTimestampUs() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).ulTimestampUs) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(ulTimestampUs) - ) - ); - } - test_field_ulTimestampUs(); - fn test_field_dwMissedFrames() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwMissedFrames) as usize - ptr as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(dwMissedFrames) - ) - ); - } - test_field_dwMissedFrames(); - fn test_field_bRequiredPostProcessing() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bRequiredPostProcessing) as usize - ptr as usize - }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(bRequiredPostProcessing) - ) - ); - } - test_field_bRequiredPostProcessing(); - fn test_field_bDirectCapture() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_FRAME_GRAB_INFO>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bDirectCapture) as usize - ptr as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_FRAME_GRAB_INFO), - "::", - stringify!(bDirectCapture) - ) - ); - } - test_field_bDirectCapture(); -} -#[doc = " Describes information about a captured frame."] -pub type NVFBC_FRAME_GRAB_INFO = _NVFBC_FRAME_GRAB_INFO; -#[doc = " Defines parameters for the CreateHandle() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_CREATE_HANDLE_PARAMS { - #[doc = " [in] Must be set to NVFBC_CREATE_HANDLE_PARAMS_VER"] - pub dwVersion: u32, - #[doc = " [in] Application specific private information passed to the NvFBC"] - #[doc = " session."] - pub privateData: *const ::std::os::raw::c_void, - #[doc = " [in] Size of the application specific private information passed to the"] - #[doc = " NvFBC session."] - pub privateDataSize: u32, - #[doc = " [in] Whether NvFBC should not create and manage its own graphics context"] - #[doc = ""] - #[doc = " NvFBC internally uses OpenGL to perfom graphics operations on the"] - #[doc = " captured frames. By default, NvFBC will create and manage (e.g., make"] - #[doc = " current, detect new threads, etc.) its own OpenGL context."] - #[doc = ""] - #[doc = " If set to NVFBC_TRUE, NvFBC will use the application's context. It will"] - #[doc = " be the application's responsibility to make sure that a context is"] - #[doc = " current on the thread calling into the NvFBC API."] - pub bExternallyManagedContext: NVFBC_BOOL, - #[doc = " [in] GLX context"] - #[doc = ""] - #[doc = " GLX context that NvFBC should use internally to create pixmaps and"] - #[doc = " make them current when creating a new capture session."] - #[doc = ""] - #[doc = " Note: NvFBC expects a context created against a GLX_RGBA_TYPE render"] - #[doc = " type."] - pub glxCtx: *mut ::std::os::raw::c_void, - #[doc = " [in] GLX framebuffer configuration"] - #[doc = ""] - #[doc = " Framebuffer configuration that was used to create the GLX context, and"] - #[doc = " that will be used to create pixmaps internally."] - #[doc = ""] - #[doc = " Note: NvFBC expects a configuration having at least the following"] - #[doc = " attributes:"] - #[doc = " GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT"] - #[doc = " GLX_BIND_TO_TEXTURE_RGBA_EXT, 1"] - #[doc = " GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT"] - pub glxFBConfig: *mut ::std::os::raw::c_void, -} -#[test] -fn bindgen_test_layout__NVFBC_CREATE_HANDLE_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_CREATE_HANDLE_PARAMS>(), - 40usize, - concat!("Size of: ", stringify!(_NVFBC_CREATE_HANDLE_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_CREATE_HANDLE_PARAMS>(), - 8usize, - concat!("Alignment of ", stringify!(_NVFBC_CREATE_HANDLE_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_HANDLE_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_HANDLE_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_privateData() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_HANDLE_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).privateData) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_HANDLE_PARAMS), - "::", - stringify!(privateData) - ) - ); - } - test_field_privateData(); - fn test_field_privateDataSize() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_HANDLE_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).privateDataSize) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_HANDLE_PARAMS), - "::", - stringify!(privateDataSize) - ) - ); - } - test_field_privateDataSize(); - fn test_field_bExternallyManagedContext() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_HANDLE_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bExternallyManagedContext) as usize - ptr as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_HANDLE_PARAMS), - "::", - stringify!(bExternallyManagedContext) - ) - ); - } - test_field_bExternallyManagedContext(); - fn test_field_glxCtx() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_HANDLE_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).glxCtx) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_HANDLE_PARAMS), - "::", - stringify!(glxCtx) - ) - ); - } - test_field_glxCtx(); - fn test_field_glxFBConfig() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_HANDLE_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).glxFBConfig) as usize - ptr as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_HANDLE_PARAMS), - "::", - stringify!(glxFBConfig) - ) - ); - } - test_field_glxFBConfig(); -} -#[doc = " Defines parameters for the CreateHandle() API call."] -pub type NVFBC_CREATE_HANDLE_PARAMS = _NVFBC_CREATE_HANDLE_PARAMS; -#[doc = " Defines parameters for the ::NvFBCDestroyHandle() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_DESTROY_HANDLE_PARAMS { - #[doc = " [in] Must be set to NVFBC_DESTROY_HANDLE_PARAMS_VER"] - pub dwVersion: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_DESTROY_HANDLE_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_DESTROY_HANDLE_PARAMS>(), - 4usize, - concat!("Size of: ", stringify!(_NVFBC_DESTROY_HANDLE_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_DESTROY_HANDLE_PARAMS>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_DESTROY_HANDLE_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_DESTROY_HANDLE_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_DESTROY_HANDLE_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); -} -#[doc = " Defines parameters for the ::NvFBCDestroyHandle() API call."] -pub type NVFBC_DESTROY_HANDLE_PARAMS = _NVFBC_DESTROY_HANDLE_PARAMS; -#[doc = " Describes an RandR output."] -#[doc = ""] -#[doc = " Filling this structure relies on the XRandR extension. This feature cannot"] -#[doc = " be used if the extension is missing or its version is below the requirements."] -#[doc = ""] -#[doc = " \\see Requirements"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_OUTPUT { - #[doc = " Identifier of the RandR output."] - pub dwId: u32, - #[doc = " Name of the RandR output, as reported by tools such as xrandr(1)."] - #[doc = ""] - #[doc = " Example: \"DVI-I-0\""] - pub name: [::std::os::raw::c_char; 128usize], - #[doc = " Region of the X screen tracked by the RandR CRTC driving this RandR"] - #[doc = " output."] - pub trackedBox: NVFBC_BOX, -} -#[test] -fn bindgen_test_layout__NVFBC_OUTPUT() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_OUTPUT>(), - 148usize, - concat!("Size of: ", stringify!(_NVFBC_OUTPUT)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_OUTPUT>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_OUTPUT)) - ); - fn test_field_dwId() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_OUTPUT>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwId) as usize - ptr as usize - }, - 0usize, - concat!("Offset of field: ", stringify!(_NVFBC_OUTPUT), "::", stringify!(dwId)) - ); - } - test_field_dwId(); - fn test_field_name() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_OUTPUT>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize - }, - 4usize, - concat!("Offset of field: ", stringify!(_NVFBC_OUTPUT), "::", stringify!(name)) - ); - } - test_field_name(); - fn test_field_trackedBox() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_OUTPUT>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).trackedBox) as usize - ptr as usize - }, - 132usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_OUTPUT), - "::", - stringify!(trackedBox) - ) - ); - } - test_field_trackedBox(); -} -#[doc = " Describes an RandR output."] -#[doc = ""] -#[doc = " Filling this structure relies on the XRandR extension. This feature cannot"] -#[doc = " be used if the extension is missing or its version is below the requirements."] -#[doc = ""] -#[doc = " \\see Requirements"] -pub type NVFBC_RANDR_OUTPUT_INFO = _NVFBC_OUTPUT; -#[doc = " Defines parameters for the ::NvFBCGetStatus() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_GET_STATUS_PARAMS { - #[doc = " [in] Must be set to NVFBC_GET_STATUS_PARAMS_VER"] - pub dwVersion: u32, - #[doc = " [out] Whether or not framebuffer capture is supported by the graphics"] - #[doc = " driver."] - pub bIsCapturePossible: NVFBC_BOOL, - #[doc = " [out] Whether or not there is already a capture session on this system."] - pub bCurrentlyCapturing: NVFBC_BOOL, - #[doc = " [out] Whether or not it is possible to create a capture session on this"] - #[doc = " system."] - pub bCanCreateNow: NVFBC_BOOL, - #[doc = " [out] Size of the X screen (framebuffer)."] - pub screenSize: NVFBC_SIZE, - #[doc = " [out] Whether the XRandR extension is available."] - #[doc = ""] - #[doc = " If this extension is not available then it is not possible to have"] - #[doc = " information about RandR outputs."] - pub bXRandRAvailable: NVFBC_BOOL, - #[doc = " [out] Array of outputs connected to the X screen."] - #[doc = ""] - #[doc = " An application can track a specific output by specifying its ID when"] - #[doc = " creating a capture session."] - #[doc = ""] - #[doc = " Only if XRandR is available."] - pub outputs: [NVFBC_RANDR_OUTPUT_INFO; 5usize], - #[doc = " [out] Number of outputs connected to the X screen."] - #[doc = ""] - #[doc = " This must be used to parse the array of connected outputs."] - #[doc = ""] - #[doc = " Only if XRandR is available."] - pub dwOutputNum: u32, - #[doc = " [out] Version of the NvFBC library running on this system."] - pub dwNvFBCVersion: u32, - #[doc = " [out] Whether the X server is currently in modeset."] - #[doc = ""] - #[doc = " When the X server is in modeset, it must give up all its video"] - #[doc = " memory allocations. It is not possible to create a capture"] - #[doc = " session until the modeset is over."] - #[doc = ""] - #[doc = " Note that VT-switches are considered modesets."] - pub bInModeset: NVFBC_BOOL, -} -#[test] -fn bindgen_test_layout__NVFBC_GET_STATUS_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_GET_STATUS_PARAMS>(), - 780usize, - concat!("Size of: ", stringify!(_NVFBC_GET_STATUS_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_GET_STATUS_PARAMS>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_GET_STATUS_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_bIsCapturePossible() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bIsCapturePossible) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(bIsCapturePossible) - ) - ); - } - test_field_bIsCapturePossible(); - fn test_field_bCurrentlyCapturing() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bCurrentlyCapturing) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(bCurrentlyCapturing) - ) - ); - } - test_field_bCurrentlyCapturing(); - fn test_field_bCanCreateNow() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bCanCreateNow) as usize - ptr as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(bCanCreateNow) - ) - ); - } - test_field_bCanCreateNow(); - fn test_field_screenSize() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).screenSize) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(screenSize) - ) - ); - } - test_field_screenSize(); - fn test_field_bXRandRAvailable() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bXRandRAvailable) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(bXRandRAvailable) - ) - ); - } - test_field_bXRandRAvailable(); - fn test_field_outputs() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).outputs) as usize - ptr as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(outputs) - ) - ); - } - test_field_outputs(); - fn test_field_dwOutputNum() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwOutputNum) as usize - ptr as usize - }, - 768usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(dwOutputNum) - ) - ); - } - test_field_dwOutputNum(); - fn test_field_dwNvFBCVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwNvFBCVersion) as usize - ptr as usize - }, - 772usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(dwNvFBCVersion) - ) - ); - } - test_field_dwNvFBCVersion(); - fn test_field_bInModeset() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_GET_STATUS_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bInModeset) as usize - ptr as usize - }, - 776usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_GET_STATUS_PARAMS), - "::", - stringify!(bInModeset) - ) - ); - } - test_field_bInModeset(); -} -#[doc = " Defines parameters for the ::NvFBCGetStatus() API call."] -pub type NVFBC_GET_STATUS_PARAMS = _NVFBC_GET_STATUS_PARAMS; -#[doc = " Defines parameters for the ::NvFBCCreateCaptureSession() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_CREATE_CAPTURE_SESSION_PARAMS { - #[doc = " [in] Must be set to NVFBC_CREATE_CAPTURE_SESSION_PARAMS_VER"] - pub dwVersion: u32, - #[doc = " [in] Desired capture type."] - #[doc = ""] - #[doc = " Note that when specyfing ::NVFBC_CAPTURE_SHARED_CUDA NvFBC will try to"] - #[doc = " dlopen() the corresponding libraries. This means that NvFBC can run on"] - #[doc = " a system without the CUDA library since it does not link against them."] - pub eCaptureType: NVFBC_CAPTURE_TYPE, - #[doc = " [in] What region of the framebuffer should be tracked."] - pub eTrackingType: NVFBC_TRACKING_TYPE, - #[doc = " [in] ID of the output to track if eTrackingType is set to"] - #[doc = " ::NVFBC_TRACKING_OUTPUT."] - pub dwOutputId: u32, - #[doc = " [in] Crop the tracked region."] - #[doc = ""] - #[doc = " The coordinates are relative to the tracked region."] - #[doc = ""] - #[doc = " It can be set to 0 to capture the entire tracked region."] - pub captureBox: NVFBC_BOX, - #[doc = " [in] Desired size of the captured frame."] - #[doc = ""] - #[doc = " This parameter allow to scale the captured frame."] - #[doc = ""] - #[doc = " It can be set to 0 to disable frame resizing."] - pub frameSize: NVFBC_SIZE, - #[doc = " [in] Whether the mouse cursor should be composited to the frame."] - #[doc = ""] - #[doc = " Disabling the cursor will not generate new frames when only the cursor"] - #[doc = " is moved."] - pub bWithCursor: NVFBC_BOOL, - #[doc = " [in] Whether NvFBC should not attempt to recover from modesets."] - #[doc = ""] - #[doc = " NvFBC is able to detect when a modeset event occured and can automatically"] - #[doc = " re-create a capture session with the same settings as before, then resume"] - #[doc = " its frame capture session transparently."] - #[doc = ""] - #[doc = " This option allows to disable this behavior. NVFBC_ERR_MUST_RECREATE"] - #[doc = " will be returned in that case."] - #[doc = ""] - #[doc = " It can be useful in the cases when an application needs to do some work"] - #[doc = " between setting up a capture and grabbing the first frame."] - #[doc = ""] - #[doc = " For example: an application using the ToGL interface needs to register"] - #[doc = " resources with EncodeAPI prior to encoding frames."] - #[doc = ""] - #[doc = " Note that during modeset recovery, NvFBC will try to re-create the"] - #[doc = " capture session every second until it succeeds."] - pub bDisableAutoModesetRecovery: NVFBC_BOOL, - #[doc = " [in] Whether NvFBC should round the requested frameSize."] - #[doc = ""] - #[doc = " When disabled, NvFBC will not attempt to round the requested resolution."] - #[doc = ""] - #[doc = " However, some pixel formats have resolution requirements. E.g., YUV/NV"] - #[doc = " formats must have a width being a multiple of 4, and a height being a"] - #[doc = " multiple of 2. RGB formats don't have such requirements."] - #[doc = ""] - #[doc = " If the resolution doesn't meet the requirements of the format, then NvFBC"] - #[doc = " will fail at setup time."] - #[doc = ""] - #[doc = " When enabled, NvFBC will round the requested width to the next multiple"] - #[doc = " of 4 and the requested height to the next multiple of 2."] - #[doc = ""] - #[doc = " In this case, requesting any resolution will always work with every"] - #[doc = " format. However, an NvFBC client must be prepared to handle the case"] - #[doc = " where the requested resolution is different than the captured resolution."] - #[doc = ""] - #[doc = " NVFBC_FRAME_GRAB_INFO::dwWidth and NVFBC_FRAME_GRAB_INFO::dwHeight should"] - #[doc = " always be used for getting information about captured frames."] - pub bRoundFrameSize: NVFBC_BOOL, - #[doc = " [in] Rate in ms at which the display server generates new frames"] - #[doc = ""] - #[doc = " This controls the frequency at which the display server will generate"] - #[doc = " new frames if new content is available. This effectively controls the"] - #[doc = " capture rate when using blocking calls."] - #[doc = ""] - #[doc = " Note that lower values will increase the CPU and GPU loads."] - #[doc = ""] - #[doc = " The default value is 16ms (~ 60 Hz)."] - pub dwSamplingRateMs: u32, - #[doc = " [in] Enable push model for frame capture"] - #[doc = ""] - #[doc = " When set to NVFBC_TRUE, the display server will generate frames whenever"] - #[doc = " it receives a damage event from applications."] - #[doc = ""] - #[doc = " Setting this to NVFBC_TRUE will ignore ::dwSamplingRateMs."] - #[doc = ""] - #[doc = " Using push model with the NVFBC_*_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY"] - #[doc = " capture flag should guarantee the shortest amount of time between an"] - #[doc = " application rendering a frame and an NvFBC client capturing it, provided"] - #[doc = " that the NvFBC client is able to process the frames quickly enough."] - #[doc = ""] - #[doc = " Note that applications running at high frame rates will increase CPU and"] - #[doc = " GPU loads."] - pub bPushModel: NVFBC_BOOL, - #[doc = " [in] Allow direct capture"] - #[doc = ""] - #[doc = " Direct capture allows NvFBC to attach itself to a fullscreen graphics"] - #[doc = " application. Whenever that application presents a frame, it makes a copy"] - #[doc = " of it directly into a buffer owned by NvFBC thus bypassing the X server."] - #[doc = ""] - #[doc = " When direct capture is *not* enabled, the NVIDIA X driver generates a"] - #[doc = " frame for NvFBC when it receives a damage event from an application if push"] - #[doc = " model is enabled, or periodically checks if there are any pending damage"] - #[doc = " events otherwise (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::dwSamplingRateMs)."] - #[doc = ""] - #[doc = " Direct capture is possible under the following conditions:"] - #[doc = " - Direct capture is allowed"] - #[doc = " - Push model is enabled (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bPushModel)"] - #[doc = " - The mouse cursor is not composited (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bWithCursor)"] - #[doc = " - No viewport transformation is required. This happens when the remote"] - #[doc = " desktop is e.g. rotated."] - #[doc = ""] - #[doc = " When direct capture is possible, NvFBC will automatically attach itself"] - #[doc = " to a fullscreen unoccluded application, if such exists."] - #[doc = ""] - #[doc = " Notes:"] - #[doc = " - This includes compositing desktops such as GNOME (e.g., gnome-shell"] - #[doc = " is the fullscreen unoccluded application)."] - #[doc = " - There can be only one fullscreen unoccluded application at a time."] - #[doc = " - The NVIDIA X driver monitors which application qualifies or no"] - #[doc = " longer qualifies."] - #[doc = ""] - #[doc = " For example, if a fullscreen application is launched in GNOME, NvFBC will"] - #[doc = " detach from gnome-shell and attach to that application."] - #[doc = ""] - #[doc = " Attaching and detaching happens automatically from the perspective of an"] - #[doc = " NvFBC client. When detaching from an application, the X driver will"] - #[doc = " transparently resume generating frames for NvFBC."] - #[doc = ""] - #[doc = " An application can know whether a given frame was obtained through"] - #[doc = " direct capture by checking NVFBC_FRAME_GRAB_INFO::bDirectCapture."] - pub bAllowDirectCapture: NVFBC_BOOL, -} -#[test] -fn bindgen_test_layout__NVFBC_CREATE_CAPTURE_SESSION_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>(), - 64usize, - concat!("Size of: ", stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_eCaptureType() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).eCaptureType) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(eCaptureType) - ) - ); - } - test_field_eCaptureType(); - fn test_field_eTrackingType() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).eTrackingType) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(eTrackingType) - ) - ); - } - test_field_eTrackingType(); - fn test_field_dwOutputId() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwOutputId) as usize - ptr as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(dwOutputId) - ) - ); - } - test_field_dwOutputId(); - fn test_field_captureBox() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).captureBox) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(captureBox) - ) - ); - } - test_field_captureBox(); - fn test_field_frameSize() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).frameSize) as usize - ptr as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(frameSize) - ) - ); - } - test_field_frameSize(); - fn test_field_bWithCursor() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bWithCursor) as usize - ptr as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(bWithCursor) - ) - ); - } - test_field_bWithCursor(); - fn test_field_bDisableAutoModesetRecovery() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bDisableAutoModesetRecovery) as usize - ptr as usize - }, - 44usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(bDisableAutoModesetRecovery) - ) - ); - } - test_field_bDisableAutoModesetRecovery(); - fn test_field_bRoundFrameSize() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bRoundFrameSize) as usize - ptr as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(bRoundFrameSize) - ) - ); - } - test_field_bRoundFrameSize(); - fn test_field_dwSamplingRateMs() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwSamplingRateMs) as usize - ptr as usize - }, - 52usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(dwSamplingRateMs) - ) - ); - } - test_field_dwSamplingRateMs(); - fn test_field_bPushModel() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bPushModel) as usize - ptr as usize - }, - 56usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(bPushModel) - ) - ); - } - test_field_bPushModel(); - fn test_field_bAllowDirectCapture() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_CREATE_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bAllowDirectCapture) as usize - ptr as usize - }, - 60usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_CREATE_CAPTURE_SESSION_PARAMS), - "::", - stringify!(bAllowDirectCapture) - ) - ); - } - test_field_bAllowDirectCapture(); -} -#[doc = " Defines parameters for the ::NvFBCCreateCaptureSession() API call."] -pub type NVFBC_CREATE_CAPTURE_SESSION_PARAMS = _NVFBC_CREATE_CAPTURE_SESSION_PARAMS; -#[doc = " Defines parameters for the ::NvFBCDestroyCaptureSession() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_DESTROY_CAPTURE_SESSION_PARAMS { - #[doc = " [in] Must be set to NVFBC_DESTROY_CAPTURE_SESSION_PARAMS_VER"] - pub dwVersion: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_DESTROY_CAPTURE_SESSION_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_DESTROY_CAPTURE_SESSION_PARAMS>(), - 4usize, - concat!("Size of: ", stringify!(_NVFBC_DESTROY_CAPTURE_SESSION_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_DESTROY_CAPTURE_SESSION_PARAMS>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_DESTROY_CAPTURE_SESSION_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_DESTROY_CAPTURE_SESSION_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_DESTROY_CAPTURE_SESSION_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); -} -#[doc = " Defines parameters for the ::NvFBCDestroyCaptureSession() API call."] -pub type NVFBC_DESTROY_CAPTURE_SESSION_PARAMS = _NVFBC_DESTROY_CAPTURE_SESSION_PARAMS; -#[doc = " Defines parameters for the ::NvFBCBindContext() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_BIND_CONTEXT_PARAMS { - #[doc = " [in] Must be set to NVFBC_BIND_CONTEXT_PARAMS_VER"] - pub dwVersion: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_BIND_CONTEXT_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_BIND_CONTEXT_PARAMS>(), - 4usize, - concat!("Size of: ", stringify!(_NVFBC_BIND_CONTEXT_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_BIND_CONTEXT_PARAMS>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_BIND_CONTEXT_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_BIND_CONTEXT_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_BIND_CONTEXT_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); -} -#[doc = " Defines parameters for the ::NvFBCBindContext() API call."] -pub type NVFBC_BIND_CONTEXT_PARAMS = _NVFBC_BIND_CONTEXT_PARAMS; -#[doc = " Defines parameters for the ::NvFBCReleaseContext() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_RELEASE_CONTEXT_PARAMS { - #[doc = " [in] Must be set to NVFBC_RELEASE_CONTEXT_PARAMS_VER"] - pub dwVersion: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_RELEASE_CONTEXT_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_RELEASE_CONTEXT_PARAMS>(), - 4usize, - concat!("Size of: ", stringify!(_NVFBC_RELEASE_CONTEXT_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_RELEASE_CONTEXT_PARAMS>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_RELEASE_CONTEXT_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_RELEASE_CONTEXT_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_RELEASE_CONTEXT_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); -} -#[doc = " Defines parameters for the ::NvFBCReleaseContext() API call."] -pub type NVFBC_RELEASE_CONTEXT_PARAMS = _NVFBC_RELEASE_CONTEXT_PARAMS; -#[doc = " Default, capturing waits for a new frame or mouse move."] -#[doc = ""] -#[doc = " The default behavior of blocking grabs is to wait for a new frame until"] -#[doc = " after the call was made. But it's possible that there is a frame already"] -#[doc = " ready that the client hasn't seen."] -#[doc = " \\see NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY"] -pub const NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS: NVFBC_TOSYS_GRAB_FLAGS = 0; -#[doc = " Capturing does not wait for a new frame nor a mouse move."] -#[doc = ""] -#[doc = " It is therefore possible to capture the same frame multiple times."] -#[doc = " When this occurs, the dwCurrentFrame parameter of the"] -#[doc = " NVFBC_FRAME_GRAB_INFO structure is not incremented."] -pub const NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT: NVFBC_TOSYS_GRAB_FLAGS = 1; -#[doc = " Forces the destination buffer to be refreshed even if the frame has not"] -#[doc = " changed since previous capture."] -#[doc = ""] -#[doc = " By default, if the captured frame is identical to the previous one, NvFBC"] -#[doc = " will omit one copy and not update the destination buffer."] -#[doc = ""] -#[doc = " Setting that flag will prevent this behavior. This can be useful e.g.,"] -#[doc = " if the application has modified the buffer in the meantime."] -pub const NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_FORCE_REFRESH: NVFBC_TOSYS_GRAB_FLAGS = 2; -#[doc = " Similar to NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS, except that the capture will"] -#[doc = " not wait if there is already a frame available that the client has"] -#[doc = " never seen yet."] -pub const NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY: NVFBC_TOSYS_GRAB_FLAGS = 4; -#[doc = " Defines flags that can be used when capturing to system memory."] -pub type NVFBC_TOSYS_GRAB_FLAGS = ::std::os::raw::c_uint; -#[doc = " Defines parameters for the ::NvFBCToSysSetUp() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_TOSYS_SETUP_PARAMS { - #[doc = " [in] Must be set to NVFBC_TOSYS_SETUP_PARAMS_VER"] - pub dwVersion: u32, - #[doc = " [in] Desired buffer format."] - pub eBufferFormat: NVFBC_BUFFER_FORMAT, - #[doc = " [out] Pointer to a pointer to a buffer in system memory."] - #[doc = ""] - #[doc = " This buffer contains the pixel value of the requested format. Refer to"] - #[doc = " the description of the buffer formats to understand the memory layout."] - #[doc = ""] - #[doc = " The application does not need to allocate memory for this buffer. It"] - #[doc = " should not free this buffer either. This buffer is automatically"] - #[doc = " re-allocated when needed (e.g., when the resolution changes)."] - #[doc = ""] - #[doc = " This buffer is allocated by the NvFBC library to the proper size. This"] - #[doc = " size is returned in the dwByteSize field of the"] - #[doc = " ::NVFBC_FRAME_GRAB_INFO structure."] - pub ppBuffer: *mut *mut ::std::os::raw::c_void, - #[doc = " [in] Whether differential maps should be generated."] - pub bWithDiffMap: NVFBC_BOOL, - #[doc = " [out] Pointer to a pointer to a buffer in system memory."] - #[doc = ""] - #[doc = " This buffer contains the differential map of two frames. It must be read"] - #[doc = " as an array of unsigned char. Each unsigned char is either 0 or"] - #[doc = " non-zero. 0 means that the pixel value at the given location has not"] - #[doc = " changed since the previous captured frame. Non-zero means that the pixel"] - #[doc = " value has changed."] - #[doc = ""] - #[doc = " The application does not need to allocate memory for this buffer. It"] - #[doc = " should not free this buffer either. This buffer is automatically"] - #[doc = " re-allocated when needed (e.g., when the resolution changes)."] - #[doc = ""] - #[doc = " This buffer is allocated by the NvFBC library to the proper size. The"] - #[doc = " size of the differential map is returned in ::diffMapSize."] - #[doc = ""] - #[doc = " This option is not compatible with the ::NVFBC_BUFFER_FORMAT_YUV420P and"] - #[doc = " ::NVFBC_BUFFER_FORMAT_YUV444P buffer formats."] - pub ppDiffMap: *mut *mut ::std::os::raw::c_void, - #[doc = " [in] Scaling factor of the differential maps."] - #[doc = ""] - #[doc = " For example, a scaling factor of 16 means that one pixel of the diffmap"] - #[doc = " will represent 16x16 pixels of the original frames."] - #[doc = ""] - #[doc = " If any of these 16x16 pixels is different between the current and the"] - #[doc = " previous frame, then the corresponding pixel in the diffmap will be set"] - #[doc = " to non-zero."] - #[doc = ""] - #[doc = " The default scaling factor is 1. A dwDiffMapScalingFactor of 0 will be"] - #[doc = " set to 1."] - pub dwDiffMapScalingFactor: u32, - #[doc = " [out] Size of the differential map."] - #[doc = ""] - #[doc = " Only set if bWithDiffMap is set to NVFBC_TRUE."] - pub diffMapSize: NVFBC_SIZE, -} -#[test] -fn bindgen_test_layout__NVFBC_TOSYS_SETUP_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_TOSYS_SETUP_PARAMS>(), - 48usize, - concat!("Size of: ", stringify!(_NVFBC_TOSYS_SETUP_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_TOSYS_SETUP_PARAMS>(), - 8usize, - concat!("Alignment of ", stringify!(_NVFBC_TOSYS_SETUP_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_SETUP_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_eBufferFormat() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).eBufferFormat) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_SETUP_PARAMS), - "::", - stringify!(eBufferFormat) - ) - ); - } - test_field_eBufferFormat(); - fn test_field_ppBuffer() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).ppBuffer) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_SETUP_PARAMS), - "::", - stringify!(ppBuffer) - ) - ); - } - test_field_ppBuffer(); - fn test_field_bWithDiffMap() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bWithDiffMap) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_SETUP_PARAMS), - "::", - stringify!(bWithDiffMap) - ) - ); - } - test_field_bWithDiffMap(); - fn test_field_ppDiffMap() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).ppDiffMap) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_SETUP_PARAMS), - "::", - stringify!(ppDiffMap) - ) - ); - } - test_field_ppDiffMap(); - fn test_field_dwDiffMapScalingFactor() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwDiffMapScalingFactor) as usize - ptr as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_SETUP_PARAMS), - "::", - stringify!(dwDiffMapScalingFactor) - ) - ); - } - test_field_dwDiffMapScalingFactor(); - fn test_field_diffMapSize() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).diffMapSize) as usize - ptr as usize - }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_SETUP_PARAMS), - "::", - stringify!(diffMapSize) - ) - ); - } - test_field_diffMapSize(); -} -#[doc = " Defines parameters for the ::NvFBCToSysSetUp() API call."] -pub type NVFBC_TOSYS_SETUP_PARAMS = _NVFBC_TOSYS_SETUP_PARAMS; -#[doc = " Defines parameters for the ::NvFBCToSysGrabFrame() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_TOSYS_GRAB_FRAME_PARAMS { - #[doc = " [in] Must be set to NVFBC_TOSYS_GRAB_FRAME_PARAMS_VER"] - pub dwVersion: u32, - #[doc = " [in] Flags defining the behavior of this frame capture."] - pub dwFlags: u32, - #[doc = " [out] Information about the captured frame."] - #[doc = ""] - #[doc = " Can be NULL."] - pub pFrameGrabInfo: *mut NVFBC_FRAME_GRAB_INFO, - #[doc = " [in] Wait timeout in milliseconds."] - #[doc = ""] - #[doc = " When capturing frames with the NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS or"] - #[doc = " NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags,"] - #[doc = " NvFBC will wait for a new frame or mouse move until the below timer"] - #[doc = " expires."] - #[doc = ""] - #[doc = " When timing out, the last captured frame will be returned. Note that as"] - #[doc = " long as the NVFBC_TOSYS_GRAB_FLAGS_FORCE_REFRESH flag is not set,"] - #[doc = " returning an old frame will incur no performance penalty."] - #[doc = ""] - #[doc = " NvFBC clients can use the return value of the grab frame operation to"] - #[doc = " find out whether a new frame was captured, or the timer expired."] - #[doc = ""] - #[doc = " Note that the behavior of blocking calls is to wait for a new frame"] - #[doc = " *after* the call has been made. When using timeouts, it is possible"] - #[doc = " that NvFBC will return a new frame (e.g., it has never been captured"] - #[doc = " before) even though no new frame was generated after the grab call."] - #[doc = ""] - #[doc = " For the precise definition of what constitutes a new frame, see"] - #[doc = " ::bIsNewFrame."] - #[doc = ""] - #[doc = " Set to 0 to disable timeouts."] - pub dwTimeoutMs: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_TOSYS_GRAB_FRAME_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_TOSYS_GRAB_FRAME_PARAMS>(), - 24usize, - concat!("Size of: ", stringify!(_NVFBC_TOSYS_GRAB_FRAME_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_TOSYS_GRAB_FRAME_PARAMS>(), - 8usize, - concat!("Alignment of ", stringify!(_NVFBC_TOSYS_GRAB_FRAME_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_GRAB_FRAME_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_dwFlags() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwFlags) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_GRAB_FRAME_PARAMS), - "::", - stringify!(dwFlags) - ) - ); - } - test_field_dwFlags(); - fn test_field_pFrameGrabInfo() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pFrameGrabInfo) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_GRAB_FRAME_PARAMS), - "::", - stringify!(pFrameGrabInfo) - ) - ); - } - test_field_pFrameGrabInfo(); - fn test_field_dwTimeoutMs() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOSYS_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwTimeoutMs) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOSYS_GRAB_FRAME_PARAMS), - "::", - stringify!(dwTimeoutMs) - ) - ); - } - test_field_dwTimeoutMs(); -} -#[doc = " Defines parameters for the ::NvFBCToSysGrabFrame() API call."] -pub type NVFBC_TOSYS_GRAB_FRAME_PARAMS = _NVFBC_TOSYS_GRAB_FRAME_PARAMS; -#[doc = " Default, capturing waits for a new frame or mouse move."] -#[doc = ""] -#[doc = " The default behavior of blocking grabs is to wait for a new frame until"] -#[doc = " after the call was made. But it's possible that there is a frame already"] -#[doc = " ready that the client hasn't seen."] -#[doc = " \\see NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY"] -pub const NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS: NVFBC_TOCUDA_FLAGS = 0; -#[doc = " Capturing does not wait for a new frame nor a mouse move."] -#[doc = ""] -#[doc = " It is therefore possible to capture the same frame multiple times."] -#[doc = " When this occurs, the dwCurrentFrame parameter of the"] -#[doc = " NVFBC_FRAME_GRAB_INFO structure is not incremented."] -pub const NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT: NVFBC_TOCUDA_FLAGS = 1; -#[doc = " [in] Forces the destination buffer to be refreshed even if the frame"] -#[doc = " has not changed since previous capture."] -#[doc = ""] -#[doc = " By default, if the captured frame is identical to the previous one, NvFBC"] -#[doc = " will omit one copy and not update the destination buffer."] -#[doc = ""] -#[doc = " Setting that flag will prevent this behavior. This can be useful e.g.,"] -#[doc = " if the application has modified the buffer in the meantime."] -pub const NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_FORCE_REFRESH: NVFBC_TOCUDA_FLAGS = 2; -#[doc = " Similar to NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS, except that the capture will"] -#[doc = " not wait if there is already a frame available that the client has"] -#[doc = " never seen yet."] -pub const NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY: NVFBC_TOCUDA_FLAGS = 4; -#[doc = " Defines flags that can be used when capturing to a CUDA buffer in video memory."] -pub type NVFBC_TOCUDA_FLAGS = ::std::os::raw::c_uint; -#[doc = " Defines parameters for the ::NvFBCToCudaSetUp() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_TOCUDA_SETUP_PARAMS { - #[doc = " [in] Must be set to NVFBC_TOCUDA_SETUP_PARAMS_VER"] - pub dwVersion: u32, - #[doc = " [in] Desired buffer format."] - pub eBufferFormat: NVFBC_BUFFER_FORMAT, -} -#[test] -fn bindgen_test_layout__NVFBC_TOCUDA_SETUP_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_TOCUDA_SETUP_PARAMS>(), - 8usize, - concat!("Size of: ", stringify!(_NVFBC_TOCUDA_SETUP_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_TOCUDA_SETUP_PARAMS>(), - 4usize, - concat!("Alignment of ", stringify!(_NVFBC_TOCUDA_SETUP_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOCUDA_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOCUDA_SETUP_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_eBufferFormat() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOCUDA_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).eBufferFormat) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOCUDA_SETUP_PARAMS), - "::", - stringify!(eBufferFormat) - ) - ); - } - test_field_eBufferFormat(); -} -#[doc = " Defines parameters for the ::NvFBCToCudaSetUp() API call."] -pub type NVFBC_TOCUDA_SETUP_PARAMS = _NVFBC_TOCUDA_SETUP_PARAMS; -#[doc = " Defines parameters for the ::NvFBCToCudaGrabFrame() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_TOCUDA_GRAB_FRAME_PARAMS { - #[doc = " [in] Must be set to NVFBC_TOCUDA_GRAB_FRAME_PARAMS_VER."] - pub dwVersion: u32, - #[doc = " [in] Flags defining the behavior of this frame capture."] - pub dwFlags: u32, - #[doc = " [out] Pointer to a ::CUdeviceptr"] - #[doc = ""] - #[doc = " The application does not need to allocate memory for this CUDA device."] - #[doc = ""] - #[doc = " The application does need to create its own CUDA context to use this"] - #[doc = " CUDA device."] - #[doc = ""] - #[doc = " This ::CUdeviceptr will be mapped to a segment in video memory containing"] - #[doc = " the frame. It is not possible to process a CUDA device while capturing"] - #[doc = " a new frame. If the application wants to do so, it must copy the CUDA"] - #[doc = " device using ::cuMemcpyDtoD or ::cuMemcpyDtoH beforehand."] - pub pCUDADeviceBuffer: *mut ::std::os::raw::c_void, - #[doc = " [out] Information about the captured frame."] - #[doc = ""] - #[doc = " Can be NULL."] - pub pFrameGrabInfo: *mut NVFBC_FRAME_GRAB_INFO, - #[doc = " [in] Wait timeout in milliseconds."] - #[doc = ""] - #[doc = " When capturing frames with the NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS or"] - #[doc = " NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags,"] - #[doc = " NvFBC will wait for a new frame or mouse move until the below timer"] - #[doc = " expires."] - #[doc = ""] - #[doc = " When timing out, the last captured frame will be returned. Note that as"] - #[doc = " long as the NVFBC_TOCUDA_GRAB_FLAGS_FORCE_REFRESH flag is not set,"] - #[doc = " returning an old frame will incur no performance penalty."] - #[doc = ""] - #[doc = " NvFBC clients can use the return value of the grab frame operation to"] - #[doc = " find out whether a new frame was captured, or the timer expired."] - #[doc = ""] - #[doc = " Note that the behavior of blocking calls is to wait for a new frame"] - #[doc = " *after* the call has been made. When using timeouts, it is possible"] - #[doc = " that NvFBC will return a new frame (e.g., it has never been captured"] - #[doc = " before) even though no new frame was generated after the grab call."] - #[doc = ""] - #[doc = " For the precise definition of what constitutes a new frame, see"] - #[doc = " ::bIsNewFrame."] - #[doc = ""] - #[doc = " Set to 0 to disable timeouts."] - pub dwTimeoutMs: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_TOCUDA_GRAB_FRAME_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_TOCUDA_GRAB_FRAME_PARAMS>(), - 32usize, - concat!("Size of: ", stringify!(_NVFBC_TOCUDA_GRAB_FRAME_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_TOCUDA_GRAB_FRAME_PARAMS>(), - 8usize, - concat!("Alignment of ", stringify!(_NVFBC_TOCUDA_GRAB_FRAME_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOCUDA_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOCUDA_GRAB_FRAME_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_dwFlags() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOCUDA_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwFlags) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOCUDA_GRAB_FRAME_PARAMS), - "::", - stringify!(dwFlags) - ) - ); - } - test_field_dwFlags(); - fn test_field_pCUDADeviceBuffer() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOCUDA_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pCUDADeviceBuffer) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOCUDA_GRAB_FRAME_PARAMS), - "::", - stringify!(pCUDADeviceBuffer) - ) - ); - } - test_field_pCUDADeviceBuffer(); - fn test_field_pFrameGrabInfo() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOCUDA_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pFrameGrabInfo) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOCUDA_GRAB_FRAME_PARAMS), - "::", - stringify!(pFrameGrabInfo) - ) - ); - } - test_field_pFrameGrabInfo(); - fn test_field_dwTimeoutMs() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOCUDA_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwTimeoutMs) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOCUDA_GRAB_FRAME_PARAMS), - "::", - stringify!(dwTimeoutMs) - ) - ); - } - test_field_dwTimeoutMs(); -} -#[doc = " Defines parameters for the ::NvFBCToCudaGrabFrame() API call."] -pub type NVFBC_TOCUDA_GRAB_FRAME_PARAMS = _NVFBC_TOCUDA_GRAB_FRAME_PARAMS; -#[doc = " Default, capturing waits for a new frame or mouse move."] -#[doc = ""] -#[doc = " The default behavior of blocking grabs is to wait for a new frame until"] -#[doc = " after the call was made. But it's possible that there is a frame already"] -#[doc = " ready that the client hasn't seen."] -#[doc = " \\see NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY"] -pub const NVFBC_TOGL_FLAGS_NVFBC_TOGL_GRAB_FLAGS_NOFLAGS: NVFBC_TOGL_FLAGS = 0; -#[doc = " Capturing does not wait for a new frame nor a mouse move."] -#[doc = ""] -#[doc = " It is therefore possible to capture the same frame multiple times."] -#[doc = " When this occurs, the dwCurrentFrame parameter of the"] -#[doc = " NVFBC_FRAME_GRAB_INFO structure is not incremented."] -pub const NVFBC_TOGL_FLAGS_NVFBC_TOGL_GRAB_FLAGS_NOWAIT: NVFBC_TOGL_FLAGS = 1; -#[doc = " [in] Forces the destination buffer to be refreshed even if the frame"] -#[doc = " has not changed since previous capture."] -#[doc = ""] -#[doc = " By default, if the captured frame is identical to the previous one, NvFBC"] -#[doc = " will omit one copy and not update the destination buffer."] -#[doc = ""] -#[doc = " Setting that flag will prevent this behavior. This can be useful e.g.,"] -#[doc = " if the application has modified the buffer in the meantime."] -pub const NVFBC_TOGL_FLAGS_NVFBC_TOGL_GRAB_FLAGS_FORCE_REFRESH: NVFBC_TOGL_FLAGS = 2; -#[doc = " Similar to NVFBC_TOGL_GRAB_FLAGS_NOFLAGS, except that the capture will"] -#[doc = " not wait if there is already a frame available that the client has"] -#[doc = " never seen yet."] -pub const NVFBC_TOGL_FLAGS_NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY: NVFBC_TOGL_FLAGS = 4; -#[doc = " Defines flags that can be used when capturing to an OpenGL buffer in video memory."] -pub type NVFBC_TOGL_FLAGS = ::std::os::raw::c_uint; -#[doc = " Defines parameters for the ::NvFBCToGLSetUp() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_TOGL_SETUP_PARAMS { - #[doc = " [in] Must be set to NVFBC_TOGL_SETUP_PARAMS_VER"] - pub dwVersion: u32, - #[doc = " [in] Desired buffer format."] - pub eBufferFormat: NVFBC_BUFFER_FORMAT, - #[doc = " [in] Whether differential maps should be generated."] - pub bWithDiffMap: NVFBC_BOOL, - #[doc = " [out] Pointer to a pointer to a buffer in system memory."] - #[doc = ""] - #[doc = " \\see NVFBC_TOSYS_SETUP_PARAMS::ppDiffMap"] - pub ppDiffMap: *mut *mut ::std::os::raw::c_void, - #[doc = " [in] Scaling factor of the differential maps."] - #[doc = ""] - #[doc = " \\see NVFBC_TOSYS_SETUP_PARAMS::dwDiffMapScalingFactor"] - pub dwDiffMapScalingFactor: u32, - #[doc = " [out] List of GL textures that will store the captured frames."] - #[doc = ""] - #[doc = " This array is 0 terminated. The number of textures varies depending on"] - #[doc = " the capture settings (such as whether diffmaps are enabled)."] - #[doc = ""] - #[doc = " An application wishing to interop with, for example, EncodeAPI will need"] - #[doc = " to register these textures prior to start encoding frames."] - #[doc = ""] - #[doc = " After each frame capture, the texture holding the current frame will be"] - #[doc = " returned in NVFBC_TOGL_GRAB_FRAME_PARAMS::dwTexture."] - pub dwTextures: [u32; 2usize], - #[doc = " [out] GL target to which the texture should be bound."] - pub dwTexTarget: u32, - #[doc = " [out] GL format of the textures."] - pub dwTexFormat: u32, - #[doc = " [out] GL type of the textures."] - pub dwTexType: u32, - #[doc = " [out] Size of the differential map."] - #[doc = ""] - #[doc = " Only set if bWithDiffMap is set to NVFBC_TRUE."] - pub diffMapSize: NVFBC_SIZE, -} -#[test] -fn bindgen_test_layout__NVFBC_TOGL_SETUP_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_TOGL_SETUP_PARAMS>(), - 56usize, - concat!("Size of: ", stringify!(_NVFBC_TOGL_SETUP_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_TOGL_SETUP_PARAMS>(), - 8usize, - concat!("Alignment of ", stringify!(_NVFBC_TOGL_SETUP_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_eBufferFormat() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).eBufferFormat) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(eBufferFormat) - ) - ); - } - test_field_eBufferFormat(); - fn test_field_bWithDiffMap() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).bWithDiffMap) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(bWithDiffMap) - ) - ); - } - test_field_bWithDiffMap(); - fn test_field_ppDiffMap() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).ppDiffMap) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(ppDiffMap) - ) - ); - } - test_field_ppDiffMap(); - fn test_field_dwDiffMapScalingFactor() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwDiffMapScalingFactor) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(dwDiffMapScalingFactor) - ) - ); - } - test_field_dwDiffMapScalingFactor(); - fn test_field_dwTextures() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwTextures) as usize - ptr as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(dwTextures) - ) - ); - } - test_field_dwTextures(); - fn test_field_dwTexTarget() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwTexTarget) as usize - ptr as usize - }, - 36usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(dwTexTarget) - ) - ); - } - test_field_dwTexTarget(); - fn test_field_dwTexFormat() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwTexFormat) as usize - ptr as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(dwTexFormat) - ) - ); - } - test_field_dwTexFormat(); - fn test_field_dwTexType() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwTexType) as usize - ptr as usize - }, - 44usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(dwTexType) - ) - ); - } - test_field_dwTexType(); - fn test_field_diffMapSize() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_SETUP_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).diffMapSize) as usize - ptr as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_SETUP_PARAMS), - "::", - stringify!(diffMapSize) - ) - ); - } - test_field_diffMapSize(); -} -#[doc = " Defines parameters for the ::NvFBCToGLSetUp() API call."] -pub type NVFBC_TOGL_SETUP_PARAMS = _NVFBC_TOGL_SETUP_PARAMS; -#[doc = " Defines parameters for the ::NvFBCToGLGrabFrame() API call."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _NVFBC_TOGL_GRAB_FRAME_PARAMS { - #[doc = " [in] Must be set to NVFBC_TOGL_GRAB_FRAME_PARAMS_VER."] - pub dwVersion: u32, - #[doc = " [in] Flags defining the behavior of this frame capture."] - pub dwFlags: u32, - #[doc = " [out] Index of the texture storing the current frame."] - #[doc = ""] - #[doc = " This is an index in the NVFBC_TOGL_SETUP_PARAMS::dwTextures array."] - pub dwTextureIndex: u32, - #[doc = " [out] Information about the captured frame."] - #[doc = ""] - #[doc = " Can be NULL."] - pub pFrameGrabInfo: *mut NVFBC_FRAME_GRAB_INFO, - #[doc = " [in] Wait timeout in milliseconds."] - #[doc = ""] - #[doc = " When capturing frames with the NVFBC_TOGL_GRAB_FLAGS_NOFLAGS or"] - #[doc = " NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags,"] - #[doc = " NvFBC will wait for a new frame or mouse move until the below timer"] - #[doc = " expires."] - #[doc = ""] - #[doc = " When timing out, the last captured frame will be returned. Note that as"] - #[doc = " long as the NVFBC_TOGL_GRAB_FLAGS_FORCE_REFRESH flag is not set,"] - #[doc = " returning an old frame will incur no performance penalty."] - #[doc = ""] - #[doc = " NvFBC clients can use the return value of the grab frame operation to"] - #[doc = " find out whether a new frame was captured, or the timer expired."] - #[doc = ""] - #[doc = " Note that the behavior of blocking calls is to wait for a new frame"] - #[doc = " *after* the call has been made. When using timeouts, it is possible"] - #[doc = " that NvFBC will return a new frame (e.g., it has never been captured"] - #[doc = " before) even though no new frame was generated after the grab call."] - #[doc = ""] - #[doc = " For the precise definition of what constitutes a new frame, see"] - #[doc = " ::bIsNewFrame."] - #[doc = ""] - #[doc = " Set to 0 to disable timeouts."] - pub dwTimeoutMs: u32, -} -#[test] -fn bindgen_test_layout__NVFBC_TOGL_GRAB_FRAME_PARAMS() { - assert_eq!( - ::std::mem::size_of::<_NVFBC_TOGL_GRAB_FRAME_PARAMS>(), - 32usize, - concat!("Size of: ", stringify!(_NVFBC_TOGL_GRAB_FRAME_PARAMS)) - ); - assert_eq!( - ::std::mem::align_of::<_NVFBC_TOGL_GRAB_FRAME_PARAMS>(), - 8usize, - concat!("Alignment of ", stringify!(_NVFBC_TOGL_GRAB_FRAME_PARAMS)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_GRAB_FRAME_PARAMS), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_dwFlags() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwFlags) as usize - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_GRAB_FRAME_PARAMS), - "::", - stringify!(dwFlags) - ) - ); - } - test_field_dwFlags(); - fn test_field_dwTextureIndex() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwTextureIndex) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_GRAB_FRAME_PARAMS), - "::", - stringify!(dwTextureIndex) - ) - ); - } - test_field_dwTextureIndex(); - fn test_field_pFrameGrabInfo() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pFrameGrabInfo) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_GRAB_FRAME_PARAMS), - "::", - stringify!(pFrameGrabInfo) - ) - ); - } - test_field_pFrameGrabInfo(); - fn test_field_dwTimeoutMs() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::<_NVFBC_TOGL_GRAB_FRAME_PARAMS>::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwTimeoutMs) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_NVFBC_TOGL_GRAB_FRAME_PARAMS), - "::", - stringify!(dwTimeoutMs) - ) - ); - } - test_field_dwTimeoutMs(); -} -#[doc = " Defines parameters for the ::NvFBCToGLGrabFrame() API call."] -pub type NVFBC_TOGL_GRAB_FRAME_PARAMS = _NVFBC_TOGL_GRAB_FRAME_PARAMS; -extern "C" { - #[doc = " Gets the last error message that got recorded for a client."] - #[doc = ""] - #[doc = " When NvFBC returns an error, it will save an error message that can be"] - #[doc = " queried through this API call. Only the last message is saved."] - #[doc = " The message and the return code should give enough information about"] - #[doc = " what went wrong."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " Handle to the NvFBC client."] - #[doc = " \\return"] - #[doc = " A NULL terminated error message, or an empty string. Its maximum length"] - #[doc = " is NVFBC_ERROR_STR_LEN."] - pub fn NvFBCGetLastErrorStr(sessionHandle: NVFBC_SESSION_HANDLE) -> *const ::std::os::raw::c_char; -} -extern "C" { - #[doc = " \\brief Allocates a new handle for an NvFBC client."] - #[doc = ""] - #[doc = " This function allocates a session handle used to identify an FBC client."] - #[doc = ""] - #[doc = " This function implicitly calls NvFBCBindContext()."] - #[doc = ""] - #[doc = " \\param [out] pSessionHandle"] - #[doc = " Pointer that will hold the allocated session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_CREATE_HANDLE_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_PTR \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_OUT_OF_MEMORY \\n"] - #[doc = " ::NVFBC_ERR_MAX_CLIENTS \\n"] - #[doc = " ::NVFBC_ERR_X \\n"] - #[doc = " ::NVFBC_ERR_GLX \\n"] - #[doc = " ::NVFBC_ERR_GL"] - #[doc = ""] - pub fn NvFBCCreateHandle( - pSessionHandle: *mut NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_CREATE_HANDLE_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Destroys the handle of an NvFBC client."] - #[doc = ""] - #[doc = " This function uninitializes an FBC client."] - #[doc = ""] - #[doc = " This function implicitly calls NvFBCReleaseContext()."] - #[doc = ""] - #[doc = " After this fucntion returns, it is not possible to use this session handle"] - #[doc = " for any further API call."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_DESTROY_HANDLE_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_X"] - pub fn NvFBCDestroyHandle( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_DESTROY_HANDLE_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Gets the current status of the display driver."] - #[doc = ""] - #[doc = " This function queries the display driver for various information."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_GET_STATUS_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_X"] - pub fn NvFBCGetStatus(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_GET_STATUS_PARAMS) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Binds the FBC context to the calling thread."] - #[doc = ""] - #[doc = " The NvFBC library internally relies on objects that must be bound to a"] - #[doc = " thread. Such objects are OpenGL contexts and CUDA contexts."] - #[doc = ""] - #[doc = " This function binds these objects to the calling thread."] - #[doc = ""] - #[doc = " The FBC context must be bound to the calling thread for most NvFBC entry"] - #[doc = " points, otherwise ::NVFBC_ERR_CONTEXT is returned."] - #[doc = ""] - #[doc = " If the FBC context is already bound to a different thread,"] - #[doc = " ::NVFBC_ERR_CONTEXT is returned. The other thread must release the context"] - #[doc = " first by calling the ReleaseContext() entry point."] - #[doc = ""] - #[doc = " If the FBC context is already bound to the current thread, this function has"] - #[doc = " no effects."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_DESTROY_CAPTURE_SESSION_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_X"] - pub fn NvFBCBindContext( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_BIND_CONTEXT_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Releases the FBC context from the calling thread."] - #[doc = ""] - #[doc = " If the FBC context is bound to a different thread, ::NVFBC_ERR_CONTEXT is"] - #[doc = " returned."] - #[doc = ""] - #[doc = " If the FBC context is already released, this functino has no effects."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_X"] - pub fn NvFBCReleaseContext( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_RELEASE_CONTEXT_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Creates a capture session for an FBC client."] - #[doc = ""] - #[doc = " This function starts a capture session of the desired type (system memory,"] - #[doc = " video memory with CUDA interop, or H.264 compressed frames in system memory)."] - #[doc = ""] - #[doc = " Not all types are supported on all systems. Also, it is possible to use"] - #[doc = " NvFBC without having the CUDA library. In this case, requesting a capture"] - #[doc = " session of the concerned type will return an error."] - #[doc = ""] - #[doc = " After this function returns, the display driver will start generating frames"] - #[doc = " that can be captured using the corresponding API call."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_CREATE_CAPTURE_SESSION_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_INVALID_PARAM \\n"] - #[doc = " ::NVFBC_ERR_OUT_OF_MEMORY \\n"] - #[doc = " ::NVFBC_ERR_X \\n"] - #[doc = " ::NVFBC_ERR_GLX \\n"] - #[doc = " ::NVFBC_ERR_GL \\n"] - #[doc = " ::NVFBC_ERR_CUDA \\n"] - #[doc = " ::NVFBC_ERR_MUST_RECREATE \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL"] - pub fn NvFBCCreateCaptureSession( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_CREATE_CAPTURE_SESSION_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Destroys a capture session for an FBC client."] - #[doc = ""] - #[doc = " This function stops a capture session and frees allocated objects."] - #[doc = ""] - #[doc = " After this function returns, it is possible to create another capture"] - #[doc = " session using the corresponding API call."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_DESTROY_CAPTURE_SESSION_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_X"] - pub fn NvFBCDestroyCaptureSession( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_DESTROY_CAPTURE_SESSION_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Sets up a capture to system memory session."] - #[doc = ""] - #[doc = " This function configures how the capture to system memory should behave. It"] - #[doc = " can be called anytime and several times after the capture session has been"] - #[doc = " created. However, it must be called at least once prior to start capturing"] - #[doc = " frames."] - #[doc = ""] - #[doc = " This function allocates the buffer that will contain the captured frame."] - #[doc = " The application does not need to free this buffer. The size of this buffer"] - #[doc = " is returned in the ::NVFBC_FRAME_GRAB_INFO structure."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_TOSYS_SETUP_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_UNSUPPORTED \\n"] - #[doc = " ::NVFBC_ERR_INVALID_PTR \\n"] - #[doc = " ::NVFBC_ERR_INVALID_PARAM \\n"] - #[doc = " ::NVFBC_ERR_OUT_OF_MEMORY \\n"] - #[doc = " ::NVFBC_ERR_X"] - pub fn NvFBCToSysSetUp(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_TOSYS_SETUP_PARAMS) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Captures a frame to a buffer in system memory."] - #[doc = ""] - #[doc = " This function triggers a frame capture to a buffer in system memory that was"] - #[doc = " registered with the ToSysSetUp() API call."] - #[doc = ""] - #[doc = " Note that it is possible that the resolution of the desktop changes while"] - #[doc = " capturing frames. This should be transparent for the application."] - #[doc = ""] - #[doc = " When the resolution changes, the capture session is recreated using the same"] - #[doc = " parameters, and necessary buffers are re-allocated. The frame counter is not"] - #[doc = " reset."] - #[doc = ""] - #[doc = " An application can detect that the resolution changed by comparing the"] - #[doc = " dwByteSize member of the ::NVFBC_FRAME_GRAB_INFO against a previous"] - #[doc = " frame and/or dwWidth and dwHeight."] - #[doc = ""] - #[doc = " During a change of resolution the capture is paused even in asynchronous"] - #[doc = " mode."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_TOSYS_GRAB_FRAME_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_INVALID_PTR \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_X \\n"] - #[doc = " ::NVFBC_ERR_MUST_RECREATE \\n"] - #[doc = " \\see NvFBCCreateCaptureSession \\n"] - #[doc = " \\see NvFBCToSysSetUp"] - pub fn NvFBCToSysGrabFrame( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_TOSYS_GRAB_FRAME_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Sets up a capture to video memory session."] - #[doc = ""] - #[doc = " This function configures how the capture to video memory with CUDA interop"] - #[doc = " should behave. It can be called anytime and several times after the capture"] - #[doc = " session has been created. However, it must be called at least once prior"] - #[doc = " to start capturing frames."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = ""] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_TOCUDA_SETUP_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_UNSUPPORTED \\n"] - #[doc = " ::NVFBC_ERR_GL \\n"] - #[doc = " ::NVFBC_ERR_X"] - pub fn NvFBCToCudaSetUp( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_TOCUDA_SETUP_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Captures a frame to a CUDA device in video memory."] - #[doc = ""] - #[doc = " This function triggers a frame capture to a CUDA device in video memory."] - #[doc = ""] - #[doc = " Note about changes of resolution: \\see NvFBCToSysGrabFrame"] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = ""] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_TOCUDA_GRAB_FRAME_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_INVALID_PTR \\n"] - #[doc = " ::NVFBC_ERR_CUDA \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_X \\n"] - #[doc = " ::NVFBC_ERR_MUST_RECREATE \\n"] - #[doc = " \\see NvFBCCreateCaptureSession \\n"] - #[doc = " \\see NvFBCToCudaSetUp"] - pub fn NvFBCToCudaGrabFrame( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_TOCUDA_GRAB_FRAME_PARAMS, - ) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Sets up a capture to OpenGL buffer in video memory session."] - #[doc = ""] - #[doc = " This function configures how the capture to video memory should behave."] - #[doc = " It can be called anytime and several times after the capture session has been"] - #[doc = " created. However, it must be called at least once prior to start capturing"] - #[doc = " frames."] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = ""] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_TOGL_SETUP_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_UNSUPPORTED \\n"] - #[doc = " ::NVFBC_ERR_GL \\n"] - #[doc = " ::NVFBC_ERR_X"] - pub fn NvFBCToGLSetUp(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_TOGL_SETUP_PARAMS) -> NVFBCSTATUS; -} -extern "C" { - #[doc = " \\brief Captures a frame to an OpenGL buffer in video memory."] - #[doc = ""] - #[doc = " This function triggers a frame capture to a selected resource in video memory."] - #[doc = ""] - #[doc = " Note about changes of resolution: \\see NvFBCToSysGrabFrame"] - #[doc = ""] - #[doc = " \\param [in] sessionHandle"] - #[doc = " FBC session handle."] - #[doc = ""] - #[doc = " \\param [in] pParams"] - #[doc = " ::NVFBC_TOGL_GRAB_FRAME_PARAMS"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_HANDLE \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION \\n"] - #[doc = " ::NVFBC_ERR_BAD_REQUEST \\n"] - #[doc = " ::NVFBC_ERR_CONTEXT \\n"] - #[doc = " ::NVFBC_ERR_INVALID_PTR \\n"] - #[doc = " ::NVFBC_ERR_INTERNAL \\n"] - #[doc = " ::NVFBC_ERR_X \\n"] - #[doc = " ::NVFBC_ERR_MUST_RECREATE \\n"] - #[doc = " \\see NvFBCCreateCaptureSession \\n"] - #[doc = " \\see NvFBCToCudaSetUp"] - pub fn NvFBCToGLGrabFrame( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_TOGL_GRAB_FRAME_PARAMS, - ) -> NVFBCSTATUS; -} -#[doc = " \\cond FBC_PFN"] -#[doc = ""] -#[doc = " Defines API function pointers"] -pub type PNVFBCGETLASTERRORSTR = - ::std::option::Option *const ::std::os::raw::c_char>; -pub type PNVFBCCREATEHANDLE = ::std::option::Option< - unsafe extern "C" fn( - pSessionHandle: *mut NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_CREATE_HANDLE_PARAMS, - ) -> NVFBCSTATUS, ->; -pub type PNVFBCDESTROYHANDLE = ::std::option::Option< - unsafe extern "C" fn(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_DESTROY_HANDLE_PARAMS) -> NVFBCSTATUS, ->; -pub type PNVFBCBINDCONTEXT = ::std::option::Option< - unsafe extern "C" fn(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_BIND_CONTEXT_PARAMS) -> NVFBCSTATUS, ->; -pub type PNVFBCRELEASECONTEXT = ::std::option::Option< - unsafe extern "C" fn( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_RELEASE_CONTEXT_PARAMS, - ) -> NVFBCSTATUS, ->; -pub type PNVFBCGETSTATUS = ::std::option::Option< - unsafe extern "C" fn(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_GET_STATUS_PARAMS) -> NVFBCSTATUS, ->; -pub type PNVFBCCREATECAPTURESESSION = ::std::option::Option< - unsafe extern "C" fn( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_CREATE_CAPTURE_SESSION_PARAMS, - ) -> NVFBCSTATUS, ->; -pub type PNVFBCDESTROYCAPTURESESSION = ::std::option::Option< - unsafe extern "C" fn( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_DESTROY_CAPTURE_SESSION_PARAMS, - ) -> NVFBCSTATUS, ->; -pub type PNVFBCTOSYSSETUP = ::std::option::Option< - unsafe extern "C" fn(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_TOSYS_SETUP_PARAMS) -> NVFBCSTATUS, ->; -pub type PNVFBCTOSYSGRABFRAME = ::std::option::Option< - unsafe extern "C" fn( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_TOSYS_GRAB_FRAME_PARAMS, - ) -> NVFBCSTATUS, ->; -pub type PNVFBCTOCUDASETUP = ::std::option::Option< - unsafe extern "C" fn(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_TOCUDA_SETUP_PARAMS) -> NVFBCSTATUS, ->; -pub type PNVFBCTOCUDAGRABFRAME = ::std::option::Option< - unsafe extern "C" fn( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_TOCUDA_GRAB_FRAME_PARAMS, - ) -> NVFBCSTATUS, ->; -pub type PNVFBCTOGLSETUP = ::std::option::Option< - unsafe extern "C" fn(sessionHandle: NVFBC_SESSION_HANDLE, pParams: *mut NVFBC_TOGL_SETUP_PARAMS) -> NVFBCSTATUS, ->; -pub type PNVFBCTOGLGRABFRAME = ::std::option::Option< - unsafe extern "C" fn( - sessionHandle: NVFBC_SESSION_HANDLE, - pParams: *mut NVFBC_TOGL_GRAB_FRAME_PARAMS, - ) -> NVFBCSTATUS, ->; -#[doc = " \\ingroup FBC_STRUCT"] -#[doc = ""] -#[doc = " Structure populated with API function pointers."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct NVFBC_API_FUNCTION_LIST { - #[doc = "!< [in] Must be set to NVFBC_VERSION."] - pub dwVersion: u32, - #[doc = "!< [out] Pointer to ::NvFBCGetLastErrorStr()."] - pub nvFBCGetLastErrorStr: PNVFBCGETLASTERRORSTR, - #[doc = "!< [out] Pointer to ::NvFBCCreateHandle()."] - pub nvFBCCreateHandle: PNVFBCCREATEHANDLE, - #[doc = "!< [out] Pointer to ::NvFBCDestroyHandle()."] - pub nvFBCDestroyHandle: PNVFBCDESTROYHANDLE, - #[doc = "!< [out] Pointer to ::NvFBCGetStatus()."] - pub nvFBCGetStatus: PNVFBCGETSTATUS, - #[doc = "!< [out] Pointer to ::NvFBCCreateCaptureSession()."] - pub nvFBCCreateCaptureSession: PNVFBCCREATECAPTURESESSION, - #[doc = "!< [out] Pointer to ::NvFBCDestroyCaptureSession()."] - pub nvFBCDestroyCaptureSession: PNVFBCDESTROYCAPTURESESSION, - #[doc = "!< [out] Pointer to ::NvFBCToSysSetUp()."] - pub nvFBCToSysSetUp: PNVFBCTOSYSSETUP, - #[doc = "!< [out] Pointer to ::NvFBCToSysGrabFrame()."] - pub nvFBCToSysGrabFrame: PNVFBCTOSYSGRABFRAME, - #[doc = "!< [out] Pointer to ::NvFBCToCudaSetUp()."] - pub nvFBCToCudaSetUp: PNVFBCTOCUDASETUP, - #[doc = "!< [out] Pointer to ::NvFBCToCudaGrabFrame()."] - pub nvFBCToCudaGrabFrame: PNVFBCTOCUDAGRABFRAME, - #[doc = "!< [out] Retired. Do not use."] - pub pad1: *mut ::std::os::raw::c_void, - #[doc = "!< [out] Retired. Do not use."] - pub pad2: *mut ::std::os::raw::c_void, - #[doc = "!< [out] Retired. Do not use."] - pub pad3: *mut ::std::os::raw::c_void, - #[doc = "!< [out] Pointer to ::NvFBCBindContext()."] - pub nvFBCBindContext: PNVFBCBINDCONTEXT, - #[doc = "!< [out] Pointer to ::NvFBCReleaseContext()."] - pub nvFBCReleaseContext: PNVFBCRELEASECONTEXT, - #[doc = "!< [out] Retired. Do not use."] - pub pad4: *mut ::std::os::raw::c_void, - #[doc = "!< [out] Retired. Do not use."] - pub pad5: *mut ::std::os::raw::c_void, - #[doc = "!< [out] Retired. Do not use."] - pub pad6: *mut ::std::os::raw::c_void, - #[doc = "!< [out] Retired. Do not use."] - pub pad7: *mut ::std::os::raw::c_void, - #[doc = "!< [out] Pointer to ::nvFBCToGLSetup()."] - pub nvFBCToGLSetUp: PNVFBCTOGLSETUP, - #[doc = "!< [out] Pointer to ::nvFBCToGLGrabFrame()."] - pub nvFBCToGLGrabFrame: PNVFBCTOGLGRABFRAME, -} -#[test] -fn bindgen_test_layout_NVFBC_API_FUNCTION_LIST() { - assert_eq!( - ::std::mem::size_of::(), - 176usize, - concat!("Size of: ", stringify!(NVFBC_API_FUNCTION_LIST)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(NVFBC_API_FUNCTION_LIST)) - ); - fn test_field_dwVersion() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).dwVersion) as usize - ptr as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(dwVersion) - ) - ); - } - test_field_dwVersion(); - fn test_field_nvFBCGetLastErrorStr() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCGetLastErrorStr) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCGetLastErrorStr) - ) - ); - } - test_field_nvFBCGetLastErrorStr(); - fn test_field_nvFBCCreateHandle() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCCreateHandle) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCCreateHandle) - ) - ); - } - test_field_nvFBCCreateHandle(); - fn test_field_nvFBCDestroyHandle() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCDestroyHandle) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCDestroyHandle) - ) - ); - } - test_field_nvFBCDestroyHandle(); - fn test_field_nvFBCGetStatus() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCGetStatus) as usize - ptr as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCGetStatus) - ) - ); - } - test_field_nvFBCGetStatus(); - fn test_field_nvFBCCreateCaptureSession() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCCreateCaptureSession) as usize - ptr as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCCreateCaptureSession) - ) - ); - } - test_field_nvFBCCreateCaptureSession(); - fn test_field_nvFBCDestroyCaptureSession() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCDestroyCaptureSession) as usize - ptr as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCDestroyCaptureSession) - ) - ); - } - test_field_nvFBCDestroyCaptureSession(); - fn test_field_nvFBCToSysSetUp() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCToSysSetUp) as usize - ptr as usize - }, - 56usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCToSysSetUp) - ) - ); - } - test_field_nvFBCToSysSetUp(); - fn test_field_nvFBCToSysGrabFrame() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCToSysGrabFrame) as usize - ptr as usize - }, - 64usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCToSysGrabFrame) - ) - ); - } - test_field_nvFBCToSysGrabFrame(); - fn test_field_nvFBCToCudaSetUp() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCToCudaSetUp) as usize - ptr as usize - }, - 72usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCToCudaSetUp) - ) - ); - } - test_field_nvFBCToCudaSetUp(); - fn test_field_nvFBCToCudaGrabFrame() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCToCudaGrabFrame) as usize - ptr as usize - }, - 80usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCToCudaGrabFrame) - ) - ); - } - test_field_nvFBCToCudaGrabFrame(); - fn test_field_pad1() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pad1) as usize - ptr as usize - }, - 88usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(pad1) - ) - ); - } - test_field_pad1(); - fn test_field_pad2() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pad2) as usize - ptr as usize - }, - 96usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(pad2) - ) - ); - } - test_field_pad2(); - fn test_field_pad3() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pad3) as usize - ptr as usize - }, - 104usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(pad3) - ) - ); - } - test_field_pad3(); - fn test_field_nvFBCBindContext() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCBindContext) as usize - ptr as usize - }, - 112usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCBindContext) - ) - ); - } - test_field_nvFBCBindContext(); - fn test_field_nvFBCReleaseContext() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCReleaseContext) as usize - ptr as usize - }, - 120usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCReleaseContext) - ) - ); - } - test_field_nvFBCReleaseContext(); - fn test_field_pad4() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pad4) as usize - ptr as usize - }, - 128usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(pad4) - ) - ); - } - test_field_pad4(); - fn test_field_pad5() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pad5) as usize - ptr as usize - }, - 136usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(pad5) - ) - ); - } - test_field_pad5(); - fn test_field_pad6() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pad6) as usize - ptr as usize - }, - 144usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(pad6) - ) - ); - } - test_field_pad6(); - fn test_field_pad7() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).pad7) as usize - ptr as usize - }, - 152usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(pad7) - ) - ); - } - test_field_pad7(); - fn test_field_nvFBCToGLSetUp() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCToGLSetUp) as usize - ptr as usize - }, - 160usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCToGLSetUp) - ) - ); - } - test_field_nvFBCToGLSetUp(); - fn test_field_nvFBCToGLGrabFrame() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr).nvFBCToGLGrabFrame) as usize - ptr as usize - }, - 168usize, - concat!( - "Offset of field: ", - stringify!(NVFBC_API_FUNCTION_LIST), - "::", - stringify!(nvFBCToGLGrabFrame) - ) - ); - } - test_field_nvFBCToGLGrabFrame(); -} -extern "C" { - #[doc = " \\ingroup FBC_FUNC"] - #[doc = ""] - #[doc = " \\brief Entry Points to the NvFBC interface."] - #[doc = ""] - #[doc = " Creates an instance of the NvFBC interface, and populates the"] - #[doc = " pFunctionList with function pointers to the API routines implemented by"] - #[doc = " the NvFBC interface."] - #[doc = ""] - #[doc = " \\param [out] pFunctionList"] - #[doc = ""] - #[doc = " \\return"] - #[doc = " ::NVFBC_SUCCESS \\n"] - #[doc = " ::NVFBC_ERR_INVALID_PTR \\n"] - #[doc = " ::NVFBC_ERR_API_VERSION"] - pub fn NvFBCCreateInstance(pFunctionList: *mut NVFBC_API_FUNCTION_LIST) -> NVFBCSTATUS; -} -#[doc = " \\ingroup FBC_FUNC"] -#[doc = ""] -#[doc = " Defines function pointer for the ::NvFBCCreateInstance() API call."] -pub type PNVFBCCREATEINSTANCE = - ::std::option::Option NVFBCSTATUS>; diff --git a/nvfbc-sys/src/lib.rs b/nvfbc-sys/src/lib.rs index 9d53bae..428a22c 100644 --- a/nvfbc-sys/src/lib.rs +++ b/nvfbc-sys/src/lib.rs @@ -2,25 +2,4 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] -mod generated; -pub use generated::*; - -pub const NVFBC_VERSION: u32 = NVFBC_VERSION_MINOR | (NVFBC_VERSION_MAJOR << 8); - -pub const NVFBC_CREATE_HANDLE_PARAMS_VER: u32 = nvfbc_struct_version::(2); -pub const NVFBC_DESTROY_HANDLE_PARAMS_VER: u32 = nvfbc_struct_version::(1); -pub const NVFBC_GET_STATUS_PARAMS_VER: u32 = nvfbc_struct_version::(2); -pub const NVFBC_CREATE_CAPTURE_SESSION_PARAMS_VER: u32 = nvfbc_struct_version::(6); -pub const NVFBC_DESTROY_CAPTURE_SESSION_PARAMS_VER: u32 = nvfbc_struct_version::(1); -pub const NVFBC_TOGL_SETUP_PARAMS_VER: u32 = nvfbc_struct_version::(2); -pub const NVFBC_TOGL_GRAB_FRAME_PARAMS_VER: u32 = nvfbc_struct_version::(2); -pub const NVFBC_TOCUDA_SETUP_PARAMS_VER: u32 = nvfbc_struct_version::(1); -pub const NVFBC_TOCUDA_GRAB_FRAME_PARAMS_VER: u32 = nvfbc_struct_version::(2); -pub const NVFBC_TOSYS_SETUP_PARAMS_VER: u32 = nvfbc_struct_version::(3); -pub const NVFBC_TOSYS_GRAB_FRAME_PARAMS_VER: u32 = nvfbc_struct_version::(2); -pub const NVFBC_RELEASE_CONTEXT_PARAMS_VER: u32 = nvfbc_struct_version::(1); -pub const NVFBC_BIND_CONTEXT_PARAMS_VER: u32 = nvfbc_struct_version::(1); - -pub const fn nvfbc_struct_version(version: u32) -> u32 { - std::mem::size_of::() as u32 | ((version) << 16 | NVFBC_VERSION << 24) -} +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); \ No newline at end of file diff --git a/nvfbc-sys/wrapper.h b/nvfbc-sys/wrapper.h new file mode 100644 index 0000000..5542f1d --- /dev/null +++ b/nvfbc-sys/wrapper.h @@ -0,0 +1,4 @@ +#include +#include +// #include // error: unknown type name 'IDirect3DSurface9' +#include \ No newline at end of file diff --git a/nvfbc/src/common.rs b/nvfbc/src/common.rs index 5e8b940..ffe36b2 100644 --- a/nvfbc/src/common.rs +++ b/nvfbc/src/common.rs @@ -1,12 +1,8 @@ -use std::os::raw::c_uint; -use std::{mem::MaybeUninit, ffi::CStr}; +use std::{ffi::CStr, mem::MaybeUninit, os::raw::c_uint}; -use nvfbc_sys::_NVFBCSTATUS_NVFBC_SUCCESS as SUCCESS; -use nvfbc_sys::NVFBC_SESSION_HANDLE; +use nvfbc_sys::{NVFBC_SESSION_HANDLE, _NVFBCSTATUS_NVFBC_SUCCESS as SUCCESS}; -use crate::CaptureType; -use crate::Error; -use crate::Status; +use crate::{CaptureType, Error, Status}; pub type Handle = NVFBC_SESSION_HANDLE; @@ -26,10 +22,7 @@ pub(crate) fn create_handle() -> Result params.privateDataSize = std::mem::size_of_val(&MAGIC_PRIVATE_DATA) as u32; let mut handle = 0; - let ret = unsafe { nvfbc_sys::NvFBCCreateHandle( - &mut handle, - &mut params - )}; + let ret = unsafe { nvfbc_sys::NvFBCCreateHandle(&mut handle, &mut params) }; if ret != SUCCESS { return Err(Error::new(ret, None)); } @@ -56,7 +49,11 @@ pub(crate) fn status(handle: Handle) -> Result { Ok(params.into()) } -pub(crate) fn create_capture_session(handle: Handle, capture_type: CaptureType, sampling_rate: std::time::Duration) -> Result<(), Error> { +pub(crate) fn create_capture_session( + handle: Handle, + capture_type: CaptureType, + sampling_rate: std::time::Duration, +) -> Result<(), Error> { let mut params: nvfbc_sys::_NVFBC_CREATE_CAPTURE_SESSION_PARAMS = unsafe { MaybeUninit::zeroed().assume_init() }; params.dwVersion = nvfbc_sys::NVFBC_CREATE_CAPTURE_SESSION_PARAMS_VER; params.eCaptureType = capture_type as c_uint; @@ -64,11 +61,15 @@ pub(crate) fn create_capture_session(handle: Handle, capture_type: CaptureType, params.frameSize = nvfbc_sys::NVFBC_SIZE { w: 0, h: 0 }; params.eTrackingType = nvfbc_sys::NVFBC_TRACKING_TYPE_NVFBC_TRACKING_DEFAULT; params.dwSamplingRateMs = sampling_rate.as_millis() as u32; - check_ret(handle, unsafe { nvfbc_sys::NvFBCCreateCaptureSession(handle, &mut params) }) + check_ret(handle, unsafe { + nvfbc_sys::NvFBCCreateCaptureSession(handle, &mut params) + }) } pub(crate) fn destroy_capture_session(handle: Handle) -> Result<(), Error> { let mut params: nvfbc_sys::_NVFBC_DESTROY_CAPTURE_SESSION_PARAMS = unsafe { MaybeUninit::zeroed().assume_init() }; params.dwVersion = nvfbc_sys::NVFBC_DESTROY_CAPTURE_SESSION_PARAMS_VER; - check_ret(handle, unsafe { nvfbc_sys::NvFBCDestroyCaptureSession(handle, &mut params) }) + check_ret(handle, unsafe { + nvfbc_sys::NvFBCDestroyCaptureSession(handle, &mut params) + }) } diff --git a/nvfbc/src/cuda.rs b/nvfbc/src/cuda.rs index 3c85dcd..53023eb 100644 --- a/nvfbc/src/cuda.rs +++ b/nvfbc/src/cuda.rs @@ -1,30 +1,27 @@ -use std::ffi::c_void; -use std::mem::MaybeUninit; -use std::ptr::null_mut; +use std::{ffi::c_void, mem::MaybeUninit, ptr::null_mut}; use nvfbc_sys::{ - NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT, NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS, - NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY + NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT, + NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY, }; use crate::{ + common::{ + check_ret, + create_capture_session, + create_handle, + destroy_capture_session, + destroy_handle, + status, + Handle, + }, BufferFormat, CaptureType, Error, Status, }; -use crate::common::{ - Handle, - check_ret, - create_capture_session, - create_handle, - destroy_capture_session, - destroy_handle, - status, -}; - pub enum CaptureMethod { /// Capturing does not wait for a new frame nor a mouse move. /// @@ -83,7 +80,9 @@ impl CudaCapturer { /// /// CUDA must be initialized before creating this object. pub fn new() -> Result { - Ok(Self { handle: create_handle()? }) + Ok(Self { + handle: create_handle()?, + }) } /// Retrieve the status of NVFBC. @@ -102,7 +101,9 @@ impl CudaCapturer { let mut params: nvfbc_sys::NVFBC_TOCUDA_SETUP_PARAMS = unsafe { MaybeUninit::zeroed().assume_init() }; params.dwVersion = nvfbc_sys::NVFBC_TOCUDA_SETUP_PARAMS_VER; params.eBufferFormat = buffer_format as u32; - check_ret(self.handle, unsafe { nvfbc_sys::NvFBCToCudaSetUp(self.handle, &mut params) }) + check_ret(self.handle, unsafe { + nvfbc_sys::NvFBCToCudaSetUp(self.handle, &mut params) + }) } /// Stop a capture session. @@ -112,14 +113,16 @@ impl CudaCapturer { /// Retrieve the next frame from the GPU. pub fn next_frame(&mut self, capture_method: CaptureMethod) -> Result { - let mut device_buffer: *mut c_void = null_mut(); + let mut device_buffer: *mut c_void = null_mut(); let mut frame_info: nvfbc_sys::NVFBC_FRAME_GRAB_INFO = unsafe { MaybeUninit::zeroed().assume_init() }; let mut params: nvfbc_sys::NVFBC_TOCUDA_GRAB_FRAME_PARAMS = unsafe { MaybeUninit::zeroed().assume_init() }; params.dwVersion = nvfbc_sys::NVFBC_TOCUDA_GRAB_FRAME_PARAMS_VER; params.dwFlags = capture_method as u32; params.pFrameGrabInfo = &mut frame_info; params.pCUDADeviceBuffer = &mut device_buffer as *mut _ as *mut c_void; - check_ret(self.handle, unsafe { nvfbc_sys::NvFBCToCudaGrabFrame(self.handle, &mut params) })?; + check_ret(self.handle, unsafe { + nvfbc_sys::NvFBCToCudaGrabFrame(self.handle, &mut params) + })?; Ok(CudaFrameInfo { device_buffer: device_buffer as usize, @@ -139,10 +142,9 @@ impl CudaCapturer { pub fn release_context(&self) -> Result<(), Error> { let mut params: nvfbc_sys::NVFBC_RELEASE_CONTEXT_PARAMS = unsafe { MaybeUninit::zeroed().assume_init() }; params.dwVersion = nvfbc_sys::NVFBC_RELEASE_CONTEXT_PARAMS_VER; - check_ret( - self.handle, - unsafe { nvfbc_sys::NvFBCReleaseContext(self.handle, &mut params) } - ) + check_ret(self.handle, unsafe { + nvfbc_sys::NvFBCReleaseContext(self.handle, &mut params) + }) } /// Binds the FBC context to the calling thread. @@ -164,10 +166,9 @@ impl CudaCapturer { pub fn bind_context(&self) -> Result<(), Error> { let mut params: nvfbc_sys::NVFBC_BIND_CONTEXT_PARAMS = unsafe { MaybeUninit::zeroed().assume_init() }; params.dwVersion = nvfbc_sys::NVFBC_BIND_CONTEXT_PARAMS_VER; - check_ret( - self.handle, - unsafe { nvfbc_sys::NvFBCBindContext(self.handle, &mut params) } - ) + check_ret(self.handle, unsafe { + nvfbc_sys::NvFBCBindContext(self.handle, &mut params) + }) } } diff --git a/nvfbc/src/error.rs b/nvfbc/src/error.rs index 1f69163..846ecf9 100644 --- a/nvfbc/src/error.rs +++ b/nvfbc/src/error.rs @@ -14,25 +14,26 @@ impl Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[rustfmt::skip] let error_code_message = match self.code { - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_API_VERSION => "The API version between the client and the library is not compatible".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INTERNAL => "An internal error occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM => "One or more of the parameter passed to the API call is invalid".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PTR => "One or more of the pointers passed to the API call is invalid".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE => "The handle passed to the API call to identify the client is invalid".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS => "The maximum number of threaded clients (10) of the same process has been reached".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED => "The requested feature is not currently supported by the library".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY => "Unable to allocate enough memory to perform the requested operation".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST => "The API call was not expected".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_X => "An unknown X error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GLX => "An unknown GLX error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GL => "An unknown OpenGL error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CUDA => "An unknown CUDA error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_ENCODER => "A hardware encoder error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CONTEXT => "An NVFBC context error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE => "The capture session must be recreated".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_VULKAN => "A Vulkan error has occurred".to_string(), - code => format!("Un unknown error code ({}) was returned", code), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_API_VERSION => "The API version between the client and the library is not compatible", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INTERNAL => "An internal error occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM => "One or more of the parameter passed to the API call is invalid", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PTR => "One or more of the pointers passed to the API call is invalid", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE => "The handle passed to the API call to identify the client is invalid", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS => "The maximum number of threaded clients (10) of the same process has been reached", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED => "The requested feature is not currently supported by the library", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY => "Unable to allocate enough memory to perform the requested operation", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST => "The API call was not expected", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_X => "An unknown X error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GLX => "An unknown GLX error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GL => "An unknown OpenGL error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CUDA => "An unknown CUDA error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_ENCODER => "A hardware encoder error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CONTEXT => "An NVFBC context error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE => "The capture session must be recreated", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_VULKAN => "A Vulkan error has occurred", + code => format!("Un unknown error code ({}) was returned", code).as_str(), }; if let Some(message) = &self.message { diff --git a/nvfbc/src/lib.rs b/nvfbc/src/lib.rs index f77f1bd..29ee2e2 100644 --- a/nvfbc/src/lib.rs +++ b/nvfbc/src/lib.rs @@ -52,7 +52,7 @@ mod error; pub mod system; mod types; -pub use types::*; -pub use error::Error; pub use cuda::CudaCapturer; +pub use error::Error; pub use system::SystemCapturer; +pub use types::*; diff --git a/nvfbc/src/system.rs b/nvfbc/src/system.rs index c9675ca..edd4e45 100644 --- a/nvfbc/src/system.rs +++ b/nvfbc/src/system.rs @@ -1,28 +1,25 @@ -use std::cell::Cell; -use std::ffi::c_void; -use std::mem::MaybeUninit; -use std::ptr::null_mut; +use std::{cell::Cell, ffi::c_void, mem::MaybeUninit, ptr::null_mut}; use nvfbc_sys::{ - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT, NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS, - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY, }; -use crate::common::{ - Handle, - check_ret, - create_capture_session, - create_handle, - destroy_capture_session, - destroy_handle, - status, -}; use crate::{ + common::{ + check_ret, + create_capture_session, + create_handle, + destroy_capture_session, + destroy_handle, + status, + Handle, + }, BufferFormat, + CaptureType, Error, Status, - CaptureType, }; /// Different methods for capturing a frame. @@ -83,7 +80,10 @@ impl SystemCapturer { /// This also initializes a handle for the NVFBC API. pub fn new() -> Result { let handle = create_handle()?; - let self_ = Self { handle, buffer: Box::new(Cell::new(null_mut())) }; + let self_ = Self { + handle, + buffer: Box::new(Cell::new(null_mut())), + }; Ok(self_) } @@ -104,7 +104,9 @@ impl SystemCapturer { params.dwVersion = nvfbc_sys::NVFBC_TOSYS_SETUP_PARAMS_VER; params.eBufferFormat = buffer_format as u32; params.ppBuffer = self.buffer.as_ptr(); - check_ret(self.handle, unsafe { nvfbc_sys::NvFBCToSysSetUp(self.handle, &mut params) }) + check_ret(self.handle, unsafe { + nvfbc_sys::NvFBCToSysSetUp(self.handle, &mut params) + }) } /// Stop a capture session. @@ -127,7 +129,9 @@ impl SystemCapturer { params.dwVersion = nvfbc_sys::NVFBC_TOSYS_GRAB_FRAME_PARAMS_VER; params.dwFlags = capture_method as u32; params.pFrameGrabInfo = &mut frame_info; - check_ret(self.handle, unsafe { nvfbc_sys::NvFBCToSysGrabFrame(self.handle, &mut params) })?; + check_ret(self.handle, unsafe { + nvfbc_sys::NvFBCToSysGrabFrame(self.handle, &mut params) + })?; let buffer_ptr = unsafe { self.buffer.as_ptr().read_volatile().cast() }; let buffer = unsafe { std::slice::from_raw_parts(buffer_ptr, frame_info.dwByteSize as usize) }; diff --git a/nvfbc/src/types.rs b/nvfbc/src/types.rs index a2b4121..8d9a3df 100644 --- a/nvfbc/src/types.rs +++ b/nvfbc/src/types.rs @@ -125,7 +125,9 @@ impl From for Status { id: status.outputs[output_index as usize].dwId, name: unsafe { CStr::from_ptr(&status.outputs[output_index as usize].name as *const i8) - .to_str().unwrap().to_string() + .to_str() + .unwrap() + .to_string() }, tracked_box: Box { x: status.outputs[output_index as usize].trackedBox.x, @@ -140,7 +142,10 @@ impl From for Status { is_capture_possible: status.bIsCapturePossible == nvfbc_sys::_NVFBC_BOOL_NVFBC_TRUE, currently_capturing: status.bCurrentlyCapturing == nvfbc_sys::_NVFBC_BOOL_NVFBC_TRUE, can_create_now: status.bCanCreateNow == nvfbc_sys::_NVFBC_BOOL_NVFBC_TRUE, - screen_size: Size { w: status.screenSize.w, h: status.screenSize.h }, + screen_size: Size { + w: status.screenSize.w, + h: status.screenSize.h, + }, xrandr_available: status.bXRandRAvailable == nvfbc_sys::_NVFBC_BOOL_NVFBC_TRUE, outputs, nvfbc_version: status.dwNvFBCVersion, diff --git a/rustfmt.toml b/rustfmt.toml index 4b9795f..06d20f1 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -7,3 +7,5 @@ overflow_delimited_expr = true reorder_impl_items = true unstable_features = true use_field_init_shorthand = true +group_imports = "StdExternalCrate" +imports_granularity = "Crate" From 66c30ad7466638c45bbd3c52adb57cd308dc73d7 Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Sat, 9 Mar 2024 23:25:19 -0500 Subject: [PATCH 2/6] nvfbc: W.I.P Windows Support --- Cargo.lock | 143 ++++++++++++++++++++++--------------------- nvfbc-sys/Cargo.toml | 4 +- nvfbc-sys/build.rs | 19 ++++-- nvfbc-sys/src/lib.rs | 5 +- nvfbc-sys/wrapper.h | 3 +- nvfbc/src/common.rs | 20 ++++-- nvfbc/src/cuda.rs | 19 ++++-- nvfbc/src/error.rs | 74 ++++++++++++++++------ nvfbc/src/system.rs | 19 ++++-- 9 files changed, 192 insertions(+), 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d674e4..cba67ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,9 +65,9 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] name = "byteorder" @@ -109,43 +109,37 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-deque" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.17" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.18" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crunchy" @@ -173,9 +167,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "errno" @@ -189,9 +183,9 @@ dependencies = [ [[package]] name = "exr" -version = "1.71.0" +version = "1.72.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8" +checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" dependencies = [ "bit_field", "flume", @@ -205,9 +199,9 @@ dependencies = [ [[package]] name = "fdeflate" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "209098dd6dfc4445aa6111f0e98653ac323eaa4dfd212c9ca3931bf9955c31bd" +checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" dependencies = [ "simd-adler32", ] @@ -233,9 +227,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" +checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" dependencies = [ "color_quant", "weezl", @@ -249,10 +243,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "half" -version = "2.2.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" dependencies = [ + "cfg-if", "crunchy", ] @@ -267,9 +262,9 @@ dependencies = [ [[package]] name = "image" -version = "0.24.7" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", @@ -277,7 +272,6 @@ dependencies = [ "exr", "gif", "jpeg-decoder", - "num-rational", "num-traits", "png", "qoi", @@ -295,9 +289,9 @@ dependencies = [ [[package]] name = "jpeg-decoder" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" dependencies = [ "rayon", ] @@ -372,9 +366,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", "simd-adler32", @@ -390,32 +384,11 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -436,6 +409,7 @@ name = "nvfbc-sys" version = "0.1.5" dependencies = [ "bindgen", + "windows", ] [[package]] @@ -446,9 +420,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "png" -version = "0.17.10" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -469,9 +443,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -496,9 +470,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -506,9 +480,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -611,9 +585,9 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "spin" @@ -648,9 +622,9 @@ dependencies = [ [[package]] name = "tiff" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" dependencies = [ "flate2", "jpeg-decoder", @@ -665,9 +639,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "weezl" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "which" @@ -681,6 +655,35 @@ dependencies = [ "rustix", ] +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result", + "windows-targets", +] + +[[package]] +name = "windows-result" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd19df78e5168dfb0aedc343d1d1b8d422ab2db6756d2dc3fef75035402a3f64" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.52.0" diff --git a/nvfbc-sys/Cargo.toml b/nvfbc-sys/Cargo.toml index 74f446d..e49e927 100644 --- a/nvfbc-sys/Cargo.toml +++ b/nvfbc-sys/Cargo.toml @@ -9,7 +9,9 @@ keywords = ["NVFBC"] categories = ["multimedia::video"] repository = "https://github.com/hgaiser/nvfbc-rs" +[dependencies] +windows = { version = "0.54", features = ["Win32_Graphics_Direct3D9"] } + [build-dependencies] # https://github.com/rust-lang/rust-bindgen/issues/753 bindgen = { git = "https://github.com/jbaublitz/rust-bindgen.git", branch = "issue-rust-bindgen-753" } - diff --git a/nvfbc-sys/build.rs b/nvfbc-sys/build.rs index 7095ce8..0daa1d8 100644 --- a/nvfbc-sys/build.rs +++ b/nvfbc-sys/build.rs @@ -58,19 +58,28 @@ fn main() { println!("cargo:rustc-link-search={library_path}"); println!("cargo:rustc-link-lib={library_name}"); - println!("cargo:rerun-if-changed=wrapper.h"); + println!("cargo:rerun-if-changed={header_name}"); + // Allowlist is transient while Blocklist is not + // This results in less re-exported types from d3d9helper.h let bindings = bindgen::Builder::default() .header(header_name) + .allowlist_file(".*nvFBC.h") + .allowlist_file(".*nvFBCCuda.h") + .allowlist_file(".*nvFBCToDx9Vid.h") + .allowlist_file(".*nvFBCToSys.h") + .blocklist_file(".*d3d9helper.h") .clang_args(["-I", include_path]) .clang_args(["-x", "c++"]) - .clang_macro_fallback() - .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) - .generate() - .expect("Unable to generate bindings"); + .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())); + + #[cfg(target_os = "linux")] // Broken for Windows + let bindings = bindings.clang_macro_fallback(); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings + .generate() + .expect("Unable to generate bindings") .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); } diff --git a/nvfbc-sys/src/lib.rs b/nvfbc-sys/src/lib.rs index 428a22c..5cb38a5 100644 --- a/nvfbc-sys/src/lib.rs +++ b/nvfbc-sys/src/lib.rs @@ -2,4 +2,7 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); \ No newline at end of file +// d3d9helper.h +pub use windows::Win32::Graphics::Direct3D9::IDirect3DSurface9; + +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/nvfbc-sys/wrapper.h b/nvfbc-sys/wrapper.h index 5542f1d..808ab72 100644 --- a/nvfbc-sys/wrapper.h +++ b/nvfbc-sys/wrapper.h @@ -1,4 +1,5 @@ +#include #include #include -// #include // error: unknown type name 'IDirect3DSurface9' +#include // error: unknown type name 'IDirect3DSurface9' -> d3d9helper.h #include \ No newline at end of file diff --git a/nvfbc/src/common.rs b/nvfbc/src/common.rs index ffe36b2..fe07851 100644 --- a/nvfbc/src/common.rs +++ b/nvfbc/src/common.rs @@ -1,13 +1,19 @@ use std::{ffi::CStr, mem::MaybeUninit, os::raw::c_uint}; -use nvfbc_sys::{NVFBC_SESSION_HANDLE, _NVFBCSTATUS_NVFBC_SUCCESS as SUCCESS}; +#[cfg(target_os = "linux")] +use nvfbc_sys::{NVFBC_SESSION_HANDLE, _NVFBCSTATUS as Return, _NVFBCSTATUS_NVFBC_SUCCESS as Success}; +#[cfg(target_os = "windows")] +use nvfbc_sys::{_NVFBCRESULT_NVFBC_SUCCESS as Success, _NVFBC_STATE as Return}; use crate::{CaptureType, Error, Status}; +#[cfg(target_os = "linux")] +pub type Handle = NVFBC_SESSION_HANDLE; +#[cfg(target_os = "windows")] pub type Handle = NVFBC_SESSION_HANDLE; -pub(crate) fn check_ret(handle: Handle, ret: nvfbc_sys::_NVFBCSTATUS) -> Result<(), Error> { - if ret != SUCCESS { +pub(crate) fn check_ret(handle: Handle, ret: Return) -> Result<(), Error> { + if ret != Success { return Err(Error::new(ret, get_last_error(handle))); } Ok(()) @@ -22,8 +28,11 @@ pub(crate) fn create_handle() -> Result params.privateDataSize = std::mem::size_of_val(&MAGIC_PRIVATE_DATA) as u32; let mut handle = 0; + #[cfg(target_os = "windows")] + let ret = unsafe { nvfbc_sys::NvFBC_CreateEx(&mut params) }; + #[cfg(target_os = "linux")] let ret = unsafe { nvfbc_sys::NvFBCCreateHandle(&mut handle, &mut params) }; - if ret != SUCCESS { + if ret != Success { return Err(Error::new(ret, None)); } @@ -45,6 +54,9 @@ pub(crate) fn get_last_error(handle: Handle) -> Option { pub(crate) fn status(handle: Handle) -> Result { let mut params: nvfbc_sys::_NVFBC_GET_STATUS_PARAMS = unsafe { MaybeUninit::zeroed().assume_init() }; params.dwVersion = nvfbc_sys::NVFBC_GET_STATUS_PARAMS_VER; + #[cfg(target_os = "windows")] + check_ret(handle, unsafe { nvfbc_sys::NvFBC_GetStatusEx(&mut params) })?; + #[cfg(target_os = "linux")] check_ret(handle, unsafe { nvfbc_sys::NvFBCGetStatus(handle, &mut params) })?; Ok(params.into()) } diff --git a/nvfbc/src/cuda.rs b/nvfbc/src/cuda.rs index 53023eb..cc03f10 100644 --- a/nvfbc/src/cuda.rs +++ b/nvfbc/src/cuda.rs @@ -1,9 +1,16 @@ use std::{ffi::c_void, mem::MaybeUninit, ptr::null_mut}; +#[cfg(target_os = "windows")] use nvfbc_sys::{ - NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS, - NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT, - NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY, + NVFBC_CUDA_FLAGS_NVFBC_TOCUDA_NOFLAGS as Blocking, + NVFBC_CUDA_FLAGS_NVFBC_TOCUDA_NOWAIT as NoWait, + NVFBC_CUDA_FLAGS_NVFBC_TOCUDA_WAIT_WITH_TIMEOUT as NoWaitIfNewFrame, +}; +#[cfg(target_os = "linux")] +use nvfbc_sys::{ + NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS as Blocking, + NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT as NoWait, + NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY as NoWaitIfNewFrame, }; use crate::{ @@ -28,14 +35,14 @@ pub enum CaptureMethod { /// It is therefore possible to capture the same frame multiple times. /// When this occurs, the current_frame parameter of the /// CudaFrameInfo struct is not incremented. - NoWait = NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT as isize, + NoWait = NoWait as isize, /// Similar to NoWait, except that the capture will not wait if there /// is already a frame available that the client has never seen yet. - NoWaitIfNewFrame = NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY as isize, + NoWaitIfNewFrame = NoWaitIfNewFrame as isize, /// Capturing waits for a new frame or mouse move. - Blocking = NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS as isize, + Blocking = Blocking as isize, } /// Contains information about a frame captured in a CUDA device. diff --git a/nvfbc/src/error.rs b/nvfbc/src/error.rs index 846ecf9..72596cf 100644 --- a/nvfbc/src/error.rs +++ b/nvfbc/src/error.rs @@ -1,13 +1,18 @@ use std::fmt; +#[cfg(target_os = "windows")] +use nvfbc_sys::_NVFBCRESULT as Code; +#[cfg(target_os = "linux")] +use nvfbc_sys::_NVFBCSTATUS as Code; + #[derive(Debug)] pub struct Error { - code: u32, + code: Code, message: Option, } impl Error { - pub fn new(code: u32, message: Option) -> Self { + pub fn new(code: Code, message: Option) -> Self { Error { code, message } } } @@ -15,25 +20,54 @@ impl Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[rustfmt::skip] + #[cfg(target_os = "linux")] + let error_code_message = match self.code { + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_API_VERSION => "The API version between the client and the library is not compatible".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INTERNAL => "An internal error occurred".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM => "One or more of the parameter passed to the API call is invalid".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PTR => "One or more of the pointers passed to the API call is invalid".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE => "The handle passed to the API call to identify the client is invalid".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS => "The maximum number of threaded clients (10) of the same process has been reached".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED => "The requested feature is not currently supported by the library".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY => "Unable to allocate enough memory to perform the requested operation".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST => "The API call was not expected".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_X => "An unknown X error has occurred".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GLX => "An unknown GLX error has occurred".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GL => "An unknown OpenGL error has occurred".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CUDA => "An unknown CUDA error has occurred".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_ENCODER => "A hardware encoder error has occurred".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CONTEXT => "An NVFBC context error has occurred".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE => "The capture session must be recreated".to_string(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_VULKAN => "A Vulkan error has occurred".to_string(), + code => format!("Un unknown error code ({}) was returned", code), + }; + + #[rustfmt::skip] + #[cfg(target_os = "windows")] let error_code_message = match self.code { - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_API_VERSION => "The API version between the client and the library is not compatible", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INTERNAL => "An internal error occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM => "One or more of the parameter passed to the API call is invalid", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PTR => "One or more of the pointers passed to the API call is invalid", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE => "The handle passed to the API call to identify the client is invalid", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS => "The maximum number of threaded clients (10) of the same process has been reached", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED => "The requested feature is not currently supported by the library", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY => "Unable to allocate enough memory to perform the requested operation", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST => "The API call was not expected", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_X => "An unknown X error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GLX => "An unknown GLX error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GL => "An unknown OpenGL error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CUDA => "An unknown CUDA error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_ENCODER => "A hardware encoder error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CONTEXT => "An NVFBC context error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE => "The capture session must be recreated", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_VULKAN => "A Vulkan error has occurred", - code => format!("Un unknown error code ({}) was returned", code).as_str(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_GENERIC => "Unexpected failure in NVFBC.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALID_PARAM => "One or more of the paramteres passed to NvFBC are invalid [This include NULL pointers].".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALIDATED_SESSION => "NvFBC session is invalid. Client needs to recreate session.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_PROTECTED_CONTENT => "Protected content detected. Capture failed.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_DRIVER_FAILURE => "GPU driver returned failure to process NvFBC command.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_CUDA_FAILURE => "CUDA driver returned failure to process NvFBC command.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_UNSUPPORTED => "API Unsupported on this version of NvFBC.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_HW_ENC_FAILURE => "HW Encoder returned failure to process NVFBC command.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INCOMPATIBLE_DRIVER => "NVFBC is not compatible with this version of the GPU driver.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_UNSUPPORTED_PLATFORM => "NVFBC is not supported on this platform.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_OUT_OF_MEMORY => "Failed to allocate memory.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALID_PTR => "A NULL pointer was passed.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INCOMPATIBLE_VERSION => "An API was called with a parameter struct that has an incompatible version. Check dwVersion field of paramter struct.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_OPT_CAPTURE_FAILURE => "Desktop Capture failed.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INSUFFICIENT_PRIVILEGES => "User doesn't have appropriate previlages.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALID_CALL => "NVFBC APIs called in wrong sequence.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_SYSTEM_ERROR => "Win32 error.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALID_TARGET => "The target adapter idx can not be used for NVFBC capture. It may not correspond to an NVIDIA GPU, or may not be attached to desktop.".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_NVAPI_FAILURE => "NvAPI Error".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_DYNAMIC_DISABLE => "NvFBC is dynamically disabled. Cannot continue to capture".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_IPC_FAILURE => "NVFBC encountered an error in state management".to_string(), + nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_CURSOR_CAPTURE_FAILURE => "Hardware cursor capture failed".to_string(), + code => format!("Un unknown error code ({}) was returned", code), }; if let Some(message) = &self.message { diff --git a/nvfbc/src/system.rs b/nvfbc/src/system.rs index edd4e45..eb410fb 100644 --- a/nvfbc/src/system.rs +++ b/nvfbc/src/system.rs @@ -1,9 +1,16 @@ use std::{cell::Cell, ffi::c_void, mem::MaybeUninit, ptr::null_mut}; +#[cfg(target_os = "linux")] use nvfbc_sys::{ - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS, - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT, - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS as NoWaitIfNewFrame, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT as NoWait, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY as Blocking, +}; +#[cfg(target_os = "windows")] +use nvfbc_sys::{ + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_NOFLAGS as NoWaitIfNewFrame, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_NOWAIT as NoWait, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_WAIT_WITH_TIMEOUT as Blocking, }; use crate::{ @@ -24,9 +31,9 @@ use crate::{ /// Different methods for capturing a frame. pub enum CaptureMethod { - NoWait = NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT as isize, - NoWaitIfNewFrame = NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS as isize, - Blocking = NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY as isize, + NoWait = NoWait as isize, + NoWaitIfNewFrame = NoWaitIfNewFrame as isize, + Blocking = Blocking as isize, } /// Contains information about a frame captured in a CUDA device. From 4087431f10ba287ab7fafc3a281c86efac82dd63 Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Mon, 11 Mar 2024 13:59:35 -0400 Subject: [PATCH 3/6] rust-bindgen issue 753 fork was updated to fix Windows --- nvfbc-sys/Cargo.toml | 2 +- nvfbc-sys/build.rs | 10 ++++------ nvfbc/src/common.rs | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/nvfbc-sys/Cargo.toml b/nvfbc-sys/Cargo.toml index e49e927..8df1157 100644 --- a/nvfbc-sys/Cargo.toml +++ b/nvfbc-sys/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["NVFBC"] categories = ["multimedia::video"] repository = "https://github.com/hgaiser/nvfbc-rs" -[dependencies] +[target.'cfg(windows)'.dependencies] windows = { version = "0.54", features = ["Win32_Graphics_Direct3D9"] } [build-dependencies] diff --git a/nvfbc-sys/build.rs b/nvfbc-sys/build.rs index 0daa1d8..37228f4 100644 --- a/nvfbc-sys/build.rs +++ b/nvfbc-sys/build.rs @@ -71,15 +71,13 @@ fn main() { .blocklist_file(".*d3d9helper.h") .clang_args(["-I", include_path]) .clang_args(["-x", "c++"]) - .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())); - - #[cfg(target_os = "linux")] // Broken for Windows - let bindings = bindings.clang_macro_fallback(); + .clang_macro_fallback() + .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) + .generate() + .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings - .generate() - .expect("Unable to generate bindings") .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); } diff --git a/nvfbc/src/common.rs b/nvfbc/src/common.rs index fe07851..f960176 100644 --- a/nvfbc/src/common.rs +++ b/nvfbc/src/common.rs @@ -10,7 +10,7 @@ use crate::{CaptureType, Error, Status}; #[cfg(target_os = "linux")] pub type Handle = NVFBC_SESSION_HANDLE; #[cfg(target_os = "windows")] -pub type Handle = NVFBC_SESSION_HANDLE; +pub type Handle = (); // TODO: Windows doesn't have a handle... pub(crate) fn check_ret(handle: Handle, ret: Return) -> Result<(), Error> { if ret != Success { From e9361df927abf07f4d5a457c81b737b39dfbbce2 Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Sat, 23 Mar 2024 18:56:06 -0400 Subject: [PATCH 4/6] Revert "nvfbc: W.I.P Windows Support" --- Cargo.lock | 143 +++++++++++++++++++++---------------------- nvfbc-sys/Cargo.toml | 4 +- nvfbc-sys/build.rs | 9 +-- nvfbc-sys/src/lib.rs | 5 +- nvfbc-sys/wrapper.h | 3 +- nvfbc/src/common.rs | 20 ++---- nvfbc/src/cuda.rs | 19 ++---- nvfbc/src/error.rs | 74 ++++++---------------- nvfbc/src/system.rs | 19 ++---- 9 files changed, 110 insertions(+), 186 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cba67ab..1d674e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,9 +65,9 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bytemuck" -version = "1.14.3" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" @@ -109,37 +109,43 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" dependencies = [ + "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.18" +version = "0.9.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d" dependencies = [ + "autocfg", + "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" +dependencies = [ + "cfg-if", +] [[package]] name = "crunchy" @@ -167,9 +173,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "errno" @@ -183,9 +189,9 @@ dependencies = [ [[package]] name = "exr" -version = "1.72.0" +version = "1.71.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" +checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8" dependencies = [ "bit_field", "flume", @@ -199,9 +205,9 @@ dependencies = [ [[package]] name = "fdeflate" -version = "0.3.4" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" +checksum = "209098dd6dfc4445aa6111f0e98653ac323eaa4dfd212c9ca3931bf9955c31bd" dependencies = [ "simd-adler32", ] @@ -227,9 +233,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.13.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" +checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" dependencies = [ "color_quant", "weezl", @@ -243,11 +249,10 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "half" -version = "2.4.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" dependencies = [ - "cfg-if", "crunchy", ] @@ -262,9 +267,9 @@ dependencies = [ [[package]] name = "image" -version = "0.24.9" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" +checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" dependencies = [ "bytemuck", "byteorder", @@ -272,6 +277,7 @@ dependencies = [ "exr", "gif", "jpeg-decoder", + "num-rational", "num-traits", "png", "qoi", @@ -289,9 +295,9 @@ dependencies = [ [[package]] name = "jpeg-decoder" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" dependencies = [ "rayon", ] @@ -366,9 +372,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", "simd-adler32", @@ -384,11 +390,32 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -409,7 +436,6 @@ name = "nvfbc-sys" version = "0.1.5" dependencies = [ "bindgen", - "windows", ] [[package]] @@ -420,9 +446,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "png" -version = "0.17.13" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -443,9 +469,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -470,9 +496,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.9.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -480,9 +506,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -585,9 +611,9 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] name = "smallvec" -version = "1.13.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "spin" @@ -622,9 +648,9 @@ dependencies = [ [[package]] name = "tiff" -version = "0.9.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" +checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211" dependencies = [ "flate2", "jpeg-decoder", @@ -639,9 +665,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "weezl" -version = "0.1.8" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" [[package]] name = "which" @@ -655,35 +681,6 @@ dependencies = [ "rustix", ] -[[package]] -name = "windows" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" -dependencies = [ - "windows-core", - "windows-targets", -] - -[[package]] -name = "windows-core" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" -dependencies = [ - "windows-result", - "windows-targets", -] - -[[package]] -name = "windows-result" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd19df78e5168dfb0aedc343d1d1b8d422ab2db6756d2dc3fef75035402a3f64" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/nvfbc-sys/Cargo.toml b/nvfbc-sys/Cargo.toml index 8df1157..74f446d 100644 --- a/nvfbc-sys/Cargo.toml +++ b/nvfbc-sys/Cargo.toml @@ -9,9 +9,7 @@ keywords = ["NVFBC"] categories = ["multimedia::video"] repository = "https://github.com/hgaiser/nvfbc-rs" -[target.'cfg(windows)'.dependencies] -windows = { version = "0.54", features = ["Win32_Graphics_Direct3D9"] } - [build-dependencies] # https://github.com/rust-lang/rust-bindgen/issues/753 bindgen = { git = "https://github.com/jbaublitz/rust-bindgen.git", branch = "issue-rust-bindgen-753" } + diff --git a/nvfbc-sys/build.rs b/nvfbc-sys/build.rs index 37228f4..7095ce8 100644 --- a/nvfbc-sys/build.rs +++ b/nvfbc-sys/build.rs @@ -58,17 +58,10 @@ fn main() { println!("cargo:rustc-link-search={library_path}"); println!("cargo:rustc-link-lib={library_name}"); - println!("cargo:rerun-if-changed={header_name}"); + println!("cargo:rerun-if-changed=wrapper.h"); - // Allowlist is transient while Blocklist is not - // This results in less re-exported types from d3d9helper.h let bindings = bindgen::Builder::default() .header(header_name) - .allowlist_file(".*nvFBC.h") - .allowlist_file(".*nvFBCCuda.h") - .allowlist_file(".*nvFBCToDx9Vid.h") - .allowlist_file(".*nvFBCToSys.h") - .blocklist_file(".*d3d9helper.h") .clang_args(["-I", include_path]) .clang_args(["-x", "c++"]) .clang_macro_fallback() diff --git a/nvfbc-sys/src/lib.rs b/nvfbc-sys/src/lib.rs index 5cb38a5..428a22c 100644 --- a/nvfbc-sys/src/lib.rs +++ b/nvfbc-sys/src/lib.rs @@ -2,7 +2,4 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] -// d3d9helper.h -pub use windows::Win32::Graphics::Direct3D9::IDirect3DSurface9; - -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); \ No newline at end of file diff --git a/nvfbc-sys/wrapper.h b/nvfbc-sys/wrapper.h index 808ab72..5542f1d 100644 --- a/nvfbc-sys/wrapper.h +++ b/nvfbc-sys/wrapper.h @@ -1,5 +1,4 @@ -#include #include #include -#include // error: unknown type name 'IDirect3DSurface9' -> d3d9helper.h +// #include // error: unknown type name 'IDirect3DSurface9' #include \ No newline at end of file diff --git a/nvfbc/src/common.rs b/nvfbc/src/common.rs index f960176..ffe36b2 100644 --- a/nvfbc/src/common.rs +++ b/nvfbc/src/common.rs @@ -1,19 +1,13 @@ use std::{ffi::CStr, mem::MaybeUninit, os::raw::c_uint}; -#[cfg(target_os = "linux")] -use nvfbc_sys::{NVFBC_SESSION_HANDLE, _NVFBCSTATUS as Return, _NVFBCSTATUS_NVFBC_SUCCESS as Success}; -#[cfg(target_os = "windows")] -use nvfbc_sys::{_NVFBCRESULT_NVFBC_SUCCESS as Success, _NVFBC_STATE as Return}; +use nvfbc_sys::{NVFBC_SESSION_HANDLE, _NVFBCSTATUS_NVFBC_SUCCESS as SUCCESS}; use crate::{CaptureType, Error, Status}; -#[cfg(target_os = "linux")] pub type Handle = NVFBC_SESSION_HANDLE; -#[cfg(target_os = "windows")] -pub type Handle = (); // TODO: Windows doesn't have a handle... -pub(crate) fn check_ret(handle: Handle, ret: Return) -> Result<(), Error> { - if ret != Success { +pub(crate) fn check_ret(handle: Handle, ret: nvfbc_sys::_NVFBCSTATUS) -> Result<(), Error> { + if ret != SUCCESS { return Err(Error::new(ret, get_last_error(handle))); } Ok(()) @@ -28,11 +22,8 @@ pub(crate) fn create_handle() -> Result params.privateDataSize = std::mem::size_of_val(&MAGIC_PRIVATE_DATA) as u32; let mut handle = 0; - #[cfg(target_os = "windows")] - let ret = unsafe { nvfbc_sys::NvFBC_CreateEx(&mut params) }; - #[cfg(target_os = "linux")] let ret = unsafe { nvfbc_sys::NvFBCCreateHandle(&mut handle, &mut params) }; - if ret != Success { + if ret != SUCCESS { return Err(Error::new(ret, None)); } @@ -54,9 +45,6 @@ pub(crate) fn get_last_error(handle: Handle) -> Option { pub(crate) fn status(handle: Handle) -> Result { let mut params: nvfbc_sys::_NVFBC_GET_STATUS_PARAMS = unsafe { MaybeUninit::zeroed().assume_init() }; params.dwVersion = nvfbc_sys::NVFBC_GET_STATUS_PARAMS_VER; - #[cfg(target_os = "windows")] - check_ret(handle, unsafe { nvfbc_sys::NvFBC_GetStatusEx(&mut params) })?; - #[cfg(target_os = "linux")] check_ret(handle, unsafe { nvfbc_sys::NvFBCGetStatus(handle, &mut params) })?; Ok(params.into()) } diff --git a/nvfbc/src/cuda.rs b/nvfbc/src/cuda.rs index cc03f10..53023eb 100644 --- a/nvfbc/src/cuda.rs +++ b/nvfbc/src/cuda.rs @@ -1,16 +1,9 @@ use std::{ffi::c_void, mem::MaybeUninit, ptr::null_mut}; -#[cfg(target_os = "windows")] use nvfbc_sys::{ - NVFBC_CUDA_FLAGS_NVFBC_TOCUDA_NOFLAGS as Blocking, - NVFBC_CUDA_FLAGS_NVFBC_TOCUDA_NOWAIT as NoWait, - NVFBC_CUDA_FLAGS_NVFBC_TOCUDA_WAIT_WITH_TIMEOUT as NoWaitIfNewFrame, -}; -#[cfg(target_os = "linux")] -use nvfbc_sys::{ - NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS as Blocking, - NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT as NoWait, - NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY as NoWaitIfNewFrame, + NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS, + NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT, + NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY, }; use crate::{ @@ -35,14 +28,14 @@ pub enum CaptureMethod { /// It is therefore possible to capture the same frame multiple times. /// When this occurs, the current_frame parameter of the /// CudaFrameInfo struct is not incremented. - NoWait = NoWait as isize, + NoWait = NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT as isize, /// Similar to NoWait, except that the capture will not wait if there /// is already a frame available that the client has never seen yet. - NoWaitIfNewFrame = NoWaitIfNewFrame as isize, + NoWaitIfNewFrame = NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY as isize, /// Capturing waits for a new frame or mouse move. - Blocking = Blocking as isize, + Blocking = NVFBC_TOCUDA_FLAGS_NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS as isize, } /// Contains information about a frame captured in a CUDA device. diff --git a/nvfbc/src/error.rs b/nvfbc/src/error.rs index 72596cf..846ecf9 100644 --- a/nvfbc/src/error.rs +++ b/nvfbc/src/error.rs @@ -1,18 +1,13 @@ use std::fmt; -#[cfg(target_os = "windows")] -use nvfbc_sys::_NVFBCRESULT as Code; -#[cfg(target_os = "linux")] -use nvfbc_sys::_NVFBCSTATUS as Code; - #[derive(Debug)] pub struct Error { - code: Code, + code: u32, message: Option, } impl Error { - pub fn new(code: Code, message: Option) -> Self { + pub fn new(code: u32, message: Option) -> Self { Error { code, message } } } @@ -20,54 +15,25 @@ impl Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[rustfmt::skip] - #[cfg(target_os = "linux")] - let error_code_message = match self.code { - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_API_VERSION => "The API version between the client and the library is not compatible".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INTERNAL => "An internal error occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM => "One or more of the parameter passed to the API call is invalid".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PTR => "One or more of the pointers passed to the API call is invalid".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE => "The handle passed to the API call to identify the client is invalid".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS => "The maximum number of threaded clients (10) of the same process has been reached".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED => "The requested feature is not currently supported by the library".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY => "Unable to allocate enough memory to perform the requested operation".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST => "The API call was not expected".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_X => "An unknown X error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GLX => "An unknown GLX error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GL => "An unknown OpenGL error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CUDA => "An unknown CUDA error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_ENCODER => "A hardware encoder error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CONTEXT => "An NVFBC context error has occurred".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE => "The capture session must be recreated".to_string(), - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_VULKAN => "A Vulkan error has occurred".to_string(), - code => format!("Un unknown error code ({}) was returned", code), - }; - - #[rustfmt::skip] - #[cfg(target_os = "windows")] let error_code_message = match self.code { - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_GENERIC => "Unexpected failure in NVFBC.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALID_PARAM => "One or more of the paramteres passed to NvFBC are invalid [This include NULL pointers].".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALIDATED_SESSION => "NvFBC session is invalid. Client needs to recreate session.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_PROTECTED_CONTENT => "Protected content detected. Capture failed.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_DRIVER_FAILURE => "GPU driver returned failure to process NvFBC command.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_CUDA_FAILURE => "CUDA driver returned failure to process NvFBC command.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_UNSUPPORTED => "API Unsupported on this version of NvFBC.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_HW_ENC_FAILURE => "HW Encoder returned failure to process NVFBC command.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INCOMPATIBLE_DRIVER => "NVFBC is not compatible with this version of the GPU driver.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_UNSUPPORTED_PLATFORM => "NVFBC is not supported on this platform.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_OUT_OF_MEMORY => "Failed to allocate memory.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALID_PTR => "A NULL pointer was passed.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INCOMPATIBLE_VERSION => "An API was called with a parameter struct that has an incompatible version. Check dwVersion field of paramter struct.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_OPT_CAPTURE_FAILURE => "Desktop Capture failed.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INSUFFICIENT_PRIVILEGES => "User doesn't have appropriate previlages.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALID_CALL => "NVFBC APIs called in wrong sequence.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_SYSTEM_ERROR => "Win32 error.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_INVALID_TARGET => "The target adapter idx can not be used for NVFBC capture. It may not correspond to an NVIDIA GPU, or may not be attached to desktop.".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_NVAPI_FAILURE => "NvAPI Error".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_DYNAMIC_DISABLE => "NvFBC is dynamically disabled. Cannot continue to capture".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_IPC_FAILURE => "NVFBC encountered an error in state management".to_string(), - nvfbc_sys::_NVFBCRESULT_NVFBC_ERROR_CURSOR_CAPTURE_FAILURE => "Hardware cursor capture failed".to_string(), - code => format!("Un unknown error code ({}) was returned", code), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_API_VERSION => "The API version between the client and the library is not compatible", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INTERNAL => "An internal error occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM => "One or more of the parameter passed to the API call is invalid", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PTR => "One or more of the pointers passed to the API call is invalid", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE => "The handle passed to the API call to identify the client is invalid", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS => "The maximum number of threaded clients (10) of the same process has been reached", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED => "The requested feature is not currently supported by the library", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY => "Unable to allocate enough memory to perform the requested operation", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST => "The API call was not expected", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_X => "An unknown X error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GLX => "An unknown GLX error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GL => "An unknown OpenGL error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CUDA => "An unknown CUDA error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_ENCODER => "A hardware encoder error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CONTEXT => "An NVFBC context error has occurred", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE => "The capture session must be recreated", + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_VULKAN => "A Vulkan error has occurred", + code => format!("Un unknown error code ({}) was returned", code).as_str(), }; if let Some(message) = &self.message { diff --git a/nvfbc/src/system.rs b/nvfbc/src/system.rs index eb410fb..edd4e45 100644 --- a/nvfbc/src/system.rs +++ b/nvfbc/src/system.rs @@ -1,16 +1,9 @@ use std::{cell::Cell, ffi::c_void, mem::MaybeUninit, ptr::null_mut}; -#[cfg(target_os = "linux")] use nvfbc_sys::{ - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS as NoWaitIfNewFrame, - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT as NoWait, - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY as Blocking, -}; -#[cfg(target_os = "windows")] -use nvfbc_sys::{ - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_NOFLAGS as NoWaitIfNewFrame, - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_NOWAIT as NoWait, - NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_WAIT_WITH_TIMEOUT as Blocking, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT, + NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY, }; use crate::{ @@ -31,9 +24,9 @@ use crate::{ /// Different methods for capturing a frame. pub enum CaptureMethod { - NoWait = NoWait as isize, - NoWaitIfNewFrame = NoWaitIfNewFrame as isize, - Blocking = Blocking as isize, + NoWait = NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT as isize, + NoWaitIfNewFrame = NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS as isize, + Blocking = NVFBC_TOSYS_GRAB_FLAGS_NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY as isize, } /// Contains information about a frame captured in a CUDA device. From 816ef3a3240e716be801149b6c49bf49ccd02d1d Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Sat, 23 Mar 2024 19:03:33 -0400 Subject: [PATCH 5/6] nvfbc-sys: Finalize Windows Support --- Cargo.lock | 30 ++++++++++++++++++++++++++++++ nvfbc-sys/Cargo.toml | 2 ++ nvfbc-sys/build.rs | 7 ++++++- nvfbc-sys/src/lib.rs | 3 +++ nvfbc-sys/wrapper.h | 3 ++- 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d674e4..279831e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -436,6 +436,7 @@ name = "nvfbc-sys" version = "0.1.5" dependencies = [ "bindgen", + "windows", ] [[package]] @@ -681,6 +682,35 @@ dependencies = [ "rustix", ] +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result", + "windows-targets", +] + +[[package]] +name = "windows-result" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd19df78e5168dfb0aedc343d1d1b8d422ab2db6756d2dc3fef75035402a3f64" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.52.0" diff --git a/nvfbc-sys/Cargo.toml b/nvfbc-sys/Cargo.toml index 74f446d..db627cd 100644 --- a/nvfbc-sys/Cargo.toml +++ b/nvfbc-sys/Cargo.toml @@ -13,3 +13,5 @@ repository = "https://github.com/hgaiser/nvfbc-rs" # https://github.com/rust-lang/rust-bindgen/issues/753 bindgen = { git = "https://github.com/jbaublitz/rust-bindgen.git", branch = "issue-rust-bindgen-753" } +[target.'cfg(windows)'.dependencies] +windows = { version = "0.54", features = ["Win32_Graphics_Direct3D9"] } diff --git a/nvfbc-sys/build.rs b/nvfbc-sys/build.rs index 7095ce8..9526063 100644 --- a/nvfbc-sys/build.rs +++ b/nvfbc-sys/build.rs @@ -58,10 +58,15 @@ fn main() { println!("cargo:rustc-link-search={library_path}"); println!("cargo:rustc-link-lib={library_name}"); - println!("cargo:rerun-if-changed=wrapper.h"); + println!("cargo:rerun-if-changed={header_name}"); let bindings = bindgen::Builder::default() .header(header_name) + .allowlist_file(".*nvFBC.h") + .allowlist_file(".*nvFBCCuda.h") + .allowlist_file(".*nvFBCToDx9Vid.h") + .allowlist_file(".*nvFBCToSys.h") + .blocklist_file(".*d3d9helper.h") .clang_args(["-I", include_path]) .clang_args(["-x", "c++"]) .clang_macro_fallback() diff --git a/nvfbc-sys/src/lib.rs b/nvfbc-sys/src/lib.rs index 428a22c..875954d 100644 --- a/nvfbc-sys/src/lib.rs +++ b/nvfbc-sys/src/lib.rs @@ -2,4 +2,7 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] +#[cfg(target_os = "windows")] // d3d9helper.h +pub use windows::Win32::Graphics::Direct3D9::IDirect3DSurface9; + include!(concat!(env!("OUT_DIR"), "/bindings.rs")); \ No newline at end of file diff --git a/nvfbc-sys/wrapper.h b/nvfbc-sys/wrapper.h index 5542f1d..cb9ab68 100644 --- a/nvfbc-sys/wrapper.h +++ b/nvfbc-sys/wrapper.h @@ -1,4 +1,5 @@ +#include #include #include -// #include // error: unknown type name 'IDirect3DSurface9' +// #include // error: unknown type name 'IDirect3DSurface9' -> d3d9helper.h #include \ No newline at end of file From 68831b220c02c90a12cd3faf02efbbd1b495d4ce Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Thu, 28 Mar 2024 01:52:41 -0400 Subject: [PATCH 6/6] nvfbc: Fix temporary value freed while still in use --- nvfbc/src/error.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/nvfbc/src/error.rs b/nvfbc/src/error.rs index 846ecf9..69b2440 100644 --- a/nvfbc/src/error.rs +++ b/nvfbc/src/error.rs @@ -16,24 +16,24 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { #[rustfmt::skip] let error_code_message = match self.code { - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_API_VERSION => "The API version between the client and the library is not compatible", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INTERNAL => "An internal error occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM => "One or more of the parameter passed to the API call is invalid", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PTR => "One or more of the pointers passed to the API call is invalid", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE => "The handle passed to the API call to identify the client is invalid", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS => "The maximum number of threaded clients (10) of the same process has been reached", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED => "The requested feature is not currently supported by the library", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY => "Unable to allocate enough memory to perform the requested operation", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST => "The API call was not expected", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_X => "An unknown X error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GLX => "An unknown GLX error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GL => "An unknown OpenGL error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CUDA => "An unknown CUDA error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_ENCODER => "A hardware encoder error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CONTEXT => "An NVFBC context error has occurred", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE => "The capture session must be recreated", - nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_VULKAN => "A Vulkan error has occurred", - code => format!("Un unknown error code ({}) was returned", code).as_str(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_API_VERSION => "The API version between the client and the library is not compatible".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INTERNAL => "An internal error occurred".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PARAM => "One or more of the parameter passed to the API call is invalid".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_PTR => "One or more of the pointers passed to the API call is invalid".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_INVALID_HANDLE => "The handle passed to the API call to identify the client is invalid".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MAX_CLIENTS => "The maximum number of threaded clients (10) of the same process has been reached".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_UNSUPPORTED => "The requested feature is not currently supported by the library".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_OUT_OF_MEMORY => "Unable to allocate enough memory to perform the requested operation".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_BAD_REQUEST => "The API call was not expected".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_X => "An unknown X error has occurred".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GLX => "An unknown GLX error has occurred".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_GL => "An unknown OpenGL error has occurred".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CUDA => "An unknown CUDA error has occurred".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_ENCODER => "A hardware encoder error has occurred".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_CONTEXT => "An NVFBC context error has occurred".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_MUST_RECREATE => "The capture session must be recreated".to_owned(), + nvfbc_sys::_NVFBCSTATUS_NVFBC_ERR_VULKAN => "A Vulkan error has occurred".to_owned(), + code => format!("Un unknown error code ({}) was returned", code), }; if let Some(message) = &self.message {