Prevent delayed camera startup from shifting video into the future
This commit is contained in:
1 parent
ac3801761e
commit
4c2d8aa4cc
3 files changed
+57
-14
No files matched your search
@@ -6,6 +6,7 @@
|
||||
#include "../src/call_video_encoder.h"
|
||||
#include "../src/call_video_decoder.h"
|
||||
#include "../src/call_video_cadence.h"
|
||||
#include "../src/call_video_capture_clock.h"
|
||||
#include "../../../src/call/call_video_bitstream.h"
|
||||
extern "C" {
|
||||
#include "debug_config.h"
|
||||
@@ -42,6 +43,29 @@ class CallVideoEncoderTest : public QObject {
|
||||
return {17, 640, 360, 30, 0, (uint8_t)codec, (uint8_t)(codec == 1 ? 31 : 93), 4000000, (uint8_t)(codec == 1 ? 2 : 1)};
|
||||
}
|
||||
private slots:
|
||||
void captureClockDelayedStartup() {
|
||||
CallVideoCaptureClock clock;
|
||||
const int64_t origin = 1000000;
|
||||
int64_t previous = -1;
|
||||
for (int i = 0; i < 900; i++) {
|
||||
// Первый кадр приходит с задержкой 220мс; затем камера догоняет по 5мс за кадр.
|
||||
const int64_t source = i * 33333LL;
|
||||
const int64_t delay = std::max<int64_t>(0, 220000 - i * 5000LL);
|
||||
const int64_t arrival = origin + source + delay;
|
||||
const int64_t pts = clock.map(source, arrival);
|
||||
QVERIFY(pts <= arrival);
|
||||
QVERIFY(pts > previous);
|
||||
if (i > 44) QCOMPARE(pts, origin + source);
|
||||
previous = pts;
|
||||
}
|
||||
QCOMPARE(clock.correction, 220000LL);
|
||||
// Задержанный callback не сдвигает уже откалиброванные часы вперёд.
|
||||
QCOMPARE(clock.map(30000000, origin + 30100000), origin + 30000000);
|
||||
QCOMPARE(clock.map(30033333, origin + 30033333), origin + 30033333);
|
||||
QCOMPARE(clock.map(0, origin + 31000000), origin + 31000000); // Перезапуск часов камеры.
|
||||
QCOMPARE(clock.map(-1, origin + 31033333), origin + 31033333); // Нет PTS.
|
||||
QCOMPARE(clock.map(100, origin + 31066666), origin + 31066666);
|
||||
}
|
||||
void captureCadence() {
|
||||
CallVideoCadence jittered, fast;
|
||||
for (int i = 0; i < 300; i++) QVERIFY(jittered.accept(1000000 + i * 33333 + (i % 2 ? -1500 : 1500)));
|
||||
|
||||
Reference in new issue
Block a user