From 41ca37d2df279a403c3611dd305d47f9db257a2f Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Tue, 28 Mar 2023 13:08:12 -0700 Subject: [PATCH] render contact logo when video off --- net/web/src/context/useRingContext.hook.js | 25 ++++++++++++++++------ net/web/src/session/Session.jsx | 14 ++++++------ net/web/src/session/Session.styled.js | 13 ++++++----- net/web/src/session/useSession.hook.js | 12 +++++++++-- 4 files changed, 45 insertions(+), 19 deletions(-) diff --git a/net/web/src/context/useRingContext.hook.js b/net/web/src/context/useRingContext.hook.js index b2257a6e..5f4ff739 100644 --- a/net/web/src/context/useRingContext.hook.js +++ b/net/web/src/context/useRingContext.hook.js @@ -10,6 +10,7 @@ export function useRingContext() { const [state, setState] = useState({ ringing: new Map(), callStatus: null, + cardId: null, localStream: null, localVideo: false, localAudio: false, @@ -30,6 +31,18 @@ export function useRingContext() { const videoTrack = useRef(); const audioTrack = useRef(); + const iceServers = [ + { + urls: 'stun:35.165.123.117:5001?transport=udp', + username: 'user', + credential: 'pass' + }, + { + urls: 'turn:35.165.123.117:5001?transport=udp', + username: 'user', + credential: 'pass' + }]; + const updateState = (value) => { setState((s) => ({ ...s, ...value })) } @@ -95,10 +108,10 @@ export function useRingContext() { // connect signal socket calling.current = { state: "connecting", callId, contactNode, contactToken, host: false }; - updateState({ callStatus: "connecting", remoteVideo: false, remoteAudio: false }); + updateState({ callStatus: "connecting", cardId, remoteVideo: false, remoteAudio: false }); // form peer connection - pc.current = new RTCPeerConnection(); + pc.current = new RTCPeerConnection({ iceServers }); pc.current.ontrack = (ev) => { if (!stream.current) { stream.current = new MediaStream(); @@ -253,10 +266,10 @@ export function useRingContext() { }, RING); calling.current = { state: "connecting", callId: id, host: true }; - updateState({ callStatus: "connecting", remoteVideo: false, remoteAudio: false }); + updateState({ callStatus: "connecting", cardId, remoteVideo: false, remoteAudio: false }); // form peer connection - pc.current = new RTCPeerConnection(); + pc.current = new RTCPeerConnection({ iceServers }); pc.current.ontrack = (ev) => { //{streams: [stream]}) => { console.log("ADD TRACK", ev); if (!stream.current) { @@ -385,7 +398,7 @@ export function useRingContext() { else { videoTrack.current.enabled = true; } - updateState({ localVideo: true }); + updateState({ localVideo: true, localAudio: true }); }, disableVideo: async () => { if (videoTrack.current) { @@ -399,7 +412,7 @@ export function useRingContext() { }, disableAudio: async () => { audioTrack.current.enabled = false; - updateState({ loaclAudio: false }); + updateState({ localAudio: false }); }, } diff --git a/net/web/src/session/Session.jsx b/net/web/src/session/Session.jsx index 8893911f..89695cb9 100644 --- a/net/web/src/session/Session.jsx +++ b/net/web/src/session/Session.jsx @@ -33,7 +33,7 @@ export function Session() { const label = ring.name ? ring.name : `${ring.handle}@${ring.node}`; incoming.push(
- +
{ label }
actions.ignore(ring)} className="ringing-ignore">
actions.decline(ring)} className="ringing-decline">
@@ -86,6 +86,7 @@ export function Session() { } }; remote.current.srcObject = state.remoteStream; + remote.current.play(); } else { console.log("video player not set"); @@ -95,6 +96,7 @@ export function Session() { useEffect(() => { if (local.current) { local.current.srcObject = state.localStream; + local.current.play(); } }, [state.localStream]); @@ -325,19 +327,19 @@ export function Session() { { !state.remoteVideo && ( - + )} { state.remoteStream && ( -