docs: 协议表补充 msgType=9 会话配置帧

- README §4.4.1 增加 msg_type 9 与 payload 字段说明
- AGENTS.md 的 msgType 约定同步到 9
This commit is contained in:
tongtong committed 2026-11-27 17:42:44 +08:00
1 parent 59b3cefb97
commit 5f9fe88e37
2 files changed
+7 -2

No files matched your search

+1 -1
View File
@@ -53,7 +53,7 @@ flutter build windows --debug
## 关键约定(改代码前先看) ## 关键约定(改代码前先看)
- **控制帧格式**:`[version:1][msgType:1][sequence:u16][length:u32]` + payload,全小端;外层再套 AEAD(`[8B 明文头][12B nonce][密文][16B tag]`)。 - **控制帧格式**:`[version:1][msgType:1][sequence:u16][length:u32]` + payload,全小端;外层再套 AEAD(`[8B 明文头][12B nonce][密文][16B tag]`)。
- **msgType**:`0` touch / `1` mouse / `2` key / `3` wheel / `4` clipboard / `5` ping / `6` pong / `7` file(JSON 子协议) / `8` mirror(投屏请求应答)。 - **msgType**:`0` touch / `1` mouse / `2` key / `3` wheel / `4` clipboard / `5` ping / `6` pong / `7` file(JSON 子协议) / `8` mirror(投屏请求应答) / `9` sessionConfig(UTF-8 JSON 会话配置)。
- **端口**:视频 `41000`、控制 `41001`、音频 `41002`、文件服务 `53317`(占用时顺延 53318~53320)、信令 `8080`。 - **端口**:视频 `41000`、控制 `41001`、音频 `41002`、文件服务 `53317`(占用时顺延 53318~53320)、信令 `8080`。
- **被控端两阶段**:待命(只建发现+控制通道,不建编码器、不创建 VirtualDisplay)→ 投屏(收到 `msgType=8 action=request` 且用户确认、权限校验通过后才开流)。 - **被控端两阶段**:待命(只建发现+控制通道,不建编码器、不创建 VirtualDisplay)→ 投屏(收到 `msgType=8 action=request` 且用户确认、权限校验通过后才开流)。
- **单消费者约束**:`ttstd_video_next` 只能有一个消费线程;独立串流窗口复用同一个 `FrameStore`,不要新建第二个解码器。 - **单消费者约束**:`ttstd_video_next` 只能有一个消费线程;独立串流窗口复用同一个 `FrameStore`,不要新建第二个解码器。
+6 -1
View File
@@ -164,7 +164,7 @@ sig=<信令服务器URL,可选>
struct ControlFrameHeader { struct ControlFrameHeader {
u8 version; // 当前 = 1 u8 version; // 当前 = 1
u8 msg_type; // 0=touch 1=mouse 2=key 3=wheel 4=clipboard 5=ping 6=pong u8 msg_type; // 0=touch 1=mouse 2=key 3=wheel 4=clipboard 5=ping 6=pong
// 7=file(JSON 子协议) 8=mirror(投屏请求/应答) // 7=file(JSON 子协议) 8=mirror(投屏请求/应答) 9=sessionConfig(会话配置)
u16 sequence; // 递增序号,用于去重/重传 u16 sequence; // 递增序号,用于去重/重传
u32 payload_len; // 负载长度(不包括头部) u32 payload_len; // 负载长度(不包括头部)
}; };
@@ -204,6 +204,11 @@ struct MirrorEvent {
u8 action; // 0=request 1=stop 2=granted 3=denied 4=stopped 5=error u8 action; // 0=request 1=stop 2=granted 3=denied 4=stopped 5=error
u8 message[]; // 可选,UTF-8 原因说明(denied/error 时) u8 message[]; // 可选,UTF-8 原因说明(denied/error 时)
}; };
// 会话配置(msg_type = 9):主控端在请求投屏之前下发,payload 为 UTF-8 JSON,字段全部可选
// {"preferH265":false,"bitrateMbps":8,"audioEnabled":true,"clipboardSync":true}
// 被控端缺省字段沿用当前值;投屏中改编码格式/码率会重建采集链路,
// audioEnabled=false 时不建音频采集,clipboardSync=false 时双向丢弃剪贴板内容。
``` ```
#### 4.4.2 序列化/反序列化抽象接口 #### 4.4.2 序列化/反序列化抽象接口