adding button in contact for calling

This commit is contained in:
Roland Osborne 2023-03-29 23:57:39 -07:00
parent 8b36cd0c2a
commit 3ff5ac6f14
3 changed files with 11 additions and 11 deletions

View File

@ -33,11 +33,6 @@ export function useRingContext() {
const audioTrack = useRef(); const audioTrack = useRef();
const iceServers = [ const iceServers = [
{
urls: 'stun:35.165.123.117:5001?transport=udp',
username: 'user',
credential: 'pass'
},
{ {
urls: 'turn:35.165.123.117:5001?transport=udp', urls: 'turn:35.165.123.117:5001?transport=udp',
username: 'user', username: 'user',
@ -174,6 +169,7 @@ export function useRingContext() {
ws.current.close(); ws.current.close();
} }
else if (signal.description) { else if (signal.description) {
console.log("NULL STREAM");
stream.current = null; stream.current = null;
if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') { if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') {
return; //rudely ignore return; //rudely ignore
@ -295,6 +291,7 @@ export function useRingContext() {
pc.current.ontrack = (ev) => { //{streams: [stream]}) => { pc.current.ontrack = (ev) => { //{streams: [stream]}) => {
console.log("ADD TRACK", ev); console.log("ADD TRACK", ev);
if (!stream.current) { if (!stream.current) {
console.log("NEW MEDIA!");
stream.current = new MediaStream(); stream.current = new MediaStream();
updateState({ remoteStream: stream.current }); updateState({ remoteStream: stream.current });
} }
@ -361,6 +358,8 @@ export function useRingContext() {
} }
} }
else if (signal.description) { else if (signal.description) {
console.log("NEW DESCRIPTION");
stream.current = null;
if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') { if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') {
await pc.current.setLocalDescription({ type: "rollback" }); await pc.current.setLocalDescription({ type: "rollback" });
} }

View File

@ -80,12 +80,18 @@ export function Session() {
setCallHeight(height); setCallHeight(height);
setCallWidth(videoWidth * (height / videoHeight)); setCallWidth(videoWidth * (height / videoHeight));
} }
else if (videoHeight < 256 || videoWidth < 256) {
setCallHeight(256);
setCallWidth(256);
}
else { else {
setCallHeight(videoHeight); setCallHeight(videoHeight);
setCallWidth(videoWidth); setCallWidth(videoWidth);
} }
}; };
console.log(" SET REMOTE STREAM");
remote.current.srcObject = state.remoteStream; remote.current.srcObject = state.remoteStream;
remote.current.load();
remote.current.play(); remote.current.play();
} }
else { else {

View File

@ -9,10 +9,6 @@ export function Contact({ close, guid, listing }) {
const [ modal, modalContext ] = Modal.useModal(); const [ modal, modalContext ] = Modal.useModal();
const { state, actions } = useContact(guid, listing, close); const { state, actions } = useContact(guid, listing, close);
const ring = async () => {
actions.ring();
};
const updateContact = async (action) => { const updateContact = async (action) => {
try { try {
await action(); await action();
@ -98,6 +94,7 @@ export function Contact({ close, guid, listing }) {
<div className="controls"> <div className="controls">
<div className={ state.buttonStatus } onClick={() => updateContact(actions.disconnect)}>Disconnect</div> <div className={ state.buttonStatus } onClick={() => updateContact(actions.disconnect)}>Disconnect</div>
<div className={ state.buttonStatus } onClick={() => updateContact(actions.disconnectRemove)}>Delete Contact</div> <div className={ state.buttonStatus } onClick={() => updateContact(actions.disconnectRemove)}>Delete Contact</div>
<div className={ state.buttonStatus } onClick={actions.ring}>Call Contact</div>
</div> </div>
)} )}
@ -137,8 +134,6 @@ export function Contact({ close, guid, listing }) {
</div> </div>
)} )}
<div className={ state.buttonStatus } onClick={ring}>RING</div>
</div> </div>
</div> </div>