mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-24 14:55:37 +00:00
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const recorderSource = readFileSync(
|
|
fileURLToPath(new URL("./ScreenCaptureKitRecorder.swift", import.meta.url)),
|
|
"utf8",
|
|
);
|
|
|
|
describe("ScreenCaptureKitRecorder finalization coordination", () => {
|
|
it("marks manual stops as participants in the shared finalization", () => {
|
|
expect(recorderSource).toContain("finalizeCapture(interactive: true)");
|
|
expect(recorderSource).toContain("finalization.outputResult.get()");
|
|
expect(recorderSource).toContain(
|
|
"self.interactiveStopParticipated = self.interactiveStopParticipated || interactive",
|
|
);
|
|
});
|
|
|
|
it("does not let automatic window-close exit preempt a joined manual stop", () => {
|
|
expect(recorderSource).toContain("self.finalizeCapture(interactive: false)");
|
|
expect(recorderSource).toMatch(
|
|
/if finalization\.interactiveStopParticipated\s*\{\s*return\s*\}/,
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("ScreenCaptureKitRecorder resume timing", () => {
|
|
it("anchors warm-start resume timing to video before accepting audio", () => {
|
|
expect(recorderSource).toContain(
|
|
"guard outputType == .screen, let pauseStartedHostTime else",
|
|
);
|
|
});
|
|
|
|
it("drops non-monotonic video and audio samples", () => {
|
|
expect(recorderSource).toContain(
|
|
"CMTimeCompare(presentationTime, lastVideoPresentationTime) <= 0",
|
|
);
|
|
expect(recorderSource).toContain(
|
|
"CMTimeCompare(presentationTime, lastPresentationTime) > 0",
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("ScreenCaptureKitRecorder colour metadata", () => {
|
|
it("asks ScreenCaptureKit for BT.709-compatible video-range frames", () => {
|
|
expect(recorderSource).toContain(
|
|
"streamConfig.pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange",
|
|
);
|
|
expect(recorderSource).toContain("streamConfig.colorSpaceName = CGColorSpace.sRGB");
|
|
expect(recorderSource).toContain(
|
|
"streamConfig.colorMatrix = CGDisplayStream.yCbCrMatrix_ITU_R_709_2",
|
|
);
|
|
expect(recorderSource).toContain(
|
|
"rawValue: kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange",
|
|
);
|
|
expect(recorderSource).toContain("sourceFormatHint: sourceVideoFormat");
|
|
expect(recorderSource).not.toContain("videoCodecType: .h264");
|
|
});
|
|
|
|
it("tags recordings as BT.709", () => {
|
|
expect(recorderSource).toContain("AVVideoColorPropertiesKey");
|
|
expect(recorderSource).toContain("AVVideoColorPrimaries_ITU_R_709_2");
|
|
expect(recorderSource).toContain("AVVideoTransferFunction_ITU_R_709_2");
|
|
expect(recorderSource).toContain("AVVideoYCbCrMatrix_ITU_R_709_2");
|
|
});
|
|
});
|