MenuMenu

RTCMultiConnection.CodecsHandler

Allows you manage audio/video codecs e.g. vp8, vp9, h264, opus, isac, G722 etc

Disable Video NACK

<script src="/dev/CodecsHandler.js"></script>
<script>
// in your HTML file
connection.processSdp = function(sdp) {
    // Disable NACK to test IDR recovery
    sdp = CodecsHandler.disableNACK(sdp);
    return sdp;
};
</script>

Description

parameterdescription
CodecsHandler.disableNACK Disable video NACK
CodecsHandler.removeVPX Remove both vp8 and vp9 codecs
CodecsHandler.prioritize Prioritize any "existing" codec e.g. ask Chrome to use vp8 instead of vp9 etc.
CodecsHandler.removeNonG722 Remove all audio codecs except G722
CodecsHandler.preferVP9 Ask Chrome to use vp9 all the time
CodecsHandler.setApplicationSpecificBandwidth Set "AS=kbps"
1) first parameter is "sdp" string
2) second parameter is "bandwidth" object {audio: 50, video: 100}
3) last parameter is "isScreen" boolean; which forces 300kbps minimum video bitrates
CodecsHandler.setVideoBitrates 1) first parameter is "sdp" string
2) last parameter is {min: bitrates, max: bitrates}
CodecsHandler.setOpusAttributes 1) first parameter is "sdp" string
2) last parameter accepts all following:
{
    'stereo': 1,
    'sprop-stereo': 1,
    'maxaveragebitrate': connection.bandwidth.audio * 1000 * 8,
    'maxplaybackrate': connection.bandwidth.audio * 1000 * 8,
    'cbr': 1,
    'useinbandfec': 1,
    'usedtx': 1,
    'maxptime': 3
}

Prioritize Codecs

<script src="/dev/CodecsHandler.js"></script>
<script>
// in your HTML file
if(connection.DetectRTC.browser.name === 'Firefox') {
    connection.getAllParticipants().forEach(function(p) {
        var peer = connection.peers[p].peer;

        CodecsHandler.prioritize('audio/opus', peer);
    });
}
</script>

Wanna use H264 for video?

connection.codecs.video = 'H264';

Wanna use VP8 for video?

connection.codecs.video = 'VP8';

Wanna use VP9 for video?

connection.codecs.video = 'VP9';

Wanna use G722 for audio?

connection.codecs.audio = 'G722';

Wanna use opus for audio?

connection.codecs.audio = 'opus';

Demo

<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script>

<script>
var connection = new RTCMultiConnection();

// this line is VERY_important
connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';

// if you want audio+video conferencing
connection.session = {
    audio: true,
    video: true
};

connection.openOrJoin('your-room-id');
</script>

<script src="/dev/CodecsHandler.js"></script>
<script>
// in your HTML file
connection.processSdp = function(sdp) {
    // Disable NACK to test IDR recovery
    sdp = CodecsHandler.disableNACK(sdp);
    return sdp;
};
</script>