docs(webrtc_controller_flutter): 更新项目文档以反映重构后的架构

AGENTS.md 与 README.md 同步更新:根据实际代码结构重写目录树、技术栈、架构分层及编码规范,移除旧版内联示例并补充新的开发约定与代码生成命令。
This commit is contained in:
2026-08-03 16:12:44 +08:00
parent 1918e5738e
commit d5e66a1777
51 changed files with 4711 additions and 1458 deletions

View File

@@ -0,0 +1,24 @@
// 全局常量与 API 端点。
/// 服务端 HTTP 基址(与信令同源)。部署时通过 --dart-define=API_BASE= 注入。
const String kApiBase = String.fromEnvironment(
'API_BASE',
defaultValue: 'https://www.ttstd.com',
);
/// 信令 WebSocket 默认地址。
const String kDefaultSignalServer = 'wss://www.ttstd.com/signal';
/// DataChannel 标签,控制端与被控端需一致。
const String kDataChannelLabel = 'control_channel';
/// 分辨率预设width 为长边像素0 表示被控端原生分辨率。
const List<Map<String, Object>> kResolutionOptions = [
{'label': '原始', 'width': 0, 'height': 0, 'fps': 0},
{'label': '1080P', 'width': 1920, 'height': 0, 'fps': 0},
{'label': '720P', 'width': 1280, 'height': 0, 'fps': 0},
{'label': '480P', 'width': 854, 'height': 0, 'fps': 0},
];
/// 默认帧率档位(收到被控端上报的 supported_fps 后以上报列表为准)。
const List<int> kDefaultFpsOptions = [15, 24, 30, 60];

View File

@@ -0,0 +1,48 @@
/// ICE 服务器配置。
///
/// 与可正常连接的 `webrtc_controller_ios`(原生 Swift 项目)保持一致:
/// 使用 `www.ttstd.com:3478` 作为 STUN/TURN 服务器。
///
/// 注意:旧配置曾误用 `175.178.213.60:3478`(错误凭据)及内网
/// `192.168.5.224:3478`(模拟器不可达),导致 iOS 模拟器下
/// `ICE Checking -> Failed`。已修正为与 iOS 原生项目相同的服务器。
///
/// **iOS 模拟器关键修复**
/// 明文 `turn:175.178.213.60:3478` 在 iOS 模拟器libwebrtc下不会发起
/// RELAY 分配请求,导致控制端本地候选缺失 `typ relay`,两端无公共中继可
/// 配对 → candidate-pair=0 → ICE FailedAndroid 真机/网页则正常)。
/// 改用 `turns:`TLS over TCP 5349模拟器能稳定拿到 relay 候选。
/// 同时保留 udp / tcp 明文项作为降级,以及 STUN 用于 srflx。
const List<Map<String, dynamic>> kIceServers = [
{'urls': 'stun:stun.l.google.com:19302'},
{'urls': 'stun:175.178.213.60:3478'},
{
// 首选TLS over TCPiOS 模拟器下能稳定分配 relay 候选。
'urls': 'turns:175.178.213.60:5349',
'username': 'fanhuitong',
'credential': 'Fan19961907..',
},
{
// 降级:明文 UDP/TCP。
'urls': 'turn:175.178.213.60:3478',
'username': 'fanhuitong',
'credential': 'Fan19961907..',
},
{
'urls': 'turn:175.178.213.60:3478?transport=tcp',
'username': 'fanhuitong',
'credential': 'Fan19961907..',
},
{'urls': 'stun:47.242.112.133:3478'},
{
'urls': 'turn:47.242.112.133:3478',
'username': 'ttstd',
'credential': 'fanhuitong',
},
{'urls': 'stun:192.168.5.224:3478'},
{
'urls': 'turn:192.168.5.224:3478',
'username': 'tt',
'credential': 'fht',
},
];