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:
mofeng-git
2026-01-04 15:06:08 +08:00
parent 0c82d1a840
commit 9ab3d052f9
24 changed files with 766 additions and 258 deletions

View File

@@ -232,9 +232,15 @@ export interface StreamConfig {
encoder: EncoderType;
/** Bitrate preset (Speed/Balanced/Quality) */
bitrate_preset: BitratePreset;
/** Custom STUN server (e.g., "stun:stun.l.google.com:19302") */
/**
* Custom STUN server (e.g., "stun:stun.l.google.com:19302")
* If empty, uses public ICE servers from secrets.toml
*/
stun_server?: string;
/** Custom TURN server (e.g., "turn:turn.example.com:3478") */
/**
* Custom TURN server (e.g., "turn:turn.example.com:3478")
* If empty, uses public ICE servers from secrets.toml
*/
turn_server?: string;
/** TURN username */
turn_username?: string;
@@ -532,6 +538,10 @@ export interface StreamConfigResponse {
mode: StreamMode;
encoder: EncoderType;
bitrate_preset: BitratePreset;
/** 是否有公共 ICE 服务器可用(编译时确定) */
has_public_ice_servers: boolean;
/** 当前是否正在使用公共 ICE 服务器STUN/TURN 都为空时) */
using_public_ice_servers: boolean;
stun_server?: string;
turn_server?: string;
turn_username?: string;
@@ -543,9 +553,15 @@ export interface StreamConfigUpdate {
mode?: StreamMode;
encoder?: EncoderType;
bitrate_preset?: BitratePreset;
/** STUN server URL (e.g., "stun:stun.l.google.com:19302") */
/**
* STUN server URL (e.g., "stun:stun.l.google.com:19302")
* Leave empty to use public ICE servers
*/
stun_server?: string;
/** TURN server URL (e.g., "turn:turn.example.com:3478") */
/**
* TURN server URL (e.g., "turn:turn.example.com:3478")
* Leave empty to use public ICE servers
*/
turn_server?: string;
/** TURN username */
turn_username?: string;