@pexip/media 21.0.0 → 22.1.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 +66 -0
- package/README.md +20 -32
- package/api-docs/README.mdx +20 -35
- package/api-docs/functions/applyContentHint.mdx +1 -1
- package/api-docs/functions/createAudioMixingProcess.mdx +1 -1
- package/api-docs/functions/createGetDisplayMedia.mdx +3 -3
- package/api-docs/functions/createMediaSignal.mdx +2 -2
- package/api-docs/functions/createMediaSignals.mdx +5 -3
- package/api-docs/functions/deriveInitialPermissionStatus.mdx +4 -2
- package/api-docs/functions/getPermissionStatus.mdx +31 -11
- package/api-docs/functions/toDeniedDevices.mdx +3 -1
- package/api-docs/interfaces/AudioDetectionSignals.mdx +2 -2
- package/api-docs/interfaces/AudioSignalDetectionOptions.mdx +1 -1
- package/api-docs/interfaces/ExtendedMediaTrackSettings.mdx +11 -7
- package/api-docs/interfaces/Media.mdx +4 -4
- package/api-docs/interfaces/MediaAttributes.mdx +2 -2
- package/api-docs/interfaces/MediaChangesSignals.mdx +5 -5
- package/api-docs/interfaces/MediaController.mdx +3 -3
- package/api-docs/interfaces/MediaInit.mdx +1 -1
- package/api-docs/interfaces/MediaOptions.mdx +3 -3
- package/api-docs/interfaces/MediaTrack.mdx +3 -3
- package/api-docs/interfaces/MediaTrackInit.mdx +12 -10
- package/api-docs/interfaces/PreviewControllerProps.mdx +1 -0
- package/api-docs/interfaces/PreviewEventHandler.mdx +7 -7
- package/api-docs/interfaces/PreviewStreamController.mdx +10 -10
- package/api-docs/interfaces/PreviewStreamParams.mdx +7 -6
- package/api-docs/interfaces/VoiceActivityDetectionOptions.mdx +1 -1
- package/api-docs/type-aliases/GetUserMediaProcess.mdx +4 -2
- package/api-docs/type-aliases/Process.mdx +3 -1
- package/api-docs/variables/internalSignals.mdx +1 -1
- package/dist/audioMixingProcessor.d.ts +4 -2
- package/dist/audioMixingProcessor.js +22 -12
- package/dist/audioProcessor.d.ts +7 -2
- package/dist/audioProcessor.js +25 -20
- package/dist/logger.d.ts +0 -2
- package/dist/logger.js +0 -16
- package/dist/media.js +5 -5
- package/dist/previewController.d.ts +3 -1
- package/dist/previewController.js +42 -9
- package/dist/typeGuard.d.ts +1 -2
- package/dist/typeGuard.js +0 -3
- package/dist/types.d.ts +7 -14
- package/dist/utils.js +15 -5
- package/dist/videoProcessor.d.ts +40 -22
- package/dist/videoProcessor.js +227 -247
- package/package.json +11 -11
- package/api-docs/functions/isVideoStreamTrackProcessorAPIs.mdx +0 -13
- package/api-docs/type-aliases/Segmenters.mdx +0 -3
- package/api-docs/type-aliases/VideoStreamTrackProcessorAPIs.mdx +0 -7
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IndexedDevices, InputConstraintSet, InputDeviceConstraint, MediaDeviceInfoLike, MediaDeviceRequest } from '@pexip/media-control';
|
|
2
|
-
import type { RendererOptions, RenderEffects
|
|
2
|
+
import type { RendererOptions, RenderEffects } from '@pexip/media-processor';
|
|
3
3
|
import type { Signal } from '@pexip/signal';
|
|
4
4
|
export type Unsubscribe = () => void;
|
|
5
5
|
export interface ExtendedMediaTrackSettings extends MediaTrackSettings {
|
|
@@ -14,10 +14,12 @@ export interface ExtendedMediaTrackSettings extends MediaTrackSettings {
|
|
|
14
14
|
maskCombineRatio?: number;
|
|
15
15
|
foregroundThreshold?: number;
|
|
16
16
|
videoSegmentation?: RenderEffects;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
panEnabled?: boolean;
|
|
18
|
+
tiltEnabled?: boolean;
|
|
19
|
+
zoomEnabled?: boolean;
|
|
20
|
+
pan?: number;
|
|
21
|
+
tilt?: number;
|
|
22
|
+
zoom?: number;
|
|
21
23
|
contentHint?: AudioContentHint | VideoContentHint;
|
|
22
24
|
}
|
|
23
25
|
export type ExtendedMediaTrackSettingsKey = keyof ExtendedMediaTrackSettings;
|
|
@@ -230,12 +232,6 @@ export type GetUserMediaProcess = (request: {
|
|
|
230
232
|
};
|
|
231
233
|
currentMedia: Media | undefined;
|
|
232
234
|
}) => Promise<Media>;
|
|
233
|
-
/**
|
|
234
|
-
* Use which processor API to process the stream track
|
|
235
|
-
* `stream` - Use `MediaStreamTrackProcessor`, when available
|
|
236
|
-
* `canvas` - Use Canvas
|
|
237
|
-
*/
|
|
238
|
-
export type VideoStreamTrackProcessorAPIs = 'stream' | 'canvas';
|
|
239
235
|
export declare enum UserMediaStatus {
|
|
240
236
|
/**
|
|
241
237
|
* The initial status
|
|
@@ -573,9 +569,6 @@ export declare enum DeniedDevices {
|
|
|
573
569
|
Camera = "camera",
|
|
574
570
|
Both = "microphone-and-camera"
|
|
575
571
|
}
|
|
576
|
-
export type Segmenters = {
|
|
577
|
-
[Property in SegmentationModel]: Segmenter;
|
|
578
|
-
};
|
|
579
572
|
/**
|
|
580
573
|
* Audio content hints are only applicable when the MediaStreamTrack contains an
|
|
581
574
|
* audio track
|
package/dist/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ import { calculateMaxBlurPass, clamping, } from '@pexip/media-processor';
|
|
|
3
3
|
import { hasOwn, assert, isEmpty } from '@pexip/utils';
|
|
4
4
|
import { internalSignals } from './signals';
|
|
5
5
|
import { MAX_TENT_BLUR_SIZE } from './constants';
|
|
6
|
+
import { mapFeatureToSettings } from './videoProcessor';
|
|
6
7
|
export const makeDeriveDeviceStatus = (constraints) => (audio, video, both) => {
|
|
7
8
|
if (constraints.audio) {
|
|
8
9
|
if (constraints.video) {
|
|
@@ -181,9 +182,9 @@ export const createMediaTrack = (trackInit) => {
|
|
|
181
182
|
},
|
|
182
183
|
async release() {
|
|
183
184
|
trackUnsubscribe?.();
|
|
184
|
-
trackInit.track?.stop();
|
|
185
185
|
await trackInit.release?.();
|
|
186
186
|
await trackInit.previousMediaTrack?.release();
|
|
187
|
+
trackInit.track?.stop();
|
|
187
188
|
trackInit.signals?.onMediaTrackStopped?.emit(this);
|
|
188
189
|
},
|
|
189
190
|
toJSON() {
|
|
@@ -571,7 +572,6 @@ export const AUDIO_SETTINGS_KEYS = [
|
|
|
571
572
|
export const VIDEO_SETTINGS_KEYS = [
|
|
572
573
|
'frameRate',
|
|
573
574
|
'videoSegmentation',
|
|
574
|
-
'videoSegmentationModel',
|
|
575
575
|
'foregroundThreshold',
|
|
576
576
|
'backgroundBlurAmount',
|
|
577
577
|
'edgeBlurAmount',
|
|
@@ -629,10 +629,11 @@ export const getSettingsFromKeys = (keys, settings) => {
|
|
|
629
629
|
return settings;
|
|
630
630
|
}
|
|
631
631
|
const result = {};
|
|
632
|
+
const mapped = mapFeatureToSettings(settings);
|
|
632
633
|
for (const key of keys) {
|
|
633
|
-
if (
|
|
634
|
+
if (mapped[key] !== undefined) {
|
|
634
635
|
// @ts-expect-error --- Type issue and need to be fixed when we have time
|
|
635
|
-
result[key] =
|
|
636
|
+
result[key] = mapped[key];
|
|
636
637
|
}
|
|
637
638
|
}
|
|
638
639
|
return result;
|
|
@@ -782,12 +783,21 @@ export const createMediaProcessor = ({ audioProcessors, videoProcessors, onProce
|
|
|
782
783
|
}
|
|
783
784
|
catch (error) {
|
|
784
785
|
if (error instanceof Error) {
|
|
786
|
+
if (track.stopped) {
|
|
787
|
+
// Ignore the error as track stopped
|
|
788
|
+
return track;
|
|
789
|
+
}
|
|
785
790
|
onProcessingError?.(error, track);
|
|
786
791
|
}
|
|
787
792
|
return track;
|
|
788
793
|
}
|
|
789
794
|
};
|
|
790
795
|
return async (newTracks) => {
|
|
791
|
-
return await Promise.all(newTracks.
|
|
796
|
+
return await Promise.all(newTracks.flatMap(track => {
|
|
797
|
+
if (track.stopped === undefined || track.stopped) {
|
|
798
|
+
return [];
|
|
799
|
+
}
|
|
800
|
+
return [processTrack(track)];
|
|
801
|
+
}));
|
|
792
802
|
};
|
|
793
803
|
};
|
package/dist/videoProcessor.d.ts
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import type { RenderBackend,
|
|
2
|
-
import type { MediaDeviceRequest } from '@pexip/media-control';
|
|
3
|
-
import type {
|
|
4
|
-
interface
|
|
5
|
-
segmenters: Partial<Segmenters>;
|
|
6
|
-
transformer?: SegmentationTransform;
|
|
7
|
-
videoProcessor?: () => VideoProcessor;
|
|
8
|
-
videoSegmentationModel?: SegmentationModel;
|
|
9
|
-
}
|
|
10
|
-
interface VideoStreamProcessOptions extends Partial<VideoRenderParams>, Omit<ProcessorDeps, 'videoProcessor'> {
|
|
11
|
-
/**
|
|
12
|
-
* What API to use for processing the MediaStreamTrack
|
|
13
|
-
* `stream` - Use MediaStreamTrackProcessor, when available
|
|
14
|
-
* `canvas` - Use Canvas
|
|
15
|
-
*/
|
|
16
|
-
trackProcessorAPI?: () => VideoStreamTrackProcessorAPIs;
|
|
1
|
+
import type { RenderBackend, VideoProcessor } from '@pexip/media-processor';
|
|
2
|
+
import type { InputConstraintSet, MediaDeviceRequest } from '@pexip/media-control';
|
|
3
|
+
import type { ExtendedMediaTrackSettings, MediaSignals, TrackProcessor, VideoContentHint, VideoRenderParams } from './types';
|
|
4
|
+
interface VideoStreamProcessOptions extends Partial<VideoRenderParams> {
|
|
17
5
|
/**
|
|
18
6
|
* Whether or to enable this processor
|
|
19
7
|
*/
|
|
20
8
|
shouldEnable: () => boolean;
|
|
9
|
+
getVideoProcessor: () => VideoProcessor;
|
|
21
10
|
referenceProcessingHeight?: number;
|
|
22
11
|
processingWidth: number;
|
|
23
12
|
processingHeight: number;
|
|
24
|
-
hasInitializedDeps?: boolean;
|
|
25
13
|
width?: number;
|
|
26
14
|
height?: number;
|
|
27
15
|
label?: string;
|
|
@@ -30,13 +18,43 @@ interface VideoStreamProcessOptions extends Partial<VideoRenderParams>, Omit<Pro
|
|
|
30
18
|
gpuAPI?: () => RenderBackend;
|
|
31
19
|
signals?: MediaSignals;
|
|
32
20
|
}
|
|
33
|
-
interface VideoStreamProcessProps extends Partial<VideoRenderParams
|
|
34
|
-
hasInitialized: boolean;
|
|
21
|
+
interface VideoStreamProcessProps extends Partial<VideoRenderParams> {
|
|
35
22
|
contentHint?: VideoContentHint;
|
|
36
23
|
}
|
|
37
|
-
declare const FEATURE_KEYS:
|
|
38
|
-
|
|
24
|
+
declare const FEATURE_KEYS: {
|
|
25
|
+
readonly backgroundBlurAmount: "number";
|
|
26
|
+
readonly backgroundImageUrl: "string";
|
|
27
|
+
readonly backgroundThreshold: "number";
|
|
28
|
+
readonly maskCombineRatio: "number";
|
|
29
|
+
readonly edgeBlurAmount: "number";
|
|
30
|
+
readonly foregroundThreshold: "number";
|
|
31
|
+
readonly frameRate: "number";
|
|
32
|
+
readonly videoSegmentation: "string";
|
|
33
|
+
readonly width: "number";
|
|
34
|
+
readonly height: "number";
|
|
35
|
+
readonly pan: "boolean";
|
|
36
|
+
readonly tilt: "boolean";
|
|
37
|
+
readonly zoom: "boolean";
|
|
38
|
+
readonly contentHint: "string";
|
|
39
|
+
readonly sigmaSpace: "number";
|
|
40
|
+
readonly sigmaRangeLo: "number";
|
|
41
|
+
readonly sigmaRangeHi: "number";
|
|
42
|
+
readonly excludeBystanders: "boolean";
|
|
43
|
+
readonly personCenterX: "number";
|
|
44
|
+
readonly personCenterY: "number";
|
|
45
|
+
readonly morphErodeRadiusPx: "number";
|
|
46
|
+
readonly morphPass: "number";
|
|
47
|
+
readonly morphDilateRadiusPx: "number";
|
|
48
|
+
readonly lightWrapIntensity: "number";
|
|
49
|
+
readonly lightWrapTightness: "number";
|
|
50
|
+
readonly lightWrapEdgeBand: "number";
|
|
51
|
+
readonly lightWrapBlurAmount: "number";
|
|
52
|
+
readonly downSampleFactor: "number";
|
|
53
|
+
};
|
|
54
|
+
type FeaturePropKeys = keyof typeof FEATURE_KEYS;
|
|
39
55
|
type FeatureProps = Pick<Partial<VideoStreamProcessProps>, FeaturePropKeys>;
|
|
40
56
|
export declare const updateFeatureProps: (constraints: MediaDeviceRequest["video"], props: FeatureProps) => FeatureProps;
|
|
41
|
-
export declare const
|
|
57
|
+
export declare const mapFeatureToSettings: (props: InputConstraintSet) => ExtendedMediaTrackSettings;
|
|
58
|
+
export declare const mapSettingsToFeatures: (settings: ExtendedMediaTrackSettings) => InputConstraintSet;
|
|
59
|
+
export declare const createVideoStreamProcess: ({ backgroundImageUrl, dynamicProcessingDimensions, backgroundThreshold, downSampleFactor, foregroundThreshold, lightWrapEdgeBand, lightWrapIntensity, lightWrapTightness, morphDilateRadiusPx, morphErodeRadiusPx, morphPass, personCenterX, personCenterY, sigmaSpace, sigmaRangeHi, sigmaRangeLo, frameRate, gpuAPI, label, referenceProcessingHeight, maskCombineRatio, processingHeight, processingWidth, shouldEnable, stopAsMute, videoSegmentation, signals, getVideoProcessor, ...options }: VideoStreamProcessOptions) => TrackProcessor;
|
|
42
60
|
export {};
|