forked from react-native-webrtc/react-native-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (38 loc) · 1.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
import RTCPeerConnection from './RTCPeerConnection';
import RTCIceCandidate from './RTCIceCandidate';
import RTCSessionDescription from './RTCSessionDescription';
import RTCView from './RTCView';
import MediaStream from './MediaStream';
import MediaStreamTrack from './MediaStreamTrack';
import mediaDevices from './MediaDevices';
import permissions from './Permissions';
export {
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
mediaDevices,
permissions,
registerGlobals
};
function registerGlobals() {
// Should not happen. React Native has a global navigator object.
if (typeof navigator !== 'object') {
throw new Error('navigator is not an object');
}
if (!navigator.mediaDevices) {
navigator.mediaDevices = {};
}
navigator.mediaDevices.getUserMedia =
mediaDevices.getUserMedia.bind(mediaDevices);
navigator.mediaDevices.enumerateDevices =
mediaDevices.enumerateDevices.bind(mediaDevices);
global.RTCPeerConnection = RTCPeerConnection;
global.RTCIceCandidate = RTCIceCandidate;
global.RTCSessionDescription = RTCSessionDescription;
global.MediaStream = MediaStream;
global.MediaStreamTrack = MediaStreamTrack;
}