I
I
impressive172021-07-02 00:01:43
JavaScript
impressive17, 2021-07-02 00:01:43

How to send a webRTC track to JS?

Tell me, please, I'm trying to broadcast video from the browser to the server via webRTC.
It seems that it was possible to establish a connection between the front (js) and the server (go) via webRTC. Implemented all the way with installing sdp and iceCandidate. But I do not really understand how to understand whether the connection has been established.
On the server there is an ontrack handler (in the lib that I use there). On js, I'm trying to add a track to peerConnection, but it says that it already exists and there really is a webcam, but nothing comes to the server in the handler.

navigator.mediaDevices.getUserMedia({ video: true, audio: true })
        .then(stream => {
            localVideo.srcObject = stream;
            stream.getTracks().forEach(track => localPeerConnection.addTrack(track));
            localPeerConnection.createOffer().then(createdOffer).catch(setSessionDescriptionError)
        }).catch(log);

Please tell me at what point and how to add a track for transmission to the server?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question