@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.
- package/README.md +2 -132
- package/package.json +20 -25
- package/platforms/android/java/com/octanexplat/camera/CameraPreviewView.java +24 -0
- package/platforms/android/java/com/octanexplat/camera/CameraSessionBridge.java +153 -21
- package/platforms/ios/src/XplatSwitchingMovieWriter.swift +557 -0
- package/src/CameraView.android.tsrx +187 -154
- package/src/CameraView.ios.tsrx +124 -110
- package/src/CameraView.macos.tsrx +103 -96
- package/src/CameraView.tsrx +2 -0
- package/src/CameraView.web.tsrx +157 -146
- package/src/CameraView.windows.tsrx +134 -125
- package/src/camera-host.macos.ts +1059 -0
- package/src/camera-permission.mobile.ts +85 -81
- package/src/camera-permission.windows.ts +56 -53
- package/src/camera-session.ios.ts +89 -61
- package/src/camera-session.macos.ts +51 -49
- package/src/camera-session.windows.ts +113 -105
- package/src/host-movie.web.ts +257 -231
- package/src/index.ts +28 -26
- package/src/index.web.ts +27 -25
- package/src/layout-child.ts +86 -79
- package/src/layout-child.web.ts +54 -53
- package/src/layout-child.windows.ts +80 -74
- package/src/movie-metadata.web.ts +84 -81
- package/src/movie-storage.web.ts +142 -135
- package/src/movie-writer.ios.ts +170 -0
- package/src/photo-lifecycle.macos.ts +60 -0
- package/src/photo-sheet.macos.ts +505 -0
- package/src/preview-display.ios.ts +69 -0
- package/src/preview-pinch.ts +41 -0
- package/src/preview-tap.ts +22 -21
- package/src/props.ts +115 -93
- package/src/recording-haptics.ios.ts +39 -0
- package/src/recording-source.web.ts +159 -0
- package/src/session-backend.android.ts +552 -410
- package/src/session-backend.ios.ts +1500 -1148
- package/src/session-backend.linux.ts +886 -860
- package/src/session-backend.macos.ts +697 -679
- package/src/session-backend.ts +51 -49
- package/src/session-backend.web.ts +1181 -867
- package/src/session-backend.windows.ts +1540 -1467
- package/src/session-core.ts +925 -714
- package/src/session.ts +12 -12
- package/src/style-merge.ts +40 -37
- package/src/synthetic-session.ts +391 -339
- package/src/types.ts +372 -298
- package/types/generated/.tsrx-typegen-manifest.json +4 -24
- package/types/generated/CameraView.d.ts +2 -0
- package/types/generated/camera-host.macos.d.ts +33 -0
- package/types/generated/index.d.ts +27 -26
- package/types/generated/photo-lifecycle.macos.d.ts +12 -0
- package/types/generated/photo-sheet.macos.d.ts +36 -0
- package/types/generated/props.d.ts +24 -2
- package/types/generated/session-core.d.ts +30 -1
- package/types/generated/synthetic-session.d.ts +7 -0
- package/types/generated/types.d.ts +75 -1
- package/platforms/macos/src/CameraOwnership.swift +0 -22
- package/platforms/macos/src/PhotoCaptureLifecycle.swift +0 -34
- package/platforms/macos/src/XplatCameraHost.swift +0 -639
- package/platforms/macos/src/XplatPhotoCaptureSheet.swift +0 -192
- package/types/generated/CameraView.android.d.ts +0 -9
- package/types/generated/CameraView.ios.d.ts +0 -5
- package/types/generated/CameraView.macos.d.ts +0 -5
- package/types/generated/CameraView.mobile.d.ts +0 -5
- package/types/generated/CameraView.windows.d.ts +0 -11
- package/types/generated/camera-permission.mobile.d.ts +0 -2
- package/types/generated/camera-permission.windows.d.ts +0 -6
- package/types/generated/camera-session.ios.d.ts +0 -2
- package/types/generated/camera-session.macos.d.ts +0 -10
- package/types/generated/camera-session.windows.d.ts +0 -9
- package/types/generated/host-movie.web.d.ts +0 -100
- package/types/generated/index.web.d.ts +0 -7
- package/types/generated/layout-child.d.ts +0 -11
- package/types/generated/layout-child.windows.d.ts +0 -13
- package/types/generated/movie-metadata.web.d.ts +0 -9
- package/types/generated/movie-storage.web.d.ts +0 -5
- package/types/generated/preview-tap.d.ts +0 -7
- package/types/generated/session-backend.android.d.ts +0 -3
- package/types/generated/session-backend.ios.d.ts +0 -5
- package/types/generated/session-backend.linux.d.ts +0 -3
- package/types/generated/session-backend.macos.d.ts +0 -8
- package/types/generated/session-backend.web.d.ts +0 -3
- package/types/generated/session-backend.windows.d.ts +0 -37
- package/types/generated/style-merge.d.ts +0 -8
package/src/types.ts
CHANGED
|
@@ -19,66 +19,66 @@ export type CameraPermissionKind = 'camera' | 'microphone'
|
|
|
19
19
|
* `unknown` exist so hosts that cannot distinguish user denial from
|
|
20
20
|
* policy refusal do not fabricate `restricted`. */
|
|
21
21
|
export type CameraPermissionStatus =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
| 'notDetermined'
|
|
23
|
+
| 'granted'
|
|
24
|
+
| 'denied'
|
|
25
|
+
| 'restricted'
|
|
26
|
+
| 'blocked'
|
|
27
|
+
| 'unknown'
|
|
28
|
+
| 'unavailable'
|
|
29
29
|
|
|
30
30
|
/** Portable error categories. `unsupported*` covers missing host features,
|
|
31
31
|
* devices, or capture configurations — including adapters that are not
|
|
32
32
|
* implemented yet during staged delivery. */
|
|
33
33
|
export type CameraCaptureErrorKind =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
| 'permissionDenied'
|
|
35
|
+
| 'permissionRestricted'
|
|
36
|
+
| 'permissionBlocked'
|
|
37
|
+
| 'unsupportedPlatform'
|
|
38
|
+
| 'unsupportedConfiguration'
|
|
39
|
+
| 'unavailable'
|
|
40
|
+
| 'busy'
|
|
41
|
+
| 'invalidState'
|
|
42
|
+
| 'invalidArgument'
|
|
43
|
+
| 'destinationUnavailable'
|
|
44
|
+
| 'insufficientStorage'
|
|
45
|
+
| 'noMedia'
|
|
46
|
+
| 'captureFailed'
|
|
47
|
+
| 'finalizationFailed'
|
|
48
|
+
| 'storageFailed'
|
|
49
|
+
| 'configurationMissing'
|
|
50
50
|
|
|
51
51
|
/** Structured diagnostic carried by failures and non-fatal warnings. */
|
|
52
52
|
export interface CaptureIssue {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
/** Error category discriminator. */
|
|
54
|
+
kind: CameraCaptureErrorKind
|
|
55
|
+
/** Operation being attempted, e.g. 'startRecording', 'finalize'. */
|
|
56
|
+
operation: string
|
|
57
|
+
/** Human-readable failure description. */
|
|
58
|
+
message: string
|
|
59
|
+
/** Camera/mic authorization state. */
|
|
60
|
+
permission?: CameraPermissionKind
|
|
61
|
+
/** Underlying platform error when one exists — diagnostic only, never required for control flow. */
|
|
62
|
+
cause?: unknown
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/** Error thrown or settled by the session API. Satisfies `CaptureIssue`
|
|
66
66
|
* so `error.kind` drives control flow without unwrapping. */
|
|
67
67
|
export class CameraCaptureError extends Error implements CaptureIssue {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
kind: CameraCaptureErrorKind
|
|
69
|
+
operation: string
|
|
70
|
+
permission?: CameraPermissionKind
|
|
71
|
+
/** Underlying platform error when one exists — diagnostic only. */
|
|
72
|
+
cause?: unknown
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
constructor(issue: Omit<CaptureIssue, 'cause'> & { cause?: unknown }) {
|
|
75
|
+
super(issue.message)
|
|
76
|
+
this.name = 'CameraCaptureError'
|
|
77
|
+
this.kind = issue.kind
|
|
78
|
+
this.operation = issue.operation
|
|
79
|
+
this.permission = issue.permission
|
|
80
|
+
this.cause = issue.cause
|
|
81
|
+
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/** Lens direction vocabulary. */
|
|
@@ -90,19 +90,32 @@ export type CameraFacing = 'front' | 'back'
|
|
|
90
90
|
* mirroring. The `CameraView` `onTap` event and
|
|
91
91
|
* `CameraSession.focusAtPoint` share this space. */
|
|
92
92
|
export interface CameraPreviewPoint {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
/** Focus/exposure point x, normalized 0-1. */
|
|
94
|
+
x: number
|
|
95
|
+
/** Focus/exposure point y, normalized 0-1. */
|
|
96
|
+
y: number
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Normalized pinch on the preview: `scale` is cumulative from gesture
|
|
100
|
+
* start (1 = no change) and `focus` is the focal point in the same
|
|
101
|
+
* preview space as `CameraPreviewPoint`. */
|
|
102
|
+
export interface CameraPinchEvent {
|
|
103
|
+
/** Scale factor relative to gesture start. */
|
|
104
|
+
scale: number
|
|
105
|
+
/** Gesture phase — began → moved → ended/cancelled. */
|
|
106
|
+
state: 'began' | 'moved' | 'ended' | 'cancelled'
|
|
107
|
+
/** Focal point normalized to the preview; falls back to the center when
|
|
108
|
+
* the platform does not report one. */
|
|
109
|
+
focus: CameraPreviewPoint
|
|
97
110
|
}
|
|
98
111
|
|
|
99
112
|
/** Capture orientation vocabulary. */
|
|
100
113
|
export type CameraOrientation =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
| 'portrait'
|
|
115
|
+
| 'portraitUpsideDown'
|
|
116
|
+
| 'landscapeLeft'
|
|
117
|
+
| 'landscapeRight'
|
|
118
|
+
| 'unspecified'
|
|
106
119
|
|
|
107
120
|
/** Camera selection for `CameraSessionConfig.camera`. Desktop and browser
|
|
108
121
|
* hosts expose device identities instead of front/back semantics. */
|
|
@@ -110,85 +123,111 @@ export type CameraSelection = 'default' | 'front' | 'back' | { deviceId: string
|
|
|
110
123
|
|
|
111
124
|
/** Configuration for opening a session. */
|
|
112
125
|
export interface CameraSessionConfig {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
/** Lens or device identity. Default `'default'`: rear when available. */
|
|
127
|
+
camera?: CameraSelection
|
|
128
|
+
/** Include an audio track; requires microphone permission. Default
|
|
129
|
+
* false — silent capture is a deliberate app choice, never a
|
|
130
|
+
* fallback from denied microphone access. */
|
|
131
|
+
audio?: boolean
|
|
132
|
+
/** iOS only: allow haptics AND system sounds while this session owns microphone
|
|
133
|
+
* capture (including preview). Other platforms ignore this iOS audio-session
|
|
134
|
+
* policy. Defaults to leaving the existing app policy unchanged. The previous
|
|
135
|
+
* value is restored after the last opted-in camera owner stops audio capture.
|
|
136
|
+
* External audio-session owners must coordinate policy changes with the app. */
|
|
137
|
+
ios?: { allowHapticsAndSystemSoundsDuringRecording?: boolean }
|
|
138
|
+
/** Capture profile. `'standard'` targets 720p at 30 fps and may select
|
|
139
|
+
* a device-supported alternative; the started attempt discloses the
|
|
140
|
+
* actual configuration. */
|
|
141
|
+
profile?: 'standard'
|
|
123
142
|
}
|
|
124
143
|
|
|
125
144
|
/** Resolution/frame-rate combination advertised by capability discovery.
|
|
126
145
|
* Entries are supported combinations, not independent lists. */
|
|
127
146
|
export interface CameraProfileCapability {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
/** Capture profile (resolution/framerate preset). */
|
|
148
|
+
profile: 'standard'
|
|
149
|
+
/** Frame width in pixels. */
|
|
150
|
+
width: number
|
|
151
|
+
/** Frame height in pixels. */
|
|
152
|
+
height: number
|
|
153
|
+
/** Frames per second. */
|
|
154
|
+
frameRate: number
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Live zoom state of the active camera. Ratios are relative to the
|
|
158
|
+
* device's unzoomed field of view: `1` is no zoom. Bounds belong to the
|
|
159
|
+
* currently bound device — a camera swap can change them. */
|
|
160
|
+
export interface CameraZoomState {
|
|
161
|
+
/** Current zoom ratio. */
|
|
162
|
+
zoom: number
|
|
163
|
+
/** Minimum ratio the active device accepts (1, or below 1 when the
|
|
164
|
+
* device switches to a wider constituent camera). */
|
|
165
|
+
minZoom: number
|
|
166
|
+
/** Maximum ratio the active device accepts. */
|
|
167
|
+
maxZoom: number
|
|
136
168
|
}
|
|
137
169
|
|
|
138
170
|
/** One usable camera device. */
|
|
139
171
|
export interface CameraDeviceInfo {
|
|
140
|
-
|
|
141
|
-
|
|
172
|
+
/** Device-stable camera identifier. */
|
|
173
|
+
/** Store-assigned id. */
|
|
142
174
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
175
|
+
id: string
|
|
176
|
+
/** Human-readable device name. */
|
|
177
|
+
label: string
|
|
178
|
+
/** Lens direction. */
|
|
179
|
+
facing?: CameraFacing
|
|
148
180
|
}
|
|
149
181
|
|
|
150
182
|
/** What the session's host can do right now. `supported: false` means the
|
|
151
183
|
* adapter or host cannot record (reason explains); `available` reflects
|
|
152
184
|
* current hardware/permission state and changes over time. */
|
|
153
185
|
export interface CameraSessionCapabilities {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
/** A camera backend exists on this leaf. */
|
|
187
|
+
supported: boolean
|
|
188
|
+
/** Why capture is unsupported or currently unavailable. */
|
|
189
|
+
reason?: string
|
|
190
|
+
/** At least one usable camera is present. */
|
|
191
|
+
available: boolean
|
|
192
|
+
/** Detected camera devices. */
|
|
193
|
+
cameras: CameraDeviceInfo[]
|
|
194
|
+
/** Capture profiles the session can run. */
|
|
195
|
+
profiles: CameraProfileCapability[]
|
|
196
|
+
/** The session can add an audio track when permission allows. */
|
|
197
|
+
audio: boolean
|
|
198
|
+
/** Live `switchCamera` preserves the take, continuous requested audio,
|
|
199
|
+
* held video during acquisition, and one output file. False means
|
|
200
|
+
* camera selection is available only through idle `configure`. */
|
|
201
|
+
cameraSwitchDuringRecording: boolean
|
|
202
|
+
/** `focusAtPoint` can move autofocus metering on the active camera —
|
|
203
|
+
* false on fixed-focus devices (common for front cameras) and on
|
|
204
|
+
* platforms without point-of-interest metering. */
|
|
205
|
+
focusPointOfInterest: boolean
|
|
206
|
+
/** `focusAtPoint` can move auto-exposure metering on the active
|
|
207
|
+
* camera. */
|
|
208
|
+
exposurePointOfInterest: boolean
|
|
209
|
+
/** The active camera reports live zoom control through `zoomState`
|
|
210
|
+
* and `setZoom` (`zoomState().maxZoom > minZoom`). */
|
|
211
|
+
zoom: boolean
|
|
212
|
+
/** Fixed orientations the source can lock for a take. */
|
|
213
|
+
orientations: CameraOrientation[]
|
|
214
|
+
/** `native` enforcement can still overshoot at media boundaries;
|
|
215
|
+
* `bestEffort` limits are scheduled and may overshoot more. */
|
|
216
|
+
durationLimit: 'native' | 'bestEffort'
|
|
217
|
+
/** Where `elapsedMs` comes from while recording. */
|
|
218
|
+
elapsedTime: 'nativeMedia' | 'estimated'
|
|
219
|
+
/** Where the clip was written. */
|
|
220
|
+
output: {
|
|
221
|
+
/** Output MIME type. */
|
|
222
|
+
mimeType: string
|
|
223
|
+
/** File container format. */
|
|
224
|
+
container: string
|
|
225
|
+
/** `appPrivateFile` output survives dispose and app restart;
|
|
226
|
+
* `originLocal` is browser storage subject to site-data clearing. */
|
|
227
|
+
storage: 'appPrivateFile' | 'originLocal'
|
|
228
|
+
/** Accepts an app-supplied `destinationFileUrl` on start. */
|
|
229
|
+
destinationFileUrl: boolean
|
|
230
|
+
}
|
|
192
231
|
}
|
|
193
232
|
|
|
194
233
|
/** Recorder lifecycle states. */
|
|
@@ -196,233 +235,268 @@ export type CameraRecorderState = 'idle' | 'starting' | 'recording' | 'finalizin
|
|
|
196
235
|
|
|
197
236
|
/** Frozen capture configuration reported once capture actually begins. */
|
|
198
237
|
export interface EffectiveCaptureConfig {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
238
|
+
/** The CameraDeviceInfo.id in use. */
|
|
239
|
+
cameraId: string
|
|
240
|
+
/** Lens direction. */
|
|
241
|
+
facing?: CameraFacing
|
|
242
|
+
/** Whether audio capture is enabled for video. */
|
|
243
|
+
audio: boolean
|
|
244
|
+
/** Frame width in pixels. */
|
|
245
|
+
width: number
|
|
246
|
+
/** Frame height in pixels. */
|
|
247
|
+
height: number
|
|
248
|
+
/** Frames per second. */
|
|
249
|
+
frameRate: number
|
|
250
|
+
/** Capture orientation. */
|
|
251
|
+
orientation: CameraOrientation
|
|
252
|
+
/** Output MIME type. */
|
|
253
|
+
mimeType: string
|
|
254
|
+
/** File container format. */
|
|
255
|
+
container: string
|
|
217
256
|
}
|
|
218
257
|
|
|
219
258
|
/** Observable session state. */
|
|
220
259
|
export interface CameraSessionSnapshot {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
260
|
+
/** A live switch is pending. Recorder state remains `recording`. */
|
|
261
|
+
switchingCamera: boolean
|
|
262
|
+
/** Latest camera confirmed by a started take or successful live switch.
|
|
263
|
+
* The attempt configuration remains the immutable starting config. */
|
|
264
|
+
activeCamera?: CameraDeviceInfo
|
|
265
|
+
/** Current lifecycle state. */
|
|
266
|
+
state: CameraRecorderState
|
|
267
|
+
/** Non-prompting last-known authorization, refreshed by `permissions()`
|
|
268
|
+
* and `requestPermission()`. */
|
|
269
|
+
permission: Record<CameraPermissionKind, CameraPermissionStatus>
|
|
270
|
+
/** Camera hardware/driver availability, separate from recorder state. */
|
|
271
|
+
cameraAvailable: boolean
|
|
272
|
+
/** An active preview view is attached to this session. */
|
|
273
|
+
previewAttached: boolean
|
|
274
|
+
/** Interrupted by the OS (call, route change, …). */
|
|
275
|
+
interrupted: boolean
|
|
276
|
+
/** Retry count for the current operation. */
|
|
277
|
+
attempt?: {
|
|
278
|
+
/** Device-stable camera identifier. */
|
|
279
|
+
id: string
|
|
280
|
+
/** Current lifecycle state. */
|
|
281
|
+
state: 'starting' | 'recording' | 'finalizing'
|
|
282
|
+
elapsedMs: number
|
|
283
|
+
configuration?: EffectiveCaptureConfig
|
|
284
|
+
}
|
|
241
285
|
}
|
|
242
286
|
|
|
243
287
|
/** What ended a capture attempt. `interrupted` covers system suspension
|
|
244
288
|
* and preview teardown; `previewReleased` distinguishes an app-driven
|
|
245
289
|
* deactivation from an OS interruption. */
|
|
246
290
|
export type MovieEndReason =
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
291
|
+
| 'stopped'
|
|
292
|
+
| 'maximumDuration'
|
|
293
|
+
| 'interrupted'
|
|
294
|
+
| 'backgrounded'
|
|
295
|
+
| 'cameraUnavailable'
|
|
296
|
+
| 'previewReleased'
|
|
297
|
+
| 'disposed'
|
|
298
|
+
| 'captureError'
|
|
255
299
|
|
|
256
300
|
/** Portable completed-output reference. `resourceId` reopens the clip
|
|
257
301
|
* through `openOutput`; `fileUrl` additionally guarantees file-backed
|
|
258
302
|
* native output. `synthetic` marks test-seam clips. */
|
|
259
303
|
export type MovieOutput =
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
304
|
+
| {
|
|
305
|
+
/** Error category discriminator. */
|
|
306
|
+
kind: 'nativeFile'
|
|
307
|
+
/** Store handle for the clip (gallery/native ref). */
|
|
308
|
+
resourceId: string
|
|
309
|
+
/** Filesystem URL of the written clip. */
|
|
310
|
+
/** Filesystem URL of the written clip. */
|
|
267
311
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
312
|
+
fileUrl: string
|
|
313
|
+
/** True for generated/test clips, not real captures. */
|
|
314
|
+
synthetic?: boolean
|
|
315
|
+
}
|
|
316
|
+
| {
|
|
317
|
+
/** Error category discriminator. */
|
|
318
|
+
kind: 'browserStorage'
|
|
319
|
+
/** Store handle for the clip (gallery/native ref). */
|
|
320
|
+
resourceId: string
|
|
321
|
+
retention: 'persistent' | 'bestEffort'
|
|
322
|
+
/** True for generated/test clips, not real captures. */
|
|
323
|
+
synthetic?: boolean
|
|
324
|
+
}
|
|
281
325
|
|
|
282
326
|
/** One finished recording. */
|
|
283
327
|
export interface MovieClip {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
328
|
+
/** Where the clip was written. */
|
|
329
|
+
output: MovieOutput
|
|
330
|
+
/** Output MIME type. */
|
|
331
|
+
mimeType: string
|
|
332
|
+
/** Authoritative duration read from the finalized movie. */
|
|
333
|
+
durationMs: number
|
|
334
|
+
/** Presentation dimensions after the orientation transform. */
|
|
335
|
+
width: number
|
|
336
|
+
/** Frame height in pixels. */
|
|
337
|
+
height: number
|
|
338
|
+
/** Capture orientation. */
|
|
339
|
+
orientation: CameraOrientation
|
|
340
|
+
/** Whether the finalized movie actually contains an audio track.
|
|
341
|
+
* Missing requested audio is a failure, not silent capture. */
|
|
342
|
+
hasAudio: boolean
|
|
299
343
|
}
|
|
300
344
|
|
|
301
345
|
/** One immutable terminal result per admitted attempt. `partial` marks a
|
|
302
346
|
* usable clip ended early by an external condition — still a success;
|
|
303
347
|
* app review decides whether to keep it. */
|
|
304
348
|
export type MovieOutcome =
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
349
|
+
| {
|
|
350
|
+
/** Error category discriminator. */
|
|
351
|
+
kind: 'clip'
|
|
352
|
+
clip: MovieClip
|
|
353
|
+
/** Why recording stopped. */
|
|
354
|
+
endReason: MovieEndReason
|
|
355
|
+
partial: boolean
|
|
356
|
+
warning?: CaptureIssue
|
|
357
|
+
}
|
|
358
|
+
| {
|
|
359
|
+
/** Error category discriminator. */
|
|
360
|
+
kind: 'failed'
|
|
361
|
+
/** Why recording stopped. */
|
|
362
|
+
endReason: MovieEndReason
|
|
363
|
+
stage: 'preparation' | 'capture' | 'finalization' | 'storage'
|
|
364
|
+
error: CaptureIssue
|
|
365
|
+
}
|
|
322
366
|
|
|
323
367
|
/** Ordered lifecycle observation, correlated to an attempt when relevant. */
|
|
324
368
|
export type CameraSessionEvent =
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
369
|
+
| { type: 'stateChanged'; snapshot: CameraSessionSnapshot }
|
|
370
|
+
| { type: 'started'; attemptId: string; configuration: EffectiveCaptureConfig }
|
|
371
|
+
| { type: 'finished'; attemptId: string; outcome: MovieOutcome }
|
|
372
|
+
| {
|
|
373
|
+
/** Output kind discriminator. */
|
|
374
|
+
type: 'interruption'
|
|
375
|
+
phase: 'began' | 'ended'
|
|
376
|
+
reason?: CameraInterruptionReason
|
|
377
|
+
}
|
|
378
|
+
| { type: 'availability'; available: boolean }
|
|
335
379
|
|
|
336
380
|
/** Why the OS interrupted capture. */
|
|
337
381
|
export type CameraInterruptionReason =
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
382
|
+
| 'background'
|
|
383
|
+
| 'audioInUse'
|
|
384
|
+
| 'cameraInUse'
|
|
385
|
+
| 'multitasking'
|
|
386
|
+
| 'systemPressure'
|
|
387
|
+
| 'unknown'
|
|
344
388
|
|
|
345
389
|
/** Options for session.startRecording(). */
|
|
346
390
|
export interface StartRecordingOptions {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
391
|
+
/** Positive finite milliseconds. Enforcement precision comes from
|
|
392
|
+
* `capabilities().durationLimit`; the final duration is read from
|
|
393
|
+
* the movie and may overshoot. */
|
|
394
|
+
maximumDurationMs?: number
|
|
395
|
+
/** Fixed orientation for the take. Must appear in
|
|
396
|
+
* `capabilities().orientations`; omit for the source default. */
|
|
397
|
+
orientation?: CameraOrientation
|
|
398
|
+
/** App-supplied writable local `file://` URL (native hosts only,
|
|
399
|
+
* where `capabilities().output.destinationFileUrl` is true).
|
|
400
|
+
* Existing files are never overwritten. */
|
|
401
|
+
destinationFileUrl?: string
|
|
358
402
|
}
|
|
359
403
|
|
|
360
404
|
/** One admitted capture attempt. `completion` is available immediately and
|
|
361
405
|
* settles exactly once with the terminal outcome; repeated `stop()`
|
|
362
406
|
* joins the same finalization. */
|
|
363
407
|
export interface MovieTake {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
408
|
+
/** Attempt identifier — unique per `startRecording` call. */
|
|
409
|
+
readonly id: string
|
|
410
|
+
/** Lifecycle phase; terminal value is `settled` (check `completion` for the outcome). */
|
|
411
|
+
readonly state: 'starting' | 'recording' | 'finalizing' | 'settled'
|
|
412
|
+
/** Elapsed capture time in milliseconds; excludes preparation and
|
|
413
|
+
* finalization. Source identified by `capabilities().elapsedTime`. */
|
|
414
|
+
readonly elapsedMs: number
|
|
415
|
+
/** Terminal outcome — resolves exactly once; `stop()` returns this same promise. */
|
|
416
|
+
readonly completion: Promise<MovieOutcome>
|
|
417
|
+
/** Requests stop and joins finalization. Returns `completion`. */
|
|
418
|
+
stop(): Promise<MovieOutcome>
|
|
375
419
|
}
|
|
376
420
|
|
|
377
421
|
/** Reopened access to a stored clip. `release()` frees temporary access;
|
|
378
422
|
* it never deletes the clip. */
|
|
379
423
|
export interface MovieOutputHandle {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
424
|
+
/** Playable/readable location for the clip. */
|
|
425
|
+
readonly url: string
|
|
426
|
+
/** On-disk path when the clip is file-backed; absent for memory/remote storage. */
|
|
427
|
+
readonly fileUrl?: string
|
|
428
|
+
/** Free temporary access to the clip — never deletes it. */
|
|
429
|
+
release(): void
|
|
386
430
|
}
|
|
387
431
|
|
|
388
432
|
/** An owned camera session — dispose when done. */
|
|
389
433
|
export interface CameraSession {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
434
|
+
/** Non-prompting permission inspection; may return `unknown` when the
|
|
435
|
+
* host cannot observe authorization. */
|
|
436
|
+
permissions(): Promise<Record<CameraPermissionKind, CameraPermissionStatus>>
|
|
437
|
+
/** Runs the system authorization flow for one kind. Calls are
|
|
438
|
+
* serialized; a status other than `notDetermined` returns without
|
|
439
|
+
* prompting. */
|
|
440
|
+
requestPermission(kind: CameraPermissionKind): Promise<CameraPermissionStatus>
|
|
441
|
+
/** Hardware/OS limits for this session — polled live, so values can change as devices come and go. */
|
|
442
|
+
capabilities(): Promise<CameraSessionCapabilities>
|
|
443
|
+
/** Point-in-time session state — subscribe for changes. */
|
|
444
|
+
snapshot(): CameraSessionSnapshot
|
|
445
|
+
/** Ordered lifecycle events. A caller never loses a result by
|
|
446
|
+
* subscribing late — `completion` is authoritative. Listener
|
|
447
|
+
* exceptions do not change capture. */
|
|
448
|
+
subscribe(listener: (event: CameraSessionEvent) => void): () => void
|
|
449
|
+
/** Tap-to-focus: meters one autofocus/auto-exposure pass at a
|
|
450
|
+
* normalized preview-space point (see `CameraPreviewPoint`), pairing
|
|
451
|
+
* with the `CameraView` `onTap` event. No-ops while no preview is
|
|
452
|
+
* attached, after `dispose`, and on hosts without point-of-interest
|
|
453
|
+
* metering — `capabilities()` reports `focusPointOfInterest` and
|
|
454
|
+
* `exposurePointOfInterest` separately. Out-of-range coordinates
|
|
455
|
+
* clamp to the preview edge; non-finite coordinates throw
|
|
456
|
+
* `invalidArgument`. Metering is per-device state: a camera swap
|
|
457
|
+
* through `configure` returns focus/exposure to the new device's
|
|
458
|
+
* default. */
|
|
459
|
+
focusAtPoint(point: CameraPreviewPoint): void
|
|
460
|
+
/** Live zoom state of the active camera (see `CameraZoomState`).
|
|
461
|
+
* Returns `undefined` while no camera is bound, after `dispose`, and
|
|
462
|
+
* on hosts or devices without zoom control — check
|
|
463
|
+
* `capabilities().zoom` before showing zoom UI. Values change with
|
|
464
|
+
* the bound device: re-read after `configure` or `switchCamera`. */
|
|
465
|
+
zoomState(): CameraZoomState | undefined
|
|
466
|
+
/** Writes a zoom ratio on the active camera without reconfiguring the
|
|
467
|
+
* session; works while recording. Values clamp to the active
|
|
468
|
+
* device's live `zoomState()` bounds on every write. No-ops while no
|
|
469
|
+
* camera is bound, after `dispose`, and on hosts without zoom
|
|
470
|
+
* control. Non-finite values throw `invalidArgument`. */
|
|
471
|
+
setZoom(ratio: number): void
|
|
472
|
+
/** Replaces configuration while idle. Validates against current
|
|
473
|
+
* capabilities and rejects with `invalidState` during an attempt,
|
|
474
|
+
* including one admitted while capability discovery was pending.
|
|
475
|
+
* Live camera changes use `switchCamera` when advertised; rejection
|
|
476
|
+
* leaves the take running and does not request stop. */
|
|
477
|
+
configure(config: Partial<CameraSessionConfig>): Promise<void>
|
|
478
|
+
/** Change only the camera during `recording`. Audio and elapsed time
|
|
479
|
+
* continue while video holds its last frame. Resolves when the replacement
|
|
480
|
+
* camera is producing frames on the existing recording path; this is source
|
|
481
|
+
* readiness, not an encoded-frame acknowledgement. Completion still belongs
|
|
482
|
+
* to the original take. Rejects `busy` for overlapping switches,
|
|
483
|
+
* `invalidState` outside recording, and `unsupportedConfiguration`
|
|
484
|
+
* when the host cannot preserve this contract. Use idle `configure`
|
|
485
|
+
* before starting a take. Cancellation never restarts recording.
|
|
486
|
+
* @example
|
|
487
|
+
* import type { CameraSession } from '@octane-xplat/camera'
|
|
488
|
+
* async function faceFront(session: CameraSession): Promise<void> {
|
|
489
|
+
* await session.switchCamera('front')
|
|
490
|
+
* }
|
|
491
|
+
*/
|
|
492
|
+
switchCamera(camera: CameraSelection): Promise<void>
|
|
493
|
+
/** Admits one capture attempt. Throws `CameraCaptureError` before
|
|
494
|
+
* admission for invalid arguments, busy, invalid state, or
|
|
495
|
+
* unavailable camera — no attempt is created. */
|
|
496
|
+
startRecording(options?: StartRecordingOptions): MovieTake
|
|
497
|
+
/** Reopens a stored output for playback or reading. */
|
|
498
|
+
openOutput(output: MovieOutput): Promise<MovieOutputHandle>
|
|
499
|
+
/** Requests stop on any active attempt, awaits finalization, then
|
|
500
|
+
* releases camera ownership. */
|
|
501
|
+
dispose(): Promise<void>
|
|
428
502
|
}
|