From a52f9fd955614ee961be6d5576d51a3b1dd858b9 Mon Sep 17 00:00:00 2001 From: Lance Stout <lancestout@gmail.com> Date: Thu, 2 Mar 2017 19:23:49 -0800 Subject: [PATCH] Prevent exception when used with React Native Turns out that the RTCPeerConnection shim in React Native does not expose a `getLocalStreams` method, so trying to make a bound proxy would blow up. --- rtcpeerconnection.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rtcpeerconnection.js b/rtcpeerconnection.js index 92f7096..6390785 100644 --- a/rtcpeerconnection.js +++ b/rtcpeerconnection.js @@ -114,7 +114,14 @@ function PeerConnection(config, constraints) { this.pc = new RTCPeerConnection(config, constraints); - this.getLocalStreams = this.pc.getLocalStreams.bind(this.pc); + if (this.pc.getLocalStreams) { + this.getLocalStreams = this.pc.getLocalStreams.bind(this.pc); + } else { + this.getLocalStreams = function () { + return []; + }; + } + this.getRemoteStreams = this.pc.getRemoteStreams.bind(this.pc); this.addStream = this.pc.addStream.bind(this.pc); -- GitLab