Browse Source

Check continuing H265 screen video and avoid waiting on failed input

master
evgeny 2 days ago
parent
commit
69cee1bec4
  1. 2
      tools/chatgui/src/radio_audio_engine.cpp
  2. 17
      tools/chatgui/tests/test_stream_publish.cpp

2
tools/chatgui/src/radio_audio_engine.cpp

@ -192,7 +192,7 @@ void RadioAudioEngine::postSettings(const std::array<int, 9>& values, bool apply
void RadioAudioEngine::reconfigureCapture() { void RadioAudioEngine::reconfigureCapture() {
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "RadioAudio: reconfigure capture group=%016llx manual=%d auto=%d", DEBUG_INFO(DEBUG_CATEGORY_RADIO, "RadioAudio: reconfigure capture group=%016llx manual=%d auto=%d",
(unsigned long long)m_groupId.load(), m_talking.load(), autoEnabled()); (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; m_wantStereo = chat_setting_get_int(gui_bridge_get_inst(), "radio_capture_stereo", 0) != 0;
updateState(); updateState();
recoverDevices(); recoverDevices();

17
tools/chatgui/tests/test_stream_publish.cpp

@ -281,15 +281,23 @@ private slots:
} }
if (!screens) QSKIP("No enumerated screens"); if (!screens) QSKIP("No enumerated screens");
} }
void nativeScreenCapture_data() {
QTest::addColumn<int>("codec");
QTest::newRow("h264") << int(STREAM_MEDIA_H264);
QTest::newRow("h265") << int(STREAM_MEDIA_H265);
}
void nativeScreenCapture() { void nativeScreenCapture() {
#ifdef HAVE_STREAM_CAPTURE #ifdef HAVE_STREAM_CAPTURE
if (!qEnvironmentVariableIsSet("UTUN_TEST_SCREEN_CAPTURE")) QSKIP("Run with X11 screen capture enabled"); 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); StreamPublishEngine engine; QTRY_VERIFY_WITH_TIMEOUT(!engine.codecs().isEmpty(), 15000);
if (!engine.codecs().contains(codec)) QSKIP("Requested encoder unavailable");
connect(&engine, &StreamPublishEngine::softwareEncodingRequested, &engine, connect(&engine, &StreamPublishEngine::softwareEncodingRequested, &engine,
[&engine](uint64_t generation) { engine.answerSoftwareEncoding(generation, true); }); [&engine](uint64_t generation) { engine.answerSoftwareEncoding(generation, true); });
QSignalSpy errors(&engine, &StreamPublishEngine::errorOccurred); QSignalSpy errors(&engine, &StreamPublishEngine::errorOccurred);
StreamPublishConfig config; config.audio = false; config.nativeSize = true; config.automaticBitrate = true; 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.width = 640; config.video.height = 360; config.video.fps = 15;
config.video.codec = codec;
uint64_t epoch = 0; unsigned captured = 0; uint64_t epoch = 0; unsigned captured = 0;
for (const auto& source : engine.sources()) { for (const auto& source : engine.sources()) {
if (source.kind != StreamVideoSource::Screen || source.size.isEmpty()) continue; 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); 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()); QCOMPARE(engine.config().video.width, expected.width()); QCOMPARE(engine.config().video.height, expected.height());
QVERIFY(errors.isEmpty()); captured++; 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"); if (!captured) QSKIP("No enumerated screens");
engine.stop(); QTRY_VERIFY_WITH_TIMEOUT(!engine.active(), 4000); gui_stream_stop(204); engine.stop(); QTRY_VERIFY_WITH_TIMEOUT(!engine.active(), 4000); gui_stream_stop(204);

Loading…
Cancel
Save