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

@@ -1,6 +1,6 @@
use crate::video::encoder::BitratePreset;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use crate::video::encoder::BitratePreset;
// Re-export ExtensionsConfig from extensions module
pub use crate::extensions::ExtensionsConfig;
@@ -147,8 +147,8 @@ pub struct OtgDescriptorConfig {
impl Default for OtgDescriptorConfig {
fn default() -> Self {
Self {
vendor_id: 0x1d6b, // Linux Foundation
product_id: 0x0104, // Multifunction Composite Gadget
vendor_id: 0x1d6b, // Linux Foundation
product_id: 0x0104, // Multifunction Composite Gadget
manufacturer: "One-KVM".to_string(),
product: "One-KVM USB Device".to_string(),
serial_number: None,
@@ -425,8 +425,15 @@ impl StreamConfig {
/// Check if using public ICE servers (user left fields empty)
pub fn is_using_public_ice_servers(&self) -> bool {
use crate::webrtc::config::public_ice;
self.stun_server.as_ref().map(|s| s.is_empty()).unwrap_or(true)
&& self.turn_server.as_ref().map(|s| s.is_empty()).unwrap_or(true)
self.stun_server
.as_ref()
.map(|s| s.is_empty())
.unwrap_or(true)
&& self
.turn_server
.as_ref()
.map(|s| s.is_empty())
.unwrap_or(true)
&& public_ice::is_configured()
}
}

View File

@@ -126,11 +126,10 @@ impl ConfigStore {
/// Load configuration from database
async fn load_config(pool: &Pool<Sqlite>) -> Result<AppConfig> {
let row: Option<(String,)> = sqlx::query_as(
"SELECT value FROM config WHERE key = 'app_config'"
)
.fetch_optional(pool)
.await?;
let row: Option<(String,)> =
sqlx::query_as("SELECT value FROM config WHERE key = 'app_config'")
.fetch_optional(pool)
.await?;
match row {
Some((json,)) => {
@@ -245,10 +244,13 @@ mod tests {
assert!(!config.initialized);
// Update config
store.update(|c| {
c.initialized = true;
c.web.http_port = 9000;
}).await.unwrap();
store
.update(|c| {
c.initialized = true;
c.web.http_port = 9000;
})
.await
.unwrap();
// Verify update
let config = store.get();