(window)
| 2350 | } |
| 2351 | |
| 2352 | function shimRemoteStreamsAPI(window) { |
| 2353 | if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) !== 'object' || !window.RTCPeerConnection) { |
| 2354 | return; |
| 2355 | } |
| 2356 | if (!('getRemoteStreams' in window.RTCPeerConnection.prototype)) { |
| 2357 | window.RTCPeerConnection.prototype.getRemoteStreams = function getRemoteStreams() { |
| 2358 | return this._remoteStreams ? this._remoteStreams : []; |
| 2359 | }; |
| 2360 | } |
| 2361 | if (!('onaddstream' in window.RTCPeerConnection.prototype)) { |
| 2362 | Object.defineProperty(window.RTCPeerConnection.prototype, 'onaddstream', { |
| 2363 | get: function get() { |
| 2364 | return this._onaddstream; |
| 2365 | }, |
| 2366 | set: function set(f) { |
| 2367 | var _this3 = this; |
| 2368 | |
| 2369 | if (this._onaddstream) { |
| 2370 | this.removeEventListener('addstream', this._onaddstream); |
| 2371 | this.removeEventListener('track', this._onaddstreampoly); |
| 2372 | } |
| 2373 | this.addEventListener('addstream', this._onaddstream = f); |
| 2374 | this.addEventListener('track', this._onaddstreampoly = function (e) { |
| 2375 | e.streams.forEach(function (stream) { |
| 2376 | if (!_this3._remoteStreams) { |
| 2377 | _this3._remoteStreams = []; |
| 2378 | } |
| 2379 | if (_this3._remoteStreams.includes(stream)) { |
| 2380 | return; |
| 2381 | } |
| 2382 | _this3._remoteStreams.push(stream); |
| 2383 | var event = new Event('addstream'); |
| 2384 | event.stream = stream; |
| 2385 | _this3.dispatchEvent(event); |
| 2386 | }); |
| 2387 | }); |
| 2388 | } |
| 2389 | }); |
| 2390 | var origSetRemoteDescription = window.RTCPeerConnection.prototype.setRemoteDescription; |
| 2391 | window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription() { |
| 2392 | var pc = this; |
| 2393 | if (!this._onaddstreampoly) { |
| 2394 | this.addEventListener('track', this._onaddstreampoly = function (e) { |
| 2395 | e.streams.forEach(function (stream) { |
| 2396 | if (!pc._remoteStreams) { |
| 2397 | pc._remoteStreams = []; |
| 2398 | } |
| 2399 | if (pc._remoteStreams.indexOf(stream) >= 0) { |
| 2400 | return; |
| 2401 | } |
| 2402 | pc._remoteStreams.push(stream); |
| 2403 | var event = new Event('addstream'); |
| 2404 | event.stream = stream; |
| 2405 | pc.dispatchEvent(event); |
| 2406 | }); |
| 2407 | }); |
| 2408 | } |
| 2409 | return origSetRemoteDescription.apply(pc, arguments); |
nothing calls this directly
no outgoing calls
no test coverage detected