@stream-io/video-react-native-sdk 1.20.1-alpha.2 → 1.20.2

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 (35) hide show
  1. package/CHANGELOG.md +2635 -0
  2. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js +37 -10
  3. package/dist/commonjs/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  4. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js +8 -0
  5. package/dist/commonjs/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
  6. package/dist/commonjs/hooks/useTrackDimensions.js +20 -7
  7. package/dist/commonjs/hooks/useTrackDimensions.js.map +1 -1
  8. package/dist/commonjs/version.js +1 -1
  9. package/dist/commonjs/version.js.map +1 -1
  10. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js +39 -12
  11. package/dist/module/components/Call/CallContent/RTCViewPipIOS.js.map +1 -1
  12. package/dist/module/components/Call/CallContent/RTCViewPipNative.js +7 -0
  13. package/dist/module/components/Call/CallContent/RTCViewPipNative.js.map +1 -1
  14. package/dist/module/hooks/useTrackDimensions.js +20 -7
  15. package/dist/module/hooks/useTrackDimensions.js.map +1 -1
  16. package/dist/module/version.js +1 -1
  17. package/dist/module/version.js.map +1 -1
  18. package/dist/typescript/components/Call/CallContent/RTCViewPipIOS.d.ts.map +1 -1
  19. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts +1 -0
  20. package/dist/typescript/components/Call/CallContent/RTCViewPipNative.d.ts.map +1 -1
  21. package/dist/typescript/hooks/useTrackDimensions.d.ts.map +1 -1
  22. package/dist/typescript/version.d.ts +1 -1
  23. package/dist/typescript/version.d.ts.map +1 -1
  24. package/ios/PictureInPicture/StreamPictureInPictureController.swift +4 -0
  25. package/ios/RTCViewPip.swift +17 -3
  26. package/ios/RTCViewPipManager.mm +1 -0
  27. package/ios/RTCViewPipManager.swift +39 -6
  28. package/ios/StreamVideoReactNative-Bridging-Header.h +1 -0
  29. package/package.json +8 -8
  30. package/src/components/Call/CallContent/RTCViewPipIOS.tsx +56 -12
  31. package/src/components/Call/CallContent/RTCViewPipNative.tsx +17 -0
  32. package/src/hooks/useTrackDimensions.ts +16 -5
  33. package/src/version.ts +1 -1
  34. package/ios/StreamVideoReactNative.xcodeproj/project.xcworkspace/xcuserdata/santhoshvaiyapuri.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  35. package/ios/StreamVideoReactNative.xcodeproj/xcuserdata/santhoshvaiyapuri.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -3,14 +3,21 @@ import {
3
3
  getLogger,
4
4
  hasScreenShare,
5
5
  speakerLayoutSortPreset,
6
+ type StreamVideoParticipant,
7
+ type VideoTrackType,
6
8
  } from '@stream-io/video-client';
7
9
  import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
8
10
  import type { MediaStream } from '@stream-io/react-native-webrtc';
9
- import React, { useEffect, useMemo } from 'react';
11
+ import React, { useEffect, useMemo, useCallback } from 'react';
10
12
  import { findNodeHandle } from 'react-native';
11
- import { onNativeCallClosed, RTCViewPipNative } from './RTCViewPipNative';
13
+ import {
14
+ onNativeCallClosed,
15
+ onNativeDimensionsUpdated,
16
+ RTCViewPipNative,
17
+ } from './RTCViewPipNative';
12
18
  import { useDebouncedValue } from '../../../utils/hooks';
13
19
  import { shouldDisableIOSLocalVideoOnBackgroundRef } from '../../../utils/internal/shouldDisableIOSLocalVideoOnBackground';
20
+ import { useTrackDimensions } from '../../../hooks/useTrackDimensions';
14
21
 
15
22
  type Props = {
16
23
  includeLocalParticipantVideo?: boolean;
@@ -80,23 +87,60 @@ export const RTCViewPipIOS = React.memo((props: Props) => {
80
87
  };
81
88
  }, [call]);
82
89
 
