mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-10-28 08:20:49 +08:00
perf(video): 新增 RKMPP DMA 采集编码通路并完善恢复逻辑
支持原生 HDMI 和 UVC 缓冲区导出,增加同步 RKMPP 编码及可选 MJPEG 硬件转码。 校验帧布局和缓冲区租约,在 DMA 不可用或编码失败时回退到复制通路。 保留自定义码率和 GOP 策略,重开采集时同步 HDMI 源帧率,并区分 UVC 超时状态。 验证:88 个视频测试通过(含 4 个新增回归测试);ARM64 cargo check --tests 通过。
This commit is contained in:
@@ -2,8 +2,32 @@
|
||||
|
||||
use std::io;
|
||||
|
||||
#[cfg(any(
|
||||
test,
|
||||
all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm"))
|
||||
))]
|
||||
use crate::video::device::VideoControlMode;
|
||||
use crate::video::signal::SignalStatus;
|
||||
|
||||
#[cfg(any(
|
||||
test,
|
||||
all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm"))
|
||||
))]
|
||||
pub(crate) fn capture_recovery_status(
|
||||
control_mode: VideoControlMode,
|
||||
error: &io::Error,
|
||||
) -> SignalStatus {
|
||||
if control_mode == VideoControlMode::Configurable && error.kind() == io::ErrorKind::TimedOut {
|
||||
return SignalStatus::UvcCaptureStall;
|
||||
}
|
||||
match classify_capture_io_error(error) {
|
||||
CaptureIoErrorKind::TransientSignal {
|
||||
status: Some(status),
|
||||
} => status,
|
||||
_ => SignalStatus::NoSignal,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum CaptureIoErrorKind {
|
||||
DeviceLost,
|
||||
@@ -52,6 +76,33 @@ pub fn capture_error_log_key(err: &io::Error) -> String {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn recovery_distinguishes_uvc_stalls_from_hdmi_signal_loss() {
|
||||
let timeout = io::Error::from(io::ErrorKind::TimedOut);
|
||||
assert_eq!(
|
||||
capture_recovery_status(VideoControlMode::Configurable, &timeout),
|
||||
SignalStatus::UvcCaptureStall
|
||||
);
|
||||
assert_eq!(
|
||||
capture_recovery_status(VideoControlMode::SourceFollowing, &timeout),
|
||||
SignalStatus::NoSignal
|
||||
);
|
||||
assert_eq!(
|
||||
capture_recovery_status(
|
||||
VideoControlMode::Configurable,
|
||||
&io::Error::from_raw_os_error(71)
|
||||
),
|
||||
SignalStatus::UvcUsbError
|
||||
);
|
||||
assert_eq!(
|
||||
capture_recovery_status(
|
||||
VideoControlMode::SourceFollowing,
|
||||
&io::Error::from_raw_os_error(5)
|
||||
),
|
||||
SignalStatus::NoSignal
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn maps_known_signal_status_strings() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user