react-native-webrtc 124.0.6 → 124.0.8

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 (134) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/.eslintignore +1 -0
  3. package/CLAUDE.md +714 -0
  4. package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +5 -3
  5. package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +74 -8
  6. package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +24 -3
  7. package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +4 -4
  8. package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +8 -0
  9. package/android/src/main/java/com/oney/WebRTCModule/ThreadUtils.java +8 -0
  10. package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +112 -26
  11. package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +56 -28
  12. package/ios/RCTWebRTC/RCTConvert+WebRTC.m +19 -0
  13. package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +22 -23
  14. package/ios/RCTWebRTC/SerializeUtils.m +6 -0
  15. package/ios/RCTWebRTC/VideoCaptureController.m +40 -1
  16. package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +23 -9
  17. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.h +2 -0
  18. package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +95 -0
  19. package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +1 -0
  20. package/lib/commonjs/MediaDevices.js +12 -10
  21. package/lib/commonjs/MediaDevices.js.map +1 -1
  22. package/lib/commonjs/MediaStream.js +14 -9
  23. package/lib/commonjs/MediaStream.js.map +1 -1
  24. package/lib/commonjs/MediaStreamTrack.js +28 -12
  25. package/lib/commonjs/MediaStreamTrack.js.map +1 -1
  26. package/lib/commonjs/MediaStreamTrackEvent.js +2 -2
  27. package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -1
  28. package/lib/commonjs/MessageEvent.js +2 -2
  29. package/lib/commonjs/MessageEvent.js.map +1 -1
  30. package/lib/commonjs/Permissions.js +3 -3
  31. package/lib/commonjs/Permissions.js.map +1 -1
  32. package/lib/commonjs/RTCCertificate.js +25 -0
  33. package/lib/commonjs/RTCCertificate.js.map +1 -0
  34. package/lib/commonjs/RTCDataChannel.js +38 -13
  35. package/lib/commonjs/RTCDataChannel.js.map +1 -1
  36. package/lib/commonjs/RTCDataChannelEvent.js +2 -2
  37. package/lib/commonjs/RTCDataChannelEvent.js.map +1 -1
  38. package/lib/commonjs/RTCErrorEvent.js +2 -2
  39. package/lib/commonjs/RTCErrorEvent.js.map +1 -1
  40. package/lib/commonjs/RTCIceCandidateEvent.js +2 -2
  41. package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -1
  42. package/lib/commonjs/RTCPeerConnection.js +109 -27
  43. package/lib/commonjs/RTCPeerConnection.js.map +1 -1
  44. package/lib/commonjs/RTCRtpEncodingParameters.js +17 -1
  45. package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
  46. package/lib/commonjs/RTCTrackEvent.js +2 -2
  47. package/lib/commonjs/RTCTrackEvent.js.map +1 -1
  48. package/lib/commonjs/RTCUtil.js +1 -1
  49. package/lib/commonjs/RTCUtil.js.map +1 -1
  50. package/lib/commonjs/getDisplayMedia.js +2 -1
  51. package/lib/commonjs/getDisplayMedia.js.map +1 -1
  52. package/lib/commonjs/index.js +22 -2
  53. package/lib/commonjs/index.js.map +1 -1
  54. package/lib/commonjs/vendor/event-target-shim/LICENSE +22 -0
  55. package/lib/commonjs/vendor/event-target-shim/index.d.js +6 -0
  56. package/lib/commonjs/vendor/event-target-shim/index.d.js.map +1 -0
  57. package/lib/commonjs/vendor/event-target-shim/index.js +1221 -0
  58. package/lib/commonjs/vendor/event-target-shim/index.js.map +1 -0
  59. package/lib/module/MediaDevices.js +11 -9
  60. package/lib/module/MediaDevices.js.map +1 -1
  61. package/lib/module/MediaStream.js +13 -8
  62. package/lib/module/MediaStream.js.map +1 -1
  63. package/lib/module/MediaStreamTrack.js +25 -9
  64. package/lib/module/MediaStreamTrack.js.map +1 -1
  65. package/lib/module/MediaStreamTrackEvent.js +1 -1
  66. package/lib/module/MediaStreamTrackEvent.js.map +1 -1
  67. package/lib/module/MessageEvent.js +1 -1
  68. package/lib/module/MessageEvent.js.map +1 -1
  69. package/lib/module/Permissions.js +3 -3
  70. package/lib/module/Permissions.js.map +1 -1
  71. package/lib/module/RTCCertificate.js +18 -0
  72. package/lib/module/RTCCertificate.js.map +1 -0
  73. package/lib/module/RTCDataChannel.js +37 -12
  74. package/lib/module/RTCDataChannel.js.map +1 -1
  75. package/lib/module/RTCDataChannelEvent.js +1 -1
  76. package/lib/module/RTCDataChannelEvent.js.map +1 -1
  77. package/lib/module/RTCErrorEvent.js +1 -1
  78. package/lib/module/RTCErrorEvent.js.map +1 -1
  79. package/lib/module/RTCIceCandidateEvent.js +1 -1
  80. package/lib/module/RTCIceCandidateEvent.js.map +1 -1
  81. package/lib/module/RTCPeerConnection.js +103 -21
  82. package/lib/module/RTCPeerConnection.js.map +1 -1
  83. package/lib/module/RTCRtpEncodingParameters.js +17 -1
  84. package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
  85. package/lib/module/RTCTrackEvent.js +1 -1
  86. package/lib/module/RTCTrackEvent.js.map +1 -1
  87. package/lib/module/RTCUtil.js +1 -1
  88. package/lib/module/RTCUtil.js.map +1 -1
  89. package/lib/module/getDisplayMedia.js +2 -1
  90. package/lib/module/getDisplayMedia.js.map +1 -1
  91. package/lib/module/index.js +5 -3
  92. package/lib/module/index.js.map +1 -1
  93. package/lib/module/vendor/event-target-shim/LICENSE +22 -0
  94. package/lib/module/vendor/event-target-shim/index.d.js +52 -0
  95. package/lib/module/vendor/event-target-shim/index.d.js.map +1 -0
  96. package/lib/module/vendor/event-target-shim/index.js +1221 -0
  97. package/lib/module/vendor/event-target-shim/index.js.map +1 -0
  98. package/lib/typescript/MediaDevices.d.ts +8 -4
  99. package/lib/typescript/MediaStream.d.ts +5 -1
  100. package/lib/typescript/MediaStreamTrack.d.ts +7 -1
  101. package/lib/typescript/MediaStreamTrackEvent.d.ts +1 -1
  102. package/lib/typescript/MessageEvent.d.ts +1 -1
  103. package/lib/typescript/Permissions.d.ts +1 -1
  104. package/lib/typescript/RTCCertificate.d.ts +16 -0
  105. package/lib/typescript/RTCDataChannel.d.ts +13 -1
  106. package/lib/typescript/RTCDataChannelEvent.d.ts +1 -1
  107. package/lib/typescript/RTCErrorEvent.d.ts +1 -1
  108. package/lib/typescript/RTCIceCandidateEvent.d.ts +1 -1
  109. package/lib/typescript/RTCPeerConnection.d.ts +30 -1
  110. package/lib/typescript/RTCRtpEncodingParameters.d.ts +4 -0
  111. package/lib/typescript/RTCTrackEvent.d.ts +1 -1
  112. package/lib/typescript/getDisplayMedia.d.ts +7 -1
  113. package/lib/typescript/index.d.ts +4 -1
  114. package/package.json +2 -3
  115. package/src/MediaDevices.ts +15 -14
  116. package/src/MediaStream.ts +17 -9
  117. package/src/MediaStreamTrack.ts +30 -10
  118. package/src/MediaStreamTrackEvent.ts +2 -2
  119. package/src/MessageEvent.ts +1 -1
  120. package/src/Permissions.ts +3 -3
  121. package/src/RTCCertificate.ts +24 -0
  122. package/src/RTCDataChannel.ts +49 -14
  123. package/src/RTCDataChannelEvent.ts +2 -2
  124. package/src/RTCErrorEvent.ts +1 -1
  125. package/src/RTCIceCandidateEvent.ts +2 -2
  126. package/src/RTCPeerConnection.ts +138 -24
  127. package/src/RTCRtpEncodingParameters.ts +20 -0
  128. package/src/RTCTrackEvent.ts +1 -1
  129. package/src/RTCUtil.ts +1 -1
  130. package/src/getDisplayMedia.ts +9 -2
  131. package/src/index.ts +9 -2
  132. package/src/vendor/event-target-shim/LICENSE +22 -0
  133. package/src/vendor/event-target-shim/index.d.ts +411 -0
  134. package/src/vendor/event-target-shim/index.js +1186 -0
