From 6e0d3f30228dafb7c3269d5dd468a010b5e1b924 Mon Sep 17 00:00:00 2001 From: evgeny Date: Mon, 19 Oct 2026 22:46:35 +0200 Subject: [PATCH] Exercise real Full HD codecs and camera buffer boundaries --- .../chatgui/tests/test_call_camera_capture.cpp | 8 ++++++++ .../chatgui/tests/test_call_video_encoder.cpp | 18 +++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tools/chatgui/tests/test_call_camera_capture.cpp b/tools/chatgui/tests/test_call_camera_capture.cpp index a1fb88bb..b55c22b0 100644 --- a/tools/chatgui/tests/test_call_camera_capture.cpp +++ b/tools/chatgui/tests/test_call_camera_capture.cpp @@ -117,11 +117,15 @@ private slots: } void fastCameraKeepsThirtyFps() { auto capture = std::make_unique(); + CallCameraDevices devices; + connect(capture.get(), &CallCameraCapture::devicesChanged, this, [&](const CallCameraDevices& value) { devices = value; }); 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); + QCOMPARE(devices.size(), 1); QCOMPARE(devices.front().id, QByteArray("red")); + QVERIFY(devices.front().modes.contains({QSize(1920, 1080), 30})); 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); @@ -165,6 +169,10 @@ private slots: QVERIFY(creator.create()); const QString name = creator.name(); QVERIFY(peer.attach(name)); creator.data()[0] = 17; QCOMPARE(peer.data()[0], uchar(17)); + creator.data()[CallCameraProtocol::FrameBytes - 1] = 99; + QCOMPARE(peer.data()[CallCameraProtocol::FrameBytes - 1], uchar(99)); + QVERIFY(CallCameraProtocol::validSize(1920, 1080)); QVERIFY(CallCameraProtocol::validSize(1080, 1920)); + QVERIFY(!CallCameraProtocol::validSize(1920, 1920)); QVERIFY(!CallCameraProtocol::validSize(1921, 1080)); creator.close(); peer.data()[0] = 23; QCOMPARE(peer.data()[0], uchar(23)); peer.close(); QVERIFY(!peer.attach(name)); } diff --git a/tools/chatgui/tests/test_call_video_encoder.cpp b/tools/chatgui/tests/test_call_video_encoder.cpp index 821ba34a..0baec2dc 100644 --- a/tools/chatgui/tests/test_call_video_encoder.cpp +++ b/tools/chatgui/tests/test_call_video_encoder.cpp @@ -130,8 +130,8 @@ private slots: auto caps = CallVideoDecoder::capabilities(); QCOMPARE(caps.decode[0].profiles, uint8_t(3)); QCOMPARE(caps.decode[1].profiles, uint8_t(1)); for (const auto& limit : caps.decode) { - QCOMPARE(limit.width, uint16_t(1280)); QCOMPARE(limit.height, uint16_t(1280)); - QCOMPARE(limit.pixels_per_second, uint32_t(1280 * 720 * 30)); + QCOMPARE(limit.width, uint16_t(1920)); QCOMPARE(limit.height, uint16_t(1920)); + QCOMPARE(limit.pixels_per_second, uint32_t(1920 * 1080 * 30)); } QCOMPARE(caps.encode[0].width, uint16_t(0)); QCOMPARE(caps.encode[1].width, uint16_t(0)); const QString directory = qEnvironmentVariable("UTUN_CALL_VIDEO_REMOTE_DIR"); @@ -155,26 +155,30 @@ private slots: } } void bothOrientations_data() { - QTest::addColumn("codec"); QTest::newRow("H264") << 1; QTest::newRow("H265") << 2; + QTest::addColumn("codec"); QTest::addColumn("fullhd"); + QTest::newRow("H264-720p") << 1 << false; QTest::newRow("H265-720p") << 2 << false; + QTest::newRow("H264-1080p") << 1 << true; QTest::newRow("H265-1080p") << 2 << true; } void bothOrientations() { - QFETCH(int, codec); + QFETCH(int, codec); QFETCH(bool, fullhd); const char* backend = codec == 1 ? "libx264" : "libx265"; if (!avcodec_find_encoder_by_name(backend)) QSKIP("Software encoder unavailable"); auto config = configuration(codec); + const uint16_t width = fullhd ? 1920 : 1280, height = fullhd ? 1080 : 720; + config.level = codec == 1 ? (fullhd ? 40 : 31) : (fullhd ? 120 : 93); auto receiver = CallVideoDecoder::capabilities(); call_video_caps sender{}; - call_video_limit limit{1280, 720, 30, 1280 * 720 * 30, 4000000, config.profile, config.level}; + call_video_limit limit{width, height, 30, uint32_t(width) * height * 30, 4000000, config.profile, config.level}; // Обе пробы используют production open с проверкой настоящего KEY. for (bool portrait : {false, true}) { - config.width = portrait ? 720 : 1280; config.height = portrait ? 1280 : 720; + config.width = portrait ? height : width; config.height = portrait ? width : height; CallVideoEncoder probe; QVERIFY2(probe.open(config, 1000000, backend), qPrintable(probe.error())); } QVERIFY(!call_video_limit_orientations(&limit, codec)); sender.encode[codec - 1] = limit; CallVideoDecoder decoder(CallVideoDecoder::Backend::SoftwareOnly); uint64_t pts = 1000000, frameId = 0; for (bool portrait : {false, true, false}) { - config.width = portrait ? 720 : 1280; config.height = portrait ? 1280 : 720; + config.width = portrait ? height : width; config.height = portrait ? width : height; config.generation++; config.level = 0; QCOMPARE(call_video_choose(&sender, &receiver, &config), codec); QVERIFY(call_video_format_supported(&sender, &receiver, &config));