mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
install ffmpeg lib with vcpkg (#8724)
* use vcpkg to install ffmpeg and build sdk from source, so no prebuild lib in hwcodec. * link ffmpeg in rustdesk directly, ffmpeg can be used as basic library. * for windows developers, `VCPKG_DEFAULT_HOST_TRIPLET` env need to be set to `x64-windows-static` during installation. Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -188,6 +188,50 @@ fn gen_vcpkg_package(package: &str, ffi_header: &str, generated: &str, regex: &s
|
||||
generate_bindings(&ffi_header, &includes, &ffi_rs, &exact_file, regex);
|
||||
}
|
||||
|
||||
// If you have problems installing ffmpeg, you can disable hwcodec feature and disable this function.
|
||||
fn ffmpeg() {
|
||||
// ffmpeg
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let static_libs = vec!["avcodec", "avutil", "avformat"];
|
||||
static_libs.iter().for_each(|lib| {
|
||||
find_package(lib);
|
||||
});
|
||||
if target_os == "windows" {
|
||||
println!("cargo:rustc-link-lib=static=libmfx");
|
||||
}
|
||||
|
||||
// os
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
let dyn_libs: Vec<&str> = if target_os == "windows" {
|
||||
["User32", "bcrypt", "ole32", "advapi32"].to_vec()
|
||||
} else if target_os == "linux" {
|
||||
let mut v = ["va", "va-drm", "va-x11", "vdpau", "X11", "stdc++"].to_vec();
|
||||
if target_arch == "x86_64" {
|
||||
v.push("z");
|
||||
}
|
||||
v
|
||||
} else if target_os == "macos" || target_os == "ios" {
|
||||
["c++", "m"].to_vec()
|
||||
} else if target_os == "android" {
|
||||
["z", "m", "android", "atomic"].to_vec()
|
||||
} else {
|
||||
panic!("unsupported os");
|
||||
};
|
||||
dyn_libs
|
||||
.iter()
|
||||
.map(|lib| println!("cargo:rustc-link-lib={}", lib))
|
||||
.count();
|
||||
|
||||
if target_os == "macos" || target_os == "ios" {
|
||||
println!("cargo:rustc-link-lib=framework=CoreFoundation");
|
||||
println!("cargo:rustc-link-lib=framework=CoreVideo");
|
||||
println!("cargo:rustc-link-lib=framework=CoreMedia");
|
||||
println!("cargo:rustc-link-lib=framework=VideoToolbox");
|
||||
println!("cargo:rustc-link-lib=framework=AVFoundation");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// note: all link symbol names in x86 (32-bit) are prefixed wth "_".
|
||||
// run "rustup show" to show current default toolchain, if it is stable-x86-pc-windows-msvc,
|
||||
@@ -204,6 +248,7 @@ fn main() {
|
||||
gen_vcpkg_package("libvpx", "vpx_ffi.h", "vpx_ffi.rs", "^[vV].*");
|
||||
gen_vcpkg_package("aom", "aom_ffi.h", "aom_ffi.rs", "^(aom|AOM|OBU|AV1).*");
|
||||
gen_vcpkg_package("libyuv", "yuv_ffi.h", "yuv_ffi.rs", ".*");
|
||||
ffmpeg();
|
||||
|
||||
// there is problem with cfg(target_os) in build.rs, so use our workaround
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user