react-native-webrtc 1.100.1 → 106.0.0-beta.1

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 (166) hide show
  1. package/ISSUE_TEMPLATE.md +17 -13
  2. package/README.md +46 -129
  3. package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +160 -165
  4. package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +279 -0
  5. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +361 -56
  6. package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +5 -1
  7. package/ios/RCTWebRTC/RCTConvert+WebRTC.m +2 -6
  8. package/ios/RCTWebRTC/ScreenCapturer.m +0 -1
  9. package/ios/RCTWebRTC/SerializeUtils.h +25 -0
  10. package/ios/RCTWebRTC/SerializeUtils.m +219 -0
  11. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +284 -128
  12. package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +216 -0
  13. package/ios/RCTWebRTC/WebRTCModule.h +15 -4
  14. package/ios/RCTWebRTC/WebRTCModule.m +26 -6
  15. package/lib/commonjs/EventEmitter.js +24 -0
  16. package/lib/commonjs/EventEmitter.js.map +1 -1
  17. package/lib/commonjs/Logger.js +65 -0
  18. package/lib/commonjs/Logger.js.map +1 -0
  19. package/lib/commonjs/MediaStream.js +1 -1
  20. package/lib/commonjs/MediaStream.js.map +1 -1
  21. package/lib/commonjs/MediaStreamTrack.js +4 -2
  22. package/lib/commonjs/MediaStreamTrack.js.map +1 -1
  23. package/lib/commonjs/Permissions.js +1 -1
  24. package/lib/commonjs/Permissions.js.map +1 -1
  25. package/lib/commonjs/RTCDataChannel.js.map +1 -1
  26. package/lib/commonjs/RTCErrorEvent.js +33 -0
  27. package/lib/commonjs/RTCErrorEvent.js.map +1 -0
  28. package/lib/commonjs/RTCPeerConnection.js +354 -103
  29. package/lib/commonjs/RTCPeerConnection.js.map +1 -1
  30. package/lib/commonjs/RTCRtcpParameters.js +24 -0
  31. package/lib/commonjs/RTCRtcpParameters.js.map +1 -0
  32. package/lib/commonjs/RTCRtpCapabilities.js +79 -0
  33. package/lib/commonjs/RTCRtpCapabilities.js.map +1 -0
  34. package/lib/commonjs/RTCRtpCodecCapability.js +25 -0
  35. package/lib/commonjs/RTCRtpCodecCapability.js.map +1 -0
  36. package/lib/commonjs/RTCRtpCodecParameters.js +33 -0
  37. package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -0
  38. package/lib/commonjs/RTCRtpEncodingParameters.js +81 -0
  39. package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -0
  40. package/lib/commonjs/RTCRtpHeaderExtension.js +27 -0
  41. package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -0
  42. package/lib/commonjs/RTCRtpParameters.js +26 -0
  43. package/lib/commonjs/RTCRtpParameters.js.map +1 -0
  44. package/lib/commonjs/RTCRtpReceiveParameters.js +20 -0
  45. package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -0
  46. package/lib/commonjs/RTCRtpReceiver.js +51 -0
  47. package/lib/commonjs/RTCRtpReceiver.js.map +1 -0
  48. package/lib/commonjs/RTCRtpSendParameters.js +60 -0
  49. package/lib/commonjs/RTCRtpSendParameters.js.map +1 -0
  50. package/lib/commonjs/RTCRtpSender.js +85 -0
  51. package/lib/commonjs/RTCRtpSender.js.map +1 -0
  52. package/lib/commonjs/RTCRtpTransceiver.js +141 -0
  53. package/lib/commonjs/RTCRtpTransceiver.js.map +1 -0
  54. package/lib/commonjs/RTCSessionDescription.js.map +1 -1
  55. package/lib/commonjs/RTCTrackEvent.js +32 -0
  56. package/lib/commonjs/RTCTrackEvent.js.map +1 -0
  57. package/lib/commonjs/RTCUtil.js +20 -37
  58. package/lib/commonjs/RTCUtil.js.map +1 -1
  59. package/lib/commonjs/getDisplayMedia.js.map +1 -1
  60. package/lib/commonjs/getUserMedia.js.map +1 -1
  61. package/lib/commonjs/index.js +127 -3
  62. package/lib/commonjs/index.js.map +1 -1
  63. package/lib/module/EventEmitter.js +21 -0
  64. package/lib/module/EventEmitter.js.map +1 -1
  65. package/lib/module/Logger.js +53 -0
  66. package/lib/module/Logger.js.map +1 -0
  67. package/lib/module/MediaStream.js +1 -1
  68. package/lib/module/MediaStream.js.map +1 -1
  69. package/lib/module/MediaStreamTrack.js +4 -2
  70. package/lib/module/MediaStreamTrack.js.map +1 -1
  71. package/lib/module/Permissions.js +1 -1
  72. package/lib/module/Permissions.js.map +1 -1
  73. package/lib/module/RTCDataChannel.js.map +1 -1
  74. package/lib/module/RTCErrorEvent.js +22 -0
  75. package/lib/module/RTCErrorEvent.js.map +1 -0
  76. package/lib/module/RTCPeerConnection.js +348 -103
  77. package/lib/module/RTCPeerConnection.js.map +1 -1
  78. package/lib/module/RTCRtcpParameters.js +15 -0
  79. package/lib/module/RTCRtcpParameters.js.map +1 -0
  80. package/lib/module/RTCRtpCapabilities.js +63 -0
  81. package/lib/module/RTCRtpCapabilities.js.map +1 -0
  82. package/lib/module/RTCRtpCodecCapability.js +16 -0
  83. package/lib/module/RTCRtpCodecCapability.js.map +1 -0
  84. package/lib/module/RTCRtpCodecParameters.js +24 -0
  85. package/lib/module/RTCRtpCodecParameters.js.map +1 -0
  86. package/lib/module/RTCRtpEncodingParameters.js +72 -0
  87. package/lib/module/RTCRtpEncodingParameters.js.map +1 -0
  88. package/lib/module/RTCRtpHeaderExtension.js +18 -0
  89. package/lib/module/RTCRtpHeaderExtension.js.map +1 -0
  90. package/lib/module/RTCRtpParameters.js +17 -0
  91. package/lib/module/RTCRtpParameters.js.map +1 -0
  92. package/lib/module/RTCRtpReceiveParameters.js +8 -0
  93. package/lib/module/RTCRtpReceiveParameters.js.map +1 -0
  94. package/lib/module/RTCRtpReceiver.js +39 -0
  95. package/lib/module/RTCRtpReceiver.js.map +1 -0
  96. package/lib/module/RTCRtpSendParameters.js +49 -0
  97. package/lib/module/RTCRtpSendParameters.js.map +1 -0
  98. package/lib/module/RTCRtpSender.js +70 -0
  99. package/lib/module/RTCRtpSender.js.map +1 -0
  100. package/lib/module/RTCRtpTransceiver.js +125 -0
  101. package/lib/module/RTCRtpTransceiver.js.map +1 -0
  102. package/lib/module/RTCSessionDescription.js.map +1 -1
  103. package/lib/module/RTCTrackEvent.js +23 -0
  104. package/lib/module/RTCTrackEvent.js.map +1 -0
  105. package/lib/module/RTCUtil.js +18 -36
  106. package/lib/module/RTCUtil.js.map +1 -1
  107. package/lib/module/getDisplayMedia.js.map +1 -1
  108. package/lib/module/getUserMedia.js.map +1 -1
  109. package/lib/module/index.js +35 -4
  110. package/lib/module/index.js.map +1 -1
  111. package/lib/typescript/EventEmitter.d.ts +3 -0
  112. package/lib/typescript/Logger.d.ts +13 -0
  113. package/lib/typescript/MediaDevices.d.ts +2 -2
  114. package/lib/typescript/MediaStream.d.ts +6 -6
  115. package/lib/typescript/MediaStreamTrack.d.ts +10 -9
  116. package/lib/typescript/RTCDataChannel.d.ts +4 -2
  117. package/lib/typescript/RTCErrorEvent.d.ts +12 -0
  118. package/lib/typescript/RTCPeerConnection.d.ts +42 -11
  119. package/lib/typescript/RTCRtcpParameters.d.ts +8 -0
  120. package/lib/typescript/RTCRtpCapabilities.d.ts +19 -0
  121. package/lib/typescript/RTCRtpCodecCapability.d.ts +7 -0
  122. package/lib/typescript/RTCRtpCodecParameters.d.ts +14 -0
  123. package/lib/typescript/RTCRtpEncodingParameters.d.ts +21 -0
  124. package/lib/typescript/RTCRtpHeaderExtension.d.ts +10 -0
  125. package/lib/typescript/RTCRtpParameters.d.ts +14 -0
  126. package/lib/typescript/RTCRtpReceiveParameters.d.ts +4 -0
  127. package/lib/typescript/RTCRtpReceiver.d.ts +15 -0
  128. package/lib/typescript/RTCRtpSendParameters.d.ts +17 -0
  129. package/lib/typescript/RTCRtpSender.d.ts +21 -0
  130. package/lib/typescript/RTCRtpTransceiver.d.ts +35 -0
  131. package/lib/typescript/RTCTrackEvent.d.ts +15 -0
  132. package/lib/typescript/RTCUtil.d.ts +5 -9
  133. package/lib/typescript/getDisplayMedia.d.ts +2 -1
  134. package/lib/typescript/getUserMedia.d.ts +2 -1
  135. package/lib/typescript/index.d.ts +16 -3
  136. package/package.json +6 -4
  137. package/react-native-webrtc.podspec +1 -1
  138. package/src/EventEmitter.ts +21 -1
  139. package/src/Logger.ts +49 -0
  140. package/src/MediaStream.ts +11 -11
  141. package/src/MediaStreamTrack.ts +14 -13
  142. package/src/Permissions.ts +1 -1
  143. package/src/RTCDataChannel.ts +11 -8
  144. package/src/RTCErrorEvent.ts +21 -0
  145. package/src/RTCPeerConnection.ts +400 -158
  146. package/src/RTCRtcpParameters.ts +14 -0
  147. package/src/RTCRtpCapabilities.ts +54 -0
  148. package/src/RTCRtpCodecCapability.ts +13 -0
  149. package/src/RTCRtpCodecParameters.ts +23 -0
  150. package/src/RTCRtpEncodingParameters.ts +67 -0
  151. package/src/RTCRtpHeaderExtension.ts +18 -0
  152. package/src/RTCRtpParameters.ts +21 -0
  153. package/src/RTCRtpReceiveParameters.ts +7 -0
  154. package/src/RTCRtpReceiver.ts +35 -0
  155. package/src/RTCRtpSendParameters.ts +51 -0
  156. package/src/RTCRtpSender.ts +72 -0
  157. package/src/RTCRtpTransceiver.ts +125 -0
  158. package/src/RTCSessionDescription.ts +3 -3
  159. package/src/RTCTrackEvent.ts +21 -0
  160. package/src/RTCUtil.ts +20 -40
  161. package/src/getDisplayMedia.ts +1 -1
  162. package/src/getUserMedia.ts +2 -2
  163. package/src/index.ts +51 -6
  164. package/tools/build-webrtc.py +32 -33
  165. package/tools/downloadBitcode.sh +2 -12
  166. package/tools/downloadWebRTC.js +21 -12
