@pexip/media-control 20.3.5 → 22.0.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 CHANGED
@@ -1,5 +1,68 @@
1
1
  # Changelog
2
2
 
3
+ ## 22.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 498ff3b: - **`extractConstraints` newly exported**
8
+ - **`videoSegmentationModel`** removed from `EXTENDED_CONSTRAIN_STRING_KEYS`
9
+ and `InputConstraintSet`.
10
+
11
+ ### Patch Changes
12
+
13
+ - fb41d4d: Changes related to Typescript V6 Upgrade
14
+ - Updated dependencies [498ff3b]
15
+ - Updated dependencies [fb41d4d]
16
+ - Updated dependencies [b99c070]
17
+ - @pexip/utils@17.3.0
18
+
19
+ ## 21.0.0
20
+
21
+ ### Minor Changes
22
+
23
+ - 1786b2d: `isStreamingRequestingDevice` returns `false` when request is `false`
24
+ Added an early return when request === false, so that a device kind explicitly
25
+ set to false in the constraints is correctly reported as not
26
+ streaming/requesting that device. Previously this case fell through to the
27
+ request === undefined check which returned true.
28
+ - a004e3c: Introduce new `renderParams` that can be applied via the video
29
+ constraints:
30
+ - `backgroundThreshold` - Segmentation threshold for classifying pixels as
31
+ background (lower values include more background).
32
+ - `downSampleFactor` - Factor for downsampling the video frame before
33
+ processing (higher values improve performance but reduce quality).
34
+ - `lightWrapBlurAmount` - Amount of blur applied to the light wrap effect
35
+ around the subject's edges.
36
+ - `lightWrapEdgeBand` - Width of the edge band in pixels where the light wrap
37
+ effect is applied.
38
+ - `lightWrapIntensity` - Intensity/strength of the light wrap effect (0.0 to
39
+ 1.0).
40
+ - `lightWrapTightness` - Controls how tightly the light wrap effect hugs the
41
+ subject's edges.
42
+ - `morphDilateRadiusPx` - Radius in pixels for morphological dilation
43
+ operation on the segmentation mask.
44
+ - `morphErodeRadiusPx` - Radius in pixels for morphological erosion operation
45
+ on the segmentation mask.
46
+ - `morphPass` - Number of morphological filter passes to apply for mask
47
+ refinement.
48
+ - `personCenterX` - X-coordinate (0.0 to 1.0) of the expected center position
49
+ of the person in the frame for segmentation optimization.
50
+ - `personCenterY` - Y-coordinate (0.0 to 1.0) of the expected center position
51
+ of the person in the frame for segmentation optimization.
52
+ - `sigmaRangeHi` - Bilateral filter: upper bound of sigma in color space for
53
+ edge-preserving smoothing.
54
+ - `sigmaRangeLo` - Bilateral filter: lower bound of sigma in color space for
55
+ edge-preserving smoothing.
56
+ - `sigmaSpace` - Bilateral filter: sigma in pixel space for mask edge
57
+ snapping.
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [1fff975]
62
+ - Updated dependencies [3963c2e]
63
+ - Updated dependencies [762ebd2]
64
+ - @pexip/utils@17.2.0
65
+
3
66
  ## 20.3.5
4
67
 
5
68
  ### Patch Changes
@@ -319,6 +319,7 @@ which devices are delivered, fail, or exist.
319
319
  | [getFacingModeFromConstraintString](functions/getFacingModeFromConstraintString.mdx) | - |
320
320
  | [resolveMediaDeviceConstraints](functions/resolveMediaDeviceConstraints.mdx) | Resolve *constraints* and mediaTrackConstraints by checking the type and try to return the best possible from mediaTrackConstraints. |
321
321
  | [applyConstraints](functions/applyConstraints.mdx) | Call applyConstraints foreach track accordingly |
322
+ | [extractConstraints](functions/extractConstraints.mdx) | - |
322
323
  | [extractConstraintsWithKeys](functions/extractConstraintsWithKeys.mdx) | Extract the constraints with provided keys |
323
324
  | [findDeviceFromConstraints](functions/findDeviceFromConstraints.mdx) | Find device from the device list with provided constraints |
324
325
  | [relaxInputConstraint](functions/relaxInputConstraint.mdx) | Relax input constraints to enable looking up the device by `deviceId` as well as `label` as a fallback as a best effort to get a similar device when possible. If the the device is found we will use the `exact` constraint otherwise we will use the `ideal`. |
