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.
This commit is contained in:
Saúl Ibarra Corretgé 2022-12-16 10:24:25 +01:00 committed by Saúl Ibarra Corretgé
parent 294d2c9f6e
commit d3d442e4d2
1 changed files with 6 additions and 38 deletions

View File

@ -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