JSFiddle - React, Tailwind, and code Playground
by henbos
JavaScript
// Copy of fippo's https://jsfiddle.net/fippo/Lrdj4mwu/2/
// with getStats added
const sdp = `v=0
o=- 0 3 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=fingerprint:sha-256 A7:24:72:CA:6E:02:55:39:BA:66:DF:6E:CC:4C:D8:B0:1A:BF:1A:56:65:7D:F4:03:AD:7E:77:43:2A:29:EC:93
a=ice-ufrag:ETEn
a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l
m=audio 9 UDP/TLS/RTP/SAVPF 111
c=IN IP4 0.0.0.0
a=rtcp-mux
a=sendonly
a=mid:0
a=rtpmap:111 opus/48000/2
a=fmtp:111 useinbandfec=0
a=setup:actpass
m=audio 9 UDP/TLS/RTP/SAVPF 111
c=IN IP4 0.0.0.0
a=rtcp-mux
a=sendonly
a=mid:1
a=rtpmap:111 opus/48000/2
a=fmtp:111 useinbandfec=1
a=setup:actpass
`;
const pc = new RTCPeerConnection();
async function run() {
await pc.setRemoteDescription({type: 'offer', sdp});
await pc.setLocalDescription();
const report = await pc.getStats();
for (const stats of report.values()) {
if (stats.type != 'codec')
continue;
console.log(JSON.stringify(stats, null, 2));
}
}
run();