ソースを参照

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
     /**

読み込み中…
キャンセル
保存