react-native-webrtc 1.92.2 → 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.
Files changed (44) hide show
  1. package/.prettierignore +9 -0
  2. package/.prettierrc.json +10 -0
  3. package/android/libs/.placeholder +0 -0
  4. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +0 -5
  5. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +199 -255
  6. package/apple/.placeholder +0 -0
  7. package/ios/RCTWebRTC/VideoCaptureController.m +5 -3
  8. package/metro.config.js +3 -4
  9. package/metro.config.macos.js +7 -8
  10. package/package.json +20 -12
  11. package/react-native.config.js +5 -6
  12. package/src/EventEmitter.js +1 -1
  13. package/src/MediaDevices.js +6 -12
  14. package/src/MediaStream.js +120 -131
  15. package/src/MediaStreamError.js +8 -10
  16. package/src/MediaStreamErrorEvent.js +6 -7
  17. package/src/MediaStreamEvent.js +6 -7
  18. package/src/MediaStreamTrack.js +89 -103
  19. package/src/MediaStreamTrackEvent.js +6 -7
  20. package/src/MessageEvent.js +7 -8
  21. package/src/Permissions.js +26 -23
  22. package/src/RTCDataChannel.js +127 -145
  23. package/src/RTCDataChannelEvent.js +6 -7
  24. package/src/RTCEvent.js +5 -6
  25. package/src/RTCIceCandidate.js +15 -16
  26. package/src/RTCIceCandidateEvent.js +8 -9
  27. package/src/RTCPeerConnection.js +295 -325
  28. package/src/RTCSessionDescription.js +15 -16
  29. package/src/RTCUtil.js +56 -57
  30. package/src/RTCView.js +59 -69
  31. package/src/ScreenCapturePickerView.js +2 -5
  32. package/src/getDisplayMedia.js +7 -6
  33. package/src/getUserMedia.js +85 -85
  34. package/src/index.js +28 -34
  35. package/tools/build-webrtc.py +61 -49
  36. package/tools/downloadBitcode.sh +4 -16
  37. package/tools/downloadWebRTC.js +100 -0
  38. package/android/libs/libjingle_peerconnection.so.jar +0 -0
  39. package/android/libs/libwebrtc.jar +0 -0
  40. package/apple/WebRTC.xcframework.tgz +0 -0
  41. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  42. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  43. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  44. package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/metro.config.js CHANGED
@@ -1,8 +1,7 @@
1
-
2
1
  const blacklist = require('metro-config/src/defaults/blacklist');
3
2
 
4
3
  module.exports = {
5
- resolver: {
6
- blacklistRE: blacklist([/node_modules\/react-native-macos\/.*/])
7
- },
4
+ resolver: {
5
+ blacklistRE: blacklist([/node_modules\/react-native-macos\/.*/])
6
+ }
8
7
  };
@@ -1,15 +1,14 @@
1
-
2
1
  const path = require('path');
3
2
  const blacklist = require('metro-config/src/defaults/blacklist');
4
3
 
5
4
  const rnmPath = path.resolve(__dirname, 'node_modules/react-native-macos');
6
5
 
7
6
  module.exports = {
8
- resolver: {
9
- extraNodeModules: {
10
- 'react-native': rnmPath,
11
- },
12
- platforms: ['macos', 'ios', 'android'],
13
- blacklistRE: blacklist([/node_modules\/react-native\/.*/])
14
- },
7
+ resolver: {
8
+ extraNodeModules: {
9
+ 'react-native': rnmPath
10
+ },
11
+ platforms: ['macos', 'ios', 'android'],
12
+ blacklistRE: blacklist([/node_modules\/react-native\/.*/])
13
+ }
15
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-webrtc",
3
- "version": "1.92.2",
3
+ "version": "1.94.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/react-native-webrtc/react-native-webrtc.git"
@@ -18,24 +18,32 @@
18
18
  ],
19
19
  "main": "src/index.js",
