appium-xcuitest-driver 13.2.0 → 13.3.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 +6 -0
- package/build/lib/commands/media-stream.d.ts +34 -0
- package/build/lib/commands/media-stream.d.ts.map +1 -0
- package/build/lib/commands/media-stream.js +230 -0
- package/build/lib/commands/media-stream.js.map +1 -0
- package/build/lib/device/media-stream/batcher.d.ts +17 -0
- package/build/lib/device/media-stream/batcher.d.ts.map +1 -0
- package/build/lib/device/media-stream/batcher.js +48 -0
- package/build/lib/device/media-stream/batcher.js.map +1 -0
- package/build/lib/device/media-stream/constants.d.ts +20 -0
- package/build/lib/device/media-stream/constants.d.ts.map +1 -0
- package/build/lib/device/media-stream/constants.js +23 -0
- package/build/lib/device/media-stream/constants.js.map +1 -0
- package/build/lib/device/media-stream/device-source.d.ts +39 -0
- package/build/lib/device/media-stream/device-source.d.ts.map +1 -0
- package/build/lib/device/media-stream/device-source.js +229 -0
- package/build/lib/device/media-stream/device-source.js.map +1 -0
- package/build/lib/device/media-stream/jpeg.d.ts +6 -0
- package/build/lib/device/media-stream/jpeg.d.ts.map +1 -0
- package/build/lib/device/media-stream/jpeg.js +17 -0
- package/build/lib/device/media-stream/jpeg.js.map +1 -0
- package/build/lib/device/media-stream/media-proxy.d.ts +13 -0
- package/build/lib/device/media-stream/media-proxy.d.ts.map +1 -0
- package/build/lib/device/media-stream/media-proxy.js +33 -0
- package/build/lib/device/media-stream/media-proxy.js.map +1 -0
- package/build/lib/device/media-stream/orientation.d.ts +22 -0
- package/build/lib/device/media-stream/orientation.d.ts.map +1 -0
- package/build/lib/device/media-stream/orientation.js +35 -0
- package/build/lib/device/media-stream/orientation.js.map +1 -0
- package/build/lib/device/media-stream/simulator-source.d.ts +16 -0
- package/build/lib/device/media-stream/simulator-source.d.ts.map +1 -0
- package/build/lib/device/media-stream/simulator-source.js +45 -0
- package/build/lib/device/media-stream/simulator-source.js.map +1 -0
- package/build/lib/device/media-stream/sps.d.ts +12 -0
- package/build/lib/device/media-stream/sps.d.ts.map +1 -0
- package/build/lib/device/media-stream/sps.js +196 -0
- package/build/lib/device/media-stream/sps.js.map +1 -0
- package/build/lib/device/media-stream/stream.d.ts +70 -0
- package/build/lib/device/media-stream/stream.d.ts.map +1 -0
- package/build/lib/device/media-stream/stream.js +356 -0
- package/build/lib/device/media-stream/stream.js.map +1 -0
- package/build/lib/device/media-stream/types.d.ts +73 -0
- package/build/lib/device/media-stream/types.d.ts.map +1 -0
- package/build/lib/device/media-stream/types.js +2 -0
- package/build/lib/device/media-stream/types.js.map +1 -0
- package/build/lib/driver.d.ts +20 -0
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +14 -0
- package/build/lib/driver.js.map +1 -1
- package/build/lib/execute-method-map.d.ts +16 -0
- package/build/lib/execute-method-map.d.ts.map +1 -1
- package/build/lib/execute-method-map.js +16 -0
- package/build/lib/execute-method-map.js.map +1 -1
- package/lib/commands/media-stream.ts +315 -0
- package/lib/device/media-stream/batcher.ts +51 -0
- package/lib/device/media-stream/constants.ts +22 -0
- package/lib/device/media-stream/device-source.ts +265 -0
- package/lib/device/media-stream/jpeg.ts +16 -0
- package/lib/device/media-stream/media-proxy.ts +45 -0
- package/lib/device/media-stream/orientation.ts +55 -0
- package/lib/device/media-stream/simulator-source.ts +55 -0
- package/lib/device/media-stream/sps.ts +208 -0
- package/lib/device/media-stream/stream.ts +404 -0
- package/lib/device/media-stream/types.ts +83 -0
- package/lib/driver.ts +15 -0
- package/lib/execute-method-map.ts +16 -0
- package/node_modules/@appium/media-proxy/CHANGELOG.md +33 -0
- package/node_modules/@appium/media-proxy/LICENSE +201 -0
- package/node_modules/@appium/media-proxy/README.md +185 -0
- package/node_modules/@appium/media-proxy/THIRD_PARTY_NOTICES.md +29 -0
- package/node_modules/@appium/media-proxy/binding.gyp +90 -0
- package/node_modules/@appium/media-proxy/lib/src/background.d.ts +5 -0
- package/node_modules/@appium/media-proxy/lib/src/background.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/background.js +16 -0
- package/node_modules/@appium/media-proxy/lib/src/background.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/capabilities.d.ts +9 -0
- package/node_modules/@appium/media-proxy/lib/src/capabilities.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/capabilities.js +11 -0
- package/node_modules/@appium/media-proxy/lib/src/capabilities.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/errors.d.ts +26 -0
- package/node_modules/@appium/media-proxy/lib/src/errors.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/errors.js +40 -0
- package/node_modules/@appium/media-proxy/lib/src/errors.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/apst.d.ts +43 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/apst.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/apst.js +126 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/apst.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/mjpeg-http.d.ts +30 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/mjpeg-http.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/mjpeg-http.js +148 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/mjpeg-http.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/mjpeg-multipart.d.ts +11 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/mjpeg-multipart.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/mjpeg-multipart.js +26 -0
- package/node_modules/@appium/media-proxy/lib/src/framing/mjpeg-multipart.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/index.d.ts +10 -0
- package/node_modules/@appium/media-proxy/lib/src/index.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/index.js +7 -0
- package/node_modules/@appium/media-proxy/lib/src/index.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/native.d.ts +12 -0
- package/node_modules/@appium/media-proxy/lib/src/native.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/native.js +36 -0
- package/node_modules/@appium/media-proxy/lib/src/native.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/pkg-root.d.ts +6 -0
- package/node_modules/@appium/media-proxy/lib/src/pkg-root.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/pkg-root.js +12 -0
- package/node_modules/@appium/media-proxy/lib/src/pkg-root.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/queue.d.ts +34 -0
- package/node_modules/@appium/media-proxy/lib/src/queue.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/queue.js +123 -0
- package/node_modules/@appium/media-proxy/lib/src/queue.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/transcoder.d.ts +81 -0
- package/node_modules/@appium/media-proxy/lib/src/transcoder.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/transcoder.js +422 -0
- package/node_modules/@appium/media-proxy/lib/src/transcoder.js.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/types.d.ts +147 -0
- package/node_modules/@appium/media-proxy/lib/src/types.d.ts.map +1 -0
- package/node_modules/@appium/media-proxy/lib/src/types.js +2 -0
- package/node_modules/@appium/media-proxy/lib/src/types.js.map +1 -0
- package/node_modules/@appium/media-proxy/package.json +67 -0
- package/node_modules/@appium/media-proxy/prebuilds/darwin-arm64/@appium+media-proxy.node +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/darwin-arm64/ffmpeg-LICENSE-LGPL-2.1.txt +502 -0
- package/node_modules/@appium/media-proxy/prebuilds/darwin-arm64/ffmpeg-build-info.txt +3 -0
- package/node_modules/@appium/media-proxy/prebuilds/darwin-arm64/libavcodec-appium.62.dylib +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/darwin-arm64/libavutil-appium.60.dylib +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/darwin-arm64/libswscale-appium.9.dylib +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-arm64/@appium+media-proxy.node +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-arm64/ffmpeg-LICENSE-LGPL-2.1.txt +502 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-arm64/ffmpeg-build-info.txt +3 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-arm64/libavcodec-appium.so.62 +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-arm64/libavutil-appium.so.60 +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-arm64/libswscale-appium.so.9 +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-x64/@appium+media-proxy.node +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-x64/ffmpeg-LICENSE-LGPL-2.1.txt +502 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-x64/ffmpeg-build-info.txt +3 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-x64/libavcodec-appium.so.62 +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-x64/libavutil-appium.so.60 +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/linux-x64/libswscale-appium.so.9 +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/win32-x64/@appium+media-proxy.node +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/win32-x64/avcodec-appium-62.dll +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/win32-x64/avutil-appium-60.dll +0 -0
- package/node_modules/@appium/media-proxy/prebuilds/win32-x64/ffmpeg-LICENSE-LGPL-2.1.txt +502 -0
- package/node_modules/@appium/media-proxy/prebuilds/win32-x64/ffmpeg-build-info.txt +3 -0
- package/node_modules/@appium/media-proxy/prebuilds/win32-x64/swscale-appium-9.dll +0 -0
- package/node_modules/@appium/media-proxy/scripts/install.mjs +29 -0
- package/node_modules/@appium/media-proxy/src/background.ts +15 -0
- package/node_modules/@appium/media-proxy/src/capabilities.ts +12 -0
- package/node_modules/@appium/media-proxy/src/errors.ts +45 -0
- package/node_modules/@appium/media-proxy/src/framing/apst.ts +158 -0
- package/node_modules/@appium/media-proxy/src/framing/mjpeg-http.ts +186 -0
- package/node_modules/@appium/media-proxy/src/framing/mjpeg-multipart.ts +38 -0
- package/node_modules/@appium/media-proxy/src/index.ts +43 -0
- package/node_modules/@appium/media-proxy/src/native/addon.cc +402 -0
- package/node_modules/@appium/media-proxy/src/native/audio_pipeline.cc +426 -0
- package/node_modules/@appium/media-proxy/src/native/audio_pipeline.h +63 -0
- package/node_modules/@appium/media-proxy/src/native/ffmpeg_util.h +37 -0
- package/node_modules/@appium/media-proxy/src/native/h264_encoder.cc +133 -0
- package/node_modules/@appium/media-proxy/src/native/h264_encoder.h +48 -0
- package/node_modules/@appium/media-proxy/src/native/mediafoundation_encoder.cc +442 -0
- package/node_modules/@appium/media-proxy/src/native/mediafoundation_encoder.h +14 -0
- package/node_modules/@appium/media-proxy/src/native/napi_util.h +20 -0
- package/node_modules/@appium/media-proxy/src/native/openh264_encoder.cc +285 -0
- package/node_modules/@appium/media-proxy/src/native/openh264_encoder.h +14 -0
- package/node_modules/@appium/media-proxy/src/native/pipeline.cc +555 -0
- package/node_modules/@appium/media-proxy/src/native/pipeline.h +108 -0
- package/node_modules/@appium/media-proxy/src/native/vendor/openh264/LICENSE +23 -0
- package/node_modules/@appium/media-proxy/src/native/vendor/openh264/codec_api.h +592 -0
- package/node_modules/@appium/media-proxy/src/native/vendor/openh264/codec_app_def.h +820 -0
- package/node_modules/@appium/media-proxy/src/native/vendor/openh264/codec_def.h +216 -0
- package/node_modules/@appium/media-proxy/src/native/vendor/openh264/codec_ver.h +15 -0
- package/node_modules/@appium/media-proxy/src/native/videotoolbox_encoder.cc +314 -0
- package/node_modules/@appium/media-proxy/src/native/videotoolbox_encoder.h +13 -0
- package/node_modules/@appium/media-proxy/src/native.ts +51 -0
- package/node_modules/@appium/media-proxy/src/pkg-root.ts +14 -0
- package/node_modules/@appium/media-proxy/src/queue.ts +133 -0
- package/node_modules/@appium/media-proxy/src/transcoder.ts +480 -0
- package/node_modules/@appium/media-proxy/src/types.ts +158 -0
- package/node_modules/bare-fs/package.json +2 -2
- package/node_modules/bare-fs/prebuilds/darwin-arm64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/linux-arm64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/linux-x64/bare-fs.bare +0 -0
- package/node_modules/bare-fs/prebuilds/win32-x64/bare-fs.bare +0 -0
- package/node_modules/plist/dist/parse-binary.d.ts.map +1 -1
- package/node_modules/plist/dist/parse-binary.js +37 -9
- package/node_modules/plist/dist/parse-binary.js.map +1 -1
- package/node_modules/plist/package.json +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { loadRemoteXPCModule } from '../remote-xpc/module-loader.js';
|
|
2
|
+
import { explainEncoderError, loadMediaProxy } from './media-proxy.js';
|
|
3
|
+
import { parseDisplayGeometry } from './orientation.js';
|
|
4
|
+
/** How often the display's orientation is read; a rotation shows up within this time (plus its animation) */
|
|
5
|
+
const ORIENTATION_POLL_MS = 1000;
|
|
6
|
+
/** The device sends one IDR and its picture drifts after large screen changes, so remotexpc asks for new ones */
|
|
7
|
+
const KEYFRAME_INTERVAL_MS = 2000;
|
|
8
|
+
/** The device's video RTP clock (400 ticks per frame at 60 fps), not the 90 kHz of RFC 7798 */
|
|
9
|
+
const VIDEO_CLOCK_RATE = 24_000;
|
|
10
|
+
/** Asks the device whether it can stream its screen; opens and closes a display service for that */
|
|
11
|
+
export async function isDeviceStreamingSupported(facade) {
|
|
12
|
+
const display = (await facade.requireTunnelService('media streaming', (services) => services.startDisplayService(facade.udid)));
|
|
13
|
+
try {
|
|
14
|
+
return await display.isStreamingSupported();
|
|
15
|
+
}
|
|
16
|
+
finally {
|
|
17
|
+
await display.close().catch(() => { });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Real device (iOS/tvOS 27+): remotexpc captures the HEVC screen stream over the tunnel and
|
|
22
|
+
* media-proxy transcodes it to H.264 or MJPEG.
|
|
23
|
+
*/
|
|
24
|
+
export class DeviceMediaSource {
|
|
25
|
+
facade;
|
|
26
|
+
opts;
|
|
27
|
+
log;
|
|
28
|
+
display;
|
|
29
|
+
capture;
|
|
30
|
+
audioCapture;
|
|
31
|
+
audioFeeder;
|
|
32
|
+
transcoder;
|
|
33
|
+
feeder;
|
|
34
|
+
orientationTimer;
|
|
35
|
+
infoService;
|
|
36
|
+
rotation = 0;
|
|
37
|
+
polling = false;
|
|
38
|
+
failure;
|
|
39
|
+
starting;
|
|
40
|
+
stopping;
|
|
41
|
+
constructor(facade, opts, log) {
|
|
42
|
+
this.facade = facade;
|
|
43
|
+
this.opts = opts;
|
|
44
|
+
this.log = log;
|
|
45
|
+
}
|
|
46
|
+
async start() {
|
|
47
|
+
this.starting = this.open();
|
|
48
|
+
await this.starting;
|
|
49
|
+
}
|
|
50
|
+
async open() {
|
|
51
|
+
const { opts } = this;
|
|
52
|
+
const mediaProxy = await loadMediaProxy();
|
|
53
|
+
const { ScreenStreamCapture, AudioStreamCapture, XPCUUID, AAC_ELD_FORMAT } = await loadRemoteXPCModule();
|
|
54
|
+
const withAudio = opts.kind === 'video' && Boolean(opts.audio);
|
|
55
|
+
const displayId = opts.displayId === undefined ? undefined : Number(opts.displayId);
|
|
56
|
+
const geometry = await this.readGeometry(displayId);
|
|
57
|
+
const input = {
|
|
58
|
+
videoClockRate: VIDEO_CLOCK_RATE,
|
|
59
|
+
// Without the size the padding stays; without the orientation a landscape UI stays turned
|
|
60
|
+
...(geometry && isEven(geometry.width) && isEven(geometry.height)
|
|
61
|
+
? { crop: { width: geometry.width, height: geometry.height } }
|
|
62
|
+
: {}),
|
|
63
|
+
rotation: geometry?.rotation ?? 0,
|
|
64
|
+
};
|
|
65
|
+
this.rotation = input.rotation;
|
|
66
|
+
// Fails here, before the device starts streaming, if the addon or an encoder is missing
|
|
67
|
+
let transcoder;
|
|
68
|
+
try {
|
|
69
|
+
transcoder =
|
|
70
|
+
opts.kind === 'video'
|
|
71
|
+
? mediaProxy.createTranscoder({
|
|
72
|
+
codec: 'h264',
|
|
73
|
+
fps: opts.fps,
|
|
74
|
+
bitrate: opts.bitrate,
|
|
75
|
+
...(withAudio ? { audio: true, audioSpecificConfig: AAC_ELD_FORMAT.audioSpecificConfig } : {}),
|
|
76
|
+
...input,
|
|
77
|
+
})
|
|
78
|
+
: mediaProxy.createTranscoder({
|
|
79
|
+
codec: 'mjpeg',
|
|
80
|
+
fps: opts.fps,
|
|
81
|
+
quality: opts.quality,
|
|
82
|
+
scale: opts.scale,
|
|
83
|
+
...input,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
throw explainEncoderError(e);
|
|
88
|
+
}
|
|
89
|
+
this.transcoder = transcoder;
|
|
90
|
+
try {
|
|
91
|
+
const display = (await this.facade.requireTunnelService('media streaming', (services) => services.startDisplayService(this.facade.udid)));
|
|
92
|
+
this.display = display;
|
|
93
|
+
if (!(await display.isStreamingSupported())) {
|
|
94
|
+
throw new Error('The device does not support media streaming (requires iOS/tvOS 27+)');
|
|
95
|
+
}
|
|
96
|
+
// One session id pairs the video and audio streams, as Xcode's mirror does
|
|
97
|
+
const clientSessionId = withAudio ? XPCUUID.random() : undefined;
|
|
98
|
+
this.capture = (await ScreenStreamCapture.start(display, {
|
|
99
|
+
displayId,
|
|
100
|
+
keyFrameIntervalMs: KEYFRAME_INTERVAL_MS,
|
|
101
|
+
...(clientSessionId ? { clientSessionId } : {}),
|
|
102
|
+
}));
|
|
103
|
+
if (clientSessionId) {
|
|
104
|
+
this.audioCapture = (await AudioStreamCapture.start(display, {
|
|
105
|
+
clientSessionId,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
this.orientationTimer = setInterval(() => void this.pollOrientation(displayId), ORIENTATION_POLL_MS);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
await this.teardown();
|
|
112
|
+
throw e;
|
|
113
|
+
}
|
|
114
|
+
this.feeder = this.feed(this.capture, transcoder);
|
|
115
|
+
if (this.audioCapture) {
|
|
116
|
+
this.audioFeeder = this.feedAudio(this.audioCapture, transcoder);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Optional: a device that cannot report its display still streams, just without crop and rotation
|
|
120
|
+
async readGeometry(displayId) {
|
|
121
|
+
try {
|
|
122
|
+
const service = (await this.facade.requireTunnelService('media streaming', (services) => services.startCoreDeviceInfoService(this.facade.udid)));
|
|
123
|
+
this.infoService = service;
|
|
124
|
+
return parseDisplayGeometry(await service.getDisplayInfo(), displayId);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
this.log.warn(`Cannot read the display geometry, the stream is not cropped or rotated: ${e.message}`);
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async pollOrientation(displayId) {
|
|
132
|
+
const { infoService, transcoder } = this;
|
|
133
|
+
if (!infoService || !transcoder || this.polling) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.polling = true;
|
|
137
|
+
try {
|
|
138
|
+
const rotation = parseDisplayGeometry(await infoService.getDisplayInfo(), displayId)?.rotation;
|
|
139
|
+
if (rotation !== undefined && rotation !== this.rotation) {
|
|
140
|
+
this.log.debug(`The display rotated from ${this.rotation} to ${rotation} degrees`);
|
|
141
|
+
this.rotation = rotation;
|
|
142
|
+
transcoder.setRotation(rotation);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
this.log.debug(`Cannot read the display orientation: ${e.message}`);
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
this.polling = false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async *units() {
|
|
153
|
+
const { transcoder } = this;
|
|
154
|
+
if (!transcoder) {
|
|
155
|
+
throw new Error('The source has not been started');
|
|
156
|
+
}
|
|
157
|
+
const isVideo = this.opts.kind === 'video';
|
|
158
|
+
for await (const u of transcoder.units()) {
|
|
159
|
+
const { data, sequence, timestampMicros } = u;
|
|
160
|
+
yield isVideo
|
|
161
|
+
? {
|
|
162
|
+
track: u.track,
|
|
163
|
+
data,
|
|
164
|
+
isKeyFrame: u.isKeyFrame,
|
|
165
|
+
sequence,
|
|
166
|
+
timestampMicros,
|
|
167
|
+
}
|
|
168
|
+
: { track: 'jpeg', data, isKeyFrame: true, sequence, timestampMicros };
|
|
169
|
+
}
|
|
170
|
+
if (this.failure) {
|
|
171
|
+
throw this.failure;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async requestKeyFrame() {
|
|
175
|
+
return (await this.capture?.requestKeyFrame()) ?? false;
|
|
176
|
+
}
|
|
177
|
+
async stop() {
|
|
178
|
+
// A stop that arrives while start() is pending must not miss what it creates
|
|
179
|
+
await this.starting?.catch(() => { });
|
|
180
|
+
await this.teardown();
|
|
181
|
+
}
|
|
182
|
+
async teardown() {
|
|
183
|
+
this.stopping ??= (async () => {
|
|
184
|
+
clearInterval(this.orientationTimer);
|
|
185
|
+
// The capture's own stop() also tells the device to stop streaming
|
|
186
|
+
await this.capture?.stop().catch((e) => this.log.debug(`Cannot stop the capture: ${e.message}`));
|
|
187
|
+
await this.audioCapture
|
|
188
|
+
?.stop()
|
|
189
|
+
.catch((e) => this.log.debug(`Cannot stop the audio capture: ${e.message}`));
|
|
190
|
+
await this.transcoder?.close().catch((e) => this.log.debug(`Cannot close the transcoder: ${e.message}`));
|
|
191
|
+
await Promise.resolve(this.infoService?.close?.()).catch((e) => this.log.debug(`Cannot close the info service: ${e.message}`));
|
|
192
|
+
await this.display?.close().catch((e) => this.log.debug(`Cannot close the display service: ${e.message}`));
|
|
193
|
+
await this.feeder;
|
|
194
|
+
await this.audioFeeder;
|
|
195
|
+
})();
|
|
196
|
+
await this.stopping;
|
|
197
|
+
}
|
|
198
|
+
async feed(capture, transcoder) {
|
|
199
|
+
try {
|
|
200
|
+
for await (const au of capture.accessUnits()) {
|
|
201
|
+
if (au.isKeyFrame) {
|
|
202
|
+
// The device's IDR is a clean reference: start a new H.264 GOP from it
|
|
203
|
+
transcoder.requestKeyFrame();
|
|
204
|
+
}
|
|
205
|
+
transcoder.push(au);
|
|
206
|
+
}
|
|
207
|
+
await transcoder.end();
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
this.failure = e;
|
|
211
|
+
await transcoder.close().catch(() => { });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Audio is best effort: a failing audio stream must not end the video
|
|
215
|
+
async feedAudio(capture, transcoder) {
|
|
216
|
+
try {
|
|
217
|
+
for await (const au of capture.accessUnits()) {
|
|
218
|
+
transcoder.pushAudio(au);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
this.log.warn(`The audio stream ended: ${e.message}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function isEven(value) {
|
|
227
|
+
return value % 2 === 0;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=device-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-source.js","sourceRoot":"","sources":["../../../../lib/device/media-stream/device-source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAC,oBAAoB,EAAsC,MAAM,kBAAkB,CAAC;AAqB3F,6GAA6G;AAC7G,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,iHAAiH;AACjH,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAElC,+FAA+F;AAC/F,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEhC,oGAAoG;AAC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AED,sEAAsE;IAC9D,KAAK,CAAC,SAAS,CAAC,OAAqB,EAAE,UAAsB;QACnE,IAAI,CAAC;YACH,IAAI,KAAK,EAAE,MAAM,EAAE,IAAI,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC7C,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,2BAA4B,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jpeg.d.ts","sourceRoot":"","sources":["../../../../lib/device/media-stream/jpeg.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAchF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Reads the dimensions from the first SOFn marker; null if not found. */
|
|
2
|
+
export function readJpegSize(buf) {
|
|
3
|
+
let i = 2;
|
|
4
|
+
while (i + 9 < buf.length) {
|
|
5
|
+
if (buf[i] !== 0xff) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const marker = buf[i + 1];
|
|
9
|
+
// SOF0..SOF15 except DHT (C4), JPG (C8) and DAC (CC)
|
|
10
|
+
if (marker >= 0xc0 && marker <= 0xcf && ![0xc4, 0xc8, 0xcc].includes(marker)) {
|
|
11
|
+
return { height: buf.readUInt16BE(i + 5), width: buf.readUInt16BE(i + 7) };
|
|
12
|
+
}
|
|
13
|
+
i += 2 + buf.readUInt16BE(i + 2);
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=jpeg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jpeg.js","sourceRoot":"","sources":["../../../../lib/device/media-stream/jpeg.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QAC1B,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1B,qDAAqD;QACrD,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7E,OAAO,EAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,EAAC,CAAC;QAC3E,CAAC;QACD,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as MediaProxy from '@appium/media-proxy';
|
|
2
|
+
export type MediaProxyModule = typeof MediaProxy;
|
|
3
|
+
/**
|
|
4
|
+
* Lazily imports the optional `@appium/media-proxy`, so that sessions not streaming a real device never load it.
|
|
5
|
+
*
|
|
6
|
+
* @throws When the package is not installed
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadMediaProxy(): Promise<MediaProxyModule>;
|
|
9
|
+
/** Why H.264 can't be streamed here, or `undefined` if an encoder is available. */
|
|
10
|
+
export declare function describeMissingH264Encoder(mediaProxy: Pick<MediaProxyModule, 'listH264Encoders'>): string | undefined;
|
|
11
|
+
/** Rewords media-proxy's "no H.264 encoder" error (written for its own options) for the driver's. */
|
|
12
|
+
export declare function explainEncoderError(e: unknown): unknown;
|
|
13
|
+
//# sourceMappingURL=media-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-proxy.d.ts","sourceRoot":"","sources":["../../../../lib/device/media-stream/media-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAGvD,MAAM,MAAM,gBAAgB,GAAG,OAAO,UAAU,CAAC;AAIjD;;;;GAIG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAUhE;AAOD,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,GAAG,MAAM,GAAG,SAAS,CAErH;AAED,qGAAqG;AACrG,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CASvD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { errors } from 'appium/driver.js';
|
|
2
|
+
let cached;
|
|
3
|
+
/**
|
|
4
|
+
* Lazily imports the optional `@appium/media-proxy`, so that sessions not streaming a real device never load it.
|
|
5
|
+
*
|
|
6
|
+
* @throws When the package is not installed
|
|
7
|
+
*/
|
|
8
|
+
export async function loadMediaProxy() {
|
|
9
|
+
try {
|
|
10
|
+
cached ??= await import('@appium/media-proxy');
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
throw new Error(`Streaming a real device requires the optional '@appium/media-proxy' package: ${e.message}`, { cause: e });
|
|
14
|
+
}
|
|
15
|
+
return cached;
|
|
16
|
+
}
|
|
17
|
+
const OPENH264_DOCS = 'https://github.com/appium/appium-ios/tree/main/packages/media-proxy#software-h264-openh264';
|
|
18
|
+
const OPENH264_HINT = `Request kind 'jpeg' (it needs no encoder), or install Cisco's OpenH264 ` +
|
|
19
|
+
`and set MEDIA_PROXY_OPENH264_PATH to the library. The required version, download links and steps: ${OPENH264_DOCS}`;
|
|
20
|
+
/** Why H.264 can't be streamed here, or `undefined` if an encoder is available. */
|
|
21
|
+
export function describeMissingH264Encoder(mediaProxy) {
|
|
22
|
+
return mediaProxy.listH264Encoders().length === 0 ? `No H.264 encoder is available. ${OPENH264_HINT}` : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Rewords media-proxy's "no H.264 encoder" error (written for its own options) for the driver's. */
|
|
25
|
+
export function explainEncoderError(e) {
|
|
26
|
+
const message = e?.message;
|
|
27
|
+
if (e?.name !== 'MediaProxyEncoderUnavailableError' ||
|
|
28
|
+
!message?.startsWith('No H.264 encoder')) {
|
|
29
|
+
return e;
|
|
30
|
+
}
|
|
31
|
+
return new errors.UnsupportedOperationError(`${message.split('. Use codec')[0]}. ${OPENH264_HINT}`);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=media-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-proxy.js","sourceRoot":"","sources":["../../../../lib/device/media-stream/media-proxy.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAIxC,IAAI,MAAoC,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,IAAI,CAAC;QACH,MAAM,KAAK,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,gFAAiF,CAAW,CAAC,OAAO,EAAE,EACtG,EAAC,KAAK,EAAE,CAAC,EAAC,CACX,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,aAAa,GAAG,4FAA4F,CAAC;AACnH,MAAM,aAAa,GACjB,yEAAyE;IACzE,qGAAqG,aAAa,EAAE,CAAC;AAEvH,mFAAmF;AACnF,MAAM,UAAU,0BAA0B,CAAC,UAAsD;IAC/F,OAAO,UAAU,CAAC,gBAAgB,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,kCAAkC,aAAa,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACpH,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,mBAAmB,CAAC,CAAU;IAC5C,MAAM,OAAO,GAAI,CAAuB,EAAE,OAAO,CAAC;IAClD,IACG,CAAuB,EAAE,IAAI,KAAK,mCAAmC;QACtE,CAAC,OAAO,EAAE,UAAU,CAAC,kBAAkB,CAAC,EACxC,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,IAAI,MAAM,CAAC,yBAAyB,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE,CAAC,CAAC;AACtG,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type Rotation = 0 | 90 | 180 | 270;
|
|
2
|
+
export interface DisplayGeometry {
|
|
3
|
+
/** The visible size in pixels, which is smaller than the stream: the device pads it to a multiple of 16 */
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
/** Clockwise degrees that make the stream's picture upright, if the display reported its orientation */
|
|
7
|
+
rotation?: Rotation;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Reads the visible size and the rotation of a display from CoreDevice's `getDisplayInfo()`.
|
|
11
|
+
*
|
|
12
|
+
* The device always streams the display's native portrait buffer and says nothing about its orientation, so a
|
|
13
|
+
* landscape UI arrives turned. The display reports it as `currentOrientation`: `rot0`, `rot90`, `rot180` or
|
|
14
|
+
* `rot270`, and the stream needs turning clockwise by exactly that many degrees (verified on an iPad in all
|
|
15
|
+
* but the upside-down orientation, which follows from the others).
|
|
16
|
+
*
|
|
17
|
+
* @param info The result of `getDisplayInfo()`
|
|
18
|
+
* @param displayId The display to read; the primary one by default
|
|
19
|
+
* @returns `undefined` if the display or its size cannot be found
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseDisplayGeometry(info: unknown, displayId?: number): DisplayGeometry | undefined;
|
|
22
|
+
//# sourceMappingURL=orientation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orientation.d.ts","sourceRoot":"","sources":["../../../../lib/device/media-stream/orientation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,2GAA2G;IAC3G,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,wGAAwG;IACxG,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AASD;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAoBnG"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the visible size and the rotation of a display from CoreDevice's `getDisplayInfo()`.
|
|
3
|
+
*
|
|
4
|
+
* The device always streams the display's native portrait buffer and says nothing about its orientation, so a
|
|
5
|
+
* landscape UI arrives turned. The display reports it as `currentOrientation`: `rot0`, `rot90`, `rot180` or
|
|
6
|
+
* `rot270`, and the stream needs turning clockwise by exactly that many degrees (verified on an iPad in all
|
|
7
|
+
* but the upside-down orientation, which follows from the others).
|
|
8
|
+
*
|
|
9
|
+
* @param info The result of `getDisplayInfo()`
|
|
10
|
+
* @param displayId The display to read; the primary one by default
|
|
11
|
+
* @returns `undefined` if the display or its size cannot be found
|
|
12
|
+
*/
|
|
13
|
+
export function parseDisplayGeometry(info, displayId) {
|
|
14
|
+
const displays = info?.displays;
|
|
15
|
+
if (!Array.isArray(displays)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const display = displayId === undefined
|
|
19
|
+
? (displays.find((d) => d.primary) ?? displays[0])
|
|
20
|
+
: displays.find((d) => d.displayId === displayId);
|
|
21
|
+
const size = display?.currentMode?.size;
|
|
22
|
+
if (!Array.isArray(size) ||
|
|
23
|
+
!Number.isInteger(size[0]) ||
|
|
24
|
+
!Number.isInteger(size[1]) ||
|
|
25
|
+
size[0] <= 0 ||
|
|
26
|
+
size[1] <= 0) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return { width: size[0], height: size[1], rotation: parseRotation(display?.currentOrientation) };
|
|
30
|
+
}
|
|
31
|
+
function parseRotation(orientation) {
|
|
32
|
+
const degrees = /^rot(0|90|180|270)$/.exec(orientation ?? '')?.[1];
|
|
33
|
+
return degrees === undefined ? undefined : Number(degrees);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=orientation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orientation.js","sourceRoot":"","sources":["../../../../lib/device/media-stream/orientation.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAa,EAAE,SAAkB;IACpE,MAAM,QAAQ,GAAI,IAAgD,EAAE,QAAQ,CAAC;IAC7E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,OAAO,GACX,SAAS,KAAK,SAAS;QACrB,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC;IACxC,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACpB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACZ,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EACZ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,kBAAkB,CAAC,EAAC,CAAC;AACjG,CAAC;AAED,SAAS,aAAa,CAAC,WAA+B;IACpD,MAAM,OAAO,GAAG,qBAAqB,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACnE,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,MAAM,CAAC,OAAO,CAAc,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Simulator } from 'appium-ios-simulator';
|
|
2
|
+
import type { MediaSource, SourceUnit, StartMediaStreamOpts } from './types.js';
|
|
3
|
+
/** coresim encodes at the source (VideoToolbox / JPEG), so there is nothing to transcode. */
|
|
4
|
+
export declare class SimulatorMediaSource implements MediaSource {
|
|
5
|
+
private readonly sim;
|
|
6
|
+
private readonly opts;
|
|
7
|
+
private stream?;
|
|
8
|
+
private starting?;
|
|
9
|
+
private stopping?;
|
|
10
|
+
constructor(sim: Simulator, opts: StartMediaStreamOpts);
|
|
11
|
+
start(): Promise<void>;
|
|
12
|
+
private open;
|
|
13
|
+
units(): AsyncGenerator<SourceUnit>;
|
|
14
|
+
stop(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=simulator-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulator-source.d.ts","sourceRoot":"","sources":["../../../../lib/device/media-stream/simulator-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAKpD,OAAO,KAAK,EAAC,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAE9E,6FAA6F;AAC7F,qBAAa,oBAAqB,YAAW,WAAW;IAMpD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IANvB,OAAO,CAAC,MAAM,CAAC,CAA4C;IAC3D,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,CAAgB;gBAGd,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,oBAAoB;IAGvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAKd,IAAI;IAUX,KAAK,IAAI,cAAc,CAAC,UAAU,CAAC;IAcpC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAO5B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** coresim encodes at the source (VideoToolbox / JPEG), so there is nothing to transcode. */
|
|
2
|
+
export class SimulatorMediaSource {
|
|
3
|
+
sim;
|
|
4
|
+
opts;
|
|
5
|
+
stream;
|
|
6
|
+
starting;
|
|
7
|
+
stopping;
|
|
8
|
+
constructor(sim, opts) {
|
|
9
|
+
this.sim = sim;
|
|
10
|
+
this.opts = opts;
|
|
11
|
+
}
|
|
12
|
+
async start() {
|
|
13
|
+
this.starting = this.open();
|
|
14
|
+
await this.starting;
|
|
15
|
+
}
|
|
16
|
+
async open() {
|
|
17
|
+
const { opts, sim } = this;
|
|
18
|
+
const common = { fps: opts.fps, displayId: opts.displayId };
|
|
19
|
+
const stream = opts.kind === 'video'
|
|
20
|
+
? await sim.startVideoStream({ ...common, codec: opts.codec, bitrate: opts.bitrate, audio: opts.audio })
|
|
21
|
+
: await sim.startJpegStream({ ...common, quality: opts.quality, scale: opts.scale });
|
|
22
|
+
this.stream = opts.kind === 'video' ? { video: stream } : { jpeg: stream };
|
|
23
|
+
}
|
|
24
|
+
async *units() {
|
|
25
|
+
const { stream } = this;
|
|
26
|
+
if (!stream) {
|
|
27
|
+
throw new Error('The source has not been started');
|
|
28
|
+
}
|
|
29
|
+
if ('video' in stream) {
|
|
30
|
+
yield* stream.video.accessUnits();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
for await (const f of stream.jpeg.frames()) {
|
|
34
|
+
yield { track: 'jpeg', data: f.data, isKeyFrame: true, sequence: f.sequence, timestampMicros: f.timestampMicros };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async stop() {
|
|
38
|
+
// A stop that arrives while start() is pending must not miss the stream it creates
|
|
39
|
+
await this.starting?.catch(() => { });
|
|
40
|
+
const { stream } = this;
|
|
41
|
+
this.stopping ??= stream ? ('video' in stream ? stream.video : stream.jpeg).stop() : Promise.resolve();
|
|
42
|
+
await this.stopping;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=simulator-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulator-source.js","sourceRoot":"","sources":["../../../../lib/device/media-stream/simulator-source.ts"],"names":[],"mappings":"AAOA,6FAA6F;AAC7F,MAAM,OAAO,oBAAoB;IAMZ;IACA;IANX,MAAM,CAA6C;IACnD,QAAQ,CAAiB;IACzB,QAAQ,CAAiB;IAEjC,YACmB,GAAc,EACd,IAA0B;QAD1B,QAAG,GAAH,G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AE,CAAC;YAClC,OAAO;QACT,CAAC;QACD,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,MAAM,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC,eAAe,EAAC,CAAC;QAClH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,mFAAmF;QACnF,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrC,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvG,MAAM,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface VideoSize {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
/** Splits an Annex-B buffer into NAL units (without start codes). */
|
|
6
|
+
export declare function splitNalUnits(data: Buffer): Buffer[];
|
|
7
|
+
/**
|
|
8
|
+
* Reads the frame size from the SPS in a video config unit (Annex-B).
|
|
9
|
+
* Returns null if there is no SPS or it cannot be parsed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseVideoSize(config: Buffer, codec: 'h264' | 'hevc'): VideoSize | null;
|
|
12
|
+
//# sourceMappingURL=sps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sps.d.ts","sourceRoot":"","sources":["../../../../lib/device/media-stream/sps.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AA2CD,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBpD;AA8HD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAcvF"}
|