feat(connection): 支持服务端下发 TURN 配置与触摸模式协商

This commit is contained in:
tongtong committed 2026-11-09 19:03:55 +08:00
1 parent e06e12fbbc
commit 004bf6b137
6 files changed
+189 -108

No files matched your search

@@ -138,7 +138,9 @@ class ControlMessageEncoder {
}
}
/// 被控端上报的远程视频信息(REPORT_RESOLUTION / REPORT_STREAM_MODE)。
enum TouchMode { legacy, discrete, motion }
/// 被控端上报的视频信息和触摸能力。
class ReportInfo {
final int action;
final int width;
@@ -146,6 +148,7 @@ class ReportInfo {
final int fps;
final int streamMode;
final List<int> supportedFps;
final TouchMode touchMode;
const ReportInfo({
this.action = 0,
@@ -154,13 +157,14 @@ class ReportInfo {
this.fps = 0,
this.streamMode = 0,
this.supportedFps = const [],
this.touchMode = TouchMode.legacy,
});
}
/// protobuf wire format 解码器。
///
/// 与控制端 `com.ttstd.control.ControlMessage`(protobuf 3)字段号完全对齐,
/// 仅解析被控端会回传的字段(action/width/height/fps/stream_mode/supported_fps)。
/// 解析被控端上报的视频和触摸能力字段。
class ControlMessageDecoder {
/// 解析被控端上报的 REPORT_* 消息;无法解析返回 null。
static ReportInfo? decode(Uint8List data) {
@@ -169,6 +173,7 @@ class ControlMessageDecoder {
int height = 0;
int fps = 0;
int streamMode = 0;
var touchMode = TouchMode.legacy;
final supportedFps = <int>[];
final reader = ByteData.sublistView(data);
@@ -203,8 +208,30 @@ class ControlMessageDecoder {
case 16:
supportedFps.add(val);
break;
case 17:
touchMode = switch (val) {
1 => TouchMode.discrete,
2 => TouchMode.motion,
_ => TouchMode.legacy,
};
break;
}
break;
case 2:
final length = _readVarint(reader, pos);
pos = length.$2;
final end = pos + length.$1;
if (end < pos || end > data.length) return null;
if (field == 16) {
while (pos < end) {
final fps = _readVarint(reader, pos);
pos = fps.$2;
if (pos > end) return null;
supportedFps.add(fps.$1);
}
}
pos = end;
break;
default:
// 未知 wire type:跳过(解析到 known fields 前不应出现)
return null;
@@ -220,6 +247,7 @@ class ControlMessageDecoder {
fps: fps,
streamMode: streamMode,
supportedFps: supportedFps,
touchMode: touchMode,
);
}