1

I am developing a voice chat application. After the server receives an RTP packet from a client, it sends this packet unmodified to all the other clients. Each client has a different SSRC.

The following code works (i.e. all audio streams received from server are played correctly):

function join_vc(offer){
    const rtc_conn = new RTCPeerConnection({
        bundlePolicy: 'max-compat'
    })

    rtc_conn.ontrack = (ev) => {
        const vc_audio = $("#vc_audio")[0]
        vc_audio.srcObject = ev.streams[0]
        vc_audio.play()
    }

    rtc_conn.onicegatheringstatechange = (state) => {
        if(rtc_conn.iceGatheringState === "complete"){
            const answer = rtc_conn.localDescription
            vc_sock.send(JSON.stringify(answer))
        }
    }

    await rtc_conn.setRemoteDescription(offer)

    const media = await navigator.mediaDevices.getUserMedia({audio: true})
    console.log("tracks", await navigator.mediaDevices.enumerateDevices())
    media.getTracks().forEach(track => {rtc_conn.addTrack(track, media)})

    const answer = await rtc_conn.createAnswer()
    await rtc_conn.setLocalDescription(answer)

}

However, the streams are played as one, and I couldn't find a way to separate them. The RTCPeerConnection instance has a single RTCReceiver, which has a single RTCTransport.

Is there a way to separate multiplexed streams (to enable client-side muting / volume adjustment) by SSRCs using WebRTC API? Re-negotiating all RTCPeerConnections whenever a new participant joins a voice channel seems expensive; keeping separate connections is even more expensive (O(N^2)).

I tried using transformers, but they are not available for Chrome.

2
  • by using a single m= line you are specifically asking for everything to be mixed together (and I doubt that scales). If you know the ssrcs you can do local renegotiation adding separate m= lines which will give you a separate track Commented Apr 29 at 0:42
  • @PhilippHancke I see. So re-negotiation is necessary then. But I guess otherwise streams cannot be separated. Commented Apr 29 at 19:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.