Преглед изворни кода

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

Loading…
Откажи
Сачувај