20
20
  "dependencies": {
21
- "base64-js": "^1.1.2",
22
- "cross-os": "^1.3.0",
23
- "event-target-shim": "^1.0.5",
24
- "prop-types": "^15.5.10",
25
- "uuid": "^3.3.2"
21
+ "base64-js": "1.5.1",
22
+ "event-target-shim": "6.0.2",
23
+ "tar": "6.1.11",
24
+ "uuid": "3.4.0"
26
25
  },
27
26
  "peerDependencies": {
28
27
  "react-native": ">=0.60.0"
29
28
  },
30
29
  "scripts": {
31
- "postinstall": "cross-os darwin-extract"
32
- },
33
- "cross-os": {
34
- "darwin-extract": {
35
- "darwin": "tar -zxf apple/WebRTC.xcframework.tgz -C apple"
36
- }
30
+ "postinstall": "node tools/downloadWebRTC.js",
31
+ "prepare": "husky install"
37
32
  },
38
33
  "bugs": {
39
34
  "url": "https://github.com/react-native-webrtc/react-native-webrtc/issues"
35
+ },
36
+ "devDependencies": {
37
+ "husky": "7.0.2",
38
+ "lint-staged": "11.2.3",
39
+ "prettier": "2.4.1"
40
+ },
41
+ "lint-staged": {
42
+ "**/*": "prettier --write --ignore-unknown"
43
+ },
44
+ "webrtc-builds": {
45
+ "android": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/android-webrtc.tgz",
46
+ "ios": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/WebRTC.xcframework.tgz",
47
+ "ios-bitcode": "https://github.com/jitsi/webrtc/releases/download/v94.0.0/WebRTC.xcframework-bitcode.tgz"
40
48
  }
41
49
  }
@@ -1,12 +1,11 @@
1
-
2
1
  'use strict';
3
2
 
4
3
  const macSwitch = '--use-react-native-macos';
5
4
 
6
5
  if (process.argv.includes(macSwitch)) {
7
- process.argv = process.argv.filter(arg => arg !== macSwitch);
8
- process.argv.push('--config=metro.config.macos.js');
9
- module.exports = {
10
- reactNativePath: 'node_modules/react-native-macos',
11
- };
6
+ process.argv = process.argv.filter(arg => arg !== macSwitch);
7
+ process.argv.push('--config=metro.config.macos.js');
8
+ module.exports = {
9
+ reactNativePath: 'node_modules/react-native-macos'
10
+ };
12
11
  }
@@ -1,4 +1,4 @@
1
- import {NativeModules, NativeEventEmitter} from 'react-native';
1
+ import { NativeModules, NativeEventEmitter } from 'react-native';
2
2
 
3
3
  const { WebRTCModule } = NativeModules;
4
4
 
@@ -1,21 +1,15 @@
1
- 'use strict';
2
1
 
3
- import {NativeModules} from 'react-native';
4
- import EventTarget from 'event-target-shim';
2
+ import { NativeModules } from 'react-native';
3
+ import { defineCustomEventTarget } from 'event-target-shim';
5
4
 
6
5
  import getDisplayMedia from './getDisplayMedia';
7
6
  import getUserMedia from './getUserMedia';
8
7
 
9
- const {WebRTCModule} = NativeModules;
8
+ const { WebRTCModule } = NativeModules;
10
9
 
