@octane-xplat/camera 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +2 -132
  2. package/package.json +20 -25
  3. package/platforms/android/java/com/octanexplat/camera/CameraPreviewView.java +24 -0
  4. package/platforms/android/java/com/octanexplat/camera/CameraSessionBridge.java +153 -21
  5. package/platforms/ios/src/XplatSwitchingMovieWriter.swift +557 -0
  6. package/src/CameraView.android.tsrx +187 -154
  7. package/src/CameraView.ios.tsrx +124 -110
  8. package/src/CameraView.macos.tsrx +103 -96
  9. package/src/CameraView.tsrx +2 -0
  10. package/src/CameraView.web.tsrx +157 -146
  11. package/src/CameraView.windows.tsrx +134 -125
  12. package/src/camera-host.macos.ts +1059 -0
  13. package/src/camera-permission.mobile.ts +85 -81
  14. package/src/camera-permission.windows.ts +56 -53
  15. package/src/camera-session.ios.ts +89 -61
  16. package/src/camera-session.macos.ts +51 -49
  17. package/src/camera-session.windows.ts +113 -105
  18. package/src/host-movie.web.ts +257 -231
  19. package/src/index.ts +28 -26
  20. package/src/index.web.ts +27 -25
  21. package/src/layout-child.ts +86 -79
  22. package/src/layout-child.web.ts +54 -53
  23. package/src/layout-child.windows.ts +80 -74
  24. package/src/movie-metadata.web.ts +84 -81
  25. package/src/movie-storage.web.ts +142 -135
  26. package/src/movie-writer.ios.ts +170 -0
  27. package/src/photo-lifecycle.macos.ts +60 -0
  28. package/src/photo-sheet.macos.ts +505 -0
  29. package/src/preview-display.ios.ts +69 -0
  30. package/src/preview-pinch.ts +41 -0
  31. package/src/preview-tap.ts +22 -21
  32. package/src/props.ts +115 -93
  33. package/src/recording-haptics.ios.ts +39 -0
  34. package/src/recording-source.web.ts +159 -0
  35. package/src/session-backend.android.ts +552 -410
  36. package/src/session-backend.ios.ts +1500 -1148
  37. package/src/session-backend.linux.ts +886 -860
  38. package/src/session-backend.macos.ts +697 -679
  39. package/src/session-backend.ts +51 -49
  40. package/src/session-backend.web.ts +1181 -867
  41. package/src/session-backend.windows.ts +1540 -1467
  42. package/src/session-core.ts +925 -714
  43. package/src/session.ts +12 -12
  44. package/src/style-merge.ts +40 -37
  45. package/src/synthetic-session.ts +391 -339
  46. package/src/types.ts +372 -298
  47. package/types/generated/.tsrx-typegen-manifest.json +4 -24
  48. package/types/generated/CameraView.d.ts +2 -0
  49. package/types/generated/camera-host.macos.d.ts +33 -0
  50. package/types/generated/index.d.ts +27 -26
  51. package/types/generated/photo-lifecycle.macos.d.ts +12 -0
  52. package/types/generated/photo-sheet.macos.d.ts +36 -0
  53. package/types/generated/props.d.ts +24 -2
  54. package/types/generated/session-core.d.ts +30 -1
  55. package/types/generated/synthetic-session.d.ts +7 -0
  56. package/types/generated/types.d.ts +75 -1
  57. package/platforms/macos/src/CameraOwnership.swift +0 -22
  58. package/platforms/macos/src/PhotoCaptureLifecycle.swift +0 -34
  59. package/platforms/macos/src/XplatCameraHost.swift +0 -639
  60. package/platforms/macos/src/XplatPhotoCaptureSheet.swift +0 -192
  61. package/types/generated/CameraView.android.d.ts +0 -9
  62. package/types/generated/CameraView.ios.d.ts +0 -5
  63. package/types/generated/CameraView.macos.d.ts +0 -5
  64. package/types/generated/CameraView.mobile.d.ts +0 -5
  65. package/types/generated/CameraView.windows.d.ts +0 -11
  66. package/types/generated/camera-permission.mobile.d.ts +0 -2
  67. package/types/generated/camera-permission.windows.d.ts +0 -6
  68. package/types/generated/camera-session.ios.d.ts +0 -2
  69. package/types/generated/camera-session.macos.d.ts +0 -10
  70. package/types/generated/camera-session.windows.d.ts +0 -9
  71. package/types/generated/host-movie.web.d.ts +0 -100
  72. package/types/generated/index.web.d.ts +0 -7
  73. package/types/generated/layout-child.d.ts +0 -11
  74. package/types/generated/layout-child.windows.d.ts +0 -13
  75. package/types/generated/movie-metadata.web.d.ts +0 -9
  76. package/types/generated/movie-storage.web.d.ts +0 -5
  77. package/types/generated/preview-tap.d.ts +0 -7
  78. package/types/generated/session-backend.android.d.ts +0 -3
  79. package/types/generated/session-backend.ios.d.ts +0 -5
  80. package/types/generated/session-backend.linux.d.ts +0 -3
  81. package/types/generated/session-backend.macos.d.ts +0 -8
  82. package/types/generated/session-backend.web.d.ts +0 -3
  83. package/types/generated/session-backend.windows.d.ts +0 -37
  84. package/types/generated/style-merge.d.ts +0 -8
