Repository navigation
feat(camera): detect the system's own camera effects (plan 258 S4) #1657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| import type { CameraSystemEffect } from '@/lib/backend' | ||
| import { cameraSystemEffectLine } from './camera-system-effect' | ||
|
|
||
| const none: Omit<CameraSystemEffect, 'provider'> = { | ||
| backgroundBlur: false, | ||
| backgroundReplacement: false, | ||
| studioLight: false, | ||
| turnedOffByVideorc: false | ||
| } | ||
| const mac = (flags: Partial<CameraSystemEffect> = {}): CameraSystemEffect => ({ | ||
| provider: 'macos-video-effects', | ||
| ...none, | ||
| ...flags | ||
| }) | ||
| const windows = (flags: Partial<CameraSystemEffect> = {}): CameraSystemEffect => ({ | ||
| provider: 'windows-studio-effects', | ||
| ...none, | ||
| ...flags | ||
| }) | ||
|
|
||
| describe('cameraSystemEffectLine (plan 258 S4)', () => { | ||
| it('says nothing without a system effect, or with none on', () => { | ||
| expect(cameraSystemEffectLine(undefined)).toBeNull() | ||
| expect(cameraSystemEffectLine(mac())).toBeNull() | ||
| expect(cameraSystemEffectLine(windows())).toBeNull() | ||
| }) | ||
|
|
||
| it("names macOS Portrait with the plan's copy", () => { | ||
| expect(cameraSystemEffectLine(mac({ backgroundBlur: true }))).toBe( | ||
| "macOS is blurring this camera (Video menu, Portrait). Turn it off there to use Videorc's background." | ||
| ) | ||
| }) | ||
|
|
||
| it('names background replacement over Portrait, which it hides', () => { | ||
| const line = cameraSystemEffectLine(mac({ backgroundBlur: true, backgroundReplacement: true })) | ||
| expect(line).toContain('replacing') | ||
| expect(line).toContain('(Video menu, Background)') | ||
| }) | ||
|
|
||
| it('says nothing for Studio Light alone: it lights the face, not the room', () => { | ||
| expect(cameraSystemEffectLine(mac({ studioLight: true }))).toBeNull() | ||
| }) | ||
|
|
||
| it('names Windows Studio Effects blur and where to turn it off', () => { | ||
| expect(cameraSystemEffectLine(windows({ backgroundBlur: true }))).toBe( | ||
| "Windows Studio Effects is blurring this camera (Quick Settings, Studio effects). Turn it off there to use Videorc's background." | ||
| ) | ||
| }) | ||
|
|
||
| it('says so when Videorc turned the Windows blur off for its own background', () => { | ||
| expect(cameraSystemEffectLine(windows({ turnedOffByVideorc: true }))).toBe( | ||
| "Windows Studio Effects blur is off while Videorc's background is on." | ||
| ) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import type { CameraSystemEffect } from '@/lib/backend' | ||
|
|
||
| /** | ||
| * Plan 258 S4 (D12): the line under the Studio's Camera row when the | ||
| * operating system is changing the camera's background itself. macOS Video | ||
| * Effects and Windows Studio Effects run before Videorc sees a frame, so | ||
| * viewers get them too, and with Videorc's own background they stack. The | ||
| * line names the system menu that turns them off (apps can't on macOS). A | ||
| * status line, never a toast: the camera's picture already shows it. | ||
| * | ||
| * Studio Light gets no line: it changes the light on a face, not the room | ||
| * behind it, so it neither hides the room nor fights Videorc's background. | ||
| * Null when there is nothing to say. | ||
| */ | ||
| export function cameraSystemEffectLine(effect: CameraSystemEffect | undefined): string | null { | ||
| if (!effect) return null | ||
| if (effect.provider === 'macos-video-effects') { | ||
| if (effect.backgroundReplacement) { | ||
| return "macOS is replacing this camera's background (Video menu, Background). Turn it off there to use Videorc's background." | ||
| } | ||
| if (effect.backgroundBlur) { | ||
| return "macOS is blurring this camera (Video menu, Portrait). Turn it off there to use Videorc's background." | ||
| } | ||
| return null | ||
| } | ||
| if (effect.turnedOffByVideorc) { | ||
| return "Windows Studio Effects blur is off while Videorc's background is on." | ||
| } | ||
| if (effect.backgroundBlur) { | ||
| return "Windows Studio Effects is blurring this camera (Quick Settings, Studio effects). Turn it off there to use Videorc's background." | ||
| } | ||
| return null | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2686,6 +2686,16 @@ const previewCameraStatusSchema = boundedSemanticValue( | |
| droppedFrames: nonNegativeInteger, | ||
| frameAgeMs: optionalSchema(nonNegativeInteger), | ||
| noVideo: optionalSchema(booleanSchema), | ||
| // Plan 258 S4: strict, so a renamed Rust field fails here, not in the Studio. | ||
| systemEffect: optionalSchema( | ||
| objectSchema({ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reject all extra fields in Add
|
||
| provider: enumSchema(['macos-video-effects', 'windows-studio-effects']), | ||
| backgroundBlur: booleanSchema, | ||
| backgroundReplacement: booleanSchema, | ||
| studioLight: booleanSchema, | ||
| turnedOffByVideorc: booleanSchema | ||
| }) | ||
| ), | ||
| updatedAt: timestamp | ||
| }, | ||
| { allowUnknown: true } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the recording-tab test mock for
useStudioPreview.This new call also runs when
recording-tab.test.tsrendersQuickSettings. That test's@/hooks/use-studiomock does not exportuseStudioPreview. The supplied Desktop tests and Windows desktop tests logs both show the test failing here.Add
useStudioPreviewto that mock with an emptypreviewCameraStatus, as the focused tests do. Keep the production context requirement intact.GitHub Check: Desktop tests (3/4)
[failure] 266-266: src/renderer/src/components/tabs/recording-tab.test.ts > one resolution picker (plan 174, D-8 and S3.3 B-15) > gives Studio no second picker: Output is the Session row that opens this page
Error: [vitest] No "useStudioPreview" export is defined on the "
@/hooks/use-studio" mock. Did you forget to return it from "vi.mock"?If you need to partially mock a module, you can use "importOriginal" helper inside:
vi.mock(import("
@/hooks/use-studio"), async (importOriginal) => {const actual = await importOriginal()
return {
...actual,
// your mocked methods
}
})
❯ useCameraSystemEffectLine src/renderer/src/components/studio/quick-settings.tsx:266:33
❯ SystemEffectLine src/renderer/src/components/studio/quick-settings.tsx:251:16
❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:25904:20
❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:7662:22
❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:10166:19
❯ beginWork ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:11778:18
❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:874:13
❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:17641:22
GitHub Check: gates / Windows desktop tests (3/3)
[failure] 266-266: src/renderer/src/components/tabs/recording-tab.test.ts > one resolution picker (plan 174, D-8 and S3.3 B-15) > gives Studio no second picker: Output is the Session row that opens this page
Error: [vitest] No "useStudioPreview" export is defined on the "
@/hooks/use-studio" mock. Did you forget to return it from "vi.mock"?If you need to partially mock a module, you can use "importOriginal" helper inside:
vi.mock(import("
@/hooks/use-studio"), async (importOriginal) => {const actual = await importOriginal()
return {
...actual,
// your mocked methods
}
})
❯ useCameraSystemEffectLine src/renderer/src/components/studio/quick-settings.tsx:266:33
❯ SystemEffectLine src/renderer/src/components/studio/quick-settings.tsx:251:16
❯ Object.react_stack_bottom_frame ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:25904:20
❯ renderWithHooks ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:7662:22
❯ updateFunctionComponent ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:10166:19
❯ beginWork ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:11778:18
❯ runWithFiberInDEV ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:874:13
❯ performUnitOfWork ../../node_modules/.pnpm/react-dom@19.2.6_react@19.2.6/node_modules/react-dom/cjs/react-dom-client.development.js:17641:22
Source: Linters/SAST tools