@stream-io/video-react-native-sdk 0.6.21 → 0.7.1

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 (111) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/commonjs/components/Call/CallControls/ToggleAudioPreviewButton.js +6 -6
  3. package/dist/commonjs/components/Call/CallControls/ToggleAudioPreviewButton.js.map +1 -1
  4. package/dist/commonjs/components/Call/CallControls/ToggleAudioPublishingButton.js +5 -5
  5. package/dist/commonjs/components/Call/CallControls/ToggleAudioPublishingButton.js.map +1 -1
  6. package/dist/commonjs/components/Call/CallControls/ToggleCameraFaceButton.js +4 -4
  7. package/dist/commonjs/components/Call/CallControls/ToggleCameraFaceButton.js.map +1 -1
  8. package/dist/commonjs/components/Call/CallControls/ToggleVideoPreviewButton.js +6 -6
  9. package/dist/commonjs/components/Call/CallControls/ToggleVideoPreviewButton.js.map +1 -1
  10. package/dist/commonjs/components/Call/CallControls/ToggleVideoPublishingButton.js +5 -5
  11. package/dist/commonjs/components/Call/CallControls/ToggleVideoPublishingButton.js.map +1 -1
  12. package/dist/commonjs/components/Call/Lobby/Lobby.js +4 -2
  13. package/dist/commonjs/components/Call/Lobby/Lobby.js.map +1 -1
  14. package/dist/commonjs/components/Call/RingingCallContent/IncomingCall.js +2 -0
  15. package/dist/commonjs/components/Call/RingingCallContent/IncomingCall.js.map +1 -1
  16. package/dist/commonjs/components/Call/RingingCallContent/OutgoingCall.js +7 -5
  17. package/dist/commonjs/components/Call/RingingCallContent/OutgoingCall.js.map +1 -1
  18. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js +6 -11
  19. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js.map +1 -1
  20. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js +4 -4
  21. package/dist/commonjs/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js.map +1 -1
  22. package/dist/commonjs/hooks/index.js +11 -0
  23. package/dist/commonjs/hooks/index.js.map +1 -1
  24. package/dist/commonjs/hooks/useApplyDefaultMediaStreamSettings.js +52 -0
  25. package/dist/commonjs/hooks/useApplyDefaultMediaStreamSettings.js.map +1 -0
  26. package/dist/commonjs/index.js +1 -8
  27. package/dist/commonjs/index.js.map +1 -1
  28. package/dist/commonjs/providers/StreamCall.js +30 -4
  29. package/dist/commonjs/providers/StreamCall.js.map +1 -1
  30. package/dist/commonjs/providers/index.js +0 -11
  31. package/dist/commonjs/providers/index.js.map +1 -1
  32. package/dist/commonjs/version.js +1 -1
  33. package/dist/commonjs/version.js.map +1 -1
  34. package/dist/module/components/Call/CallControls/ToggleAudioPreviewButton.js +7 -7
  35. package/dist/module/components/Call/CallControls/ToggleAudioPreviewButton.js.map +1 -1
  36. package/dist/module/components/Call/CallControls/ToggleAudioPublishingButton.js +6 -6
  37. package/dist/module/components/Call/CallControls/ToggleAudioPublishingButton.js.map +1 -1
  38. package/dist/module/components/Call/CallControls/ToggleCameraFaceButton.js +5 -5
  39. package/dist/module/components/Call/CallControls/ToggleCameraFaceButton.js.map +1 -1
  40. package/dist/module/components/Call/CallControls/ToggleVideoPreviewButton.js +7 -7
  41. package/dist/module/components/Call/CallControls/ToggleVideoPreviewButton.js.map +1 -1
  42. package/dist/module/components/Call/CallControls/ToggleVideoPublishingButton.js +6 -6
  43. package/dist/module/components/Call/CallControls/ToggleVideoPublishingButton.js.map +1 -1
  44. package/dist/module/components/Call/Lobby/Lobby.js +4 -2
  45. package/dist/module/components/Call/Lobby/Lobby.js.map +1 -1
  46. package/dist/module/components/Call/RingingCallContent/IncomingCall.js +2 -0
  47. package/dist/module/components/Call/RingingCallContent/IncomingCall.js.map +1 -1
  48. package/dist/module/components/Call/RingingCallContent/OutgoingCall.js +8 -6
  49. package/dist/module/components/Call/RingingCallContent/OutgoingCall.js.map +1 -1
  50. package/dist/module/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js +7 -12
  51. package/dist/module/components/Livestream/LivestreamControls/LivestreamAudioControlButton.js.map +1 -1
  52. package/dist/module/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js +5 -5
  53. package/dist/module/components/Livestream/LivestreamControls/LivestreamVideoControlButton.js.map +1 -1
  54. package/dist/module/hooks/index.js +1 -0
  55. package/dist/module/hooks/index.js.map +1 -1
  56. package/dist/module/hooks/useApplyDefaultMediaStreamSettings.js +46 -0
  57. package/dist/module/hooks/useApplyDefaultMediaStreamSettings.js.map +1 -0
  58. package/dist/module/index.js +1 -1
  59. package/dist/module/index.js.map +1 -1
  60. package/dist/module/providers/StreamCall.js +30 -4
  61. package/dist/module/providers/StreamCall.js.map +1 -1
  62. package/dist/module/providers/index.js +0 -1
  63. package/dist/module/providers/index.js.map +1 -1
  64. package/dist/module/version.js +1 -1
  65. package/dist/module/version.js.map +1 -1
  66. package/dist/typescript/components/Call/CallControls/ToggleAudioPreviewButton.d.ts.map +1 -1
  67. package/dist/typescript/components/Call/CallControls/ToggleAudioPublishingButton.d.ts.map +1 -1
  68. package/dist/typescript/components/Call/CallControls/ToggleCameraFaceButton.d.ts.map +1 -1
  69. package/dist/typescript/components/Call/CallControls/ToggleVideoPreviewButton.d.ts.map +1 -1
  70. package/dist/typescript/components/Call/CallControls/ToggleVideoPublishingButton.d.ts.map +1 -1
  71. package/dist/typescript/components/Call/Lobby/Lobby.d.ts.map +1 -1
  72. package/dist/typescript/components/Call/RingingCallContent/IncomingCall.d.ts.map +1 -1
  73. package/dist/typescript/components/Call/RingingCallContent/OutgoingCall.d.ts.map +1 -1
  74. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamAudioControlButton.d.ts.map +1 -1
  75. package/dist/typescript/components/Livestream/LivestreamControls/LivestreamVideoControlButton.d.ts.map +1 -1
  76. package/dist/typescript/hooks/index.d.ts +1 -0
  77. package/dist/typescript/hooks/index.d.ts.map +1 -1
  78. package/dist/typescript/hooks/useApplyDefaultMediaStreamSettings.d.ts +5 -0
  79. package/dist/typescript/hooks/useApplyDefaultMediaStreamSettings.d.ts.map +1 -0
  80. package/dist/typescript/index.d.ts +1 -1
  81. package/dist/typescript/index.d.ts.map +1 -1
  82. package/dist/typescript/providers/StreamCall.d.ts +1 -8
  83. package/dist/typescript/providers/StreamCall.d.ts.map +1 -1
  84. package/dist/typescript/providers/index.d.ts +0 -1
  85. package/dist/typescript/providers/index.d.ts.map +1 -1
  86. package/dist/typescript/version.d.ts +1 -1
  87. package/dist/typescript/version.d.ts.map +1 -1
  88. package/package.json +3 -3
  89. package/src/components/Call/CallControls/ToggleAudioPreviewButton.tsx +6 -8
  90. package/src/components/Call/CallControls/ToggleAudioPublishingButton.tsx +5 -10
  91. package/src/components/Call/CallControls/ToggleCameraFaceButton.tsx +4 -9
  92. package/src/components/Call/CallControls/ToggleVideoPreviewButton.tsx +6 -8
  93. package/src/components/Call/CallControls/ToggleVideoPublishingButton.tsx +5 -10
  94. package/src/components/Call/Lobby/Lobby.tsx +4 -2
  95. package/src/components/Call/RingingCallContent/IncomingCall.tsx +3 -0
  96. package/src/components/Call/RingingCallContent/OutgoingCall.tsx +8 -11
  97. package/src/components/Livestream/LivestreamControls/LivestreamAudioControlButton.tsx +17 -29
  98. package/src/components/Livestream/LivestreamControls/LivestreamVideoControlButton.tsx +4 -5
  99. package/src/hooks/index.ts +1 -0
  100. package/src/hooks/useApplyDefaultMediaStreamSettings.tsx +42 -0
  101. package/src/index.ts +1 -1
  102. package/src/providers/StreamCall.tsx +37 -18
  103. package/src/providers/index.ts +0 -1
  104. package/src/version.ts +1 -1
  105. package/dist/commonjs/providers/MediaStreamManagement.js +0 -116
  106. package/dist/commonjs/providers/MediaStreamManagement.js.map +0 -1
  107. package/dist/module/providers/MediaStreamManagement.js +0 -107
  108. package/dist/module/providers/MediaStreamManagement.js.map +0 -1
  109. package/dist/typescript/providers/MediaStreamManagement.d.ts +0 -23
  110. package/dist/typescript/providers/MediaStreamManagement.d.ts.map +0 -1
  111. package/src/providers/MediaStreamManagement.tsx +0 -132
