UNPKG

simple-webrtc-element-whep

Version:
461 lines 24.3 kB
'use strict'; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _MediaMTXWebRTCReader_instances, _a, _MediaMTXWebRTCReader_supportsNonAdvertisedCodec, _MediaMTXWebRTCReader_unquoteCredential, _MediaMTXWebRTCReader_linkToIceServers, _MediaMTXWebRTCReader_parseOffer, _MediaMTXWebRTCReader_reservePayloadType, _MediaMTXWebRTCReader_enableStereoPcmau, _MediaMTXWebRTCReader_enableMultichannelOpus, _MediaMTXWebRTCReader_enableL16, _MediaMTXWebRTCReader_enableStereoOpus, _MediaMTXWebRTCReader_editOffer, _MediaMTXWebRTCReader_generateSdpFragment, _MediaMTXWebRTCReader_handleError, _MediaMTXWebRTCReader_getNonAdvertisedCodecs, _MediaMTXWebRTCReader_start, _MediaMTXWebRTCReader_authHeader, _MediaMTXWebRTCReader_requestICEServers, _MediaMTXWebRTCReader_setupPeerConnection, _MediaMTXWebRTCReader_sendOffer, _MediaMTXWebRTCReader_setAnswer, _MediaMTXWebRTCReader_onLocalCandidate, _MediaMTXWebRTCReader_sendLocalCandidates, _MediaMTXWebRTCReader_onConnectionState, _MediaMTXWebRTCReader_onTrack; /** WebRTC/WHEP reader. */ export class MediaMTXWebRTCReader { /** * Create a MediaMTXWebRTCReader. * @param conf - configuration. */ constructor(conf) { _MediaMTXWebRTCReader_instances.add(this); this.retryPause = 2000; this.state = 'getting_codecs'; this.restartTimeout = null; this.pc = null; this.offerData = null; this.sessionUrl = null; this.queuedCandidates = []; this.nonAdvertisedCodecs = []; this.conf = conf; __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_getNonAdvertisedCodecs).call(this); } /** * Close the reader and all its resources. */ close() { this.state = 'closed'; if (this.pc !== null) { this.pc.close(); } if (this.restartTimeout !== null) { clearTimeout(this.restartTimeout); } } } _a = MediaMTXWebRTCReader, _MediaMTXWebRTCReader_instances = new WeakSet(), _MediaMTXWebRTCReader_supportsNonAdvertisedCodec = function _MediaMTXWebRTCReader_supportsNonAdvertisedCodec(codec, fmtp) { return new Promise(resolve => { const pc = new RTCPeerConnection({ iceServers: [] }); const mediaType = 'audio'; let payloadType = ''; pc.addTransceiver(mediaType, { direction: 'recvonly' }); pc.createOffer() .then(offer => { if (offer.sdp === undefined) { throw new Error('SDP not present'); } if (offer.sdp.includes(` ${codec}`)) { // codec is advertised, there's no need to add it manually throw new Error('already present'); } const sections = offer.sdp.split(`m=${mediaType}`); const payloadTypes = sections .slice(1) .map(s => s.split('\r\n')[0].split(' ').slice(3)) .reduce((prev, cur) => [...prev, ...cur], []); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); const lines = sections[1].split('\r\n'); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} ${codec}`); if (fmtp !== undefined) { lines.splice(lines.length - 1, 0, `a=fmtp:${payloadType} ${fmtp}`); } sections[1] = lines.join('\r\n'); offer.sdp = sections.join(`m=${mediaType}`); return pc.setLocalDescription(offer); }) .then(() => pc.setRemoteDescription(new RTCSessionDescription({ type: 'answer', sdp: 'v=0\r\n' + 'o=- 6539324223450680508 0 IN IP4 0.0.0.0\r\n' + 's=-\r\n' + 't=0 0\r\n' + 'a=fingerprint:sha-256 0D:9F:78:15:42:B5:4B:E6:E2:94:3E:5B:37:78:E1:4B:54:59:A3:36:3A:E5:05:EB:27:EE:8F:D2:2D:41:29:25\r\n' + `m=${mediaType} 9 UDP/TLS/RTP/SAVPF ${payloadType}\r\n` + 'c=IN IP4 0.0.0.0\r\n' + 'a=ice-pwd:7c3bf4770007e7432ee4ea4d697db675\r\n' + 'a=ice-ufrag:29e036dc\r\n' + 'a=sendonly\r\n' + 'a=rtcp-mux\r\n' + `a=rtpmap:${payloadType} ${codec}\r\n` + (fmtp !== undefined ? `a=fmtp:${payloadType} ${fmtp}\r\n` : '') }))) .then(() => { resolve(true); }) .catch(() => { resolve(false); }) .finally(() => { pc.close(); }); }); }, _MediaMTXWebRTCReader_unquoteCredential = function _MediaMTXWebRTCReader_unquoteCredential(v) { return JSON.parse(`"${v}"`); }, _MediaMTXWebRTCReader_linkToIceServers = function _MediaMTXWebRTCReader_linkToIceServers(links) { return links !== null ? links.split(', ').map((link) => { const m = link.match(/^<(.+?)>; rel="ice-server"(; username="(.*?)"; credential="(.*?)"; credential-type="password")?/i); const ret = { urls: [m[1]] }; if (m[3] !== undefined) { ret.username = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_unquoteCredential).call(this, m[3]); ret.credential = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_unquoteCredential).call(this, m[4]); ret.credentialType = 'password'; } return ret; }) : []; }, _MediaMTXWebRTCReader_parseOffer = function _MediaMTXWebRTCReader_parseOffer(sdp) { const ret = { iceUfrag: '', icePwd: '', medias: [] }; for (const line of sdp.split('\r\n')) { if (line.startsWith('m=')) { ret.medias.push(line.slice('m='.length)); } else if (ret.iceUfrag === '' && line.startsWith('a=ice-ufrag:')) { ret.iceUfrag = line.slice('a=ice-ufrag:'.length); } else if (ret.icePwd === '' && line.startsWith('a=ice-pwd:')) { ret.icePwd = line.slice('a=ice-pwd:'.length); } } return ret; }, _MediaMTXWebRTCReader_reservePayloadType = function _MediaMTXWebRTCReader_reservePayloadType(payloadTypes) { // everything is valid between 30 and 127, except for interval between 64 and 95 // https://chromium.googlesource.com/external/webrtc/+/refs/heads/master/call/payload_type.h#29 for (let i = 30; i <= 127; i++) { if ((i <= 63 || i >= 96) && !payloadTypes.includes(i.toString())) { const pl = i.toString(); payloadTypes.push(pl); return pl; } } throw Error('unable to find a free payload type'); }, _MediaMTXWebRTCReader_enableStereoPcmau = function _MediaMTXWebRTCReader_enableStereoPcmau(payloadTypes, section) { const lines = section.split('\r\n'); let payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} PCMU/8000/2`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} PCMA/8000/2`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); return lines.join('\r\n'); }, _MediaMTXWebRTCReader_enableMultichannelOpus = function _MediaMTXWebRTCReader_enableMultichannelOpus(payloadTypes, section) { const lines = section.split('\r\n'); let payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} multiopus/48000/3`); lines.splice(lines.length - 1, 0, `a=fmtp:${payloadType} channel_mapping=0,2,1;num_streams=2;coupled_streams=1`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} multiopus/48000/4`); lines.splice(lines.length - 1, 0, `a=fmtp:${payloadType} channel_mapping=0,1,2,3;num_streams=2;coupled_streams=2`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} multiopus/48000/5`); lines.splice(lines.length - 1, 0, `a=fmtp:${payloadType} channel_mapping=0,4,1,2,3;num_streams=3;coupled_streams=2`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} multiopus/48000/6`); lines.splice(lines.length - 1, 0, `a=fmtp:${payloadType} channel_mapping=0,4,1,2,3,5;num_streams=4;coupled_streams=2`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} multiopus/48000/7`); lines.splice(lines.length - 1, 0, `a=fmtp:${payloadType} channel_mapping=0,4,1,2,3,5,6;num_streams=4;coupled_streams=4`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} multiopus/48000/8`); lines.splice(lines.length - 1, 0, `a=fmtp:${payloadType} channel_mapping=0,6,1,4,5,2,3,7;num_streams=5;coupled_streams=4`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); return lines.join('\r\n'); }, _MediaMTXWebRTCReader_enableL16 = function _MediaMTXWebRTCReader_enableL16(payloadTypes, section) { const lines = section.split('\r\n'); let payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} L16/8000/2`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} L16/16000/2`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); payloadType = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_reservePayloadType).call(this, payloadTypes); lines[0] += ` ${payloadType}`; lines.splice(lines.length - 1, 0, `a=rtpmap:${payloadType} L16/48000/2`); lines.splice(lines.length - 1, 0, `a=rtcp-fb:${payloadType} transport-cc`); return lines.join('\r\n'); }, _MediaMTXWebRTCReader_enableStereoOpus = function _MediaMTXWebRTCReader_enableStereoOpus(section) { let opusPayloadFormat = ''; const lines = section.split('\r\n'); for (let i = 0; i < lines.length; i++) { if (lines[i].startsWith('a=rtpmap:') && lines[i].toLowerCase().includes('opus/')) { opusPayloadFormat = lines[i].slice('a=rtpmap:'.length).split(' ')[0]; break; } } if (opusPayloadFormat === '') { return section; } for (let i = 0; i < lines.length; i++) { if (lines[i].startsWith(`a=fmtp:${opusPayloadFormat} `)) { if (!lines[i].includes('stereo')) { lines[i] += ';stereo=1'; } if (!lines[i].includes('sprop-stereo')) { lines[i] += ';sprop-stereo=1'; } } } return lines.join('\r\n'); }, _MediaMTXWebRTCReader_editOffer = function _MediaMTXWebRTCReader_editOffer(sdp, nonAdvertisedCodecs) { const sections = sdp.split('m='); const payloadTypes = sections .slice(1) .map(s => s.split('\r\n')[0].split(' ').slice(3)) .reduce((prev, cur) => [...prev, ...cur], []); for (let i = 1; i < sections.length; i++) { if (sections[i].startsWith('audio')) { sections[i] = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_enableStereoOpus).call(this, sections[i]); if (nonAdvertisedCodecs.includes('pcma/8000/2')) { sections[i] = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_enableStereoPcmau).call(this, payloadTypes, sections[i]); } if (nonAdvertisedCodecs.includes('multiopus/48000/6')) { sections[i] = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_enableMultichannelOpus).call(this, payloadTypes, sections[i]); } if (nonAdvertisedCodecs.includes('L16/48000/2')) { sections[i] = __classPrivateFieldGet(this, _a, "m", _MediaMTXWebRTCReader_enableL16).call(this, payloadTypes, sections[i]); } break; } } return sections.join('m='); }, _MediaMTXWebRTCReader_generateSdpFragment = function _MediaMTXWebRTCReader_generateSdpFragment(od, candidates) { const candidatesByMedia = {}; for (const candidate of candidates) { const mid = candidate.sdpMLineIndex; if (mid !== null && candidatesByMedia[mid] === undefined) { candidatesByMedia[mid] = []; } if (mid !== null) { candidatesByMedia[mid].push(candidate); } } let frag = `a=ice-ufrag:${od.iceUfrag}\r\n` + `a=ice-pwd:${od.icePwd}\r\n`; let mid = 0; for (const media of od.medias) { if (candidatesByMedia[mid] !== undefined) { frag += `m=${media}\r\n` + `a=mid:${mid}\r\n`; for (const candidate of candidatesByMedia[mid]) { frag += `a=${candidate.candidate}\r\n`; } } mid++; } return frag; }, _MediaMTXWebRTCReader_handleError = function _MediaMTXWebRTCReader_handleError(err) { if (this.state === 'running') { if (this.pc !== null) { this.pc.close(); this.pc = null; } this.offerData = null; if (this.sessionUrl !== null) { fetch(this.sessionUrl, { method: 'DELETE' }); this.sessionUrl = null; } this.queuedCandidates = []; this.state = 'restarting'; this.restartTimeout = window.setTimeout(() => { this.restartTimeout = null; this.state = 'running'; __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_start).call(this); }, this.retryPause); if (this.conf.onError !== undefined) { this.conf.onError(`${err}, retrying in some seconds`); } } else if (this.state === 'getting_codecs') { this.state = 'failed'; if (this.conf.onError !== undefined) { this.conf.onError(err); } } }, _MediaMTXWebRTCReader_getNonAdvertisedCodecs = function _MediaMTXWebRTCReader_getNonAdvertisedCodecs() { Promise.all([ ['pcma/8000/2'], ['multiopus/48000/6', 'channel_mapping=0,4,1,2,3,5;num_streams=4;coupled_streams=2'], ['L16/48000/2'] ].map(c => __classPrivateFieldGet(MediaMTXWebRTCReader, _a, "m", _MediaMTXWebRTCReader_supportsNonAdvertisedCodec).call(MediaMTXWebRTCReader, c[0], c[1]).then(r => (r ? c[0] : false)))) .then(c => c.filter((e) => e !== false)) .then(codecs => { if (this.state !== 'getting_codecs') { throw new Error('closed'); } this.nonAdvertisedCodecs = codecs; this.state = 'running'; __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_start).call(this); }) .catch(err => { __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_handleError).call(this, err); }); }, _MediaMTXWebRTCReader_start = function _MediaMTXWebRTCReader_start() { __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_requestICEServers).call(this) .then(iceServers => __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_setupPeerConnection).call(this, iceServers)) .then(offer => __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_sendOffer).call(this, offer)) .then(answer => __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_setAnswer).call(this, answer)) .catch(err => { __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_handleError).call(this, err.toString()); }); }, _MediaMTXWebRTCReader_authHeader = function _MediaMTXWebRTCReader_authHeader() { if (this.conf.user !== undefined && this.conf.user !== '') { const credentials = btoa(`${this.conf.user}:${this.conf.pass}`); return { Authorization: `Basic ${credentials}` }; } if (this.conf.token !== undefined && this.conf.token !== '') { return { Authorization: `Bearer ${this.conf.token}` }; } return {}; }, _MediaMTXWebRTCReader_requestICEServers = function _MediaMTXWebRTCReader_requestICEServers() { return fetch(this.conf.url, { method: 'OPTIONS', headers: __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_authHeader).call(this) }).then(res => __classPrivateFieldGet(MediaMTXWebRTCReader, _a, "m", _MediaMTXWebRTCReader_linkToIceServers).call(MediaMTXWebRTCReader, res.headers.get('Link'))); }, _MediaMTXWebRTCReader_setupPeerConnection = function _MediaMTXWebRTCReader_setupPeerConnection(iceServers) { if (this.state !== 'running') { throw new Error('closed'); } this.pc = new RTCPeerConnection({ iceServers }); const direction = 'recvonly'; this.pc.addTransceiver('video', { direction }); this.pc.addTransceiver('audio', { direction }); this.pc.onicecandidate = evt => __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_onLocalCandidate).call(this, evt); this.pc.onconnectionstatechange = () => __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_onConnectionState).call(this); this.pc.ontrack = evt => __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_onTrack).call(this, evt); return this.pc.createOffer().then(offer => { if (!offer.sdp) { throw new Error('SDP not present'); } offer.sdp = __classPrivateFieldGet(MediaMTXWebRTCReader, _a, "m", _MediaMTXWebRTCReader_editOffer).call(MediaMTXWebRTCReader, offer.sdp, this.nonAdvertisedCodecs); this.offerData = __classPrivateFieldGet(MediaMTXWebRTCReader, _a, "m", _MediaMTXWebRTCReader_parseOffer).call(MediaMTXWebRTCReader, offer.sdp); return this.pc.setLocalDescription(offer).then(() => offer.sdp); }); }, _MediaMTXWebRTCReader_sendOffer = function _MediaMTXWebRTCReader_sendOffer(offer) { if (this.state !== 'running') { throw new Error('closed'); } return fetch(this.conf.url, { method: 'POST', headers: { ...__classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_authHeader).call(this), 'Content-Type': 'application/sdp' }, body: offer }).then(res => { switch (res.status) { case 201: break; case 404: throw new Error('stream not found'); case 400: return res.json().then(e => { throw new Error(e.error); }); default: throw new Error(`bad status code ${res.status}`); } const location = res.headers.get('location'); if (!location) { throw new Error('No location header in response'); } this.sessionUrl = new URL(location, this.conf.url).toString(); return res.text(); }); }, _MediaMTXWebRTCReader_setAnswer = function _MediaMTXWebRTCReader_setAnswer(answer) { if (this.state !== 'running') { throw new Error('closed'); } return this.pc.setRemoteDescription(new RTCSessionDescription({ type: 'answer', sdp: answer })).then(() => { if (this.state !== 'running') { return; } if (this.queuedCandidates.length !== 0) { __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_sendLocalCandidates).call(this, this.queuedCandidates); this.queuedCandidates = []; } }); }, _MediaMTXWebRTCReader_onLocalCandidate = function _MediaMTXWebRTCReader_onLocalCandidate(evt) { if (this.state !== 'running') { return; } if (evt.candidate !== null) { if (this.sessionUrl === null) { this.queuedCandidates.push(evt.candidate); } else { __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_sendLocalCandidates).call(this, [evt.candidate]); } } }, _MediaMTXWebRTCReader_sendLocalCandidates = function _MediaMTXWebRTCReader_sendLocalCandidates(candidates) { if (!this.sessionUrl) { throw new Error('Session URL not available'); } fetch(this.sessionUrl, { method: 'PATCH', headers: { 'Content-Type': 'application/trickle-ice-sdpfrag', 'If-Match': '*' }, body: __classPrivateFieldGet(MediaMTXWebRTCReader, _a, "m", _MediaMTXWebRTCReader_generateSdpFragment).call(MediaMTXWebRTCReader, this.offerData, candidates) }) .then(res => { switch (res.status) { case 204: break; case 404: throw new Error('stream not found'); default: throw new Error(`bad status code ${res.status}`); } }) .catch(err => { __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_handleError).call(this, err.toString()); }); }, _MediaMTXWebRTCReader_onConnectionState = function _MediaMTXWebRTCReader_onConnectionState() { if (this.state !== 'running') { return; } // "closed" can arrive before "failed" and without // the close() method being called at all. // It happens when the other peer sends a termination // message like a DTLS CloseNotify. if (this.pc && (this.pc.connectionState === 'failed' || this.pc.connectionState === 'closed')) { __classPrivateFieldGet(this, _MediaMTXWebRTCReader_instances, "m", _MediaMTXWebRTCReader_handleError).call(this, 'peer connection closed'); } }, _MediaMTXWebRTCReader_onTrack = function _MediaMTXWebRTCReader_onTrack(evt) { if (this.conf.onTrack !== undefined) { this.conf.onTrack(evt); } }; //# sourceMappingURL=index.js.map