Merge pull request #2165 from Bilb/fix-call-bugs

Fix call bugs

* add local stream display in fullscreen 
* pick a sample of 2 iceservers for init connection
* show video controls when the mouse is over the app anywhere
pull/2171/head
Audric Ackermann 3 years ago committed by GitHub
commit 04af2d05e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,7 +3,7 @@ import { animation, contextMenu, Item, Menu } from 'react-contexify';
import { InputItem } from '../../session/utils/calling/CallManager'; import { InputItem } from '../../session/utils/calling/CallManager';
import { setFullScreenCall } from '../../state/ducks/call'; import { setFullScreenCall } from '../../state/ducks/call';
import { CallManager, ToastUtils } from '../../session/utils'; import { CallManager, ToastUtils } from '../../session/utils';
import React from 'react'; import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { getHasOngoingCallWithPubkey } from '../../state/selectors/call'; import { getHasOngoingCallWithPubkey } from '../../state/selectors/call';
import { DropDownAndToggleButton } from '../icon/DropDownAndToggleButton'; import { DropDownAndToggleButton } from '../icon/DropDownAndToggleButton';
@ -317,7 +317,7 @@ const handleSpeakerToggle = async (
} }
}; };
const StyledCallWindowControls = styled.div` const StyledCallWindowControls = styled.div<{ makeVisible: boolean }>`
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
@ -335,10 +335,7 @@ const StyledCallWindowControls = styled.div`
display: flex; display: flex;
justify-content: center; justify-content: center;
opacity: 0; opacity: ${props => (props.makeVisible ? 1 : 0)};
&:hover {
opacity: 1;
}
`; `;
export const CallWindowControls = ({ export const CallWindowControls = ({
@ -360,8 +357,27 @@ export const CallWindowControls = ({
currentConnectedCameras: Array<InputItem>; currentConnectedCameras: Array<InputItem>;
isFullScreen: boolean; isFullScreen: boolean;
}) => { }) => {
const [makeVisible, setMakeVisible] = useState(true);
const setMakeVisibleTrue = () => {
setMakeVisible(true);
};
const setMakeVisibleFalse = () => {
setMakeVisible(false);
};
useEffect(() => {
setMakeVisibleTrue();
document.addEventListener('mouseenter', setMakeVisibleTrue);
document.addEventListener('mouseleave', setMakeVisibleFalse);
return () => {
document.removeEventListener('mouseenter', setMakeVisibleTrue);
document.removeEventListener('mouseleave', setMakeVisibleFalse);
};
}, [isFullScreen]);
return ( return (
<StyledCallWindowControls> <StyledCallWindowControls makeVisible={makeVisible}>
{!remoteStreamVideoIsMuted && <ShowInFullScreenButton isFullScreen={isFullScreen} />} {!remoteStreamVideoIsMuted && <ShowInFullScreenButton isFullScreen={isFullScreen} />}
<VideoInputButton <VideoInputButton

@ -26,6 +26,15 @@ const CallInFullScreenVisible = styled.div`
opacity: 1; opacity: 1;
`; `;
const StyledLocalVideoElement = styled.video<{ isVideoMuted: boolean }>`
height: 20%;
width: 20%;
bottom: 0;
right: 0;
position: absolute;
opacity: ${props => (props.isVideoMuted ? 0 : 1)};
`;
export const CallInFullScreenContainer = () => { export const CallInFullScreenContainer = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const ongoingCallWithFocused = useSelector(getHasOngoingCallWithFocusedConvo); const ongoingCallWithFocused = useSelector(getHasOngoingCallWithFocusedConvo);
@ -34,6 +43,7 @@ export const CallInFullScreenContainer = () => {
const { const {
remoteStream, remoteStream,
remoteStreamVideoIsMuted, remoteStreamVideoIsMuted,
localStream,
currentConnectedAudioInputs, currentConnectedAudioInputs,
currentConnectedAudioOutputs, currentConnectedAudioOutputs,
currentConnectedCameras, currentConnectedCameras,
@ -43,6 +53,7 @@ export const CallInFullScreenContainer = () => {
} = useVideoCallEventsListener('CallInFullScreenContainer', true); } = useVideoCallEventsListener('CallInFullScreenContainer', true);
const videoRefRemote = React.useRef<HTMLVideoElement>(null); const videoRefRemote = React.useRef<HTMLVideoElement>(null);
const videoRefLocal = React.useRef<HTMLVideoElement>(null);
function toggleFullScreenOFF() { function toggleFullScreenOFF() {
dispatch(setFullScreenCall(false)); dispatch(setFullScreenCall(false));
@ -69,6 +80,12 @@ export const CallInFullScreenContainer = () => {
} }
} }
if (videoRefLocal?.current) {
if (videoRefLocal.current.srcObject !== localStream) {
videoRefLocal.current.srcObject = localStream;
}
}
return ( return (
<CallInFullScreenVisible onClick={toggleFullScreenOFF}> <CallInFullScreenVisible onClick={toggleFullScreenOFF}>
<StyledVideoElement <StyledVideoElement
@ -76,6 +93,11 @@ export const CallInFullScreenContainer = () => {
autoPlay={true} autoPlay={true}
isVideoMuted={remoteStreamVideoIsMuted} isVideoMuted={remoteStreamVideoIsMuted}
/> />
<StyledLocalVideoElement
ref={videoRefLocal}
autoPlay={true}
isVideoMuted={localStreamVideoIsMuted}
/>
<CallWindowControls <CallWindowControls
currentConnectedAudioInputs={currentConnectedAudioInputs} currentConnectedAudioInputs={currentConnectedAudioInputs}
currentConnectedAudioOutputs={currentConnectedAudioOutputs} currentConnectedAudioOutputs={currentConnectedAudioOutputs}

@ -53,11 +53,6 @@ const CenteredAvatarInDraggable = styled.div`
align-items: center; align-items: center;
`; `;
// TODO:
/**
* Add mute input, deafen, end call, possibly add person to call
* duration - look at how duration calculated for recording.
*/
export const DraggableCallContainer = () => { export const DraggableCallContainer = () => {
const ongoingCallProps = useSelector(getHasOngoingCallWith); const ongoingCallProps = useSelector(getHasOngoingCallWith);
const selectedConversationKey = useSelector(getSelectedConversationKey); const selectedConversationKey = useSelector(getSelectedConversationKey);

@ -986,15 +986,15 @@ class CompositionBoxInner extends React.Component<Props, State> {
// update our selection because updating text programmatically // update our selection because updating text programmatically
// will put the selection at the end of the textarea // will put the selection at the end of the textarea
const selectionStart = currentSelectionStart + Number(colons.length); // const selectionStart = currentSelectionStart + Number(1);
messageBox.selectionStart = selectionStart; // messageBox.selectionStart = selectionStart;
messageBox.selectionEnd = selectionStart; // messageBox.selectionEnd = selectionStart;
// Sometimes, we have to repeat the set of the selection position with a timeout to be effective // // Sometimes, we have to repeat the set of the selection position with a timeout to be effective
setTimeout(() => { // setTimeout(() => {
messageBox.selectionStart = selectionStart; // messageBox.selectionStart = selectionStart;
messageBox.selectionEnd = selectionStart; // messageBox.selectionEnd = selectionStart;
}, 20); // }, 20);
} }
private focusCompositionBox() { private focusCompositionBox() {

@ -120,10 +120,11 @@ let ignoreOffer = false;
let isSettingRemoteAnswerPending = false; let isSettingRemoteAnswerPending = false;
let lastOutgoingOfferTimestamp = -Infinity; let lastOutgoingOfferTimestamp = -Infinity;
const configuration: RTCConfiguration = { /**
bundlePolicy: 'max-bundle', * This array holds all of the ice servers Session can contact.
rtcpMuxPolicy: 'require', * They are all contacted at the same time, so before triggering the request, we get only a subset of those, randomly
iceServers: [ */
const iceServersFullArray = [
{ {
urls: 'turn:freyr.getsession.org', urls: 'turn:freyr.getsession.org',
username: 'session202111', username: 'session202111',
@ -159,7 +160,11 @@ const configuration: RTCConfiguration = {
username: 'session202111', username: 'session202111',
credential: '053c268164bc7bd7', credential: '053c268164bc7bd7',
}, },
], ];
const configuration: RTCConfiguration = {
bundlePolicy: 'max-bundle',
rtcpMuxPolicy: 'require',
// iceTransportPolicy: 'relay', // for now, this cause the connection to break after 30-40 sec if we enable this // iceTransportPolicy: 'relay', // for now, this cause the connection to break after 30-40 sec if we enable this
}; };
@ -701,7 +706,8 @@ function createOrGetPeerConnection(withPubkey: string) {
return peerConnection; return peerConnection;
} }
remoteStream = new MediaStream(); remoteStream = new MediaStream();
peerConnection = new RTCPeerConnection(configuration); const sampleOfICeServers = _.sampleSize(iceServersFullArray, 2);
peerConnection = new RTCPeerConnection({ ...configuration, iceServers: sampleOfICeServers });
dataChannel = peerConnection.createDataChannel('session-datachannel', { dataChannel = peerConnection.createDataChannel('session-datachannel', {
ordered: true, ordered: true,
negotiated: true, negotiated: true,

Loading…
Cancel
Save