11
- const MEDIA_DEVICES_EVENTS = [
12
- 'devicechange'
13
- ];
14
-
15
- class MediaDevices extends EventTarget(MEDIA_DEVICES_EVENTS) {
16
- // TODO: implement.
17
- ondevicechange: ?Function;
10
+ const MEDIA_DEVICES_EVENTS = ['devicechange'];
18
11
 
12
+ class MediaDevices extends defineCustomEventTarget(...MEDIA_DEVICES_EVENTS) {
19
13
  /**
20
14
  * W3C "Media Capture and Streams" compatible {@code enumerateDevices}
21
15
  * implementation.
@@ -40,7 +34,7 @@ class MediaDevices extends EventTarget(MEDIA_DEVICES_EVENTS) {
40
34
  * implementation.
41
35
  * See: https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-enumeratedevices
42
36
  *
43
- * @param {*} constraints
37
+ * @param {*} constraints
44
38
  * @returns {Promise}
45
39
  */
46
40
  getUserMedia(constraints) {
@@ -1,139 +1,128 @@
1
- 'use strict';
2
1
 
3
- import {NativeModules} from 'react-native';
4
- import EventTarget from 'event-target-shim';
2
+ import { NativeModules } from 'react-native';
3
+ import { defineCustomEventTarget } from 'event-target-shim';
5
4
  import uuid from 'uuid';
6
5
 
7
6
  import MediaStreamTrack from './MediaStreamTrack';
8
7
 
9
- const {WebRTCModule} = NativeModules;
10
-
11
- const MEDIA_STREAM_EVENTS = [
12
- 'active',
13
- 'inactive',
14
- 'addtrack',
15
- 'removetrack',
16
- ];
17
-
18
- export default class MediaStream extends EventTarget(MEDIA_STREAM_EVENTS) {
19
- id: string;
20
- active: boolean = true;
21
-
22
- onactive: ?Function;
23
- oninactive: ?Function;
24
- onaddtrack: ?Function;
25
- onremovetrack: ?Function;
26
-
27
- _tracks: Array<MediaStreamTrack> = [];
28
-
29
- /**
30
- * The identifier of this MediaStream unique within the associated
31
- * WebRTCModule instance. As the id of a remote MediaStream instance is unique
32
- * only within the associated RTCPeerConnection, it is not sufficiently unique
33
- * to identify this MediaStream across multiple RTCPeerConnections and to
34
- * unambiguously differentiate it from a local MediaStream instance not added
35
- * to an RTCPeerConnection.
36
- */
37
- _reactTag: string;
38
-
39
- /**
40
- * A MediaStream can be constructed in several ways, depending on the paramters
41
- * that are passed here.
42
- *
43
- * - undefined: just a new stream, with no tracks.
44
- * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.
45
- * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.
46
- * - object: a new stream instance, represented by the passed info object, this is always
47
- * done internally, when the stream is first created in native and the JS wrapper is
48
- * built afterwards.
49
- */
50
- constructor(arg) {
51
- super();
52
-
53
- // Assigm a UUID to start with. It may get overridden for remote streams.
54
- this.id = uuid.v4();
55
- // Local MediaStreams are created by WebRTCModule to have their id and
56
- // reactTag equal because WebRTCModule follows the respective standard's
57
- // recommendation for id generation i.e. uses UUID which is unique enough
58
- // for the purposes of reactTag.
59
- this._reactTag = this.id;
60
-
61
- if (typeof arg === 'undefined') {
62
- WebRTCModule.mediaStreamCreate(this.id);
63
- } else if (arg instanceof MediaStream) {
64
- WebRTCModule.mediaStreamCreate(this.id);
65
- for (const track of arg.getTracks()) {
66
- this.addTrack(track);
67
- }
68
- } else if (Array.isArray(arg)) {
69
- WebRTCModule.mediaStreamCreate(this.id);
70
- for (const track of arg) {
71
- this.addTrack(track);
72
- }
73
- } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {
74
- this.id = arg.streamId;
75
- this._reactTag = arg.streamReactTag;
76
- for (const trackInfo of arg.tracks) {
77
- // We are not using addTrack here because the track is already part of the
78
- // stream, so there is no need to add it on the native side.
79
- this._tracks.push(new MediaStreamTrack(trackInfo));
80
- }
81
- } else {
82
- throw new TypeError(`invalid type: ${typeof arg}`);
83
- }
84
- }
85
-
86
- addTrack(track: MediaStreamTrack) {
87
- const index = this._tracks.indexOf(track);
88
- if (index !== -1) {
89
- return;
90
- }
91
- this._tracks.push(track);
92
- WebRTCModule.mediaStreamAddTrack(this._reactTag, track.id);
93
- }
94
-
95
- removeTrack(track: MediaStreamTrack) {
96
- const index = this._tracks.indexOf(track);
97
- if (index === -1) {
98
- return;
99
- }
100
- this._tracks.splice(index, 1);
101
- WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.id);
102
- }
103
-
104
- getTracks(): Array<MediaStreamTrack> {
105
- return this._tracks.slice();
106
- }
107
-
108
- getTrackById(trackId): ?MediaStreamTrack {
109
- return this._tracks.find(track => track.id === trackId);
110
- }
111
-
112
- getAudioTracks(): Array<MediaStreamTrack> {
113
- return this._tracks.filter(track => track.kind === 'audio');
114
- }
115
-
116
- getVideoTracks(): Array<MediaStreamTrack> {
117
- return this._tracks.filter(track => track.kind === 'video');
118
- }
119
-
120
- clone() {
121
- throw new Error('Not implemented.');
122
- }
123
-
124
- toURL() {
125
- return this._reactTag;
126
- }
127
-
128
- release(releaseTracks = true) {
129
- const tracks = [ ...this._tracks ];
130
- for (const track of tracks) {
131
- this.removeTrack(track);
132
- if (releaseTracks) {
133
- track.release();
134
- }
8
+ const { WebRTCModule } = NativeModules;
9
+
10
+ const MEDIA_STREAM_EVENTS = ['active', 'inactive', 'addtrack', 'removetrack'];
11
+
12
+ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM_EVENTS) {
13
+ id: string;
14
+ active: boolean = true;
15
+
16
+ _tracks: Array<MediaStreamTrack> = [];
17
+
18
+ /**
19
+ * The identifier of this MediaStream unique within the associated
20
+ * WebRTCModule instance. As the id of a remote MediaStream instance is unique
21
+ * only within the associated RTCPeerConnection, it is not sufficiently unique
22
+ * to identify this MediaStream across multiple RTCPeerConnections and to
23
+ * unambiguously differentiate it from a local MediaStream instance not added
24
+ * to an RTCPeerConnection.
25
+ */
26
+ _reactTag: string;
27
+
28
+ /**
29
+ * A MediaStream can be constructed in several ways, depending on the paramters
30
+ * that are passed here.
31
+ *
32
+ * - undefined: just a new stream, with no tracks.
33
+ * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.
34
+ * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.
35
+ * - object: a new stream instance, represented by the passed info object, this is always
36
+ * done internally, when the stream is first created in native and the JS wrapper is
37
+ * built afterwards.
38
+ */
39
+ constructor(arg) {
40
+ super();
41
+
42
+ // Assigm a UUID to start with. It may get overridden for remote streams.
43
+ this.id = uuid.v4();
44
+ // Local MediaStreams are created by WebRTCModule to have their id and
45
+ // reactTag equal because WebRTCModule follows the respective standard's
46
+ // recommendation for id generation i.e. uses UUID which is unique enough
47
+ // for the purposes of reactTag.
48
+ this._reactTag = this.id;
49
+
50
+ if (typeof arg === 'undefined') {
51
+ WebRTCModule.mediaStreamCreate(this.id);
52
+ } else if (arg instanceof MediaStream) {
53
+ WebRTCModule.mediaStreamCreate(this.id);
54
+ for (const track of arg.getTracks()) {
55
+ this.addTrack(track);
56
+ }
57
+ } else if (Array.isArray(arg)) {
58
+ WebRTCModule.mediaStreamCreate(this.id);
59
+ for (const track of arg) {
60
+ this.addTrack(track);
61
+ }
62
+ } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {
63
+ this.id = arg.streamId;
64
+ this._reactTag = arg.streamReactTag;
65
+ for (const trackInfo of arg.tracks) {
66
+ // We are not using addTrack here because the track is already part of the
67
+ // stream, so there is no need to add it on the native side.
68
+ this._tracks.push(new MediaStreamTrack(trackInfo));
69
+ }
70
+ } else {
71
+ throw new TypeError(`invalid type: ${typeof arg}`);
72
+ }
135
73
  }
136
74
 
137
- WebRTCModule.mediaStreamRelease(this._reactTag);
138
- }
75
+ addTrack(track: MediaStreamTrack) {
76
+ const index = this._tracks.indexOf(track);
77
+ if (index !== -1) {
78
+ return;
79
+ }
80
+ this._tracks.push(track);
81
+ WebRTCModule.mediaStreamAddTrack(this._reactTag, track.id);
82
+ }
83
+
84
+ removeTrack(track: MediaStreamTrack) {
85
+ const index = this._tracks.indexOf(track);
86
+ if (index === -1) {
87
+ return;
88
+ }
89
+ this._tracks.splice(index, 1);
90
+ WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.id);
91
+ }
92
+
93
+ getTracks(): Array<MediaStreamTrack> {
94
+ return this._tracks.slice();
95
+ }
96
+
97
+ getTrackById(trackId): ?MediaStreamTrack {
98
+ return this._tracks.find(track => track.id === trackId);
99
+ }
100
+
101
+ getAudioTracks(): Array<MediaStreamTrack> {
102
+ return this._tracks.filter(track => track.kind === 'audio');
103
+ }
104
+
105
+ getVideoTracks(): Array<MediaStreamTrack> {
106
+ return this._tracks.filter(track => track.kind === 'video');
107
+ }
108
+
109
+ clone() {
110
+ throw new Error('Not implemented.');
111
+ }
112
+
113
+ toURL() {
114
+ return this._reactTag;
115
+ }
116
+
117
+ release(releaseTracks = true) {
118
+ const tracks = [...this._tracks];
119
+ for (const track of tracks) {
120
+ this.removeTrack(track);
121
+ if (releaseTracks) {
122
+ track.release();
123
+ }
124
+ }
125
+
126
+ WebRTCModule.mediaStreamRelease(this._reactTag);
127
+ }
139
128
  }
@@ -1,14 +1,12 @@
1
- 'use strict';
2
1
 
3
2
  export default class MediaStreamError {
3
+ name: string;
4
+ message: ?string;
5
+ constraintName: ?string;
4
6
 
5
- name: string;
6
- message: ?string;
7
- constraintName: ?string;
8
-
9
- constructor(error) {
10
- this.name = error.name;
11
- this.message = error.message;
12
- this.constraintName = error.constraintName;
13
- }
7
+ constructor(error) {
8
+ this.name = error.name;
9
+ this.message = error.message;
10
+ this.constraintName = error.constraintName;
11
+ }
14
12
  }
@@ -1,12 +1,11 @@
1
- 'use strict';
2
1
 
3
2
  import type MediaStreamError from './MediaStreamError';
4
3
 
5
4
  export default class MediaStreamErrorEvent {
6
- type: string;
7
- error: ?MediaStreamError;
8
- constructor(type, eventInitDict) {
9
- this.type = type.toString();
10
- Object.assign(this, eventInitDict);
11
- }
5
+ type: string;
6
+ error: ?MediaStreamError;
7
+ constructor(type, eventInitDict) {
8
+ this.type = type.toString();
9
+ Object.assign(this, eventInitDict);
10
+ }
12
11
  }
@@ -1,12 +1,11 @@
1
- 'use strict';
2
1
 
3
2
  import type MediaStream from './MediaStream';
4
3
 
5
4
  export default class MediaStreamEvent {
6
- type: string;
7
- stream: MediaStream;
8
- constructor(type, eventInitDict) {
9
- this.type = type.toString();
10
- Object.assign(this, eventInitDict);
11
- }
5
+ type: string;
6
+ stream: MediaStream;
7
+ constructor(type, eventInitDict) {
8
+ this.type = type.toString();
9
+ Object.assign(this, eventInitDict);
10
+ }
12
11
  }