@@ -0,0 +1,87 @@
1
+ ## Call Signature
2
+
3
+ ```ts
4
+ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainDeviceTuple>;
5
+ ```
6
+
7
+ ### Type Parameters
8
+
9
+ | Type Parameter |
10
+ | ------ |
11
+ | `T` *extends* `"device"` |
12
+
13
+ ### Parameters
14
+
15
+ | Parameter | Type |
16
+ | ------ | ------ |
17
+ | `key` | `T` |
18
+
19
+ ### Returns
20
+
21
+ `ExtractConstraintFn`\<`ConstrainDeviceTuple`\>
22
+
23
+ ## Call Signature
24
+
25
+ ```ts
26
+ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainStringTuple>;
27
+ ```
28
+
29
+ ### Type Parameters
30
+
31
+ | Type Parameter |
32
+ | ------ |
33
+ | `T` *extends* \| `"deviceId"` \| `"groupId"` \| `"videoSegmentation"` \| `"backgroundImageUrl"` \| `"resizeMode"` \| `"contentHint"` \| `"facingMode"` |
34
+
35
+ ### Parameters
36
+
37
+ | Parameter | Type |
38
+ | ------ | ------ |
39
+ | `key` | `T` |
40
+
41
+ ### Returns
42
+
43
+ `ExtractConstraintFn`\<`ConstrainStringTuple`\>
44
+
45
+ ## Call Signature
46
+
47
+ ```ts
48
+ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainNumberTuple>;
49
+ ```
50
+
51
+ ### Type Parameters
52
+
53
+ | Type Parameter |
54
+ | ------ |
55
+ | `T` *extends* `ConstrainNumberKeys` |
56
+
57
+ ### Parameters
58
+
59
+ | Parameter | Type |
60
+ | ------ | ------ |
61
+ | `key` | `T` |
62
+
63
+ ### Returns
64
+
65
+ `ExtractConstraintFn`\<`ConstrainNumberTuple`\>
66
+
67
+ ## Call Signature
68
+
69
+ ```ts
70
+ function extractConstraints<T>(key): ExtractConstraintFn<ConstrainBooleanTuple>;
71
+ ```
72
+
73
+ ### Type Parameters
74
+
75
+ | Type Parameter |
76
+ | ------ |
77
+ | `T` *extends* \| `"denoise"` \| `"vad"` \| `"asd"` \| `"mixWithAdditionalMedia"` \| `"excludeBystanders"` \| `"pan"` \| `"tilt"` \| `"zoom"` \| `"echoCancellation"` \| `"autoGainControl"` \| `"noiseSuppression"` |
78
+
79
+ ### Parameters
80
+
81
+ | Parameter | Type |
82
+ | ------ | ------ |
83
+ | `key` | `T` |
84
+
85
+ ### Returns
86
+
87
+ `ExtractConstraintFn`\<`ConstrainBooleanTuple`\>
@@ -8,7 +8,7 @@ Extract the constraints with provided keys
8
8
 
9
9
  | Type Parameter |
10
10
  | ------ |
11
- | `T` *extends* \| `"deviceId"` \| `"groupId"` \| `"device"` \| `"videoSegmentation"` \| `"videoSegmentationModel"` \| `"denoise"` \| `"vad"` \| `"asd"` \| `"mixWithAdditionalMedia"` \| `"backgroundImageUrl"` \| `"resizeMode"` \| `"pan"` \| `"tilt"` \| `"zoom"` \| `"contentHint"` \| `"facingMode"` \| `"echoCancellation"` \| `"autoGainControl"` \| `"noiseSuppression"` \| `ConstrainNumberKeys` |
11
+ | `T` *extends* \| `"deviceId"` \| `"groupId"` \| `"device"` \| `"videoSegmentation"` \| `"denoise"` \| `"vad"` \| `"asd"` \| `"mixWithAdditionalMedia"` \| `"backgroundImageUrl"` \| `"excludeBystanders"` \| `"resizeMode"` \| `"pan"` \| `"tilt"` \| `"zoom"` \| `"contentHint"` \| `"facingMode"` \| `"echoCancellation"` \| `"autoGainControl"` \| `"noiseSuppression"` \| `ConstrainNumberKeys` |
12
12
 
13
13
  ## Parameters
14
14
 
@@ -8,7 +8,6 @@
8
8
  | ------ | ------ | ------ | ------ |
9
9
  | <a id="device"></a> `device?` | `DeviceConstraint` \| `ConstraintDeviceParameters` | Same purpose as `deviceId` but it gives more information about the device so that we can have extra tolerance on device selection | - |
10
10
  | <a id="videosegmentation"></a> `videoSegmentation?` | `ConstrainDOMString` | Whether or not using video segmentation, e.g. background blur/replacement, to specify the effects, intended to be applied to the segment. Available effects are `none`, `blur`, `overlay` or `remove` | - |
11
- | <a id="videosegmentationmodel"></a> `videoSegmentationModel?` | `ConstrainDOMString` | Segmentation model to be used for video segmentation, currently only supports `mediapipeSelfie` and `personify` | - |
12
11
  | <a id="denoise"></a> `denoise?` | `ConstrainBoolean` | Whether or not using our own noise suppression | - |
13
12
  | <a id="vad"></a> `vad?` | `ConstrainBoolean` | Voice Activity Detection | - |
14
13
  | <a id="asd"></a> `asd?` | `ConstrainBoolean` | Audio Signal Detection for the purpose of checking if the audio input is hardware muted or unusable | - |
@@ -17,21 +16,34 @@
17
16
  | <a id="edgebluramount"></a> `edgeBlurAmount?` | `ConstrainULong` | Blur amount applied to the segmented person's edge | - |
18
17
  | <a id="foregroundthreshold"></a> `foregroundThreshold?` | `ConstrainDouble` | Erode level for edge smoothing when using video segmentation | - |
19
18
  | <a id="backgroundimageurl"></a> `backgroundImageUrl?` | `ConstrainDOMString` | Image Url that is being used for video overlay effects | - |
