mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-24 14:55:37 +00:00
fix(capture): stabilize platform source handling
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
createProcessedMicrophoneConstraints,
|
||||
normalizeBrowserMicrophoneProfile,
|
||||
resolveBrowserCaptureCursorPolicy,
|
||||
shouldUseNativeWindowsCaptureForSource,
|
||||
} from "./useScreenRecorder";
|
||||
|
||||
type RecordingState = "inactive" | "recording" | "paused";
|
||||
@@ -129,6 +130,16 @@ describe("resolveBrowserCaptureCursorPolicy", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldUseNativeWindowsCaptureForSource", () => {
|
||||
it("keeps native Windows capture on screen sources", () => {
|
||||
expect(shouldUseNativeWindowsCaptureForSource({ id: "screen:101:0" })).toBe(true);
|
||||
});
|
||||
|
||||
it("routes window sources through browser capture", () => {
|
||||
expect(shouldUseNativeWindowsCaptureForSource({ id: "window:123456:0" })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
function stopRecording(
|
||||
recorder: ReturnType<typeof createMockMediaRecorder>,
|
||||
isNativeRecording: boolean,
|
||||
|
||||
@@ -211,6 +211,12 @@ export function resolveBrowserCaptureCursorPolicy({
|
||||
};
|
||||
}
|
||||
|
||||
export function shouldUseNativeWindowsCaptureForSource(
|
||||
source: Pick<ProcessedDesktopSource, "id"> | null | undefined,
|
||||
): boolean {
|
||||
return source?.id?.startsWith("screen:") === true;
|
||||
}
|
||||
|
||||
export function createProcessedMicrophoneConstraints(
|
||||
microphoneDeviceId?: string,
|
||||
profile: BrowserMicrophoneProfile = DEFAULT_BROWSER_MICROPHONE_PROFILE,
|
||||
@@ -1362,8 +1368,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
|
||||
let nativeWindowsCaptureStartFailed = false;
|
||||
if (
|
||||
platform === "win32" &&
|
||||
(selectedSource.id?.startsWith("screen:") ||
|
||||
selectedSource.id?.startsWith("window:")) &&
|
||||
shouldUseNativeWindowsCaptureForSource(selectedSource) &&
|
||||
typeof window.electronAPI.isNativeWindowsCaptureAvailable === "function"
|
||||
) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user