mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-15 15:36:44 +08:00
feat(rustdesk): 完整实现RustDesk协议和P2P连接
重大变更: - 从prost切换到protobuf 3.4实现完整的RustDesk协议栈 - 新增P2P打洞模块(punch.rs)支持直连和中继回退 - 重构加密系统:临时Curve25519密钥对+Ed25519签名 - 完善HID适配器:支持CapsLock状态同步和修饰键映射 - 添加音频流支持:Opus编码+音频帧适配器 - 优化视频流:改进帧适配器和编码器协商 - 移除pacer.rs简化视频管道 扩展系统: - 在设置向导中添加扩展步骤(ttyd/rustdesk切换) - 扩展可用性检测和自动启动 - 新增WebConfig handler用于Web服务器配置 前端改进: - SetupView增加第4步扩展配置 - 音频设备列表和配置界面 - 新增多语言支持(en-US/zh-CN) - TypeScript类型生成更新 文档: - 更新系统架构文档 - 完善config/hid/rustdesk/video/webrtc模块文档
This commit is contained in:
@@ -26,6 +26,8 @@ pub struct AudioDeviceInfo {
|
||||
pub is_capture: bool,
|
||||
/// Is this an HDMI audio device (likely from capture card)
|
||||
pub is_hdmi: bool,
|
||||
/// USB bus info for matching with video devices (e.g., "1-1" from USB path)
|
||||
pub usb_bus: Option<String>,
|
||||
}
|
||||
|
||||
impl AudioDeviceInfo {
|
||||
@@ -35,6 +37,33 @@ impl AudioDeviceInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get USB bus info for an audio card by reading sysfs
|
||||
/// Returns the USB port path like "1-1" or "1-2.3"
|
||||
fn get_usb_bus_info(card_index: i32) -> Option<String> {
|
||||
if card_index < 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Read the device symlink: /sys/class/sound/cardX/device -> ../../usb1/1-1/1-1:1.0
|
||||
let device_path = format!("/sys/class/sound/card{}/device", card_index);
|
||||
let link_target = std::fs::read_link(&device_path).ok()?;
|
||||
let link_str = link_target.to_string_lossy();
|
||||
|
||||
// Extract USB port from path like "../../usb1/1-1/1-1:1.0" or "../../1-1/1-1:1.0"
|
||||
// We want the "1-1" part (USB bus-port)
|
||||
for component in link_str.split('/') {
|
||||
// Match patterns like "1-1", "1-2", "1-1.2", "2-1.3.1"
|
||||
if component.contains('-') && !component.contains(':') {
|
||||
// Verify it looks like a USB port (starts with digit)
|
||||
if component.chars().next().map(|c| c.is_ascii_digit()).unwrap_or(false) {
|
||||
return Some(component.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
/// Enumerate available audio capture devices
|
||||
pub fn enumerate_audio_devices() -> Result<Vec<AudioDeviceInfo>> {
|
||||
enumerate_audio_devices_with_current(None)
|
||||
@@ -75,6 +104,9 @@ pub fn enumerate_audio_devices_with_current(
|
||||
|| card_longname.to_lowercase().contains("capture")
|
||||
|| card_longname.to_lowercase().contains("usb");
|
||||
|
||||
// Get USB bus info for this card
|
||||
let usb_bus = get_usb_bus_info(card_index);
|
||||
|
||||
// Try to open each device on this card for capture
|
||||
for device_index in 0..8 {
|
||||
let device_name = format!("hw:{},{}", card_index, device_index);
|
||||
@@ -98,6 +130,7 @@ pub fn enumerate_audio_devices_with_current(
|
||||
channels,
|
||||
is_capture: true,
|
||||
is_hdmi,
|
||||
usb_bus: usb_bus.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -122,6 +155,7 @@ pub fn enumerate_audio_devices_with_current(
|
||||
channels: vec![2],
|
||||
is_capture: true,
|
||||
is_hdmi,
|
||||
usb_bus: usb_bus.clone(),
|
||||
});
|
||||
}
|
||||
continue;
|
||||
@@ -145,6 +179,7 @@ pub fn enumerate_audio_devices_with_current(
|
||||
channels,
|
||||
is_capture: true,
|
||||
is_hdmi: false,
|
||||
usb_bus: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user