Skip to content

Commit

Permalink
fix RTCPeerConnection.prototype.addTrack by adding MediaStream if not…
Browse files Browse the repository at this point in the history
… available and prevent webrtc-adapter to overide getLocalStreams with bad SHAM
  • Loading branch information
hthetiot committed Nov 5, 2019
1 parent f77f8fd commit 0eeb642
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/RTCPeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 0eeb642

Please sign in to comment.