Feature: throughput criterion for adaptive quality, plus anti-oscillation

Adaptive quality only looked at RTT, so a short RTT over a narrow pipe
read as "excellent": at 20-40ms it picks Ultra/High (DIFF/RGB565), both
with bitRate == 0, and never steps down. One 1080p RGB565 frame is
4.15 MB -- 1.66s of transmission on 20 Mbps.

Adds GetTargetQualityLevelByLoad(): congestion needs both fps < 60% of
baseline and bytes/frame still near the nominal bitrate, because a static
screen has a near-zero byte rate on any link. Merged with the RTT result
as max() -- averaging lets a good RTT mask a narrow pipe. Step-down is 3
confirmations and jumps straight to the level the throughput can carry
(capped at +2); step-up stays RTT-only, so the criterion is one-way and
the worst case is one level too low instead of a 30s/15s oscillation.

Anti-oscillation, all inside the switch: RTT hysteresis (85%/115% dead
band against the target level's threshold), failed step-up pinned for 3
minutes, cooldowns 3s -> 10s down / 15s up, counters interrupt each
other, and a hard limit of 6 changes per 5 minutes.

Server-only, no client change. m_ulBytesThisSecond had to be fixed first:
it is accumulated before the switch, so file transfer, audio and
clipboard counted as screen traffic; added m_ulScreenBytesThisSecond for
the four frame cases. Also gates a real bug in the 10s post-step-down
probe that disabled the criterion permanently on a static screen.

Default on (same migration caveat as the other four). Unticking takes the
original path unchanged. Verified on Debug: 27 hysteresis cases and the
load cases pass, menu defaults correct; not yet measured end to end.
This commit is contained in:
yuanyuanxiang committed 2026-11-05 14:24:42 +01:00
1 parent ab83f5d685
commit d6b04a98f0
12 files changed
+543 -23

No files matched your search

+19
View File
@@ -1152,6 +1152,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
ON_COMMAND(ID_TOOL_TUNING_X264_VBV, &CMy2015RemoteDlg::OnToolTuningX264Vbv)
ON_COMMAND(ID_TOOL_TUNING_GDI_SLEEP, &CMy2015RemoteDlg::OnToolTuningGdiSleep)
ON_COMMAND(ID_TOOL_TUNING_PACE_FPS_FLOOR, &CMy2015RemoteDlg::OnToolTuningPaceFpsFloor)
ON_COMMAND(ID_TOOL_TUNING_ADAPTIVE_LOAD, &CMy2015RemoteDlg::OnToolTuningAdaptiveLoad)
ON_COMMAND(ID_EXECUTE_TESTRUN, &CMy2015RemoteDlg::OnExecuteTestrun)
ON_COMMAND(ID_EXECUTE_GHOST, &CMy2015RemoteDlg::OnExecuteGhost)
ON_COMMAND(ID_MASTER_TRAIL, &CMy2015RemoteDlg::OnMasterTrail)
@@ -2808,6 +2809,10 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
m_bTuningX264Vbv = THIS_CFG.GetInt("settings", "TuningX264Vbv", 1) != 0;
m_bTuningGdiNoSleep = THIS_CFG.GetInt("settings", "TuningGdiNoSleep", 1) != 0;
m_bTuningPaceFpsFloor = THIS_CFG.GetInt("settings", "TuningPaceFpsFloor", 1) != 0;
// 自适应加吞吐判据:纯服务端,默认开。判据分不清"链路慢"和"本机慢",
// 所以配套了三条防振荡措施(RTT 迟滞、升档失败封顶、探测样本门槛),
// 见 CScreenSpyDlg::EvaluateQuality。取消勾选即完全回到只看 RTT 的行为。
m_bAdaptiveDualCriteria = THIS_CFG.GetInt("settings", "AdaptiveDualCriteria", 1) != 0;
if (CMenu* advMenu = m_MainMenu.GetSubMenu(5)) {
advMenu->CheckMenuItem(ID_TOOL_EMBED_TLS_ANCHOR,
m_bEmbedTlsInDll ? MF_CHECKED : MF_UNCHECKED);
@@ -10785,6 +10790,8 @@ void CMy2015RemoteDlg::SyncTuningMenuChecks()
m_bTuningGdiNoSleep ? MF_CHECKED : MF_UNCHECKED);
tuningMenu->CheckMenuItem(ID_TOOL_TUNING_PACE_FPS_FLOOR,
m_bTuningPaceFpsFloor ? MF_CHECKED : MF_UNCHECKED);
tuningMenu->CheckMenuItem(ID_TOOL_TUNING_ADAPTIVE_LOAD,
m_bAdaptiveDualCriteria ? MF_CHECKED : MF_UNCHECKED);
}
// 高级→远程桌面调优→x264 码率封顶(VBV):默认开,取消勾选即关闭。
@@ -10825,6 +10832,18 @@ void CMy2015RemoteDlg::OnToolTuningPaceFpsFloor()
m_bTuningPaceFpsFloor ? 1 : 0);
}
// 高级→远程桌面调优→自适应加吞吐判据:默认关,取消/勾选立即对当前会话生效。
// 与前四项不同,这一项是纯服务端的:只改 CScreenSpyDlg::EvaluateQuality 的判据,
// 不下发任何命令给客户端,所以不需要 CMD_SCREEN_TUNING 位,也不必重开远程桌面窗口。
void CMy2015RemoteDlg::OnToolTuningAdaptiveLoad()
{
m_bAdaptiveDualCriteria = !m_bAdaptiveDualCriteria;
THIS_CFG.SetInt("settings", "AdaptiveDualCriteria", m_bAdaptiveDualCriteria ? 1 : 0);
SyncTuningMenuChecks();
Mprintf("[Tuning] AdaptiveDualCriteria = %d(自适应质量的吞吐判据)\n",
m_bAdaptiveDualCriteria ? 1 : 0);
}
// 当前调优开关位,供 CScreenSpyDlg 打开远程桌面时下发 CMD_SCREEN_TUNING。
int CMy2015RemoteDlg::GetScreenTuningFlags() const
{