trying bunch of shit
This commit is contained in:
@@ -27,12 +27,14 @@ async function handleJoin(req: Request, res: Response) {
|
|||||||
|
|
||||||
const peer = new webrtc.RTCPeerConnection({
|
const peer = new webrtc.RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [
|
||||||
{
|
{ urls: "stun:stun.stunprotocol.org:3478" },
|
||||||
urls: "stun:stun.stunprotocol.org",
|
{ urls: "stun:stun.l.google.com:19302" },
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// allow this peer connection to receive other peoples' streams
|
||||||
|
peer.ontrack = (e: any) => handleStreams(e, peer, lineId);
|
||||||
|
|
||||||
// now that remote is set
|
// now that remote is set
|
||||||
// allow this peer connection for this specific line to get tracks for this line already
|
// allow this peer connection for this specific line to get tracks for this line already
|
||||||
try {
|
try {
|
||||||
@@ -50,9 +52,7 @@ async function handleJoin(req: Request, res: Response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
peer.addTransceiver("video");
|
peer.addTransceiver("video");
|
||||||
|
peer.addTransceiver("audio");
|
||||||
// allow this peer connection to receive other peoples' streams
|
|
||||||
peer.ontrack = (e: any) => handleStreams(e, peer, lineId);
|
|
||||||
|
|
||||||
// create connection between server and client who hit this endpoint
|
// create connection between server and client who hit this endpoint
|
||||||
const desc = new webrtc.RTCSessionDescription(sdp);
|
const desc = new webrtc.RTCSessionDescription(sdp);
|
||||||
|
|||||||
@@ -32,9 +32,8 @@ export default function VideoChat() {
|
|||||||
const createPeer = async (lineId: string) => {
|
const createPeer = async (lineId: string) => {
|
||||||
const peer = new RTCPeerConnection({
|
const peer = new RTCPeerConnection({
|
||||||
iceServers: [
|
iceServers: [
|
||||||
{
|
{ urls: "stun:stun.stunprotocol.org:3478" },
|
||||||
urls: "stun:stun.stunprotocol.org",
|
{ urls: "stun:stun.l.google.com:19302" },
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ export default function VideoChat() {
|
|||||||
|
|
||||||
const localMediaStream = await navigator.mediaDevices.getUserMedia({
|
const localMediaStream = await navigator.mediaDevices.getUserMedia({
|
||||||
video: true,
|
video: true,
|
||||||
audio: false,
|
audio: true,
|
||||||
});
|
});
|
||||||
console.log("localMediaStream", localMediaStream);
|
console.log("localMediaStream", localMediaStream);
|
||||||
console.log(`tracks: `, localMediaStream.getTracks());
|
console.log(`tracks: `, localMediaStream.getTracks());
|
||||||
@@ -65,12 +64,17 @@ export default function VideoChat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
peer.addTransceiver("video");
|
peer.addTransceiver("video");
|
||||||
|
peer.addTransceiver("audio");
|
||||||
|
|
||||||
|
console.log(peer.getReceivers());
|
||||||
console.log(peer.getSenders());
|
console.log(peer.getSenders());
|
||||||
|
|
||||||
const remoteStream = new MediaStream([peer.getSenders()[0].track!]);
|
const remoteStream = new MediaStream([
|
||||||
|
peer.getSenders()[0].track!,
|
||||||
|
peer.getSenders()[1].track!,
|
||||||
|
]);
|
||||||
|
|
||||||
incomingVideoRef.current!.srcObject = remoteStream;
|
// incomingVideoRef.current!.srcObject = remoteStream;
|
||||||
|
|
||||||
console.log(peer.connectionState);
|
console.log(peer.connectionState);
|
||||||
|
|
||||||
@@ -111,22 +115,26 @@ export default function VideoChat() {
|
|||||||
// render tracks on the server peer sending something
|
// render tracks on the server peer sending something
|
||||||
// todo: memoize the line so that we can show user where stream is coming from
|
// todo: memoize the line so that we can show user where stream is coming from
|
||||||
const handleTrackEvent = (e: any) => {
|
const handleTrackEvent = (e: any) => {
|
||||||
const incomingStream = e.streams[0];
|
console.log(e);
|
||||||
|
|
||||||
console.log("incoming stream", incomingStream);
|
const incomingStream = e.streams[0] as MediaStream;
|
||||||
|
|
||||||
// if (incomingVideoRef.current) {
|
console.log("incoming stream", incomingStream.getTracks());
|
||||||
// toast(`setting incoming stream ref`);
|
|
||||||
// incomingVideoRef.current.srcObject = new MediaStream(incomingStream);
|
|
||||||
|
|
||||||
// setInterval(() => {
|
if (incomingVideoRef.current) {
|
||||||
// incomingVideoRef!.current!.play().then(console.log).catch(console.log);
|
toast(`setting incoming stream ref`);
|
||||||
// }, 2000);
|
incomingVideoRef.current.srcObject = new MediaStream([
|
||||||
|
e.transceiver.sender.track,
|
||||||
|
]);
|
||||||
|
|
||||||
// incomingVideoRef.current.oncanplay = () =>
|
incomingVideoRef.current.oncanplay = () => {
|
||||||
// console.log("cannn PLLLAYY VID!!!!");
|
console.log("cannn PLLLAYY VID!!!!");
|
||||||
// incomingVideoRef.current.play().then(console.log).catch(console.log);
|
|
||||||
// }
|
incomingVideoRef.current.play().then(console.log).catch(console.error);
|
||||||
|
};
|
||||||
|
|
||||||
|
incomingVideoRef.current.play().then(console.log).catch(console.error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -153,9 +161,9 @@ export default function VideoChat() {
|
|||||||
<video
|
<video
|
||||||
ref={videoRef}
|
ref={videoRef}
|
||||||
id={"userVideo"}
|
id={"userVideo"}
|
||||||
|
height={"500"}
|
||||||
|
width={"700"}
|
||||||
muted
|
muted
|
||||||
height={"300"}
|
|
||||||
width={"300"}
|
|
||||||
autoPlay
|
autoPlay
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -165,7 +173,6 @@ export default function VideoChat() {
|
|||||||
height={"500"}
|
height={"500"}
|
||||||
width={"700"}
|
width={"700"}
|
||||||
autoPlay
|
autoPlay
|
||||||
muted
|
|
||||||
controls
|
controls
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user