@@ -1,4 +1,3 @@
1
1
  export * from './StreamVideo';
2
2
  export * from './StreamCall';
3
- export * from './MediaStreamManagement';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "0.6.21";
1
+ export declare const version = "0.7.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-react-native-sdk",
3
- "version": "0.6.21",
3
+ "version": "0.7.1",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/module/index.js",
@@ -45,8 +45,8 @@
45
45
  "!**/.*"
46
46
  ],
47
47
  "dependencies": {
48
- "@stream-io/video-client": "^1.0.1",
49
- "@stream-io/video-react-bindings": "^0.4.27",
48
+ "@stream-io/video-client": "^1.0.2",
49
+ "@stream-io/video-react-bindings": "^0.4.28",
50
50
  "intl-pluralrules": "2.0.1",
51
51
  "lodash.merge": "^4.6.2",
52
52
  "react-native-url-polyfill": "1.3.0",
@@ -1,4 +1,4 @@
1
- import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
1
+ import { useCallStateHooks } from '@stream-io/video-react-bindings';
2
2
  import React from 'react';
3
3
  import { useTheme } from '../../../contexts';
4
4
  import { Mic, MicOff } from '../../../icons';
@@ -28,33 +28,31 @@ export const ToggleAudioPreviewButton = ({
28
28
  variants: { buttonSizes },
29
29
  },
30
30
  } = useTheme();
31
- const call = useCall();
32
31
  const { useMicrophoneState } = useCallStateHooks();
33
- const { status } = useMicrophoneState();
32
+ const { isMute, microphone } = useMicrophoneState();
34
33
 
35
34
  const onPress = async () => {
36
35
  if (onPressHandler) {
37
36
  onPressHandler();
38
37
  return;
39
38
  }
40
- await call?.microphone.toggle();
39
+ await microphone.toggle();
41
40
  };
42
41
 
43
42
  return (
44
43
  <CallControlsButton
45
44
  onPress={onPress}
46
- color={status === 'enabled' ? colors.static_white : colors.static_black}
45
+ color={!isMute ? colors.static_white : colors.static_black}
47
46
  size={buttonSizes.md}
48
47
  style={{
49
48
  container: {
50
- shadowColor:
51
- status === 'enabled' ? colors.static_white : colors.static_black,
49
+ shadowColor: !isMute ? colors.static_white : colors.static_black,
52
50
  ...toggleAudioPreviewButton.container,
53
51
  },
54
52
  svgContainer: toggleAudioPreviewButton.svgContainer,
55
53
  }}
56
54
  >
57
- {status === 'enabled' ? (
55
+ {!isMute ? (
58
56
  <Mic color={colors.static_black} />
59
57
  ) : (
60
58
  <MicOff color={colors.static_white} />
@@ -1,10 +1,6 @@
1
1
  import React from 'react';
2
2
  import { OwnCapability } from '@stream-io/video-client';
3
- import {
4
- Restricted,
5
- useCall,
6
- useCallStateHooks,
7
- } from '@stream-io/video-react-bindings';
3
+ import { Restricted, useCallStateHooks } from '@stream-io/video-react-bindings';
8
4
  import { CallControlsButton } from './CallControlsButton';
9
5
  import { Mic, MicOff } from '../../../icons';
10
6
  import { useTheme } from '../../../contexts/ThemeContext';
@@ -26,9 +22,8 @@ export type ToggleAudioPublishingButtonProps = {
26
22
  export const ToggleAudioPublishingButton = ({
27
23
  onPressHandler,
28
24
  }: ToggleAudioPublishingButtonProps) => {
29
- const call = useCall();
30
25
  const { useMicrophoneState } = useCallStateHooks();
31
- const { status } = useMicrophoneState();
26
+ const { isMute, microphone } = useMicrophoneState();
32
27
 
33
28
  const {
34
29
  theme: { colors, toggleAudioPublishingButton },
@@ -39,17 +34,17 @@ export const ToggleAudioPublishingButton = ({
39
34
  return;
40
35
  }
41
36
 
42
- await call?.microphone.toggle();
37
+ await microphone.toggle();
43
38
  };
44
39
 
45
40
  return (
46
41
  <Restricted requiredGrants={[OwnCapability.SEND_AUDIO]}>
47
42
  <CallControlsButton
48
43
  onPress={onPress}
49
- color={status === 'enabled' ? colors.static_white : colors.overlay_dark}
44
+ color={!isMute ? colors.static_white : colors.overlay_dark}
50
45
  style={toggleAudioPublishingButton}
51
46
  >
52
- {status === 'enabled' ? (
47
+ {!isMute ? (
53
48
  <Mic color={colors.static_black} />
54
49
  ) : (
55
50
  <MicOff color={colors.static_white} />
@@ -1,9 +1,5 @@
1
1
  import { OwnCapability } from '@stream-io/video-client';
2
- import {
3
- Restricted,
4
- useCall,
5
- useCallStateHooks,
6
- } from '@stream-io/video-react-bindings';
2
+ import { Restricted, useCallStateHooks } from '@stream-io/video-react-bindings';
7
3
  import React from 'react';
8
4
  import { CallControlsButton } from './CallControlsButton';
9
5
  import { CameraSwitch } from '../../../icons';
@@ -26,9 +22,8 @@ export type ToggleCameraFaceButtonProps = {
26
22
  export const ToggleCameraFaceButton = ({
27
23
  onPressHandler,
28
24
  }: ToggleCameraFaceButtonProps) => {
29
- const call = useCall();
30
25
  const { useCameraState, useCallSettings } = useCallStateHooks();
31
- const { status, direction } = useCameraState();
26
+ const { camera, isMute, direction } = useCameraState();
32
27
  const callSettings = useCallSettings();
33
28
  const isVideoEnabledInCall = callSettings?.video.enabled;
34
29
 
@@ -41,7 +36,7 @@ export const ToggleCameraFaceButton = ({
41
36
  return;
42
37
  }
43
38
 
44
- await call?.camera.flip();
39
+ await camera.flip();
45
40
  };
46
41
 
47
42
  if (!isVideoEnabledInCall) {
@@ -53,7 +48,7 @@ export const ToggleCameraFaceButton = ({
53
48
  <CallControlsButton
54
49
  onPress={onPress}
55
50
  color={direction === 'back' ? colors.overlay_dark : colors.static_white}
56
- disabled={status === 'disabled'}
51
+ disabled={isMute}
57
52
  style={toggleCameraFaceButton}
58
53
  >
59
54
  <CameraSwitch
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
2
+ import { useCallStateHooks } from '@stream-io/video-react-bindings';
3
3
  import { useTheme } from '../../../contexts';
4
4
  import { CallControlsButton } from './CallControlsButton';
5
5
  import { Video, VideoSlash } from '../../../icons';
@@ -28,17 +28,16 @@ export const ToggleVideoPreviewButton = ({
28
28
  variants: { buttonSizes },
29
29
  },
30
30
  } = useTheme();
31
- const call = useCall();
32
31
  const { useCameraState, useCallSettings } = useCallStateHooks();
33
32
  const callSettings = useCallSettings();
34
33
  const isVideoEnabledInCall = callSettings?.video.enabled;
35
- const { status } = useCameraState();
34
+ const { isMute, camera } = useCameraState();
36
35
  const onPress = async () => {
37
36
  if (onPressHandler) {
38
37
  onPressHandler();
39
38
  return;
40
39
  }
41
- await call?.camera.toggle();
40
+ await camera.toggle();
42
41
  };
43
42
 
44
43
  if (!isVideoEnabledInCall) {
@@ -48,18 +47,17 @@ export const ToggleVideoPreviewButton = ({
48
47
  return (
49
48
  <CallControlsButton
50
49
  onPress={onPress}
51
- color={status === 'enabled' ? colors.static_white : colors.static_black}
50
+ color={!isMute ? colors.static_white : colors.static_black}
52
51
  size={buttonSizes.md}
53
52
  style={{
54
53
  container: {
55
- shadowColor:
56
- status === 'enabled' ? colors.static_white : colors.static_black,
54
+ shadowColor: !isMute ? colors.static_white : colors.static_black,
57
55
  ...toggleVideoPreviewButton.container,
58
56
  },
59
57
  svgContainer: toggleVideoPreviewButton.svgContainer,
60
58
  }}
61
59
  >
62
- {status === 'enabled' ? (
60
+ {!isMute ? (
63
61
  <Video color={colors.static_black} />
64
62
  ) : (
65
63
  <VideoSlash color={colors.static_white} />
@@ -1,10 +1,6 @@
1
1
  import React from 'react';
2
2
  import { OwnCapability } from '@stream-io/video-client';
3
- import {
4
- Restricted,
5
- useCall,
6
- useCallStateHooks,
7
- } from '@stream-io/video-react-bindings';
3
+ import { Restricted, useCallStateHooks } from '@stream-io/video-react-bindings';
8
4
  import { CallControlsButton } from './CallControlsButton';
9
5
  import { Video, VideoSlash } from '../../../icons';
10
6
  import { useTheme } from '../../../contexts/ThemeContext';
@@ -26,9 +22,8 @@ export type ToggleVideoPublishingButtonProps = {
26
22
  export const ToggleVideoPublishingButton = ({
27
23
  onPressHandler,
28
24
  }: ToggleVideoPublishingButtonProps) => {
29
- const call = useCall();
30
25
  const { useCameraState, useCallSettings } = useCallStateHooks();
31
- const { status } = useCameraState();
26
+ const { camera, isMute } = useCameraState();
32
27
  const callSettings = useCallSettings();
33
28
  const isVideoEnabledInCall = callSettings?.video.enabled;
34
29
  const {
@@ -39,7 +34,7 @@ export const ToggleVideoPublishingButton = ({
39
34
  onPressHandler();
40
35
  return;
41
36
  }
42
- await call?.camera.toggle();
37
+ await camera.toggle();
43
38
  };
44
39
 
45
40
  if (!isVideoEnabledInCall) {
@@ -50,9 +45,9 @@ export const ToggleVideoPublishingButton = ({
50
45
  <Restricted requiredGrants={[OwnCapability.SEND_VIDEO]}>
51
46
  <CallControlsButton
52
47
  onPress={onPress}
53
- color={status === 'enabled' ? colors.static_white : colors.overlay_dark}
48
+ color={!isMute ? colors.static_white : colors.overlay_dark}
54
49
  >
55
- {status === 'enabled' ? (
50
+ {!isMute ? (
56
51
  <Video color={colors.static_black} />
57
52
  ) : (
58
53
  <VideoSlash color={colors.static_white} />
@@ -22,6 +22,7 @@ import {
22
22
  LobbyFooter as DefaultLobbyFooter,
23
23
  LobbyFooterProps,
24
24
  } from './LobbyFooter';
25
+ import { useApplyDefaultMediaStreamSettings } from '../../../hooks/useApplyDefaultMediaStreamSettings';
25
26
 
26
27
  /**
27
28
  * Props for the Lobby Component.
@@ -67,10 +68,11 @@ export const Lobby = ({
67
68
  const { useCameraState, useCallSettings } = useCallStateHooks();
68
69
  const callSettings = useCallSettings();
69
70
  const isVideoEnabledInCall = callSettings?.video.enabled;
70
- const { status: cameraStatus, mediaStream } = useCameraState();
71
+ const { isMute: cameraIsMuted, mediaStream } = useCameraState();
71
72
  const { t } = useI18n();
72
73
  const localVideoStream = mediaStream as unknown as MediaStream | undefined;
73
74
 
75
+ useApplyDefaultMediaStreamSettings();
74
76
  useCallMediaStreamCleanup();
75
77
 
76
78
  const connectedUserAsParticipant = {
@@ -124,7 +126,7 @@ export const Lobby = ({
124
126
  ]}
125
127
  >
126
128
  <View style={styles.topView} />
127
- {cameraStatus === 'enabled' && localVideoStream ? (
129
+ {!cameraIsMuted && localVideoStream ? (
128
130
  <RTCView
129
131
  mirror={true}
130
132
  streamURL={localVideoStream.toURL()}
@@ -21,6 +21,7 @@ import {
21
21
  IncomingCallControlsProps,
22
22
  } from '../CallControls';
23
23
  import { useTheme } from '../../../contexts';
24
+ import { useApplyDefaultMediaStreamSettings } from '../../../hooks/useApplyDefaultMediaStreamSettings';
24
25
 
25
26
  /**
26
27
  * Props for the IncomingCall Component.
@@ -57,6 +58,8 @@ export const IncomingCall = ({
57
58
  theme: { colors, incomingCall, typefaces },
58
59
  } = useTheme();
59
60
 
61
+ useApplyDefaultMediaStreamSettings();
62
+
60
63
  const landscapeContentStyles: ViewStyle = {
61
64
  flexDirection: landscape ? 'row' : 'column',
62
65
  };
@@ -2,11 +2,7 @@ import React from 'react';
2
2
  import { StyleSheet, Text, View, ViewStyle } from 'react-native';
3
3
  import { UserInfo } from './UserInfo';
4
4
  import { Z_INDEX } from '../../../constants';
5
- import {
6
- useCall,
7
- useCallStateHooks,
8
- useI18n,
9
- } from '@stream-io/video-react-bindings';
5
+ import { useCallStateHooks, useI18n } from '@stream-io/video-react-bindings';
10
6
  import { MediaStream, RTCView } from '@stream-io/react-native-webrtc';
11
7
  import { useTheme } from '../../../contexts/ThemeContext';
12
8
  import {
@@ -18,6 +14,7 @@ import {
18
14
  CallTopViewProps,
19
15
  } from '../CallTopView';
20
16
  import { useCallMediaStreamCleanup } from '../../../hooks/internal/useCallMediaStreamCleanup';
17
+ import { useApplyDefaultMediaStreamSettings } from '../../../hooks/useApplyDefaultMediaStreamSettings';
21
18
 
22
19
  /**
23
20
  * Props for the OutgoingCall Component.
@@ -52,6 +49,9 @@ export const OutgoingCall = ({
52
49
  } = useTheme();
53
50
  const { t } = useI18n();
54
51
 
52
+ useApplyDefaultMediaStreamSettings();
53
+ useCallMediaStreamCleanup();
54
+
55
55
  const landscapeContentStyles: ViewStyle = {
56
56
  flexDirection: landscape ? 'row' : 'column',
57
57
  };
@@ -104,16 +104,13 @@ const Background = () => {
104
104
  const {
105
105
  theme: { colors, outgoingCall },
106
106
  } = useTheme();
107
- const call = useCall();
108
107
  const { useCameraState } = useCallStateHooks();
109
- const { status } = useCameraState();
110
- const localVideoStream = call?.camera.state.mediaStream as unknown as
108
+ const { isMute, camera } = useCameraState();
109
+ const localVideoStream = camera.state.mediaStream as unknown as
111
110
  | MediaStream
112
111
  | undefined;
113
112
 
114
- useCallMediaStreamCleanup();
115
-
116
- if (status === 'disabled' || !localVideoStream) {
113
+ if (isMute || !localVideoStream) {
117
114
  return (
118
115
  <View
119
116
  style={[
@@ -1,4 +1,4 @@
1
- import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
1
+ import { useCallStateHooks } from '@stream-io/video-react-bindings';
2
2
  import React from 'react';
3
3
  import { useTheme } from '../../../contexts';
4
4
  import { Pressable, StyleSheet, View } from 'react-native';
@@ -8,9 +8,8 @@ import { Mic, MicOff } from '../../../icons';
8
8
  * The LivestreamAudioControlButton controls the audio stream publish/unpublish while in the livestream for the host.
9
9
  */
10
10
  export const LivestreamAudioControlButton = () => {
11
- const call = useCall();
12
11
  const { useMicrophoneState } = useCallStateHooks();
13
- const { status } = useMicrophoneState();
12
+ const { isMute, microphone } = useMicrophoneState();
14
13
  const {
15
14
  theme: {
16
15
  colors,
@@ -20,7 +19,7 @@ export const LivestreamAudioControlButton = () => {
20
19
  } = useTheme();
21
20
 
22
21
  const onPress = async () => {
23
- await call?.microphone.toggle();
22
+ await microphone.toggle();
24
23
  };
25
24
 
26
25
  return (
@@ -36,33 +35,22 @@ export const LivestreamAudioControlButton = () => {
36
35
  livestreamAudioControlButton.container,
37
36
  ]}
38
37
  >
39
- {status === 'enabled' ? (
40
- <View
41
- style={[
42
- styles.icon,
43
- {
44
- height: iconSizes.sm,
45
- width: iconSizes.sm,
46
- },
47
- livestreamAudioControlButton.icon,
48
- ]}
49
- >
38
+ <View
39
+ style={[
40
+ styles.icon,
41
+ {
42
+ height: iconSizes.sm,
43
+ width: iconSizes.sm,
44
+ },
45
+ livestreamAudioControlButton.icon,
46
+ ]}
47
+ >
48
+ {!isMute ? (
50
49
  <Mic color={colors.static_white} />
51
- </View>
52
- ) : (
53
- <View
54
- style={[
55
- styles.icon,
56
- {
57
- height: iconSizes.sm,
58
- width: iconSizes.sm,
59
- },
60
- livestreamAudioControlButton.icon,
61
- ]}
62
- >
50
+ ) : (
63
51
  <MicOff color={colors.static_white} />
64
- </View>
65
- )}
52
+ )}
53
+ </View>
66
54
  </Pressable>
67
55
  );
68
56
  };
@@ -1,4 +1,4 @@
1
- import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
1
+ import { useCallStateHooks } from '@stream-io/video-react-bindings';
2
2
  import React from 'react';
3
3
  import { useTheme } from '../../../contexts';
4
4
  import { Pressable, StyleSheet, View } from 'react-native';
@@ -8,9 +8,8 @@ import { Video, VideoSlash } from '../../../icons';
8
8
  * The LivestreamVideoControlButton controls the video stream publish/unpublish while in the livestream for the host.
9
9
  */
10
10
  export const LivestreamVideoControlButton = () => {
11
- const call = useCall();
12
11
  const { useCameraState, useCallSettings } = useCallStateHooks();
13
- const { status } = useCameraState();
12
+ const { isMute, camera } = useCameraState();
14
13
  const callSettings = useCallSettings();
15
14
  const isVideoEnabledInCall = callSettings?.video.enabled;
16
15
  const {
@@ -22,7 +21,7 @@ export const LivestreamVideoControlButton = () => {
22
21
  } = useTheme();
23
22
 
24
23
  const onPress = async () => {
25
- await call?.camera.toggle();
24
+ await camera.toggle();
26
25
  };
27
26
 
28
27
  if (!isVideoEnabledInCall) {
@@ -42,7 +41,7 @@ export const LivestreamVideoControlButton = () => {
42
41
  livestreamVideoControlButton.container,
43
42
  ]}
44
43
  >
45
- {status === 'enabled' ? (
44
+ {!isMute ? (
46
45
  <View
47
46
  style={[
48
47
  styles.icon,
@@ -5,3 +5,4 @@ export * from './useAndroidKeepCallAliveEffect';
5
5
  export * from './useIsIosScreenshareBroadcastStarted';
6
6
  export * from './useIsInPiPMode';
7
7
  export * from './useAutoEnterPiPEffect';
8
+ export * from './useApplyDefaultMediaStreamSettings';
@@ -0,0 +1,42 @@
1
+ import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings';
2
+ import { useEffect, useMemo } from 'react';
3
+
4
+ /**
5
+ * Hook when used applies the default call media stream audio/video settings.
6
+ */
7
+ export const useApplyDefaultMediaStreamSettings = () => {
8
+ const { useCallSettings } = useCallStateHooks();
9
+ const settings = useCallSettings();
10
+ const call = useCall();
11
+
12
+ /*
13
+ * This is the object is used to track the initial audio/video enablement
14
+ * Uses backend settings or the Prop to set initial audio/video enabled
15
+ * Backend settings is applied only if the prop was undefined -- meaning user did not provide any value
16
+ * Memoization is needed to avoid unnecessary useEffect triggers
17
+ */
18
+ const { initialAudioEnabled, initialVideoEnabled } = useMemo(() => {
19
+ return {
20
+ initialAudioEnabled: settings?.audio.mic_default_on,
21
+ initialVideoEnabled: settings?.video.camera_default_on,
22
+ };
23
+ }, [settings?.audio.mic_default_on, settings?.video.camera_default_on]);
24
+
25
+ useEffect(() => {
26
+ if (initialAudioEnabled !== undefined) {
27
+ if (initialAudioEnabled) {
28
+ call?.microphone.enable();
29
+ } else {
30
+ call?.microphone.disable();
31
+ }
32
+ }
33
+
34
+ if (initialVideoEnabled !== undefined) {
35
+ if (initialVideoEnabled) {
36
+ call?.camera.enable();
37
+ } else {
38
+ call?.camera.disable();
39
+ }
40
+ }
41
+ }, [call, initialAudioEnabled, initialVideoEnabled]);
42
+ };
package/src/index.ts CHANGED
@@ -30,6 +30,6 @@ export * from './translations';
30
30
 
31
31
  // Overriding 'StreamVideo' from '@stream-io/video-react-bindings'
32
32
  // Explicitly re-exporting to resolve ambiguity.
33
- export { StreamVideo, StreamCall, MediaStreamManagement } from './providers';
33
+ export { StreamVideo, StreamCall } from './providers';
34
34
 
35
35
  setClientDetails();
@@ -1,16 +1,14 @@
1
- import { StreamCallProvider } from '@stream-io/video-react-bindings';
1
+ import { StreamCallProvider, useCall } from '@stream-io/video-react-bindings';
2
2
  import React, { PropsWithChildren, useEffect } from 'react';
3
3
  import { Call } from '@stream-io/video-client';
4
4
  import { useIosCallkeepWithCallingStateEffect } from '../hooks/push/useIosCallkeepWithCallingStateEffect';
5
- import {
6
- MediaDevicesInitialState,
7
- MediaStreamManagement,
8
- } from './MediaStreamManagement';
9
5
  import {
10
6
  canAddPushWSSubscriptionsRef,
11
7
  clearPushWSEventSubscriptions,
12
8
  } from '../utils/push/utils';
13
9
  import { useAndroidKeepCallAliveEffect } from '../hooks/useAndroidKeepCallAliveEffect';
10
+ import { useAppStateListener } from '../utils/hooks';
11
+ import { NativeModules, Platform } from 'react-native';
14
12
 
15
13
  export type StreamCallProps = {
16
14
  /**
@@ -18,12 +16,6 @@ export type StreamCallProps = {
18
16
  * Children can access it with useCall() hook.
19
17
  */
20
18
  call: Call;
21
- /**
22
- * Optionally provide the initial status of the media devices(audio/video) to the `MediaStreamManagement`.
23
- * Note: It will override the default state of the media devices set from the server side.
24
- * It is used to control the initial state of the media devices(audio/video) in a custom lobby component.
25
- */
26
- mediaDeviceInitialState?: MediaDevicesInitialState;
27
19
  };
28
20
  /**
29
21
  * StreamCall is a wrapper component that orchestrates the call life cycle logic and
@@ -34,21 +26,48 @@ export type StreamCallProps = {
34
26
  */
35
27
  export const StreamCall = ({
36
28
  call,
37
- mediaDeviceInitialState = {},
38
29
  children,
39
30
  }: PropsWithChildren<StreamCallProps>) => {
40
31
  return (
41
32
  <StreamCallProvider call={call}>
42
- <MediaStreamManagement {...mediaDeviceInitialState}>
43
- <AndroidKeepCallAlive />
44
- <IosInformCallkeepCallEnd />
45
- <ClearPushWSSubscriptions />
46
- {children}
47
- </MediaStreamManagement>
33
+ <AppStateListener />
34
+ <AndroidKeepCallAlive />
35
+ <IosInformCallkeepCallEnd />
36
+ <ClearPushWSSubscriptions />
37
+ {children}
48
38
  </StreamCallProvider>
49
39
  );
50
40
  };
51
41
 
42
+ const AppStateListener = () => {
43
+ const call = useCall();
44
+
45
+ // Resume/Disable video stream tracks when app goes to background/foreground
46
+ // To save on CPU resources
47
+ useAppStateListener(
48
+ async () => {
49
+ await call?.camera?.resume();
50
+ },
51
+ async () => {
52
+ if (Platform.OS === 'android') {
53
+ // in Android, we need to check if we are in PiP mode
54
+ // in PiP mode, we don't want to disable the camera
55
+ NativeModules?.StreamVideoReactNative?.isInPiPMode().then(
56
+ async (isInPiP: boolean) => {
57
+ if (!isInPiP) {
58
+ await call?.camera?.disable();
59
+ }
60
+ },
61
+ );
62
+ } else {
63
+ await call?.camera?.disable();
64
+ }
65
+ },
66
+ );
67
+
68
+ return null;
69
+ };
70
+
52
71
  /**
53
72
  * This is a renderless component is used to keep the call alive on Android device using useAndroidKeepCallAliveEffect.
54
73
  * useAndroidKeepCallAliveEffect needs to called inside a child of StreamCallProvider.
@@ -1,3 +1,2 @@
1
1
  export * from './StreamVideo';
2
2
  export * from './StreamCall';
3
- export * from './MediaStreamManagement';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.6.21';
1
+ export const version = '0.7.1';