1
votes

I wish to send two video streams (one video stream and one stream captured from the canvas HTML element) using only one RTCPeerConnection.

What I tried to do is addTrack both tracks to the peer connection object before making the offer, but it doesn't work in Firefox (it works in Chrome). The peerConnection.ontrack event only happens once, with the first track added to the peer connection object (although there are two streams).

I have read about renegotiation, but I am currently adding both tracks to the peer connection before sending the offer so I don't know if I need to do renegotiation. Do I need to?

I have also heard about the interoperability issue in multistreaming between Firefox (Unified Plan) and Chrome (Plan B), so please advise me on what approach I should take now.

I am using adapter.js.

Add code (actually javascript):

function createPeerConnection() {
    peerConnection = new RTCPeerConnection(iceServers);

    peerConnection.onicecandidate = (event) => {
        if (event.candidate) {
            // send to server
        }
    };

    videoStream.getTracks().forEach(track => peerConnection.addTrack(track, videoStream));
    canvasStream.getTracks().forEach(track => peerConnection.addTrack(track, canvasStream));
}

This is how I create the RTCPeerConnection and add the tracks. After this part is creating the offer and sending to signaling server... It all works well, it's just that the other end only receives the first track added (in Firefox). If you need those bits I will add them.

This is the ontrack event handler.

    peerConnection.ontrack = (event) => {
        console.log(event); //only prints the first track in Firefox, but prints both tracks in Chrome
    };
1
Hi! I know it is cumbersome, but could you show us a stripped down version of the code? Maybe on the way towards that you will fix the problem by yourself. It happened to me several times... :wink:wigy
I have added some code! Please tell me if you need more or a different part.Ryehl
Did you solve this issue?IR_IR

1 Answers

3
votes

Try enabling unified plan support in Chrome. This is still work in progress and behind a flag (enable experimental web platform features on chrome://flags). Then you need to construct your RTCPeerConnection with new RTCPeerConnection({sdpSemantics: 'unified-plan'})