diff --git a/tools/chatgui/src/radio_audio_engine.cpp b/tools/chatgui/src/radio_audio_engine.cpp index 768a0591..75d5462b 100644 --- a/tools/chatgui/src/radio_audio_engine.cpp +++ b/tools/chatgui/src/radio_audio_engine.cpp @@ -192,7 +192,7 @@ void RadioAudioEngine::postSettings(const std::array& values, bool apply void RadioAudioEngine::reconfigureCapture() { DEBUG_INFO(DEBUG_CATEGORY_RADIO, "RadioAudio: reconfigure capture group=%016llx manual=%d auto=%d", (unsigned long long)m_groupId.load(), m_talking.load(), autoEnabled()); - m_capture.close(); + if (!m_capture.closing()) m_capture.close(); m_wantStereo = chat_setting_get_int(gui_bridge_get_inst(), "radio_capture_stereo", 0) != 0; updateState(); recoverDevices(); diff --git a/tools/chatgui/tests/test_stream_publish.cpp b/tools/chatgui/tests/test_stream_publish.cpp index e5024234..4373ef70 100644 --- a/tools/chatgui/tests/test_stream_publish.cpp +++ b/tools/chatgui/tests/test_stream_publish.cpp @@ -281,15 +281,23 @@ private slots: } if (!screens) QSKIP("No enumerated screens"); } + void nativeScreenCapture_data() { + QTest::addColumn("codec"); + QTest::newRow("h264") << int(STREAM_MEDIA_H264); + QTest::newRow("h265") << int(STREAM_MEDIA_H265); + } void nativeScreenCapture() { #ifdef HAVE_STREAM_CAPTURE if (!qEnvironmentVariableIsSet("UTUN_TEST_SCREEN_CAPTURE")) QSKIP("Run with X11 screen capture enabled"); + QFETCH(int, codec); StreamPublishEngine engine; QTRY_VERIFY_WITH_TIMEOUT(!engine.codecs().isEmpty(), 15000); + if (!engine.codecs().contains(codec)) QSKIP("Requested encoder unavailable"); connect(&engine, &StreamPublishEngine::softwareEncodingRequested, &engine, [&engine](uint64_t generation) { engine.answerSoftwareEncoding(generation, true); }); QSignalSpy errors(&engine, &StreamPublishEngine::errorOccurred); StreamPublishConfig config; config.audio = false; config.nativeSize = true; config.automaticBitrate = true; config.video.width = 640; config.video.height = 360; config.video.fps = 15; + config.video.codec = codec; uint64_t epoch = 0; unsigned captured = 0; for (const auto& source : engine.sources()) { if (source.kind != StreamVideoSource::Screen || source.size.isEmpty()) continue; @@ -311,6 +319,15 @@ private slots: QVERIFY(matched); QCOMPARE(engine.config().source.id, source.id); QCOMPARE(engine.config().source.size, source.size); QCOMPARE(engine.config().video.width, expected.width()); QCOMPARE(engine.config().video.height, expected.height()); QVERIFY(errors.isEmpty()); captured++; + uint64_t previous = frame.pts; unsigned following = 0; + elapsed.restart(); + while (following < 8 && elapsed.elapsed() < 12000) { + if (gui_stream_pull(204, frame, 0, true, 60000000) && frame.kind == StreamRecordKind::Video) { + QVERIFY(frame.pts > previous); previous = frame.pts; following++; + } + QTest::qWait(1); + } + QCOMPARE(following, 8u); // Проверяем продолжение видео, а не только появление первого KEY. } if (!captured) QSKIP("No enumerated screens"); engine.stop(); QTRY_VERIFY_WITH_TIMEOUT(!engine.active(), 4000); gui_stream_stop(204);