JSFiddle - React, Tailwind, and code Playground
by fippo
JavaScript
async function run(include) {
const pc = new RTCPeerConnection();
let sdp = `v=0
o=- 0 3 IN IP4 127.0.0.1
s=-
t=0 0
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:6HHHdzzeIhkE0CKj
a=ice-pwd:XYDGVpfvklQIEnZ6YnyLsAew
m=audio 9 RTP/SAVPF 111
c=IN IP4 0.0.0.0
a=rtcp-mux
a=sendonly
a=mid:audio
a=rtpmap:111 opus/48000/2
a=setup:actpass
`;
if (include) {
sdp += `a=ssrc:1234 cname:something\r\n`;
}
await pc.setRemoteDescription({type: 'offer', sdp});
const stats = await pc.getStats();
console.log('include?', include, [...stats.values()].find(({type}) => type === 'inbound-rtp'));
}
run(true);
run(false);