react-native-webrtc 1.89.3 → 1.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +9 -0
- package/.prettierrc.json +10 -0
- package/README.md +4 -1
- package/android/libs/.placeholder +0 -0
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +0 -5
- package/android/src/main/java/com/oney/WebRTCModule/LibraryLoader.java +21 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +301 -324
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +9 -84
- package/apple/.placeholder +0 -0
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +3 -0
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +4 -1
- package/ios/RCTWebRTC/VideoCaptureController.h +2 -2
- package/ios/RCTWebRTC/VideoCaptureController.m +131 -48
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +56 -26
- package/metro.config.js +3 -4
- package/metro.config.macos.js +7 -8
- package/package.json +21 -12
- package/react-native.config.js +5 -6
- package/{EventEmitter.js → src/EventEmitter.js} +1 -1
- package/{MediaDevices.js → src/MediaDevices.js} +6 -12
- package/src/MediaStream.js +128 -0
- package/src/MediaStreamError.js +12 -0
- package/src/MediaStreamErrorEvent.js +11 -0
- package/src/MediaStreamEvent.js +11 -0
- package/src/MediaStreamTrack.js +104 -0
- package/src/MediaStreamTrackEvent.js +11 -0
- package/src/MessageEvent.js +10 -0
- package/{Permissions.js → src/Permissions.js} +26 -23
- package/src/RTCDataChannel.js +143 -0
- package/src/RTCDataChannelEvent.js +11 -0
- package/src/RTCEvent.js +8 -0
- package/src/RTCIceCandidate.js +20 -0
- package/src/RTCIceCandidateEvent.js +15 -0
- package/src/RTCPeerConnection.js +349 -0
- package/src/RTCSessionDescription.js +22 -0
- package/{RTCUtil.js → src/RTCUtil.js} +56 -57
- package/src/RTCView.js +60 -0
- package/src/ScreenCapturePickerView.js +4 -0
- package/{getDisplayMedia.js → src/getDisplayMedia.js} +8 -11
- package/src/getUserMedia.js +98 -0
- package/src/index.js +44 -0
- package/tools/build-webrtc.py +60 -46
- package/tools/downloadBitcode.sh +4 -16
- package/tools/downloadWebRTC.js +100 -0
- package/MediaStream.js +0 -138
- package/MediaStreamError.js +0 -14
- package/MediaStreamErrorEvent.js +0 -12
- package/MediaStreamEvent.js +0 -12
- package/MediaStreamTrack.js +0 -118
- package/MediaStreamTrackEvent.js +0 -12
- package/MessageEvent.js +0 -11
- package/RTCDataChannel.js +0 -161
- package/RTCDataChannelEvent.js +0 -12
- package/RTCEvent.js +0 -9
- package/RTCIceCandidate.js +0 -21
- package/RTCIceCandidateEvent.js +0 -16
- package/RTCPeerConnection.js +0 -390
- package/RTCSessionDescription.js +0 -23
- package/RTCView.js +0 -70
- package/ScreenCapturePickerView.js +0 -7
- package/android/libs/libjingle_peerconnection.so.jar +0 -0
- package/android/libs/libwebrtc.jar +0 -0
- package/apple/WebRTC.xcframework.tgz +0 -0
- package/getUserMedia.js +0 -98
- package/index.js +0 -47
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/RTCPeerConnection.js
DELETED
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import EventTarget from 'event-target-shim';
|
|
4
|
-
import { NativeModules } from 'react-native';
|
|
5
|
-
|
|
6
|
-
import MediaStream from './MediaStream';
|
|
7
|
-
import MediaStreamEvent from './MediaStreamEvent';
|
|
8
|
-
import MediaStreamTrack from './MediaStreamTrack';
|
|
9
|
-
import MediaStreamTrackEvent from './MediaStreamTrackEvent';
|
|
10
|
-
import RTCDataChannel from './RTCDataChannel';
|
|
11
|
-
import RTCDataChannelEvent from './RTCDataChannelEvent';
|
|
12
|
-
import RTCSessionDescription from './RTCSessionDescription';
|
|
13
|
-
import RTCIceCandidate from './RTCIceCandidate';
|
|
14
|
-
import RTCIceCandidateEvent from './RTCIceCandidateEvent';
|
|
15
|
-
import RTCEvent from './RTCEvent';
|
|
16
|
-
import * as RTCUtil from './RTCUtil';
|
|
17
|
-
import EventEmitter from './EventEmitter';
|
|
18
|
-
|
|
19
|
-
const { WebRTCModule } = NativeModules;
|
|
20
|
-
|
|
21
|
-
type RTCSignalingState =
|
|
22
|
-
'stable' |
|
|
23
|
-
'have-local-offer' |
|
|
24
|
-
'have-remote-offer' |
|
|
25
|
-
'have-local-pranswer' |
|
|
26
|
-
'have-remote-pranswer' |
|
|
27
|
-
'closed';
|
|
28
|
-
|
|
29
|
-
type RTCIceGatheringState =
|
|
30
|
-
'new' |
|
|
31
|
-
'gathering' |
|
|
32
|
-
'complete';
|
|
33
|
-
|
|
34
|
-
type RTCPeerConnectionState =
|
|
35
|
-
'new' |
|
|
36
|
-
'connecting' |
|
|
37
|
-
'connected' |
|
|
38
|
-
'disconnected' |
|
|
39
|
-
'failed' |
|
|
40
|
-
'closed';
|
|
41
|
-
|
|
42
|
-
type RTCIceConnectionState =
|
|
43
|
-
'new' |
|
|
44
|
-
'checking' |
|
|
45
|
-
'connected' |
|
|
46
|
-
'completed' |
|
|
47
|
-
'failed' |
|
|
48
|
-
'disconnected' |
|
|
49
|
-
'closed';
|
|
50
|
-
|
|
51
|
-
type RTCDataChannelInit = {
|
|
52
|
-
ordered?: boolean;
|
|
53
|
-
maxPacketLifeTime?: number;
|
|
54
|
-
maxRetransmits?: number;
|
|
55
|
-
protocol?: string;
|
|
56
|
-
negotiated?: boolean;
|
|
57
|
-
id?: number;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const PEER_CONNECTION_EVENTS = [
|
|
61
|
-
'connectionstatechange',
|
|
62
|
-
'icecandidate',
|
|
63
|
-
'icecandidateerror',
|
|
64
|
-
'iceconnectionstatechange',
|
|
65
|
-
'icegatheringstatechange',
|
|
66
|
-
'negotiationneeded',
|
|
67
|
-
'signalingstatechange',
|
|
68
|
-
// Peer-to-peer Data API:
|
|
69
|
-
'datachannel',
|
|
70
|
-
// old:
|
|
71
|
-
'addstream',
|
|
72
|
-
'removestream',
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
let nextPeerConnectionId = 0;
|
|
76
|
-
|
|
77
|
-
export default class RTCPeerConnection extends EventTarget(PEER_CONNECTION_EVENTS) {
|
|
78
|
-
localDescription: RTCSessionDescription;
|
|
79
|
-
remoteDescription: RTCSessionDescription;
|
|
80
|
-
|
|
81
|
-
signalingState: RTCSignalingState = 'stable';
|
|
82
|
-
iceGatheringState: RTCIceGatheringState = 'new';
|
|
83
|
-
connectionState: RTCPeerConnectionState = 'new';
|
|
84
|
-
iceConnectionState: RTCIceConnectionState = 'new';
|
|
85
|
-
|
|
86
|
-
onconnectionstatechange: ?Function;
|
|
87
|
-
onicecandidate: ?Function;
|
|
88
|
-
onicecandidateerror: ?Function;
|
|
89
|
-
oniceconnectionstatechange: ?Function;
|
|
90
|
-
onicegatheringstatechange: ?Function;
|
|
91
|
-
onnegotiationneeded: ?Function;
|
|
92
|
-
onsignalingstatechange: ?Function;
|
|
93
|
-
|
|
94
|
-
onaddstream: ?Function;
|
|
95
|
-
onremovestream: ?Function;
|
|
96
|
-
|
|
97
|
-
_peerConnectionId: number;
|
|
98
|
-
_localStreams: Array<MediaStream> = [];
|
|
99
|
-
_remoteStreams: Array<MediaStream> = [];
|
|
100
|
-
_subscriptions: Array<any>;
|
|
101
|
-
|
|
102
|
-
constructor(configuration) {
|
|
103
|
-
super();
|
|
104
|
-
this._peerConnectionId = nextPeerConnectionId++;
|
|
105
|
-
WebRTCModule.peerConnectionInit(configuration, this._peerConnectionId);
|
|
106
|
-
this._registerEvents();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
addStream(stream: MediaStream) {
|
|
110
|
-
const index = this._localStreams.indexOf(stream);
|
|
111
|
-
if (index !== -1) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
WebRTCModule.peerConnectionAddStream(stream._reactTag, this._peerConnectionId);
|
|
115
|
-
this._localStreams.push(stream);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
removeStream(stream: MediaStream) {
|
|
119
|
-
const index = this._localStreams.indexOf(stream);
|
|
120
|
-
if (index === -1) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
this._localStreams.splice(index, 1);
|
|
124
|
-
WebRTCModule.peerConnectionRemoveStream(stream._reactTag, this._peerConnectionId);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
createOffer(options) {
|
|
128
|
-
return new Promise((resolve, reject) => {
|
|
129
|
-
WebRTCModule.peerConnectionCreateOffer(
|
|
130
|
-
this._peerConnectionId,
|
|
131
|
-
RTCUtil.normalizeOfferAnswerOptions(options),
|
|
132
|
-
(successful, data) => {
|
|
133
|
-
if (successful) {
|
|
134
|
-
resolve(new RTCSessionDescription(data));
|
|
135
|
-
} else {
|
|
136
|
-
reject(data); // TODO: convert to NavigatorUserMediaError
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
createAnswer(options = {}) {
|
|
143
|
-
return new Promise((resolve, reject) => {
|
|
144
|
-
WebRTCModule.peerConnectionCreateAnswer(
|
|
145
|
-
this._peerConnectionId,
|
|
146
|
-
RTCUtil.normalizeOfferAnswerOptions(options),
|
|
147
|
-
(successful, data) => {
|
|
148
|
-
if (successful) {
|
|
149
|
-
resolve(new RTCSessionDescription(data));
|
|
150
|
-
} else {
|
|
151
|
-
reject(data);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
setConfiguration(configuration) {
|
|
158
|
-
WebRTCModule.peerConnectionSetConfiguration(configuration, this._peerConnectionId);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
setLocalDescription(sessionDescription: RTCSessionDescription) {
|
|
162
|
-
return new Promise((resolve, reject) => {
|
|
163
|
-
WebRTCModule.peerConnectionSetLocalDescription(
|
|
164
|
-
sessionDescription.toJSON ? sessionDescription.toJSON() : sessionDescription,
|
|
165
|
-
this._peerConnectionId,
|
|
166
|
-
(successful, data) => {
|
|
167
|
-
if (successful) {
|
|
168
|
-
this.localDescription = new RTCSessionDescription(data);
|
|
169
|
-
resolve();
|
|
170
|
-
} else {
|
|
171
|
-
reject(data);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
setRemoteDescription(sessionDescription: RTCSessionDescription) {
|
|
178
|
-
return new Promise((resolve, reject) => {
|
|
179
|
-
WebRTCModule.peerConnectionSetRemoteDescription(
|
|
180
|
-
sessionDescription.toJSON ? sessionDescription.toJSON() : sessionDescription,
|
|
181
|
-
this._peerConnectionId,
|
|
182
|
-
(successful, data) => {
|
|
183
|
-
if (successful) {
|
|
184
|
-
this.remoteDescription = new RTCSessionDescription(data);
|
|
185
|
-
resolve();
|
|
186
|
-
} else {
|
|
187
|
-
reject(data);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
addIceCandidate(candidate) {
|
|
194
|
-
if (!candidate || !candidate.candidate) {
|
|
195
|
-
// TODO: support end-of-candidates, native crashes at this time.
|
|
196
|
-
return Promise.resolve();
|
|
197
|
-
}
|
|
198
|
-
return new Promise((resolve, reject) => {
|
|
199
|
-
WebRTCModule.peerConnectionAddICECandidate(
|
|
200
|
-
candidate.toJSON ? candidate.toJSON() : candidate,
|
|
201
|
-
this._peerConnectionId,
|
|
202
|
-
(successful, data) => {
|
|
203
|
-
if (successful) {
|
|
204
|
-
this.remoteDescription = new RTCSessionDescription(data);
|
|
205
|
-
resolve();
|
|
206
|
-
} else {
|
|
207
|
-
// XXX: This should be OperationError
|
|
208
|
-
reject(new Error('Failed to add ICE candidate'));
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
getStats() {
|
|
215
|
-
return WebRTCModule.peerConnectionGetStats(this._peerConnectionId)
|
|
216
|
-
.then( data => {
|
|
217
|
-
/* On both Android and iOS it is faster to construct a single
|
|
218
|
-
JSON string representing the Map of StatsReports and have it
|
|
219
|
-
pass through the React Native bridge rather than the Map of
|
|
220
|
-
StatsReports. While the implementations do try to be faster in
|
|
221
|
-
general, the stress is on being faster to pass through the React
|
|
222
|
-
Native bridge which is a bottleneck that tends to be visible in
|
|
223
|
-
the UI when there is congestion involving UI-related passing.
|
|
224
|
-
|
|
225
|
-
TODO Implement the logic for filtering the stats based on
|
|
226
|
-
the sender/receiver
|
|
227
|
-
*/
|
|
228
|
-
return new Map(JSON.parse(data));
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
getLocalStreams() {
|
|
233
|
-
return this._localStreams.slice();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
getRemoteStreams() {
|
|
237
|
-
return this._remoteStreams.slice();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
close() {
|
|
241
|
-
WebRTCModule.peerConnectionClose(this._peerConnectionId);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
_getTrack(streamReactTag, trackId): MediaStreamTrack {
|
|
245
|
-
const stream
|
|
246
|
-
= this._remoteStreams.find(
|
|
247
|
-
stream => stream._reactTag === streamReactTag);
|
|
248
|
-
|
|
249
|
-
return stream && stream._tracks.find(track => track.id === trackId);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
_unregisterEvents(): void {
|
|
253
|
-
this._subscriptions.forEach(e => e.remove());
|
|
254
|
-
this._subscriptions = [];
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
_registerEvents(): void {
|
|
258
|
-
this._subscriptions = [
|
|
259
|
-
EventEmitter.addListener('peerConnectionOnRenegotiationNeeded', ev => {
|
|
260
|
-
if (ev.id !== this._peerConnectionId) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
this.dispatchEvent(new RTCEvent('negotiationneeded'));
|
|
264
|
-
}),
|
|
265
|
-
EventEmitter.addListener('peerConnectionIceConnectionChanged', ev => {
|
|
266
|
-
if (ev.id !== this._peerConnectionId) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
this.iceConnectionState = ev.iceConnectionState;
|
|
270
|
-
this.dispatchEvent(new RTCEvent('iceconnectionstatechange'));
|
|
271
|
-
if (ev.iceConnectionState === 'closed') {
|
|
272
|
-
// This PeerConnection is done, clean up event handlers.
|
|
273
|
-
this._unregisterEvents();
|
|
274
|
-
}
|
|
275
|
-
}),
|
|
276
|
-
EventEmitter.addListener('peerConnectionStateChanged', ev => {
|
|
277
|
-
if (ev.id !== this._peerConnectionId) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
this.connectionState = ev.connectionState;
|
|
281
|
-
this.dispatchEvent(new RTCEvent('connectionstatechange'));
|
|
282
|
-
if (ev.connectionState === 'closed') {
|
|
283
|
-
// This PeerConnection is done, clean up event handlers.
|
|
284
|
-
this._unregisterEvents();
|
|
285
|
-
}
|
|
286
|
-
}),
|
|
287
|
-
EventEmitter.addListener('peerConnectionSignalingStateChanged', ev => {
|
|
288
|
-
if (ev.id !== this._peerConnectionId) {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
this.signalingState = ev.signalingState;
|
|
292
|
-
this.dispatchEvent(new RTCEvent('signalingstatechange'));
|
|
293
|
-
}),
|
|
294
|
-
EventEmitter.addListener('peerConnectionAddedStream', ev => {
|
|
295
|
-
if (ev.id !== this._peerConnectionId) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
const stream = new MediaStream(ev);
|
|
299
|
-
this._remoteStreams.push(stream);
|
|
300
|
-
this.remoteDescription = new RTCSessionDescription(ev.sdp);
|
|
301
|
-
this.dispatchEvent(new MediaStreamEvent('addstream', {stream}));
|
|
302
|
-
}),
|
|
303
|
-
EventEmitter.addListener('peerConnectionRemovedStream', ev => {
|
|
304
|
-
if (ev.id !== this._peerConnectionId) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
const stream = this._remoteStreams.find(s => s._reactTag === ev.streamId);
|
|
308
|
-
if (stream) {
|
|
309
|
-
const index = this._remoteStreams.indexOf(stream);
|
|
310
|
-
if (index !== -1) {
|
|
311
|
-
this._remoteStreams.splice(index, 1);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
this.remoteDescription = new RTCSessionDescription(ev.sdp);
|
|
315
|
-
this.dispatchEvent(new MediaStreamEvent('removestream', {stream}));
|
|
316
|
-
}),
|
|
317
|
-
EventEmitter.addListener('mediaStreamTrackMuteChanged', ev => {
|
|
318
|
-
if (ev.peerConnectionId !== this._peerConnectionId) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const track = this._getTrack(ev.streamReactTag, ev.trackId);
|
|
322
|
-
if (track) {
|
|
323
|
-
track.muted = ev.muted;
|
|
324
|
-
const eventName = ev.muted ? 'mute' : 'unmute';
|
|
325
|
-
track.dispatchEvent(new MediaStreamTrackEvent(eventName, {track}));
|
|
326
|
-
}
|
|
327
|
-
}),
|
|
328
|
-
EventEmitter.addListener('peerConnectionGotICECandidate', ev => {
|
|
329
|
-
if (ev.id !== this._peerConnectionId) {
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
this.localDescription = new RTCSessionDescription(ev.sdp);
|
|
333
|
-
const candidate = new RTCIceCandidate(ev.candidate);
|
|
334
|
-
const event = new RTCIceCandidateEvent('icecandidate', {candidate});
|
|
335
|
-
this.dispatchEvent(event);
|
|
336
|
-
}),
|
|
337
|
-
EventEmitter.addListener('peerConnectionIceGatheringChanged', ev => {
|
|
338
|
-
if (ev.id !== this._peerConnectionId) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
this.iceGatheringState = ev.iceGatheringState;
|
|
342
|
-
|
|
343
|
-
if (this.iceGatheringState === 'complete') {
|
|
344
|
-
this.localDescription = new RTCSessionDescription(ev.sdp);
|
|
345
|
-
this.dispatchEvent(new RTCIceCandidateEvent('icecandidate', null));
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
this.dispatchEvent(new RTCEvent('icegatheringstatechange'));
|
|
349
|
-
}),
|
|
350
|
-
EventEmitter.addListener('peerConnectionDidOpenDataChannel', ev => {
|
|
351
|
-
if (ev.id !== this._peerConnectionId) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
const channel = new RTCDataChannel(ev.dataChannel);
|
|
355
|
-
this.dispatchEvent(new RTCDataChannelEvent('datachannel', {channel}));
|
|
356
|
-
})
|
|
357
|
-
];
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Creates a new RTCDataChannel object with the given label. The
|
|
362
|
-
* RTCDataChannelInit dictionary can be used to configure properties of the
|
|
363
|
-
* underlying channel such as data reliability.
|
|
364
|
-
*
|
|
365
|
-
* @param {string} label - the value with which the label attribute of the new
|
|
366
|
-
* instance is to be initialized
|
|
367
|
-
* @param {RTCDataChannelInit} dataChannelDict - an optional dictionary of
|
|
368
|
-
* values with which to initialize corresponding attributes of the new
|
|
369
|
-
* instance such as id
|
|
370
|
-
*/
|
|
371
|
-
createDataChannel(label: string, dataChannelDict?: ?RTCDataChannelInit) {
|
|
372
|
-
if (dataChannelDict && 'id' in dataChannelDict) {
|
|
373
|
-
const id = dataChannelDict.id;
|
|
374
|
-
if (typeof id !== 'number') {
|
|
375
|
-
throw new TypeError('DataChannel id must be a number: ' + id);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const channelInfo = WebRTCModule.createDataChannel(
|
|
380
|
-
this._peerConnectionId,
|
|
381
|
-
label,
|
|
382
|
-
dataChannelDict);
|
|
383
|
-
|
|
384
|
-
if (channelInfo === null) {
|
|
385
|
-
throw new TypeError('Failed to create new DataChannel');
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return new RTCDataChannel(channelInfo);
|
|
389
|
-
}
|
|
390
|
-
}
|
package/RTCSessionDescription.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
export default class RTCSessionDescription {
|
|
4
|
-
sdp: string;
|
|
5
|
-
type: string;
|
|
6
|
-
|
|
7
|
-
constructor(info = {type: null, sdp: ''}) {
|
|
8
|
-
this._sdp = info.sdp;
|
|
9
|
-
this._type = info.type;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get sdp() {
|
|
13
|
-
return this._sdp;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get type() {
|
|
17
|
-
return this._type;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
toJSON() {
|
|
21
|
-
return {sdp: this._sdp, type: this._type};
|
|
22
|
-
}
|
|
23
|
-
}
|
package/RTCView.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
NativeModules,
|
|
5
|
-
requireNativeComponent,
|
|
6
|
-
} from 'react-native';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
|
|
9
|
-
const {WebRTCModule} = NativeModules;
|
|
10
|
-
|
|
11
|
-
const RTCView = {
|
|
12
|
-
name: 'RTCVideoView',
|
|
13
|
-
propTypes: {
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Indicates whether the video specified by {@link #streamURL} should be
|
|
17
|
-
* mirrored during rendering. Commonly, applications choose to mirror the
|
|
18
|
-
* user-facing camera.
|
|
19
|
-
*/
|
|
20
|
-
mirror: PropTypes.bool,
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* In the fashion of
|
|
24
|
-
* https://www.w3.org/TR/html5/embedded-content-0.html#dom-video-videowidth
|
|
25
|
-
* and https://www.w3.org/TR/html5/rendering.html#video-object-fit,
|
|
26
|
-
* resembles the CSS style object-fit.
|
|
27
|
-
*/
|
|
28
|
-
objectFit: PropTypes.oneOf(['contain', 'cover']),
|
|
29
|
-
|
|
30
|
-
streamURL: PropTypes.string,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Similarly to the CSS property z-index, specifies the z-order of this
|
|
34
|
-
* RTCView in the stacking space of all RTCViews. When RTCViews overlap,
|
|
35
|
-
* zOrder determines which one covers the other. An RTCView with a larger
|
|
36
|
-
* zOrder generally covers an RTCView with a lower one.
|
|
37
|
-
*
|
|
38
|
-
* Non-overlapping RTCViews may safely share a z-order (because one does not
|
|
39
|
-
* have to cover the other).
|
|
40
|
-
*
|
|
41
|
-
* The support for zOrder is platform-dependent and/or
|
|
42
|
-
* implementation-specific. Thus, specifying a value for zOrder is to be
|
|
43
|
-
* thought of as giving a hint rather than as imposing a requirement. For
|
|
44
|
-
* example, video renderers such as RTCView are commonly implemented using
|
|
45
|
-
* OpenGL and OpenGL views may have different numbers of layers in their
|
|
46
|
-
* stacking space. Android has three: a layer bellow the window (aka
|
|
47
|
-
* default), a layer bellow the window again but above the previous layer
|
|
48
|
-
* (aka media overlay), and above the window. Consequently, it is advisable
|
|
49
|
-
* to limit the number of utilized layers in the stacking space to the
|
|
50
|
-
* minimum sufficient for the desired display. For example, a video call
|
|
51
|
-
* application usually needs a maximum of two zOrder values: 0 for the
|
|
52
|
-
* remote video(s) which appear in the background, and 1 for the local
|
|
53
|
-
* video(s) which appear above the remote video(s).
|
|
54
|
-
*/
|
|
55
|
-
zOrder: PropTypes.number
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const View = requireNativeComponent('RTCVideoView', RTCView, {nativeOnly: {
|
|
60
|
-
testID: true,
|
|
61
|
-
accessibilityComponentType: true,
|
|
62
|
-
renderToHardwareTextureAndroid: true,
|
|
63
|
-
accessibilityLabel: true,
|
|
64
|
-
accessibilityLiveRegion: true,
|
|
65
|
-
importantForAccessibility: true,
|
|
66
|
-
onLayout: true,
|
|
67
|
-
nativeID: true,
|
|
68
|
-
}});
|
|
69
|
-
|
|
70
|
-
export default View;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/getUserMedia.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import {Platform, NativeModules} from 'react-native';
|
|
4
|
-
import * as RTCUtil from './RTCUtil';
|
|
5
|
-
|
|
6
|
-
import MediaStream from './MediaStream';
|
|
7
|
-
import MediaStreamError from './MediaStreamError';
|
|
8
|
-
import permissions from './Permissions';
|
|
9
|
-
|
|
10
|
-
const { WebRTCModule } = NativeModules;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export default function getUserMedia(constraints = {}) {
|
|
14
|
-
// According to
|
|
15
|
-
// https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-getusermedia,
|
|
16
|
-
// the constraints argument is a dictionary of type MediaStreamConstraints.
|
|
17
|
-
if (typeof constraints !== 'object') {
|
|
18
|
-
return Promise.reject(new TypeError('constraints is not a dictionary'));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if ((typeof constraints.audio === 'undefined' || !constraints.audio)
|
|
22
|
-
&& (typeof constraints.video === 'undefined' || !constraints.video)) {
|
|
23
|
-
return Promise.reject(new TypeError('audio and/or video is required'));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Normalize constraints.
|
|
27
|
-
constraints = RTCUtil.normalizeConstraints(constraints);
|
|
28
|
-
|
|
29
|
-
// Request required permissions
|
|
30
|
-
const reqPermissions = [];
|
|
31
|
-
if (constraints.audio) {
|
|
32
|
-
reqPermissions.push(permissions.request({ name: 'microphone' }));
|
|
33
|
-
} else {
|
|
34
|
-
reqPermissions.push(Promise.resolve(false));
|
|
35
|
-
}
|
|
36
|
-
if (constraints.video) {
|
|
37
|
-
reqPermissions.push(permissions.request({ name: 'camera' }));
|
|
38
|
-
} else {
|
|
39
|
-
reqPermissions.push(Promise.resolve(false));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
Promise.all(reqPermissions).then(results => {
|
|
44
|
-
const [ audioPerm, videoPerm ] = results;
|
|
45
|
-
|
|
46
|
-
// Check permission results and remove unneeded permissions.
|
|
47
|
-
|
|
48
|
-
if (!audioPerm && !videoPerm) {
|
|
49
|
-
// https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-getusermedia
|
|
50
|
-
// step 4
|
|
51
|
-
const error = {
|
|
52
|
-
message: 'Permission denied.',
|
|
53
|
-
name: 'SecurityError'
|
|
54
|
-
};
|
|
55
|
-
reject(new MediaStreamError(error));
|
|
56
|
-
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
audioPerm || (delete constraints.audio);
|
|
61
|
-
videoPerm || (delete constraints.video);
|
|
62
|
-
|
|
63
|
-
const success = (id, tracks) => {
|
|
64
|
-
// Store initial constraints.
|
|
65
|
-
for (const trackInfo of tracks) {
|
|
66
|
-
const c = constraints[trackInfo.kind];
|
|
67
|
-
if (typeof c === 'object') {
|
|
68
|
-
trackInfo.constraints = RTCUtil.deepClone(c);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const info = {
|
|
73
|
-
streamId: id,
|
|
74
|
-
streamReactTag: id,
|
|
75
|
-
tracks
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
resolve(new MediaStream(info));
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const failure = (type, message) => {
|
|
82
|
-
let error;
|
|
83
|
-
switch (type) {
|
|
84
|
-
case 'TypeError':
|
|
85
|
-
error = new TypeError(message);
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
if (!error) {
|
|
89
|
-
error = new MediaStreamError({ message, name: type });
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
reject(error);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
WebRTCModule.getUserMedia(constraints, success, failure);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
package/index.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import ScreenCapturePickerView from './ScreenCapturePickerView';
|
|
4
|
-
import RTCPeerConnection from './RTCPeerConnection';
|
|
5
|
-
import RTCIceCandidate from './RTCIceCandidate';
|
|
6
|
-
import RTCSessionDescription from './RTCSessionDescription';
|
|
7
|
-
import RTCView from './RTCView';
|
|
8
|
-
import MediaStream from './MediaStream';
|
|
9
|
-
import MediaStreamTrack from './MediaStreamTrack';
|
|
10
|
-
import mediaDevices from './MediaDevices';
|
|
11
|
-
import permissions from './Permissions';
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
ScreenCapturePickerView,
|
|
15
|
-
RTCPeerConnection,
|
|
16
|
-
RTCIceCandidate,
|
|
17
|
-
RTCSessionDescription,
|
|
18
|
-
RTCView,
|
|
19
|
-
MediaStream,
|
|
20
|
-
MediaStreamTrack,
|
|
21
|
-
mediaDevices,
|
|
22
|
-
permissions,
|
|
23
|
-
registerGlobals
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function registerGlobals() {
|
|
27
|
-
// Should not happen. React Native has a global navigator object.
|
|
28
|
-
if (typeof navigator !== 'object') {
|
|
29
|
-
throw new Error('navigator is not an object');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!navigator.mediaDevices) {
|
|
33
|
-
navigator.mediaDevices = {};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
navigator.mediaDevices.getUserMedia =
|
|
37
|
-
mediaDevices.getUserMedia.bind(mediaDevices);
|
|
38
|
-
|
|
39
|
-
navigator.mediaDevices.enumerateDevices =
|
|
40
|
-
mediaDevices.enumerateDevices.bind(mediaDevices);
|
|
41
|
-
|
|
42
|
-
global.RTCPeerConnection = RTCPeerConnection;
|
|
43
|
-
global.RTCIceCandidate = RTCIceCandidate;
|
|
44
|
-
global.RTCSessionDescription = RTCSessionDescription;
|
|
45
|
-
global.MediaStream = MediaStream;
|
|
46
|
-
global.MediaStreamTrack = MediaStreamTrack;
|
|
47
|
-
}
|
|
Binary file
|
package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>SchemeUserState</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>RCTWebRTC.xcscheme_^#shared#^_</key>
|
|
8
|
-
<dict>
|
|
9
|
-
<key>orderHint</key>
|
|
10
|
-
<integer>0</integer>
|
|
11
|
-
</dict>
|
|
12
|
-
</dict>
|
|
13
|
-
</dict>
|
|
14
|
-
</plist>
|