diff --git a/.gitignore b/.gitignore index b04ecba..dcf85ff 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,4 @@ # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock target Cargo.lock -src/ffi/cuda.rs -src/ffi/cuvid.rs -src/ffi/nvenc.rs + diff --git a/Cargo.toml b/Cargo.toml index d473717..8ced1f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,10 +2,15 @@ name = "nvidia-video-codec" version = "0.1.0" authors = ["Luca Barbato "] - -build = "build.rs" - -[build-dependencies.libbindgen] -git = "https://github.com/servo/rust-bindgen" +license = "MIT" +description = "NVIDIA Video Codec bindings" +repository = "https://github.com/rust-av/nvidia-video-codec-rs" +readme = "../README.md" +keywords = ["NVIDIA", "cuvid", "nvenc"] [dependencies] +nvidia-video-codec-sys = { version = "0.1.0", path = "nvidia-video-codec-sys" } + +[workspace] +members = ["nvidia-video-codec-sys"] + diff --git a/nvidia-video-codec-sys/.gitignore b/nvidia-video-codec-sys/.gitignore new file mode 100644 index 0000000..02d8cb5 --- /dev/null +++ b/nvidia-video-codec-sys/.gitignore @@ -0,0 +1,3 @@ +src/cuda.rs +src/cuvid.rs +src/nvenc.rs diff --git a/nvidia-video-codec-sys/Cargo.toml b/nvidia-video-codec-sys/Cargo.toml new file mode 100644 index 0000000..5f7d255 --- /dev/null +++ b/nvidia-video-codec-sys/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "nvidia-video-codec-sys" +version = "0.1.0" +authors = ["Luca Barbato "] +license = "MIT" +description = "FFI bindings to NVIDIA Video Codec" +repository = "https://github.com/rust-av/nvidia-video-codec-rs" + +build = "build.rs" + +[build-dependencies.libbindgen] +git = "https://github.com/servo/rust-bindgen" + +[dependencies] diff --git a/nvidia-video-codec-sys/LICENSE b/nvidia-video-codec-sys/LICENSE new file mode 100644 index 0000000..1da4a47 --- /dev/null +++ b/nvidia-video-codec-sys/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Luca Barbato + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build.rs b/nvidia-video-codec-sys/build.rs similarity index 92% rename from build.rs rename to nvidia-video-codec-sys/build.rs index 159e5c5..dbe33d8 100644 --- a/build.rs +++ b/nvidia-video-codec-sys/build.rs @@ -53,18 +53,18 @@ fn main() { .header(cuda_include.join("cuda.h").to_string_lossy()); // Manually fix the comment so rustdoc won't try to pick them - format_write(cuda_builder, "src/ffi/cuda.rs"); + format_write(cuda_builder, "src/cuda.rs"); let cuvid_builder = common_builder() .clang_arg(format!("-I{}", nvc_include.to_string_lossy())) .clang_arg(format!("-I{}", cuda_include.to_string_lossy())) .header(nvc_include.join("nvcuvid.h").to_string_lossy()); - format_write(cuvid_builder, "src/ffi/cuvid.rs"); + format_write(cuvid_builder, "src/cuvid.rs"); let nvenc_builder = common_builder() .clang_arg(format!("-I{}", nvc_include.to_string_lossy())) .header(nvc_include.join("nvEncodeAPI.h").to_string_lossy()); - format_write(nvenc_builder, "src/ffi/nvenc.rs"); + format_write(nvenc_builder, "src/nvenc.rs"); } diff --git a/nvidia-video-codec-sys/src/lib.rs b/nvidia-video-codec-sys/src/lib.rs new file mode 100644 index 0000000..2cad8fc --- /dev/null +++ b/nvidia-video-codec-sys/src/lib.rs @@ -0,0 +1,24 @@ +// TODO do w/out the unions? +#![feature(untagged_unions)] + +pub mod cuda; +pub mod cuvid; +pub mod nvenc; + +#[cfg(test)] +mod tests { + use super::cuda::*; + #[test] + fn init_and_version() { + let ret = unsafe { cuInit(0) }; + println!("{:?}", ret); + + let ver = unsafe { + let mut ver = 0; + cuDriverGetVersion(&mut ver as *mut i32); + ver + }; + + println!("Version {}", ver); + } +} diff --git a/src/cuda/device.rs b/src/cuda/device.rs index 41b8b3e..fa683b3 100644 --- a/src/cuda/device.rs +++ b/src/cuda/device.rs @@ -4,7 +4,7 @@ use std::os::raw::c_char; use ffi::cuda::*; use ffi::cuda::cudaError_enum::*; -struct CuDevice { +pub struct CuDevice { device: CUdevice, } diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs deleted file mode 100644 index 62bf03c..0000000 --- a/src/ffi/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod cuda; -pub mod cuvid; -pub mod nvenc; diff --git a/src/lib.rs b/src/lib.rs index 7856669..ed8124b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,24 +1,3 @@ -// TODO do w/out the unions? -#![feature(untagged_unions)] - -mod ffi; +extern crate nvidia_video_codec_sys as ffi; pub mod cuda; - -#[cfg(test)] -mod tests { - use super::ffi::cuda::*; - #[test] - fn init_and_version() { - let ret = unsafe { cuInit(0) }; - println!("{:?}", ret); - - let ver = unsafe { - let mut ver = 0; - cuDriverGetVersion(&mut ver as *mut i32); - ver - }; - - println!("Version {}", ver); - } -}