mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-15 15:36:44 +08:00
feat(video): 事务化切换与前端统一编排,增强视频输入格式支持
- 后端:切换事务+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
This commit is contained in:
@@ -228,16 +228,17 @@ impl MjpegStreamer {
|
||||
let device = self.current_device.read().await;
|
||||
let config = self.config.read().await;
|
||||
|
||||
let (resolution, format, frames_captured) = if let Some(ref cap) = *self.capturer.read().await {
|
||||
let stats = cap.stats().await;
|
||||
(
|
||||
Some((config.resolution.width, config.resolution.height)),
|
||||
Some(config.format.to_string()),
|
||||
stats.frames_captured,
|
||||
)
|
||||
} else {
|
||||
(None, None, 0)
|
||||
};
|
||||
let (resolution, format, frames_captured) =
|
||||
if let Some(ref cap) = *self.capturer.read().await {
|
||||
let stats = cap.stats().await;
|
||||
(
|
||||
Some((config.resolution.width, config.resolution.height)),
|
||||
Some(config.format.to_string()),
|
||||
stats.frames_captured,
|
||||
)
|
||||
} else {
|
||||
(None, None, 0)
|
||||
};
|
||||
|
||||
MjpegStreamerStats {
|
||||
state: state.to_string(),
|
||||
@@ -286,7 +287,10 @@ impl MjpegStreamer {
|
||||
|
||||
/// Initialize with specific device
|
||||
pub async fn init_with_device(self: &Arc<Self>, device: VideoDeviceInfo) -> Result<()> {
|
||||
info!("MjpegStreamer: Initializing with device: {}", device.path.display());
|
||||
info!(
|
||||
"MjpegStreamer: Initializing with device: {}",
|
||||
device.path.display()
|
||||
);
|
||||
|
||||
let config = self.config.read().await.clone();
|
||||
|
||||
@@ -322,7 +326,9 @@ impl MjpegStreamer {
|
||||
let _lock = self.start_lock.lock().await;
|
||||
|
||||
if self.config_changing.load(Ordering::SeqCst) {
|
||||
return Err(AppError::VideoError("Config change in progress".to_string()));
|
||||
return Err(AppError::VideoError(
|
||||
"Config change in progress".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let state = *self.state.read().await;
|
||||
@@ -332,7 +338,8 @@ impl MjpegStreamer {
|
||||
|
||||
// Get capturer
|
||||
let capturer = self.capturer.read().await.clone();
|
||||
let capturer = capturer.ok_or_else(|| AppError::VideoError("Not initialized".to_string()))?;
|
||||
let capturer =
|
||||
capturer.ok_or_else(|| AppError::VideoError("Not initialized".to_string()))?;
|
||||
|
||||
// Start capture
|
||||
capturer.start().await?;
|
||||
@@ -412,7 +419,9 @@ impl MjpegStreamer {
|
||||
let device = devices
|
||||
.into_iter()
|
||||
.find(|d| d.path == *path)
|
||||
.ok_or_else(|| AppError::VideoError(format!("Device not found: {}", path.display())))?;
|
||||
.ok_or_else(|| {
|
||||
AppError::VideoError(format!("Device not found: {}", path.display()))
|
||||
})?;
|
||||
|
||||
self.init_with_device(device).await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user