mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-01 10:31:54 +08:00
feat(webrtc): 添加公共ICE服务器支持和优化HID延迟
- 重构ICE配置:将TURN配置改为统一的ICE配置,支持STUN和多TURN URL - 添加公共ICE服务器:类似RustDesk,用户留空时使用编译时配置的公共服务器 - 优化DataChannel HID消息:使用tokio::spawn立即处理,避免依赖webrtc-rs轮询 - 添加WebRTCReady事件:客户端等待此事件后再建立连接 - 初始化时启动音频流,确保WebRTC可订阅 - 移除多余的trace/debug日志减少开销 - 更新前端配置界面支持公共ICE服务器显示
This commit is contained in:
@@ -383,8 +383,10 @@ pub struct StreamConfig {
|
||||
/// Bitrate preset (Speed/Balanced/Quality)
|
||||
pub bitrate_preset: BitratePreset,
|
||||
/// Custom STUN server (e.g., "stun:stun.l.google.com:19302")
|
||||
/// If empty, uses public ICE servers from secrets.toml
|
||||
pub stun_server: Option<String>,
|
||||
/// Custom TURN server (e.g., "turn:turn.example.com:3478")
|
||||
/// If empty, uses public ICE servers from secrets.toml
|
||||
pub turn_server: Option<String>,
|
||||
/// TURN username
|
||||
pub turn_username: Option<String>,
|
||||
@@ -407,7 +409,8 @@ impl Default for StreamConfig {
|
||||
mode: StreamMode::Mjpeg,
|
||||
encoder: EncoderType::Auto,
|
||||
bitrate_preset: BitratePreset::Balanced,
|
||||
stun_server: Some("stun:stun.l.google.com:19302".to_string()),
|
||||
// Empty means use public ICE servers (like RustDesk)
|
||||
stun_server: None,
|
||||
turn_server: None,
|
||||
turn_username: None,
|
||||
turn_password: None,
|
||||
@@ -418,6 +421,16 @@ impl Default for StreamConfig {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
&& public_ice::is_configured()
|
||||
}
|
||||
}
|
||||
|
||||
/// Web server configuration
|
||||
#[typeshare]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user