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.
Files changed (69) hide show
  1. package/.prettierignore +9 -0
  2. package/.prettierrc.json +10 -0
  3. package/README.md +4 -1
  4. package/android/libs/.placeholder +0 -0
  5. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +0 -5
  6. package/android/src/main/java/com/oney/WebRTCModule/LibraryLoader.java +21 -0
  7. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +301 -324
  8. package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +9 -84
  9. package/apple/.placeholder +0 -0
  10. package/ios/RCTWebRTC/RCTConvert+WebRTC.m +3 -0
  11. package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +4 -1
  12. package/ios/RCTWebRTC/VideoCaptureController.h +2 -2
  13. package/ios/RCTWebRTC/VideoCaptureController.m +131 -48
  14. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +56 -26
  15. package/metro.config.js +3 -4
  16. package/metro.config.macos.js +7 -8
  17. package/package.json +21 -12
  18. package/react-native.config.js +5 -6
  19. package/{EventEmitter.js → src/EventEmitter.js} +1 -1
  20. package/{MediaDevices.js → src/MediaDevices.js} +6 -12
  21. package/src/MediaStream.js +128 -0
  22. package/src/MediaStreamError.js +12 -0
  23. package/src/MediaStreamErrorEvent.js +11 -0
  24. package/src/MediaStreamEvent.js +11 -0
  25. package/src/MediaStreamTrack.js +104 -0
  26. package/src/MediaStreamTrackEvent.js +11 -0
  27. package/src/MessageEvent.js +10 -0
  28. package/{Permissions.js → src/Permissions.js} +26 -23
  29. package/src/RTCDataChannel.js +143 -0
  30. package/src/RTCDataChannelEvent.js +11 -0
  31. package/src/RTCEvent.js +8 -0
  32. package/src/RTCIceCandidate.js +20 -0
  33. package/src/RTCIceCandidateEvent.js +15 -0
  34. package/src/RTCPeerConnection.js +349 -0
  35. package/src/RTCSessionDescription.js +22 -0
  36. package/{RTCUtil.js → src/RTCUtil.js} +56 -57
  37. package/src/RTCView.js +60 -0
  38. package/src/ScreenCapturePickerView.js +4 -0
  39. package/{getDisplayMedia.js → src/getDisplayMedia.js} +8 -11
  40. package/src/getUserMedia.js +98 -0
  41. package/src/index.js +44 -0
  42. package/tools/build-webrtc.py +60 -46
  43. package/tools/downloadBitcode.sh +4 -16
  44. package/tools/downloadWebRTC.js +100 -0
  45. package/MediaStream.js +0 -138
  46. package/MediaStreamError.js +0 -14
  47. package/MediaStreamErrorEvent.js +0 -12
  48. package/MediaStreamEvent.js +0 -12
  49. package/MediaStreamTrack.js +0 -118
  50. package/MediaStreamTrackEvent.js +0 -12
  51. package/MessageEvent.js +0 -11
  52. package/RTCDataChannel.js +0 -161
  53. package/RTCDataChannelEvent.js +0 -12
  54. package/RTCEvent.js +0 -9
  55. package/RTCIceCandidate.js +0 -21
  56. package/RTCIceCandidateEvent.js +0 -16
  57. package/RTCPeerConnection.js +0 -390
  58. package/RTCSessionDescription.js +0 -23
  59. package/RTCView.js +0 -70
  60. package/ScreenCapturePickerView.js +0 -7
  61. package/android/libs/libjingle_peerconnection.so.jar +0 -0
  62. package/android/libs/libwebrtc.jar +0 -0
  63. package/apple/WebRTC.xcframework.tgz +0 -0
  64. package/getUserMedia.js +0 -98
  65. package/index.js +0 -47
  66. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  67. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  68. package/ios/RCTWebRTC.xcodeproj/project.xcworkspace/xcuserdata/saghul.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  69. package/ios/RCTWebRTC.xcodeproj/xcuserdata/saghul.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -1,118 +0,0 @@
