Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/utils/browserCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,29 @@
showError(unsupportedWarning, { timeout: TOAST_PERMANENT_TIMEOUT })
}
}

/**
* Check if the browser supports WebRTC Encoded Transform (i.e. Firefox).
*/
export function supportsEncodedTransform() {
return (window.RTCRtpScriptTransform && window.RTCRtpSender && 'transform' in RTCRtpSender.prototype)

Check failure on line 85 in src/utils/browserCheck.ts

View workflow job for this annotation

GitHub Actions / NPM typecheck

Property 'RTCRtpScriptTransform' does not exist on type 'Window & typeof globalThis'.
}

/**
* Check if the browser supports insertable streams (i.e. Chromium).
*/
export function supportsInsertableStreams() {
if (!(window.RTCRtpReceiver && 'createEncodedStreams' in RTCRtpReceiver.prototype && window.RTCRtpSender && 'createEncodedStreams' in RTCRtpSender.prototype)) {
return false
}

// Feature-detect transferable streams which we need to operate in a worker.
// See https://groups.google.com/a/chromium.org/g/blink-dev/c/1LStSgBt6AM/m/hj0odB8pCAAJ
const stream = new ReadableStream()
try {
window.postMessage(stream, '*', [stream])
return true
} catch {
return false
}
}
9 changes: 2 additions & 7 deletions src/utils/e2ee/encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@ import Deferred from './JitsiDeferred.js'
import E2EEcontext from './JitsiE2EEContext.js'
import initializeOlm from './olm.js'
import { hasTalkFeature, getTalkConfig } from '../../services/CapabilitiesManager.ts'
import { supportsEncodedTransform, supportsInsertableStreams } from '../browserCheck.ts'
import Signaling from '../signaling.js'
import Peer from '../webrtc/simplewebrtc/peer.js'
import SimpleWebRTC from '../webrtc/simplewebrtc/simplewebrtc.js'

const supportsTransform
// Firefox
= (window.RTCRtpScriptTransform && window.RTCRtpSender && 'transform' in RTCRtpSender.prototype)
// Chrome
|| (window.RTCRtpReceiver && 'createEncodedStreams' in RTCRtpReceiver.prototype && window.RTCRtpSender && 'createEncodedStreams' in RTCRtpSender.prototype)

// Period which we'll wait before updating / rotating our keys when a participant
// joins or leaves.
const DEBOUNCE_PERIOD = 5000
Expand All @@ -45,7 +40,7 @@ class Encryption {
* @async
*/
static async isSupported() {
if (!supportsTransform) {
if (!supportsEncodedTransform() && !supportsInsertableStreams()) {
throw new Error('stream transform is not supported')
}

Expand Down
5 changes: 5 additions & 0 deletions src/utils/webrtc/simplewebrtc/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import webrtcSupport from 'webrtcsupport'

import localMedia from './localmedia.js'
import Peer from './peer.js'
import { supportsInsertableStreams } from '../../browserCheck.ts'

/**
* @param {object} opts the options object.
Expand Down Expand Up @@ -37,6 +38,10 @@ export default function WebRTC(opts) {
}
let item

if (supportsInsertableStreams()) {
this.config.peerConnectionConfig.encodedInsertableStreams = true
}

// We also allow a 'logger' option. It can be any object that implements
// log, warn, and error methods.
// We log nothing by default, following "the rule of silence":
Expand Down
Loading