@@ -1,10 +1,10 @@
1
- import { EventTarget, Event, defineEventAttribute } from 'event-target-shim/index';
2
1
  import { NativeModules } from 'react-native';
3
2
 
4
3
  import { MediaTrackConstraints } from './Constraints';
5
4
  import { addListener, removeListener } from './EventEmitter';
6
5
  import Logger from './Logger';
7
6
  import { deepClone, normalizeConstraints } from './RTCUtil';
7
+ import { Event, EventTarget, getEventAttributeValue, setEventAttributeValue } from './vendor/event-target-shim';
8
8
 
9
9
  const log = new Logger('pc');
10
10
  const { WebRTCModule } = NativeModules;
@@ -70,6 +70,30 @@ export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventM
70
70
  }
71
71
  }
72
72
 
73
+ get onended() {
74
+ return getEventAttributeValue(this, 'ended');
75
+ }
76
+
77
+ set onended(value) {
78
+ setEventAttributeValue(this, 'ended', value);
79
+ }
80
+
81
+ get onmute() {
82
+ return getEventAttributeValue(this, 'mute');
83
+ }
84
+
85
+ set onmute(value) {
86
+ setEventAttributeValue(this, 'mute', value);
87
+ }
88
+
89
+ get onunmute() {
90
+ return getEventAttributeValue(this, 'unmute');
91
+ }
92
+
93
+ set onunmute(value) {
94
+ setEventAttributeValue(this, 'unmute', value);
95
+ }
96
+
73
97
  get enabled(): boolean {
74
98
  return this._enabled;
75
99
  }
