Browse Source

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 years ago
parent
commit
cf1305bdd2
1 changed files with 16 additions and 2 deletions
  1. 16
    2
      modules/browser/BrowserCapabilities.js

+ 16
- 2
modules/browser/BrowserCapabilities.js View File

281
      * @returns {boolean} {@code true} if the browser supports insertable streams.
281
      * @returns {boolean} {@code true} if the browser supports insertable streams.
282
      */
282
      */
283
     supportsInsertableStreams() {
283
     supportsInsertableStreams() {
284
-        return Boolean(typeof window.RTCRtpSender !== 'undefined'
284
+        if (!(typeof window.RTCRtpSender !== 'undefined'
285
             && (window.RTCRtpSender.prototype.createEncodedStreams
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…
Cancel
Save