Browse Source

tpc: use the peerconnection type constructor from RTCUtils

Avoids having to do browser checks twice.

Fixes: #423
dev1
Saúl Ibarra Corretgé 8 years ago
parent
commit
11865ba1f7
2 changed files with 9 additions and 21 deletions
  1. 5
    5
      modules/RTC/RTCUtils.js
  2. 4
    16
      modules/RTC/TraceablePeerConnection.js

+ 5
- 5
modules/RTC/RTCUtils.js View File

@@ -746,7 +746,7 @@ class RTCUtils extends Listenable {
746 746
 
747 747
                     return;
748 748
                 }
749
-                this.peerconnection = mozRTCPeerConnection;
749
+                this.RTCPeerConnectionType = mozRTCPeerConnection;
750 750
                 this.getUserMedia
751 751
                     = wrapGetUserMedia(
752 752
                         navigator.mozGetUserMedia.bind(navigator));
@@ -800,7 +800,7 @@ class RTCUtils extends Listenable {
800 800
                     || RTCBrowserType.isElectron()
801 801
                     || RTCBrowserType.isReactNative()) {
802 802
 
803
-                this.peerconnection = webkitRTCPeerConnection;
803
+                this.RTCPeerConnectionType = webkitRTCPeerConnection;
804 804
                 const getUserMedia
805 805
                     = navigator.webkitGetUserMedia.bind(navigator);
806 806
 
@@ -875,8 +875,8 @@ class RTCUtils extends Listenable {
875 875
 
876 876
                 // TODO: Uncomment when done. For now use the Edge native
877 877
                 // RTCPeerConnection.
878
-                // this.peerconnection = ortcRTCPeerConnection;
879
-                this.peerconnection = RTCPeerConnection;
878
+                // this.RTCPeerConnectionType = ortcRTCPeerConnection;
879
+                this.RTCPeerConnectionType = RTCPeerConnection;
880 880
                 this.getUserMedia
881 881
                     = wrapGetUserMedia(
882 882
                         navigator.mediaDevices.getUserMedia.bind(
@@ -905,7 +905,7 @@ class RTCUtils extends Listenable {
905 905
             } else if (RTCBrowserType.isTemasysPluginUsed()) {
906 906
                 // Detect IE/Safari
907 907
                 const webRTCReadyCb = () => {
908
-                    this.peerconnection = RTCPeerConnection;
908
+                    this.RTCPeerConnectionType = RTCPeerConnection;
909 909
                     this.getUserMedia = window.getUserMedia;
910 910
                     this.enumerateDevices
911 911
                         = enumerateDevicesThroughMediaStreamTrack;

+ 4
- 16
modules/RTC/TraceablePeerConnection.js View File

@@ -1,5 +1,4 @@
1
-/* global __filename, mozRTCPeerConnection, webkitRTCPeerConnection,
2
-    RTCPeerConnection, RTCSessionDescription */
1
+/* global __filename, RTCSessionDescription */
3 2
 
4 3
 import { getLogger } from 'jitsi-meet-logger';
5 4
 import transform from 'sdp-transform';
@@ -9,6 +8,7 @@ import JitsiRemoteTrack from './JitsiRemoteTrack';
9 8
 import * as MediaType from '../../service/RTC/MediaType';
10 9
 import LocalSdpMunger from './LocalSdpMunger';
11 10
 import RTC from './RTC';
11
+import RTCUtils from './RTCUtils';
12 12
 import RTCBrowserType from './RTCBrowserType';
13 13
 import RTCEvents from '../../service/RTC/RTCEvents';
14 14
 import RtxModifier from '../xmpp/RtxModifier';
@@ -150,21 +150,9 @@ export default function TraceablePeerConnection(
150 150
         SignalingEvents.PEER_MUTED_CHANGED,
151 151
         this._peerMutedChanged);
152 152
     this.options = options;
153
-    let RTCPeerConnectionType = null;
154 153
 
155
-    if (RTCBrowserType.isFirefox()) {
156
-        RTCPeerConnectionType = mozRTCPeerConnection;
157
-    } else if (RTCBrowserType.isEdge()) {
158
-        // TODO: Uncomment when done. For now use the Edge native
159
-        // RTCPeerConnection.
160
-        // RTCPeerConnectionType = ortcRTCPeerConnection;
161
-        RTCPeerConnectionType = RTCPeerConnection;
162
-    } else if (RTCBrowserType.isTemasysPluginUsed()) {
163
-        RTCPeerConnectionType = RTCPeerConnection;
164
-    } else {
165
-        RTCPeerConnectionType = webkitRTCPeerConnection;
166
-    }
167
-    this.peerconnection = new RTCPeerConnectionType(iceConfig, constraints);
154
+    this.peerconnection
155
+        = new RTCUtils.RTCPeerConnectionType(iceConfig, constraints);
168 156
     this.updateLog = [];
169 157
     this.stats = {};
170 158
     this.statsinterval = null;

Loading…
Cancel
Save