@@ -186,6 +210,11 @@ export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventM
186
210
  throw new Error('Only implemented for video tracks');
187
211
  }
188
212
 
213
+ // Preserve current facing mode when user doesn't specify one
214
+ if (constraints && !constraints?.facingMode && this._settings?.facingMode) {
215
+ constraints.facingMode = this._settings.facingMode;
216
+ }
217
+
189
218
  const normalized = normalizeConstraints({ video: constraints ?? true });
190
219
 
191
220
  this._settings = await WebRTCModule.mediaStreamTrackApplyConstraints(this.id, normalized.video);
@@ -230,12 +259,3 @@ export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventM
230
259
  WebRTCModule.mediaStreamTrackRelease(this.id);
231
260
  }
232
261
  }
233
-
234
- /**
235
- * Define the `onxxx` event handlers.
236
- */
237
- const proto = MediaStreamTrack.prototype;
238
-
239
- defineEventAttribute(proto, 'ended');
240
- defineEventAttribute(proto, 'mute');
241
- defineEventAttribute(proto, 'unmute');
@@ -1,6 +1,6 @@
1
- import { Event } from 'event-target-shim/index';
2
-
3
1
  import type MediaStreamTrack from './MediaStreamTrack';
2
+ import { Event } from './vendor/event-target-shim';
3
+
4
4
 
5
5
  type MEDIA_STREAM_EVENTS = 'addtrack'| 'removetrack'
6
6
 
@@ -1,4 +1,4 @@
1
- import { Event } from 'event-target-shim/index';
1
+ import { Event } from './vendor/event-target-shim';
2
2
 
3
3
  export type MessageEventData = string | ArrayBuffer | Blob;
4
4
 
