Show stream playback buffer chains on desktop and Android

Send coalesced per-hop telemetry every 200 ms ahead of video DATA using the shared ETCP transport. Measure pending frames before ETCP handoff, retain stale and unavailable node values, and display the worst path with playback tempo.

Bump stream wire protocol to v7. Validate with 187 core tests, 21 desktop player tests, two Android indicator tests, and an Android APK build.
This commit is contained in:
evgeny committed 2026-10-25 15:21:23 +01:00
1 parent 61d07e12c8
commit 7b4cacc439
30 files changed
+831 -19

No files matched your search

+61
View File
@@ -6,6 +6,8 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QScrollArea>
#include <QStyle>
#include <QPushButton>
#include <QSlider>
#include <QCloseEvent>
@@ -38,6 +40,23 @@ int64_t nowUs() {
}
std::atomic<uint64_t> nextId{0};
QString text(const char* value) { return QCoreApplication::translate("ChatGui", value); }
/* Ровно восемь Unicode code points и один компактный знак многоточия; HTML имён экранируется. */
QString shortNodeName(const char* name) {
QString value = QString::fromUtf8(name); int end = 0, count = 0;
while (end < value.size() && count < 8) {
if (value.at(end).isHighSurrogate() && end + 1 < value.size() && value.at(end + 1).isLowSurrogate()) end++;
end++; count++;
}
return (value.left(end) + (end < value.size() ? QStringLiteral("…") : QString())).toHtmlEscaped();
}
QString bufferTime(int64_t us) {
if (us < 0) return QStringLiteral("?");
QString value = QString::number(us / 1000000.0, 'f', 1);
if (value.endsWith(QStringLiteral(".0"))) value.chop(2);
return value + QStringLiteral("S");
}
}
struct StreamPlayerWindow::Playback {
@@ -113,6 +132,12 @@ StreamPlayerWindow::StreamPlayerWindow(uint64_t group, uint64_t source, uint64_t
auto* layout = new QVBoxLayout(this); auto* title = new QLabel(name, this); layout->addWidget(title);
m_status = new QLabel(text("Connecting…"), this); layout->addWidget(m_status);
m_render = new VideoRenderWidget(this, true); layout->addWidget(m_render, 1);
m_telemetry = new QLabel(this); m_telemetry->setObjectName(QStringLiteral("streamTelemetry"));
m_telemetry->setTextFormat(Qt::RichText); m_telemetry->setAlignment(Qt::AlignCenter);
auto* telemetryScroll = new QScrollArea(this); telemetryScroll->setFrameShape(QFrame::NoFrame);
telemetryScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); telemetryScroll->setAlignment(Qt::AlignCenter);
telemetryScroll->setFixedHeight(fontMetrics().height() * 2 + style()->pixelMetric(QStyle::PM_ScrollBarExtent) + 4);
telemetryScroll->setWidget(m_telemetry); layout->addWidget(telemetryScroll);
auto* controls = new QHBoxLayout;
auto* volume = new QSlider(Qt::Horizontal, this); volume->setRange(0, 100); volume->setValue(100);
volume->setAccessibleName(text("Stream volume")); controls->addWidget(new QLabel(text("Volume"), this)); controls->addWidget(volume);
@@ -220,6 +245,42 @@ void StreamPlayerWindow::tick() {
finished = p.ended && p.videoEnded && p.videos.empty() && audioDone;
}
p.notify();
if (nowUs() - m_telemetryAt >= STREAM_TELEMETRY_PERIOD_MS * 1000) {
m_telemetryAt = nowUs();
stream_viewer_telemetry t{};
if (gui_stream_telemetry(p.id, t)) {
int64_t reserve = -1; int tempo = 1000;
{
std::lock_guard<std::mutex> guard(p.lock);
int64_t ready = p.activeAudio && !p.media.audio_ended ? p.media.ready_us : p.media.video_us;
if (p.started && ready >= 0) reserve = std::max<int64_t>(0, ready - p.clock(nowUs()));
if (p.presenting && !p.timing.waiting && !finished && !p.failed) tempo = p.adaptation.tempo_milli;
}
QString times, names, tooltip;
for (unsigned i = 0; i <= t.chain.count; i++) {
bool own = i == t.chain.count;
uint8_t flags = own ? STREAM_TELEMETRY_KNOWN : t.chain.rows[i].flags;
int64_t us = own ? reserve : (flags & STREAM_TELEMETRY_KNOWN) ? (int64_t)t.chain.rows[i].buffered_us : -1;
QString color = flags & STREAM_TELEMETRY_DOWN ? QStringLiteral("#c88888")
: flags & STREAM_TELEMETRY_STALE ? QStringLiteral("#888888") : m_telemetry->palette().color(QPalette::WindowText).name();
QString value = bufferTime(us);
if (flags & STREAM_TELEMETRY_DOWN) value += QStringLiteral(" ×");
else if ((flags & STREAM_TELEMETRY_STALE) && us >= 0) value += QStringLiteral(" ?");
if (i) { times += QStringLiteral("<td>&nbsp;→&nbsp;</td>"); names += QStringLiteral("<td></td>"); tooltip += QStringLiteral(" → "); }
times += QStringLiteral("<td align='center' style='color:%1'>%2</td>").arg(color, value);
names += QStringLiteral("<td align='center' style='color:%1'>%2</td>").arg(color, shortNodeName(t.names[i]));
tooltip += QString::fromUtf8(t.names[i]) + QStringLiteral(": ") + bufferTime(us);
}
if (tempo > 1000) {
QString rate = QString::number(tempo / 1000.0, 'f', 2);
if (rate.endsWith(QLatin1Char('0'))) rate.chop(1);
times += QStringLiteral("<td>&nbsp; %1x</td>").arg(rate); names += QStringLiteral("<td></td>");
}
m_telemetry->setText(QStringLiteral("<table cellspacing='0'><tr>%1</tr><tr>%2</tr></table>").arg(times, names));
m_telemetry->adjustSize();
m_telemetry->setToolTip(tooltip);
}
}
if (!image.isNull()) {
m_render->setFrame(image); m_status->setText(text("Live"));
if (first) DEBUG_INFO(DEBUG_CATEGORY_STREAM,