feat(discovery): 被控端免填 IP,UDP 信标自动发现
- Rust: 新增 discovery::beacon(UDP 41003),被动接收 offer、用包源地址作设备 IP、单播回 host;FFI 增加 ttstd_discovery_start/devices/connect/stop(ABI 3) - Android: 新增 HostBeacon 广播自身并解析 host 应答;ReceiverSession 在 host 为空时等信标再拨号;主界面移除 IP/信令输入框,改为显示发现状态 - Flutter: discover 优先取同网段信标结果并与信令合并去重;connect 先起监听再通知设备拨号;设备卡片标注「UDP 自动发现」 - 视频诊断: 缺少 SPS/PPS 的提示改为收到关键帧后才告警,避免刚接入就误报 - 文档: DEMO 增加发现流程、防火墙与模拟器 NAT 说明及实测截图
This commit is contained in:
1 parent
df2affa9e2
commit
5442dbff2c
13 files changed
+835
-74
No files matched your search
+49
-1
@@ -459,8 +459,56 @@ pub unsafe extern "C" fn ttstd_video_stats(out_json: *mut u8, capacity: usize) -
|
||||
copy_out(json.as_bytes(), out_json, capacity)
|
||||
}
|
||||
|
||||
/// 启动同网段自动发现(UDP 41003)。幂等:已在运行时直接返回 OK。
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ttstd_discovery_start(
|
||||
control_port: u16,
|
||||
media_port: u16,
|
||||
audio_port: u16,
|
||||
) -> i32 {
|
||||
if crate::discovery::beacon::start(control_port, media_port, audio_port) {
|
||||
OK
|
||||
} else {
|
||||
ERR_INVALID_ARGUMENT
|
||||
}
|
||||
}
|
||||
|
||||
/// 已发现设备列表 JSON:`{"devices":[...]}`,字段与信令 `/list` 一致。
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ttstd_discovery_devices(out_json: *mut u8, capacity: usize) -> i32 {
|
||||
let json = crate::discovery::beacon::devices_json();
|
||||
copy_out(json.as_bytes(), out_json, capacity)
|
||||
}
|
||||
|
||||
/// 通知指定 IP 的被控端「主控端已就绪」,被控端据此拨号。
|
||||
///
|
||||
/// # Safety
|
||||
/// ip 必须指向长度为 len 的 UTF-8 字节。
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ttstd_discovery_connect(ip: *const u8, len: usize) -> i32 {
|
||||
let bytes = match read_slice(ip, len) {
|
||||
Ok(bytes) => bytes,
|
||||
Err(code) => return code,
|
||||
};
|
||||
let text = match std::str::from_utf8(bytes) {
|
||||
Ok(text) => text,
|
||||
Err(_) => return ERR_INVALID_ARGUMENT,
|
||||
};
|
||||
if crate::discovery::beacon::connect(text) {
|
||||
OK
|
||||
} else {
|
||||
ERR_INVALID_ARGUMENT
|
||||
}
|
||||
}
|
||||
|
||||
/// 停止自动发现(退出或测试用)。
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ttstd_discovery_stop() {
|
||||
crate::discovery::beacon::stop();
|
||||
}
|
||||
|
||||
/// ABI 版本,便于 Dart 侧校验动态库是否匹配。
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ttstd_core_abi_revision() -> i32 {
|
||||
2
|
||||
3
|
||||
}
|
||||
Reference in new issue
Block a user