should be working once again with proper media stream id and everything

This commit is contained in:
talksik
2022-04-28 16:37:09 -05:00
parent f68b551a43
commit 3f350bc09f
2 changed files with 19 additions and 16 deletions
+2
View File
@@ -49,6 +49,8 @@ async function handleJoin(req: Request, res: Response) {
console.log(`hacking around small problem with adding track`, e);
}
peer.addTransceiver("video");
// allow this peer connection to receive other peoples' streams
peer.ontrack = (e: any) => handleStreams(e, peer, lineId);
+17 -16
View File
@@ -40,15 +40,13 @@ export default function VideoChat() {
peer.onconnectionstatechange = console.log;
// todo: understand this better
peer.addTransceiver("video");
// peer.addTransceiver("video", { streams: [localMediaStream] });
peer.onnegotiationneeded = () => console.log("negotiation needed");
peer.onicecandidate = console.warn;
const localMediaStream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: false,
});
console.log("localMediaStream", localMediaStream);
console.log(`tracks: `, localMediaStream.getTracks());
setLocalMediaStream(localMediaStream);
@@ -66,20 +64,10 @@ export default function VideoChat() {
});
}
peer.addTransceiver("video");
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
const offer = await peer.createOffer();
await peer.setLocalDescription(offer);
@@ -97,12 +85,23 @@ export default function VideoChat() {
const desc = new RTCSessionDescription(data.data.sdp);
peer.setRemoteDescription(desc).catch((e) => console.log(e));
peer.ontrack = handleTrackEvent;
console.log(
`done handling negotiation with media server | remote description: `,
desc
);
console.log(peer);
return peer;
};
const handleNegotiationNeededEvent = async (
peer: RTCPeerConnection,
lineId: string
) => {};
// render tracks on the server peer sending something
// todo: memoize the line so that we can show user where stream is coming from
const handleTrackEvent = (e: any) => {
@@ -164,6 +163,8 @@ export default function VideoChat() {
controls
/>
<script src="https://meet.jit.si/external_api.js"></script>
<h1 className="text-3xl mt-10">Select a Line</h1>
{lines.map((lineId) => (
<a