should be working once again with proper media stream id and everything
This commit is contained in:
@@ -49,6 +49,8 @@ async function handleJoin(req: Request, res: Response) {
|
|||||||
console.log(`hacking around small problem with adding track`, e);
|
console.log(`hacking around small problem with adding track`, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peer.addTransceiver("video");
|
||||||
|
|
||||||
// allow this peer connection to receive other peoples' streams
|
// allow this peer connection to receive other peoples' streams
|
||||||
peer.ontrack = (e: any) => handleStreams(e, peer, lineId);
|
peer.ontrack = (e: any) => handleStreams(e, peer, lineId);
|
||||||
|
|
||||||
|
|||||||
@@ -40,15 +40,13 @@ export default function VideoChat() {
|
|||||||
|
|
||||||
peer.onconnectionstatechange = console.log;
|
peer.onconnectionstatechange = console.log;
|
||||||
|
|
||||||
// todo: understand this better
|
peer.onnegotiationneeded = () => console.log("negotiation needed");
|
||||||
peer.addTransceiver("video");
|
peer.onicecandidate = console.warn;
|
||||||
// peer.addTransceiver("video", { streams: [localMediaStream] });
|
|
||||||
|
|
||||||
const localMediaStream = await navigator.mediaDevices.getUserMedia({
|
const localMediaStream = await navigator.mediaDevices.getUserMedia({
|
||||||
video: true,
|
video: true,
|
||||||
audio: false,
|
audio: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("localMediaStream", localMediaStream);
|
console.log("localMediaStream", localMediaStream);
|
||||||
console.log(`tracks: `, localMediaStream.getTracks());
|
console.log(`tracks: `, localMediaStream.getTracks());
|
||||||
setLocalMediaStream(localMediaStream);
|
setLocalMediaStream(localMediaStream);
|
||||||
@@ -66,20 +64,10 @@ export default function VideoChat() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peer.addTransceiver("video");
|
||||||
|
|
||||||
console.log(peer.connectionState);
|
console.log(peer.connectionState);
|
||||||
|
|
||||||
peer.ontrack = handleTrackEvent;
|
|
||||||
peer.onnegotiationneeded = () => handleNegotiationNeededEvent(peer, lineId);
|
|
||||||
|
|
||||||
console.log(peer);
|
|
||||||
|
|
||||||
return peer;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleNegotiationNeededEvent = async (
|
|
||||||
peer: RTCPeerConnection,
|
|
||||||
lineId: string
|
|
||||||
) => {
|
|
||||||
// create offer
|
// create offer
|
||||||
const offer = await peer.createOffer();
|
const offer = await peer.createOffer();
|
||||||
await peer.setLocalDescription(offer);
|
await peer.setLocalDescription(offer);
|
||||||
@@ -97,12 +85,23 @@ export default function VideoChat() {
|
|||||||
const desc = new RTCSessionDescription(data.data.sdp);
|
const desc = new RTCSessionDescription(data.data.sdp);
|
||||||
peer.setRemoteDescription(desc).catch((e) => console.log(e));
|
peer.setRemoteDescription(desc).catch((e) => console.log(e));
|
||||||
|
|
||||||
|
peer.ontrack = handleTrackEvent;
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`done handling negotiation with media server | remote description: `,
|
`done handling negotiation with media server | remote description: `,
|
||||||
desc
|
desc
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(peer);
|
||||||
|
|
||||||
|
return peer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleNegotiationNeededEvent = async (
|
||||||
|
peer: RTCPeerConnection,
|
||||||
|
lineId: string
|
||||||
|
) => {};
|
||||||
|
|
||||||
// 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) => {
|
||||||
@@ -164,6 +163,8 @@ export default function VideoChat() {
|
|||||||
controls
|
controls
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<script src="https://meet.jit.si/external_api.js"></script>
|
||||||
|
|
||||||
<h1 className="text-3xl mt-10">Select a Line</h1>
|
<h1 className="text-3xl mt-10">Select a Line</h1>
|
||||||
{lines.map((lineId) => (
|
{lines.map((lineId) => (
|
||||||
<a
|
<a
|
||||||
|
|||||||
Reference in New Issue
Block a user