react-native-webrtc 1.92.1 → 1.94.2

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.
Files changed (67) hide show
  1. package/.prettierignore +9 -0
  2. package/.prettierrc.json +10 -0
  3. package/README.md +2 -2
  4. package/android/libs/.placeholder +0 -0
  5. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +21 -8
  6. package/android/src/main/java/com/oney/WebRTCModule/StringUtils.java +24 -0
  7. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +199 -255
  8. package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +10 -2
  9. package/apple/.placeholder +0 -0
  10. package/ios/RCTWebRTC/VideoCaptureController.h +2 -2
  11. package/ios/RCTWebRTC/VideoCaptureController.m +131 -48
  12. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +39 -20
  13. package/metro.config.js +3 -4
  14. package/metro.config.macos.js +7 -8
  15. package/package.json +20 -12
  16. package/react-native.config.js +5 -6
  17. package/{EventEmitter.js → src/EventEmitter.js} +1 -1
  18. package/{MediaDevices.js → src/MediaDevices.js} +6 -12
  19. package/src/MediaStream.js +128 -0
  20. package/src/MediaStreamError.js +12 -0
  21. package/src/MediaStreamErrorEvent.js +11 -0
  22. package/src/MediaStreamEvent.js +11 -0
  23. package/src/MediaStreamTrack.js +104 -0
  24. package/src/MediaStreamTrackEvent.js +11 -0
  25. package/src/MessageEvent.js +10 -0
  26. package/{Permissions.js → src/Permissions.js} +26 -23
  27. package/src/RTCDataChannel.js +143 -0
  28. package/src/RTCDataChannelEvent.js +11 -0
  29. package/src/RTCEvent.js +8 -0
  30. package/src/RTCIceCandidate.js +20 -0
  31. package/src/RTCIceCandidateEvent.js +15 -0
  32. package/src/RTCPeerConnection.js +349 -0
  33. package/src/RTCSessionDescription.js +22 -0
  34. package/{RTCUtil.js → src/RTCUtil.js} +77 -57
  35. package/src/RTCView.js +60 -0
  36. package/src/ScreenCapturePickerView.js +4 -0
  37. package/{getDisplayMedia.js → src/getDisplayMedia.js} +7 -6
  38. package/src/getUserMedia.js +98 -0
  39. package/src/index.js +44 -0
  40. package/tools/build-webrtc.py +61 -49
  41. package/tools/downloadBitcode.sh +4 -16
  42. package/tools/downloadWebRTC.js +100 -0
  43. package/MediaStream.js +0 -138
  44. package/MediaStreamError.js +0 -14
  45. package/MediaStreamErrorEvent.js +0 -12
  46. package/MediaStreamEvent.js +0 -12
  47. package/MediaStreamTrack.js +0 -118
  48. package/MediaStreamTrackEvent.js +0 -12
  49. package/MessageEvent.js +0 -11
  50. package/RTCDataChannel.js +0 -161
  51. package/RTCDataChannelEvent.js +0 -12
  52. package/RTCEvent.js +0 -9
  53. package/RTCIceCandidate.js +0 -21
  54. package/RTCIceCandidateEvent.js +0 -16
  55. package/RTCPeerConnection.js +0 -379
  56. package/RTCSessionDescription.js +0 -23
  57. package/RTCView.js +0 -70
  58. package/ScreenCapturePickerView.js +0 -7
  59. package/android/libs/libjingle_peerconnection.so.jar +0 -0
  60. package/android/libs/libwebrtc.jar +0 -0
  61. package/apple/WebRTC.xcframework.tgz +0 -0
  62. package/getUserMedia.js +0 -98
  63. package/index.js +0 -50
  64. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  65. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  66. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  67. package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -1,379 +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(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(data);
150
- } else {
151
- reject(data);
152
- }
153
- });
154
- });
155
- }
156
-
157
- setConfiguration(configuration) {
158
- WebRTCModule.peerConnectionSetConfiguration(configuration, this._peerConnectionId);
159
- }
160
-
161
- async setLocalDescription(sessionDescription: ?RTCSessionDescription) {
162
- const desc = sessionDescription ?
163
- (sessionDescription.toJSON ? sessionDescription.toJSON() : sessionDescription) : null;
164
- const newSdp = await WebRTCModule.peerConnectionSetLocalDescription(this._peerConnectionId, desc);
165
-
166
- this.localDescription = new RTCSessionDescription(newSdp);
167
- }
168
-
169
- setRemoteDescription(sessionDescription: RTCSessionDescription) {
170
- return new Promise((resolve, reject) => {
171
- WebRTCModule.peerConnectionSetRemoteDescription(
172
- sessionDescription.toJSON ? sessionDescription.toJSON() : sessionDescription,
173
- this._peerConnectionId,
174
- (successful, data) => {
175
- if (successful) {
176
- this.remoteDescription = new RTCSessionDescription(data);
177
- resolve();
178
- } else {
179
- reject(data);
180
- }
181
- });
182
- });
183
- }
184
-
185
- async addIceCandidate(candidate) {
186
- if (!candidate || !candidate.candidate) {
187
- // XXX end-of cantidates is not implemented: https://bugs.chromium.org/p/webrtc/issues/detail?id=9218
188
- return;
189
- }
190
-
191
- const newSdp = await WebRTCModule.peerConnectionAddICECandidate(
192
- this._peerConnectionId,
193
- candidate.toJSON ? candidate.toJSON() : candidate
194
- );
195
-
196
- this.remoteDescription = new RTCSessionDescription(newSdp);
197
- }
198
-
199
- getStats() {
200
- return WebRTCModule.peerConnectionGetStats(this._peerConnectionId)
201
- .then( data => {
202
- /* On both Android and iOS it is faster to construct a single
203
- JSON string representing the Map of StatsReports and have it
204
- pass through the React Native bridge rather than the Map of
205
- StatsReports. While the implementations do try to be faster in
206
- general, the stress is on being faster to pass through the React
207
- Native bridge which is a bottleneck that tends to be visible in
208
- the UI when there is congestion involving UI-related passing.
209
-
210
- TODO Implement the logic for filtering the stats based on
211
- the sender/receiver
212
- */
213
- return new Map(JSON.parse(data));
214
- });
215
- }
216
-
217
- getLocalStreams() {
218
- return this._localStreams.slice();
219
- }
220
-
221
- getRemoteStreams() {
222
- return this._remoteStreams.slice();
223
- }
224
-
225
- close() {
226
- WebRTCModule.peerConnectionClose(this._peerConnectionId);
227
- }
228
-
229
- restartIce() {
230
- WebRTCModule.peerConnectionRestartIce(this._peerConnectionId);
231
- }
232
-
233
- _getTrack(streamReactTag, trackId): MediaStreamTrack {
234
- const stream
235
- = this._remoteStreams.find(
236
- stream => stream._reactTag === streamReactTag);
237
-
238
- return stream && stream._tracks.find(track => track.id === trackId);
239
- }
240
-
241
- _unregisterEvents(): void {
242
- this._subscriptions.forEach(e => e.remove());
243
- this._subscriptions = [];
244
- }
245
-
246
- _registerEvents(): void {
247
- this._subscriptions = [
248
- EventEmitter.addListener('peerConnectionOnRenegotiationNeeded', ev => {
249
- if (ev.id !== this._peerConnectionId) {
250
- return;
251
- }
252
- this.dispatchEvent(new RTCEvent('negotiationneeded'));
253
- }),
254
- EventEmitter.addListener('peerConnectionIceConnectionChanged', ev => {
255
- if (ev.id !== this._peerConnectionId) {
256
- return;
257
- }
258
- this.iceConnectionState = ev.iceConnectionState;
259
- this.dispatchEvent(new RTCEvent('iceconnectionstatechange'));
260
- if (ev.iceConnectionState === 'closed') {
261
- // This PeerConnection is done, clean up event handlers.
262
- this._unregisterEvents();
263
- }
264
- }),
265
- EventEmitter.addListener('peerConnectionStateChanged', ev => {
266
- if (ev.id !== this._peerConnectionId) {
267
- return;
268
- }
269
- this.connectionState = ev.connectionState;
270
- this.dispatchEvent(new RTCEvent('connectionstatechange'));
271
- if (ev.connectionState === 'closed') {
272
- // This PeerConnection is done, clean up event handlers.
273
- this._unregisterEvents();
274
- }
275
- }),
276
- EventEmitter.addListener('peerConnectionSignalingStateChanged', ev => {
277
- if (ev.id !== this._peerConnectionId) {
278
- return;
279
- }
280
- this.signalingState = ev.signalingState;
281
- this.dispatchEvent(new RTCEvent('signalingstatechange'));
282
- }),
283
- EventEmitter.addListener('peerConnectionAddedStream', ev => {
284
- if (ev.id !== this._peerConnectionId) {
285
- return;
286
- }
287
- const stream = new MediaStream(ev);
288
- this._remoteStreams.push(stream);
289
- this.remoteDescription = new RTCSessionDescription(ev.sdp);
290
- this.dispatchEvent(new MediaStreamEvent('addstream', {stream}));
291
- }),
292
- EventEmitter.addListener('peerConnectionRemovedStream', ev => {
293
- if (ev.id !== this._peerConnectionId) {
294
- return;
295
- }
296
- const stream = this._remoteStreams.find(s => s._reactTag === ev.streamId);
297
- if (stream) {
298
- const index = this._remoteStreams.indexOf(stream);
299
- if (index !== -1) {
300
- this._remoteStreams.splice(index, 1);
301
- }
302
- }
303
- this.remoteDescription = new RTCSessionDescription(ev.sdp);
304
- this.dispatchEvent(new MediaStreamEvent('removestream', {stream}));
305
- }),
306
- EventEmitter.addListener('mediaStreamTrackMuteChanged', ev => {
307
- if (ev.peerConnectionId !== this._peerConnectionId) {
308
- return;
309
- }
310
- const track = this._getTrack(ev.streamReactTag, ev.trackId);
311
- if (track) {
312
- track.muted = ev.muted;
313
- const eventName = ev.muted ? 'mute' : 'unmute';
314
- track.dispatchEvent(new MediaStreamTrackEvent(eventName, {track}));
315
- }
316
- }),
317
- EventEmitter.addListener('peerConnectionGotICECandidate', ev => {
318
- if (ev.id !== this._peerConnectionId) {
319
- return;
320
- }
321
- this.localDescription = new RTCSessionDescription(ev.sdp);
322
- const candidate = new RTCIceCandidate(ev.candidate);
323
- const event = new RTCIceCandidateEvent('icecandidate', {candidate});
324
- this.dispatchEvent(event);
325
- }),
326
- EventEmitter.addListener('peerConnectionIceGatheringChanged', ev => {
327
- if (ev.id !== this._peerConnectionId) {
328
- return;
329
- }
330
- this.iceGatheringState = ev.iceGatheringState;
331
-
332
- if (this.iceGatheringState === 'complete') {
333
- this.localDescription = new RTCSessionDescription(ev.sdp);
334
- this.dispatchEvent(new RTCIceCandidateEvent('icecandidate', null));
335
- }
336
-
337
- this.dispatchEvent(new RTCEvent('icegatheringstatechange'));
338
- }),
339
- EventEmitter.addListener('peerConnectionDidOpenDataChannel', ev => {
340
- if (ev.id !== this._peerConnectionId) {
341
- return;
342
- }
343
- const channel = new RTCDataChannel(ev.dataChannel);
344
- this.dispatchEvent(new RTCDataChannelEvent('datachannel', {channel}));
345
- })
346
- ];
347
- }
348
-
349
- /**
350
- * Creates a new RTCDataChannel object with the given label. The
351
- * RTCDataChannelInit dictionary can be used to configure properties of the
352
- * underlying channel such as data reliability.
353
- *
354
- * @param {string} label - the value with which the label attribute of the new
355
- * instance is to be initialized
356
- * @param {RTCDataChannelInit} dataChannelDict - an optional dictionary of
357
- * values with which to initialize corresponding attributes of the new
358
- * instance such as id
359
- */
360
- createDataChannel(label: string, dataChannelDict: ?RTCDataChannelInit) {
361
- if (dataChannelDict && 'id' in dataChannelDict) {
362
- const id = dataChannelDict.id;
363
- if (typeof id !== 'number') {
364
- throw new TypeError('DataChannel id must be a number: ' + id);
365
- }
366
- }
367
-
368
- const channelInfo = WebRTCModule.createDataChannel(
369
- this._peerConnectionId,
370
- label,
371
- dataChannelDict);
372
-
373
- if (channelInfo === null) {
374
- throw new TypeError('Failed to create new DataChannel');
375
- }
376
-
377
- return new RTCDataChannel(channelInfo);
378
- }
379
- }
@@ -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;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- import {
4
- requireNativeComponent,
5
- } from 'react-native';
6
-
7
- export default requireNativeComponent('ScreenCapturePickerView');;
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,50 +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.getDisplayMedia =
40
- mediaDevices.getDisplayMedia.bind(mediaDevices);
41
-
42
- navigator.mediaDevices.enumerateDevices =
43
- mediaDevices.enumerateDevices.bind(mediaDevices);
44
-
45
- global.RTCPeerConnection = RTCPeerConnection;
46
- global.RTCIceCandidate = RTCIceCandidate;
47
- global.RTCSessionDescription = RTCSessionDescription;
48
- global.MediaStream = MediaStream;
49
- global.MediaStreamTrack = MediaStreamTrack;
50
- }
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- <FileRef
5
- location = "self:">
6
- </FileRef>
7
- </Workspace>
@@ -1,8 +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>IDEDidComputeMac32BitWarning</key>
6
- <true/>
7
- </dict>
8
- </plist>
@@ -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>