2

I want to use my own stream when I do a renegotiation. The standard way is to pass the media parameter to the createOffer function. In this case, Janus handles the getUserMedia request.

    async switchCamera() {



       this.videoCall.createOffer({


            media: {
                replaceVideo: true
            },

            success: (jsep) => {
                this.videoCall.send({message: {request:"set"}, "jsep": jsep});
            },

            error: (e) => {
                alert(e);
            }
        });






    }

In my case, I want to do it by myself. I've created the following function:

    async switchCamera() {


        cameraHelper.switchCamera(); // Sets facing mode
        this.localStream = await cameraHelper.requestMedia(); // Returns media stream




       this.videoCall.createOffer({

            stream: this.localStream,

            success: (jsep) => {
                this.videoCall.send({message: {request:"set"}, "jsep": jsep});
            },

            error: (e) => {
                alert(e);
            }
        });






    }

If I call the switchCamera function, Chrome crashes on the receivers side. The last error message before the crash is the following one:

Uncaught DOMException: Failed to execute 'addTrack' on 'RTCPeerConnection': A sender already exists for the track.

Do I have to execute some other functions before I can add a new stream?

user2891491
  • 351
  • 8
  • 16

0 Answers0