ToTa
ToTa

Reputation: 3334

How to change Webrtc rtcpMuxPolicy?

I am trying to change rtcpMuxPolicy and also the bundlePolicy, but it seems like it cannot be changed

This is my code:

Attempt 1:

var servers = {
    'iceServers': [{
        'urls': 'stun-url..'
    }, {
        'urls': 'stun-url-2..'
    }, {
        'urls': 'turn-url..',
        'credential': 'psw',
        'username': 'user'
    }],
    peerIdentity: [{bundlePolicy: 'max-bundle', rtcpMuxPolicy: 'negotiate'}]//added this line
};

var pc;
var sendChannel;

navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);

pc = new RTCPeerConnection(servers);

Attempt 2:

var servers = {
        'iceServers': [{
            'urls': 'stun-url..'
        }, {
            'urls': 'stun-url-2..'
        }, {
            'urls': 'turn-url..',
            'credential': 'psw',
            'username': 'user'
        }]
    };

    var pc;
    var sendChannel;

    navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia);

    pc = new RTCPeerConnection(servers);
    pc.setConfiguration([{bundlePolicy: 'max-bundle', rtcpMuxPolicy: 'negotiate'}]);

With both examples, I am still seeing the default values:

pc.getConfiguration()

bundlePolicy: "balanced"
rtcpMuxPolicy: "require"

And I can notice only one change and that is, the iceServers array is empty, but bundlePolicy, and rtcpMuxPolicy are still the default.

I have WebRtc web solution that communicates with an Android application and everything works perfectly when streaming video, the problem occurs when I add dataChannel i.e.

sendChannel = pc.createDataChannel('sendDataChannel');

After adding the above line in my web solution, the android throws an error saying:

setSDP error: Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to setup RTCP mux filter..

Upvotes: 2

Views: 1666

Answers (1)

jib
jib

Reputation: 42430

First off, remove peerIdentity: [{ and }]. Only iceServers expects an array. The syntax is:

const pc = new RTCPeerConnection({
  iceServers: [{urls: 'stun-url..'}, {urls: 'stun-url-2..'}],
  bundlePolicy: 'max-bundle', // add this line
  rtcpMuxPolicy: 'negotiate'  // and this one
});
pc.setConfiguration({bundlePolicy: 'max-bundle', rtcpMuxPolicy: 'negotiate'});

Secondly, note that even though some browsers support rtcpMuxPolicy, the feature the 'negotiate' value controls is marked "Feature at risk" in the specification, so setting this value is most likely not supported.

The spec says: "the user agent MAY not implement non-multiplexed RTCP, in which case it will reject attempts to construct an RTCPeerConnection with the negotiate policy."

Upvotes: 1

Related Questions