浏览代码

e2ee: detect transferable streams

Since we use transferable streams to transfer the streams to the worker
we need to feature detect them as Chrome 86 will launch Insertable Streams
by default without shipping transferable streams yet (status still unclear,
it might still ship too)

See here for the feature detection used:
  https://groups.google.com/a/chromium.org/g/blink-dev/c/1LStSgBt6AM/m/hj0odB8pCAAJ
dev1
Philipp Hancke 5 年前
父节点
当前提交
cf1305bdd2
共有 1 个文件被更改,包括 16 次插入2 次删除
  1. 16
    2
      modules/browser/BrowserCapabilities.js

+ 16
- 2
modules/browser/BrowserCapabilities.js 查看文件

@@ -281,9 +281,23 @@ export default class BrowserCapabilities extends BrowserDetection {
281 281
      * @returns {boolean} {@code true} if the browser supports insertable streams.
282 282
      */
283 283
     supportsInsertableStreams() {
284
-        return Boolean(typeof window.RTCRtpSender !== 'undefined'
284
+        if (!(typeof window.RTCRtpSender !== 'undefined'
285 285
             && (window.RTCRtpSender.prototype.createEncodedStreams
286
-                || window.RTCRtpSender.prototype.createEncodedVideoStreams));
286
+                || window.RTCRtpSender.prototype.createEncodedVideoStreams))) {
287
+            return false;
288
+        }
289
+
290
+        // Feature-detect transferable streams which we need to operate in a worker.
291
+        // See https://groups.google.com/a/chromium.org/g/blink-dev/c/1LStSgBt6AM/m/hj0odB8pCAAJ
292
+        const stream = new ReadableStream();
293
+
294
+        try {
295
+            window.postMessage(stream, '*', [ stream ]);
296
+
297
+            return true;
298
+        } catch {
299
+            return false;
300
+        }
287 301
     }
288 302
 
289 303
     /**

正在加载...
取消
保存