83
- const streamURL = useMemo(() => {
84
- if (!participantInSpotlight) {
85
- return undefined;
90
+ const onDimensionsUpdated = useCallback((width: number, height: number) => {
91
+ const node = findNodeHandle(nativeRef.current);
92
+ if (node !== null && width > 0 && height > 0) {
93
+ onNativeDimensionsUpdated(node, width, height);
86
94
  }
95
+ }, []);
87
96
 
88
- const { videoStream, screenShareStream } = participantInSpotlight;
97
+ const { videoStream, screenShareStream } = participantInSpotlight;
89
98
 
90
- const isScreenSharing = hasScreenShare(participantInSpotlight);
99
+ const isScreenSharing = hasScreenShare(participantInSpotlight);
91
100
 
92
- const videoStreamToRender = (isScreenSharing
93
- ? screenShareStream
94
- : videoStream) as unknown as MediaStream | undefined;
101
+ const videoStreamToRender = (isScreenSharing
102
+ ? screenShareStream
103
+ : videoStream) as unknown as MediaStream | undefined;
95
104
 
105
+ const streamURL = useMemo(() => {
106
+ if (!videoStreamToRender) {
107
+ return undefined;
108
+ }
96
109
  return videoStreamToRender?.toURL();
97
- }, [participantInSpotlight]);
110
+ }, [videoStreamToRender]);
98
111
 
99
- return <RTCViewPipNative streamURL={streamURL} ref={nativeRef} />;
112
+ return (
113
+ <>
114
+ <RTCViewPipNative streamURL={streamURL} ref={nativeRef} />
115
+ <DimensionsUpdatedRenderless
116
+ participant={participantInSpotlight}
117
+ trackType={isScreenSharing ? 'screenShareTrack' : 'videoTrack'}
118
+ onDimensionsUpdated={onDimensionsUpdated}
119
+ key={streamURL}
120
+ />
121
+ </>
122
+ );
100
123
  });
101
124
 
125
+ const DimensionsUpdatedRenderless = React.memo(
126
+ ({
127
+ participant,
128
+ trackType,
129
+ onDimensionsUpdated,
130
+ }: {
131
+ participant: StreamVideoParticipant;
132
+ trackType: VideoTrackType;
133
+ onDimensionsUpdated: (width: number, height: number) => void;
134
+ }) => {
135
+ const { width, height } = useTrackDimensions(participant, trackType);
136
+
137
+ useEffect(() => {
138
+ onDimensionsUpdated(width, height);
139
+ }, [width, height, onDimensionsUpdated]);
140
+
141
+ return null;
142
+ },
143
+ );
144
+
145
+ DimensionsUpdatedRenderless.displayName = 'DimensionsUpdatedRenderless';
102
146
  RTCViewPipIOS.displayName = 'RTCViewPipIOS';
@@ -26,6 +26,23 @@ export function onNativeCallClosed(reactTag: number) {
26
26
  );
27
27
  }
28
28
 
29
+ export function onNativeDimensionsUpdated(
30
+ reactTag: number,
31
+ width: number,
32
+ height: number,
33
+ ) {
34
+ getLogger(['RTCViewPipNative'])('debug', 'onNativeDimensionsUpdated', {
35
+ width,
36
+ height,
37
+ });
38
+ UIManager.dispatchViewManagerCommand(
39
+ reactTag,
40
+ UIManager.getViewManagerConfig(COMPONENT_NAME).Commands
41
+ .setPreferredContentSize,
42
+ [width, height],
43
+ );
44
+ }
45
+
29
46
  /** Wrapper for the native view
30
47
  * meant to stay private and not exposed */
31
48
  export const RTCViewPipNative = React.memo(
@@ -34,7 +34,7 @@ export function useTrackDimensions(
34
34
 
35
35
  // Set up videoTrackDimensionChanged event listener for more direct dimension updates
36
36
  useEffect(() => {
37
- if (!trackId || !NativeModules.WebRTCModule) return;
37
+ if (!trackId || !track) return;
38
38
 
39
39
  const handleVideoTrackDimensionChanged = (eventData: {
40
40
  pcId: string;
@@ -46,16 +46,27 @@ export function useTrackDimensions(
46
46
  if (eventData.trackId === trackId) {
47
47
  setTrackDimensions((prev) => {
48
48
  if (
49
- prev.width !== eventData.width ||
50
- prev.height !== eventData.height
49
+ prev.width === eventData.width &&
50
+ prev.height === eventData.height
51
51
  ) {
52
- return { width: eventData.width, height: eventData.height };
52
+ return prev;
53
53
  }
54
- return prev;
54
+ return { width: eventData.width, height: eventData.height };
55
55
  });
56
56
  }
57
57
  };
58
58
 
59
+ const { width, height } = track.getSettings();
60
+ setTrackDimensions((prev) => {
61
+ if (prev.width === width && prev.height === height) {
62
+ return prev;
63
+ }
64
+ return {
65
+ width: width ?? 0,
66
+ height: height ?? 0,
67
+ };
68
+ });
69
+
59
70
  const subscription = webRTCEventEmitter.addListener(
60
71
  'videoTrackDimensionChanged',
61
72
  handleVideoTrackDimensionChanged,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.20.1-alpha.1';
1
+ export const version = '1.20.2';
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>StreamVideoReactNative.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- </dict>
13
- </dict>
14
- </plist>