JSFiddle - React, Tailwind, and code Playground

by fippo

HTML

<script src="https://wpt.live/webrtc/third_party/sdp/sdp.js"></script>

JavaScript

const rtpConstraints = { optional: [{ RtpDataChannels: true}]};
const pc = new RTCPeerConnection({}, rtpConstraints);
pc.createDataChannel('rtp-data-channel-must-die');
pc.createOffer({offerToReceiveAudio: true, offerToReceiveVideo: true})
  .then(offer => {
    const {sdp} = offer;
    const sections = SDPUtils.getMediaSections(sdp);
    const payloadTypes = sections
      .map(section => SDPUtils.parseMLine(section).fmt)
      .join(' ')
      .split(' ')
      .map(x => parseInt(x, 10))
      .sort((a, b) => a - b)
      .filter(x => x >= 96);
    console.log(payloadTypes);
  });