FreeRDP
Loading...
Searching...
No Matches
sdl::overlay Namespace Reference

Data Structures

struct  Reading
class  Names
struct  Row
struct  View
struct  Box
struct  Layout

Functions

static bool startsWith (const std::string &s, const char *prefix)
static std::string fixed (double v, int precision)
static std::optional< double > rate (const Names &names, const Reading &now, const Reading *prev, const std::string &name)
static std::string per (const std::optional< double > &v, int precision=1)
static const char * av1Label (const Names &names, const Reading &now)
static void videoRows (std::vector< Row > &rows, const Names &names, const Reading &now, const Reading *prev)
static void networkRows (std::vector< Row > &rows, const Names &names, const Reading &now, const Reading *prev)
std::vector< Row > realtimeRows (const Names &names, const Reading &now, const Reading *prev, const View &view)
Layout layout (float leftWidth, float leftHeight, float rightWidth, float rightHeight, float width, float margin)
std::string buildSummary (const char *config)

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation SDL Client: what the stats and info overlay shows

Copyright 2026 Cong Zhang congz.nosp@m.hang.nosp@m.zh@gm.nosp@m.ail..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Data Structure Documentation

◆ sdl::overlay::Reading

struct sdl::overlay::Reading

One reading of the statistics, taken on the session thread.

Definition at line 33 of file sdl_overlay_model.hpp.

Data Fields
uint32_t desktopHeight = 0
uint32_t desktopWidth = 0
uint64_t ns = 0

when it was taken, in ns from any base

vector< uint64_t > values

by statistic index

◆ sdl::overlay::Row

struct sdl::overlay::Row

Definition at line 56 of file sdl_overlay_model.hpp.

Data Fields
string label
string value

◆ sdl::overlay::View

struct sdl::overlay::View

What the overlay knows besides the statistics.

Definition at line 63 of file sdl_overlay_model.hpp.

Data Fields
uint64_t sessionSeconds = 0
int windowHeight = 0
int windowWidth = 0

◆ sdl::overlay::Box

struct sdl::overlay::Box

Definition at line 75 of file sdl_overlay_model.hpp.

Data Fields
float h = 0
float w = 0
float x = 0
float y = 0

◆ sdl::overlay::Layout

struct sdl::overlay::Layout

Definition at line 83 of file sdl_overlay_model.hpp.

Collaboration diagram for sdl::overlay::Layout:
Data Fields
Box left
Box right

Function Documentation

◆ av1Label()

const char * sdl::overlay::av1Label ( const Names & names,
const Reading & now )
static

Definition at line 102 of file sdl_overlay_model.cpp.

103 {
104#if defined(WITH_GFX_AV2)
105 const auto caps = names.get(now, "GFX_CAPS_VERSION").value_or(0);
106 if (caps == 0)
107 return "AV1/AV2";
108 return (caps == RDPGFX_CAPVERSION_FRDP_2) ? "AV2" : "AV1";
109#else
110 /* a build without AV2 never confirms it */
111 WINPR_UNUSED(names);
112 WINPR_UNUSED(now);
113 return "AV1";
114#endif
115 }
std::optional< uint64_t > get(const Reading &r, const std::string &name) const

◆ buildSummary()

std::string sdl::overlay::buildSummary ( const char * config)
nodiscard

The build lines of freerdp_get_build_config(): its type, compiler and architecture.

Definition at line 239 of file sdl_overlay_model.cpp.

240 {
241 if (!config)
242 return "";
243
244 const std::array<const char*, 3> keys = { "Build type:", "Compiler:",
245 "Target architecture:" };
246 std::vector<std::string> parts;
247 std::istringstream lines(config);
248 std::string line;
249 while (std::getline(lines, line))
250 {
251 for (const auto* key : keys)
252 {
253 if (!startsWith(line, key))
254 continue;
255 auto value = line.substr(strlen(key));
256 const auto start = value.find_first_not_of(' ');
257 if (start != std::string::npos)
258 parts.push_back(value.substr(start));
259 }
260 }
261
262 std::string summary;
263 for (const auto& part : parts)
264 summary += summary.empty() ? part : ", " + part;
265 return summary;
266 }

◆ fixed()

std::string sdl::overlay::fixed ( double v,
int precision )
static

Definition at line 73 of file sdl_overlay_model.cpp.

74 {
75 std::array<char, 64> buffer{};
76 (void)snprintf(buffer.data(), buffer.size(), "%.*f", precision, v);
77 return buffer.data();
78 }

◆ layout()

Layout sdl::overlay::layout ( float leftWidth,
float leftHeight,
float rightWidth,
float rightHeight,
float width,
float margin )
nodiscard

Where the two parts go in a window width pixels wide: the client part at the top left, the real-time part at the top right, or under the client part when the two do not fit side by side, so they never cover each other. A part that is wider than the window is cut at its edge. An empty part has the size 0.

Definition at line 226 of file sdl_overlay_model.cpp.

228 {
229 Layout l;
230 l.left = { margin, margin, leftWidth, leftHeight };
231 l.right = { std::max(0.0F, width - margin - rightWidth), margin, rightWidth, rightHeight };
232
233 const bool hasLeft = (leftWidth > 0) && (leftHeight > 0);
234 if (hasLeft && (margin + leftWidth + margin + rightWidth + margin > width))
235 l.right.y = margin + leftHeight + margin;
236 return l;
237 }

Referenced by SdlOverlayPainter::draw().

Here is the caller graph for this function:

