mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-12 10:34:24 +08:00
- 统一使用 QUERY_DV_TIMINGS 判断 HDMI RX 输入状态 - 增加 source-following 设备状态 API 与前端只读展示 - 支持长时间无信号后的 MJPEG/WebRTC 自动恢复 - 修复模式切换时采集设备尚未释放导致的 EBUSY - 取消陈旧 WebRTC 重连并统一采集恢复策略 - 移除视频输入状态区域的冗余标题
65 lines
1.8 KiB
Rust
65 lines
1.8 KiB
Rust
use axum::{extract::State, Json};
|
|
use std::sync::Arc;
|
|
|
|
use crate::config::VideoConfig;
|
|
use crate::error::Result;
|
|
use crate::state::AppState;
|
|
|
|
use super::apply::{apply_video_config, try_apply_lock, ConfigApplyOptions};
|
|
use super::types::VideoConfigUpdate;
|
|
|
|
pub async fn get_video_config(State(state): State<Arc<AppState>>) -> Json<VideoConfig> {
|
|
Json(state.config.get().video.clone())
|
|
}
|
|
|
|
pub async fn update_video_config(
|
|
State(state): State<Arc<AppState>>,
|
|
Json(mut req): Json<VideoConfigUpdate>,
|
|
) -> Result<Json<VideoConfig>> {
|
|
let selected_path = req
|
|
.device
|
|
.clone()
|
|
.or_else(|| state.config.get().video.device.clone());
|
|
if let Some(path) = selected_path {
|
|
let source_following = state
|
|
.stream_manager
|
|
.list_devices()
|
|
.await
|
|
.ok()
|
|
.and_then(|devices| {
|
|
devices
|
|
.into_iter()
|
|
.find(|device| device.path.to_string_lossy() == path)
|
|
})
|
|
.is_some_and(|device| {
|
|
device.control_mode == crate::video::device::VideoControlMode::SourceFollowing
|
|
});
|
|
if source_following {
|
|
req.ignore_source_following_parameters();
|
|
}
|
|
}
|
|
req.validate()?;
|
|
|
|
let _apply_guard = try_apply_lock(&state.config_apply_locks.video, "video")?;
|
|
let old_video_config = state.config.get().video.clone();
|
|
|
|
state
|
|
.config
|
|
.update(|config| {
|
|
req.apply_to(&mut config.video);
|
|
})
|
|
.await?;
|
|
|
|
let new_video_config = state.config.get().video.clone();
|
|
|
|
apply_video_config(
|
|
&state,
|
|
&old_video_config,
|
|
&new_video_config,
|
|
ConfigApplyOptions::forced(),
|
|
)
|
|
.await?;
|
|
|
|
Ok(Json(new_video_config))
|
|
}
|