@@ -15,13 +15,14 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
15
15
  _enabled: boolean;
16
16
  _settings: object;
17
17
  _muted: boolean;
18
+ _peerConnectionId: number;
18
19
 
19
- id: string;
20
- kind: string;
21
- label: string;
20
+ readonly id: string;
21
+ readonly kind: string;
22
+ readonly label: string = "";
22
23
  readyState: MediaStreamTrackState;
23
- remote: boolean;
24
-
24
+ readonly remote: boolean;
25
+
25
26
  constructor(info) {
26
27
  super();
27
28
 
@@ -29,10 +30,10 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
29
30
  this._enabled = info.enabled;
30
31
  this._settings = info.settings || {};
31
32
  this._muted = false;
33
+ this._peerConnectionId = info.peerConnectionId;
32
34
 
33
35
  this.id = info.id;
34
36
  this.kind = info.kind;
35
- this.label = info.label;
36
37
  this.remote = info.remote;
37
38
 
38
39
  const _readyState = info.readyState.toLowerCase();
@@ -55,7 +56,7 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
55
56
  return this._muted;
56
57
  }
57
58
 
58
- stop() {
59
+ stop(): void {
59
60
  WebRTCModule.mediaStreamTrackSetEnabled(this.id, false);
60
61
  this.readyState = 'ended';
61
62
  // TODO: save some stopped flag?
@@ -68,7 +69,7 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
68
69
  * This is how the reference application (AppRTCMobile) implements camera
69
70
  * switching.
70
71
  */
71
- _switchCamera() {
72
+ _switchCamera(): void {
72
73
  if (this.remote) {
73
74
  throw new Error('Not implemented for remote tracks');
74
75
  }
@@ -78,15 +79,15 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
78
79
  WebRTCModule.mediaStreamTrackSwitchCamera(this.id);
79
80
  }
80
81
 
81
- applyConstraints() {
82
+ applyConstraints(): never {
82
83
  throw new Error('Not implemented.');
83
84
  }
84
85
 
85
- clone() {
86
+ clone(): never {
86
87
  throw new Error('Not implemented.');
87
88
  }
88
89
 
89
- getCapabilities() {
90
+ getCapabilities(): never {
90
91
  throw new Error('Not implemented.');
91
92
  }
92
93
 
@@ -97,8 +98,8 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
97
98
  getSettings() {
98
99
  return deepClone(this._settings);
99
100
  }
100
-
101
- release() {
101
+
102
+ release(): void {
102
103
  WebRTCModule.mediaStreamTrackRelease(this.id);
103
104
  }
104
105
  }
@@ -84,7 +84,7 @@ class Permissions {
84
84
  permissionDesc.name === 'camera'
85
85
  ? PermissionsAndroid.PERMISSIONS.CAMERA
86
86
  : PermissionsAndroid.PERMISSIONS.RECORD_AUDIO;
87
- return new Promise((resolve, reject) => {
87
+ return new Promise(resolve => {
88
88
  PermissionsAndroid.check(perm).then(
89
89
  granted => resolve(granted ? this.RESULT.GRANTED : this.RESULT.PROMPT),
90
90
  () => resolve(this.RESULT.PROMPT)
@@ -23,11 +23,11 @@ export default class RTCDataChannel extends defineCustomEventTarget(...DATA_CHAN
23
23
  _ordered: boolean;
24
24
  _protocol: string;
25
25
  _readyState: RTCDataChannelState;
26
- _subscriptions: Array<any> = [];
26
+ _subscriptions: any[] = [];
27
27
 
28
- binaryType: string = 'arraybuffer'; // we only support 'arraybuffer'
29
- bufferedAmount: number = 0;
30
- bufferedAmountLowThreshold: number = 0;
28
+ binaryType = 'arraybuffer'; // we only support 'arraybuffer'
29
+ bufferedAmount = 0;
30
+ bufferedAmountLowThreshold = 0;
31
31
 
32
32
  constructor(info) {
33
33
  super();
@@ -79,7 +79,10 @@ export default class RTCDataChannel extends defineCustomEventTarget(...DATA_CHAN
79
79
  return this._readyState;
80
80
  }
81
81
 
82
- send(data: string | ArrayBuffer | ArrayBufferView) {
82
+ send(data: string): void;
83
+ send(data: ArrayBuffer): void;
84
+ send(data: ArrayBufferView): void;
85
+ send(data: string | ArrayBuffer | ArrayBufferView): void {
83
86
  if (typeof data === 'string') {
84
87
  WebRTCModule.dataChannelSend(this._peerConnectionId, this._reactTag, data, 'text');
85
88
  return;
@@ -96,19 +99,19 @@ export default class RTCDataChannel extends defineCustomEventTarget(...DATA_CHAN
96
99
  WebRTCModule.dataChannelSend(this._peerConnectionId, this._reactTag, base64.fromByteArray(data as Uint8Array), 'binary');
97
100
  }
98
101
 
99
- close() {
102
+ close(): void {
100
103
  if (this._readyState === 'closing' || this._readyState === 'closed') {
101
104
  return;
102
105
  }
103
106
  WebRTCModule.dataChannelClose(this._peerConnectionId, this._reactTag);
104
107
  }
105
108
 
106
- _unregisterEvents() {
109
+ _unregisterEvents(): void {
107
110
  this._subscriptions.forEach(e => e.remove());
108
111
  this._subscriptions = [];
109
112
  }
110
113
 
111
- _registerEvents() {
114
+ _registerEvents(): void {
112
115
  this._subscriptions = [
113
116
  EventEmitter.addListener('dataChannelStateChanged', ev => {
114
117
  if (ev.reactTag !== this._reactTag) {
@@ -0,0 +1,21 @@
1
+ import RTCEvent from "./RTCEvent";
2
+
3
+ type RTCPeerConnectionErrorFunc =
4
+ | 'addTransceiver'
5
+ | 'getTransceivers'
6
+ | 'addTrack'
7
+ | 'removeTrack';
8
+
9
+ /**
10
+ * @brief This class Represents internal error happening on the native side as
11
+ * part of asynchronous invocations to synchronous web APIs.
12
+ */
13
+ export default class RTCErrorEvent extends RTCEvent {
14
+ readonly func: RTCPeerConnectionErrorFunc;
15
+ readonly message: string;
16
+ constructor(type: string, func: RTCPeerConnectionErrorFunc, message: string) {
17
+ super(type);
18
+ this.func = func;
19
+ this.message = message;
20
+ }
21
+ }