@@ -55,7 +55,7 @@ class Permissions {
55
55
  /**
56
56
  * Validates the given permission descriptor.
57
57
  */
58
- _validatePermissionDescriptior(permissionDesc) {
58
+ _validatePermissionDescriptor(permissionDesc) {
59
59
  if (typeof permissionDesc !== 'object') {
60
60
  throw new TypeError('Argument 1 of Permissions.query is not an object.');
61
61
  }
@@ -77,7 +77,7 @@ class Permissions {
77
77
  */
78
78
  query(permissionDesc: PermissionDescriptor) {
79
79
  try {
80
- this._validatePermissionDescriptior(permissionDesc);
80
+ this._validatePermissionDescriptor(permissionDesc);
81
81
  } catch (e) {
82
82
  return Promise.reject(e);
83
83
  }
@@ -107,7 +107,7 @@ class Permissions {
107
107
  */
108
108
  request(permissionDesc: PermissionDescriptor) {
109
109
  try {
110
- this._validatePermissionDescriptior(permissionDesc);
110
+ this._validatePermissionDescriptor(permissionDesc);
111
111
  } catch (e) {
112
112
  return Promise.reject(e);
113
113
  }
@@ -0,0 +1,24 @@
1
+ export type RTCCertificateFingerprint = {
2
+ algorithm: string;
3
+ value: string;
4
+ };
5
+
6
+ export default class RTCCertificate {
7
+ _expires: number;
8
+ _fingerprints: RTCCertificateFingerprint[];
9
+ _id: string;
10
+
11
+ constructor(info: { certificateId: string, expires: number, fingerprints: RTCCertificateFingerprint[] }) {
12
+ this._id = info.certificateId;
13
+ this._expires = info.expires;
14
+ this._fingerprints = info.fingerprints;
15
+ }
16
+
17
+ get expires(): number {
18
+ return this._expires;
19
+ }
20
+
21
+ getFingerprints(): RTCCertificateFingerprint[] {
22
+ return this._fingerprints;
23
+ }
24
+ }
@@ -1,10 +1,10 @@
1
1
  import * as base64 from 'base64-js';
2
- import { EventTarget, defineEventAttribute } from 'event-target-shim/index';
3
2
  import { NativeModules } from 'react-native';
4
3
 
5
4
  import { addListener, removeListener } from './EventEmitter';
6
5
  import MessageEvent from './MessageEvent';
7
6
  import RTCDataChannelEvent from './RTCDataChannelEvent';
7
+ import { EventTarget, getEventAttributeValue, setEventAttributeValue } from './vendor/event-target-shim';
8
8
 
9
9
  const { WebRTCModule } = NativeModules;
10
10
 
@@ -22,7 +22,6 @@ type DataChannelEventMap = {
22
22
  export default class RTCDataChannel extends EventTarget<DataChannelEventMap> {
23
23
  _peerConnectionId: number;
24
24
  _reactTag: string;
25
-
26
25
  _bufferedAmount: number;
27
26
  _id: number;
28
27
  _label: string;
@@ -55,6 +54,54 @@ export default class RTCDataChannel extends EventTarget<DataChannelEventMap> {
55
54
  this._registerEvents();
56
55
  }
57
56
 
57
+ get onbufferedamountlow() {
58
+ return getEventAttributeValue(this, 'bufferedamountlow');
59
+ }
60
+
61
+ set onbufferedamountlow(value) {
62
+ setEventAttributeValue(this, 'bufferedamountlow', value);
63
+ }
64
+
65
+ get onclose() {
66
+ return getEventAttributeValue(this, 'close');
67
+ }
68
+
69
+ set onclose(value) {
70
+ setEventAttributeValue(this, 'close', value);
71
+ }
72
+
73
+ get onclosing() {
74
+ return getEventAttributeValue(this, 'closing');
75
+ }
76
+
77
+ set onclosing(value) {
78
+ setEventAttributeValue(this, 'closing', value);
79
+ }
80
+
81
+ get onerror() {
82
+ return getEventAttributeValue(this, 'error');
83
+ }
84
+
85
+ set onerror(value) {
86
+ setEventAttributeValue(this, 'error', value);
87
+ }
88
+
89
+ get onmessage() {
90
+ return getEventAttributeValue(this, 'message');
91
+ }
92
+
93
+ set onmessage(value) {
94
+ setEventAttributeValue(this, 'message', value);
95
+ }
96
+
97
+ get onopen() {
98
+ return getEventAttributeValue(this, 'open');
99
+ }
100
+
101
+ set onopen(value) {
102
+ setEventAttributeValue(this, 'open', value);
103
+ }
104
+
58
105
  get bufferedAmount(): number {
59
106
  return this._bufferedAmount;
60
107
  }
@@ -176,15 +223,3 @@ export default class RTCDataChannel extends EventTarget<DataChannelEventMap> {
176
223
  });
177
224
  }
178
225
  }
179
-
180
- /**
181
- * Define the `onxxx` event handlers.
182
- */
183
- const proto = RTCDataChannel.prototype;
184
-
185
- defineEventAttribute(proto, 'bufferedamountlow');
186
- defineEventAttribute(proto, 'close');
187
- defineEventAttribute(proto, 'closing');
188
- defineEventAttribute(proto, 'error');
189
- defineEventAttribute(proto, 'message');
190
- defineEventAttribute(proto, 'open');
@@ -1,6 +1,6 @@
1
- import { Event } from 'event-target-shim/index';
2
-
3
1
  import type RTCDataChannel from './RTCDataChannel';
2
+ import { Event } from './vendor/event-target-shim';
3
+
4
4
 
5
5
  type DATA_CHANNEL_EVENTS = 'open'| 'message'| 'bufferedamountlow'| 'closing'| 'close'| 'error' | 'datachannel';
6
6
 
@@ -1,4 +1,4 @@
1
- import { Event } from 'event-target-shim/index';
1
+ import { Event } from './vendor/event-target-shim';
2
2
 
3
3
  type RTCPeerConnectionErrorFunc =
4
4
  | 'addTransceiver'
@@ -1,6 +1,6 @@
1
- import { Event } from 'event-target-shim/index';
2
-
3
1
  import type RTCIceCandidate from './RTCIceCandidate';
2
+ import { Event } from './vendor/event-target-shim';
3
+
4
4
 
5
5
  type RTC_ICECANDIDATE_EVENTS = 'icecandidate' | 'icecandidateerror'
6
6
 
@@ -1,4 +1,3 @@
1
- import { EventTarget, Event, defineEventAttribute } from 'event-target-shim/index';
2
1
  import { NativeModules } from 'react-native';
3
2
 
4
3
  import { addListener, removeListener } from './EventEmitter';
@@ -6,6 +5,7 @@ import Logger from './Logger';
6
5
  import MediaStream from './MediaStream';
7
6
  import MediaStreamTrack from './MediaStreamTrack';
8
7
  import MediaStreamTrackEvent from './MediaStreamTrackEvent';
8
+ import RTCCertificate from './RTCCertificate';
9
9
  import RTCDataChannel from './RTCDataChannel';
10
10
  import RTCDataChannelEvent from './RTCDataChannelEvent';
11
11
  import RTCIceCandidate from './RTCIceCandidate';
@@ -19,6 +19,7 @@ import RTCSessionDescription, { RTCSessionDescriptionInit } from './RTCSessionDe
19
19
  import RTCTrackEvent from './RTCTrackEvent';
20
20
  import * as RTCUtil from './RTCUtil';
21
21
  import { RTCOfferOptions } from './RTCUtil';
22
+ import { Event, EventTarget, getEventAttributeValue, setEventAttributeValue } from './vendor/event-target-shim';
22
23
 
23
24
  const log = new Logger('pc');
24
25
  const { WebRTCModule } = NativeModules;
@@ -55,6 +56,7 @@ type RTCIceServer = {
55
56
 
56
57
  type RTCConfiguration = {
57
58
  bundlePolicy?: 'balanced' | 'max-compat' | 'max-bundle',
59
+ certificates?: RTCCertificate[],
58
60
  iceCandidatePoolSize?: number,
59
61
  iceServers?: RTCIceServer[],
60
62
  iceTransportPolicy?: 'all' | 'relay',
@@ -89,6 +91,40 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
89
91
  _remoteStreams: Map<string, MediaStream>;
90
92
  _pendingTrackEvents: any[];
91
93
 
94
+ static generateCertificate(
95
+ keygenAlgorithm: string | {
96
+ name: string,
97
+ namedCurve?: string,
98
+ modulusLength?: number,
99
+ publicExponent?: Uint8Array,
100
+ hash?: string
101
+ }
102
+ ): Promise<RTCCertificate> {
103
+ const options: { keyType?: string, expires?: number } = {};
104
+
105
+ let algorithm = keygenAlgorithm;
106
+
107
+ if (typeof algorithm === 'string') {
108
+ algorithm = { name: algorithm };
109
+ }
110
+
111
+ if (algorithm.name === 'RSASSA-PKCS1-v1_5') {
112
+ options.keyType = 'RSA';
113
+ } else if (algorithm.name === 'ECDSA') {
114
+ options.keyType = 'ECDSA';
115
+ } else {
116
+ // Default to ECDSA for other cases or if unspecified
117
+ // This behavior matches common expectations when modern defaults are preferred
118
+ if (algorithm.name && algorithm.name.toUpperCase().includes('RSA')) {
119
+ options.keyType = 'RSA';
120
+ } else {
121
+ options.keyType = 'ECDSA';
122
+ }
123
+ }
124
+
125
+ return WebRTCModule.generateCertificate(options).then(info => new RTCCertificate(info));
126
+ }
127
+
92
128
  constructor(configuration?: RTCConfiguration) {
93
129
  super();
94
130
 
@@ -118,6 +154,16 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
118
154
 
119
155
  // Filter out bogus servers.
120
156
  configuration.iceServers = servers.filter(s => s.urls);
157
+
158
+ // Sanitize certificates.
159
+ if (configuration.certificates) {
160
+ // @ts-ignore
161
+ configuration.certificates = configuration.certificates.map(cert => {
162
+ return {
163
+ certificateId: cert._id
164
+ };
165
+ });
166
+ }
121
167
  }
122
168
 
123
169
  if (!WebRTCModule.peerConnectionInit(configuration, this._pcId)) {
@@ -133,6 +179,86 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
133
179
  log.debug(`${this._pcId} ctor`);
134
180
  }
135
181
 
182
+ get onconnectionstatechange() {
183
+ return getEventAttributeValue(this, 'connectionstatechange');
184
+ }
185
+
186
+ set onconnectionstatechange(value) {
187
+ setEventAttributeValue(this, 'connectionstatechange', value);
188
+ }
189
+
190
+ get onicecandidate() {
191
+ return getEventAttributeValue(this, 'icecandidate');
192
+ }
193
+
194
+ set onicecandidate(value) {
195
+ setEventAttributeValue(this, 'icecandidate', value);
196
+ }
197
+
198
+ get onicecandidateerror() {
199
+ return getEventAttributeValue(this, 'icecandidateerror');
200
+ }
201
+
202
+ set onicecandidateerror(value) {
203
+ setEventAttributeValue(this, 'icecandidateerror', value);
204
+ }
205
+
206
+ get oniceconnectionstatechange() {
207
+ return getEventAttributeValue(this, 'iceconnectionstatechange');
208
+ }
209
+
210
+ set oniceconnectionstatechange(value) {
211
+ setEventAttributeValue(this, 'iceconnectionstatechange', value);
212
+ }
213
+
214
+ get onicegatheringstatechange() {
215
+ return getEventAttributeValue(this, 'icegatheringstatechange');
216
+ }
217
+
218
+ set onicegatheringstatechange(value) {
219
+ setEventAttributeValue(this, 'icegatheringstatechange', value);
220
+ }
221
+
222
+ get onnegotiationneeded() {
223
+ return getEventAttributeValue(this, 'negotiationneeded');
224
+ }
225
+
226
+ set onnegotiationneeded(value) {
227
+ setEventAttributeValue(this, 'negotiationneeded', value);
228
+ }
229
+
230
+ get onsignalingstatechange() {
231
+ return getEventAttributeValue(this, 'signalingstatechange');
232
+ }
233
+
234
+ set onsignalingstatechange(value) {
235
+ setEventAttributeValue(this, 'signalingstatechange', value);
236
+ }
237
+
238
+ get ondatachannel() {
239
+ return getEventAttributeValue(this, 'datachannel');
240
+ }
241
+
242
+ set ondatachannel(value) {
243
+ setEventAttributeValue(this, 'datachannel', value);
244
+ }
245
+
246
+ get ontrack() {
247
+ return getEventAttributeValue(this, 'track');
248
+ }
249
+
250
+ set ontrack(value) {
251
+ setEventAttributeValue(this, 'track', value);
252
+ }
253
+
254
+ get onerror() {
255
+ return getEventAttributeValue(this, 'error');
256
+ }
257
+
258
+ set onerror(value) {
259
+ setEventAttributeValue(this, 'error', value);
260
+ }
261
+
136
262
  async createOffer(options?:RTCOfferOptions) {
137
263
  log.debug(`${this._pcId} createOffer`);
138
264
 
@@ -326,6 +452,10 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
326
452
  }
327
453
 
328
454
  async addIceCandidate(candidate): Promise<void> {
455
+ if (this.connectionState === 'closed') {
456
+ throw new Error('Peer Connection is closed');
457
+ }
458
+
329
459
  log.debug(`${this._pcId} addIceCandidate`);
330
460
 
331
461
  if (!candidate || !candidate.candidate) {
@@ -589,13 +719,6 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
589
719
  this.connectionState = ev.connectionState;
590
720
 
591
721
  this.dispatchEvent(new Event('connectionstatechange'));
592
-
593
- if (ev.connectionState === 'closed') {
594
- // This PeerConnection is done, clean up.
595
- removeListener(this);
596
-
597
- WebRTCModule.peerConnectionDispose(this._pcId);
598
- }
599
722
  });
600
723
 
601
724
  addListener(this, 'peerConnectionSignalingStateChanged', (ev: any) => {
@@ -606,6 +729,13 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
606
729
  this.signalingState = ev.signalingState;
607
730
 
608
731
  this.dispatchEvent(new Event('signalingstatechange'));
732
+
733
+ if (ev.signalingState === 'closed') {
734
+ // This PeerConnection is done, clean up.
735
+ removeListener(this);
736
+
737
+ WebRTCModule.peerConnectionDispose(this._pcId);
738
+ }
609
739
  });
610
740
 
611
741
  // Consider moving away from this event: https://github.com/WebKit/WebKit/pull/3953
@@ -814,19 +944,3 @@ export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEven
814
944
  this._transceivers.sort((a, b) => a.order - b.order);
815
945
  }
816
946
  }
817
-
818
- /**
819
- * Define the `onxxx` event handlers.
820
- */
821
- const proto = RTCPeerConnection.prototype;
822
-
823
- defineEventAttribute(proto, 'connectionstatechange');
824
- defineEventAttribute(proto, 'icecandidate');
825
- defineEventAttribute(proto, 'icecandidateerror');
826
- defineEventAttribute(proto, 'iceconnectionstatechange');
827
- defineEventAttribute(proto, 'icegatheringstatechange');
828
- defineEventAttribute(proto, 'negotiationneeded');
829
- defineEventAttribute(proto, 'signalingstatechange');
830
- defineEventAttribute(proto, 'datachannel');
831
- defineEventAttribute(proto, 'track');
832
- defineEventAttribute(proto, 'error');
@@ -3,6 +3,7 @@ export interface RTCRtpEncodingParametersInit {
3
3
  rid?: string;
4
4
  maxFramerate?: number;
5
5
  maxBitrate?: number;
6
+ minBitrate?: number;
6
7
  scaleResolutionDownBy?: number;
7
8
  }
8
9
 
@@ -11,12 +12,14 @@ export default class RTCRtpEncodingParameters {
11
12
  _rid: string | null;
12
13
  _maxFramerate: number | null;
13
14
  _maxBitrate: number | null;
15
+ _minBitrate: number | null;
14
16
  _scaleResolutionDownBy: number | null;
15
17
 
16
18
  constructor(init: RTCRtpEncodingParametersInit) {
17
19
  this.active = init.active;
18
20
  this._rid = init.rid ?? null;
19
21
  this._maxBitrate = init.maxBitrate ?? null;
22
+ this._minBitrate = init.minBitrate ?? null;
20
23
  this._maxFramerate = init.maxFramerate ?? null;
21
24
  this._scaleResolutionDownBy = init.scaleResolutionDownBy ?? null;
22
25
  }
@@ -51,6 +54,19 @@ export default class RTCRtpEncodingParameters {
51
54
  }
52
55
  }
53
56
 
57
+ get minBitrate() {
58
+ return this._minBitrate;
59
+ }
60
+
61
+ set minBitrate(bitrate) {
62
+ // eslint-disable-next-line eqeqeq
63
+ if (bitrate != null && bitrate >= 0) {
64
+ this._minBitrate = bitrate;
65
+ } else {
66
+ this._minBitrate = null;
67
+ }
68
+ }
69
+
54
70
  get scaleResolutionDownBy() {
55
71
  return this._scaleResolutionDownBy;
56
72
  }
@@ -77,6 +93,10 @@ export default class RTCRtpEncodingParameters {
77
93
  obj['maxBitrate'] = this._maxBitrate;
78
94
  }
79
95
 
96
+ if (this._minBitrate !== null) {
97
+ obj['minBitrate'] = this._minBitrate;
98
+ }
99
+
80
100
  if (this._maxFramerate !== null) {
81
101
  obj['maxFramerate'] = this._maxFramerate;
82
102
  }
@@ -1,9 +1,9 @@
1
- import { Event } from 'event-target-shim/index';
2
1
 
3
2
  import MediaStream from './MediaStream';
4
3
  import type MediaStreamTrack from './MediaStreamTrack';
5
4
  import RTCRtpReceiver from './RTCRtpReceiver';
6
5
  import RTCRtpTransceiver from './RTCRtpTransceiver';
6
+ import { Event } from './vendor/event-target-shim';
7
7
 
8
8
  type TRACK_EVENTS = 'track'
9
9
 
package/src/RTCUtil.ts CHANGED
@@ -167,7 +167,7 @@ export function isSdpTypeValid(type: string): boolean {
167
167
  export function normalizeOfferOptions(options?: RTCOfferOptions) {
168
168
  const newOptions: Record<string,string> = {};
169
169
 
170
- if (typeof options !== 'object') {
170
+ if (!options || typeof options !== 'object') {
171
171
  return newOptions;
172
172
  }
173
173
 
@@ -6,9 +6,16 @@ import MediaStreamError from './MediaStreamError';
6
6
 
7
7
  const { WebRTCModule } = NativeModules;
8
8
 
9
- export default function getDisplayMedia(): Promise<MediaStream> {
9
+ export interface Constraints {
10
+ android?: {
11
+ createConfigForDefaultDisplay?: boolean;
12
+ resolutionScale?: number;
13
+ }
14
+ }
15
+
16
+ export default function getDisplayMedia(constraints: Constraints = {}): Promise<MediaStream> {
10
17
  return new Promise((resolve, reject) => {
11
- WebRTCModule.getDisplayMedia().then(
18
+ WebRTCModule.getDisplayMedia(constraints).then(
12
19
  data => {
13
20
  const { streamId, track } = data;
14
21
 
package/src/index.ts CHANGED
@@ -16,11 +16,14 @@ import MediaStreamTrack, { type MediaTrackSettings } from './MediaStreamTrack';
16
16
  import MediaStreamTrackEvent from './MediaStreamTrackEvent';
17
17
  import permissions from './Permissions';
18
18
  import RTCAudioSession from './RTCAudioSession';
19
+ import RTCCertificate from './RTCCertificate';
19
20
  import RTCErrorEvent from './RTCErrorEvent';
20
21
  import RTCIceCandidate from './RTCIceCandidate';
21
22
  import RTCPIPView, { startIOSPIP, stopIOSPIP } from './RTCPIPView';
22
23
  import RTCPeerConnection from './RTCPeerConnection';
24
+ import RTCRtpEncodingParameters, { type RTCRtpEncodingParametersInit } from './RTCRtpEncodingParameters';
23
25
  import RTCRtpReceiver from './RTCRtpReceiver';
26
+ import RTCRtpSendParameters, { type RTCRtpSendParametersInit } from './RTCRtpSendParameters';
24
27
  import RTCRtpSender from './RTCRtpSender';
25
28
  import RTCRtpTransceiver from './RTCRtpTransceiver';
26
29
  import RTCSessionDescription from './RTCSessionDescription';
@@ -36,17 +39,22 @@ export {
36
39
  RTCIceCandidate,
37
40
  RTCPeerConnection,
38
41
  RTCSessionDescription,
42
+ RTCCertificate,
39
43
  RTCView,
40
44
  RTCPIPView,
41
45
  ScreenCapturePickerView,
46
+ RTCRtpEncodingParameters,
42
47
  RTCRtpTransceiver,
43
48
  RTCRtpReceiver,
44
49
  RTCRtpSender,
50
+ RTCRtpSendParameters,
45
51
  RTCErrorEvent,
46
52
  RTCAudioSession,
47
53
  MediaStream,
48
54
  MediaStreamTrack,
49
55
  type MediaTrackSettings,
56
+ type RTCRtpEncodingParametersInit,
57
+ type RTCRtpSendParametersInit,
50
58
  type RTCVideoViewProps,
51
59
  type RTCIOSPIPOptions,
52
60
  mediaDevices,
@@ -73,9 +81,8 @@ function registerGlobals(): void {
73
81
  global.navigator.mediaDevices.enumerateDevices = mediaDevices.enumerateDevices.bind(mediaDevices);
74
82
 
75
83
  global.RTCIceCandidate = RTCIceCandidate;
84
+ global.RTCCertificate = RTCCertificate;
76
85
  global.RTCPeerConnection = RTCPeerConnection;
77
- global.RTCRtpReceiver = RTCRtpReceiver;
78
- global.RTCRtpSender = RTCRtpReceiver;
79
86
  global.RTCSessionDescription = RTCSessionDescription;
80
87
  global.MediaStream = MediaStream;
81
88
  global.MediaStreamTrack = MediaStreamTrack;
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Toru Nagashima
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+