From 0eeb642f956aad760828c583e0a4664484f9ad85 Mon Sep 17 00:00:00 2001 From: Harold Thetiot Date: Tue, 5 Nov 2019 10:23:37 +0100 Subject: [PATCH] fix RTCPeerConnection.prototype.addTrack by adding MediaStream if not available and prevent webrtc-adapter to overide getLocalStreams with bad SHAM --- js/RTCPeerConnection.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/RTCPeerConnection.js b/js/RTCPeerConnection.js index 4ffea3e4..d6b8e767 100644 --- a/js/RTCPeerConnection.js +++ b/js/RTCPeerConnection.js @@ -48,6 +48,7 @@ function RTCPeerConnection(pcConfig, pcConstraints) { // Fix webrtc-adapter bad SHIM on addTrack causing error when original does support multiple streams. // NotSupportedError: The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track. Object.defineProperty(this, 'addTrack', RTCPeerConnection.prototype_descriptor.addTrack); + Object.defineProperty(this, 'getLocalStreams', RTCPeerConnection.prototype_descriptor.getLocalStreams); // Public atributes. this._localDescription = null; @@ -419,6 +420,8 @@ RTCPeerConnection.prototype.addTrack = function (track, stream) { } // Add localStreams if missing + stream = stream || Object.values(this.localStreams)[0] || new MediaStream(); + // Fix webrtc-adapter bad SHIM on addStream if (stream) { if (!(stream instanceof MediaStream.originalMediaStream)) {