@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/dist/index.d.ts CHANGED
@@ -1,837 +1,11 @@
1
- import * as _pexip_media_control from '@pexip/media-control';
2
- import { MediaDeviceRequest, MediaDeviceInfoLike, InputConstraintSet, DisplayMediaOptions } from '@pexip/media-control';
3
- import { RenderEffects, SegmentationModel, RenderParams, Segmenter, ThrottleOptions, AudioGraphOptions, AudioNodeInit, VideoProcessor, SegmentationTransform } from '@pexip/media-processor';
4
- import { Signal, SignalVariant } from '@pexip/signal';
5
- import { AsyncQueueOptions } from '@pexip/utils';
6
-
7
- type Unsubscribe = () => void;
8
- interface ExtendedMediaTrackSettings extends MediaTrackSettings {
9
- mixWithAdditionalMedia?: boolean;
10
- channelCount?: number;
11
- denoise?: boolean;
12
- vad?: boolean;
13
- asd?: boolean;
14
- backgroundBlurAmount?: number;
15
- bgImageUrl?: string;
16
- edgeBlurAmount?: number;
17
- flipHorizontal?: boolean;
18
- foregroundThreshold?: number;
19
- videoSegmentation?: RenderEffects;
20
- videoSegmentationModel?: SegmentationModel;
21
- pan?: boolean;
22
- tilt?: boolean;
23
- zoom?: boolean;
24
- contentHint?: AudioContentHint | VideoContentHint;
25
- }
26
- type ExtendedMediaTrackSettingsKey = keyof ExtendedMediaTrackSettings;
27
- interface MediaSettings {
28
- audio: ExtendedMediaTrackSettings[];
29
- video: ExtendedMediaTrackSettings[];
30
- }
31
- /**
32
- * URL links needed for creating a denoise node for audio processing
33
- */
34
- interface DenoiseParams {
35
- /**
36
- * wasm URL to get the denoise wasm
37
- */
38
- wasmURL: string;
39
- /**
40
- * AudioWorklet module URL to get the worklet, @see AudioContext['audioWorklet']['addModule']
41
- */
42
- workletModule: string;
43
- /**
44
- * AudioWorklet options to pass @see AudioContext['audioWorklet']['addModule']
45
- */
46
- workletOptions?: WorkletOptions;
47
- }
48
- interface MediaAttributes {
49
- /**
50
- * The constraints used to request the media
51
- */
52
- constraints?: MediaDeviceRequest;
53
- /**
54
- * The devices used for the media
55
- */
56
- devices: MediaDeviceInfoLike[];
57
- /**
58
- * Media stream for the media
59
- */
60
- stream?: MediaStream;
61
- /**
62
- * The raw stream obtained from the `getUserMedia` API
63
- */
64
- rawStream?: MediaStream;
65
- /**
66
- * Audio input device is used for the audio track from the current stream
67
- */
68
- audioInput?: MediaDeviceInfoLike;
69
- /**
70
- * Video input device is used for the video track from the current stream
71
- */
72
- videoInput?: MediaDeviceInfoLike;
73
- /**
74
- * The audio input device which is expected to be used for the current
75
- * stream based on the provided constraints
76
- */
77
- expectedAudioInput?: MediaDeviceInfoLike;
78
- /**
79
- * The video input device which is expected to be used for the current
80
- * stream based on the provided constraints
81
- */
82
- expectedVideoInput?: MediaDeviceInfoLike;
83
- /**
84
- * The status of the media
85
- */
86
- status: UserMediaStatus;
87
- /**
88
- * Current mute state of audio track
89
- * `undefined` means there is no such track from the stream
90
- */
91
- audioMuted: boolean | undefined;
92
- /**
93
- * Current mute state of video track
94
- * `undefined` means there is no such track from the stream
95
- */
96
- videoMuted: boolean | undefined;
97
- }
98
- interface Media extends MediaAttributes {
99
- /**
100
- * mute/unmute the audio track
101
- */
102
- muteAudio(mute: boolean): void;
103
- /**
104
- * mute/unmute the video track
105
- */
106
- muteVideo(mute: boolean): void;
107
- /**
108
- * Apply the constraints to the current media
109
- */
110
- applyConstraints(constraints: MediaDeviceRequest): Promise<void>;
111
- /**
112
- * Release the media resources, e.g. camera/microphone
113
- */
114
- release(): Promise<void>;
115
- getSettings(): MediaSettings;
116
- toJSON?: () => unknown;
117
- }
118
- type Process<T> = (a: T) => Promise<Media>;
119
- type MediaProcessor = Process<Promise<Media>>;
120
- /**
121
- * A media pipeline to get and process media
122
- */
123
- type Pipeline<T = MediaDeviceRequest> = [
124
- Process<T>,
125
- ...MediaProcessor[]
126
- ];
127
- type ProcessMedia = (media: Media) => undefined | Media;
128
- /**
129
- * Use which processor API to process the stream track
130
- * `stream` - Use MediaStreamTrackProcessor, when available
131
- * `canvas` - Use Canvas
132
- */
133
- type VideoStreamTrackProcessorAPIs = 'stream' | 'canvas';
134
- declare enum UserMediaStatus {
135
- /**
136
- * The initial status
137
- */
138
- Initial = "initial",
139
- /**
140
- * When we know the permissions were already granted from permission API
141
- */
142
- InitialPermissionsGranted = "initial-permissions-granted",
143
- /**
144
- * When we do not know the permissions from permission API
145
- */
146
- InitialPermissionsNotGranted = "initial-permissions-not-granted",
147
- /**
148
- * When video input permissions are initially denied in the browser and audio input permissions are unknown
149
- */
150
- InitialPermissionsVideoInputDenied = "initial-permissions-videoinput-denied",
151
- /**
152
- * When audio input permissions are initially denied in the browser and video input permissions are unknown
153
- */
154
- InitialPermissionsAudioInputDenied = "initial-permissions-audioinput-denied",
155
- /**
156
- * When video input permissions are granted in the browser and audio input permissions are unknown
157
- */
158
- InitialPermissionsVideoInputGranted = "initial-permissions-videoinput-granted",
159
- /**
160
- * When audio input permissions are granted in the browser and video input permissions are unknown
161
- */
162
- InitialPermissionsAudioInputGranted = "initial-permissions-audioinput-granted",
163
- /**
164
- * When audio input permissions are granted but video input permissions are initially denied
165
- */
166
- InitialPermissionsGrantedVideoInputDenied = "initial-permissions-audioinput-granted-videoinput-denied",
167
- /**
168
- * When video input permissions are granted but audio input permissions are initially denied
169
- */
170
- InitialPermissionsGrantedAudioInputDenied = "initial-permissions-videoinput-granted-audioinput-denied",
171
- /**
172
- * When there is no any kind of input devices
173
- */
174
- NoDevicesFound = "no-devices-found",
175
- /**
176
- * When there is no any video input devices
177
- */
178
- NoVideoDevicesFound = "no-video-devices-found",
179
- /**
180
- * When there is no any audio input devices
181
- */
182
- NoAudioDevicesFound = "no-audio-devices-found",
183
- /**
184
- * Derived from `MediaDeviceFailure.AudioInputDeviceNotFoundError`
185
- */
186
- AudioDeviceNotFound = "audio-device-not-found",
187
- /**
188
- * Derived from `MediaDeviceFailure.VideoInputDeviceNotFoundError`
189
- */
190
- VideoDeviceNotFound = "video-device-not-found",
191
- /**
192
- * Derived from `MediaDeviceFailure.AudioAndVideoDeviceNotFoundError`
193
- */
194
- AudioVideoDevicesNotFound = "audio-video-devices-not-found",
195
- /**
196
- * When Permission is granted by user for both video and audio, and both
197
- * devices are exactly matched with the request constraints
198
- */
199
- PermissionsGranted = "permissions-granted",
200
- /**
201
- * When Permission is granted by user for both video and audio, and both
202
- * devices are NOT exactly matched with the request constraints
203
- */
204
- PermissionsGrantedFallback = "permissions-granted-fallback-devices",
205
- /**
206
- * When Permission is granted by user for both video and audio, and audio
207
- * input is NOT exactly matched with the request constraints
208
- */
209
- PermissionsGrantedFallbackAudioinput = "permissions-granted-fallback-audioinput",
210
- /**
211
- * When Permission is granted by user for both video and audio, and video
212
- * input is NOT exactly matched with the request constraints
213
- */
214
- PermissionsGrantedFallbackVideoinput = "permissions-granted-fallback-videoinput",
215
- /**
216
- * When Permission for using both audio and video devices are rejected by the user
217
- * from `PermissionDeniedError`
218
- */
219
- PermissionsRejected = "permissions-rejected",
220
- /**
221
- * When Permission for using the audio device is rejected by the user
222
- * from `PermissionDeniedError`
223
- */
224
- PermissionsRejectedAudioInput = "permissions-rejected-audioinput",
225
- /**
226
- * When Permission for using the video device is rejected by the user
227
- * from `PermissionDeniedError`
228
- */
229
- PermissionsRejectedVideoInput = "permissions-rejected-videoinput",
230
- /**
231
- * When only request and return exact audio input device
232
- */
233
- PermissionsOnlyAudioinput = "permissions-only-audioinput",
234
- /**
235
- * When only request audio input device because of no video devices
236
- * available and returned exact audio input device
237
- */
238
- PermissionsOnlyAudioinputNoVideoDevices = "permissions-only-audioinput-no-video-devices",
239
- /**
240
- * When only request and returned NOT exact audio input device
241
- */
242
- PermissionsOnlyAudioinputFallback = "permissions-only-fallback-audioinput",
243
- /**
244
- * When only request audio input device because of no video devices
245
- * available and returned NOT exact audio input device
246
- */
247
- PermissionsOnlyAudioinputFallbackNoVideoDevices = "permissions-only-fallback-audioinput-no-video-devices",
248
- /**
249
- * When only request and return exact video input device
250
- */
251
- PermissionsOnlyVideoinput = "permissions-only-videoinput",
252
- /**
253
- * When only request video input device because of no audio devices
254
- * available and returned exact video input device
255
- */
256
- PermissionsOnlyVideoinputNoAudioDevices = "permissions-only-videoinput-no-audio-devices",
257
- /**
258
- * When only request and returned NOT exact video input device
259
- */
260
- PermissionsOnlyVideoinputFallback = "permissions-only-fallback-videoinput",
261
- /**
262
- * When only request video input device because of no video devices
263
- * available and returned NOT exact video input device
264
- */
265
- PermissionsOnlyVideoinputFallbackNoAudioDevices = "permissions-only-fallback-videoinput-no-audio-devices",
266
- /**
267
- * When requesting the audio device is used by other application
268
- */
269
- AudioDeviceInUse = "audio-device-in-use",
270
- /**
271
- * When requesting the video device is used by other application
272
- */
273
- VideoDeviceInUse = "video-device-in-use",
274
- /**
275
- * When requesting both audio and video devices are used by other application
276
- */
277
- DevicesInUse = "devices-in-use",
278
- /**
279
- * When requesting both audio and video with over-constrained
280
- */
281
- Overconstrained = "overconstrained",
282
- /**
283
- * When requesting video with over-constrained
284
- */
285
- VideoOverconstrained = "video-overconstrained",
286
- /**
287
- * When requesting audio with over-constrained
288
- */
289
- AudioOverconstrained = "audio-overconstrained",
290
- /**
291
- * When requesting both audio and video with invalid constraints
292
- */
293
- InvalidConstraints = "invalid-constraints",
294
- /**
295
- * When requesting video with invalid constraints
296
- */
297
- InvalidVideoConstraints = "invalid-video-constraints",
298
- /**
299
- * When requesting audio with invalid constraints
300
- */
301
- InvalidAudioConstraints = "invalid-audio-constraints",
302
- /**
303
- * When requesting both audio and video with NotSupportedError
304
- */
305
- NotSupportedError = "not-supported-error",
306
- /**
307
- * When requesting video with NotSupportedError
308
- */
309
- NotSupportedErrorOnlyVideoInput = "not-supported-error-only-video",
310
- /**
311
- * When requesting audio with NotSupportedError
312
- */
313
- NotSupportedErrorOnlyAudioInput = "not-supported-error-only-audio",
314
- /**
315
- * Unknown error from both video and audio
316
- */
317
- UnknownError = "unknown-error",
318
- /**
319
- * Unknown error from audio device
320
- */
321
- UnknownErrorOnlyAudioinput = "unknown-error-only-audioinput",
322
- /**
323
- * Unknown error from video device
324
- */
325
- UnknownErrorOnlyVideoinput = "unknown-error-only-videoinput"
326
- }
327
- interface AudioSignalDetectionOptions {
328
- /**
329
- * Audio Signal Detection Duration in second
330
- */
331
- audioSignalDetectionDuration?: number;
332
- /**
333
- * Whether or not to detect audio signal for malfunctioning device
334
- */
335
- shouldDetectAudio: () => boolean;
336
- }
337
- interface VoiceActivityDetectionOptions {
338
- /**
339
- * Voice Activity Detection in millisecond
340
- */
341
- vadThrottleMS?: number;
342
- /**
343
- * Whether or not to detect voice activity
344
- */
345
- shouldDetectVoiceActivity: () => boolean;
346
- }
347
- interface DeviceMuteState {
348
- /**
349
- * Indicating whether audio is muted
350
- */
351
- audio: boolean;
352
- /**
353
- * Indicating whether video is muted
354
- */
355
- video: boolean;
356
- }
357
- interface MediaOptions {
358
- /**
359
- * Media signals to be used for the module
360
- *
361
- * @see MediaSignals
362
- */
363
- signals: MediaSignals;
364
- /**
365
- * Media Processors
366
- */
367
- mediaProcessors: MediaProcessor[];
368
- /**
369
- * A function to get the devices' mute state
370
- */
371
- getMuteState: () => DeviceMuteState;
372
- /**
373
- * Pass default constraints to use with get media wrappers
374
- */
375
- getDefaultConstraints?: () => {
376
- audio?: InputConstraintSet | false;
377
- video?: InputConstraintSet | false;
378
- };
379
- }
380
- interface MediaProps {
381
- /**
382
- * Current media
383
- */
384
- media: Media;
385
- /**
386
- * Current device
387
- */
388
- devices: MediaDeviceInfoLike[];
389
- /**
390
- * When should we discard the requested MediaStream
391
- */
392
- discardMedia: boolean;
393
- }
394
- interface MediaController {
395
- /**
396
- * Current Media
397
- */
398
- media: Media;
399
- /**
400
- * Current device list
401
- */
402
- devices: MediaDeviceInfoLike[];
403
- /**
404
- * Execute the media pipeline immediately with provided constraints
405
- *
406
- * @param constraints - @see MediaDeviceRequest
407
- */
408
- getUserMedia: (constraints: MediaDeviceRequest) => void;
409
- /**
410
- * Execute the media pipeline immediately with provided constraints. An
411
- * explicit version of `getUserMedia` to make it possible to chain other
412
- * async actions
413
- *
414
- * @param constraints - @see MediaDeviceRequest
415
- */
416
- getUserMediaAsync: (constraints: MediaDeviceRequest) => Promise<void>;
417
- /**
418
- * Cross-check PermissionState and available devices before requesting user
419
- * media, the request will be skipped if there is no granted device.
420
- */
421
- tryAndGetUserMedia: (constraints: MediaDeviceRequest) => void;
422
- }
423
- type VideoRenderParams = Omit<RenderParams, 'backgroundImage' | 'effects'> & {
424
- /**
425
- * Target frame rate for the video segmentation
426
- */
427
- frameRate: number;
428
- /**
429
- * Default background image URL for overlay effects
430
- */
431
- bgImageUrl: string;
432
- /**
433
- * Render Effects
434
- */
435
- videoSegmentation: RenderEffects;
436
- pan?: boolean;
437
- tilt?: boolean;
438
- zoom?: boolean;
439
- };
440
- interface StreamTrackSignals {
441
- /**
442
- * MediaStreamTrack events: mute
443
- * https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack#events
444
- */
445
- onStreamTrackMuted: Signal<MediaStreamTrack>;
446
- /**
447
- * MediaStreamTrack events: unmute
448
- * https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack#events
449
- */
450
- onStreamTrackUnmuted: Signal<MediaStreamTrack>;
451
- /**
452
- * MediaStreamTrack events: ended
453
- * https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack#events
454
- */
455
- onStreamTrackEnded: Signal<MediaStreamTrack>;
456
- /**
457
- * Emit `MediaStreamTrack` whenever a call to `Media['muteAudio']` or
458
- * `Media['muteVideo']`
459
- */
460
- onStreamTrackEnabled: Signal<MediaStreamTrack>;
461
- }
462
- interface MediaChangesSignals {
463
- onDevicesChanged: Signal<MediaDeviceInfoLike[]>;
464
- onStatusChanged: Signal<UserMediaStatus>;
465
- onMediaChanged: Signal<Media>;
466
- }
467
- interface AudioDetectionSignals {
468
- onVAD: Signal<undefined>;
469
- onSilentDetected: Signal<boolean>;
470
- }
471
- type MediaSignalsOptional = Pick<Partial<MediaChangesSignals>, 'onDevicesChanged' | 'onStatusChanged'> & Partial<StreamTrackSignals>;
472
- type MediaSignalsRequired = Pick<MediaChangesSignals, 'onMediaChanged'> & AudioDetectionSignals;
473
- type MediaSignals = MediaSignalsRequired & MediaSignalsOptional;
474
- declare enum DeniedDevices {
475
- Microphone = "microphone",
476
- Camera = "camera",
477
- Both = "microphone-and-camera"
478
- }
479
- interface Segmenters {
480
- mediapipeSelfie: Segmenter;
481
- }
482
- /**
483
- * Audio content hints are only applicable when the MediaStreamTrack contains an
484
- * audio track
485
- *
486
- * {@link https://www.w3.org/TR/mst-content-hint/#audio-content-hints}
487
- */
488
- declare const AUDIO_CONTENT_HINTS: {
489
- /**
490
- * No hint has been provided, the implementation should make its
491
- * best-informed guess on how to handle contained audio data. This may be
492
- * inferred from how the track was opened or by doing content analysis
493
- */
494
- readonly NoHint: "";
495
- /**
496
- * The track should be treated as if it contains speech data. Consuming this
497
- * signal it may be appropriate to apply noise suppression or boost
498
- * intelligibility of the incoming signal.
499
- */
500
- readonly Speech: "speech";
501
- /**
502
- * The track should be treated as if it contains data for the purpose of
503
- * speech recognition by a machine. Consuming this signal it may be
504
- * appropriate to boost intelligibility of the incoming signal for
505
- * transcription and turn off audio-processing components that are used for
506
- * human consumption.
507
- */
508
- readonly SpeechRecognition: "speech-recognition";
509
- /**
510
- * The track should be treated as if it contains music data. Generally this
511
- * might imply tuning or turning off audio-processing components that are
512
- * used to process speech data to prevent the audio from being distorted.
513
- */
514
- readonly Music: "music";
515
- };
516
- type AudioContentHint = (typeof AUDIO_CONTENT_HINTS)[keyof typeof AUDIO_CONTENT_HINTS];
517
- /**
518
- * Video content hints are only applicable when the MediaStreamTrack contains a
519
- * video track.
520
- *
521
- * {@link https://www.w3.org/TR/mst-content-hint/#video-content-hints}
522
- */
523
- declare const VIDEO_CONTENT_HINTS: {
524
- /**
525
- * No hint has been provided, the implementation should make its
526
- * best-informed guess on how contained video content should be treated.
527
- * This can for example be inferred from how the track was opened or by
528
- * doing content analysis.
529
- */
530
- readonly NoHint: "";
531
- /**
532
- * The track should be treated as if it contains video where motion is
533
- * important. This is normally webcam video, movies or video games.
534
- * Quantization artefacts and downscaling are acceptable in order to
535
- * preserve motion as well as possible while still retaining target
536
- * bitrates. During low bitrates when compromises have to be made, more
537
- * effort is spent on preserving frame rate than edge quality and details.
538
- */
539
- readonly Motion: "motion";
540
- /**
541
- * The track should be treated as if video details are extra important.
542
- * This is generally applicable to presentations or web pages with text
543
- * content, painting or line art. This setting would normally optimize for
544
- * detail in the resulting individual frames rather than smooth playback.
545
- * Artefacts from quantization or downscaling that make small text or line
546
- * art unintelligible should be avoided.
547
- */
548
- readonly Detail: "detail";
549
- /**
550
- * The track should be treated as if video details are extra important, and
551
- * that significant sharp edges and areas of consistent color can occur
552
- * frequently. This is generally applicable to presentations or web pages
553
- * with text content. This setting would normally optimize for detail in the
554
- * resulting individual frames rather than smooth playback, and may take
555
- * advantage of encoder tools that optimize for text rendering. Artefacts
556
- * from quantization or downscaling that make small text or line art
557
- * unintelligible should be avoided.
558
- */
559
- readonly Text: "text";
560
- };
561
- type VideoContentHint = (typeof VIDEO_CONTENT_HINTS)[keyof typeof VIDEO_CONTENT_HINTS];
562
-
563
- /**
564
- * Create an object to interact with the media scream, which is usually used for
565
- * our main stream.
566
- *
567
- * @param options - @see MediaOptions
568
- */
569
- declare const createMedia: ({ getMuteState, signals, mediaProcessors, getDefaultConstraints, }: MediaOptions) => MediaController;
570
-
571
- type AudioNodeInits = AudioNodeInit[];
572
- /**
573
- * A function to be called to create the AudioNodes needed for the graph
574
- * creation
575
- *
576
- * @param media - Media to be used for the AudioGraph creation
577
- */
578
- type CreateNodes = (media: Media) => AudioNodeInits;
579
- interface AudioProcessOptions {
580
- /**
581
- * An option is being passed to AnalyserNode creation when used
582
- * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize
583
- *
584
- * @defaultValue 2048
585
- */
586
- fftSize?: number;
587
- /**
588
- * Params needed for setting up noise suppression WebAssembly and
589
- * AudioWorklet
590
- */
591
- denoiseParams?: DenoiseParams;
592
- /**
593
- * Update frequency for analyzer per second
594
- *
595
- * @defaultValue 0.5
596
- */
597
- analyzerUpdateFrequency?: number;
598
- /**
599
- * Audio Signal Detection duration in second
600
- *
601
- * @defaultValue 4.0
602
- */
603
- audioSignalDetectionDuration?: number;
604
- /**
605
- * Callback when Voice Activity detected
606
- */
607
- onVoiceActivityDetected?: () => void;
608
- /**
609
- * Callback when Audio Signal detected
610
- */
611
- onAudioSignalDetected?: (silent: boolean) => void;
612
- /**
613
- * @see AudioGraphOptions
614
- */
615
- audioGraphOptions?: AudioGraphOptions;
616
- /**
617
- * Whether or to enable this processor
618
- */
619
- shouldEnable: () => boolean;
620
- /**
621
- * Insert additional nodes between the source and destination
622
- */
623
- createNodes?: CreateNodes;
624
- /**
625
- * Silent threshold, how large the value of the sample is considered as
626
- * silent in FFTed time domain
627
- */
628
- silentThreshold?: number;
629
- scope?: string;
630
- }
631
- /**
632
- * Create a Audio Stream Processor and will own the stream passed-in
633
- */
634
- declare const createAudioStreamProcess: ({ analyzerUpdateFrequency, audioGraphOptions, audioSignalDetectionDuration, clock, createNodes, denoiseParams, fftSize, onAudioSignalDetected, onVoiceActivityDetected, shouldEnable, silentThreshold, throttleMs, scope, }: AudioProcessOptions & ThrottleOptions) => Process<Promise<Media>>;
635
-
636
- interface ProcessorDeps {
637
- videoProcessor?: VideoProcessor;
638
- transformer?: SegmentationTransform;
639
- segmenters: Segmenters;
640
- videoSegmentationModel?: SegmentationModel;
641
- }
642
- interface VideoStreamProcessOptions extends Partial<VideoRenderParams>, Omit<ProcessorDeps, 'videoProcessor'> {
643
- /**
644
- * What API to use for processing the MediaStreamTrack
645
- * `stream` - Use MediaStreamTrackProcessor, when available
646
- * `canvas` - Use Canvas
647
- */
648
- trackProcessorAPI?: VideoStreamTrackProcessorAPIs;
649
- /**
650
- * Whether or to enable this processor
651
- */
652
- shouldEnable: () => boolean;
653
- /**
654
- * Callback when error occurs
655
- */
656
- onError?: (error: Error) => void;
657
- processingWidth: number;
658
- processingHeight: number;
659
- hasInitializedDeps?: boolean;
660
- width?: number;
661
- height?: number;
662
- scope?: string;
663
- }
664
- declare const createVideoStreamProcess: ({ trackProcessorAPI, processingWidth, processingHeight, shouldEnable, frameRate, videoSegmentation, foregroundThreshold, bgImageUrl, flipHorizontal, edgeBlurAmount, scope, ...options }: VideoStreamProcessOptions) => Process<Promise<Media>>;
665
-
666
- /**
667
- * Log meta and message with respective log level
668
- */
669
- type LogMethod = (meta: unknown, message?: string) => void;
670
- declare enum LogLevels {
671
- trace = 10,
672
- debug = 20,
673
- info = 30,
674
- warn = 40,
675
- error = 50,
676
- fatal = 60,
677
- silent
678
- }
679
- type LogLevelsString = keyof typeof LogLevels;
680
- type LogMethods = {
681
- [key in LogLevelsString]: LogMethod;
682
- };
683
- /**
684
- * Log Level from high to low, "fatal" | "error" | "warn" | "info" | "debug" | "trace"
685
- * Typically, debug and trace logs are only valid for development, and not needed in production
686
- */
687
- interface Logger extends LogMethods {
688
- /**
689
- * Adds a value to the redaction set, which makes it replaced by [REDACTED] when logged to file.
690
- *
691
- * @remarks
692
- * The redaction set is applied globally, and only applies to the log file, not console logs.
693
- *
694
- * @param value - the string to redact
695
- */
696
- redact(value: string): void;
697
- }
698
-
699
- declare function setLogger(newLogger: Logger): void;
700
-
701
- type EventCallback<T> = (event: T) => void;
702
- type EventErrorCallback = (error: Error) => void;
703
- type PreviewInput = MediaDeviceInfoLike | undefined;
704
- interface PreviewEventHandler {
705
- audioInput?: EventCallback<PreviewInput>;
706
- videoInput?: EventCallback<PreviewInput>;
707
- media?: EventCallback<Media>;
708
- videoInputError?: EventErrorCallback;
709
- audioInputError?: EventErrorCallback;
710
- applyChangesError?: EventErrorCallback;
711
- revertChangesError?: EventErrorCallback;
712
- updatingPreview?: EventCallback<boolean>;
713
- updatingMain?: EventCallback<boolean>;
714
- unsubscribeMain?: Unsubscribe;
715
- }
716
- interface PreviewStreamParams {
717
- getCurrentDevices: () => MediaDeviceInfoLike[];
718
- getCurrentMedia: () => Media | undefined;
719
- updateMainStream: (request: MediaDeviceRequest) => Promise<void>;
720
- mediaSignal: MediaSignals['onMediaChanged'];
721
- onEnded?: () => void;
722
- fftSize?: number;
723
- queueOptions?: Partial<AsyncQueueOptions>;
724
- processors: MediaProcessor[];
725
- }
726
- interface PreviewControllerProps {
727
- media: Media;
728
- audioInput?: MediaDeviceInfoLike;
729
- videoInput?: MediaDeviceInfoLike;
730
- updatingPreview: boolean;
731
- updatingMain: boolean;
732
- originalMainAudioInput?: MediaDeviceInfoLike;
733
- discardMedia: boolean;
734
- initialized: boolean;
735
- }
736
- interface PreviewStreamController {
737
- media: Media;
738
- audioInputChanged: boolean;
739
- videoInputChanged: boolean;
740
- inputChanged: boolean;
741
- audioInput: PreviewInput;
742
- videoInput: PreviewInput;
743
- updatingPreview: boolean;
744
- updatingMain: boolean;
745
- updateAudioInput(input: PreviewInput): void;
746
- updateVideoInput(input: PreviewInput): void;
747
- applyChanges(): Promise<void>;
748
- revertChanges(): Promise<void>;
749
- onMediaChanged(callback: EventCallback<Media>): Unsubscribe;
750
- onAudioInputChanged(callback: EventCallback<PreviewInput>): Unsubscribe;
751
- onVideoInputChanged(callback: EventCallback<PreviewInput>): Unsubscribe;
752
- onUpdatingPreview(callback: EventCallback<boolean>): Unsubscribe;
753
- onUpdatingMain(callback: EventCallback<boolean>): Unsubscribe;
754
- onAudioInputError(callback: EventErrorCallback): Unsubscribe;
755
- onVideoInputError(callback: EventErrorCallback): Unsubscribe;
756
- onApplyChangesError(callback: EventErrorCallback): Unsubscribe;
757
- onRevertChangesError(callback: EventErrorCallback): Unsubscribe;
758
- }
759
- declare const createPreviewStreamController: ({ getCurrentDevices, getCurrentMedia, updateMainStream, onEnded, mediaSignal, queueOptions, processors, }: PreviewStreamParams) => PreviewStreamController;
760
- type CreatePreviewStreamController = typeof createPreviewStreamController;
761
-
762
- type UserMediaValidator = (status: UserMediaStatus) => boolean;
763
- declare const isFallbackVideo: UserMediaValidator;
764
- declare const isFallbackAudio: UserMediaValidator;
765
- declare const isFallback: UserMediaValidator;
766
- declare const hasNoDevice: UserMediaValidator;
767
- declare const hasNoAudioDevices: UserMediaValidator;
768
- declare const hasNoVideoDevices: UserMediaValidator;
769
- declare const isGrantedOnlyVideoNoAudioDevices: UserMediaValidator;
770
- declare const isPromptAudio: UserMediaValidator;
771
- declare const isGrantedOnlyVideo: UserMediaValidator;
772
- declare const isGrantedOnlyAudioNoVideoDevices: UserMediaValidator;
773
- declare const isPromptVideo: UserMediaValidator;
774
- declare const isGrantedOnlyAudio: UserMediaValidator;
775
- declare const areBothGranted: UserMediaValidator;
776
- declare const isGrantedVideo: UserMediaValidator;
777
- declare const isGrantedAudio: UserMediaValidator;
778
- declare const isGranted: UserMediaValidator;
779
- declare const isOnlyAudioError: UserMediaValidator;
780
- declare const isOnlyVideoError: UserMediaValidator;
781
- declare const isRejected: UserMediaValidator;
782
- declare const isRejectedOnlyAudio: UserMediaValidator;
783
- declare const isRejectedOnlyVideo: UserMediaValidator;
784
- declare const isOverConstrained: UserMediaValidator;
785
- declare const isUnknownError: UserMediaValidator;
786
- declare const isInitial: UserMediaValidator;
787
- declare const isInitialPermissions: UserMediaValidator;
788
- declare const isInitialPermissionsNotGranted: UserMediaValidator;
789
- declare const isInitialPermissionsGranted: UserMediaValidator;
790
- declare const isAudioDeviceInUse: UserMediaValidator;
791
- declare const isDeviceInUse: UserMediaValidator;
792
- declare const isVideoDeviceInUse: UserMediaValidator;
793
- declare const toDeniedDevices: (status?: UserMediaStatus) => DeniedDevices | undefined;
794
- declare const getPermissionStatus: (getPermissionState?: (anyActiveStream?: boolean | undefined) => Promise<_pexip_media_control.InputDevicePermission>) => Promise<UserMediaStatus.Initial | UserMediaStatus.InitialPermissionsGranted | UserMediaStatus.InitialPermissionsNotGranted | UserMediaStatus.InitialPermissionsVideoInputDenied | UserMediaStatus.InitialPermissionsAudioInputDenied | UserMediaStatus.InitialPermissionsVideoInputGranted | UserMediaStatus.InitialPermissionsAudioInputGranted | UserMediaStatus.InitialPermissionsGrantedVideoInputDenied | UserMediaStatus.InitialPermissionsGrantedAudioInputDenied | UserMediaStatus.PermissionsRejected>;
795
- declare const deriveInitialPermissionStatus: (prevStatus: UserMediaStatus, getPermissionState?: (anyActiveStream?: boolean | undefined) => Promise<_pexip_media_control.InputDevicePermission>) => Promise<UserMediaStatus>;
796
-
797
- /**
798
- * Create a general signal with consistent scoped name
799
- *
800
- * @param name - Signal name
801
- * @param crucial - Signify if the signal is unmissable. @defaultValue true
802
- * @param variant - The variant of the signal @see Signal @defaultValue 'generic'
803
- */
804
- declare const createMediaSignal: <T = undefined>(name: string, crucial?: boolean, variant?: SignalVariant) => Signal<T>;
805
- declare const REQUIRED_SIGNAL_KEYS: readonly ["onMediaChanged", "onVAD", "onSilentDetected"];
806
- /**
807
- * Create and return all required and optional (if specified with `more`),
808
- * signals for media to work
809
- *
810
- * @param more - Keys from `MediaSignalsOptional`, @see MediaSignalsOptional
811
- * @param scope - any scope prefix for the generated signal name, @see Signal
812
- *
813
- * The following signals created by default
814
- * - 'onMediaChanged',
815
- * - 'onVAD',
816
- *
817
- * @see REQUIRED_SIGNAL_KEYS
818
- */
819
- declare const createMediaSignals: <K extends "onDevicesChanged" | "onStatusChanged" | keyof StreamTrackSignals>(more: K[], scope?: string) => Pick<Required<MediaSignals>, "onMediaChanged" | "onVAD" | "onSilentDetected" | K>;
820
-
821
- /**
822
- * Apply the content hint to the track
823
- *
824
- * @param hint - Content hint
825
- * @param track - The track to be applied
826
- */
827
- declare const applyContentHint: <T extends "" | "speech" | "speech-recognition" | "music" | "motion" | "detail" | "text">(hint?: T | undefined) => (track: MediaStreamTrack) => void;
828
-
829
- /**
830
- * Create a Audio Mixing Processor and will own the stream passed-in
831
- */
832
- declare const createAudioMixingProcess: (getCurrrentMedia: () => MediaStream | undefined, scope?: string) => Process<Promise<Media>>;
833
-
834
- declare const createGetDisplayMedia: (getDefaultConstraints: () => DisplayMediaOptions, getDisplayMedia?: MediaDevices['getDisplayMedia']) => (constraints?: DisplayMediaOptions) => Promise<MediaStream | undefined>;
835
- type GetDisplayMedia = ReturnType<typeof createGetDisplayMedia>;
836
-
837
- export { AUDIO_CONTENT_HINTS, AudioContentHint, AudioDetectionSignals, AudioSignalDetectionOptions, CreatePreviewStreamController, DeniedDevices, DenoiseParams, ExtendedMediaTrackSettings, ExtendedMediaTrackSettingsKey, GetDisplayMedia, Media, MediaAttributes, MediaChangesSignals, MediaController, MediaOptions, MediaProcessor, MediaProps, MediaSettings, MediaSignals, MediaSignalsOptional, MediaSignalsRequired, Pipeline, PreviewControllerProps, PreviewEventHandler, PreviewInput, PreviewStreamController, PreviewStreamParams, Process, ProcessMedia, REQUIRED_SIGNAL_KEYS, Segmenters, StreamTrackSignals, Unsubscribe, UserMediaStatus, UserMediaValidator, VIDEO_CONTENT_HINTS, VideoContentHint, VideoRenderParams, VideoStreamTrackProcessorAPIs, VoiceActivityDetectionOptions, applyContentHint, areBothGranted, createAudioMixingProcess, createAudioStreamProcess, createGetDisplayMedia, createMedia, createMediaSignal, createMediaSignals, createPreviewStreamController, createVideoStreamProcess, deriveInitialPermissionStatus, getPermissionStatus, hasNoAudioDevices, hasNoDevice, hasNoVideoDevices, isAudioDeviceInUse, isDeviceInUse, isFallback, isFallbackAudio, isFallbackVideo, isGranted, isGrantedAudio, isGrantedOnlyAudio, isGrantedOnlyAudioNoVideoDevices, isGrantedOnlyVideo, isGrantedOnlyVideoNoAudioDevices, isGrantedVideo, isInitial, isInitialPermissions, isInitialPermissionsGranted, isInitialPermissionsNotGranted, isOnlyAudioError, isOnlyVideoError, isOverConstrained, isPromptAudio, isPromptVideo, isRejected, isRejectedOnlyAudio, isRejectedOnlyVideo, isUnknownError, isVideoDeviceInUse, setLogger, toDeniedDevices };
1
+ export { createMedia } from './media';
2
+ export { createAudioStreamProcess } from './audioProcessor';
3
+ export { createVideoStreamProcess } from './videoProcessor';
4
+ export * from './types';
5
+ export { setLogger } from './logger';
6
+ export * from './previewController';
7
+ export * from './status';
8
+ export * from './signals';
9
+ export { applyContentHint } from './utils';
10
+ export { createAudioMixingProcess } from './audioMixingProcessor';
11
+ export * from './displayMedia';