浏览代码

Use unified plan for mobile browsers on iOS

All browsers on iOS use WebKit engine so they use the Unified Plan.
dev1
Jordan Owens 4 年前
父节点
当前提交
840302192a
共有 1 个文件被更改,包括 19 次插入7 次删除
  1. 19
    7
      modules/browser/BrowserCapabilities.js

+ 19
- 7
modules/browser/BrowserCapabilities.js 查看文件

64
             || this.isOpera();
64
             || this.isOpera();
65
     }
65
     }
66
 
66
 
67
+    /**
68
+     * Checks if the current browser is WebKit based. It's either
69
+     * Safari or uses WebKit as its engine.
70
+     *
71
+     * This includes Chrome and Firefox on iOS
72
+     *
73
+     * @returns {boolean}
74
+     */
75
+    isWebKitBased() {
76
+        // https://trac.webkit.org/changeset/236144/webkit/trunk/LayoutTests/webrtc/video-addLegacyTransceiver.html
77
+        return this._bowser.isEngine('webkit')
78
+            && typeof navigator.mediaDevices !== 'undefined'
79
+            && typeof navigator.mediaDevices.getUserMedia !== 'undefined'
80
+            && typeof window.RTCRtpTransceiver !== 'undefined'
81
+            // eslint-disable-next-line no-undef
82
+            && Object.keys(RTCRtpTransceiver.prototype).indexOf('currentDirection') > -1;
83
+    }
84
+
67
     /**
85
     /**
68
      * Checks whether current running context is a Trusted Web Application.
86
      * Checks whether current running context is a Trusted Web Application.
69
      *
87
      *
208
      * @returns {boolean}
226
      * @returns {boolean}
209
      */
227
      */
210
     usesUnifiedPlan() {
228
     usesUnifiedPlan() {
211
-        if (this.isFirefox()) {
229
+        if (this.isFirefox() || this.isWebKitBased()) {
212
             return true;
230
             return true;
213
         }
231
         }
214
 
232
 
215
-        if (this.isSafari() && typeof window.RTCRtpTransceiver !== 'undefined') {
216
-            // https://trac.webkit.org/changeset/236144/webkit/trunk/LayoutTests/webrtc/video-addLegacyTransceiver.html
217
-            // eslint-disable-next-line no-undef
218
-            return Object.keys(RTCRtpTransceiver.prototype).indexOf('currentDirection') > -1;
219
-        }
220
-
221
         return false;
233
         return false;
222
     }
234
     }
223
 
235
 

正在加载...
取消
保存