20
- | <a id="maskcombineratio"></a> `maskCombineRatio?` | `ConstrainDouble` | The ratio to be used for smoothing segmentation mask | - |
19
+ | <a id="maskcombineratio"></a> `maskCombineRatio?` | `ConstrainDouble` | The ratio to be used for smoothing segmentation mask. How much uncertainty enables temporal blend, [0,1]. Higher = more frame-to-frame blending, more stability but more trailing ghosts. Typical: 0.6–0.85. | - |
20
+ | <a id="backgroundthreshold"></a> `backgroundThreshold?` | `ConstrainDouble` | [0,1] Lower mask confidence: all mask pixels <= this are considered definite background. Adjust to make mask edges tighter or more permissive for background inclusion. Example: 0.3 ("mask < 0.3 = sure background"). | - |
21
+ | <a id="sigmaspace"></a> `sigmaSpace?` | `ConstrainDouble` | Bilateral filter: sigma in pixel space for mask edge snapping. Controls the neighborhood/pixel distance—higher is larger window (5–10 typical). | - |
22
+ | <a id="sigmarangelo"></a> `sigmaRangeLo?` | `ConstrainDouble` | Bilateral filter: minimum sigma in color/luma (for mask interiors), [0,1]. Controls how little color difference is needed to cross-mask regions away from edge. Lower = sharper edge preservation in mask interiors. Example: 0.2 | - |
23
+ | <a id="sigmarangehi"></a> `sigmaRangeHi?` | `ConstrainDouble` | Bilateral filter: maximum sigma in color/luma (for mask uncertain zones), [0,1]. Controls how much color similarity is required at uncertain/edge mask locations. Higher = more mask smoothing at edges. Example: 0.8 | - |
24
+ | <a id="excludebystanders"></a> `excludeBystanders?` | `ConstrainBoolean` | Whether to exclude bystanders/connected people from the output mask. The main person instance (closest to personCenter OR largest blob) is kept in the output mask. All other bystanders/connected people are suppressed (bystander removal). | - |
25
+ | <a id="personcenterx"></a> `personCenterX?` | `ConstrainDouble` | Person center: normalized in [0,1] image coordinates for main subject selection. Used by the CCL/bias filter to select the main person blob. | - |
26
+ | <a id="personcentery"></a> `personCenterY?` | `ConstrainDouble` | Person center: normalized in [0,1] image coordinates for main subject selection. Used by the CCL/bias filter to select the main person blob. | - |
27
+ | <a id="morpheroderadiuspx"></a> `morphErodeRadiusPx?` | `ConstrainULong` | Morphological erosion: radius in pixels [1,12]. Sets kernel size for bridge-breaking. Larger values break thicker bridges but may erode fine details. | - |
28
+ | <a id="morphpass"></a> `morphPass?` | `ConstrainULong` | Morphological pass: number of separable passes [1,10]. More passes increase the effective span. | - |
29
+ | <a id="morphdilateradiuspx"></a> `morphDilateRadiusPx?` | `ConstrainULong` | Geodesic dilation: radius in pixels [1,12]. Must match erosion for good reconstruction. | - |
30
+ | <a id="lightwrapintensity"></a> `lightWrapIntensity?` | `ConstrainDouble` | [0,1] Light wrap amount (halo intensity) at mask edge. Wraps blurred background color just outside the subject edge onto the subject boundary for realism. | - |
31
+ | <a id="lightwraptightness"></a> `lightWrapTightness?` | `ConstrainDouble` | [0.5,4.0] Controls power/tightness of the wrap band falloff. Higher = tighter/narrower wrap. | - |
32
+ | <a id="lightwrapedgeband"></a> `lightWrapEdgeBand?` | `ConstrainDouble` | Width of the wrap band (feather size, in normalized mask units) between the backgroundThreshold and foregroundThreshold in [0.0, (foregroundThreshold - backgroundThreshold) / 2] Higher = wider soft halo. | - |
33
+ | <a id="lightwrapbluramount"></a> `lightWrapBlurAmount?` | `ConstrainULong` | Blur amount used for background color in the wrap band (units=blur passes). | - |
34
+ | <a id="downsamplefactor"></a> `downSampleFactor?` | `ConstrainULong` | Downsampling factor for mask/blurring, must be [2,4]. 2 = half resolution, 4 = quarter resolution for faster filtering. Use for performance tuning vs. quality. | - |
21
35
  | <a id="resizemode"></a> `resizeMode?` | `ConstrainDOMString` | Image Url that is being used for video overlay effects | - |
22
36
  | <a id="pan"></a> `pan?` | `boolean` | Current pan, tilt and zoom level for a PTZ controllable camera on web | - |
23
37
  | <a id="tilt"></a> `tilt?` | `boolean` | - | - |
24
38
  | <a id="zoom"></a> `zoom?` | `boolean` | - | - |
25
39
  | <a id="contenthint"></a> `contentHint?` | `ConstrainDOMString` | Content Hint for the track to apply | - |
26
- | <a id="volume"></a> `volume?` | `ConstrainNumber` | - | `MediaTrackConstraints.volume` |
27
- | <a id="latency"></a> `latency?` | `ConstrainNumber` | - | `MediaTrackConstraints.latency` |
28
40
  | <a id="aspectratio"></a> `aspectRatio?` | `ConstrainDouble` | - | `MediaTrackConstraints.aspectRatio` |
29
41
  | <a id="autogaincontrol"></a> `autoGainControl?` | `ConstrainBoolean` | - | `MediaTrackConstraints.autoGainControl` |
30
42
  | <a id="backgroundblur"></a> `backgroundBlur?` | `ConstrainBoolean` | - | `MediaTrackConstraints.backgroundBlur` |
31
43
  | <a id="channelcount"></a> `channelCount?` | `ConstrainULong` | - | `MediaTrackConstraints.channelCount` |
32
44
  | <a id="deviceid"></a> `deviceId?` | `ConstrainDOMString` | - | `MediaTrackConstraints.deviceId` |
33
45
  | <a id="displaysurface"></a> `displaySurface?` | `ConstrainDOMString` | - | `MediaTrackConstraints.displaySurface` |
34
- | <a id="echocancellation"></a> `echoCancellation?` | `ConstrainBoolean` | - | `MediaTrackConstraints.echoCancellation` |
46
+ | <a id="echocancellation"></a> `echoCancellation?` | `ConstrainBooleanOrDOMString` | - | `MediaTrackConstraints.echoCancellation` |
35
47
  | <a id="facingmode"></a> `facingMode?` | `ConstrainDOMString` | - | `MediaTrackConstraints.facingMode` |
36
48
  | <a id="framerate"></a> `frameRate?` | `ConstrainDouble` | - | `MediaTrackConstraints.frameRate` |
37
49
  | <a id="groupid"></a> `groupId?` | `ConstrainDOMString` | - | `MediaTrackConstraints.groupId` |
@@ -213,7 +213,6 @@ export const extractConstrainBoolean = (key) => (constraints) => {
213
213
  return NONE;
214
214
  };
