瀏覽代碼

Abstracts unified and plan B checks.

master
Boris Grozev 9 年之前
父節點
當前提交
cb7ff545b6
共有 2 個檔案被更改,包括 20 行新增11 行删除
  1. 9
    0
      modules/RTC/RTCBrowserType.js
  2. 11
    11
      modules/xmpp/TraceablePeerConnection.js

+ 9
- 0
modules/RTC/RTCBrowserType.js 查看文件

@@ -46,6 +46,15 @@ var RTCBrowserType = {
46 46
 
47 47
     getChromeVersion: function () {
48 48
         return RTCBrowserType.isChrome() ? browserVersion : null;
49
+    },
50
+
51
+    usesPlanB: function() {
52
+        return RTCBrowserType.isChrome() || RTCBrowserType.isOpera()
53
+            || RTCBrowserType.isTemasysPluginUsed();
54
+    },
55
+
56
+    usesUnifiedPlan: function() {
57
+        return RTCBrowserType.isFirefox();
49 58
     }
50 59
 
51 60
     // Add version getters for other browsers when needed

+ 11
- 11
modules/xmpp/TraceablePeerConnection.js 查看文件

@@ -90,7 +90,8 @@ function TraceablePeerConnection(ice_config, constraints, session) {
90 90
             self.ondatachannel(event);
91 91
         }
92 92
     };
93
-    if (!navigator.mozGetUserMedia && this.maxstats) {
93
+    // XXX: do all non-firefox browsers which we support also support this?
94
+    if (!RTCBrowserType.isFirefox() && this.maxstats) {
94 95
         this.statsinterval = window.setInterval(function() {
95 96
             self.peerconnection.getStats(function(stats) {
96 97
                 var results = stats.result();
@@ -138,7 +139,7 @@ if (TraceablePeerConnection.prototype.__defineGetter__ !== undefined) {
138 139
         this.trace('getLocalDescription::preTransform', dumpSDP(desc));
139 140
 
140 141
         // if we're running on FF, transform to Plan B first.
141
-        if (navigator.mozGetUserMedia) {
142
+        if (RTCBrowserType.usesUnifiedPlan()) {
142 143
             desc = this.interop.toPlanB(desc);
143 144
             this.trace('getLocalDescription::postTransform (Plan B)', dumpSDP(desc));
144 145
         }
@@ -149,7 +150,7 @@ if (TraceablePeerConnection.prototype.__defineGetter__ !== undefined) {
149 150
         this.trace('getRemoteDescription::preTransform', dumpSDP(desc));
150 151
 
151 152
         // if we're running on FF, transform to Plan B first.
152
-        if (navigator.mozGetUserMedia) {
153
+        if (RTCBrowserType.usesUnifiedPlan()) {
153 154
             desc = this.interop.toPlanB(desc);
154 155
             this.trace('getRemoteDescription::postTransform (Plan B)', dumpSDP(desc));
155 156
         }
@@ -207,7 +208,7 @@ TraceablePeerConnection.prototype.createDataChannel = function (label, opts) {
207 208
 TraceablePeerConnection.prototype.setLocalDescription = function (description, successCallback, failureCallback) {
208 209
     this.trace('setLocalDescription::preTransform', dumpSDP(description));
209 210
     // if we're running on FF, transform to Plan A first.
210
-    if (navigator.mozGetUserMedia) {
211
+    if (RTCBrowserType.usesUnifiedPlan()) {
211 212
         description = this.interop.toUnifiedPlan(description);
212 213
         this.trace('setLocalDescription::postTransform (Plan A)', dumpSDP(description));
213 214
     }
@@ -237,7 +238,7 @@ TraceablePeerConnection.prototype.setRemoteDescription = function (description,
237 238
     this.trace('setRemoteDescription::postTransform (simulcast)', dumpSDP(description));
238 239
 
239 240
     // if we're running on FF, transform to Plan A first.
240
-    if (navigator.mozGetUserMedia) {
241
+    if (RTCBrowserType.usesUnifiedPlan()) {
241 242
         description = this.interop.toUnifiedPlan(description);
242 243
         this.trace('setRemoteDescription::postTransform (Plan A)', dumpSDP(description));
243 244
     }
@@ -277,7 +278,7 @@ TraceablePeerConnection.prototype.createOffer = function (successCallback, failu
277 278
             // if we're running on FF, transform to Plan B first.
278 279
             // NOTE this is not tested because in meet the focus generates the
279 280
             // offer.
280
-            if (navigator.mozGetUserMedia) {
281
+            if (RTCBrowserType.usesUnifiedPlan()) {
281 282
                 offer = self.interop.toPlanB(offer);
282 283
                 self.trace('createOfferOnSuccess::postTransform (Plan B)', dumpSDP(offer));
283 284
             }
@@ -303,7 +304,7 @@ TraceablePeerConnection.prototype.createAnswer = function (successCallback, fail
303 304
         function (answer) {
304 305
             self.trace('createAnswerOnSuccess::preTransfom', dumpSDP(answer));
305 306
             // if we're running on FF, transform to Plan A first.
306
-            if (navigator.mozGetUserMedia) {
307
+            if (RTCBrowserType.usesUnifiedPlan()) {
307 308
                 answer = self.interop.toPlanB(answer);
308 309
                 self.trace('createAnswerOnSuccess::postTransfom (Plan B)', dumpSDP(answer));
309 310
             }
@@ -340,12 +341,11 @@ TraceablePeerConnection.prototype.addIceCandidate = function (candidate, success
340 341
 };
341 342
 
342 343
 TraceablePeerConnection.prototype.getStats = function(callback, errback) {
343
-    if (navigator.mozGetUserMedia) {
344
+    // TODO: Is this the correct way to handle Opera, Temasys?
345
+    if (RTCBrowserType.isFirefox()) {
344 346
         // ignore for now...
345 347
         if(!errback)
346
-            errback = function () {
347
-
348
-            }
348
+            errback = function () {};
349 349
         this.peerconnection.getStats(null,callback,errback);
350 350
     } else {
351 351
         this.peerconnection.getStats(callback);

Loading…
取消
儲存