@pexip/media 17.2.0 → 17.4.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 +39 -0
- package/dist/audioMixingProcessor.d.ts +18 -0
- package/dist/audioMixingProcessor.js +173 -0
- package/dist/audioProcessor.d.ts +86 -0
- package/dist/audioProcessor.js +310 -0
- package/dist/baseLogger.d.ts +37 -0
- package/dist/baseLogger.js +29 -0
- package/dist/displayMedia.d.ts +3 -0
- package/dist/displayMedia.js +31 -0
- package/dist/index.d.ts +11 -837
- package/dist/index.js +11 -0
- package/dist/logger.d.ts +11 -0
- package/dist/logger.js +44 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.js +296 -0
- package/dist/previewController.d.ts +64 -0
- package/dist/previewController.js +375 -0
- package/dist/signals.d.ts +25 -0
- package/dist/signals.js +38 -0
- package/dist/status.d.ts +35 -0
- package/dist/status.js +199 -0
- package/dist/typeGuard.d.ts +9 -0
- package/dist/typeGuard.js +40 -0
- package/dist/types.d.ts +559 -0
- package/dist/types.js +278 -0
- package/dist/userMedia.d.ts +38 -0
- package/dist/userMedia.js +333 -0
- package/dist/utils.d.ts +108 -0
- package/dist/utils.js +360 -0
- package/dist/videoProcessor.d.ts +56 -0
- package/dist/videoProcessor.js +349 -0
- package/package.json +10 -10
- package/dist/index.mjs +0 -2900
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isAudioNodeInit } from '@pexip/media-processor';
|
|
2
|
+
import { UserMediaStatus, AUDIO_CONTENT_HINTS, VIDEO_CONTENT_HINTS, } from './types';
|
|
3
|
+
export const isNonNullObject = (value) => {
|
|
4
|
+
if (typeof value === 'object' && value !== null) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
|
+
};
|
|
9
|
+
export const isUserMediaStatus = (value) => {
|
|
10
|
+
if (value && typeof value === 'string') {
|
|
11
|
+
return Object.values(UserMediaStatus).includes(value);
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
export const isMedia = (value) => {
|
|
16
|
+
if (isNonNullObject(value) && 'release' in value) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
export const isAnalyzerNodeInitProp = (value) => {
|
|
22
|
+
if (value === undefined || isAudioNodeInit(value)) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
export const isAudioContentHint = (value) => {
|
|
28
|
+
if (typeof value === 'string' &&
|
|
29
|
+
Object.values(AUDIO_CONTENT_HINTS).includes(value)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
export const isVideoContentHint = (value) => {
|
|
35
|
+
if (typeof value === 'string' &&
|
|
36
|
+
Object.values(VIDEO_CONTENT_HINTS).includes(value)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import type { InputConstraintSet, MediaDeviceInfoLike, MediaDeviceRequest } from '@pexip/media-control';
|
|
2
|
+
import type { RenderParams, RenderEffects, Segmenter, SegmentationModel } from '@pexip/media-processor';
|
|
3
|
+
import type { Signal } from '@pexip/signal';
|
|
4
|
+
export type Unsubscribe = () => void;
|
|
5
|
+
export interface ExtendedMediaTrackSettings extends MediaTrackSettings {
|
|
6
|
+
mixWithAdditionalMedia?: boolean;
|
|
7
|
+
channelCount?: number;
|
|
8
|
+
denoise?: boolean;
|
|
9
|
+
vad?: boolean;
|
|
10
|
+
asd?: boolean;
|
|
11
|
+
backgroundBlurAmount?: number;
|
|
12
|
+
bgImageUrl?: string;
|
|
13
|
+
edgeBlurAmount?: number;
|
|
14
|
+
flipHorizontal?: boolean;
|
|
15
|
+
foregroundThreshold?: number;
|
|
16
|
+
videoSegmentation?: RenderEffects;
|
|
17
|
+
videoSegmentationModel?: SegmentationModel;
|
|
18
|
+
pan?: boolean;
|
|
19
|
+
tilt?: boolean;
|
|
20
|
+
zoom?: boolean;
|
|
21
|
+
contentHint?: AudioContentHint | VideoContentHint;
|
|
22
|
+
}
|
|
23
|
+
export type ExtendedMediaTrackSettingsKey = keyof ExtendedMediaTrackSettings;
|
|
24
|
+
export interface MediaSettings {
|
|
25
|
+
audio: ExtendedMediaTrackSettings[];
|
|
26
|
+
video: ExtendedMediaTrackSettings[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* URL links needed for creating a denoise node for audio processing
|
|
30
|
+
*/
|
|
31
|
+
export interface DenoiseParams {
|
|
32
|
+
/**
|
|
33
|
+
* wasm URL to get the denoise wasm
|
|
34
|
+
*/
|
|
35
|
+
wasmURL: string;
|
|
36
|
+
/**
|
|
37
|
+
* AudioWorklet module URL to get the worklet, @see AudioContext['audioWorklet']['addModule']
|
|
38
|
+
*/
|
|
39
|
+
workletModule: string;
|
|
40
|
+
/**
|
|
41
|
+
* AudioWorklet options to pass @see AudioContext['audioWorklet']['addModule']
|
|
42
|
+
*/
|
|
43
|
+
workletOptions?: WorkletOptions;
|
|
44
|
+
}
|
|
45
|
+
export interface MediaAttributes {
|
|
46
|
+
/**
|
|
47
|
+
* The constraints used to request the media
|
|
48
|
+
*/
|
|
49
|
+
constraints?: MediaDeviceRequest;
|
|
50
|
+
/**
|
|
51
|
+
* The devices used for the media
|
|
52
|
+
*/
|
|
53
|
+
devices: MediaDeviceInfoLike[];
|
|
54
|
+
/**
|
|
55
|
+
* Media stream for the media
|
|
56
|
+
*/
|
|
57
|
+
stream?: MediaStream;
|
|
58
|
+
/**
|
|
59
|
+
* The raw stream obtained from the `getUserMedia` API
|
|
60
|
+
*/
|
|
61
|
+
rawStream?: MediaStream;
|
|
62
|
+
/**
|
|
63
|
+
* Audio input device is used for the audio track from the current stream
|
|
64
|
+
*/
|
|
65
|
+
audioInput?: MediaDeviceInfoLike;
|
|
66
|
+
/**
|
|
67
|
+
* Video input device is used for the video track from the current stream
|
|
68
|
+
*/
|
|
69
|
+
videoInput?: MediaDeviceInfoLike;
|
|
70
|
+
/**
|
|
71
|
+
* The audio input device which is expected to be used for the current
|
|
72
|
+
* stream based on the provided constraints
|
|
73
|
+
*/
|
|
74
|
+
expectedAudioInput?: MediaDeviceInfoLike;
|
|
75
|
+
/**
|
|
76
|
+
* The video input device which is expected to be used for the current
|
|
77
|
+
* stream based on the provided constraints
|
|
78
|
+
*/
|
|
79
|
+
expectedVideoInput?: MediaDeviceInfoLike;
|
|
80
|
+
/**
|
|
81
|
+
* The status of the media
|
|
82
|
+
*/
|
|
83
|
+
status: UserMediaStatus;
|
|
84
|
+
/**
|
|
85
|
+
* Current mute state of audio track
|
|
86
|
+
* `undefined` means there is no such track from the stream
|
|
87
|
+
*/
|
|
88
|
+
audioMuted: boolean | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Current mute state of video track
|
|
91
|
+
* `undefined` means there is no such track from the stream
|
|
92
|
+
*/
|
|
93
|
+
videoMuted: boolean | undefined;
|
|
94
|
+
}
|
|
95
|
+
export interface Media extends MediaAttributes {
|
|
96
|
+
/**
|
|
97
|
+
* mute/unmute the audio track
|
|
98
|
+
*/
|
|
99
|
+
muteAudio(mute: boolean): void;
|
|
100
|
+
/**
|
|
101
|
+
* mute/unmute the video track
|
|
102
|
+
*/
|
|
103
|
+
muteVideo(mute: boolean): void;
|
|
104
|
+
/**
|
|
105
|
+
* Apply the constraints to the current media
|
|
106
|
+
*/
|
|
107
|
+
applyConstraints(constraints: MediaDeviceRequest): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Release the media resources, e.g. camera/microphone
|
|
110
|
+
*/
|
|
111
|
+
release(): Promise<void>;
|
|
112
|
+
getSettings(): MediaSettings;
|
|
113
|
+
toJSON?: () => unknown;
|
|
114
|
+
}
|
|
115
|
+
export type Process<T> = (a: T) => Promise<Media>;
|
|
116
|
+
export type MediaProcessor = Process<Promise<Media>>;
|
|
117
|
+
/**
|
|
118
|
+
* A media pipeline to get and process media
|
|
119
|
+
*/
|
|
120
|
+
export type Pipeline<T = MediaDeviceRequest> = [
|
|
121
|
+
Process<T>,
|
|
122
|
+
...MediaProcessor[]
|
|
123
|
+
];
|
|
124
|
+
export type ProcessMedia = (media: Media) => undefined | Media;
|
|
125
|
+
/**
|
|
126
|
+
* Use which processor API to process the stream track
|
|
127
|
+
* `stream` - Use MediaStreamTrackProcessor, when available
|
|
128
|
+
* `canvas` - Use Canvas
|
|
129
|
+
*/
|
|
130
|
+
export type VideoStreamTrackProcessorAPIs = 'stream' | 'canvas';
|
|
131
|
+
export declare enum UserMediaStatus {
|
|
132
|
+
/**
|
|
133
|
+
* The initial status
|
|
134
|
+
*/
|
|
135
|
+
Initial = "initial",
|
|
136
|
+
/**
|
|
137
|
+
* When we know the permissions were already granted from permission API
|
|
138
|
+
*/
|
|
139
|
+
InitialPermissionsGranted = "initial-permissions-granted",
|
|
140
|
+
/**
|
|
141
|
+
* When we do not know the permissions from permission API
|
|
142
|
+
*/
|
|
143
|
+
InitialPermissionsNotGranted = "initial-permissions-not-granted",
|
|
144
|
+
/**
|
|
145
|
+
* When video input permissions are initially denied in the browser and audio input permissions are unknown
|
|
146
|
+
*/
|
|
147
|
+
InitialPermissionsVideoInputDenied = "initial-permissions-videoinput-denied",
|
|
148
|
+
/**
|
|
149
|
+
* When audio input permissions are initially denied in the browser and video input permissions are unknown
|
|
150
|
+
*/
|
|
151
|
+
InitialPermissionsAudioInputDenied = "initial-permissions-audioinput-denied",
|
|
152
|
+
/**
|
|
153
|
+
* When video input permissions are granted in the browser and audio input permissions are unknown
|
|
154
|
+
*/
|
|
155
|
+
InitialPermissionsVideoInputGranted = "initial-permissions-videoinput-granted",
|
|
156
|
+
/**
|
|
157
|
+
* When audio input permissions are granted in the browser and video input permissions are unknown
|
|
158
|
+
*/
|
|
159
|
+
InitialPermissionsAudioInputGranted = "initial-permissions-audioinput-granted",
|
|
160
|
+
/**
|
|
161
|
+
* When audio input permissions are granted but video input permissions are initially denied
|
|
162
|
+
*/
|
|
163
|
+
InitialPermissionsGrantedVideoInputDenied = "initial-permissions-audioinput-granted-videoinput-denied",
|
|
164
|
+
/**
|
|
165
|
+
* When video input permissions are granted but audio input permissions are initially denied
|
|
166
|
+
*/
|
|
167
|
+
InitialPermissionsGrantedAudioInputDenied = "initial-permissions-videoinput-granted-audioinput-denied",
|
|
168
|
+
/**
|
|
169
|
+
* When there is no any kind of input devices
|
|
170
|
+
*/
|
|
171
|
+
NoDevicesFound = "no-devices-found",
|
|
172
|
+
/**
|
|
173
|
+
* When there is no any video input devices
|
|
174
|
+
*/
|
|
175
|
+
NoVideoDevicesFound = "no-video-devices-found",
|
|
176
|
+
/**
|
|
177
|
+
* When there is no any audio input devices
|
|
178
|
+
*/
|
|
179
|
+
NoAudioDevicesFound = "no-audio-devices-found",
|
|
180
|
+
/**
|
|
181
|
+
* Derived from `MediaDeviceFailure.AudioInputDeviceNotFoundError`
|
|
182
|
+
*/
|
|
183
|
+
AudioDeviceNotFound = "audio-device-not-found",
|
|
184
|
+
/**
|
|
185
|
+
* Derived from `MediaDeviceFailure.VideoInputDeviceNotFoundError`
|
|
186
|
+
*/
|
|
187
|
+
VideoDeviceNotFound = "video-device-not-found",
|
|
188
|
+
/**
|
|
189
|
+
* Derived from `MediaDeviceFailure.AudioAndVideoDeviceNotFoundError`
|
|
190
|
+
*/
|
|
191
|
+
AudioVideoDevicesNotFound = "audio-video-devices-not-found",
|
|
192
|
+
/**
|
|
193
|
+
* When Permission is granted by user for both video and audio, and both
|
|
194
|
+
* devices are exactly matched with the request constraints
|
|
195
|
+
*/
|
|
196
|
+
PermissionsGranted = "permissions-granted",
|
|
197
|
+
/**
|
|
198
|
+
* When Permission is granted by user for both video and audio, and both
|
|
199
|
+
* devices are NOT exactly matched with the request constraints
|
|
200
|
+
*/
|
|
201
|
+
PermissionsGrantedFallback = "permissions-granted-fallback-devices",
|
|
202
|
+
/**
|
|
203
|
+
* When Permission is granted by user for both video and audio, and audio
|
|
204
|
+
* input is NOT exactly matched with the request constraints
|
|
205
|
+
*/
|
|
206
|
+
PermissionsGrantedFallbackAudioinput = "permissions-granted-fallback-audioinput",
|
|
207
|
+
/**
|
|
208
|
+
* When Permission is granted by user for both video and audio, and video
|
|
209
|
+
* input is NOT exactly matched with the request constraints
|
|
210
|
+
*/
|
|
211
|
+
PermissionsGrantedFallbackVideoinput = "permissions-granted-fallback-videoinput",
|
|
212
|
+
/**
|
|
213
|
+
* When Permission for using both audio and video devices are rejected by the user
|
|
214
|
+
* from `PermissionDeniedError`
|
|
215
|
+
*/
|
|
216
|
+
PermissionsRejected = "permissions-rejected",
|
|
217
|
+
/**
|
|
218
|
+
* When Permission for using the audio device is rejected by the user
|
|
219
|
+
* from `PermissionDeniedError`
|
|
220
|
+
*/
|
|
221
|
+
PermissionsRejectedAudioInput = "permissions-rejected-audioinput",
|
|
222
|
+
/**
|
|
223
|
+
* When Permission for using the video device is rejected by the user
|
|
224
|
+
* from `PermissionDeniedError`
|
|
225
|
+
*/
|
|
226
|
+
PermissionsRejectedVideoInput = "permissions-rejected-videoinput",
|
|
227
|
+
/**
|
|
228
|
+
* When only request and return exact audio input device
|
|
229
|
+
*/
|
|
230
|
+
PermissionsOnlyAudioinput = "permissions-only-audioinput",
|
|
231
|
+
/**
|
|
232
|
+
* When only request audio input device because of no video devices
|
|
233
|
+
* available and returned exact audio input device
|
|
234
|
+
*/
|
|
235
|
+
PermissionsOnlyAudioinputNoVideoDevices = "permissions-only-audioinput-no-video-devices",
|
|
236
|
+
/**
|
|
237
|
+
* When only request and returned NOT exact audio input device
|
|
238
|
+
*/
|
|
239
|
+
PermissionsOnlyAudioinputFallback = "permissions-only-fallback-audioinput",
|
|
240
|
+
/**
|
|
241
|
+
* When only request audio input device because of no video devices
|
|
242
|
+
* available and returned NOT exact audio input device
|
|
243
|
+
*/
|
|
244
|
+
PermissionsOnlyAudioinputFallbackNoVideoDevices = "permissions-only-fallback-audioinput-no-video-devices",
|
|
245
|
+
/**
|
|
246
|
+
* When only request and return exact video input device
|
|
247
|
+
*/
|
|
248
|
+
PermissionsOnlyVideoinput = "permissions-only-videoinput",
|
|
249
|
+
/**
|
|
250
|
+
* When only request video input device because of no audio devices
|
|
251
|
+
* available and returned exact video input device
|
|
252
|
+
*/
|
|
253
|
+
PermissionsOnlyVideoinputNoAudioDevices = "permissions-only-videoinput-no-audio-devices",
|
|
254
|
+
/**
|
|
255
|
+
* When only request and returned NOT exact video input device
|
|
256
|
+
*/
|
|
257
|
+
PermissionsOnlyVideoinputFallback = "permissions-only-fallback-videoinput",
|
|
258
|
+
/**
|
|
259
|
+
* When only request video input device because of no video devices
|
|
260
|
+
* available and returned NOT exact video input device
|
|
261
|
+
*/
|
|
262
|
+
PermissionsOnlyVideoinputFallbackNoAudioDevices = "permissions-only-fallback-videoinput-no-audio-devices",
|
|
263
|
+
/**
|
|
264
|
+
* When requesting the audio device is used by other application
|
|
265
|
+
*/
|
|
266
|
+
AudioDeviceInUse = "audio-device-in-use",
|
|
267
|
+
/**
|
|
268
|
+
* When requesting the video device is used by other application
|
|
269
|
+
*/
|
|
270
|
+
VideoDeviceInUse = "video-device-in-use",
|
|
271
|
+
/**
|
|
272
|
+
* When requesting both audio and video devices are used by other application
|
|
273
|
+
*/
|
|
274
|
+
DevicesInUse = "devices-in-use",
|
|
275
|
+
/**
|
|
276
|
+
* When requesting both audio and video with over-constrained
|
|
277
|
+
*/
|
|
278
|
+
Overconstrained = "overconstrained",
|
|
279
|
+
/**
|
|
280
|
+
* When requesting video with over-constrained
|
|
281
|
+
*/
|
|
282
|
+
VideoOverconstrained = "video-overconstrained",
|
|
283
|
+
/**
|
|
284
|
+
* When requesting audio with over-constrained
|
|
285
|
+
*/
|
|
286
|
+
AudioOverconstrained = "audio-overconstrained",
|
|
287
|
+
/**
|
|
288
|
+
* When requesting both audio and video with invalid constraints
|
|
289
|
+
*/
|
|
290
|
+
InvalidConstraints = "invalid-constraints",
|
|
291
|
+
/**
|
|
292
|
+
* When requesting video with invalid constraints
|
|
293
|
+
*/
|
|
294
|
+
InvalidVideoConstraints = "invalid-video-constraints",
|
|
295
|
+
/**
|
|
296
|
+
* When requesting audio with invalid constraints
|
|
297
|
+
*/
|
|
298
|
+
InvalidAudioConstraints = "invalid-audio-constraints",
|
|
299
|
+
/**
|
|
300
|
+
* When requesting both audio and video with NotSupportedError
|
|
301
|
+
*/
|
|
302
|
+
NotSupportedError = "not-supported-error",
|
|
303
|
+
/**
|
|
304
|
+
* When requesting video with NotSupportedError
|
|
305
|
+
*/
|
|
306
|
+
NotSupportedErrorOnlyVideoInput = "not-supported-error-only-video",
|
|
307
|
+
/**
|
|
308
|
+
* When requesting audio with NotSupportedError
|
|
309
|
+
*/
|
|
310
|
+
NotSupportedErrorOnlyAudioInput = "not-supported-error-only-audio",
|
|
311
|
+
/**
|
|
312
|
+
* Unknown error from both video and audio
|
|
313
|
+
*/
|
|
314
|
+
UnknownError = "unknown-error",
|
|
315
|
+
/**
|
|
316
|
+
* Unknown error from audio device
|
|
317
|
+
*/
|
|
318
|
+
UnknownErrorOnlyAudioinput = "unknown-error-only-audioinput",
|
|
319
|
+
/**
|
|
320
|
+
* Unknown error from video device
|
|
321
|
+
*/
|
|
322
|
+
UnknownErrorOnlyVideoinput = "unknown-error-only-videoinput"
|
|
323
|
+
}
|
|
324
|
+
export interface AudioSignalDetectionOptions {
|
|
325
|
+
/**
|
|
326
|
+
* Audio Signal Detection Duration in second
|
|
327
|
+
*/
|
|
328
|
+
audioSignalDetectionDuration?: number;
|
|
329
|
+
/**
|
|
330
|
+
* Whether or not to detect audio signal for malfunctioning device
|
|
331
|
+
*/
|
|
332
|
+
shouldDetectAudio: () => boolean;
|
|
333
|
+
}
|
|
334
|
+
export interface VoiceActivityDetectionOptions {
|
|
335
|
+
/**
|
|
336
|
+
* Voice Activity Detection in millisecond
|
|
337
|
+
*/
|
|
338
|
+
vadThrottleMS?: number;
|
|
339
|
+
/**
|
|
340
|
+
* Whether or not to detect voice activity
|
|
341
|
+
*/
|
|
342
|
+
shouldDetectVoiceActivity: () => boolean;
|
|
343
|
+
}
|
|
344
|
+
interface DeviceMuteState {
|
|
345
|
+
/**
|
|
346
|
+
* Indicating whether audio is muted
|
|
347
|
+
*/
|
|
348
|
+
audio: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Indicating whether video is muted
|
|
351
|
+
*/
|
|
352
|
+
video: boolean;
|
|
353
|
+
}
|
|
354
|
+
export interface MediaOptions {
|
|
355
|
+
/**
|
|
356
|
+
* Media signals to be used for the module
|
|
357
|
+
*
|
|
358
|
+
* @see MediaSignals
|
|
359
|
+
*/
|
|
360
|
+
signals: MediaSignals;
|
|
361
|
+
/**
|
|
362
|
+
* Media Processors
|
|
363
|
+
*/
|
|
364
|
+
mediaProcessors: MediaProcessor[];
|
|
365
|
+
/**
|
|
366
|
+
* A function to get the devices' mute state
|
|
367
|
+
*/
|
|
368
|
+
getMuteState: () => DeviceMuteState;
|
|
369
|
+
/**
|
|
370
|
+
* Pass default constraints to use with get media wrappers
|
|
371
|
+
*/
|
|
372
|
+
getDefaultConstraints?: () => {
|
|
373
|
+
audio?: InputConstraintSet | false;
|
|
374
|
+
video?: InputConstraintSet | false;
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
export interface MediaProps {
|
|
378
|
+
/**
|
|
379
|
+
* Current media
|
|
380
|
+
*/
|
|
381
|
+
media: Media;
|
|
382
|
+
/**
|
|
383
|
+
* Current device
|
|
384
|
+
*/
|
|
385
|
+
devices: MediaDeviceInfoLike[];
|
|
386
|
+
/**
|
|
387
|
+
* When should we discard the requested MediaStream
|
|
388
|
+
*/
|
|
389
|
+
discardMedia: boolean;
|
|
390
|
+
}
|
|
391
|
+
export interface MediaController {
|
|
392
|
+
/**
|
|
393
|
+
* Current Media
|
|
394
|
+
*/
|
|
395
|
+
media: Media;
|
|
396
|
+
/**
|
|
397
|
+
* Current device list
|
|
398
|
+
*/
|
|
399
|
+
devices: MediaDeviceInfoLike[];
|
|
400
|
+
/**
|
|
401
|
+
* Execute the media pipeline immediately with provided constraints
|
|
402
|
+
*
|
|
403
|
+
* @param constraints - @see MediaDeviceRequest
|
|
404
|
+
*/
|
|
405
|
+
getUserMedia: (constraints: MediaDeviceRequest) => void;
|
|
406
|
+
/**
|
|
407
|
+
* Execute the media pipeline immediately with provided constraints. An
|
|
408
|
+
* explicit version of `getUserMedia` to make it possible to chain other
|
|
409
|
+
* async actions
|
|
410
|
+
*
|
|
411
|
+
* @param constraints - @see MediaDeviceRequest
|
|
412
|
+
*/
|
|
413
|
+
getUserMediaAsync: (constraints: MediaDeviceRequest) => Promise<void>;
|
|
414
|
+
/**
|
|
415
|
+
* Cross-check PermissionState and available devices before requesting user
|
|
416
|
+
* media, the request will be skipped if there is no granted device.
|
|
417
|
+
*/
|
|
418
|
+
tryAndGetUserMedia: (constraints: MediaDeviceRequest) => void;
|
|
419
|
+
}
|
|
420
|
+
export type VideoRenderParams = Omit<RenderParams, 'backgroundImage' | 'effects'> & {
|
|
421
|
+
/**
|
|
422
|
+
* Target frame rate for the video segmentation
|
|
423
|
+
*/
|
|
424
|
+
frameRate: number;
|
|
425
|
+
/**
|
|
426
|
+
* Default background image URL for overlay effects
|
|
427
|
+
*/
|
|
428
|
+
bgImageUrl: string;
|
|
429
|
+
/**
|
|
430
|
+
* Render Effects
|
|
431
|
+
*/
|
|
432
|
+
videoSegmentation: RenderEffects;
|
|
433
|
+
pan?: boolean;
|
|
434
|
+
tilt?: boolean;
|
|
435
|
+
zoom?: boolean;
|
|
436
|
+
};
|
|
437
|
+
export interface StreamTrackSignals {
|
|
438
|
+
/**
|
|
439
|
+
* MediaStreamTrack events: mute
|
|
440
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack#events
|
|
441
|
+
*/
|
|
442
|
+
onStreamTrackMuted: Signal<MediaStreamTrack>;
|
|
443
|
+
/**
|
|
444
|
+
* MediaStreamTrack events: unmute
|
|
445
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack#events
|
|
446
|
+
*/
|
|
447
|
+
onStreamTrackUnmuted: Signal<MediaStreamTrack>;
|
|
448
|
+
/**
|
|
449
|
+
* MediaStreamTrack events: ended
|
|
450
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack#events
|
|
451
|
+
*/
|
|
452
|
+
onStreamTrackEnded: Signal<MediaStreamTrack>;
|
|
453
|
+
/**
|
|
454
|
+
* Emit `MediaStreamTrack` whenever a call to `Media['muteAudio']` or
|
|
455
|
+
* `Media['muteVideo']`
|
|
456
|
+
*/
|
|
457
|
+
onStreamTrackEnabled: Signal<MediaStreamTrack>;
|
|
458
|
+
}
|
|
459
|
+
export interface MediaChangesSignals {
|
|
460
|
+
onDevicesChanged: Signal<MediaDeviceInfoLike[]>;
|
|
461
|
+
onStatusChanged: Signal<UserMediaStatus>;
|
|
462
|
+
onMediaChanged: Signal<Media>;
|
|
463
|
+
}
|
|
464
|
+
export interface AudioDetectionSignals {
|
|
465
|
+
onVAD: Signal<undefined>;
|
|
466
|
+
onSilentDetected: Signal<boolean>;
|
|
467
|
+
}
|
|
468
|
+
export type MediaSignalsOptional = Pick<Partial<MediaChangesSignals>, 'onDevicesChanged' | 'onStatusChanged'> & Partial<StreamTrackSignals>;
|
|
469
|
+
export type MediaSignalsRequired = Pick<MediaChangesSignals, 'onMediaChanged'> & AudioDetectionSignals;
|
|
470
|
+
export type MediaSignals = MediaSignalsRequired & MediaSignalsOptional;
|
|
471
|
+
export declare enum DeniedDevices {
|
|
472
|
+
Microphone = "microphone",
|
|
473
|
+
Camera = "camera",
|
|
474
|
+
Both = "microphone-and-camera"
|
|
475
|
+
}
|
|
476
|
+
export interface Segmenters {
|
|
477
|
+
mediapipeSelfie: Segmenter;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Audio content hints are only applicable when the MediaStreamTrack contains an
|
|
481
|
+
* audio track
|
|
482
|
+
*
|
|
483
|
+
* {@link https://www.w3.org/TR/mst-content-hint/#audio-content-hints}
|
|
484
|
+
*/
|
|
485
|
+
export declare const AUDIO_CONTENT_HINTS: {
|
|
486
|
+
/**
|
|
487
|
+
* No hint has been provided, the implementation should make its
|
|
488
|
+
* best-informed guess on how to handle contained audio data. This may be
|
|
489
|
+
* inferred from how the track was opened or by doing content analysis
|
|
490
|
+
*/
|
|
491
|
+
readonly NoHint: "";
|
|
492
|
+
/**
|
|
493
|
+
* The track should be treated as if it contains speech data. Consuming this
|
|
494
|
+
* signal it may be appropriate to apply noise suppression or boost
|
|
495
|
+
* intelligibility of the incoming signal.
|
|
496
|
+
*/
|
|
497
|
+
readonly Speech: "speech";
|
|
498
|
+
/**
|
|
499
|
+
* The track should be treated as if it contains data for the purpose of
|
|
500
|
+
* speech recognition by a machine. Consuming this signal it may be
|
|
501
|
+
* appropriate to boost intelligibility of the incoming signal for
|
|
502
|
+
* transcription and turn off audio-processing components that are used for
|
|
503
|
+
* human consumption.
|
|
504
|
+
*/
|
|
505
|
+
readonly SpeechRecognition: "speech-recognition";
|
|
506
|
+
/**
|
|
507
|
+
* The track should be treated as if it contains music data. Generally this
|
|
508
|
+
* might imply tuning or turning off audio-processing components that are
|
|
509
|
+
* used to process speech data to prevent the audio from being distorted.
|
|
510
|
+
*/
|
|
511
|
+
readonly Music: "music";
|
|
512
|
+
};
|
|
513
|
+
export type AudioContentHint = (typeof AUDIO_CONTENT_HINTS)[keyof typeof AUDIO_CONTENT_HINTS];
|
|
514
|
+
/**
|
|
515
|
+
* Video content hints are only applicable when the MediaStreamTrack contains a
|
|
516
|
+
* video track.
|
|
517
|
+
*
|
|
518
|
+
* {@link https://www.w3.org/TR/mst-content-hint/#video-content-hints}
|
|
519
|
+
*/
|
|
520
|
+
export declare const VIDEO_CONTENT_HINTS: {
|
|
521
|
+
/**
|
|
522
|
+
* No hint has been provided, the implementation should make its
|
|
523
|
+
* best-informed guess on how contained video content should be treated.
|
|
524
|
+
* This can for example be inferred from how the track was opened or by
|
|
525
|
+
* doing content analysis.
|
|
526
|
+
*/
|
|
527
|
+
readonly NoHint: "";
|
|
528
|
+
/**
|
|
529
|
+
* The track should be treated as if it contains video where motion is
|
|
530
|
+
* important. This is normally webcam video, movies or video games.
|
|
531
|
+
* Quantization artefacts and downscaling are acceptable in order to
|
|
532
|
+
* preserve motion as well as possible while still retaining target
|
|
533
|
+
* bitrates. During low bitrates when compromises have to be made, more
|
|
534
|
+
* effort is spent on preserving frame rate than edge quality and details.
|
|
535
|
+
*/
|
|
536
|
+
readonly Motion: "motion";
|
|
537
|
+
/**
|
|
538
|
+
* The track should be treated as if video details are extra important.
|
|
539
|
+
* This is generally applicable to presentations or web pages with text
|
|
540
|
+
* content, painting or line art. This setting would normally optimize for
|
|
541
|
+
* detail in the resulting individual frames rather than smooth playback.
|
|
542
|
+
* Artefacts from quantization or downscaling that make small text or line
|
|
543
|
+
* art unintelligible should be avoided.
|
|
544
|
+
*/
|
|
545
|
+
readonly Detail: "detail";
|
|
546
|
+
/**
|
|
547
|
+
* The track should be treated as if video details are extra important, and
|
|
548
|
+
* that significant sharp edges and areas of consistent color can occur
|
|
549
|
+
* frequently. This is generally applicable to presentations or web pages
|
|
550
|
+
* with text content. This setting would normally optimize for detail in the
|
|
551
|
+
* resulting individual frames rather than smooth playback, and may take
|
|
552
|
+
* advantage of encoder tools that optimize for text rendering. Artefacts
|
|
553
|
+
* from quantization or downscaling that make small text or line art
|
|
554
|
+
* unintelligible should be avoided.
|
|
555
|
+
*/
|
|
556
|
+
readonly Text: "text";
|
|
557
|
+
};
|
|
558
|
+
export type VideoContentHint = (typeof VIDEO_CONTENT_HINTS)[keyof typeof VIDEO_CONTENT_HINTS];
|
|
559
|
+
export {};
|