Distinguish monitors with identical Qt screen names
This commit is contained in:
1 parent
218249f9a5
commit
3d2f90e8ae
2 files changed
+57
-3
No files matched your search
@@ -223,9 +223,11 @@ private slots:
|
||||
auto* modeBox = controls.findChild<QComboBox*>("streamVideoMode");
|
||||
auto sources = StreamPublishEngine::sources();
|
||||
QSignalSpy changes(&controls, &StreamPublishWindow::settingsChanged);
|
||||
QList<QByteArray> screenIds;
|
||||
unsigned screens = 0;
|
||||
for (int i = 0; i < sources.size(); i++) {
|
||||
if (sources[i].kind != StreamVideoSource::Screen || sources[i].size.isEmpty()) continue;
|
||||
QVERIFY(!screenIds.contains(sources[i].id)); screenIds.append(sources[i].id);
|
||||
screens++; sourceBox->setCurrentIndex(-1); changes.clear(); sourceBox->setCurrentIndex(i);
|
||||
QSize size = stream_video_screen_size(sources[i].size);
|
||||
auto mode = modeBox->currentData().toList();
|
||||
@@ -237,6 +239,41 @@ private slots:
|
||||
}
|
||||
if (!screens) QSKIP("No enumerated screens");
|
||||
}
|
||||
void nativeScreenCapture() {
|
||||
#ifdef HAVE_STREAM_CAPTURE
|
||||
if (!qEnvironmentVariableIsSet("UTUN_TEST_SCREEN_CAPTURE")) QSKIP("Run with X11 screen capture enabled");
|
||||
StreamPublishEngine engine; QTRY_VERIFY_WITH_TIMEOUT(!engine.codecs().isEmpty(), 15000);
|
||||
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;
|
||||
uint64_t epoch = 0; unsigned captured = 0;
|
||||
for (const auto& source : engine.sources()) {
|
||||
if (source.kind != StreamVideoSource::Screen || source.size.isEmpty()) continue;
|
||||
QSize expected = stream_video_screen_size(source.size);
|
||||
config.source = source; config.source.size = {}; // Как portal: размер станет известен только из первого кадра.
|
||||
if (!engine.active()) {
|
||||
QVERIFY(engine.start(group, config));
|
||||
stream_member_state member{};
|
||||
QTRY_VERIFY_WITH_TIMEOUT(stream_member_load(inst, group, inst->node_id, &member, nullptr) == STREAM_OK && member.published, 5000);
|
||||
epoch = member.source.source_epoch; QVERIFY(gui_stream_open(204, group, inst->node_id, epoch));
|
||||
StreamRecord opened; QVERIFY(record(204, StreamRecordKind::Opened, opened));
|
||||
} else QVERIFY(engine.reconfigure(config));
|
||||
bool matched = false; StreamRecord frame; QElapsedTimer elapsed; elapsed.start();
|
||||
while (!matched && elapsed.elapsed() < 8000) {
|
||||
if (gui_stream_pull(204, frame, 0, true, 60000000) && frame.kind == StreamRecordKind::Video)
|
||||
matched = frame.format.width == expected.width() && frame.format.height == expected.height();
|
||||
QTest::qWait(1);
|
||||
}
|
||||
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++;
|
||||
}
|
||||
if (!captured) QSKIP("No enumerated screens");
|
||||
engine.stop(); QTRY_VERIFY_WITH_TIMEOUT(!engine.active(), 4000); gui_stream_stop(204);
|
||||
#else
|
||||
QSKIP("Screen capture unavailable");
|
||||
#endif
|
||||
}
|
||||
void broadcastAllowsRadioMicrophone() {
|
||||
AudioCaptureLease call, radio(AudioCaptureLease::Mode::Radio), recorder, publisher(AudioCaptureLease::Mode::Exclusive);
|
||||
QVERIFY(call.acquire()); QVERIFY(radio.acquire()); QVERIFY(recorder.acquire()); QVERIFY(!publisher.acquire());
|
||||
@@ -368,7 +405,8 @@ private slots:
|
||||
pattern.setStyleSheet("background: #c04020; color: white; font-size: 20px;"); pattern.show(); QTest::qWait(100);
|
||||
StreamPublishEngine engine; QTRY_VERIFY_WITH_TIMEOUT(!engine.codecs().isEmpty(), 15000);
|
||||
StreamPublishConfig config; config.video.width = 640; config.video.height = 360; config.video.fps = 15;
|
||||
config.source = {StreamVideoSource::Screen, "Virtual screen", QGuiApplication::primaryScreen()->name().toUtf8(), {}};
|
||||
for (const auto& source : engine.sources()) if (source.kind == StreamVideoSource::Screen) { config.source = source; break; }
|
||||
QVERIFY(!config.source.id.isEmpty());
|
||||
QSignalSpy errors(&engine, &StreamPublishEngine::errorOccurred);
|
||||
QVERIFY(engine.start(group, config));
|
||||
QTRY_VERIFY_WITH_TIMEOUT(engine.config().video.codec == STREAM_MEDIA_H264, 10000);
|
||||
|
||||
Reference in new issue
Block a user