@stream-io/video-react-native-sdk 0.0.1-alpha.188 → 0.0.1-alpha.190

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,19 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.1-alpha.190](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-0.0.1-alpha.189...@stream-io/video-react-native-sdk-0.0.1-alpha.190) (2023-06-21)
6
+
7
+
8
+
9
+ ## [0.0.1-alpha.189](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-0.0.1-alpha.188...@stream-io/video-react-native-sdk-0.0.1-alpha.189) (2023-06-21)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * proper media stream disposal for rn webrtc ([#682](https://github.com/GetStream/stream-video-js/issues/682)) ([8879bac](https://github.com/GetStream/stream-video-js/commit/8879bac82080232928b78316fdb452bbc3c79fbc))
15
+
16
+
17
+
5
18
  ## [0.0.1-alpha.188](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-0.0.1-alpha.187...@stream-io/video-react-native-sdk-0.0.1-alpha.188) (2023-06-20)
6
19
 
7
20
 
@@ -11,23 +11,34 @@ const contexts_1 = require("../contexts");
11
11
  */
12
12
  const useLocalVideoStream = () => {
13
13
  const [videoStream, setVideoStream] = (0, react_1.useState)(undefined);
14
- const currentVideoDevice = (0, contexts_1.useStreamVideoStoreValue)((store) => store.currentVideoDevice);
14
+ const currentVideoDeviceId = (0, contexts_1.useStreamVideoStoreValue)((store) => store.currentVideoDevice)?.deviceId;
15
15
  (0, react_1.useEffect)(() => {
16
+ let mediaStream;
17
+ let interrupted = false;
16
18
  const loadVideoStream = async () => {
17
19
  // If there is no video device, we don't need to load a video stream.
18
- if (!currentVideoDevice?.deviceId)
20
+ if (!currentVideoDeviceId) {
19
21
  return null;
20
- const stream = await (0, video_client_1.getVideoStream)({
21
- deviceId: currentVideoDevice.deviceId,
22
- });
23
- setVideoStream((previousStream) => {
24
- if (previousStream)
25
- (0, video_client_1.disposeOfMediaStream)(previousStream);
26
- return stream;
22
+ }
23
+ const _mediaStream = await (0, video_client_1.getVideoStream)({
24
+ deviceId: currentVideoDeviceId,
27
25
  });
26
+ if (interrupted) {
27
+ // device changed while we were loading the video stream, so dispose of it
28
+ (0, video_client_1.disposeOfMediaStream)(_mediaStream);
29
+ return;
30
+ }
31
+ mediaStream = _mediaStream;
32
+ setVideoStream(_mediaStream);
28
33
  };
29
34
  loadVideoStream();
30
- }, [currentVideoDevice?.deviceId]);
35
+ return () => {
36
+ interrupted = true;
37
+ if (mediaStream) {
38
+ (0, video_client_1.disposeOfMediaStream)(mediaStream);
39
+ }
40
+ };
41
+ }, [currentVideoDeviceId]);
31
42
  return videoStream;
32
43
  };
33
44
  exports.useLocalVideoStream = useLocalVideoStream;
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalVideoStream.js","sourceRoot":"","sources":["../../../src/hooks/useLocalVideoStream.ts"],"names":[],"mappings":";;;AAAA,iCAA4C;AAC5C,0DAA+E;AAE/E,0CAAuD;AAEvD;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAC5C,SAAS,CACV,CAAC;IACF,MAAM,kBAAkB,GAAG,IAAA,mCAAwB,EACjD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,kBAAkB,CACpC,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;YACjC,qEAAqE;YACrE,IAAI,CAAC,kBAAkB,EAAE,QAAQ;gBAAE,OAAO,IAAI,CAAC;YAE/C,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAc,EAAC;gBAClC,QAAQ,EAAE,kBAAk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YAAY,CAAC,CAAC;QAC/B,CAAC,CAAC;QACF,eAAe,EAAE,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,WAAW,GAAG,IAAI,CAAC;YACnB,IAAI,WAAW,EAAE;gBACf,IAAA,mCAAoB,EAAC,WAAW,CAAC,CAAC;aACnC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAE3B,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAtCW,QAAA,mBAAmB,uBAsC9B"}
package/package.json CHANGED
@@ -22,8 +22,8 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@stream-io/i18n": "^0.0.5",
25
- "@stream-io/video-client": "^0.0.19",
26
- "@stream-io/video-react-bindings": "^0.0.20"
25
+ "@stream-io/video-client": "^0.0.21",
26
+ "@stream-io/video-react-bindings": "^0.0.22"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@notifee/react-native": ">=7.7.0",
@@ -83,5 +83,5 @@
83
83
  "typedoc-plugin-markdown": "^3.15.3",
84
84
  "typescript": "^4.9.5"
85
85
  },
86
- "version": "0.0.1-alpha.188"
86
+ "version": "0.0.1-alpha.190"
87
87
  }
@@ -12,25 +12,38 @@ export const useLocalVideoStream = () => {
12
12
  const [videoStream, setVideoStream] = useState<MediaStream | undefined>(
13
13
  undefined,
14
14
  );
15
- const currentVideoDevice = useStreamVideoStoreValue(
15
+ const currentVideoDeviceId = useStreamVideoStoreValue(
16
16
  (store) => store.currentVideoDevice,
17
- );
17
+ )?.deviceId;
18
18
 
19
19
  useEffect(() => {
20
+ let mediaStream: MediaStream | undefined;
21
+ let interrupted = false;
20
22
  const loadVideoStream = async () => {
21
23
  // If there is no video device, we don't need to load a video stream.
22
- if (!currentVideoDevice?.deviceId) return null;
24
+ if (!currentVideoDeviceId) {
25
+ return null;
26
+ }
23
27
 
24
- const stream = await getVideoStream({
25
- deviceId: currentVideoDevice.deviceId,
26
- });
27
- setVideoStream((previousStream) => {
28
- if (previousStream) disposeOfMediaStream(previousStream);
29
- return stream;
28
+ const _mediaStream = await getVideoStream({
29
+ deviceId: currentVideoDeviceId,
30
30
  });
31
+ if (interrupted) {
32
+ // device changed while we were loading the video stream, so dispose of it
33
+ disposeOfMediaStream(_mediaStream);
34
+ return;
35
+ }
36
+ mediaStream = _mediaStream;
37
+ setVideoStream(_mediaStream);
31
38
  };
32
39
  loadVideoStream();
33
- }, [currentVideoDevice?.deviceId]);
40
+ return () => {
41
+ interrupted = true;
42
+ if (mediaStream) {
43
+ disposeOfMediaStream(mediaStream);
44
+ }
45
+ };
46
+ }, [currentVideoDeviceId]);
34
47
 
35
48
  return videoStream;
36
49
  };