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:
mofeng-git
2026-01-11 10:41:57 +08:00
parent 9feb74b72c
commit 206594e292
110 changed files with 3955 additions and 2251 deletions

View File

@@ -144,7 +144,8 @@ impl HidHealthMonitor {
// Check if we're in cooldown period after recent recovery
let current_ms = self.start_instant.elapsed().as_millis() as u64;
let last_recovery = self.last_recovery_ms.load(Ordering::Relaxed);
let in_cooldown = last_recovery > 0 && current_ms < last_recovery + self.config.recovery_cooldown_ms;
let in_cooldown =
last_recovery > 0 && current_ms < last_recovery + self.config.recovery_cooldown_ms;
// Check if error code changed
let error_changed = {
@@ -229,10 +230,7 @@ impl HidHealthMonitor {
// Only log and publish events if there were multiple retries
// (avoid log spam for transient single-retry recoveries)
if retry_count > 1 {
debug!(
"HID {} recovered after {} retries",
backend, retry_count
);
debug!("HID {} recovered after {} retries", backend, retry_count);
// Publish recovery event
if let Some(ref events) = *self.events.read().await {
@@ -372,9 +370,7 @@ mod tests {
let monitor = HidHealthMonitor::with_defaults();
for i in 1..=5 {
monitor
.report_error("otg", None, "Error", "io_error")
.await;
monitor.report_error("otg", None, "Error", "io_error").await;
assert_eq!(monitor.retry_count(), i);
}
}
@@ -387,9 +383,7 @@ mod tests {
});
for _ in 0..100 {
monitor
.report_error("otg", None, "Error", "io_error")
.await;
monitor.report_error("otg", None, "Error", "io_error").await;
assert!(monitor.should_retry());
}
}
@@ -417,9 +411,7 @@ mod tests {
async fn test_reset() {
let monitor = HidHealthMonitor::with_defaults();
monitor
.report_error("otg", None, "Error", "io_error")
.await;
monitor.report_error("otg", None, "Error", "io_error").await;
assert!(monitor.is_error().await);
monitor.reset().await;