@pexip/media 20.3.4 → 21.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/api-docs/README.mdx +406 -0
  3. package/api-docs/enumerations/DeniedDevices.mdx +7 -0
  4. package/api-docs/enumerations/UserMediaStatus.mdx +49 -0
  5. package/api-docs/functions/applyContentHint.mdx +33 -0
  6. package/api-docs/functions/createAudioMixingProcess.mdx +20 -0
  7. package/api-docs/functions/createAudioStreamProcess.mdx +15 -0
  8. package/api-docs/functions/createGetDisplayMedia.mdx +26 -0
  9. package/api-docs/functions/createMedia.mdx +20 -0
  10. package/api-docs/functions/createMediaSignal.mdx +42 -0
  11. package/api-docs/functions/createMediaSignals.mdx +33 -0
  12. package/api-docs/functions/createPreviewStreamController.mdx +13 -0
  13. package/api-docs/functions/createVideoStreamProcess.mdx +13 -0
  14. package/api-docs/functions/deriveInitialPermissionStatus.mdx +14 -0
  15. package/api-docs/functions/getBlurKernelSize.mdx +25 -0
  16. package/api-docs/functions/getPermissionStatus.mdx +34 -0
  17. package/api-docs/functions/getTentBlurSize.mdx +24 -0
  18. package/api-docs/functions/isAnalyzerNodeInitProp.mdx +13 -0
  19. package/api-docs/functions/isAudioContentHint.mdx +13 -0
  20. package/api-docs/functions/isMedia.mdx +13 -0
  21. package/api-docs/functions/isNonNullObject.mdx +13 -0
  22. package/api-docs/functions/isUserMediaStatus.mdx +13 -0
  23. package/api-docs/functions/isVideoContentHint.mdx +13 -0
  24. package/api-docs/functions/isVideoStreamTrackProcessorAPIs.mdx +13 -0
  25. package/api-docs/functions/setLogger.mdx +13 -0
  26. package/api-docs/functions/toDeniedDevices.mdx +13 -0
  27. package/api-docs/interfaces/AudioDetectionSignals.mdx +6 -0
  28. package/api-docs/interfaces/AudioSignalDetectionOptions.mdx +6 -0
  29. package/api-docs/interfaces/DenoiseParams.mdx +9 -0
  30. package/api-docs/interfaces/ExtendedMediaTrackSettings.mdx +38 -0
  31. package/api-docs/interfaces/Media.mdx +316 -0
  32. package/api-docs/interfaces/MediaAttributes.mdx +19 -0
  33. package/api-docs/interfaces/MediaChangesSignals.mdx +15 -0
  34. package/api-docs/interfaces/MediaController.mdx +11 -0
  35. package/api-docs/interfaces/MediaInit.mdx +14 -0
  36. package/api-docs/interfaces/MediaOptions.mdx +10 -0
  37. package/api-docs/interfaces/MediaProps.mdx +9 -0
  38. package/api-docs/interfaces/MediaSettings.mdx +6 -0
  39. package/api-docs/interfaces/MediaTrack.mdx +121 -0
  40. package/api-docs/interfaces/MediaTrackInit.mdx +29 -0
  41. package/api-docs/interfaces/PreviewControllerProps.mdx +14 -0
  42. package/api-docs/interfaces/PreviewEventHandler.mdx +19 -0
  43. package/api-docs/interfaces/PreviewStreamController.mdx +350 -0
  44. package/api-docs/interfaces/PreviewStreamParams.mdx +15 -0
  45. package/api-docs/interfaces/VoiceActivityDetectionOptions.mdx +6 -0
  46. package/api-docs/type-aliases/AudioContentHint.mdx +3 -0
  47. package/api-docs/type-aliases/CreatePreviewStreamController.mdx +3 -0
  48. package/api-docs/type-aliases/ExtendedMediaTrackSettingsKey.mdx +3 -0
  49. package/api-docs/type-aliases/GeneratedMediaSignals.mdx +9 -0
  50. package/api-docs/type-aliases/GetDisplayMedia.mdx +3 -0
  51. package/api-docs/type-aliases/GetUserMediaProcess.mdx +19 -0
  52. package/api-docs/type-aliases/MediaSignals.mdx +3 -0
  53. package/api-docs/type-aliases/MediaSignalsOptional.mdx +3 -0
  54. package/api-docs/type-aliases/MediaSignalsRequired.mdx +3 -0
  55. package/api-docs/type-aliases/PreviewInput.mdx +3 -0
  56. package/api-docs/type-aliases/Process.mdx +19 -0
  57. package/api-docs/type-aliases/Segmenters.mdx +3 -0
  58. package/api-docs/type-aliases/TrackProcessor.mdx +3 -0
  59. package/api-docs/type-aliases/Unsubscribe.mdx +7 -0
  60. package/api-docs/type-aliases/UserMediaValidator.mdx +13 -0
  61. package/api-docs/type-aliases/VideoContentHint.mdx +3 -0
  62. package/api-docs/type-aliases/VideoRenderParams.mdx +17 -0
  63. package/api-docs/type-aliases/VideoStreamTrackProcessorAPIs.mdx +7 -0
  64. package/api-docs/variables/AUDIO_CONTENT_HINTS.mdx +17 -0
  65. package/api-docs/variables/REQUIRED_SIGNAL_KEYS.mdx +3 -0
  66. package/api-docs/variables/VIDEO_CONTENT_HINTS.mdx +17 -0
  67. package/api-docs/variables/areBothGranted.mdx +3 -0
  68. package/api-docs/variables/hasNoAudioDevices.mdx +3 -0
  69. package/api-docs/variables/hasNoDevice.mdx +3 -0
  70. package/api-docs/variables/hasNoVideoDevices.mdx +3 -0
  71. package/api-docs/variables/internalSignals.mdx +13 -0
  72. package/api-docs/variables/isAudioDeviceInUse.mdx +3 -0
  73. package/api-docs/variables/isDeviceInUse.mdx +3 -0
  74. package/api-docs/variables/isDevicesInUse.mdx +3 -0
  75. package/api-docs/variables/isFallback.mdx +3 -0
  76. package/api-docs/variables/isFallbackAudio.mdx +3 -0
  77. package/api-docs/variables/isFallbackVideo.mdx +3 -0
  78. package/api-docs/variables/isGranted.mdx +3 -0
  79. package/api-docs/variables/isGrantedAudio.mdx +3 -0
  80. package/api-docs/variables/isGrantedOnlyAudio.mdx +3 -0
  81. package/api-docs/variables/isGrantedOnlyAudioNoVideoDevices.mdx +3 -0
  82. package/api-docs/variables/isGrantedOnlyVideo.mdx +3 -0
  83. package/api-docs/variables/isGrantedOnlyVideoNoAudioDevices.mdx +3 -0
  84. package/api-docs/variables/isGrantedVideo.mdx +3 -0
  85. package/api-docs/variables/isInitial.mdx +3 -0
  86. package/api-docs/variables/isInitialPermissions.mdx +3 -0
  87. package/api-docs/variables/isInitialPermissionsGranted.mdx +3 -0
  88. package/api-docs/variables/isInitialPermissionsNotGranted.mdx +3 -0
  89. package/api-docs/variables/isOnlyAudioError.mdx +3 -0
  90. package/api-docs/variables/isOnlyVideoError.mdx +3 -0
  91. package/api-docs/variables/isOverConstrained.mdx +3 -0
  92. package/api-docs/variables/isPromptAudio.mdx +3 -0
  93. package/api-docs/variables/isPromptVideo.mdx +3 -0
  94. package/api-docs/variables/isRejected.mdx +3 -0
  95. package/api-docs/variables/isRejectedOnlyAudio.mdx +3 -0
  96. package/api-docs/variables/isRejectedOnlyVideo.mdx +3 -0
  97. package/api-docs/variables/isRequestPermissionNeeded.mdx +3 -0
  98. package/api-docs/variables/isUnknownError.mdx +3 -0
  99. package/api-docs/variables/isVideoDeviceInUse.mdx +3 -0
  100. package/dist/constants.d.ts +1 -0
  101. package/dist/constants.js +1 -0
  102. package/dist/index.d.ts +1 -1
  103. package/dist/index.js +1 -1
  104. package/dist/previewController.js +1 -1
  105. package/dist/types.d.ts +3 -1
  106. package/dist/userMedia.d.ts +4 -1
  107. package/dist/userMedia.js +15 -11
  108. package/dist/utils.d.ts +17 -6
  109. package/dist/utils.js +27 -13
  110. package/dist/videoProcessor.d.ts +3 -3
  111. package/dist/videoProcessor.js +172 -30
  112. package/package.json +17 -12
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isInitial: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isInitialPermissions: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isInitialPermissionsGranted: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isInitialPermissionsNotGranted: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isOnlyAudioError: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isOnlyVideoError: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isOverConstrained: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isPromptAudio: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isPromptVideo: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isRejected: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isRejectedOnlyAudio: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isRejectedOnlyVideo: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isRequestPermissionNeeded: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isUnknownError: UserMediaValidator;
3
+ ```
@@ -0,0 +1,3 @@
1
+ ```ts
2
+ const isVideoDeviceInUse: UserMediaValidator;
3
+ ```
@@ -6,3 +6,4 @@ export declare const PROCESSOR_LABELS: Readonly<{
6
6
  }>;
7
7
  export declare const GET_USER_MEDIA_TIMEOUT_MS = 10000;
8
8
  export declare const DEVICE_CHANGE_DEBOUNCE_TIMEOUT_MS = 500;
9
+ export declare const MAX_TENT_BLUR_SIZE = 9;
package/dist/constants.js CHANGED
@@ -6,3 +6,4 @@ export const PROCESSOR_LABELS = Object.freeze({
6
6
  });
7
7
  export const GET_USER_MEDIA_TIMEOUT_MS = 10000;
8
8
  export const DEVICE_CHANGE_DEBOUNCE_TIMEOUT_MS = 500;
9
+ export const MAX_TENT_BLUR_SIZE = 9;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export * from './signals';
4
4
  export * from './status';
5
5
  export * from './typeGuard';
6
6
  export * from './types';
7
- export { applyContentHint } from './utils';
7
+ export { applyContentHint, getBlurKernelSize, getTentBlurSize } from './utils';
8
8
  export { createAudioMixingProcess } from './audioMixingProcessor';
9
9
  export { createAudioStreamProcess } from './audioProcessor';
10
10
  export { createMedia } from './media';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ export * from './signals';
4
4
  export * from './status';
5
5
  export * from './typeGuard';
6
6
  export * from './types';
7
- export { applyContentHint } from './utils';
7
+ export { applyContentHint, getBlurKernelSize, getTentBlurSize } from './utils';
8
8
  export { createAudioMixingProcess } from './audioMixingProcessor';
9
9
  export { createAudioStreamProcess } from './audioProcessor';
10
10
  export { createMedia } from './media';
@@ -373,7 +373,7 @@ export const createPreviewStreamController = ({ getCurrentDevices, getCurrentMed
373
373
  const audioSettings = extractFeaturesToConstraints(AUDIO_SETTINGS_KEYS, previewAudio);
374
374
  // Omit the width & height settings from the preview so that the one
375
375
  // from the main can be applied
376
- const { width: _width, height: _height, ...videoSettings } = extractFeaturesToConstraints(VIDEO_SETTINGS_KEYS, previewVideo);
376
+ const { width: _width, height: _height, edgeBlurAmount: _edgeBlurAmount, lightWrapBlurAmount: _lightWrapBlurAmount, backgroundBlurAmount: _backgroundBlurAmount, ...videoSettings } = extractFeaturesToConstraints(VIDEO_SETTINGS_KEYS, previewVideo);
377
377
  logger.info({ audioInput, videoInput, audioSettings, videoSettings }, 'Apply changes to main');
378
378
  try {
379
379
  await replaceMainStream({
package/dist/types.d.ts CHANGED
@@ -531,7 +531,7 @@ export interface MediaController {
531
531
  */
532
532
  tryAndGetUserMedia: (constraints: MediaDeviceRequest) => void;
533
533
  }
534
- export type VideoRenderParams = Omit<RendererOptions, 'effects'> & {
534
+ export type VideoRenderParams = Omit<RendererOptions, 'effects' | 'personCenter'> & {
535
535
  /**
536
536
  * Target frame rate for the video segmentation
537
537
  */
@@ -545,6 +545,8 @@ export type VideoRenderParams = Omit<RendererOptions, 'effects'> & {
545
545
  pan?: boolean;
546
546
  tilt?: boolean;
547
547
  zoom?: boolean;
548
+ personCenterX?: number;
549
+ personCenterY?: number;
548
550
  };
549
551
  export interface MediaChangesSignals {
550
552
  onAddTrack: Signal<MediaStreamTrack>;
@@ -11,7 +11,10 @@ export declare const toSameDeviceStatus: ({ audio, video, }: {
11
11
  audio: boolean;
12
12
  video: boolean;
13
13
  }) => UserMediaStatus.PermissionsGranted | UserMediaStatus.PermissionsGrantedFallback | UserMediaStatus.PermissionsGrantedFallbackAudioinput | UserMediaStatus.PermissionsGrantedFallbackVideoinput;
14
- export declare const toOnlyDeviceStatus: (kind: "audioinput" | "videoinput", matched: boolean, devices: IndexedDevices) => UserMediaStatus.PermissionsRejectedAudioInput | UserMediaStatus.PermissionsRejectedVideoInput | UserMediaStatus.PermissionsOnlyAudioinput | UserMediaStatus.PermissionsOnlyAudioinputNoVideoDevices | UserMediaStatus.PermissionsOnlyAudioinputFallback | UserMediaStatus.PermissionsOnlyAudioinputFallbackNoVideoDevices | UserMediaStatus.PermissionsOnlyVideoinput | UserMediaStatus.PermissionsOnlyVideoinputNoAudioDevices | UserMediaStatus.PermissionsOnlyVideoinputFallback | UserMediaStatus.PermissionsOnlyVideoinputFallbackNoAudioDevices;
14
+ export declare const toOnlyDeviceStatus: (kind: "audioinput" | "videoinput", streamedRequestedDevices: {
15
+ audio: boolean;
16
+ video: boolean;
17
+ }, devices: IndexedDevices) => UserMediaStatus.PermissionsRejectedAudioInput | UserMediaStatus.PermissionsRejectedVideoInput | UserMediaStatus.PermissionsOnlyAudioinput | UserMediaStatus.PermissionsOnlyAudioinputNoVideoDevices | UserMediaStatus.PermissionsOnlyAudioinputFallback | UserMediaStatus.PermissionsOnlyAudioinputFallbackNoVideoDevices | UserMediaStatus.PermissionsOnlyVideoinput | UserMediaStatus.PermissionsOnlyVideoinputNoAudioDevices | UserMediaStatus.PermissionsOnlyVideoinputFallback | UserMediaStatus.PermissionsOnlyVideoinputFallbackNoAudioDevices;
15
18
  /**
16
19
  * Check if there is any track match with the `kind`
17
20
  */
package/dist/userMedia.js CHANGED
@@ -71,12 +71,16 @@ export const toSameDeviceStatus = ({ audio, video, }) => {
71
71
  }
72
72
  return UserMediaStatus.PermissionsGrantedFallback;
73
73
  };
74
- export const toOnlyDeviceStatus = (kind, matched, devices) => {
75
- const hasAnotherTypeOfAuthorizedDevice = devices.anyAuthorizedDevice(kind === 'audioinput' ? 'videoinput' : 'audioinput');
76
- const hasAnotherTypeOfDevice = devices.size(kind === 'audioinput' ? 'videoinput' : 'audioinput') > 0;
74
+ export const toOnlyDeviceStatus = (kind, streamedRequestedDevices, devices) => {
75
+ const [self, other] = kind === 'audioinput' ? ['audio', 'video'] : ['video', 'audio'];
76
+ const otherKind = kind === 'audioinput' ? 'videoinput' : 'audioinput';
77
+ const matched = streamedRequestedDevices[self];
78
+ const anotherDeviceRequested = streamedRequestedDevices[other];
79
+ const hasAnotherTypeOfAuthorizedDevice = devices.anyAuthorizedDevice(otherKind);
80
+ const hasAnotherTypeOfDevice = devices.size(otherKind) > 0;
77
81
  if (matched) {
78
82
  if (hasAnotherTypeOfDevice) {
79
- if (hasAnotherTypeOfAuthorizedDevice) {
83
+ if (hasAnotherTypeOfAuthorizedDevice || !anotherDeviceRequested) {
80
84
  return kind === 'audioinput'
81
85
  ? UserMediaStatus.PermissionsOnlyAudioinput
82
86
  : UserMediaStatus.PermissionsOnlyVideoinput;
@@ -90,7 +94,7 @@ export const toOnlyDeviceStatus = (kind, matched, devices) => {
90
94
  : UserMediaStatus.PermissionsOnlyVideoinputNoAudioDevices;
91
95
  }
92
96
  if (hasAnotherTypeOfDevice) {
93
- if (hasAnotherTypeOfAuthorizedDevice) {
97
+ if (hasAnotherTypeOfAuthorizedDevice || !anotherDeviceRequested) {
94
98
  return kind === 'audioinput'
95
99
  ? UserMediaStatus.PermissionsOnlyAudioinputFallback
96
100
  : UserMediaStatus.PermissionsOnlyVideoinputFallback;
@@ -421,10 +425,10 @@ export const requestUserMedia = (getCurrentDevices, getMedia = getUserMedia) =>
421
425
  ? constraints.video
422
426
  : false,
423
427
  });
424
- const { audio, video } = isStreamingRequestedDevices(constraints, stream, devices);
425
- const onlyAudioStatus = toOnlyDeviceStatus('audioinput', audio, devices);
426
- const onlyVideoStatus = toOnlyDeviceStatus('videoinput', video, devices);
427
- const status = deriveDeviceStatus(onlyAudioStatus, onlyVideoStatus, toSameDeviceStatus({ audio, video }));
428
+ const streamedRequestedDevices = isStreamingRequestedDevices(constraints, stream, devices);
429
+ const onlyAudioStatus = toOnlyDeviceStatus('audioinput', streamedRequestedDevices, devices);
430
+ const onlyVideoStatus = toOnlyDeviceStatus('videoinput', streamedRequestedDevices, devices);
431
+ const status = deriveDeviceStatus(onlyAudioStatus, onlyVideoStatus, toSameDeviceStatus(streamedRequestedDevices));
428
432
  return [stream, status];
429
433
  }
430
434
  catch (error) {
@@ -521,10 +525,10 @@ export const createGetUserMediaProcess = ({ getCurrentDevices, getUserMedia, sco
521
525
  }));
522
526
  }
523
527
  const relaxedConstraints = {};
524
- if (constraints.audio) {
528
+ if (constraints.audio !== undefined) {
525
529
  relaxedConstraints.audio = relaxInputConstraint('audioinput', constraints.audio, currentDevices);
526
530
  }
527
- if (constraints.video) {
531
+ if (constraints.video !== undefined) {
528
532
  relaxedConstraints.video = relaxInputConstraint('videoinput', constraints.video, currentDevices);
529
533
  }
530
534
  const [stream, status] = await getUserMedia(relaxedConstraints);
package/dist/utils.d.ts CHANGED
@@ -54,17 +54,28 @@ export declare const getSettingsFromKeys: (keys: ExtendedMediaTrackSettingsKey[]
54
54
  export declare const diffSettings: (keysToLookFor: ExtendedMediaTrackSettingsKey[]) => (settingsA: ExtendedMediaTrackSettings | undefined, settingsB: ExtendedMediaTrackSettings | undefined) => ExtendedMediaTrackSettings | undefined;
55
55
  export declare const mergeSettings: (settingsA: ExtendedMediaTrackSettings | undefined, settingsB: ExtendedMediaTrackSettings | undefined) => ExtendedMediaTrackSettings | undefined;
56
56
  /**
57
- * A function to get the blur kernel size of image height
57
+ * A function to get the blur kernel size of image height based on
58
+ * Kawase blur algorithm
58
59
  *
59
- * @param percentage - The percentage of image height to calculate the blur
60
- * kernel size
61
- * @param height - The image height
62
- * @param lowestProcessingHeight - The lowest image height that is processed by the consumer, used to adjust the blur kernel size across different resolutions
60
+ * @param norm - [0-100] The normalized blur amount
61
+ * @param heightRef - The reference image height
62
+ * @param height - The current image height
63
63
  * @param max - The upper bound
64
64
  *
65
65
  * @returns blur kernel size
66
66
  */
67
- export declare const getBlurKernelSize: (percentage: number, height: number, lowestProcessingHeight?: number, max?: number) => number;
67
+ export declare const getBlurKernelSize: (norm: number, heightRef: number, height: number, max?: number) => number;
68
+ /**
69
+ * A function to get the Tent blur size of image height
70
+ *
71
+ * @param norm - [0-100] The normalized blur amount
72
+ * @param heightRef - The reference image height
73
+ * @param height - The current image height
74
+ * @param max - The upper bound
75
+ *
76
+ * @returns tent blur size
77
+ */
78
+ export declare const getTentBlurSize: (norm: number, heightRef: number, height: number, max?: number) => number;
68
79
  /**
69
80
  * Apply the content hint to the track
70
81
  *
package/dist/utils.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { createStreamTrackEventSubscriptions, createTrackDevicesChanges, extractConstraintsWithKeys, findDeviceFromConstraints, relaxInputConstraint, resolveMediaDeviceConstraints, shouldRequestDevice, toMediaDeviceInputKind, } from '@pexip/media-control';
2
- import { calculateMaxBlurPass } from '@pexip/media-processor';
2
+ import { calculateMaxBlurPass, clamping, } from '@pexip/media-processor';
3
3
  import { hasOwn, assert, isEmpty } from '@pexip/utils';
4
4
  import { internalSignals } from './signals';
5
+ import { MAX_TENT_BLUR_SIZE } from './constants';
5
6
  export const makeDeriveDeviceStatus = (constraints) => (audio, video, both) => {
6
7
  if (constraints.audio) {
7
8
  if (constraints.video) {
@@ -684,26 +685,39 @@ export const mergeSettings = (settingsA, settingsB) => {
684
685
  }
685
686
  return { ...settingsA, ...settingsB };
686
687
  };
688
+ const clampNorm = clamping(0, 100);
687
689
  /**
688
- * A function to get the blur kernel size of image height
690
+ * A function to get the blur kernel size of image height based on
691
+ * Kawase blur algorithm
689
692
  *
690
- * @param percentage - The percentage of image height to calculate the blur
691
- * kernel size
692
- * @param height - The image height
693
- * @param lowestProcessingHeight - The lowest image height that is processed by the consumer, used to adjust the blur kernel size across different resolutions
693
+ * @param norm - [0-100] The normalized blur amount
694
+ * @param heightRef - The reference image height
695
+ * @param height - The current image height
694
696
  * @param max - The upper bound
695
697
  *
696
698
  * @returns blur kernel size
697
699
  */
698
- export const getBlurKernelSize = (percentage, height, lowestProcessingHeight, max = calculateMaxBlurPass(height)) => {
699
- if (height <= 0 || percentage <= 0 || max <= 0) {
700
+ export const getBlurKernelSize = (norm, heightRef, height, max = calculateMaxBlurPass(height)) => {
701
+ if (height <= 0 || norm <= 0 || max <= 0 || heightRef <= 0) {
700
702
  return 0;
701
703
  }
702
- const minHeightMaxBlurPass = lowestProcessingHeight
703
- ? calculateMaxBlurPass(lowestProcessingHeight)
704
- : max;
705
- return Math.min(Math.ceil(percentage * 0.01 * max) +
706
- Math.max(0, max - minHeightMaxBlurPass), max);
704
+ return clamping(0, max)(Math.round(clampNorm(norm) * 0.01 * max - Math.log2(heightRef / height)));
705
+ };
706
+ /**
707
+ * A function to get the Tent blur size of image height
708
+ *
709
+ * @param norm - [0-100] The normalized blur amount
710
+ * @param heightRef - The reference image height
711
+ * @param height - The current image height
712
+ * @param max - The upper bound
713
+ *
714
+ * @returns tent blur size
715
+ */
716
+ export const getTentBlurSize = (norm, heightRef, height, max = MAX_TENT_BLUR_SIZE) => {
717
+ if (height <= 0 || norm <= 0 || heightRef <= 0 || max <= 0) {
718
+ return 0;
719
+ }
720
+ return clamping(0, max)(Math.round((norm * 0.01 * max * height) / heightRef));
707
721
  };
708
722
  /**
709
723
  * Apply the content hint to the track
@@ -18,7 +18,7 @@ interface VideoStreamProcessOptions extends Partial<VideoRenderParams>, Omit<Pro
18
18
  * Whether or to enable this processor
19
19
  */
20
20
  shouldEnable: () => boolean;
21
- lowestProcessingHeight?: number;
21
+ referenceProcessingHeight?: number;
22
22
  processingWidth: number;
23
23
  processingHeight: number;
24
24
  hasInitializedDeps?: boolean;
@@ -34,9 +34,9 @@ interface VideoStreamProcessProps extends Partial<VideoRenderParams>, Required<P
34
34
  hasInitialized: boolean;
35
35
  contentHint?: VideoContentHint;
36
36
  }
37
- declare const FEATURE_KEYS: readonly ["backgroundBlurAmount", "backgroundImageUrl", "maskCombineRatio", "edgeBlurAmount", "foregroundThreshold", "frameRate", "videoSegmentation", "videoSegmentationModel", "width", "height", "pan", "tilt", "zoom", "contentHint"];
37
+ declare const FEATURE_KEYS: readonly ["backgroundBlurAmount", "backgroundImageUrl", "backgroundThreshold", "maskCombineRatio", "edgeBlurAmount", "foregroundThreshold", "frameRate", "videoSegmentation", "videoSegmentationModel", "width", "height", "pan", "tilt", "zoom", "contentHint", "sigmaSpace", "sigmaRangeLo", "sigmaRangeHi", "excludeBystanders", "personCenterX", "personCenterY", "morphErodeRadiusPx", "morphPass", "morphDilateRadiusPx", "lightWrapIntensity", "lightWrapTightness", "lightWrapEdgeBand", "lightWrapBlurAmount", "downSampleFactor"];
38
38
  type FeaturePropKeys = (typeof FEATURE_KEYS)[number];
39
39
  type FeatureProps = Pick<Partial<VideoStreamProcessProps>, FeaturePropKeys>;
40
40
  export declare const updateFeatureProps: (constraints: MediaDeviceRequest["video"], props: FeatureProps) => FeatureProps;
41
- export declare const createVideoStreamProcess: ({ backgroundImageUrl, dynamicProcessingDimensions, edgeBlurAmount, foregroundThreshold, frameRate, gpuAPI, label, lowestProcessingHeight, maskCombineRatio, processingHeight, processingWidth, shouldEnable, stopAsMute, trackProcessorAPI, videoSegmentation, signals, ...options }: VideoStreamProcessOptions) => TrackProcessor;
41
+ 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, trackProcessorAPI, videoSegmentation, signals, ...options }: VideoStreamProcessOptions) => TrackProcessor;
42
42
  export {};