Skip to content

Commit

Permalink
fix: lobby video stream rerender
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshvai committed Nov 29, 2023
1 parent bcc8042 commit 8981a2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
7 changes: 2 additions & 5 deletions packages/react-native-sdk/src/components/Call/Lobby/Lobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ export const Lobby = ({
} = useTheme();
const connectedUser = useConnectedUser();
const { useCameraState } = useCallStateHooks();
const { status: cameraStatus } = useCameraState();
const call = useCall();
const { status: cameraStatus, mediaStream } = useCameraState();
const { t } = useI18n();
const localVideoStream = call?.camera.state.mediaStream as unknown as
| MediaStream
| undefined;
const localVideoStream = mediaStream as unknown as MediaStream | undefined;

useCallMediaStreamCleanup();

Expand Down
15 changes: 10 additions & 5 deletions packages/react-native-sdk/src/providers/MediaStreamManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,23 @@ export const MediaStreamManagement = ({
if (initialVideoEnabled === undefined) {
return;
}
// we wait until we receive the settings from the backend
if (!call || !settings) {
return;
}
if (initialAudioEnabled) {
call?.microphone.enable();
call.microphone.enable();
} else {
call?.microphone.disable();
call.microphone.disable();
}

call.camera.selectTargetResolution(settings.video.target_resolution);
if (initialVideoEnabled) {
call?.camera.enable();
call.camera.enable();
} else {
call?.camera.disable();
call.camera.disable();
}
}, [call, initialAudioEnabled, initialVideoEnabled]);
}, [call, initialAudioEnabled, initialVideoEnabled, settings]);

return <>{children}</>;
};

0 comments on commit 8981a2f

Please sign in to comment.