215
215
  export const extractConstrainNumber = (key) => (constraints) => {
216
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- @typescript-eslint and Typescript 5 issue.
217
216
  const constraint = constraints[key];
218
217
  if (constraint === undefined || constraint === null) {
219
218
  return NONE;
package/dist/devices.js CHANGED
@@ -372,6 +372,9 @@ export const resolveInputDevice = (tracksOrDevice, findInput) => {
372
372
  return undefined;
373
373
  };
374
374
  export const isStreamingRequestingDevice = (request, trackOrDevice, devices) => {
375
+ if (request === false) {
376
+ return false;
377
+ }
375
378
  if (request === undefined) {
376
379
  return true;
377
380
  }
@@ -438,7 +441,6 @@ export const queryPermissionFallback = async (name, everActiveTrack = false, get
438
441
  };
439
442
  export const queryPermission = async (name, everActiveTrack = false, getDevices = () => navigator.mediaDevices.enumerateDevices()) => {
440
443
  try {
441
- // @ts-expect-error -- Typings/dom.d.ts change blocks upgrade to typescript 4.4
442
444
  const { state } = await navigator.permissions.query({ name });
443
445
  // Firefox v133 added permission API but always returns granted but
444
446
  // based on the device label, it is actually not granted, so we need to
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { DeviceChangedChanges, areMultipleFacingModeSupported, areTracksEnabled, createTrackDevicesChanges, deviceChanged, findAudioInputDevices, findAudioOutputDevices, findCurrentAudioOutputId, findCurrentVideoInputDeviceIdFromStream, findDeviceWithDeviceId, findDevicesByKind, findMediaInputFromMediaStreamTrack, findMediaInputFromStream, findPermissionGrantedDevices, findVideoInputDevices, getDevices, getInputDevicePermissionState, hasAnyGrantedInput, hasAnyInputs, hasAudioInputs, hasAudioOrVideoInputs, hasChangedInput, hasRequestingDevice, hasVideoInputs, interpretCurrentFacingMode, isRequestedInputDevice, isRequestedInputTrack, isRequestedResolution, isStreamingRequestedDevices, isStreamingRequestedDevicesBase, isStreamingRequestingDevice, isTrackMutedOrEnded, muteStreamTrack, shouldRequestDevice, stopMediaStream, toKey, toMediaDeviceInfo, toMediaDeviceInfoLike, toMediaDeviceInputKind } from './devices';
11
11
  import { compareDevices, createIndexedDevices, findDevice, getDeviceId, isAudioInput, isAudioOutput, isDeviceGranted, isVideoInput, reverseDeviceId } from './utils';
12
- import { applyConstraints, extractConstrainDevice, extractConstraintsWithKeys, findDeviceFromConstraints, getFacingModeFromConstraintString, getValueFromConstrainNumber, isExactDeviceConstraint, mergeConstraints, relaxInputConstraint, resolveMediaDeviceConstraints } from './constraints';
12
+ import { applyConstraints, extractConstrainDevice, extractConstraints, extractConstraintsWithKeys, findDeviceFromConstraints, getFacingModeFromConstraintString, getValueFromConstrainNumber, isExactDeviceConstraint, mergeConstraints, relaxInputConstraint, resolveMediaDeviceConstraints } from './constraints';
13
13
  import { MediaEvent, Events, MediaEventType } from './eventEmitter';
14
14
  import { createStreamTrackEventSubscriptions } from './streams';
15
15
  import { DisplayMediaOptions, FacingMode, IndexedDevices, InputConstraintSet, InputDeviceConstraint, MediaDeviceFailure, MediaDeviceInfoLike, MediaDeviceKinds, MediaDeviceRequest, MediaInput, MediaStreamTrackLike, StreamTrackEventHandlers, Unsubscribe } from './types';
@@ -33,7 +33,7 @@ setDefaultConstraints: (newConstraints: MediaStreamConstraints) => void,
33
33
  */
34
34
  subscribe: (listener: (event: MediaEvent) => void) => () => void;
35
35
  export { getUserMedia, setDefaultConstraints, subscribe };
36
- export { DeviceChangedChanges, DisplayMediaOptions, Events, FacingMode, IndexedDevices, InputConstraintSet, InputDeviceConstraint, MediaDeviceFailure, MediaDeviceInfoLike, MediaDeviceKinds, MediaDeviceRequest, MediaEvent, MediaEventType, MediaInput, MediaStreamTrackLike, StreamTrackEventHandlers, Unsubscribe, applyConstraints, areMultipleFacingModeSupported, areTracksEnabled, compareDevices, createIndexedDevices, createStreamTrackEventSubscriptions, createTrackDevicesChanges, deviceChanged, extractConstrainDevice, extractConstraintsWithKeys, findAudioInputDevices, findAudioOutputDevices, findCurrentAudioOutputId, findCurrentVideoInputDeviceIdFromStream, findDevice, findDeviceFromConstraints, findDeviceWithDeviceId, findDevicesByKind, findMediaInputFromMediaStreamTrack, findMediaInputFromStream, findPermissionGrantedDevices, findVideoInputDevices, getDeviceId, getDevices, getFacingModeFromConstraintString, getInputDevicePermissionState, getValueFromConstrainNumber, hasAnyGrantedInput, hasAnyInputs, hasAudioInputs, hasAudioOrVideoInputs, hasChangedInput, hasRequestingDevice, hasVideoInputs, interpretCurrentFacingMode, isAudioInput, isAudioOutput, isDeviceGranted, isExactDeviceConstraint, isFacingMode, isIndexedDevices, isInputConstraintSet, isMediaDeviceInfo, isMediaDeviceInfoArray, isMediaStreamTrack, isRequestedInputDevice, isRequestedInputTrack, isRequestedResolution, isStreamingRequestedDevices, isStreamingRequestedDevicesBase, isStreamingRequestingDevice, isTrackMutedOrEnded, isVideoInput, mergeConstraints, muteStreamTrack, relaxInputConstraint, resolveMediaDeviceConstraints, reverseDeviceId, shouldRequestDevice, stopMediaStream, toKey, toMediaDeviceInfo, toMediaDeviceInfoLike, toMediaDeviceInputKind, };
36
+ export { DeviceChangedChanges, DisplayMediaOptions, Events, FacingMode, IndexedDevices, InputConstraintSet, InputDeviceConstraint, MediaDeviceFailure, MediaDeviceInfoLike, MediaDeviceKinds, MediaDeviceRequest, MediaEvent, MediaEventType, MediaInput, MediaStreamTrackLike, StreamTrackEventHandlers, Unsubscribe, applyConstraints, areMultipleFacingModeSupported, areTracksEnabled, compareDevices, createIndexedDevices, createStreamTrackEventSubscriptions, createTrackDevicesChanges, deviceChanged, extractConstrainDevice, extractConstraints, extractConstraintsWithKeys, findAudioInputDevices, findAudioOutputDevices, findCurrentAudioOutputId, findCurrentVideoInputDeviceIdFromStream, findDevice, findDeviceFromConstraints, findDeviceWithDeviceId, findDevicesByKind, findMediaInputFromMediaStreamTrack, findMediaInputFromStream, findPermissionGrantedDevices, findVideoInputDevices, getDeviceId, getDevices, getFacingModeFromConstraintString, getInputDevicePermissionState, getValueFromConstrainNumber, hasAnyGrantedInput, hasAnyInputs, hasAudioInputs, hasAudioOrVideoInputs, hasChangedInput, hasRequestingDevice, hasVideoInputs, interpretCurrentFacingMode, isAudioInput, isAudioOutput, isDeviceGranted, isExactDeviceConstraint, isFacingMode, isIndexedDevices, isInputConstraintSet, isMediaDeviceInfo, isMediaDeviceInfoArray, isMediaStreamTrack, isRequestedInputDevice, isRequestedInputTrack, isRequestedResolution, isStreamingRequestedDevices, isStreamingRequestedDevicesBase, isStreamingRequestingDevice, isTrackMutedOrEnded, isVideoInput, mergeConstraints, muteStreamTrack, relaxInputConstraint, resolveMediaDeviceConstraints, reverseDeviceId, shouldRequestDevice, stopMediaStream, toKey, toMediaDeviceInfo, toMediaDeviceInfoLike, toMediaDeviceInputKind, };
37
37
  export * from './constants';
38
38
  export * from './displayMedia';
39
39
  /**
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { areMultipleFacingModeSupported, areTracksEnabled, createTrackDevicesChanges, deviceChanged, findAudioInputDevices, findAudioOutputDevices, findCurrentAudioOutputId, findCurrentVideoInputDeviceIdFromStream, findDeviceWithDeviceId, findDevicesByKind, findMediaInputFromMediaStreamTrack, findMediaInputFromStream, findPermissionGrantedDevices, findVideoInputDevices, getDevices, getInputDevicePermissionState, hasAnyGrantedInput, hasAnyInputs, hasAudioInputs, hasAudioOrVideoInputs, hasChangedInput, hasRequestingDevice, hasVideoInputs, interpretCurrentFacingMode, isRequestedInputDevice, isRequestedInputTrack, isRequestedResolution, isStreamingRequestedDevices, isStreamingRequestedDevicesBase, isStreamingRequestingDevice, isTrackMutedOrEnded, muteStreamTrack, shouldRequestDevice, stopMediaStream, toKey, toMediaDeviceInfo, toMediaDeviceInfoLike, toMediaDeviceInputKind, } from './devices';
11
11
  import { compareDevices, createIndexedDevices, findDevice, getDeviceId, isAudioInput, isAudioOutput, isDeviceGranted, isVideoInput, reverseDeviceId, } from './utils';
12
- import { applyConstraints, extractConstrainDevice, extractConstraintsWithKeys, findDeviceFromConstraints, getConstraintsHandlers, getFacingModeFromConstraintString, getValueFromConstrainNumber, isExactDeviceConstraint, mergeConstraints, relaxInputConstraint, resolveMediaDeviceConstraints, } from './constraints';
12
+ import { applyConstraints, extractConstrainDevice, extractConstraints, extractConstraintsWithKeys, findDeviceFromConstraints, getConstraintsHandlers, getFacingModeFromConstraintString, getValueFromConstrainNumber, isExactDeviceConstraint, mergeConstraints, relaxInputConstraint, resolveMediaDeviceConstraints, } from './constraints';
13
13
  import { eventEmitter, MediaEventType } from './eventEmitter';
14
14
  import { handleMediaStream, createStreamTrackEventSubscriptions, } from './streams';
15
15
  import { MediaDeviceFailure, MediaDeviceKinds, } from './types';
@@ -91,6 +91,6 @@ setDefaultConstraints,
91
91
  */
92
92
  subscribe, } = state();
93
93
  export { getUserMedia, setDefaultConstraints, subscribe };
94
- export { MediaDeviceFailure, MediaDeviceKinds, MediaEventType, applyConstraints, areMultipleFacingModeSupported, areTracksEnabled, compareDevices, createIndexedDevices, createStreamTrackEventSubscriptions, createTrackDevicesChanges, deviceChanged, extractConstrainDevice, extractConstraintsWithKeys, findAudioInputDevices, findAudioOutputDevices, findCurrentAudioOutputId, findCurrentVideoInputDeviceIdFromStream, findDevice, findDeviceFromConstraints, findDeviceWithDeviceId, findDevicesByKind, findMediaInputFromMediaStreamTrack, findMediaInputFromStream, findPermissionGrantedDevices, findVideoInputDevices, getDeviceId, getDevices, getFacingModeFromConstraintString, getInputDevicePermissionState, getValueFromConstrainNumber, hasAnyGrantedInput, hasAnyInputs, hasAudioInputs, hasAudioOrVideoInputs, hasChangedInput, hasRequestingDevice, hasVideoInputs, interpretCurrentFacingMode, isAudioInput, isAudioOutput, isDeviceGranted, isExactDeviceConstraint, isFacingMode, isIndexedDevices, isInputConstraintSet, isMediaDeviceInfo, isMediaDeviceInfoArray, isMediaStreamTrack, isRequestedInputDevice, isRequestedInputTrack, isRequestedResolution, isStreamingRequestedDevices, isStreamingRequestedDevicesBase, isStreamingRequestingDevice, isTrackMutedOrEnded, isVideoInput, mergeConstraints, muteStreamTrack, relaxInputConstraint, resolveMediaDeviceConstraints, reverseDeviceId, shouldRequestDevice, stopMediaStream, toKey, toMediaDeviceInfo, toMediaDeviceInfoLike, toMediaDeviceInputKind, };
94
+ export { MediaDeviceFailure, MediaDeviceKinds, MediaEventType, applyConstraints, areMultipleFacingModeSupported, areTracksEnabled, compareDevices, createIndexedDevices, createStreamTrackEventSubscriptions, createTrackDevicesChanges, deviceChanged, extractConstrainDevice, extractConstraints, extractConstraintsWithKeys, findAudioInputDevices, findAudioOutputDevices, findCurrentAudioOutputId, findCurrentVideoInputDeviceIdFromStream, findDevice, findDeviceFromConstraints, findDeviceWithDeviceId, findDevicesByKind, findMediaInputFromMediaStreamTrack, findMediaInputFromStream, findPermissionGrantedDevices, findVideoInputDevices, getDeviceId, getDevices, getFacingModeFromConstraintString, getInputDevicePermissionState, getValueFromConstrainNumber, hasAnyGrantedInput, hasAnyInputs, hasAudioInputs, hasAudioOrVideoInputs, hasChangedInput, hasRequestingDevice, hasVideoInputs, interpretCurrentFacingMode, isAudioInput, isAudioOutput, isDeviceGranted, isExactDeviceConstraint, isFacingMode, isIndexedDevices, isInputConstraintSet, isMediaDeviceInfo, isMediaDeviceInfoArray, isMediaStreamTrack, isRequestedInputDevice, isRequestedInputTrack, isRequestedResolution, isStreamingRequestedDevices, isStreamingRequestedDevicesBase, isStreamingRequestingDevice, isTrackMutedOrEnded, isVideoInput, mergeConstraints, muteStreamTrack, relaxInputConstraint, resolveMediaDeviceConstraints, reverseDeviceId, shouldRequestDevice, stopMediaStream, toKey, toMediaDeviceInfo, toMediaDeviceInfoLike, toMediaDeviceInputKind, };
95
95
  export * from './constants';
96
96
  export * from './displayMedia';
@@ -17,15 +17,15 @@ export declare const isFloat: (t: unknown) => t is number;
17
17
  * Reference https://w3c.github.io/mediacapture-main/#dom-mediatrackconstraintset
18
18
  */
19
19
  export declare const CONSTRAIN_STRING_KEYS: readonly ["facingMode", "resizeMode", "deviceId", "groupId"];
20
- export declare const EXTENDED_CONSTRAIN_STRING_KEYS: readonly ["videoSegmentation", "videoSegmentationModel", "backgroundImageUrl", "contentHint"];
20
+ export declare const EXTENDED_CONSTRAIN_STRING_KEYS: readonly ["videoSegmentation", "backgroundImageUrl", "contentHint"];
21
21
  export type ExtendedConstrainStringKeys = (typeof EXTENDED_CONSTRAIN_STRING_KEYS)[number];
22
22
  export type ConstrainStringKeys = (typeof CONSTRAIN_STRING_KEYS)[number];
23
23
  export declare const CONSTRAIN_U_LONG_KEYS: readonly ["width", "height", "sampleRate", "sampleSize", "channelCount"];
24
- export declare const EXTENDED_CONSTRAIN_U_LONG_KEYS: readonly ["backgroundBlurAmount", "edgeBlurAmount"];
24
+ export declare const EXTENDED_CONSTRAIN_U_LONG_KEYS: readonly ["backgroundBlurAmount", "edgeBlurAmount", "morphErodeRadiusPx", "morphPass", "morphDilateRadiusPx", "lightWrapBlurAmount", "downSampleFactor"];
25
25
  export type ExtendedConstrainULongKeys = (typeof EXTENDED_CONSTRAIN_U_LONG_KEYS)[number];
26
26
  export type ConstrainULongKeys = (typeof CONSTRAIN_U_LONG_KEYS)[number];
27
- export declare const CONSTRAIN_DOUBLE_KEYS: readonly ["aspectRatio", "frameRate", "latency"];
28
- export declare const EXTENDED_CONSTRAIN_DOUBLE_KEYS: readonly ["foregroundThreshold", "maskCombineRatio"];
27
+ export declare const CONSTRAIN_DOUBLE_KEYS: readonly ["aspectRatio", "frameRate"];
28
+ export declare const EXTENDED_CONSTRAIN_DOUBLE_KEYS: readonly ["foregroundThreshold", "backgroundThreshold", "sigmaSpace", "sigmaRangeLo", "sigmaRangeHi", "maskCombineRatio", "personCenterX", "personCenterY", "lightWrapIntensity", "lightWrapTightness", "lightWrapEdgeBand"];
29
29
  export type ExtendedConstrainDoubleKeys = (typeof EXTENDED_CONSTRAIN_DOUBLE_KEYS)[number];
30
30
  export type ConstrainDoubleKeys = (typeof CONSTRAIN_DOUBLE_KEYS)[number];
31
31
  export declare const CONSTRAIN_BOOLEAN_KEYS: readonly ["echoCancellation", "autoGainControl", "noiseSuppression", "pan", "tilt", "zoom"];
@@ -33,13 +33,13 @@ export declare const CONSTRAIN_BOOLEAN_KEYS: readonly ["echoCancellation", "auto
33
33
  * Extends boolean constraint keys for our own implementation of the media
34
34
  * feature
35
35
  */
36
- export declare const EXTENDED_CONSTRAIN_BOOLEAN_KEYS: readonly ["vad", "asd", "mixWithAdditionalMedia", "denoise"];
36
+ export declare const EXTENDED_CONSTRAIN_BOOLEAN_KEYS: readonly ["vad", "asd", "mixWithAdditionalMedia", "denoise", "excludeBystanders"];
37
37
  export type ExtendedConstrainBooleanKeys = (typeof EXTENDED_CONSTRAIN_BOOLEAN_KEYS)[number];
38
38
  export type ConstrainBooleanKeys = (typeof CONSTRAIN_BOOLEAN_KEYS)[number];
39
39
  /**
40
40
  * The keys from the `MediaTrackConstraintSet`
41
41
  */
42
- export declare const CONSTRAINT_SET_KEYS: readonly ["aspectRatio", "frameRate", "latency", "width", "height", "sampleRate", "sampleSize", "channelCount", "facingMode", "resizeMode", "deviceId", "groupId", "echoCancellation", "autoGainControl", "noiseSuppression", "pan", "tilt", "zoom"];
42
+ export declare const CONSTRAINT_SET_KEYS: readonly ["aspectRatio", "frameRate", "width", "height", "sampleRate", "sampleSize", "channelCount", "facingMode", "resizeMode", "deviceId", "groupId", "echoCancellation", "autoGainControl", "noiseSuppression", "pan", "tilt", "zoom"];
43
43
  export declare const isConstrainStringKeys: (t: unknown) => t is ConstrainStringKeys;
44
44
  export declare const isExtendedConstrainStringKeys: (t: unknown) => t is ExtendedConstrainStringKeys;
45
45
  export declare const isConstrainULongKeys: (t: unknown) => t is ConstrainULongKeys;
@@ -25,7 +25,6 @@ export const CONSTRAIN_STRING_KEYS = [
25
25
  ];
26
26
  export const EXTENDED_CONSTRAIN_STRING_KEYS = [
27
27
  'videoSegmentation',
28
- 'videoSegmentationModel',
29
28
  'backgroundImageUrl',
30
29
  'contentHint',
31
30
  ];
@@ -39,15 +38,25 @@ export const CONSTRAIN_U_LONG_KEYS = [
39
38
  export const EXTENDED_CONSTRAIN_U_LONG_KEYS = [
40
39
  'backgroundBlurAmount',
41
40
  'edgeBlurAmount',
41
+ 'morphErodeRadiusPx',
42
+ 'morphPass',
43
+ 'morphDilateRadiusPx',
44
+ 'lightWrapBlurAmount',
45
+ 'downSampleFactor',
42
46
  ];
43
- export const CONSTRAIN_DOUBLE_KEYS = [
44
- 'aspectRatio',
45
- 'frameRate',
46
- 'latency',
47
- ];
47
+ export const CONSTRAIN_DOUBLE_KEYS = ['aspectRatio', 'frameRate'];
48
48
  export const EXTENDED_CONSTRAIN_DOUBLE_KEYS = [
49
49
  'foregroundThreshold',
50
+ 'backgroundThreshold',
51
+ 'sigmaSpace',
52
+ 'sigmaRangeLo',
53
+ 'sigmaRangeHi',
50
54
  'maskCombineRatio',
55
+ 'personCenterX',
56
+ 'personCenterY',
57
+ 'lightWrapIntensity',
58
+ 'lightWrapTightness',
59
+ 'lightWrapEdgeBand',
51
60
  ];
52
61
  export const CONSTRAIN_BOOLEAN_KEYS = [
53
62
  'echoCancellation',
@@ -70,6 +79,8 @@ export const EXTENDED_CONSTRAIN_BOOLEAN_KEYS = [
70
79
  'mixWithAdditionalMedia',
71
80
  // Noise Suppression using our own impl
72
81
  'denoise',
82
+ // Bystander removal
83
+ 'excludeBystanders',
73
84
  ];
74
85
  /**
75
86
  * The keys from the `MediaTrackConstraintSet`
package/dist/types.d.ts CHANGED
@@ -66,11 +66,6 @@ export interface InputConstraintSet extends MediaTrackConstraints {
66
66
  * segment. Available effects are `none`, `blur`, `overlay` or `remove`
67
67
  */
68
68
  videoSegmentation?: ConstrainDOMString;
69
- /**
70
- * Segmentation model to be used for video segmentation, currently only
71
- * supports `mediapipeSelfie` and `personify`
72
- */
73
- videoSegmentationModel?: ConstrainDOMString;
74
69
  /**
75
70
  * Whether or not using our own noise suppression
76
71
  */
@@ -107,9 +102,93 @@ export interface InputConstraintSet extends MediaTrackConstraints {
107
102
  */
108
103
  backgroundImageUrl?: ConstrainDOMString;
109
104
  /**
110
- * The ratio to be used for smoothing segmentation mask
105
+ * The ratio to be used for smoothing segmentation mask.
106
+ * How much uncertainty enables temporal blend, [0,1].
107
+ * Higher = more frame-to-frame blending, more stability but more trailing ghosts.
108
+ * Typical: 0.6–0.85.
111
109
  */
112
110
  maskCombineRatio?: ConstrainDouble;
111
+ /**
112
+ * [0,1] Lower mask confidence: all mask pixels <= this are considered definite background.
113
+ * Adjust to make mask edges tighter or more permissive for background inclusion.
114
+ * Example: 0.3 ("mask < 0.3 = sure background").
115
+ */
116
+ backgroundThreshold?: ConstrainDouble;
117
+ /**
118
+ * Bilateral filter: sigma in pixel space for mask edge snapping.
119
+ * Controls the neighborhood/pixel distance—higher is larger window (5–10 typical).
120
+ */
121
+ sigmaSpace?: ConstrainDouble;
122
+ /**
123
+ * Bilateral filter: minimum sigma in color/luma (for mask interiors), [0,1].
124
+ * Controls how little color difference is needed to cross-mask regions away from edge.
125
+ * Lower = sharper edge preservation in mask interiors.
126
+ * Example: 0.2
127
+ */
128
+ sigmaRangeLo?: ConstrainDouble;
129
+ /**
130
+ * Bilateral filter: maximum sigma in color/luma (for mask uncertain zones), [0,1].
131
+ * Controls how much color similarity is required at uncertain/edge mask locations.
132
+ * Higher = more mask smoothing at edges.
133
+ * Example: 0.8
134
+ */
135
+ sigmaRangeHi?: ConstrainDouble;
136
+ /**
137
+ * Whether to exclude bystanders/connected people from the output mask.
138
+ * The main person instance (closest to personCenter OR largest blob) is kept in
139
+ * the output mask.
140
+ * All other bystanders/connected people are suppressed (bystander removal).
141
+ */
142
+ excludeBystanders?: ConstrainBoolean;
143
+ /**
144
+ * Person center: normalized in [0,1] image coordinates for main subject selection.
145
+ * Used by the CCL/bias filter to select the main person blob.
146
+ */
147
+ personCenterX?: ConstrainDouble;
148
+ /**
149
+ * Person center: normalized in [0,1] image coordinates for main subject selection.
150
+ * Used by the CCL/bias filter to select the main person blob.
151
+ */
152
+ personCenterY?: ConstrainDouble;
153
+ /**
154
+ * Morphological erosion: radius in pixels [1,12]. Sets kernel size for bridge-breaking.
155
+ * Larger values break thicker bridges but may erode fine details.
156
+ */
157
+ morphErodeRadiusPx?: ConstrainULong;
158
+ /**
159
+ * Morphological pass: number of separable passes [1,10].
160
+ * More passes increase the effective span.
161
+ */
162
+ morphPass?: ConstrainULong;
163
+ /**
164
+ * Geodesic dilation: radius in pixels [1,12]. Must match erosion for good reconstruction.
165
+ */
166
+ morphDilateRadiusPx?: ConstrainULong;
167
+ /**
168
+ * [0,1] Light wrap amount (halo intensity) at mask edge.
169
+ * Wraps blurred background color just outside the subject edge onto the subject boundary for realism.
170
+ */
171
+ lightWrapIntensity?: ConstrainDouble;
172
+ /**
173
+ * [0.5,4.0] Controls power/tightness of the wrap band falloff. Higher = tighter/narrower wrap.
174
+ */
175
+ lightWrapTightness?: ConstrainDouble;
176
+ /**
177
+ * Width of the wrap band (feather size, in normalized mask units) between the backgroundThreshold
178
+ * and foregroundThreshold in [0.0, (foregroundThreshold - backgroundThreshold) / 2]
179
+ * Higher = wider soft halo.
180
+ */
181
+ lightWrapEdgeBand?: ConstrainDouble;
182
+ /**
183
+ * Blur amount used for background color in the wrap band (units=blur passes).
184
+ */
185
+ lightWrapBlurAmount?: ConstrainULong;
186
+ /**
187
+ * Downsampling factor for mask/blurring, must be [2,4].
188
+ * 2 = half resolution, 4 = quarter resolution for faster filtering.
189
+ * Use for performance tuning vs. quality.
190
+ */
191
+ downSampleFactor?: ConstrainULong;
113
192
  /**
114
193
  * Image Url that is being used for video overlay effects
115
194
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pexip/media-control",
3
- "version": "20.3.5",
4
- "homepage": "https://gitlab.com/pexip/zoo",
3
+ "version": "22.0.0",
4
+ "homepage": "https://developer.pexip.com",
5
5
  "bugs": "https://gitlab.com/pexip/zoo/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -35,11 +35,11 @@
35
35
  "api-docs"
36
36
  ],
37
37
  "scripts": {
38
- "build": "pexip-bundler build && yarn docs",
39
- "build:sourcemap": "pexip-bundler build --sourcemap && yarn docs",
38
+ "build": "pexip-bundler build",
39
+ "build:sourcemap": "pexip-bundler build --sourcemap",
40
40
  "clean": "rm -rf dist api-docs",
41
41
  "dev": "pexip-bundler dev",
42
- "prepack": "yarn clean && yarn build",
42
+ "prepack": "yarn clean && yarn build && yarn docs",
43
43
  "test": "jest",
44
44
  "check-format": "prettier --ignore-path=../../.prettierignore --check .",
45
45
  "format": "prettier --ignore-path=../../.prettierignore --write .",
@@ -48,11 +48,11 @@
48
48
  "docs": "typedoc"
49
49
  },
50
50
  "dependencies": {
51
- "@pexip/utils": "17.1.3"
51
+ "@pexip/utils": "17.3.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@jest/globals": "^30.2.0",
55
- "@pexip/bundler": "18.2.0",
54
+ "@jest/globals": "^29.5.12",
55
+ "@pexip/bundler": "18.2.1",
56
56
  "@swc/core": "^1.10.12",
57
57
  "@swc/jest": "^0.2.39",
58
58
  "@types/uuid": "^8.3.0",
@@ -60,9 +60,9 @@
60
60
  "jest": "^29.5.12",
61
61
  "jest-junit": "^16.0.0",
62
62
  "prettier": "^3.2.5",
63
- "typedoc": "^0.28.15",
64
- "typedoc-plugin-markdown": "^4.9.0",
65
- "typescript": "~5.7.3",
63
+ "typedoc": "^0.28.18",
64
+ "typedoc-plugin-markdown": "^4.11.0",
65
+ "typescript": "~6.0.2",
66
66
  "uuid": "^11.0.0"
67
67
  },
68
68
  "publishConfig": {