From d3d442e4d2230191f312ec12449c0aa9b9050e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 16 Dec 2022 10:24:25 +0100 Subject: [PATCH] fix(rn,polyfills) simplify WebRTC polyfills Use the polyfiller provided by react-native-webrtc. Drop the permissions API polyfill since we no longer use it in the app and lib-jitsi-meet already works without it. --- react/features/mobile/polyfills/webrtc.js | 44 ++++------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/react/features/mobile/polyfills/webrtc.js b/react/features/mobile/polyfills/webrtc.js index 2186f03a7..41721ed94 100644 --- a/react/features/mobile/polyfills/webrtc.js +++ b/react/features/mobile/polyfills/webrtc.js @@ -1,43 +1,11 @@ -import { - MediaStream, - MediaStreamTrack, - RTCIceCandidate, - RTCSessionDescription, - mediaDevices, - permissions -} from 'react-native-webrtc'; +import { registerGlobals } from 'react-native-webrtc'; import RTCPeerConnection from './RTCPeerConnection'; +registerGlobals(); + (global => { - if (typeof global.MediaStream === 'undefined') { - global.MediaStream = MediaStream; - } - if (typeof global.MediaStreamTrack === 'undefined') { - global.MediaStreamTrack = MediaStreamTrack; - } - if (typeof global.RTCIceCandidate === 'undefined') { - global.RTCIceCandidate = RTCIceCandidate; - } - if (typeof global.RTCPeerConnection === 'undefined') { - global.RTCPeerConnection = RTCPeerConnection; - } - if (typeof global.RTCPeerConnection === 'undefined') { - global.webkitRTCPeerConnection = RTCPeerConnection; - } - if (typeof global.RTCSessionDescription === 'undefined') { - global.RTCSessionDescription = RTCSessionDescription; - } - - const navigator = global.navigator; - - if (navigator) { - if (typeof navigator.mediaDevices === 'undefined') { - navigator.mediaDevices = mediaDevices; - } - if (typeof navigator.permissions === 'undefined') { - navigator.permissions = permissions; - } - } - + // Override with ours. + // TODO: consider dropping our override. + global.RTCPeerConnection = RTCPeerConnection; })(global || window || this); // eslint-disable-line no-invalid-this