react-native-webrtc 124.0.7 → 155.0.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.
- package/.claude/settings.local.json +9 -0
- package/.eslintignore +1 -0
- package/CLAUDE.md +714 -0
- package/README.md +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/AbstractVideoCaptureController.java +5 -3
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +84 -7
- package/android/src/main/java/com/oney/WebRTCModule/MediaProjectionService.java +24 -3
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +4 -4
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +8 -0
- package/android/src/main/java/com/oney/WebRTCModule/ThreadUtils.java +8 -0
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +116 -27
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +56 -28
- package/android/src/main/java/com/oney/WebRTCModule/videoEffects/VideoEffectProcessor.java +3 -3
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +21 -0
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +22 -23
- package/ios/RCTWebRTC/SerializeUtils.m +6 -0
- package/ios/RCTWebRTC/VideoCaptureController.m +40 -1
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +16 -9
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.h +2 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +95 -0
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +5 -1
- package/lib/commonjs/Constraints.js.map +1 -1
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/Logger.js.map +1 -1
- package/lib/commonjs/MediaDevices.js +13 -12
- package/lib/commonjs/MediaDevices.js.map +1 -1
- package/lib/commonjs/MediaStream.js +14 -9
- package/lib/commonjs/MediaStream.js.map +1 -1
- package/lib/commonjs/MediaStreamError.js.map +1 -1
- package/lib/commonjs/MediaStreamErrorEvent.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +28 -12
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/MediaStreamTrackEvent.js +2 -2
- package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -1
- package/lib/commonjs/MessageEvent.js +2 -2
- package/lib/commonjs/MessageEvent.js.map +1 -1
- package/lib/commonjs/Permissions.js +1 -2
- package/lib/commonjs/Permissions.js.map +1 -1
- package/lib/commonjs/RTCAudioSession.js.map +1 -1
- package/lib/commonjs/RTCCertificate.js +25 -0
- package/lib/commonjs/RTCCertificate.js.map +1 -0
- package/lib/commonjs/RTCDataChannel.js +38 -13
- package/lib/commonjs/RTCDataChannel.js.map +1 -1
- package/lib/commonjs/RTCDataChannelEvent.js +2 -2
- package/lib/commonjs/RTCDataChannelEvent.js.map +1 -1
- package/lib/commonjs/RTCErrorEvent.js +2 -2
- package/lib/commonjs/RTCErrorEvent.js.map +1 -1
- package/lib/commonjs/RTCIceCandidate.js.map +1 -1
- package/lib/commonjs/RTCIceCandidateEvent.js +2 -2
- package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -1
- package/lib/commonjs/RTCPIPView.js +1 -2
- package/lib/commonjs/RTCPIPView.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +109 -27
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtcpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpCapabilities.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecCapability.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js +17 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/commonjs/RTCRtpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -1
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpSender.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/commonjs/RTCSessionDescription.js.map +1 -1
- package/lib/commonjs/RTCTrackEvent.js +2 -2
- package/lib/commonjs/RTCTrackEvent.js.map +1 -1
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/RTCView.js +1 -2
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/commonjs/ScreenCapturePickerView.js +1 -2
- package/lib/commonjs/ScreenCapturePickerView.js.map +1 -1
- package/lib/commonjs/getDisplayMedia.js +2 -1
- package/lib/commonjs/getDisplayMedia.js.map +1 -1
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/commonjs/index.js +22 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/vendor/event-target-shim/LICENSE +22 -0
- package/lib/commonjs/vendor/event-target-shim/index.js +1221 -0
- package/lib/commonjs/vendor/event-target-shim/index.js.map +1 -0
- package/lib/module/Constraints.js.map +1 -1
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/Logger.js.map +1 -1
- package/lib/module/MediaDevices.js +11 -9
- package/lib/module/MediaDevices.js.map +1 -1
- package/lib/module/MediaStream.js +13 -8
- package/lib/module/MediaStream.js.map +1 -1
- package/lib/module/MediaStreamError.js.map +1 -1
- package/lib/module/MediaStreamErrorEvent.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +25 -9
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/MediaStreamTrackEvent.js +1 -1
- package/lib/module/MediaStreamTrackEvent.js.map +1 -1
- package/lib/module/MessageEvent.js +1 -1
- package/lib/module/MessageEvent.js.map +1 -1
- package/lib/module/Permissions.js.map +1 -1
- package/lib/module/RTCAudioSession.js.map +1 -1
- package/lib/module/RTCCertificate.js +18 -0
- package/lib/module/RTCCertificate.js.map +1 -0
- package/lib/module/RTCDataChannel.js +37 -12
- package/lib/module/RTCDataChannel.js.map +1 -1
- package/lib/module/RTCDataChannelEvent.js +1 -1
- package/lib/module/RTCDataChannelEvent.js.map +1 -1
- package/lib/module/RTCErrorEvent.js +1 -1
- package/lib/module/RTCErrorEvent.js.map +1 -1
- package/lib/module/RTCIceCandidate.js.map +1 -1
- package/lib/module/RTCIceCandidateEvent.js +1 -1
- package/lib/module/RTCIceCandidateEvent.js.map +1 -1
- package/lib/module/RTCPIPView.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +103 -21
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtcpParameters.js.map +1 -1
- package/lib/module/RTCRtpCapabilities.js.map +1 -1
- package/lib/module/RTCRtpCodecCapability.js.map +1 -1
- package/lib/module/RTCRtpCodecParameters.js.map +1 -1
- package/lib/module/RTCRtpEncodingParameters.js +17 -1
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/module/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/module/RTCRtpParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiver.js.map +1 -1
- package/lib/module/RTCRtpSendParameters.js.map +1 -1
- package/lib/module/RTCRtpSender.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCSessionDescription.js.map +1 -1
- package/lib/module/RTCTrackEvent.js +1 -1
- package/lib/module/RTCTrackEvent.js.map +1 -1
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/RTCView.js.map +1 -1
- package/lib/module/ScreenCapturePickerView.js.map +1 -1
- package/lib/module/getDisplayMedia.js +2 -1
- package/lib/module/getDisplayMedia.js.map +1 -1
- package/lib/module/getUserMedia.js.map +1 -1
- package/lib/module/index.js +5 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/vendor/event-target-shim/LICENSE +22 -0
- package/lib/module/vendor/event-target-shim/index.js +1221 -0
- package/lib/module/vendor/event-target-shim/index.js.map +1 -0
- package/lib/typescript/MediaDevices.d.ts +8 -4
- package/lib/typescript/MediaStream.d.ts +5 -1
- package/lib/typescript/MediaStreamTrack.d.ts +7 -1
- package/lib/typescript/MediaStreamTrackEvent.d.ts +1 -1
- package/lib/typescript/MessageEvent.d.ts +1 -1
- package/lib/typescript/RTCCertificate.d.ts +16 -0
- package/lib/typescript/RTCDataChannel.d.ts +13 -1
- package/lib/typescript/RTCDataChannelEvent.d.ts +1 -1
- package/lib/typescript/RTCErrorEvent.d.ts +1 -1
- package/lib/typescript/RTCIceCandidateEvent.d.ts +1 -1
- package/lib/typescript/RTCPeerConnection.d.ts +30 -1
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +4 -0
- package/lib/typescript/RTCTrackEvent.d.ts +1 -1
- package/lib/typescript/getDisplayMedia.d.ts +7 -1
- package/lib/typescript/index.d.ts +4 -1
- package/lib/typescript/vendor/event-target-shim/index.d.ts +411 -0
- package/package.json +3 -4
- package/react-native-webrtc.podspec +2 -2
- package/src/MediaDevices.ts +15 -14
- package/src/MediaStream.ts +17 -9
- package/src/MediaStreamTrack.ts +30 -10
- package/src/MediaStreamTrackEvent.ts +2 -2
- package/src/MessageEvent.ts +1 -1
- package/src/RTCCertificate.ts +24 -0
- package/src/RTCDataChannel.ts +49 -14
- package/src/RTCDataChannelEvent.ts +2 -2
- package/src/RTCErrorEvent.ts +1 -1
- package/src/RTCIceCandidateEvent.ts +2 -2
- package/src/RTCPeerConnection.ts +138 -24
- package/src/RTCRtpEncodingParameters.ts +20 -0
- package/src/RTCTrackEvent.ts +1 -1
- package/src/getDisplayMedia.ts +9 -2
- package/src/index.ts +9 -2
- package/src/vendor/event-target-shim/LICENSE +22 -0
- package/src/vendor/event-target-shim/index.d.ts +411 -0
- package/src/vendor/event-target-shim/index.js +1186 -0
- package/tools/postbuild.mjs +67 -0
package/src/RTCDataChannel.ts
CHANGED
|
@@ -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
|
|
package/src/RTCErrorEvent.ts
CHANGED
package/src/RTCPeerConnection.ts
CHANGED
|
@@ -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
|
}
|
package/src/RTCTrackEvent.ts
CHANGED
|
@@ -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/getDisplayMedia.ts
CHANGED
|
@@ -6,9 +6,16 @@ import MediaStreamError from './MediaStreamError';
|
|
|
6
6
|
|
|
7
7
|
const { WebRTCModule } = NativeModules;
|
|
8
8
|
|
|
9
|
-
export
|
|
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
|
+
|