Feature: make remote desktop tuning per client
The tuning switches lived in the master's Advanced menu and were saved globally, so two hosts could not use different settings. The client already sends ScreenSettings when a remote desktop starts, so the state belongs there: the four items now sit in the remote desktop window's system menu, directly below Screen quality, and are saved per client. ScreenSettings had a 40-byte Reserved area at offset 56; four bytes became TuningFlags, keeping the struct at 100 bytes with Capabilities at 96. A new Capabilities bit marks a value written by a versioned master; old clients, and new clients never configured, report 0 and are not trusted. CMD_SCREEN_TUNING now ends with a version byte. A five-byte command comes from an older master that does not know the server-only adaptive bit: the client applies those three bits to the session but does not save them. A fresh client starts at 0, so an old master still gets pre-feature behaviour; the new master's 0xE default is persisted on its first session. The per-client master copy stays as the old-client fallback, and the old global [settings] Tuning* keys are honoured when neither exists, so an explicit opt-out survives the migration. Verified on the Debug server with the in-process test client: a fresh client stored 0xE on first use; toggling VBV wrote 0xF to both sides; after deleting the master copy and reopening, the menu restored VBV from the client report. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
f96e4a7320
commit
a190c21217
12 files changed
+216
-156
No files matched your search
+34
-9
@@ -352,8 +352,10 @@ enum {
|
||||
// 客户端把入口写进本机配置后断开,重连循环按新入口重连;新入口连不上会自动回退。
|
||||
COMMAND_SET_PROTO = 177, // [ProtoSwitchPacket][certLen 字节 PEM 正文]
|
||||
|
||||
// 远程桌面调优开关:主控端「高级 → 远程桌面调优」的勾选项,打开远程桌面时下发一次。
|
||||
// [cmd:1][flags:4 LE],位定义见下方 TUNING_*。全 0 = 与加开关前行为完全一致。
|
||||
// 远程桌面调优开关:远程桌面对话框「远程桌面调优」的勾选项,打开远程桌面时下发一次。
|
||||
// [cmd:1][flags:4 LE][version:1],位定义见下方 TUNING_*。老主控端负载只有前 5 字节;
|
||||
// 版本字节让新客户端区分老主控端(不认识 bit3)与新主控端(bit3 明确为 0/1)。
|
||||
// 全 0 = 与加开关前行为完全一致。
|
||||
// 老客户端 OnReceive 的 switch 无 default 分支,收到不认识的命令直接忽略,故可安全下发。
|
||||
CMD_SCREEN_TUNING = 178,
|
||||
|
||||
@@ -1370,15 +1372,30 @@ struct QualityProfile {
|
||||
int bitRate; // kbps - H264
|
||||
};
|
||||
|
||||
// ===== 远程桌面调优开关(CMD_SCREEN_TUNING 的位定义)=====
|
||||
// 主控端「高级 → 远程桌面调优」里逐项勾选。GDI 去延时与发送节流默认勾选,
|
||||
// x264 码率封顶默认不勾选(仅限洲际弱网);取消勾选即把对应位清零,
|
||||
// 回到加开关前的行为。每一位都能独立开关,某项出问题可以只关那一项,不必全关。
|
||||
// 默认值改在 CMy2015RemoteDlg::OnInitDialog 的 GetInt 第三参数上,注意存量机器只要
|
||||
// 已经写过该键,改默认值就不会覆盖它们(保持用户上次的显式选择)。
|
||||
// ===== 远程桌面调优开关(CMD_SCREEN_TUNING 与 ScreenSettings.TuningFlags 的位定义)=====
|
||||
// 远程桌面对话框「远程桌面调优」子菜单里逐项勾选,按客户端分别保存:
|
||||
// 主控端把勾选结果随 CMD_SCREEN_TUNING 下发,客户端存进本机配置并回填到
|
||||
// ScreenSettings.TuningFlags,下次建立远程桌面时随位图信息一起上报,主控端据此
|
||||
// 恢复勾选状态。GDI 去延时、发送节流、自适应判据默认勾选,x264 码率封顶默认不勾选。
|
||||
// 取消勾选即把对应位清零,回到加开关前的行为;每一位都能独立开关。
|
||||
//
|
||||
// 命令负载是 [cmd:1][flags:4 LE][version:1]。版本字节只有新主控端会发:客户端据此
|
||||
// 区分「新主控端明确关掉了 bit3」和「老主控端根本不知道 bit3」,后一种情况只让低
|
||||
// 三位即时生效、不落盘,避免把客户端保存的四位值覆盖成老主控端的认知。
|
||||
#define TUNING_X264_VBV 0x00000001 // x264 软编加 VBV 码率封顶(跨洲际防单帧打爆链路)
|
||||
#define TUNING_GDI_NO_SLEEP 0x00000002 // GDI 抓屏去掉分段 BitBlt 之间的 5ms 延时(1080p 省 110ms/帧)
|
||||
#define TUNING_PACE_FPS_FLOOR 0x00000004 // 发送节流帧率下限:慢链路下不再把帧率压到 2fps
|
||||
// 纯服务端判据(自适应质量是否叠加吞吐判断)。客户端不解释这一位,只原样保存并回报,
|
||||
// 这样四个开关能共用同一个持久化/上报字段。
|
||||
#define TUNING_ADAPTIVE_DUAL 0x00000008
|
||||
|
||||
// 新主控端为还没有本机记录的客户端准备的默认值,与旧版全局设置的默认一致。
|
||||
// 注意客户端自己并不默认使用这个值:没有本机记录时客户端按 0 运行(加开关前的
|
||||
// 行为),等新主控端下发后才会保存;这样被老主控端打开时不会被悄悄打开调优项。
|
||||
#define TUNING_DEFAULT (TUNING_GDI_NO_SLEEP | TUNING_PACE_FPS_FLOOR | TUNING_ADAPTIVE_DUAL)
|
||||
|
||||
// CMD_SCREEN_TUNING 末尾版本字节的当前值。老主控端的负载只有 [cmd][flags] 5 字节。
|
||||
#define SCREEN_TUNING_CMD_VERSION 1
|
||||
|
||||
// 其中会影响编码器参数、必须在变更时重建编码器的位。其余位由抓屏/发送线程每次现读,
|
||||
// 改了立刻生效,不需要重建(重建会丢一个 IDR,画面上能看出闪一下)。
|
||||
@@ -1547,10 +1564,18 @@ typedef struct ScreenSettings {
|
||||
int AudioEnabled; // 偏移 44, 音频传输(0: 禁用, 1: 启用)
|
||||
int EncodeLevel; // 偏移 48, 编码等级
|
||||
int CustomCursor; // 偏移 52, 自定义光标
|
||||
char Reserved[40]; // 偏移 56, 保留字段(新能力参数从此处扩展)
|
||||
int TuningFlags; // 偏移 56, 远程桌面调优开关位(TUNING_*),客户端持久化并上报
|
||||
char Reserved[36]; // 偏移 60, 保留字段(新能力参数从此处扩展)
|
||||
uint32_t Capabilities; // 偏移 96, 能力位标志(放最后)
|
||||
} ScreenSettings; // 总大小 100 字节
|
||||
|
||||
// ScreenSettings.Capabilities 位定义:客户端上报的能力。
|
||||
// 没有这一位的是老客户端,或者还没被新主控端下发过调优开关的客户端;两种情况
|
||||
// TuningFlags 都不可信(可能是 0,也可能残留老主控端给的低三位)。
|
||||
#define SCREEN_CAP_TUNING_FLAGS 0x00000001 // TuningFlags 四位均由新主控端写入,可信
|
||||
|
||||
static_assert(sizeof(ScreenSettings) == 100, "ScreenSettings 是固定的 100 字节线上结构,不能变大变小");
|
||||
|
||||
// 音频控制常量
|
||||
#define CYCLEAUDIO_DISABLE 0 // 停止音频
|
||||
#define CYCLEAUDIO_ENABLE 1 // 启动音频
|
||||
|
||||
Reference in new issue
Block a user