From e99a1b9450eda6da63f0700f15394eb255aed2db Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 14 Oct 2026 12:53:24 +0200 Subject: [PATCH] Verify live desktop codec changes preserve the audio epoch --- tools/chatgui/src/stream_publish_engine.cpp | 24 +++++++++++---------- tools/chatgui/tests/test_stream_publish.cpp | 6 +++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/chatgui/src/stream_publish_engine.cpp b/tools/chatgui/src/stream_publish_engine.cpp index da1e9ebc..8445689e 100644 --- a/tools/chatgui/src/stream_publish_engine.cpp +++ b/tools/chatgui/src/stream_publish_engine.cpp @@ -428,17 +428,19 @@ void StreamPublishEngine::videoLoop() { if (generation == m->generation) { emit configurationChanged(); emit stateChanged(text("Live")); } }); } else { - auto candidate = std::make_unique(); - if (!candidate->open(config.video)) { - QString error = candidate->error(); - QMetaObject::invokeMethod(this, [this, generation, error] { sourceFailed(generation, error); }); - std::unique_lock lock(m->lock); - m->wake.wait_for(lock, std::chrono::milliseconds(100), [this, generation] { return !m->running || m->generation != generation; }); - continue; - } - encoder = std::move(candidate); current = generation; encoding = config; revision++; lastImage = {}; lastKey = -1000000; - DEBUG_INFO(DEBUG_CATEGORY_VIDEO, "desktop video prepared generation=%llu revision=%u encoder=%s", - (unsigned long long)generation, revision, qPrintable(encoder->name())); + auto candidate = std::make_unique(); + if (!candidate->open(config.video)) { + QString error = candidate->error(); + QMetaObject::invokeMethod(this, [this, generation, error] { sourceFailed(generation, error); }); + std::unique_lock lock(m->lock); + m->wake.wait_for(lock, std::chrono::milliseconds(100), [this, generation] { + return !m->running || m->generation != generation; + }); + continue; + } + encoder = std::move(candidate); current = generation; encoding = config; revision++; lastImage = {}; lastKey = -1000000; + DEBUG_INFO(DEBUG_CATEGORY_VIDEO, "desktop video prepared generation=%llu revision=%u encoder=%s", + (unsigned long long)generation, revision, qPrintable(encoder->name())); } } bool screen = config.source.kind != StreamVideoSource::Camera; diff --git a/tools/chatgui/tests/test_stream_publish.cpp b/tools/chatgui/tests/test_stream_publish.cpp index e2439444..99532b3a 100644 --- a/tools/chatgui/tests/test_stream_publish.cpp +++ b/tools/chatgui/tests/test_stream_publish.cpp @@ -253,12 +253,16 @@ private slots: QVERIFY(video >= 10); QVERIFY(audio >= 40); QVERIFY(latest > first + 1000000); QVERIFY(left && right > left * 3); opus_codec_decoder_destroy(decoder); auto next = config; next.video.bitrate = 1000000; next.video.rotation = 90; + if (engine.codecs().contains(STREAM_MEDIA_VP9)) next.video.codec = STREAM_MEDIA_VP9; QVERIFY(engine.reconfigure(next)); bool revised = false; elapsed.restart(); while (!revised && elapsed.elapsed() < 5000) { if (gui_stream_pull(202, out, 0, 60000000, 60000000) && out.kind == StreamRecordKind::Video && out.format.revision >= 2) revised = true; QTest::qWait(1); } - QVERIFY(revised); QCOMPARE(out.format.rotation, (uint16_t)90); + QVERIFY(revised); QCOMPARE(out.format.rotation, (uint16_t)90); QCOMPARE(out.format.video_codec, (uint8_t)next.video.codec); + QVERIFY(record(202, StreamRecordKind::Audio, out)); QVERIFY(out.pts > first + 1000000); + stream_member_state member{}; + QCOMPARE(stream_member_load(inst, group, inst->node_id, &member, nullptr), STREAM_OK); QCOMPARE(member.source.source_epoch, epoch); auto invalid = next; invalid.video.fps = 61; QVERIFY(engine.reconfigure(invalid)); QTRY_COMPARE_WITH_TIMEOUT(engine.config().video.fps, 15, 5000);