◆ networkRows()

void sdl::overlay::networkRows ( std::vector< Row > & rows,
const Names & names,
const Reading & now,
const Reading * prev )
static

Definition at line 153 of file sdl_overlay_model.cpp.

155 {
156 const auto bytesRow = [&](const char* label, const char* name)
157 {
158 const auto total = names.get(now, name);
159 if (!total)
160 return;
161 const auto bytes = rate(names, now, prev, name);
162 const auto kbit = bytes ? std::optional<double>(*bytes * 8.0 / 1000.0) : std::nullopt;
163 rows.push_back({ label, per(kbit, 0) + " kbit/s, " +
164 fixed(static_cast<double>(*total) / 1e6, 1) +
165 " MB this connection" });
166 };
167 bytesRow("Network in (RDP)", "NETWORK_BYTES_RECEIVED");
168 bytesRow("Network out (RDP)", "NETWORK_BYTES_SENT");
169
170 /* the server's own measurements, 0 until it makes them: not every server does */
171 if (const auto rtt = names.get(now, "NETWORK_RTT_AVERAGE_MS"))
172 {
173 const auto base = names.get(now, "NETWORK_RTT_BASE_MS").value_or(0);
174 rows.push_back({ "Round trip", (*rtt != 0) ? std::to_string(*rtt) + " ms (lowest " +
175 std::to_string(base) + ")"
176 : "not measured" });
177 }
178 if (const auto kbps = names.get(now, "NETWORK_BANDWIDTH_KBPS"))
179 rows.push_back(
180 { "Bandwidth", (*kbps != 0) ? std::to_string(*kbps) + " kbit/s" : "not measured" });
181 }

◆ per()

std::string sdl::overlay::per ( const std::optional< double > & v,
int precision = 1 )
static

Definition at line 95 of file sdl_overlay_model.cpp.

96 {
97 return v ? fixed(*v, precision) : "–";
98 }

◆ rate()

std::optional< double > sdl::overlay::rate ( const Names & names,
const Reading & now,
const Reading * prev,
const std::string & name )
static

Definition at line 82 of file sdl_overlay_model.cpp.

84 {
85 if (!prev || (now.ns <= prev->ns))
86 return std::nullopt;
87 const auto a = names.get(now, name);
88 const auto b = names.get(*prev, name);
89 if (!a || !b || (*a < *b))
90 return std::nullopt;
91 const double dt = static_cast<double>(now.ns - prev->ns) / 1e9;
92 return static_cast<double>(*a - *b) / dt;
93 }

◆ realtimeRows()

std::vector< Row > sdl::overlay::realtimeRows ( const Names & names,
const Reading & now,
const Reading * prev,
const View & view )
nodiscard

The real-time part: picture and network, as the web client's Info card shows them. prev: the reading before now, or nullptr; a counter that went down gives no rate.

Definition at line 208 of file sdl_overlay_model.cpp.

210 {
211 std::vector<Row> rows;
212 rows.push_back({ "Resolution", std::to_string(now.desktopWidth) + " × " +
213 std::to_string(now.desktopHeight) + ", window " +
214 std::to_string(view.windowWidth) + " × " +
215 std::to_string(view.windowHeight) });
216 videoRows(rows, names, now, prev);
217 networkRows(rows, names, now, prev);
218
219 std::array<char, 32> session{};
220 (void)snprintf(session.data(), session.size(), "%" PRIu64 ":%02" PRIu64,
221 view.sessionSeconds / 60, view.sessionSeconds % 60);
222 rows.push_back({ "Session", session.data() });
223 return rows;
224 }

Referenced by SdlOverlay::update().

Here is the caller graph for this function:

◆ startsWith()

bool sdl::overlay::startsWith ( const std::string & s,
const char * prefix )
static

Definition at line 68 of file sdl_overlay_model.cpp.

69 {
70 return s.compare(0, strlen(prefix), prefix) == 0;
71 }

◆ videoRows()

void sdl::overlay::videoRows ( std::vector< Row > & rows,
const Names & names,
const Reading & now,
const Reading * prev )
static

Definition at line 117 of file sdl_overlay_model.cpp.

119 {
120 /* without the graphics channel's statistics the row hides */
121 if (!names.has(std::string(codecPrefix) + "AVC420"))
122 return;
123
124 std::vector<std::string> parts;
125 for (const auto& c : codecs)
126 {
127 const std::string name = std::string(codecPrefix) + c.id;
128 if (names.get(now, name).value_or(0) == 0)
129 continue;
130 const std::string label = (strcmp(c.id, "AV1") == 0) ? av1Label(names, now) : c.label;
131 const auto bytes = rate(names, now, prev, name + "_BYTES");
132 const auto kbit = bytes ? std::optional<double>(*bytes * 8.0 / 1000.0) : std::nullopt;
133 parts.push_back(label + " " + per(rate(names, now, prev, name), 0) + "/s " +
134 per(kbit, 0) + " kbit/s");
135 }
136 for (const auto& p : paints)
137 {
138 if (names.get(now, p.id).value_or(0) == 0)
139 continue;
140 parts.push_back(std::string(p.label) + " " + per(rate(names, now, prev, p.id), 0) +
141 "/s");
142 }
143
144 if (parts.empty())
145 {
146 rows.push_back({ "Video codecs", "no updates yet" });
147 return;
148 }
149 for (size_t x = 0; x < parts.size(); x++)
150 rows.push_back({ (x == 0) ? "Video codecs" : "", parts.at(x) });
151 }