Ограничить камеру звонка до 30 fps перед конвертацией

This commit is contained in:
evgeny committed 2026-10-18 16:27:43 +02:00
1 parent f6051d3bcd
commit 21e4821e22
3 files changed
+27 -12

No files matched your search

@@ -75,6 +75,7 @@ public:
bool start(const QByteArray& id, int w, int h) override {
device = id; width = w; height = h; record("start:" + id);
if (id == "start-stall") QThread::sleep(60);
timer.setInterval(id == "fast" ? 5 : 33);
timer.start(); return true;
}
void stop() override {
@@ -111,6 +112,19 @@ private slots:
path = directory.filePath(QString::number(QDateTime::currentMSecsSinceEpoch()));
qputenv("UTUN_CAMERA_TEST_LOG", path.toUtf8());
}
void fastCameraKeepsThirtyFps() {
auto capture = std::make_unique<CallCameraCapture>();
unsigned frames = 0;
connect(capture.get(), &CallCameraCapture::frameReady, this, [&](const QImage&, qint64, qint64) { ++frames; });
QSignalSpy errors(capture.get(), &CallCameraCapture::failed);
capture->configure(true, "fast", 640, 480);
QTRY_VERIFY_WITH_TIMEOUT(frames >= 5, 3000);
const unsigned before = frames; QElapsedTimer timer; timer.start(); QTest::qWait(2000);
const double fps = (frames - before) * 1000.0 / timer.elapsed();
qInfo("fast camera converted output fps=%.2f frames=%u", fps, frames - before);
QVERIFY(fps >= 25.0); QVERIFY(fps <= 31.0); QCOMPARE(errors.size(), 0);
const qint64 child = pid(); capture.reset(); QTRY_VERIFY_WITH_TIMEOUT(!alive(child), 3000);
}
void latestFrameAndGeneration() {
auto capture = std::make_unique<CallCameraCapture>();
unsigned frames = 0; qint64 maxAge = 0; QColor color; bool expectBlue = false, wrongGeneration = false;