diff --git a/net/web/src/context/useRingContext.hook.js b/net/web/src/context/useRingContext.hook.js
index 8bc5af12..b4aad2f8 100644
--- a/net/web/src/context/useRingContext.hook.js
+++ b/net/web/src/context/useRingContext.hook.js
@@ -10,7 +10,8 @@ export function useRingContext() {
const [state, setState] = useState({
ringing: new Map(),
callStatus: null,
- stream: null,
+ localStream: null,
+ remoteStream: null,
});
const access = useRef(null);
@@ -90,7 +91,7 @@ export function useRingContext() {
if (!stream.current) {
console.log("ADD STREAM");
stream.current = new MediaStream();
- updateState({ stream: stream.current });
+ updateState({ remoteStream: stream.current });
}
stream.current.addTrack(ev.track);
};
@@ -108,8 +109,8 @@ console.log("ADD STREAM");
}
};
-console.log("ADD TRANSCEIVER");
const media = await whiteNoise();
+ updateState({ localStream: media });
pc.current.addTransceiver(media.getTracks()[0], {streams: [media]});
ws.current = createWebsocket(`wss://${contactNode}/signal`);
@@ -224,7 +225,7 @@ console.log("ADD TRANSCEIVER");
if (!stream.current) {
stream.current = new MediaStream();
console.log("ADD STREAM");
- updateState({ stream: stream.current });
+ updateState({ remoteStream: stream.current });
}
stream.current.addTrack(ev.track);
};
@@ -246,6 +247,7 @@ console.log("ADD STREAM");
video: true,
audio: true,
});
+ updateState({ localStream: stream });
for (const track of stream.getTracks()) {
console.log("ADD TRANSCEIVER TRACK");
pc.current.addTrack(track);
diff --git a/net/web/src/session/Session.jsx b/net/web/src/session/Session.jsx
index ec2e5641..eff0363a 100644
--- a/net/web/src/session/Session.jsx
+++ b/net/web/src/session/Session.jsx
@@ -1,6 +1,6 @@
import { useRef, useState, useEffect } from 'react';
import { Modal, Drawer, Spin } from 'antd';
-import { RingingWrapper, SessionWrapper } from './Session.styled';
+import { CallingWrapper, RingingWrapper, SessionWrapper } from './Session.styled';
import { useSession } from './useSession.hook';
import { Conversation } from './conversation/Conversation';
import { Details } from './details/Details';
@@ -18,11 +18,12 @@ import { EyeInvisibleOutlined, CloseOutlined, PhoneOutlined } from '@ant-design/
export function Session() {
- const [ showRinging, setShowRinging ] = useState(false);
- const [ modal, modalContext ] = Modal.useModal();
const { state, actions } = useSession();
const [ringing, setRinging] = useState([]);
- const vid = useRef();
+ const [callWidth, setCallWidth] = useState(320);
+ const [callHeight, setCallHeight] = useState(240);
+ const remote = useRef();
+ const local = useRef();
useEffect(() => {
let incoming = [];
@@ -43,16 +44,48 @@ export function Session() {
}, [state.ringing]);
useEffect(() => {
-console.log("SHOW>>>>>", ringing.length > 0);
-
- setShowRinging(ringing.length > 0 && state.callStatus == null);
- }, [state.ringing, state.callStatus]);
+ if (remote.current) {
+ remote.current.onloadedmetadata = (ev) => {
+ const { videoWidth, videoHeight } = ev.target || { videoWidth: 320, videoHeight: 240 }
+ if ((window.innerWidth * 8) / 10 < videoWidth) {
+ const scaledWidth = window.innerWidth * 8 / 10;
+ const scaledHeight = videoHeight * (scaledWidth / videoWidth)
+ if ((window.innerHeight * 8) / 10 < scaledHeight) {
+ const height = (window.innerHeight * 8) / 10;
+ setCallHeight(height);
+ setCallWidth(videoWidth * (height / videoHeight));
+ }
+ else {
+ setCallHeight(scaledHeight);
+ setCallWidth(scaledWidth);
+ }
+ }
+ else if ((window.innerHeight * 8) / 10 < videoHeight) {
+ const height = (window.innerHeight * 8) / 10;
+ setCallHeight(height);
+ setCallWidth(videoWidth * (height / videoHeight));
+ }
+ else {
+ setCallHeight(videoHeight);
+ setCallWidth(videoWidth);
+ }
+ };
+ remote.current.srcObject = state.remoteStream;
+ }
+ else {
+ console.log("video player not set");
+ }
+ }, [state.remoteStream]);
useEffect(() => {
- if (vid.current) {
- vid.current.srcObject = state.stream;
+ if (local.current) {
+ local.current.srcObject = state.localStream;
}
- }, [state.stream]);
+ }, [state.localStream]);
+
+ useEffect(() => {
+ console.log("DIM: ", callWidth, callHeight);
+ }, [callWidth, callHeight]);
const closeAccount = () => {
actions.closeProfile();
@@ -131,16 +164,6 @@ console.log("SHOW>>>>>", ringing.length > 0);