1
- 'use strict';
2
-
3
- import {NativeModules} from 'react-native';
4
- import EventTarget from 'event-target-shim';
5
- import MediaStreamErrorEvent from './MediaStreamErrorEvent';
6
- import type MediaStreamError from './MediaStreamError';
7
- import { deepClone } from './RTCUtil';
8
-
9
- const {WebRTCModule} = NativeModules;
10
-
11
- const MEDIA_STREAM_TRACK_EVENTS = [
12
- 'ended',
13
- 'mute',
14
- 'unmute',
15
- // see: https://www.w3.org/TR/mediacapture-streams/#constrainable-interface
16
- 'overconstrained',
17
- ];
18
-
19
- type MediaStreamTrackState = "live" | "ended";
20
-
21
- class MediaStreamTrack extends EventTarget(MEDIA_STREAM_TRACK_EVENTS) {
22
- _constraints: Object;
23
- _enabled: boolean;
24
- _settings: Object;
25
-
26
- id: string;
27
- kind: string;
28
- label: string;
29
- muted: boolean;
30
- // readyState in java: INITIALIZING, LIVE, ENDED, FAILED
31
- readyState: MediaStreamTrackState;
32
- remote: boolean;
33
-
34
- onended: ?Function;
35
- onmute: ?Function;
36
- onunmute: ?Function;
37
- overconstrained: ?Function;
38
-
39
- constructor(info) {
40
- super();
41
-
42
- this._constraints = info.constraints || {};
43
- this._enabled = info.enabled;
44
- this._settings = info.settings || {};
45
-
46
- this.id = info.id;
47
- this.kind = info.kind;
48
- this.label = info.label;
49
- this.muted = false;
50
- this.remote = info.remote;
51
-
52
- const _readyState = info.readyState.toLowerCase();
53
- this.readyState = (_readyState === "initializing"
54
- || _readyState === "live") ? "live" : "ended";
55
- }
56
-
57
- get enabled(): boolean {
58
- return this._enabled;
59
- }
60
-
61
- set enabled(enabled: boolean): void {
62
- if (enabled === this._enabled) {
63
- return;
64
- }
65
- WebRTCModule.mediaStreamTrackSetEnabled(this.id, !this._enabled);
66
- this._enabled = !this._enabled;
67
- this.muted = !this._enabled;
68
- }
69
-
70
- stop() {
71
- WebRTCModule.mediaStreamTrackSetEnabled(this.id, false);
72
- this.readyState = 'ended';
73
- // TODO: save some stopped flag?
74
- }
75
-
76
- /**
77
- * Private / custom API for switching the cameras on the fly, without the
78
- * need for adding / removing tracks or doing any SDP renegotiation.
79
- *
80
- * This is how the reference application (AppRTCMobile) implements camera
81
- * switching.
82
- */
83
- _switchCamera() {
84
- if (this.remote) {
85
- throw new Error('Not implemented for remote tracks');
86
- }
87
- if (this.kind !== 'video') {
88
- throw new Error('Only implemented for video tracks');
89
- }
90
- WebRTCModule.mediaStreamTrackSwitchCamera(this.id);
91
- }
92
-
93
- applyConstraints() {
94
- throw new Error('Not implemented.');
95
- }
96
-
97
- clone() {
98
- throw new Error('Not implemented.');
99
- }
100
-
101
- getCapabilities() {
102
- throw new Error('Not implemented.');
103
- }
104
-
105
- getConstraints() {
106
- return deepClone(this._constraints);
107
- }
108
-
109
- getSettings() {
110
- return deepClone(this._settings);
111
- }
112
-
113
- release() {
114
- WebRTCModule.mediaStreamTrackRelease(this.id);
115
- }
116
- }
117
-
118
- export default MediaStreamTrack;
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- import type MediaStreamTrack from './MediaStreamTrack';
4
-
5
- export default class MediaStreamTrackEvent {
6
- type: string;
7
- track: MediaStreamTrack;
8
- constructor(type, eventInitDict) {
9
- this.type = type.toString();
10
- Object.assign(this, eventInitDict);
11
- }
12
- }
package/MessageEvent.js DELETED
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- export default class MessageEvent {
4
- type: string;
5
- data: string | ArrayBuffer | Blob;
6
- origin: string;
7
- constructor(type, eventInitDict) {
8
- this.type = type.toString();
9
- Object.assign(this, eventInitDict);
10
- }
11
- }
package/RTCDataChannel.js DELETED
@@ -1,161 +0,0 @@
1
- 'use strict';
2
-
3
- import { NativeModules } from 'react-native';
4
- import base64 from 'base64-js';
5
- import EventTarget from 'event-target-shim';
6
- import MessageEvent from './MessageEvent';
7
- import RTCDataChannelEvent from './RTCDataChannelEvent';
8
- import EventEmitter from './EventEmitter';
9
-
10
- const {WebRTCModule} = NativeModules;
11
-
12
- type RTCDataChannelState =
13
- 'connecting' |
14
- 'open' |
15
- 'closing' |
16
- 'closed';
17
-
18
- const DATA_CHANNEL_EVENTS = [
19
- 'open',
20
- 'message',
21
- 'bufferedamountlow',
22
- 'closing',
23
- 'close',
24
- 'error',
25
- ];
26
-
27
- export default class RTCDataChannel extends EventTarget(DATA_CHANNEL_EVENTS) {
28
- _peerConnectionId: number;
29
- _reactTag: string;
30
-
31
- _id: number;
32
- _label: string;
33
- _maxPacketLifeTime: ?number;
34
- _maxRetransmits: ?number;
35
- _negotiated: boolean;
36
- _ordered: boolean;
37
- _protocol: string;
38
- _readyState: RTCDataChannelState;
39
-
40
- binaryType: 'arraybuffer' = 'arraybuffer'; // we only support 'arraybuffer'
41
- bufferedAmount: number = 0;
42
- bufferedAmountLowThreshold: number = 0;
43
-
44
- onopen: ?Function;
45
- onmessage: ?Function;
46
- onbufferedamountlow: ?Function;
47
- onerror: ?Function;
48
- onclose: ?Function;
49
-
50
- constructor(info) {
51
- super();
52
-
53
- this._peerConnectionId = info.peerConnectionId;
54
- this._reactTag = info.reactTag;
55
-
56
- this._label = info.label;
57
- this._id = info.id === -1 ? null : info.id; // null until negotiated.
58
- this._ordered = Boolean(info.ordered);
59
- this._maxPacketLifeTime = info.maxPacketLifeTime;
60
- this._maxRetransmits = info.maxRetransmits;
61
- this._protocol = info.protocol || '';
62
- this._negotiated = Boolean(info.negotiated);
63
- this._readyState = info.readyState;
64
-
65
- this._registerEvents();
66
- }
67
-
68
- get label(): string {
69
- return this._label;
70
- }
71
-
72
- get id(): number {
73
- return this._id;
74
- }
75
-
76
- get ordered(): boolean {
77
- return this._ordered;
78
- }
79
-
80
- get maxPacketLifeTime(): number {
81
- return this._maxPacketLifeTime;
82
- }
83
-
84
- get maxRetransmits(): number {
85
- return this._maxRetransmits;
86
- }
87
-
88
- get protocol(): string {
89
- return this._protocol;
90
- }
91
-
92
- get negotiated(): boolean {
93
- return this._negotiated;
94
- }
95
-
96
- get readyState(): string {
97
- return this._readyState;
98
- }
99
-
100
- send(data: string | ArrayBuffer | ArrayBufferView) {
101
- if (typeof data === 'string') {
102
- WebRTCModule.dataChannelSend(this._peerConnectionId, this._reactTag, data, 'text');
103
- return;
104
- }
105
-
106
- // Safely convert the buffer object to an Uint8Array for base64-encoding
107
- if (ArrayBuffer.isView(data)) {
108
- data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
109
- } else if (data instanceof ArrayBuffer) {
110
- data = new Uint8Array(data);
111
- } else {
112
- throw new TypeError('Data must be either string, ArrayBuffer, or ArrayBufferView');
113
- }
114
- WebRTCModule.dataChannelSend(this._peerConnectionId, this._reactTag, base64.fromByteArray(data), 'binary');
115
- }
116
-
117
- close() {
118
- if (this._readyState === 'closing' || this._readyState === 'closed') {
119
- return;
120
- }
121
- WebRTCModule.dataChannelClose(this._peerConnectionId, this._reactTag);
122
- }
123
-
124
- _unregisterEvents() {
125
- this._subscriptions.forEach(e => e.remove());
126
- this._subscriptions = [];
127
- }
128
-
129
- _registerEvents() {
130
- this._subscriptions = [
131
- EventEmitter.addListener('dataChannelStateChanged', ev => {
132
- if (ev.reactTag !== this._reactTag) {
133
- return;
134
- }
135
- this._readyState = ev.state;
136
- if (this._id === null && ev.id !== -1) {
137
- this._id = ev.id;
138
- }
139
- if (this._readyState === 'open') {
140
- this.dispatchEvent(new RTCDataChannelEvent('open', {channel: this}));
141
- } else if (this._readyState === 'closing') {
142
- this.dispatchEvent(new RTCDataChannelEvent('closing', {channel: this}));
143
- } else if (this._readyState === 'closed') {
144
- this.dispatchEvent(new RTCDataChannelEvent('close', {channel: this}));
145
- this._unregisterEvents();
146
- WebRTCModule.dataChannelDispose(this._peerConnectionId, this._reactTag);
147
- }
148
- }),
149
- EventEmitter.addListener('dataChannelReceiveMessage', ev => {
150
- if (ev.reactTag !== this._reactTag) {
151
- return;
152
- }
153
- let data = ev.data;
154
- if (ev.type === 'binary') {
155
- data = base64.toByteArray(ev.data).buffer;
156
- }
157
- this.dispatchEvent(new MessageEvent('message', {data}));
158
- }),
159
- ];
160
- }
161
- }
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- import type RTCDataChannel from './RTCDataChannel';
4
-
5
- export default class RTCDataChannelEvent {
6
- type: string;
7
- channel: RTCDataChannel;
8
- constructor(type, eventInitDict) {
9
- this.type = type.toString();
10
- Object.assign(this, eventInitDict);
11
- }
12
- }
package/RTCEvent.js DELETED
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- export default class RTCEvent {
4
- type: string;
5
- constructor(type, eventInitDict) {
6
- this.type = type.toString();
7
- Object.assign(this, eventInitDict);
8
- }
9
- }
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- export default class RTCIceCandidate {
4
- candidate: string;
5
- sdpMLineIndex: number;
6
- sdpMid: string;
7
-
8
- constructor(info) {
9
- this.candidate = info.candidate;
10
- this.sdpMLineIndex = info.sdpMLineIndex;
11
- this.sdpMid = info.sdpMid;
12
- }
13
-
14
- toJSON() {
15
- return {
16
- candidate: this.candidate,
17
- sdpMLineIndex: this.sdpMLineIndex,
18
- sdpMid: this.sdpMid,
19
- };
20
- }
21
- }
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- import type RTCIceCandidate from './RTCIceCandidate';
4
-
5
- export default class RTCIceCandidateEvent {
6
- type: string;
7
- candidate: RTCIceCandidate;
8
- constructor(type, eventInitDict) {
9
- this.type = type.toString();
10
-
11
- this.candidate = null;
12
- if (eventInitDict && eventInitDict.candidate) {
13
- this.candidate = eventInitDict.candidate;
14
- }
15
- }
16
- }