@@ -1,37 +1,17 @@
1
1
  {
2
2
  "version": 1,
3
3
  "files": [
4
- "CameraView.android.d.ts",
5
- "CameraView.ios.d.ts",
6
- "CameraView.macos.d.ts",
7
- "CameraView.mobile.d.ts",
4
+ "CameraView.d.ts",
8
5
  "CameraView.web.d.ts",
9
- "CameraView.windows.d.ts",
10
- "camera-permission.mobile.d.ts",
11
- "camera-permission.windows.d.ts",
12
- "camera-session.ios.d.ts",
13
- "camera-session.macos.d.ts",
14
- "camera-session.windows.d.ts",
15
- "host-movie.web.d.ts",
6
+ "camera-host.macos.d.ts",
16
7
  "index.d.ts",
17
- "index.web.d.ts",
18
- "layout-child.d.ts",
19
8
  "layout-child.web.d.ts",
20
- "layout-child.windows.d.ts",
21
- "movie-metadata.web.d.ts",
22
- "movie-storage.web.d.ts",
23
- "preview-tap.d.ts",
9
+ "photo-lifecycle.macos.d.ts",
10
+ "photo-sheet.macos.d.ts",
24
11
  "props.d.ts",
25
- "session-backend.android.d.ts",
26
12
  "session-backend.d.ts",
27
- "session-backend.ios.d.ts",
28
- "session-backend.linux.d.ts",
29
- "session-backend.macos.d.ts",
30
- "session-backend.web.d.ts",
31
- "session-backend.windows.d.ts",
32
13
  "session-core.d.ts",
33
14
  "session.d.ts",
34
- "style-merge.d.ts",
35
15
  "synthetic-session.d.ts",
36
16
  "types.d.ts"
37
17
  ]
@@ -0,0 +1,2 @@
1
+ /** @jsxImportSource octane */
2
+ export declare const CameraView: typeof import('./CameraView.web.js').CameraView;
@@ -0,0 +1,33 @@
1
+ export interface CameraHost {
2
+ attachPreview(view: object): string | null;
3
+ detachPreview(): void;
4
+ installObserver(listener: (message: string) => void): void;
5
+ permissionStatus(kind: string): string;
6
+ requestPermissionReply(kind: string, reply: (status: string) => void): void;
7
+ devices(): string;
8
+ audioDeviceAvailable(): boolean;
9
+ audioInputAttached(): boolean;
10
+ activeDeviceId(): string | null;
11
+ configure(options: {
12
+ cameraId?: string;
13
+ photo?: boolean;
14
+ audio?: boolean;
15
+ rotationAngle?: number;
16
+ }): string | null;
17
+ focusAtPoint(point: {
18
+ x: number;
19
+ y: number;
20
+ }): boolean;
21
+ supportsRotationAngles(): boolean;
22
+ movieDirectory(): string | null;
23
+ startRecording(path: string, maximumDurationMs: number): string | null;
24
+ stopRecording(): void;
25
+ recording(): boolean;
26
+ recordedMs(): number;
27
+ previewSize(): string;
28
+ capturePhoto(reply: (data: unknown) => void): string | null;
29
+ dispose(): void;
30
+ }
31
+ /** One capture host: an AVCaptureSession shared by an optional preview layer,
32
+ * one still-photo output and one movie-file output at a time. */
33
+ export declare function createCameraHost(): CameraHost;
@@ -1,33 +1,34 @@
1
- export { CameraView } from './CameraView.mobile.js'
1
+ export { CameraView } from './CameraView.js'
2
2
  export type { CameraAccessibilityRole, CameraViewHandle, CameraViewProps } from './props.js'
3
3
  export { createCameraSession } from './session.js'
4
4
  export { CameraCaptureError } from './types.js'
5
5
  export type {
6
- CameraCaptureErrorKind,
7
- CameraDeviceInfo,
8
- CameraFacing,
9
- CameraInterruptionReason,
10
- CameraOrientation,
11
- CameraPermissionKind,
12
- CameraPermissionStatus,
13
- CameraPreviewPoint,
14
- CameraProfileCapability,
15
- CameraRecorderState,
16
- CameraSelection,
17
- CameraSession,
18
- CameraSessionCapabilities,
19
- CameraSessionConfig,
20
- CameraSessionEvent,
21
- CameraSessionSnapshot,
22
- CaptureIssue,
23
- EffectiveCaptureConfig,
24
- MovieClip,
25
- MovieEndReason,
26
- MovieOutcome,
27
- MovieOutput,
28
- MovieOutputHandle,
29
- MovieTake,
30
- StartRecordingOptions,
6
+ CameraCaptureErrorKind,
7
+ CameraDeviceInfo,
8
+ CameraFacing,
9
+ CameraInterruptionReason,
10
+ CameraOrientation,
11
+ CameraPermissionKind,
12
+ CameraPermissionStatus,
13
+ CameraPreviewPoint,
14
+ CameraProfileCapability,
15
+ CameraRecorderState,
16
+ CameraSelection,
17
+ CameraSession,
18
+ CameraSessionCapabilities,
19
+ CameraSessionConfig,
20
+ CameraSessionEvent,
21
+ CameraSessionSnapshot,
22
+ CaptureIssue,
23
+ EffectiveCaptureConfig,
24
+ MovieClip,
25
+ MovieEndReason,
26
+ MovieOutcome,
27
+ MovieOutput,
28
+ MovieOutputHandle,
29
+ MovieTake,
30
+ StartRecordingOptions,
31
31
  } from './types.js'
32
+
32
33
  export { createMemoryCameraStorage, createSyntheticCameraSession } from './synthetic-session.js'
33
34
  export type { SyntheticCameraScript, SyntheticCameraStorage } from './synthetic-session.js'
@@ -0,0 +1,12 @@
1
+ /** Fences every asynchronous permission, preview and shutter result — the
2
+ * PhotoCaptureLifecycle state machine, now plain JS. */
3
+ export type Phase = 'idle' | 'preparing' | 'preview' | 'capturing' | 'finished';
4
+ export declare function createPhotoCaptureLifecycle(): {
5
+ readonly phase: Phase;
6
+ prepare(): number | null;
7
+ ready(token: number): boolean;
8
+ capture(): number | null;
9
+ accepts(token: number): boolean;
10
+ finish(): boolean;
11
+ };
12
+ export type PhotoCaptureLifecycle = ReturnType<typeof createPhotoCaptureLifecycle>;
@@ -0,0 +1,36 @@
1
+ declare const SheetBase: any;
2
+ declare class XplatPhotoCaptureSheet extends SheetBase {
3
+ static ObjCProtocols: any[];
4
+ static ObjCExposedMethods: Record<string, unknown>;
5
+ private _host;
6
+ private _life;
7
+ private get host();
8
+ private get life();
9
+ private sheet;
10
+ private parent;
11
+ private reply;
12
+ private timeout;
13
+ private closeObserver;
14
+ private preview;
15
+ private captureButton;
16
+ private statusLabel;
17
+ private options;
18
+ private disposed;
19
+ private _operationTimeout;
20
+ private get operationTimeout();
21
+ permissionStatus(): string;
22
+ presentReply(options: any, reply: (result: string | null) => void): void;
23
+ ['present:reply:'](options: any, reply: (result: string | null) => void): void;
24
+ presentOnWindow(parent: any, options: Record<string, unknown>, reply: (result: string | null) => void): void;
25
+ private deadline;
26
+ ['capturePhoto'](): void;
27
+ private persist;
28
+ private persistWrite;
29
+ ['cancelPhoto'](): void;
30
+ ['windowShouldClose:'](_sender: any): boolean;
31
+ private complete;
32
+ discard(path: any): void;
33
+ ['discard:'](path: any): void;
34
+ dispose(): void;
35
+ }
36
+ export { XplatPhotoCaptureSheet };
@@ -1,5 +1,5 @@
1
1
  import type { Octane } from 'octane/jsx-runtime';
2
- import type { CameraPreviewPoint, CameraSession } from './types.js';
2
+ import type { CameraPinchEvent, CameraPreviewPoint, CameraSession } from './types.js';
3
3
  /** Accessibility roles the preview accepts. */
4
4
  export type CameraAccessibilityRole = 'button' | 'link' | 'search' | 'image' | 'heading' | 'adjustable' | 'summary' | 'text' | 'none' | 'progressbar' | 'checkbox' | 'switch' | 'radio' | 'spinbutton' | 'tab';
5
5
  /** Imperative handle exposed through the CameraView `ref`. */
@@ -63,8 +63,23 @@ export interface CameraViewProps {
63
63
  facing?: 'front' | 'back';
64
64
  /** Default true. False releases the preview session. */
65
65
  active?: boolean;
66
- /** Fires after the preview surface starts. */
66
+ /** Fires after the preview surface starts — session-backed previews
67
+ * deliver it when the camera source is feeding the shared session and
68
+ * recording can be admitted (`session.startRecording` would not be
69
+ * rejected for an idle source). It is an admission signal, not a
70
+ * displayed-frame signal: use `onDisplayReady` when a visible first
71
+ * frame must precede an automatic recording. */
67
72
  onReady?: () => void;
73
+ /** Fires when the attached surface first displays a live camera frame,
74
+ * separate from `onReady` admission. Apps that record automatically
75
+ * should wait for this so capture never starts before the user can
76
+ * see the preview. iOS 13+ reports `AVCaptureVideoPreviewLayer`
77
+ * `previewing` in non-empty bounds; Android reports the PreviewView
78
+ * `STREAMING` state; web reports the first presented video frame.
79
+ * Fires again when the displayed preview resumes after an
80
+ * interruption. Hosts without a distinct display signal — macOS,
81
+ * Windows, Linux — never fire it. */
82
+ onDisplayReady?: () => void;
68
83
  /** Camera/preview errors. */
69
84
  onError?: (error: {
70
85
  message?: string;
@@ -76,6 +91,13 @@ export interface CameraViewProps {
76
91
  * Delivered on iOS, Android, and web; desktop runtimes do not dispatch
77
92
  * it yet. */
78
93
  onTap?: (point: CameraPreviewPoint) => void;
94
+ /** Pinch gesture on the preview — fires with the cumulative `scale`
95
+ * and a preview-space `focus` (`CameraPinchEvent`). Notification-only:
96
+ * it never consumes the gesture. Pair with `session.setZoom` for
97
+ * pinch-to-zoom; a pinch state of `began` is also the point to suspend
98
+ * any ancestor pull-down gesture for. Delivered on iOS and Android;
99
+ * desktop runtimes do not dispatch it yet. */
100
+ onPinch?: (event: CameraPinchEvent) => void;
79
101
  /** Native preview surface for platform-specific controls. */
80
102
  ref?: Octane.Ref<CameraViewHandle>;
81
103
  /** Platform-specific properties applied to the preview surface. */
@@ -1,4 +1,4 @@
1
- import type { CameraInterruptionReason, CameraPermissionKind, CameraPermissionStatus, CameraPreviewPoint, CameraSession, CameraSessionCapabilities, CameraSessionConfig, CameraSessionEvent, CameraSessionSnapshot, CaptureIssue, EffectiveCaptureConfig, MovieEndReason, MovieOutput, MovieOutputHandle, MovieTake, StartRecordingOptions } from './types.js';
1
+ import type { CameraInterruptionReason, CameraDeviceInfo, CameraPermissionKind, CameraPermissionStatus, CameraPreviewPoint, CameraSession, CameraSessionCapabilities, CameraSessionConfig, CameraSessionEvent, CameraSessionSnapshot, CameraSelection, CameraZoomState, CaptureIssue, EffectiveCaptureConfig, MovieEndReason, MovieOutput, MovieOutputHandle, MovieTake, StartRecordingOptions } from './types.js';
2
2
  /** Result an adapter reports when a capture attempt settles. Media
3
3
  * metadata is already read from the finalized movie by the adapter. */
4
4
  export type BackendSettle = {
@@ -39,7 +39,14 @@ export interface BackendCaptureRequest {
39
39
  /** Adapter-owned preview attach. `listener` reports preview lifecycle;
40
40
  * returns the detach function. */
41
41
  export interface BackendPreviewListener {
42
+ /** The session can admit `startRecording` — recording-admission
43
+ * readiness, not a displayed-frame signal. */
42
44
  onReady?: () => void;
45
+ /** The attached surface displayed its first live camera frame — a
46
+ * display-readiness signal, separate from `onReady` admission.
47
+ * Adapters fire it on each transition into displayed state; hosts
48
+ * without a distinct display signal never fire it. */
49
+ onDisplayReady?: () => void;
43
50
  onError?: (issue: CaptureIssue) => void;
44
51
  }
45
52
  /** Platform adapter surface driven by the shared session core. Adapters
@@ -60,10 +67,19 @@ export interface CameraSessionBackend {
60
67
  attachPreview(host: unknown, listener?: BackendPreviewListener): () => void;
61
68
  /** Replace configuration while idle; throws CameraCaptureError. */
62
69
  configure?(config: CameraSessionConfig): void;
70
+ /** Live camera-only swap. The adapter holds recorded video and keeps
71
+ * audio/output alive. Cancellation must retire late hardware callbacks. */
72
+ switchCamera?(camera: CameraSelection): BackendCameraSwitch;
63
73
  /** Meter one autofocus/auto-exposure pass at a normalized preview-space
64
74
  * point — the tap-to-focus primitive. Absent means the adapter cannot
65
75
  * meter at a point; the core turns it into a no-op. */
66
76
  focusAtPoint?(point: CameraPreviewPoint): void;
77
+ /** Live zoom state of the bound device; absent or `undefined` means the
78
+ * adapter exposes no zoom control. */
79
+ zoomState?(): CameraZoomState | undefined;
80
+ /** Write a zoom ratio already clamped by the core. Absent means the
81
+ * adapter exposes no zoom control. */
82
+ setZoom?(ratio: number): void;
67
83
  /** Synchronous platform-specific admission checks; creates no attempt on failure. */
68
84
  validateStart?(options: StartRecordingOptions): void;
69
85
  /** Begin capture for an admitted attempt. Async failures settle via
@@ -84,6 +100,13 @@ export interface CameraSessionBackend {
84
100
  /** Lifecycle observations the adapter emits at any time. */
85
101
  setObserver(observer: BackendObserver | undefined): void;
86
102
  }
103
+ export interface BackendCameraSwitch {
104
+ completion: Promise<CameraDeviceInfo>;
105
+ /** Commit a provisionally acquired source after the lifecycle recheck.
106
+ * Cancellation must remain effective until this synchronous handoff. */
107
+ commit?(): void;
108
+ cancel(): void;
109
+ }
87
110
  export interface BackendObserver {
88
111
  interruption(phase: 'began' | 'ended', reason?: CameraInterruptionReason): void;
89
112
  availability(available: boolean): void;
@@ -111,6 +134,8 @@ export declare class SharedCameraSession implements CameraSession {
111
134
  private disposed;
112
135
  private lastCapabilities;
113
136
  private requestChains;
137
+ private activeCamera;
138
+ private cameraSwitch;
114
139
  private attempt;
115
140
  constructor(backend: CameraSessionBackend, config: CameraSessionConfig);
116
141
  /** Package-internal: attach a preview host to this session. */
@@ -135,6 +160,10 @@ export declare class SharedCameraSession implements CameraSession {
135
160
  requestPermission(kind: CameraPermissionKind): Promise<CameraPermissionStatus>;
136
161
  capabilities(): Promise<CameraSessionCapabilities>;
137
162
  focusAtPoint(point: CameraPreviewPoint): void;
163
+ zoomState(): CameraZoomState | undefined;
164
+ setZoom(ratio: number): void;
165
+ private assertConfigurable;
166
+ switchCamera(camera: CameraSelection): Promise<void>;
138
167
  configure(next: Partial<CameraSessionConfig>): Promise<void>;
139
168
  private validateCameraSelection;
140
169
  private requestStop;
@@ -34,6 +34,13 @@ export interface SyntheticCameraScript {
34
34
  /** When set, each `focusAtPoint` call pushes its normalized point
35
35
  * here so a spec can observe metering requests. */
36
36
  focusRequests?: CameraPreviewPoint[];
37
+ /** When set, the seam reports zoom control: `zoomState()` returns a
38
+ * copy and `setZoom` writes `zoom` here so specs observe requests. */
39
+ zoom?: {
40
+ zoom: number;
41
+ minZoom: number;
42
+ maxZoom: number;
43
+ };
37
44
  }
38
45
  /** Storage backing for synthetic/test camera clips. */
39
46
  export interface SyntheticCameraStorage {
@@ -59,6 +59,18 @@ export interface CameraPreviewPoint {
59
59
  /** Focus/exposure point y, normalized 0-1. */
60
60
  y: number;
61
61
  }
62
+ /** Normalized pinch on the preview: `scale` is cumulative from gesture
63
+ * start (1 = no change) and `focus` is the focal point in the same
64
+ * preview space as `CameraPreviewPoint`. */
65
+ export interface CameraPinchEvent {
66
+ /** Scale factor relative to gesture start. */
67
+ scale: number;
68
+ /** Gesture phase — began → moved → ended/cancelled. */
69
+ state: 'began' | 'moved' | 'ended' | 'cancelled';
70
+ /** Focal point normalized to the preview; falls back to the center when
71
+ * the platform does not report one. */
72
+ focus: CameraPreviewPoint;
73
+ }
62
74
  /** Capture orientation vocabulary. */
63
75
  export type CameraOrientation = 'portrait' | 'portraitUpsideDown' | 'landscapeLeft' | 'landscapeRight' | 'unspecified';
64
76
  /** Camera selection for `CameraSessionConfig.camera`. Desktop and browser
@@ -74,6 +86,14 @@ export interface CameraSessionConfig {
74
86
  * false — silent capture is a deliberate app choice, never a
75
87
  * fallback from denied microphone access. */
76
88
  audio?: boolean;
89
+ /** iOS only: allow haptics AND system sounds while this session owns microphone
90
+ * capture (including preview). Other platforms ignore this iOS audio-session
91
+ * policy. Defaults to leaving the existing app policy unchanged. The previous
92
+ * value is restored after the last opted-in camera owner stops audio capture.
93
+ * External audio-session owners must coordinate policy changes with the app. */
94
+ ios?: {
95
+ allowHapticsAndSystemSoundsDuringRecording?: boolean;
96
+ };
77
97
  /** Capture profile. `'standard'` targets 720p at 30 fps and may select
78
98
  * a device-supported alternative; the started attempt discloses the
79
99
  * actual configuration. */
@@ -91,6 +111,18 @@ export interface CameraProfileCapability {
91
111
  /** Frames per second. */
92
112
  frameRate: number;
93
113
  }
114
+ /** Live zoom state of the active camera. Ratios are relative to the
115
+ * device's unzoomed field of view: `1` is no zoom. Bounds belong to the
116
+ * currently bound device — a camera swap can change them. */
117
+ export interface CameraZoomState {
118
+ /** Current zoom ratio. */
119
+ zoom: number;
120
+ /** Minimum ratio the active device accepts (1, or below 1 when the
121
+ * device switches to a wider constituent camera). */
122
+ minZoom: number;
123
+ /** Maximum ratio the active device accepts. */
124
+ maxZoom: number;
125
+ }
94
126
  /** One usable camera device. */
95
127
  export interface CameraDeviceInfo {
96
128
  /** Device-stable camera identifier. */
@@ -117,6 +149,10 @@ export interface CameraSessionCapabilities {
117
149
  profiles: CameraProfileCapability[];
118
150
  /** The session can add an audio track when permission allows. */
119
151
  audio: boolean;
152
+ /** Live `switchCamera` preserves the take, continuous requested audio,
153
+ * held video during acquisition, and one output file. False means
154
+ * camera selection is available only through idle `configure`. */
155
+ cameraSwitchDuringRecording: boolean;
120
156
  /** `focusAtPoint` can move autofocus metering on the active camera —
121
157
  * false on fixed-focus devices (common for front cameras) and on
122
158
  * platforms without point-of-interest metering. */
@@ -124,6 +160,9 @@ export interface CameraSessionCapabilities {
124
160
  /** `focusAtPoint` can move auto-exposure metering on the active
125
161
  * camera. */
126
162
  exposurePointOfInterest: boolean;
163
+ /** The active camera reports live zoom control through `zoomState`
164
+ * and `setZoom` (`zoomState().maxZoom > minZoom`). */
165
+ zoom: boolean;
127
166
  /** Fixed orientations the source can lock for a take. */
128
167
  orientations: CameraOrientation[];
129
168
  /** `native` enforcement can still overshoot at media boundaries;
@@ -169,6 +208,11 @@ export interface EffectiveCaptureConfig {
169
208
  }
170
209
  /** Observable session state. */
171
210
  export interface CameraSessionSnapshot {
211
+ /** A live switch is pending. Recorder state remains `recording`. */
212
+ switchingCamera: boolean;
213
+ /** Latest camera confirmed by a started take or successful live switch.
214
+ * The attempt configuration remains the immutable starting config. */
215
+ activeCamera?: CameraDeviceInfo;
172
216
  /** Current lifecycle state. */
173
217
  state: CameraRecorderState;
174
218
  /** Non-prompting last-known authorization, refreshed by `permissions()`
@@ -344,9 +388,39 @@ export interface CameraSession {
344
388
  * through `configure` returns focus/exposure to the new device's
345
389
  * default. */
346
390
  focusAtPoint(point: CameraPreviewPoint): void;
391
+ /** Live zoom state of the active camera (see `CameraZoomState`).
392
+ * Returns `undefined` while no camera is bound, after `dispose`, and
393
+ * on hosts or devices without zoom control — check
394
+ * `capabilities().zoom` before showing zoom UI. Values change with
395
+ * the bound device: re-read after `configure` or `switchCamera`. */
396
+ zoomState(): CameraZoomState | undefined;
397
+ /** Writes a zoom ratio on the active camera without reconfiguring the
398
+ * session; works while recording. Values clamp to the active
399
+ * device's live `zoomState()` bounds on every write. No-ops while no
400
+ * camera is bound, after `dispose`, and on hosts without zoom
401
+ * control. Non-finite values throw `invalidArgument`. */
402
+ setZoom(ratio: number): void;
347
403
  /** Replaces configuration while idle. Validates against current
348
- * capabilities and rejects with `invalidState` during an attempt. */
404
+ * capabilities and rejects with `invalidState` during an attempt,
405
+ * including one admitted while capability discovery was pending.
406
+ * Live camera changes use `switchCamera` when advertised; rejection
407
+ * leaves the take running and does not request stop. */
349
408
  configure(config: Partial<CameraSessionConfig>): Promise<void>;
409
+ /** Change only the camera during `recording`. Audio and elapsed time
410
+ * continue while video holds its last frame. Resolves when the replacement
411
+ * camera is producing frames on the existing recording path; this is source
412
+ * readiness, not an encoded-frame acknowledgement. Completion still belongs
413
+ * to the original take. Rejects `busy` for overlapping switches,
414
+ * `invalidState` outside recording, and `unsupportedConfiguration`
415
+ * when the host cannot preserve this contract. Use idle `configure`
416
+ * before starting a take. Cancellation never restarts recording.
417
+ * @example
418
+ * import type { CameraSession } from '@octane-xplat/camera'
419
+ * async function faceFront(session: CameraSession): Promise<void> {
420
+ * await session.switchCamera('front')
421
+ * }
422
+ */
423
+ switchCamera(camera: CameraSelection): Promise<void>;
350
424
  /** Admits one capture attempt. Throws `CameraCaptureError` before
351
425
  * admission for invalid arguments, busy, invalid state, or
352
426
  * unavailable camera — no attempt is created. */
@@ -1,22 +0,0 @@
1
- import Foundation
2
-
3
- /// Shared by preview, movie and still-photo hosts. A busy source is never stolen.
4
- enum CameraOwnership {
5
- private static let lock = NSLock()
6
- private static var owners: [String: ObjectIdentifier] = [:]
7
-
8
- static func claim(_ id: String, owner: AnyObject) -> Bool {
9
- lock.lock()
10
- defer { lock.unlock() }
11
- let token = ObjectIdentifier(owner)
12
- guard owners[id] == nil || owners[id] == token else { return false }
13
- owners[id] = token
14
- return true
15
- }
16
-
17
- static func release(_ id: String, owner: AnyObject) {
18
- lock.lock()
19
- defer { lock.unlock() }
20
- if owners[id] == ObjectIdentifier(owner) { owners.removeValue(forKey: id) }
21
- }
22
- }
@@ -1,34 +0,0 @@
1
- import Foundation
2
-
3
- /// Fences every asynchronous permission, preview and shutter result.
4
- final class PhotoCaptureLifecycle {
5
- enum Phase { case idle, preparing, preview, capturing, finished }
6
- private(set) var phase = Phase.idle
7
- private(set) var generation = 0
8
- var finished: (() -> Void)?
9
-
10
- func prepare() -> Int? {
11
- guard phase == .idle else { return nil }
12
- phase = .preparing
13
- return generation
14
- }
15
- func ready(_ token: Int) -> Bool {
16
- guard accepts(token), phase == .preparing else { return false }
17
- phase = .preview
18
- return true
19
- }
20
- func capture() -> Int? {
21
- guard phase == .preview else { return nil }
22
- phase = .capturing
23
- return generation
24
- }
25
- func accepts(_ token: Int) -> Bool { phase != .finished && token == generation }
26
- @discardableResult func finish() -> Bool {
27
- guard phase != .finished else { return false }
28
- phase = .finished
29
- generation += 1
30
- finished?()
31
- finished = nil
32
- return true
33
- }
34
- }