Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Support macos 12.7 (#1343)

Brendan Allan3af8741ef3c1
diff --git a/Cargo.toml b/Cargo.toml
index f18ad9c2b..0b35f66d4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -42,7 +42,7 @@ tracing = "0.1.41"
futures = "0.3.31"
cidre = { git = "https://github.com/CapSoftware/cidre", rev = "bf84b67079a8", features = [
- "macos_13_0",
+ "macos_12_7",
"cv",
"cf",
"core_audio",
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index d6ae97bfc..115008412 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -1873,6 +1873,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
show_window,
write_clipboard_string,
platform::perform_haptic_feedback,
+ platform::is_system_audio_capture_supported,
list_fails,
set_fail,
update_auth_plan,
diff --git a/apps/desktop/src-tauri/src/platform/mod.rs b/apps/desktop/src-tauri/src/platform/mod.rs
index 267ec61b9..b409f600d 100644
--- a/apps/desktop/src-tauri/src/platform/mod.rs
+++ b/apps/desktop/src-tauri/src/platform/mod.rs
@@ -52,3 +52,23 @@ pub fn perform_haptic_feedback(
#[cfg(not(target_os = "macos"))]
Err("Haptics are only supported on macOS.".into())
}
+
+/// Check if system audio capture is supported on the current platform and OS version.
+/// On macOS, system audio capture requires macOS 13.0 or later.
+/// On Windows/Linux, this may have different requirements.
+#[tauri::command]
+#[specta::specta]
+#[instrument]
+pub fn is_system_audio_capture_supported() -> bool {
+ #[cfg(target_os = "macos")]
+ {
+ scap_screencapturekit::is_system_audio_supported()
+ }
+
+ #[cfg(not(target_os = "macos"))]
+ {
+ // On Windows/Linux, we assume system audio capture is available
+ // This can be refined later based on platform-specific requirements
+ true
+ }
+}
diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsx
index 5a98956cc..dcfbe8a86 100644
--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx
+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx
@@ -1,10 +1,6 @@
import { Button } from "@cap/ui-solid";
import { useNavigate } from "@solidjs/router";
-import {
- createMutation,
- createQuery,
- useQueryClient,
-} from "@tanstack/solid-query";
+import { createMutation, createQuery } from "@tanstack/solid-query";
import { getVersion } from "@tauri-apps/api/app";
import { getCurrentWindow, LogicalSize } from "@tauri-apps/api/window";
import { cx } from "cva";
@@ -12,7 +8,6 @@ import {
type ComponentProps,
createEffect,
createResource,
- createSignal,
ErrorBoundary,
onCleanup,
onMount,
@@ -29,7 +24,6 @@ import {
createCurrentRecordingQuery,
createLicenseQuery,
createVideoDevicesQuery,
- getPermissions,
listAudioDevices,
listScreens,
listWindows,
@@ -39,7 +33,6 @@ import {
type CaptureDisplay,
type CaptureWindow,
commands,
- events,
type RecordingMode,
type ScreenCaptureTarget,
} from "~/utils/tauri";
@@ -172,10 +165,11 @@ function Page() {
cameraID: () =>
cameras.find((c) => {
const { cameraID } = rawOptions;
- if (!cameraID) return;
+ if (!cameraID) return null;
if ("ModelID" in cameraID && c.model_id === cameraID.ModelID) return c;
if ("DeviceID" in cameraID && c.device_id === cameraID.DeviceID)
return c;
+ return null;
}),
micName: () => mics.data?.find((name: any) => name === rawOptions.micName),
};
@@ -558,29 +552,9 @@ function Page() {
);
}
-function useRequestPermission() {
- const queryClient = useQueryClient();
-
- async function requestPermission(type: "camera" | "microphone") {
- try {
- if (type === "camera") {
- await commands.resetCameraPermissions();
- } else if (type === "microphone") {
- await commands.resetMicrophonePermissions();
- }
- await commands.requestPermission(type);
- await queryClient.refetchQueries(getPermissions);
- } catch (error) {
- console.error(`Failed to get ${type} permission:`, error);
- }
- }
-
- return requestPermission;
-}
-
import { createEventListener } from "@solid-primitives/event-listener";
import { makePersisted } from "@solid-primitives/storage";
-import { CheckMenuItem, Menu, PredefinedMenuItem } from "@tauri-apps/api/menu";
+import { CheckMenuItem, Menu } from "@tauri-apps/api/menu";
import {
getCurrentWebviewWindow,
WebviewWindow,
@@ -591,10 +565,12 @@ import * as updater from "@tauri-apps/plugin-updater";
import { Transition } from "solid-transition-group";
import { SignInButton } from "~/components/SignInButton";
import { authStore, generalSettingsStore } from "~/store";
-import { createTauriEventListener } from "~/utils/createEventListener";
import { handleRecordingResult } from "~/utils/recording";
import { apiClient } from "~/utils/web-api";
import { WindowChromeHeader } from "./Context";
+import { CameraSelectBase } from "./new-main/CameraSelect";
+import { MicrophoneSelectBase } from "./new-main/MicrophoneSelect";
+import { SystemAudioToggleRoot } from "./new-main/SystemAudio";
import {
RecordingOptionsProvider,
useRecordingOptions,
@@ -761,220 +737,50 @@ function AreaSelectButton(props: {
);
}
-const NO_CAMERA = "No Camera";
-
function CameraSelect(props: {
disabled?: boolean;
options: CameraInfo[];
value: CameraInfo | null;
onChange: (cameraInfo: CameraInfo | null) => void;
}) {
- const currentRecording = createCurrentRecordingQuery();
- const permissions = createQuery(() => getPermissions);
- const requestPermission = useRequestPermission();
-
- const permissionGranted = () =>
- permissions?.data?.camera === "granted" ||
- permissions?.data?.camera === "notNeeded";
-
- const onChange = (cameraInfo: CameraInfo | null) => {
- if (!cameraInfo && !permissionGranted()) return requestPermission("camera");
-
- props.onChange(cameraInfo);
-
- trackEvent("camera_selected", {
- camera_name: cameraInfo,
- enabled: !!cameraInfo,
- });
- };
-
return (
- <div class="flex flex-col gap-[0.25rem] items-stretch text-[--text-primary]">
- <button
- type="button"
- disabled={!!currentRecording.data || props.disabled}
- class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-3 w-full disabled:text-gray-11 transition-colors KSelect"
- onClick={() => {
- if (!permissionGranted()) {
- requestPermission("camera");
- return;
- }
-
- Promise.all([
- CheckMenuItem.new({
- text: NO_CAMERA,
- checked: props.value === null,
- action: () => onChange(null),
- }),
- PredefinedMenuItem.new({ item: "Separator" }),
- ...props.options.map((o) =>
- CheckMenuItem.new({
- text: o.display_name,
- checked: o === props.value,
- action: () => onChange(o),
- }),
- ),
- ])
- .then((items) => Menu.new({ items }))
- .then((m) => {
- m.popup();
- });
- }}
- >
- <IconCapCamera class="text-gray-11 size-[1.25rem]" />
- <span class="flex-1 text-left truncate">
- {props.value?.display_name ?? NO_CAMERA}
- </span>
- <TargetSelectInfoPill
- value={props.value}
- permissionGranted={permissionGranted()}
- requestPermission={() => requestPermission("camera")}
- onClick={(e) => {
- if (!props.options) return;
- if (props.value !== null) {
- e.stopPropagation();
- props.onChange(null);
- }
- }}
- />
- </button>
- </div>
+ <CameraSelectBase
+ {...props}
+ PillComponent={InfoPill}
+ class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-3 w-full disabled:text-gray-11 transition-colors KSelect"
+ iconClass="text-gray-11 size-[1.25rem]"
+ />
);
}
-const NO_MICROPHONE = "No Microphone";
-
function MicrophoneSelect(props: {
disabled?: boolean;
options: string[];
value: string | null;
onChange: (micName: string | null) => void;
}) {
- const DB_SCALE = 40;
-
- const permissions = createQuery(() => getPermissions);
- const currentRecording = createCurrentRecordingQuery();
-
- const [dbs, setDbs] = createSignal<number | undefined>();
-
- const requestPermission = useRequestPermission();
-
- const permissionGranted = () =>
- permissions?.data?.microphone === "granted" ||
- permissions?.data?.microphone === "notNeeded";
-
- type Option = { name: string };
-
- const handleMicrophoneChange = async (item: Option | null) => {
- if (!props.options) return;
-
- props.onChange(item ? item.name : null);
- if (!item) setDbs();
-
- trackEvent("microphone_selected", {
- microphone_name: item?.name ?? null,
- enabled: !!item,
- });
- };
-
- createTauriEventListener(events.audioInputLevelChange, (dbs) => {
- if (!props.value) setDbs();
- else setDbs(dbs);
- });
-
- // visual audio level from 0 -> 1
- const audioLevel = () =>
- (1 - Math.max((dbs() ?? 0) + DB_SCALE, 0) / DB_SCALE) ** 0.5;
-
return (
- <div class="flex flex-col gap-[0.25rem] items-stretch text-[--text-primary]">
- <button
- type="button"
- disabled={!!currentRecording.data || props.disabled}
- class="relative flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-3 w-full disabled:text-gray-11 transition-colors KSelect overflow-hidden z-10"
- onClick={() => {
- if (!permissionGranted()) {
- requestPermission("microphone");
- return;
- }
-
- Promise.all([
- CheckMenuItem.new({
- text: NO_MICROPHONE,
- checked: props.value === null,
- action: () => handleMicrophoneChange(null),
- }),
- PredefinedMenuItem.new({ item: "Separator" }),
- ...(props.options ?? []).map((name) =>
- CheckMenuItem.new({
- text: name,
- checked: name === props.value,
- action: () => handleMicrophoneChange({ name: name }),
- }),
- ),
- ])
- .then((items) => Menu.new({ items }))
- .then((m) => {
- m.popup();
- });
- }}
- >
- <Show when={props.value !== null && dbs()}>
- {(_) => (
- <div
- class="bg-blue-100 opacity-50 left-0 inset-y-0 absolute -z-10 transition-[right] duration-100"
- style={{
- right: `${audioLevel() * 100}%`,
- }}
- />
- )}
- </Show>
- <IconCapMicrophone class="text-gray-11 size-[1.25rem]" />
- <span class="flex-1 text-left truncate">
- {props.value ?? NO_MICROPHONE}
- </span>
- <TargetSelectInfoPill
- value={props.value}
- permissionGranted={permissionGranted()}
- requestPermission={() => requestPermission("microphone")}
- onClick={(e) => {
- if (props.value !== null) {
- e.stopPropagation();
- props.onChange(null);
- }
- }}
- />
- </button>
- </div>
+ <MicrophoneSelectBase
+ {...props}
+ class="relative flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-3 w-full disabled:text-gray-11 transition-colors KSelect overflow-hidden z-10"
+ levelIndicatorClass="bg-blue-100"
+ iconClass="text-gray-11 size-[1.25rem]"
+ PillComponent={InfoPill}
+ />
);
}
function SystemAudio() {
- const { rawOptions, setOptions } = useRecordingOptions();
- const currentRecording = createCurrentRecordingQuery();
-
return (
- <button
- type="button"
- onClick={() => {
- if (!rawOptions) return;
- setOptions({ captureSystemAudio: !rawOptions.captureSystemAudio });
- }}
- disabled={!!currentRecording.data}
+ <SystemAudioToggleRoot
class="relative flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-3 w-full disabled:text-gray-11 transition-colors KSelect overflow-hidden z-10"
- >
- <div class="size-[1.25rem] flex items-center justify-center">
- <IconPhMonitorBold class="text-gray-11 stroke-2 size-[1.2rem]" />
- </div>
- <span class="flex-1 text-left truncate">
- {rawOptions.captureSystemAudio
- ? "Record System Audio"
- : "No System Audio"}
- </span>
- <InfoPill variant={rawOptions.captureSystemAudio ? "blue" : "red"}>
- {rawOptions.captureSystemAudio ? "On" : "Off"}
- </InfoPill>
- </button>
+ PillComponent={InfoPill}
+ icon={
+ <div class="size-[1.25rem] flex items-center justify-center">
+ <IconPhMonitorBold class="text-gray-11 stroke-2 size-[1.2rem]" />
+ </div>
+ }
+ />
);
}
@@ -1038,39 +844,6 @@ function TargetSelect<T extends { id: string; name: string }>(props: {
);
}
-function TargetSelectInfoPill<T>(props: {
- value: T | null;
- permissionGranted: boolean;
- requestPermission: () => void;
- onClick: (e: MouseEvent) => void;
-}) {
- return (
- <InfoPill
- variant={props.value !== null && props.permissionGranted ? "blue" : "red"}
- onPointerDown={(e) => {
- if (!props.permissionGranted || props.value === null) return;
-
- e.stopPropagation();
- }}
- onClick={(e) => {
- if (!props.permissionGranted) {
- props.requestPermission();
- e.stopPropagation();
- return;
- }
-
- props.onClick(e);
- }}
- >
- {!props.permissionGranted
- ? "Request Permission"
- : props.value !== null
- ? "On"
- : "Off"}
- </InfoPill>
- );
-}
-
function InfoPill(
props: ComponentProps<"button"> & { variant: "blue" | "red" },
) {
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/CameraSelect.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/CameraSelect.tsx
index 83a28b7fa..ab95e90f4 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/CameraSelect.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/CameraSelect.tsx
@@ -1,8 +1,10 @@
import { createQuery } from "@tanstack/solid-query";
import { CheckMenuItem, Menu, PredefinedMenuItem } from "@tauri-apps/api/menu";
+import type { Component, ComponentProps } from "solid-js";
import { trackEvent } from "~/utils/analytics";
import { createCurrentRecordingQuery, getPermissions } from "~/utils/queries";
import type { CameraInfo } from "~/utils/tauri";
+import InfoPill from "./InfoPill";
import TargetSelectInfoPill from "./TargetSelectInfoPill";
import useRequestPermission from "./useRequestPermission";
@@ -13,6 +15,27 @@ export default function CameraSelect(props: {
options: CameraInfo[];
value: CameraInfo | null;
onChange: (camera: CameraInfo | null) => void;
+}) {
+ return (
+ <CameraSelectBase
+ {...props}
+ PillComponent={InfoPill}
+ class="flex flex-row gap-2 items-center px-2 w-full h-9 rounded-lg transition-colors cursor-default disabled:opacity-70 bg-gray-3 disabled:text-gray-11 KSelect"
+ iconClass="text-gray-10 size-4"
+ />
+ );
+}
+
+export function CameraSelectBase(props: {
+ disabled?: boolean;
+ options: CameraInfo[];
+ value: CameraInfo | null;
+ onChange: (camera: CameraInfo | null) => void;
+ PillComponent: Component<
+ ComponentProps<"button"> & { variant: "blue" | "red" }
+ >;
+ class: string;
+ iconClass: string;
}) {
const currentRecording = createCurrentRecordingQuery();
const permissions = createQuery(() => getPermissions);
@@ -23,7 +46,7 @@ export default function CameraSelect(props: {
permissions?.data?.camera === "notNeeded";
const onChange = (cameraLabel: CameraInfo | null) => {
- if (!cameraLabel && permissions?.data?.camera !== "granted")
+ if (!cameraLabel && !permissionGranted())
return requestPermission("camera");
props.onChange(cameraLabel);
@@ -37,9 +60,14 @@ export default function CameraSelect(props: {
return (
<div class="flex flex-col gap-[0.25rem] items-stretch text-[--text-primary]">
<button
+ type="button"
disabled={!!currentRecording.data || props.disabled}
- class="flex flex-row gap-2 items-center px-2 w-full h-9 rounded-lg transition-colors cursor-default disabled:opacity-70 bg-gray-3 disabled:text-gray-11 KSelect"
onClick={() => {
+ if (!permissionGranted()) {
+ requestPermission("camera");
+ return;
+ }
+
Promise.all([
CheckMenuItem.new({
text: NO_CAMERA,
@@ -60,12 +88,14 @@ export default function CameraSelect(props: {
m.popup();
});
}}
+ class={props.class}
>
- <IconCapCamera class="text-gray-10 size-4" />
+ <IconCapCamera class={props.iconClass} />
<p class="flex-1 text-sm text-left truncate">
{props.value?.display_name ?? NO_CAMERA}
</p>
<TargetSelectInfoPill
+ PillComponent={props.PillComponent}
value={props.value}
permissionGranted={permissionGranted()}
requestPermission={() => requestPermission("camera")}
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/MicrophoneSelect.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/MicrophoneSelect.tsx
index a6f6d4d9d..f1cb10010 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/MicrophoneSelect.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/MicrophoneSelect.tsx
@@ -1,9 +1,18 @@
import { createQuery } from "@tanstack/solid-query";
import { CheckMenuItem, Menu, PredefinedMenuItem } from "@tauri-apps/api/menu";
-import { createSignal, onCleanup, onMount, Show } from "solid-js";
+import { cx } from "cva";
+import {
+ type Component,
+ type ComponentProps,
+ createSignal,
+ onMount,
+ Show,
+} from "solid-js";
import { trackEvent } from "~/utils/analytics";
+import { createTauriEventListener } from "~/utils/createEventListener";
import { createCurrentRecordingQuery, getPermissions } from "~/utils/queries";
import { events } from "~/utils/tauri";
+import InfoPill from "./InfoPill";
import TargetSelectInfoPill from "./TargetSelectInfoPill";
import useRequestPermission from "./useRequestPermission";
@@ -14,6 +23,29 @@ export default function MicrophoneSelect(props: {
options: string[];
value: string | null;
onChange: (micName: string | null) => void;
+}) {
+ return (
+ <MicrophoneSelectBase
+ {...props}
+ class="flex overflow-hidden relative z-10 flex-row gap-2 items-center px-2 w-full h-9 rounded-lg transition-colors cursor-default disabled:opacity-70 bg-gray-3 disabled:text-gray-11 KSelect"
+ levelIndicatorClass="bg-blue-7"
+ iconClass="text-gray-10 size-4"
+ PillComponent={InfoPill}
+ />
+ );
+}
+
+export function MicrophoneSelectBase(props: {
+ disabled?: boolean;
+ options: string[];
+ value: string | null;
+ onChange: (micName: string | null) => void;
+ class: string;
+ levelIndicatorClass: string;
+ iconClass: string;
+ PillComponent: Component<
+ ComponentProps<"button"> & { variant: "blue" | "red" }
+ >;
}) {
const DB_SCALE = 40;
@@ -42,13 +74,11 @@ export default function MicrophoneSelect(props: {
});
};
- const result = events.audioInputLevelChange.listen((dbs) => {
+ createTauriEventListener(events.audioInputLevelChange, (dbs) => {
if (!props.value) setDbs();
- else setDbs(dbs.payload);
+ else setDbs(dbs);
});
- onCleanup(() => result.then((unsub) => unsub()));
-
// visual audio level from 0 -> 1
const audioLevel = () =>
(1 - Math.max((dbs() ?? 0) + DB_SCALE, 0) / DB_SCALE) ** 0.5;
@@ -65,9 +95,15 @@ export default function MicrophoneSelect(props: {
return (
<div class="flex flex-col gap-[0.25rem] items-stretch text-[--text-primary]">
<button
+ type="button"
disabled={!!currentRecording.data || props.disabled}
- class="flex overflow-hidden relative z-10 flex-row gap-2 items-center px-2 w-full h-9 rounded-lg transition-colors cursor-default disabled:opacity-70 bg-gray-3 disabled:text-gray-11 KSelect"
+ class={props.class}
onClick={() => {
+ if (!permissionGranted()) {
+ requestPermission("microphone");
+ return;
+ }
+
Promise.all([
CheckMenuItem.new({
text: NO_MICROPHONE,
@@ -92,18 +128,20 @@ export default function MicrophoneSelect(props: {
<Show when={props.value !== null && dbs()}>
{(_) => (
<div
- class="bg-blue-7 opacity-50 left-0 inset-y-0 absolute transition-[right] duration-100 -z-10"
- style={{
- right: `${audioLevel() * 100}%`,
- }}
+ class={cx(
+ "opacity-50 left-0 inset-y-0 absolute transition-[right] duration-100 -z-10",
+ props.levelIndicatorClass,
+ )}
+ style={{ right: `${audioLevel() * 100}%` }}
/>
)}
</Show>
- <IconCapMicrophone class="text-gray-10 size-4" />
+ <IconCapMicrophone class={props.iconClass} />
<p class="flex-1 text-sm text-left truncate">
{props.value ?? NO_MICROPHONE}
</p>
<TargetSelectInfoPill
+ PillComponent={props.PillComponent}
value={props.value}
permissionGranted={permissionGranted()}
requestPermission={() => requestPermission("microphone")}
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/SystemAudio.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/SystemAudio.tsx
index c07c7bce9..786c15781 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/SystemAudio.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/SystemAudio.tsx
@@ -1,29 +1,72 @@
-import { createCurrentRecordingQuery } from "~/utils/queries";
+import { createQuery } from "@tanstack/solid-query";
+import type { Component, ComponentProps, JSX } from "solid-js";
+import { Dynamic } from "solid-js/web";
+
+import {
+ createCurrentRecordingQuery,
+ isSystemAudioSupported,
+} from "~/utils/queries";
import { useRecordingOptions } from "../OptionsContext";
import InfoPill from "./InfoPill";
export default function SystemAudio() {
+ return (
+ <SystemAudioToggleRoot
+ class="flex flex-row gap-2 items-center px-2 w-full h-9 rounded-lg transition-colors cursor-default disabled:opacity-70 bg-gray-3 disabled:text-gray-11 KSelect"
+ PillComponent={InfoPill}
+ icon={<IconPhMonitorBold class="text-gray-10 size-4" />}
+ />
+ );
+}
+
+export function SystemAudioToggleRoot(
+ props: Omit<
+ ComponentProps<"button">,
+ "onClick" | "disabled" | "title" | "type" | "children"
+ > & {
+ PillComponent: Component<{
+ variant: "blue" | "red";
+ children: JSX.Element;
+ }>;
+ icon: JSX.Element;
+ },
+) {
const { rawOptions, setOptions } = useRecordingOptions();
const currentRecording = createCurrentRecordingQuery();
+ const systemAudioSupported = createQuery(() => isSystemAudioSupported);
+
+ const isDisabled = () =>
+ !!currentRecording.data || systemAudioSupported.data === false;
+ const tooltipMessage = () => {
+ if (systemAudioSupported.data === false) {
+ return "System audio capture requires macOS 13.0 or later";
+ }
+ return undefined;
+ };
return (
<button
+ {...props}
+ type="button"
+ title={tooltipMessage()}
onClick={() => {
- if (!rawOptions) return;
+ if (!rawOptions || isDisabled()) return;
setOptions({ captureSystemAudio: !rawOptions.captureSystemAudio });
}}
- disabled={!!currentRecording.data}
- class="flex flex-row gap-2 items-center px-2 w-full h-9 rounded-lg transition-colors curosr-default disabled:opacity-70 bg-gray-3 disabled:text-gray-11 KSelect"
+ disabled={isDisabled()}
>
- <IconPhMonitorBold class="text-gray-10 size-4" />
+ {props.icon}
<p class="flex-1 text-sm text-left truncate">
{rawOptions.captureSystemAudio
? "Record System Audio"
: "No System Audio"}
</p>
- <InfoPill variant={rawOptions.captureSystemAudio ? "blue" : "red"}>
+ <Dynamic
+ component={props.PillComponent}
+ variant={rawOptions.captureSystemAudio ? "blue" : "red"}
+ >
{rawOptions.captureSystemAudio ? "On" : "Off"}
- </InfoPill>
+ </Dynamic>
</button>
);
}
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/TargetSelectInfoPill.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/TargetSelectInfoPill.tsx
index 55aceee4e..2f05e6b66 100644
--- a/apps/desktop/src/routes/(window-chrome)/new-main/TargetSelectInfoPill.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/new-main/TargetSelectInfoPill.tsx
@@ -1,13 +1,18 @@
-import InfoPill from "./InfoPill";
+import type { Component, ComponentProps } from "solid-js";
+import { Dynamic } from "solid-js/web";
export default function TargetSelectInfoPill<T>(props: {
value: T | null;
permissionGranted: boolean;
requestPermission: () => void;
onClick: (e: MouseEvent) => void;
+ PillComponent: Component<
+ ComponentProps<"button"> & { variant: "blue" | "red" }
+ >;
}) {
return (
- <InfoPill
+ <Dynamic
+ component={props.PillComponent}
variant={props.value !== null && props.permissionGranted ? "blue" : "red"}
onPointerDown={(e) => {
if (!props.permissionGranted || props.value === null) return;
@@ -28,6 +33,6 @@ export default function TargetSelectInfoPill<T>(props: {
: props.value !== null
? "On"
: "Off"}
- </InfoPill>
+ </Dynamic>
);
}
diff --git a/apps/desktop/src/utils/queries.ts b/apps/desktop/src/utils/queries.ts
index c9462c5c9..a70c79a2b 100644
--- a/apps/desktop/src/utils/queries.ts
+++ b/apps/desktop/src/utils/queries.ts
@@ -112,6 +112,12 @@ export const getPermissions = queryOptions({
refetchInterval: 1000,
});
+export const isSystemAudioSupported = queryOptions({
+ queryKey: ["systemAudioSupported"] as const,
+ queryFn: () => commands.isSystemAudioCaptureSupported(),
+ staleTime: Number.POSITIVE_INFINITY, // This won't change during runtime
+});
+
export function createOptionsQuery() {
const PERSIST_KEY = "recording-options-query-2";
const [_state, _setState] = createStore<{
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index 927aea45a..bcf2824ad 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -182,6 +182,14 @@ async writeClipboardString(text: string) : Promise<null> {
async performHapticFeedback(pattern: HapticPattern | null, time: HapticPerformanceTime | null) : Promise<null> {
return await TAURI_INVOKE("perform_haptic_feedback", { pattern, time });
},
+/**
+ * Check if system audio capture is supported on the current platform and OS version.
+ * On macOS, system audio capture requires macOS 13.0 or later.
+ * On Windows/Linux, this may have different requirements.
+ */
+async isSystemAudioCaptureSupported() : Promise<boolean> {
+ return await TAURI_INVOKE("is_system_audio_capture_supported");
+},
async listFails() : Promise<{ [key in string]: boolean }> {
return await TAURI_INVOKE("list_fails");
},
@@ -301,7 +309,6 @@ recordingOptionsChanged: RecordingOptionsChanged,
recordingStarted: RecordingStarted,
recordingStopped: RecordingStopped,
renderFrameEvent: RenderFrameEvent,
-requestNewScreenshot: RequestNewScreenshot,
requestOpenRecordingPicker: RequestOpenRecordingPicker,
requestOpenSettings: RequestOpenSettings,
requestScreenCapturePrewarm: RequestScreenCapturePrewarm,
@@ -323,7 +330,6 @@ recordingOptionsChanged: "recording-options-changed",
recordingStarted: "recording-started",
recordingStopped: "recording-stopped",
renderFrameEvent: "render-frame-event",
-requestNewScreenshot: "request-new-screenshot",
requestOpenRecordingPicker: "request-open-recording-picker",
requestOpenSettings: "request-open-settings",
requestScreenCapturePrewarm: "request-screen-capture-prewarm",
@@ -343,7 +349,7 @@ export type AspectRatio = "wide" | "vertical" | "square" | "classic" | "tall"
export type Audio = { duration: number; sample_rate: number; channels: number; start_time: number }
export type AudioConfiguration = { mute: boolean; improve: boolean; micVolumeDb?: number; micStereoMode?: StereoMode; systemVolumeDb?: number }
export type AudioInputLevelChange = number
-export type AudioMeta = { path: string;
+export type AudioMeta = { path: string;
/**
* unix time of the first frame
*/
@@ -395,11 +401,11 @@ export type Flags = { captions: boolean }
export type FramesRendered = { renderedCount: number; totalFrames: number; type: "FramesRendered" }
export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; hapticsEnabled?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; custom_cursor_capture2?: boolean; serverUrl?: string; recordingCountdown?: number | null; enableNativeCameraPreview: boolean; autoZoomOnClicks?: boolean; enableNewRecordingFlow: boolean; postDeletionBehaviour?: PostDeletionBehaviour; excludedWindows?: WindowExclusion[]; deleteInstantRecordingsAfterUpload?: boolean; instantModeMaxResolution?: number }
export type GifExportSettings = { fps: number; resolution_base: XY<number>; quality: GifQuality | null }
-export type GifQuality = {
+export type GifQuality = {
/**
* Encoding quality from 1-100 (default: 90)
*/
-quality: number | null;
+quality: number | null;
/**
* Whether to prioritize speed over quality (default: false)
*/
@@ -449,7 +455,6 @@ export type RecordingStarted = null
export type RecordingStopped = null
export type RecordingTargetMode = "display" | "window" | "area"
export type RenderFrameEvent = { frame_number: number; fps: number; resolution_base: XY<number> }
-export type RequestNewScreenshot = null
export type RequestOpenRecordingPicker = { target_mode: RecordingTargetMode | null }
export type RequestOpenSettings = { page: string }
export type RequestScreenCapturePrewarm = { force?: boolean }
@@ -477,7 +482,7 @@ export type UploadProgress = { progress: number }
export type UploadProgressEvent = { video_id: string; uploaded: string; total: string }
export type UploadResult = { Success: string } | "NotAuthenticated" | "PlanCheckFailed" | "UpgradeRequired"
export type Video = { duration: number; width: number; height: number; fps: number; start_time: number }
-export type VideoMeta = { path: string; fps?: number;
+export type VideoMeta = { path: string; fps?: number;
/**
* unix time of the first frame
*/
diff --git a/crates/audio/src/bin/macos-audio-capture.rs b/crates/audio/src/bin/macos-audio-capture.rs
index 2ba94cc29..72e60ce82 100644
--- a/crates/audio/src/bin/macos-audio-capture.rs
+++ b/crates/audio/src/bin/macos-audio-capture.rs
@@ -12,7 +12,7 @@ mod macos {
use std::{sync::mpsc::Sender, time::Duration};
use cidre::{
- cm, define_obj_type, ns, objc,
+ api, cm, define_obj_type, ns, objc,
sc::{
self,
stream::{Output, OutputImpl},
@@ -63,8 +63,13 @@ mod macos {
pub async fn main() {
let mut cfg = sc::StreamCfg::new();
- cfg.set_captures_audio(true);
- cfg.set_excludes_current_process_audio(false);
+
+ if api::macos_available("13.0") {
+ unsafe {
+ cfg.set_captures_audio(true);
+ cfg.set_excludes_current_process_audio(false);
+ }
+ }
let content = sc::ShareableContent::current().await.expect("content");
let display = &content.displays().get(0).unwrap();
diff --git a/crates/camera-avfoundation/src/lib.rs b/crates/camera-avfoundation/src/lib.rs
index 1f59ea626..f4cebcc86 100644
--- a/crates/camera-avfoundation/src/lib.rs
+++ b/crates/camera-avfoundation/src/lib.rs
@@ -12,10 +12,13 @@ use std::{
use tracing::warn;
pub fn list_video_devices() -> arc::R<ns::Array<av::CaptureDevice>> {
- let mut device_types = vec![
- av::CaptureDeviceType::built_in_wide_angle_camera(),
- av::CaptureDeviceType::desk_view_camera(),
- ];
+ let mut device_types = vec![av::CaptureDeviceType::built_in_wide_angle_camera()];
+
+ if api::macos_available("13.0")
+ && let Some(typ) = unsafe { av::CaptureDeviceType::desk_view_camera() }
+ {
+ device_types.push(typ);
+ }
if api::macos_available("14.0") {
if let Some(typ) = unsafe { av::CaptureDeviceType::external() } {
diff --git a/crates/scap-screencapturekit/src/capture.rs b/crates/scap-screencapturekit/src/capture.rs
index 18a1a0bb6..5eb35c181 100644
--- a/crates/scap-screencapturekit/src/capture.rs
+++ b/crates/scap-screencapturekit/src/capture.rs
@@ -193,7 +193,7 @@ impl CapturerBuilder {
let queue = dispatch::Queue::serial_with_ar_pool();
- if self.config.captures_audio() {
+ if crate::is_system_audio_supported() && unsafe { self.config.captures_audio() } {
stream
.add_stream_output(callbacks.as_ref(), sc::OutputType::Audio, Some(&queue))
.map_err(|e| e.retained())?;
diff --git a/crates/scap-screencapturekit/src/config.rs b/crates/scap-screencapturekit/src/config.rs
index e99e4a9a7..a95e002f8 100644
--- a/crates/scap-screencapturekit/src/config.rs
+++ b/crates/scap-screencapturekit/src/config.rs
@@ -31,8 +31,13 @@ impl StreamCfgBuilder {
});
}
+ // Only supported on macOS 13.0+
pub fn set_captures_audio(&mut self, captures_audio: bool) {
- self.0.set_captures_audio(captures_audio);
+ if crate::is_system_audio_supported() {
+ unsafe {
+ self.0.set_captures_audio(captures_audio);
+ }
+ }
}
/// Sets the queue depth (number of frames to buffer).
diff --git a/crates/scap-screencapturekit/src/lib.rs b/crates/scap-screencapturekit/src/lib.rs
index f0071fef6..7a4516245 100644
--- a/crates/scap-screencapturekit/src/lib.rs
+++ b/crates/scap-screencapturekit/src/lib.rs
@@ -7,3 +7,9 @@ mod permission;
pub use capture::{AudioFrame, Capturer, CapturerBuilder, Frame, VideoFrame};
pub use config::StreamCfgBuilder;
pub use permission::{has_permission, request_permission};
+
+/// Check if system audio capture is supported on the current macOS version.
+/// System audio capture via ScreenCaptureKit requires macOS 13.0 or later.
+pub fn is_system_audio_supported() -> bool {
+ cidre::api::macos_available("13.0")
+}