Feature: remote desktop tuning flags, on by default with per-item opt-out
Adds "Advanced -> Remote desktop tuning" with three independently checkable items, all enabled by default: x264 bitrate cap (VBV) TUNING_X264_VBV 0x1 GDI capture: no slice delay TUNING_GDI_NO_SLEEP 0x2 Send pacing FPS floor TUNING_PACE_FPS_FLOOR 0x4 Unticking an item clears its bit and restores the pre-commit behaviour exactly, so the escape hatch is one click per measure -- no rebuild, no config edit. Each bit is independent; a problem with one does not force turning all three off. Plumbing -------- Menu state -> [settings] Tuning* -> CMy2015RemoteDlg::GetScreenTuningFlags() -> CScreenSpyDlg::SendScreenTuning() (right after TOKEN_BITMAPINFO) -> CMD_SCREEN_TUNING = 178 [cmd:1][flags:4 LE] -> CScreenManager::OnReceive -> m_nTuningFlags -> ScreenCapture::SetTuningFlags Why it is safe to send to old clients: CScreenManager::OnReceive has no default branch in its switch, so an unknown command falls straight out (verified). 178 was unassigned (177 = COMMAND_SET_PROTO, 199 = TOKEN_DECRYPT), and the enum re-anchors explicitly so nothing auto- increments onto it. Flags are sent even when all-zero on purpose: the client's flag lives in CScreenManager, which survives closing and reopening the remote desktop window on the same connection. Without the zero send, unticking the menu would leave the previous flags in effect. Per-measure notes ----------------- VBV: capped CRF (peak = target, 0.5s buffer, init 0.9). The hardware paths already cap via rc_max_rate (1.5x, 1s buffer); this is tighter and only affects x264. After an IDR the buffer drains and takes up to 0.5s to refill, so a brief quality dip follows every keyframe -- if that shows up, relaxing to 1.5x/1s would match NVENC/QSV. GDI: keeps the 50-line BitBlt slicing (large single BitBlts hit driver limits) and only drops the 5ms sleep between slices -- 1080p is 22 slices = a forced 110ms per frame against a 50ms budget at 20fps. Pacing: clamps s0 to 2x the base interval instead of 4x (2fps -> 4fps), taken as max(2x base, 1000/MaxFPS) so it never exceeds the configured MaxFPS. The growth/decay code itself is untouched. This one works against the loop's own congestion signal, so it is the first to untick if a bad link feels laggier rather than smoother. SetTuningFlags only rebuilds the encoder when TUNING_ENCODER_BITS (currently just VBV) changes -- the GDI and pacing bits are read live by the capture and send threads, and rebuilding for them would drop an IDR and visibly flash the picture. Defaults: the on-by-default value lives in the third argument of THIS_CFG.GetInt(), which only applies when the key is absent. A machine that already has an explicit 0 keeps it, so the flip is not retroactive and a test machine can end up with a mixed state. Verified on the Debug build: with no Tuning* keys all three items start checked; unticking VBV alone leaves the other two checked and survives a restart; en_US/de_DE/zh_TW translations all resolve. Not yet measured end to end on a real remote desktop session.
This commit is contained in:
1 parent
1e336113a5
commit
ca4e85826f
19 files changed
+239
-9
No files matched your search
@@ -352,6 +352,11 @@ enum {
|
||||
// 客户端把入口写进本机配置后断开,重连循环按新入口重连;新入口连不上会自动回退。
|
||||
COMMAND_SET_PROTO = 177, // [ProtoSwitchPacket][certLen 字节 PEM 正文]
|
||||
|
||||
// 远程桌面调优开关:主控端「高级 → 远程桌面调优」的勾选项,打开远程桌面时下发一次。
|
||||
// [cmd:1][flags:4 LE],位定义见下方 TUNING_*。全 0 = 与加开关前行为完全一致。
|
||||
// 老客户端 OnReceive 的 switch 无 default 分支,收到不认识的命令直接忽略,故可安全下发。
|
||||
CMD_SCREEN_TUNING = 178,
|
||||
|
||||
TOKEN_DECRYPT = 199,
|
||||
TOKEN_REGEDIT = 200, // 注册表
|
||||
COMMAND_REG_FIND, // 注册表 管理标识
|
||||
@@ -1346,6 +1351,19 @@ struct QualityProfile {
|
||||
int bitRate; // kbps - H264
|
||||
};
|
||||
|
||||
// ===== 远程桌面调优开关(CMD_SCREEN_TUNING 的位定义)=====
|
||||
// 主控端「高级 → 远程桌面调优」里逐项勾选。三项默认全部勾选;取消勾选即把对应位清零,
|
||||
// 回到加开关前的行为。每一位都能独立开关,某项出问题可以只关那一项,不必全关。
|
||||
// 默认值改在 CMy2015RemoteDlg::OnInitDialog 的 GetInt 第三参数上,注意存量机器如果
|
||||
// 已经写过 0,改默认值不会覆盖它们。
|
||||
#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
|
||||
|
||||
// 其中会影响编码器参数、必须在变更时重建编码器的位。其余位由抓屏/发送线程每次现读,
|
||||
// 改了立刻生效,不需要重建(重建会丢一个 IDR,画面上能看出闪一下)。
|
||||
#define TUNING_ENCODER_BITS (TUNING_X264_VBV)
|
||||
|
||||
// 控制端使用,客户端优先从配置中读取
|
||||
inline const QualityProfile& GetQualityProfile(int level) {
|
||||
// 预定义质量配置: algorithm: 0=GRAY, 1=DIFF, 2=H264, 3=RGB565
|
||||
|
||||
Reference in new issue
Block a user