@appium/coresim 1.3.0 → 1.5.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/CHANGELOG.md +12 -0
- package/binding.gyp +7 -1
- package/lib/src/commands/process.d.ts.map +1 -1
- package/lib/src/commands/process.js +3 -4
- package/lib/src/commands/process.js.map +1 -1
- package/lib/src/commands/spawn.d.ts +9 -5
- package/lib/src/commands/spawn.d.ts.map +1 -1
- package/lib/src/commands/spawn.js +9 -5
- package/lib/src/commands/spawn.js.map +1 -1
- package/lib/src/commands/video-recording.d.ts +50 -0
- package/lib/src/commands/video-recording.d.ts.map +1 -0
- package/lib/src/commands/video-recording.js +98 -0
- package/lib/src/commands/video-recording.js.map +1 -0
- package/lib/src/commands/video-stream.d.ts +44 -0
- package/lib/src/commands/video-stream.d.ts.map +1 -0
- package/lib/src/commands/video-stream.js +240 -0
- package/lib/src/commands/video-stream.js.map +1 -0
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +1 -0
- package/lib/src/index.js.map +1 -1
- package/lib/src/native-simctl.d.ts +4 -0
- package/lib/src/native-simctl.d.ts.map +1 -1
- package/lib/src/native-simctl.js +9 -0
- package/lib/src/native-simctl.js.map +1 -1
- package/lib/src/types.d.ts +72 -0
- package/lib/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@appium+coresim.node +0 -0
- package/src/commands/process.ts +3 -4
- package/src/commands/spawn.ts +9 -5
- package/src/commands/video-recording.ts +128 -0
- package/src/commands/video-stream.ts +274 -0
- package/src/coresim.mm +310 -4
- package/src/index.ts +4 -0
- package/src/native/sim_screenshot.h +10 -0
- package/src/native/sim_screenshot.mm +11 -6
- package/src/native/sim_video_recording.h +27 -0
- package/src/native/sim_video_recording.mm +87 -0
- package/src/native/sim_video_stream.h +61 -0
- package/src/native/sim_video_stream.mm +427 -0
- package/src/native-simctl.ts +10 -0
- package/src/types.ts +76 -0
package/src/types.ts
CHANGED
|
@@ -128,6 +128,54 @@ export interface ScreenshotOptions {
|
|
|
128
128
|
quality?: number;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/** Options for `NativeSimctl.startVideoRecording`. */
|
|
132
|
+
export interface VideoRecordingOptions {
|
|
133
|
+
/**
|
|
134
|
+
* Which display to record, by `id` from `getDisplays()`. Defaults to the primary display
|
|
135
|
+
* (falling back to the first renderable display if none is primary, e.g. tvOS).
|
|
136
|
+
*/
|
|
137
|
+
displayId?: string;
|
|
138
|
+
/** Video codec — `'h264'` (default) or `'hevc'`. */
|
|
139
|
+
codec?: 'h264' | 'hevc';
|
|
140
|
+
/**
|
|
141
|
+
* For a non-rectangular display (e.g. a Dynamic Island cutout): `'ignored'` (default) saves the
|
|
142
|
+
* unmasked framebuffer, `'black'` renders the mask black, `'alpha'` is not supported and
|
|
143
|
+
* behaves like `'black'`.
|
|
144
|
+
*/
|
|
145
|
+
mask?: 'ignored' | 'alpha' | 'black';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Options for `NativeSimctl.startVideoStream`. */
|
|
149
|
+
export interface VideoStreamOptions {
|
|
150
|
+
/**
|
|
151
|
+
* Which display to stream, by `id` from `getDisplays()`. Defaults to the primary display
|
|
152
|
+
* (falling back to the first renderable display if none is primary, e.g. tvOS).
|
|
153
|
+
*/
|
|
154
|
+
displayId?: string;
|
|
155
|
+
/** Video codec — `'h264'` (default) or `'hevc'`. */
|
|
156
|
+
codec?: 'h264' | 'hevc';
|
|
157
|
+
/**
|
|
158
|
+
* Max frames/sec to poll the framebuffer at — an unchanged frame is never re-encoded, so this
|
|
159
|
+
* is an upper bound, not a guarantee. Must be >= 1. Defaults to 15.
|
|
160
|
+
*/
|
|
161
|
+
fps?: number;
|
|
162
|
+
/** Target average bitrate, in bits/sec. Defaults to 2,000,000 (2 Mbps). */
|
|
163
|
+
bitrate?: number;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* One encoded frame from `VideoStream.accessUnits()` — Annex-B NAL units. A keyframe's `data` has
|
|
168
|
+
* parameter sets (SPS/PPS, or VPS/SPS/PPS for HEVC) prepended, so it's self-decodable alone.
|
|
169
|
+
*/
|
|
170
|
+
export interface VideoAccessUnit {
|
|
171
|
+
data: Buffer;
|
|
172
|
+
isKeyFrame: boolean;
|
|
173
|
+
/** Monotonically increasing per stream, starting at 0. */
|
|
174
|
+
sequence: number;
|
|
175
|
+
/** Microseconds since the stream started. */
|
|
176
|
+
timestampMicros: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
131
179
|
/**
|
|
132
180
|
* Options for `NativeSimctl.spawnProcess`, passed through to CoreSimulator's
|
|
133
181
|
* `spawnWithPath:options:terminationQueue:terminationHandler:error:`. Only keys confirmed
|
|
@@ -230,6 +278,24 @@ export interface NativeSpawnResult {
|
|
|
230
278
|
*/
|
|
231
279
|
export type NativeSpawnExitCallback = (code: number | null, signal: number | null) => void;
|
|
232
280
|
|
|
281
|
+
/** Raw shape of an access unit as the native addon delivers it — see {@link VideoAccessUnit}. */
|
|
282
|
+
export interface NativeVideoAccessUnit {
|
|
283
|
+
data: Buffer;
|
|
284
|
+
isKeyFrame: boolean;
|
|
285
|
+
sequence: number;
|
|
286
|
+
timestampMicros: number;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export type NativeVideoAccessUnitCallback = (unit: NativeVideoAccessUnit) => void;
|
|
290
|
+
export type NativeVideoErrorCallback = (err: Error) => void;
|
|
291
|
+
|
|
292
|
+
/** A live encoder session, wrapped by `coresim.mm`'s `NativeVideoStream` — what `NativeDeviceHandle.startVideoStream()` resolves to. */
|
|
293
|
+
export interface NativeVideoStreamHandle {
|
|
294
|
+
stop(): Promise<void>;
|
|
295
|
+
/** Forces the next encoded frame to be a keyframe — trivial in-memory flag, so synchronous. */
|
|
296
|
+
requestKeyFrame(): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
233
299
|
/** A `SimDevice`, wrapped by `coresim.mm`'s `NativeDevice` — what `NativeSimctl`'s `_findDevice()` resolves to. */
|
|
234
300
|
export interface NativeDeviceHandle {
|
|
235
301
|
// Trivial in-memory accessors — kept synchronous on the native side (see coresim.mm), never a
|
|
@@ -278,6 +344,16 @@ export interface NativeDeviceHandle {
|
|
|
278
344
|
getWebInspectorSocket(): Promise<string>;
|
|
279
345
|
screenshot(options?: {format?: 'png' | 'jpeg'; displayId?: string; quality?: number}): Promise<Buffer>;
|
|
280
346
|
getDisplays(): Promise<SimDisplayInfo[]>;
|
|
347
|
+
startVideoRecording(
|
|
348
|
+
outputFile: string,
|
|
349
|
+
options?: {displayId?: string; codec?: 'h264' | 'hevc'; mask?: 'ignored' | 'alpha' | 'black'},
|
|
350
|
+
): Promise<void>;
|
|
351
|
+
stopVideoRecording(): Promise<void>;
|
|
352
|
+
startVideoStream(
|
|
353
|
+
options: {displayId?: string; codec?: 'h264' | 'hevc'; fps?: number; bitrate?: number} | undefined,
|
|
354
|
+
onAccessUnit: NativeVideoAccessUnitCallback,
|
|
355
|
+
onError: NativeVideoErrorCallback,
|
|
356
|
+
): Promise<NativeVideoStreamHandle>;
|
|
281
357
|
spawn(path: string, options: SpawnOptions | undefined, onExit: NativeSpawnExitCallback): Promise<NativeSpawnResult>;
|
|
282
358
|
}
|
|
283
359
|
|