mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-15 15:36:44 +08:00
- 后端:切换事务+transition_id,/stream/mode 返回 switching/transition_id 与实际 codec - 事件:新增 mode_switching/mode_ready,config/webrtc_ready/mode_changed 关联事务 - 编码/格式:扩展 NV21/NV16/NV24/RGB/BGR 输入与转换链路,RKMPP direct input 优化 - 前端:useVideoSession 统一切换,失败回退真实切回 MJPEG,菜单格式同步修复 - 清理:useVideoStream 降级为 MJPEG-only
93 lines
2.3 KiB
Rust
93 lines
2.3 KiB
Rust
#![allow(non_upper_case_globals)]
|
|
#![allow(non_camel_case_types)]
|
|
#![allow(non_snake_case)]
|
|
|
|
use serde_derive::{Deserialize, Serialize};
|
|
include!(concat!(env!("OUT_DIR"), "/common_ffi.rs"));
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
|
pub enum Driver {
|
|
NV,
|
|
AMF,
|
|
MFX,
|
|
FFMPEG,
|
|
}
|
|
|
|
#[cfg(any(windows, target_os = "linux"))]
|
|
pub(crate) fn supported_gpu(_encode: bool) -> (bool, bool, bool) {
|
|
#[cfg(target_os = "linux")]
|
|
use std::ffi::c_int;
|
|
#[cfg(target_os = "linux")]
|
|
extern "C" {
|
|
pub(crate) fn linux_support_nv() -> c_int;
|
|
pub(crate) fn linux_support_amd() -> c_int;
|
|
pub(crate) fn linux_support_intel() -> c_int;
|
|
}
|
|
|
|
#[allow(unused_unsafe)]
|
|
unsafe {
|
|
#[cfg(windows)]
|
|
{
|
|
// Without VRAM feature, assume all GPU types might be available
|
|
// FFmpeg will handle the actual detection
|
|
return (true, true, true);
|
|
}
|
|
|
|
#[cfg(target_os = "linux")]
|
|
return (
|
|
linux_support_nv() == 0,
|
|
linux_support_amd() == 0,
|
|
linux_support_intel() == 0,
|
|
);
|
|
#[allow(unreachable_code)]
|
|
(false, false, false)
|
|
}
|
|
}
|
|
|
|
pub fn get_gpu_signature() -> u64 {
|
|
#[cfg(windows)]
|
|
{
|
|
extern "C" {
|
|
pub fn GetHwcodecGpuSignature() -> u64;
|
|
}
|
|
unsafe { GetHwcodecGpuSignature() }
|
|
}
|
|
#[cfg(not(windows))]
|
|
{
|
|
0
|
|
}
|
|
}
|
|
|
|
#[cfg(target_os = "linux")]
|
|
pub fn setup_parent_death_signal() {
|
|
use std::sync::Once;
|
|
|
|
static INIT: Once = Once::new();
|
|
|
|
INIT.call_once(|| {
|
|
use std::ffi::c_int;
|
|
extern "C" {
|
|
fn setup_parent_death_signal() -> c_int;
|
|
}
|
|
unsafe {
|
|
let result = setup_parent_death_signal();
|
|
if result == 0 {
|
|
log::debug!("Successfully set up parent death signal");
|
|
} else {
|
|
log::warn!("Failed to set up parent death signal: {}", result);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
#[cfg(windows)]
|
|
pub fn child_exit_when_parent_exit(child_process_id: u32) -> bool {
|
|
unsafe {
|
|
extern "C" {
|
|
fn add_process_to_new_job(child_process_id: u32) -> i32;
|
|
}
|
|
let result = add_process_to_new_job(child_process_id);
|
|
result == 0
|
|
}
|
|
}
|