@stream-io/video-react-sdk 0.6.10 → 0.6.12

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
@@ -2,6 +2,25 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.6.12](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-0.6.11...@stream-io/video-react-sdk-0.6.12) (2024-04-25)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `@stream-io/video-client` updated to version `0.7.8`
10
+ * `@stream-io/video-react-bindings` updated to version `0.4.19`
11
+ * `@stream-io/audio-filters-web` updated to version `0.0.1`
12
+
13
+ ### Features
14
+
15
+ * Noise Cancellation ([#1321](https://github.com/GetStream/stream-video-js/issues/1321)) ([9144385](https://github.com/GetStream/stream-video-js/commit/91443852986ad7453d82efb900626266d8df0e96))
16
+
17
+ ### [0.6.11](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-0.6.10...@stream-io/video-react-sdk-0.6.11) (2024-04-25)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **filters:** Synchronize filter loading and unloading ([#1326](https://github.com/GetStream/stream-video-js/issues/1326)) ([cfab745](https://github.com/GetStream/stream-video-js/commit/cfab7455cfde6d7161ac823dc338e51bea00bcce))
23
+
5
24
  ### [0.6.10](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-0.6.9...@stream-io/video-react-sdk-0.6.10) (2024-04-23)
6
25
 
7
26
  ### Dependency Updates
package/dist/index.cjs.js CHANGED
@@ -127,21 +127,24 @@ const BackgroundFilters = (props) => {
127
127
  const [canvasRef, setCanvasRef] = react.useState(null);
128
128
  const [width, setWidth] = react.useState(1920);
129
129
  const [height, setHeight] = react.useState(1080);
130
- const resolveFilterRef = react.useRef();
130
+ // Holds a ref to the `resolve` function of the returned Promise as part
131
+ // of the `camera.registerFilter()` API. Once the filter is initialized,
132
+ // it should be called with the filtered MediaStream as an argument.
133
+ const signalFilterReadyRef = react.useRef();
131
134
  const [mediaStream, setMediaStream] = react.useState();
132
- const registerFilterRef = react.useRef(Promise.resolve(async () => { }));
135
+ const unregister = react.useRef();
133
136
  react.useEffect(() => {
134
137
  if (!call || !backgroundFilter)
135
138
  return;
136
- registerFilterRef.current = registerFilterRef.current.then(() => call.camera.registerFilter(async (ms) => {
139
+ const register = (unregister.current || Promise.resolve()).then(() => call.camera.registerFilter(async (ms) => {
137
140
  return new Promise((resolve) => {
138
141
  setMediaStream(ms);
139
- resolveFilterRef.current = resolve;
142
+ signalFilterReadyRef.current = resolve;
140
143
  });
141
144
  }));
142
145
  return () => {
143
- registerFilterRef.current
144
- .then((unregister) => unregister())
146
+ unregister.current = register
147
+ .then((unregisterFilter) => unregisterFilter())
145
148
  .then(() => setMediaStream(undefined))
146
149
  .catch((err) => console.error('Failed to unregister filter', err));
147
150
  };
@@ -156,7 +159,7 @@ const BackgroundFilters = (props) => {
156
159
  setWidth(w);
157
160
  setHeight(h);
158
161
  }
159
- const resolveFilter = resolveFilterRef.current;
162
+ const resolveFilter = signalFilterReadyRef.current;
160
163
  if (!resolveFilter)
161
164
  return;
162
165
  const filter = canvasRef.captureStream();
@@ -1544,6 +1547,67 @@ const CallRecordingList = ({ callRecordings, CallRecordingListHeader: CallRecord
1544
1547
  return (jsxRuntime.jsxs("div", { className: "str-video__call-recording-list", children: [jsxRuntime.jsx(CallRecordingListHeader$1, { callRecordings: callRecordings, onRefresh: onRefresh }), jsxRuntime.jsx("div", { className: "str-video__call-recording-list__listing", children: loading ? (jsxRuntime.jsx(LoadingCallRecordingList, { callRecordings: callRecordings })) : callRecordings.length ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("ul", { className: "str-video__call-recording-list__list", children: jsxRuntime.jsxs("li", { className: "str-video__call-recording-list__item", children: [jsxRuntime.jsx("div", { className: "str-video__call-recording-list__filename", children: "Name" }), jsxRuntime.jsx("div", { className: "str-video__call-recording-list__time", children: "Start time" }), jsxRuntime.jsx("div", { className: "str-video__call-recording-list__time", children: "End time" }), jsxRuntime.jsx("div", { className: "str-video__call-recording-list__download" })] }) }), jsxRuntime.jsx("ul", { className: "str-video__call-recording-list__list", children: callRecordings.map((recording) => (jsxRuntime.jsx(CallRecordingListItem$1, { recording: recording }, recording.filename))) })] })) : (jsxRuntime.jsx(EmptyCallRecordingList, {})) })] }));
1545
1548
  };
1546
1549
 
1550
+ const NoiseCancellationContext = react.createContext(null);
1551
+ /**
1552
+ * Exposes the NoiseCancellation API.
1553
+ * Throws an error if used outside <NoiseCancellationProvider />.
1554
+ */
1555
+ const useNoiseCancellation = () => {
1556
+ const context = react.useContext(NoiseCancellationContext);
1557
+ if (!context) {
1558
+ throw new Error('useNoiseCancellation must be used within a NoiseCancellationProvider');
1559
+ }
1560
+ return context;
1561
+ };
1562
+ const NoiseCancellationProvider = (props) => {
1563
+ const { children, noiseCancellation } = props;
1564
+ const call = videoReactBindings.useCall();
1565
+ const { useCallSettings, useHasPermissions } = videoReactBindings.useCallStateHooks();
1566
+ const settings = useCallSettings();
1567
+ const noiseCancellationAllowed = !!(settings &&
1568
+ settings.audio.noise_cancellation &&
1569
+ settings.audio.noise_cancellation.mode !==
1570
+ videoClient.NoiseCancellationSettingsModeEnum.DISABLED);
1571
+ const hasCapability = useHasPermissions(videoClient.OwnCapability.ENABLE_NOISE_CANCELLATION);
1572
+ const isSupported = hasCapability &&
1573
+ noiseCancellationAllowed &&
1574
+ noiseCancellation.isSupported();
1575
+ const [isEnabled, setIsEnabled] = react.useState(false);
1576
+ const deinit = react.useRef();
1577
+ react.useEffect(() => {
1578
+ if (!call || !isSupported)
1579
+ return;
1580
+ const unsubscribe = noiseCancellation.on('change', (v) => setIsEnabled(v));
1581
+ const init = (deinit.current || Promise.resolve())
1582
+ .then(() => noiseCancellation.init())
1583
+ .then(() => call.microphone.enableNoiseCancellation(noiseCancellation))
1584
+ .catch((err) => console.error(`Can't initialize noise suppression`, err));
1585
+ return () => {
1586
+ deinit.current = init
1587
+ .then(() => call.microphone.disableNoiseCancellation())
1588
+ .then(() => noiseCancellation.dispose())
1589
+ .then(() => unsubscribe());
1590
+ };
1591
+ }, [call, isSupported, noiseCancellation]);
1592
+ return (jsxRuntime.jsx(NoiseCancellationContext.Provider, { value: {
1593
+ isSupported,
1594
+ isEnabled,
1595
+ setEnabled: (enabledOrSetter) => {
1596
+ if (!noiseCancellation)
1597
+ return;
1598
+ const enable = typeof enabledOrSetter === 'function'
1599
+ ? enabledOrSetter(isEnabled)
1600
+ : enabledOrSetter;
1601
+ if (enable) {
1602
+ noiseCancellation.enable();
1603
+ }
1604
+ else {
1605
+ noiseCancellation.disable();
1606
+ }
1607
+ },
1608
+ }, children: children }));
1609
+ };
1610
+
1547
1611
  const RingingCallControls = () => {
1548
1612
  const call = videoReactBindings.useCall();
1549
1613
  const { useCallCallingState } = videoReactBindings.useCallStateHooks();
@@ -2433,7 +2497,7 @@ const VerticalScrollButtons = ({ scrollWrapper, }) => {
2433
2497
  };
2434
2498
  const hasScreenShare = (p) => !!p?.publishedTracks.includes(videoClient.SfuModels.TrackType.SCREEN_SHARE);
2435
2499
 
2436
- const [major, minor, patch] = ("0.6.10" ).split('.');
2500
+ const [major, minor, patch] = ("0.6.12" ).split('.');
2437
2501
  videoClient.setSdkInfo({
2438
2502
  type: videoClient.SfuModels.SdkType.REACT,
2439
2503
  major,
@@ -2481,6 +2545,7 @@ exports.LivestreamLayout = LivestreamLayout;
2481
2545
  exports.LoadingCallRecordingListing = LoadingCallRecordingListing;
2482
2546
  exports.LoadingIndicator = LoadingIndicator;
2483
2547
  exports.MenuToggle = MenuToggle;
2548
+ exports.NoiseCancellationProvider = NoiseCancellationProvider;
2484
2549
  exports.Notification = Notification;
2485
2550
  exports.PaginatedGridLayout = PaginatedGridLayout;
2486
2551
  exports.ParticipantActionsContextMenu = ParticipantActionsContextMenu;
@@ -2524,6 +2589,7 @@ exports.translations = translations;
2524
2589
  exports.useBackgroundFilters = useBackgroundFilters;
2525
2590
  exports.useHorizontalScrollPosition = useHorizontalScrollPosition;
2526
2591
  exports.useMenuContext = useMenuContext;
2592
+ exports.useNoiseCancellation = useNoiseCancellation;
2527
2593
  exports.useParticipantViewContext = useParticipantViewContext;
2528
2594
  exports.usePersistedDevicePreferences = usePersistedDevicePreferences;
2529
2595
  exports.useRequestPermission = useRequestPermission;