react-native-webrtc 111.0.0 → 111.0.6
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/.github/workflows/android_ci.yml +5 -1
- package/.github/workflows/ios_ci.yml +4 -0
- package/ISSUE_TEMPLATE.md +27 -12
- package/README.md +22 -10
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +0 -1
- package/android/src/main/java/com/oney/WebRTCModule/ScreenCaptureController.java +19 -14
- package/android/src/main/java/com/oney/WebRTCModule/SerializeUtils.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +53 -8
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +21 -21
- package/ios/RCTWebRTC/CaptureController.m +4 -0
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +7 -1
- package/ios/RCTWebRTC/ScreenCaptureController.m +4 -0
- package/ios/RCTWebRTC/ScreenCapturePickerViewManager.m +2 -2
- package/ios/RCTWebRTC/ScreenCapturer.m +4 -0
- package/ios/RCTWebRTC/SerializeUtils.m +12 -10
- package/ios/RCTWebRTC/TrackCapturerEventsEmitter.m +1 -1
- package/ios/RCTWebRTC/VideoCaptureController.h +2 -1
- package/ios/RCTWebRTC/VideoCaptureController.m +3 -0
- package/ios/RCTWebRTC/WebRTCModule+Permissions.m +10 -1
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.h +1 -1
- package/ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m +42 -8
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +29 -13
- package/ios/RCTWebRTC/WebRTCModule.m +3 -1
- package/ios/RCTWebRTC/WebRTCModuleOptions.h +1 -0
- package/ios/RCTWebRTC/WebRTCModuleOptions.m +1 -0
- package/ios/RCTWebRTC.xcodeproj/project.pbxproj +1 -0
- package/lib/commonjs/EventEmitter.js +4 -16
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/Logger.js +2 -26
- package/lib/commonjs/Logger.js.map +1 -1
- package/lib/commonjs/MediaDevices.js +8 -15
- package/lib/commonjs/MediaDevices.js.map +1 -1
- package/lib/commonjs/MediaStream.js +21 -44
- package/lib/commonjs/MediaStream.js.map +1 -1
- package/lib/commonjs/MediaStreamError.js +0 -11
- package/lib/commonjs/MediaStreamError.js.map +1 -1
- package/lib/commonjs/MediaStreamErrorEvent.js +0 -9
- package/lib/commonjs/MediaStreamErrorEvent.js.map +1 -1
- package/lib/commonjs/MediaStreamTrack.js +14 -69
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/MediaStreamTrackEvent.js +11 -10
- package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -1
- package/lib/commonjs/MessageEvent.js +12 -10
- package/lib/commonjs/MessageEvent.js.map +1 -1
- package/lib/commonjs/Permissions.js +19 -29
- package/lib/commonjs/Permissions.js.map +1 -1
- package/lib/commonjs/RTCDataChannel.js +18 -77
- package/lib/commonjs/RTCDataChannel.js.map +1 -1
- package/lib/commonjs/RTCDataChannelEvent.js +11 -10
- package/lib/commonjs/RTCDataChannelEvent.js.map +1 -1
- package/lib/commonjs/RTCErrorEvent.js +2 -15
- package/lib/commonjs/RTCErrorEvent.js.map +1 -1
- package/lib/commonjs/RTCIceCandidate.js +0 -14
- package/lib/commonjs/RTCIceCandidate.js.map +1 -1
- package/lib/commonjs/RTCIceCandidateEvent.js +13 -13
- package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +129 -239
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtcpParameters.js +0 -10
- package/lib/commonjs/RTCRtcpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpCapabilities.js +5 -22
- package/lib/commonjs/RTCRtpCapabilities.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecCapability.js +0 -8
- package/lib/commonjs/RTCRtpCodecCapability.js.map +1 -1
- package/lib/commonjs/RTCRtpCodecParameters.js +0 -19
- package/lib/commonjs/RTCRtpCodecParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpEncodingParameters.js +4 -34
- package/lib/commonjs/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpHeaderExtension.js +0 -12
- package/lib/commonjs/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/commonjs/RTCRtpParameters.js +2 -18
- package/lib/commonjs/RTCRtpParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiveParameters.js +0 -5
- package/lib/commonjs/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpReceiver.js +1 -26
- package/lib/commonjs/RTCRtpReceiver.js.map +1 -1
- package/lib/commonjs/RTCRtpSendParameters.js +0 -22
- package/lib/commonjs/RTCRtpSendParameters.js.map +1 -1
- package/lib/commonjs/RTCRtpSender.js +1 -30
- package/lib/commonjs/RTCRtpSender.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js +3 -36
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/commonjs/RTCSessionDescription.js +0 -13
- package/lib/commonjs/RTCSessionDescription.js.map +1 -1
- package/lib/commonjs/RTCTrackEvent.js +16 -14
- package/lib/commonjs/RTCTrackEvent.js.map +1 -1
- package/lib/commonjs/RTCUtil.js +9 -36
- package/lib/commonjs/RTCUtil.js.map +1 -1
- package/lib/commonjs/RTCView.js +6 -3
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/commonjs/ScreenCapturePickerView.js +0 -3
- package/lib/commonjs/ScreenCapturePickerView.js.map +1 -1
- package/lib/commonjs/getDisplayMedia.js +0 -6
- package/lib/commonjs/getDisplayMedia.js.map +1 -1
- package/lib/commonjs/getUserMedia.js +7 -28
- package/lib/commonjs/getUserMedia.js.map +1 -1
- package/lib/commonjs/index.js +1 -26
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/EventEmitter.js +5 -12
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/Logger.js +2 -22
- package/lib/module/Logger.js.map +1 -1
- package/lib/module/MediaDevices.js +9 -9
- package/lib/module/MediaDevices.js.map +1 -1
- package/lib/module/MediaStream.js +24 -39
- package/lib/module/MediaStream.js.map +1 -1
- package/lib/module/MediaStreamError.js +0 -9
- package/lib/module/MediaStreamError.js.map +1 -1
- package/lib/module/MediaStreamErrorEvent.js +0 -7
- package/lib/module/MediaStreamErrorEvent.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +14 -62
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/MediaStreamTrackEvent.js +11 -8
- package/lib/module/MediaStreamTrackEvent.js.map +1 -1
- package/lib/module/MessageEvent.js +12 -8
- package/lib/module/MessageEvent.js.map +1 -1
- package/lib/module/Permissions.js +19 -26
- package/lib/module/Permissions.js.map +1 -1
- package/lib/module/RTCDataChannel.js +20 -67
- package/lib/module/RTCDataChannel.js.map +1 -1
- package/lib/module/RTCDataChannelEvent.js +11 -8
- package/lib/module/RTCDataChannelEvent.js.map +1 -1
- package/lib/module/RTCErrorEvent.js +2 -11
- package/lib/module/RTCErrorEvent.js.map +1 -1
- package/lib/module/RTCIceCandidate.js +0 -12
- package/lib/module/RTCIceCandidate.js.map +1 -1
- package/lib/module/RTCIceCandidateEvent.js +13 -11
- package/lib/module/RTCIceCandidateEvent.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +131 -215
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtcpParameters.js +0 -8
- package/lib/module/RTCRtcpParameters.js.map +1 -1
- package/lib/module/RTCRtpCapabilities.js +5 -17
- package/lib/module/RTCRtpCapabilities.js.map +1 -1
- package/lib/module/RTCRtpCodecCapability.js +0 -6
- package/lib/module/RTCRtpCodecCapability.js.map +1 -1
- package/lib/module/RTCRtpCodecParameters.js +0 -17
- package/lib/module/RTCRtpCodecParameters.js.map +1 -1
- package/lib/module/RTCRtpEncodingParameters.js +4 -32
- package/lib/module/RTCRtpEncodingParameters.js.map +1 -1
- package/lib/module/RTCRtpHeaderExtension.js +0 -10
- package/lib/module/RTCRtpHeaderExtension.js.map +1 -1
- package/lib/module/RTCRtpParameters.js +2 -12
- package/lib/module/RTCRtpParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiveParameters.js +0 -1
- package/lib/module/RTCRtpReceiveParameters.js.map +1 -1
- package/lib/module/RTCRtpReceiver.js +1 -19
- package/lib/module/RTCRtpReceiver.js.map +1 -1
- package/lib/module/RTCRtpSendParameters.js +0 -18
- package/lib/module/RTCRtpSendParameters.js.map +1 -1
- package/lib/module/RTCRtpSender.js +1 -23
- package/lib/module/RTCRtpSender.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js +3 -32
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCSessionDescription.js +0 -11
- package/lib/module/RTCSessionDescription.js.map +1 -1
- package/lib/module/RTCTrackEvent.js +16 -12
- package/lib/module/RTCTrackEvent.js.map +1 -1
- package/lib/module/RTCUtil.js +9 -32
- package/lib/module/RTCUtil.js.map +1 -1
- package/lib/module/RTCView.js +1 -0
- package/lib/module/RTCView.js.map +1 -1
- package/lib/module/ScreenCapturePickerView.js.map +1 -1
- package/lib/module/getDisplayMedia.js.map +1 -1
- package/lib/module/getUserMedia.js +7 -18
- package/lib/module/getUserMedia.js.map +1 -1
- package/lib/module/index.js +2 -7
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/EventEmitter.d.ts +3 -2
- package/lib/typescript/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/Logger.d.ts +1 -0
- package/lib/typescript/Logger.d.ts.map +1 -0
- package/lib/typescript/MediaDevices.d.ts +6 -3
- package/lib/typescript/MediaDevices.d.ts.map +1 -0
- package/lib/typescript/MediaStream.d.ts +17 -7
- package/lib/typescript/MediaStream.d.ts.map +1 -0
- package/lib/typescript/MediaStreamError.d.ts +1 -0
- package/lib/typescript/MediaStreamError.d.ts.map +1 -0
- package/lib/typescript/MediaStreamErrorEvent.d.ts +1 -0
- package/lib/typescript/MediaStreamErrorEvent.d.ts.map +1 -0
- package/lib/typescript/MediaStreamTrack.d.ts +21 -6
- package/lib/typescript/MediaStreamTrack.d.ts.map +1 -0
- package/lib/typescript/MediaStreamTrackEvent.d.ts +17 -5
- package/lib/typescript/MediaStreamTrackEvent.d.ts.map +1 -0
- package/lib/typescript/MessageEvent.d.ts +19 -6
- package/lib/typescript/MessageEvent.d.ts.map +1 -0
- package/lib/typescript/Permissions.d.ts +2 -1
- package/lib/typescript/Permissions.d.ts.map +1 -0
- package/lib/typescript/RTCDataChannel.d.ts +14 -4
- package/lib/typescript/RTCDataChannel.d.ts.map +1 -0
- package/lib/typescript/RTCDataChannelEvent.d.ts +17 -5
- package/lib/typescript/RTCDataChannelEvent.d.ts.map +1 -0
- package/lib/typescript/RTCErrorEvent.d.ts +5 -4
- package/lib/typescript/RTCErrorEvent.d.ts.map +1 -0
- package/lib/typescript/RTCIceCandidate.d.ts +8 -5
- package/lib/typescript/RTCIceCandidate.d.ts.map +1 -0
- package/lib/typescript/RTCIceCandidateEvent.d.ts +18 -3
- package/lib/typescript/RTCIceCandidateEvent.d.ts.map +1 -0
- package/lib/typescript/RTCPeerConnection.d.ts +23 -8
- package/lib/typescript/RTCPeerConnection.d.ts.map +1 -0
- package/lib/typescript/RTCRtcpParameters.d.ts +1 -0
- package/lib/typescript/RTCRtcpParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpCapabilities.d.ts +1 -0
- package/lib/typescript/RTCRtpCapabilities.d.ts.map +1 -0
- package/lib/typescript/RTCRtpCodecCapability.d.ts +1 -0
- package/lib/typescript/RTCRtpCodecCapability.d.ts.map +1 -0
- package/lib/typescript/RTCRtpCodecParameters.d.ts +1 -0
- package/lib/typescript/RTCRtpCodecParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpEncodingParameters.d.ts +1 -0
- package/lib/typescript/RTCRtpEncodingParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpHeaderExtension.d.ts +1 -0
- package/lib/typescript/RTCRtpHeaderExtension.d.ts.map +1 -0
- package/lib/typescript/RTCRtpParameters.d.ts +1 -0
- package/lib/typescript/RTCRtpParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpReceiveParameters.d.ts +1 -0
- package/lib/typescript/RTCRtpReceiveParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpReceiver.d.ts +1 -0
- package/lib/typescript/RTCRtpReceiver.d.ts.map +1 -0
- package/lib/typescript/RTCRtpSendParameters.d.ts +2 -1
- package/lib/typescript/RTCRtpSendParameters.d.ts.map +1 -0
- package/lib/typescript/RTCRtpSender.d.ts +1 -0
- package/lib/typescript/RTCRtpSender.d.ts.map +1 -0
- package/lib/typescript/RTCRtpTransceiver.d.ts +1 -0
- package/lib/typescript/RTCRtpTransceiver.d.ts.map +1 -0
- package/lib/typescript/RTCSessionDescription.d.ts +1 -0
- package/lib/typescript/RTCSessionDescription.d.ts.map +1 -0
- package/lib/typescript/RTCTrackEvent.d.ts +21 -6
- package/lib/typescript/RTCTrackEvent.d.ts.map +1 -0
- package/lib/typescript/RTCUtil.d.ts +1 -0
- package/lib/typescript/RTCUtil.d.ts.map +1 -0
- package/lib/typescript/RTCView.d.ts +1 -0
- package/lib/typescript/RTCView.d.ts.map +1 -0
- package/lib/typescript/ScreenCapturePickerView.d.ts +1 -0
- package/lib/typescript/ScreenCapturePickerView.d.ts.map +1 -0
- package/lib/typescript/getDisplayMedia.d.ts +1 -0
- package/lib/typescript/getDisplayMedia.d.ts.map +1 -0
- package/lib/typescript/getUserMedia.d.ts +1 -0
- package/lib/typescript/getUserMedia.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +3 -5
- package/react-native-webrtc.podspec +1 -1
- package/src/MediaDevices.ts +13 -4
- package/src/MediaStream.ts +37 -13
- package/src/MediaStreamTrack.ts +28 -7
- package/src/MediaStreamTrackEvent.ts +18 -4
- package/src/MessageEvent.ts +19 -5
- package/src/RTCDataChannel.ts +22 -9
- package/src/RTCDataChannelEvent.ts +21 -4
- package/src/RTCErrorEvent.ts +3 -3
- package/src/RTCIceCandidate.ts +7 -1
- package/src/RTCIceCandidateEvent.ts +19 -4
- package/src/RTCPeerConnection.ts +61 -35
- package/src/RTCRtpTransceiver.ts +2 -2
- package/src/RTCTrackEvent.ts +25 -4
- package/src/index.ts +1 -2
- package/tools/format.sh +6 -0
- package/lib/commonjs/MediaStreamEvent.js +0 -23
- package/lib/commonjs/MediaStreamEvent.js.map +0 -1
- package/lib/commonjs/RTCEvent.js +0 -20
- package/lib/commonjs/RTCEvent.js.map +0 -1
- package/lib/module/MediaStreamEvent.js +0 -14
- package/lib/module/MediaStreamEvent.js.map +0 -1
- package/lib/module/RTCEvent.js +0 -11
- package/lib/module/RTCEvent.js.map +0 -1
- package/lib/typescript/MediaStreamEvent.d.ts +0 -8
- package/lib/typescript/RTCEvent.d.ts +0 -4
- package/src/MediaStreamEvent.ts +0 -11
- package/src/RTCEvent.ts +0 -7
package/src/MediaDevices.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineCustomEventTarget } from 'event-target-shim';
|
|
1
|
+
import { EventTarget, Event, defineEventAttribute } from 'event-target-shim';
|
|
3
2
|
import { NativeModules } from 'react-native';
|
|
4
3
|
|
|
5
4
|
import getDisplayMedia from './getDisplayMedia';
|
|
@@ -7,9 +6,11 @@ import getUserMedia from './getUserMedia';
|
|
|
7
6
|
|
|
8
7
|
const { WebRTCModule } = NativeModules;
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
type MediaDevicesEventMap = {
|
|
10
|
+
devicechange: Event<'devicechange'>
|
|
11
|
+
}
|
|
11
12
|
|
|
12
|
-
class MediaDevices extends
|
|
13
|
+
class MediaDevices extends EventTarget<MediaDevicesEventMap> {
|
|
13
14
|
/**
|
|
14
15
|
* W3C "Media Capture and Streams" compatible {@code enumerateDevices}
|
|
15
16
|
* implementation.
|
|
@@ -41,4 +42,12 @@ class MediaDevices extends defineCustomEventTarget(...MEDIA_DEVICES_EVENTS) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Define the `onxxx` event handlers.
|
|
47
|
+
*/
|
|
48
|
+
const proto = MediaDevices.prototype;
|
|
49
|
+
|
|
50
|
+
defineEventAttribute(proto, 'devicechange');
|
|
51
|
+
|
|
52
|
+
|
|
44
53
|
export default new MediaDevices();
|
package/src/MediaStream.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineCustomEventTarget } from 'event-target-shim';
|
|
1
|
+
import { EventTarget, defineEventAttribute } from 'event-target-shim';
|
|
3
2
|
import { NativeModules } from 'react-native';
|
|
4
3
|
|
|
5
|
-
import MediaStreamTrack from './MediaStreamTrack';
|
|
4
|
+
import MediaStreamTrack, { MediaStreamTrackInfo } from './MediaStreamTrack';
|
|
5
|
+
import MediaStreamTrackEvent from './MediaStreamTrackEvent';
|
|
6
6
|
import { uniqueID } from './RTCUtil';
|
|
7
7
|
|
|
8
8
|
const { WebRTCModule } = NativeModules;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
active = true;
|
|
10
|
+
type MediaStreamEventMap = {
|
|
11
|
+
addtrack: MediaStreamTrackEvent<'addtrack'>
|
|
12
|
+
removetrack: MediaStreamTrackEvent<'removetrack'>
|
|
13
|
+
}
|
|
15
14
|
|
|
15
|
+
export default class MediaStream extends EventTarget<MediaStreamEventMap> {
|
|
16
16
|
_tracks: MediaStreamTrack[] = [];
|
|
17
|
+
_id: string;
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* The identifier of this MediaStream unique within the associated
|
|
@@ -36,16 +37,21 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
36
37
|
* done internally, when the stream is first created in native and the JS wrapper is
|
|
37
38
|
* built afterwards.
|
|
38
39
|
*/
|
|
39
|
-
constructor(arg
|
|
40
|
+
constructor(arg?:
|
|
41
|
+
MediaStream |
|
|
42
|
+
MediaStreamTrack[] |
|
|
43
|
+
{ streamId: string, streamReactTag: string, tracks: MediaStreamTrackInfo[] }
|
|
44
|
+
) {
|
|
40
45
|
super();
|
|
41
46
|
|
|
42
|
-
//
|
|
43
|
-
this.
|
|
47
|
+
// Assign a UUID to start with. It will get overridden for remote streams.
|
|
48
|
+
this._id = uniqueID();
|
|
49
|
+
|
|
44
50
|
// Local MediaStreams are created by WebRTCModule to have their id and
|
|
45
51
|
// reactTag equal because WebRTCModule follows the respective standard's
|
|
46
52
|
// recommendation for id generation i.e. uses UUID which is unique enough
|
|
47
53
|
// for the purposes of reactTag.
|
|
48
|
-
this._reactTag = this.
|
|
54
|
+
this._reactTag = this._id;
|
|
49
55
|
|
|
50
56
|
if (typeof arg === 'undefined') {
|
|
51
57
|
WebRTCModule.mediaStreamCreate(this.id);
|
|
@@ -62,7 +68,7 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
62
68
|
this.addTrack(track);
|
|
63
69
|
}
|
|
64
70
|
} else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {
|
|
65
|
-
this.
|
|
71
|
+
this._id = arg.streamId;
|
|
66
72
|
this._reactTag = arg.streamReactTag;
|
|
67
73
|
|
|
68
74
|
for (const trackInfo of arg.tracks) {
|
|
@@ -75,6 +81,16 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
|
|
84
|
+
get id(): string {
|
|
85
|
+
return this._id;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get active(): boolean {
|
|
89
|
+
// TODO: can we reliably report this value?
|
|
90
|
+
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
78
94
|
addTrack(track: MediaStreamTrack): void {
|
|
79
95
|
const index = this._tracks.indexOf(track);
|
|
80
96
|
|
|
@@ -135,3 +151,11 @@ export default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM
|
|
|
135
151
|
WebRTCModule.mediaStreamRelease(this._reactTag);
|
|
136
152
|
}
|
|
137
153
|
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Define the `onxxx` event handlers.
|
|
157
|
+
*/
|
|
158
|
+
const proto = MediaStream.prototype;
|
|
159
|
+
|
|
160
|
+
defineEventAttribute(proto, 'addtrack');
|
|
161
|
+
defineEventAttribute(proto, 'removetrack');
|
package/src/MediaStreamTrack.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineCustomEventTarget, Event } from 'event-target-shim';
|
|
1
|
+
import { EventTarget, Event, defineEventAttribute } from 'event-target-shim';
|
|
3
2
|
import { NativeModules } from 'react-native';
|
|
4
3
|
|
|
5
4
|
import { addListener, removeListener } from './EventEmitter';
|
|
@@ -9,11 +8,27 @@ import { deepClone } from './RTCUtil';
|
|
|
9
8
|
const log = new Logger('pc');
|
|
10
9
|
const { WebRTCModule } = NativeModules;
|
|
11
10
|
|
|
12
|
-
const MEDIA_STREAM_TRACK_EVENTS = [ 'ended', 'mute', 'unmute' ];
|
|
13
11
|
|
|
14
12
|
type MediaStreamTrackState = 'live' | 'ended';
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
export type MediaStreamTrackInfo = {
|
|
15
|
+
id: string;
|
|
16
|
+
kind: string;
|
|
17
|
+
remote: boolean;
|
|
18
|
+
constraints: object;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
settings: object;
|
|
21
|
+
peerConnectionId: number;
|
|
22
|
+
readyState: MediaStreamTrackState;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type MediaStreamTrackEventMap = {
|
|
26
|
+
ended: Event<'ended'>;
|
|
27
|
+
mute: Event<'mute'>;
|
|
28
|
+
unmute: Event<'unmute'>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default class MediaStreamTrack extends EventTarget<MediaStreamTrackEventMap> {
|
|
17
32
|
_constraints: object;
|
|
18
33
|
_enabled: boolean;
|
|
19
34
|
_settings: object;
|
|
@@ -26,7 +41,7 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
|
|
|
26
41
|
readonly label: string = '';
|
|
27
42
|
readonly remote: boolean;
|
|
28
43
|
|
|
29
|
-
constructor(info) {
|
|
44
|
+
constructor(info: MediaStreamTrackInfo) {
|
|
30
45
|
super();
|
|
31
46
|
|
|
32
47
|
this._constraints = info.constraints || {};
|
|
@@ -164,7 +179,6 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
|
|
|
164
179
|
log.debug(`${this.id} mediaStreamTrackEnded`);
|
|
165
180
|
this._readyState = 'ended';
|
|
166
181
|
|
|
167
|
-
// @ts-ignore
|
|
168
182
|
this.dispatchEvent(new Event('ended'));
|
|
169
183
|
});
|
|
170
184
|
}
|
|
@@ -179,4 +193,11 @@ class MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVE
|
|
|
179
193
|
}
|
|
180
194
|
}
|
|
181
195
|
|
|
182
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Define the `onxxx` event handlers.
|
|
198
|
+
*/
|
|
199
|
+
const proto = MediaStreamTrack.prototype;
|
|
200
|
+
|
|
201
|
+
defineEventAttribute(proto, 'ended');
|
|
202
|
+
defineEventAttribute(proto, 'mute');
|
|
203
|
+
defineEventAttribute(proto, 'unmute');
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
+
import { Event } from 'event-target-shim';
|
|
1
2
|
|
|
2
3
|
import type MediaStreamTrack from './MediaStreamTrack';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type MEDIA_STREAM_EVENTS = 'addtrack'| 'removetrack'
|
|
6
|
+
|
|
7
|
+
interface IMediaStreamTrackEventInitDict extends Event.EventInit {
|
|
8
|
+
track: MediaStreamTrack;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @eventClass
|
|
13
|
+
* This event is fired whenever the MediaStreamTrack has changed in any way.
|
|
14
|
+
* @param {MEDIA_STREAM_EVENTS} type - The type of event.
|
|
15
|
+
* @param {IMediaStreamTrackEventInitDict} eventInitDict - The event init properties.
|
|
16
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaStream#events MDN} for details.
|
|
17
|
+
*/
|
|
18
|
+
export default class MediaStreamTrackEvent<TEventType extends MEDIA_STREAM_EVENTS> extends Event<TEventType> {
|
|
19
|
+
/** @eventProperty */
|
|
6
20
|
track: MediaStreamTrack;
|
|
7
|
-
constructor(type, eventInitDict:
|
|
8
|
-
|
|
21
|
+
constructor(type: TEventType, eventInitDict: IMediaStreamTrackEventInitDict) {
|
|
22
|
+
super(type, eventInitDict);
|
|
9
23
|
this.track = eventInitDict.track;
|
|
10
24
|
}
|
|
11
25
|
}
|
package/src/MessageEvent.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { Event } from 'event-target-shim';
|
|
2
2
|
export type MessageEventData = string | ArrayBuffer | Blob;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type MESSAGE_EVENTS = 'message' | 'messageerror';
|
|
5
|
+
|
|
6
|
+
interface IMessageEventInitDict extends Event.EventInit {
|
|
7
|
+
data: MessageEventData;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @eventClass
|
|
12
|
+
* This event is fired whenever the RTCDataChannel send message.
|
|
13
|
+
* @param {MESSAGE_EVENTS} type - The type of event.
|
|
14
|
+
* @param {IMessageEventInitDict} eventInitDict - The event init properties.
|
|
15
|
+
* @see
|
|
16
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/message_event#event_type MDN} for details.
|
|
17
|
+
*/
|
|
18
|
+
export default class MessageEvent<TEventType extends MESSAGE_EVENTS> extends Event<TEventType> {
|
|
19
|
+
/** @eventProperty */
|
|
6
20
|
data: MessageEventData;
|
|
7
|
-
constructor(type:
|
|
8
|
-
|
|
21
|
+
constructor(type: TEventType, eventInitDict: IMessageEventInitDict) {
|
|
22
|
+
super(type, eventInitDict);
|
|
9
23
|
this.data = eventInitDict.data;
|
|
10
24
|
}
|
|
11
25
|
}
|
package/src/RTCDataChannel.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
1
|
import * as base64 from 'base64-js';
|
|
3
|
-
import {
|
|
2
|
+
import { EventTarget, defineEventAttribute } from 'event-target-shim';
|
|
4
3
|
import { NativeModules } from 'react-native';
|
|
5
4
|
|
|
6
5
|
import { addListener, removeListener } from './EventEmitter';
|
|
@@ -11,9 +10,16 @@ const { WebRTCModule } = NativeModules;
|
|
|
11
10
|
|
|
12
11
|
type RTCDataChannelState = 'connecting' | 'open' | 'closing' | 'closed';
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
type DataChannelEventMap = {
|
|
14
|
+
bufferedamountlow: RTCDataChannelEvent<'bufferedamountlow'>;
|
|
15
|
+
close: RTCDataChannelEvent<'close'>;
|
|
16
|
+
closing: RTCDataChannelEvent<'closing'>;
|
|
17
|
+
error: RTCDataChannelEvent<'error'>;
|
|
18
|
+
message: MessageEvent<'message'>;
|
|
19
|
+
open: RTCDataChannelEvent<'open'>;
|
|
20
|
+
};
|
|
15
21
|
|
|
16
|
-
export default class RTCDataChannel extends
|
|
22
|
+
export default class RTCDataChannel extends EventTarget<DataChannelEventMap> {
|
|
17
23
|
_peerConnectionId: number;
|
|
18
24
|
_reactTag: string;
|
|
19
25
|
|
|
@@ -130,13 +136,10 @@ export default class RTCDataChannel extends defineCustomEventTarget(...DATA_CHAN
|
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
if (this._readyState === 'open') {
|
|
133
|
-
// @ts-ignore
|
|
134
139
|
this.dispatchEvent(new RTCDataChannelEvent('open', { channel: this }));
|
|
135
140
|
} else if (this._readyState === 'closing') {
|
|
136
|
-
// @ts-ignore
|
|
137
141
|
this.dispatchEvent(new RTCDataChannelEvent('closing', { channel: this }));
|
|
138
142
|
} else if (this._readyState === 'closed') {
|
|
139
|
-
// @ts-ignore
|
|
140
143
|
this.dispatchEvent(new RTCDataChannelEvent('close', { channel: this }));
|
|
141
144
|
|
|
142
145
|
// This DataChannel is done, clean up event handlers.
|
|
@@ -157,7 +160,6 @@ export default class RTCDataChannel extends defineCustomEventTarget(...DATA_CHAN
|
|
|
157
160
|
data = base64.toByteArray(ev.data).buffer;
|
|
158
161
|
}
|
|
159
162
|
|
|
160
|
-
// @ts-ignore
|
|
161
163
|
this.dispatchEvent(new MessageEvent('message', { data }));
|
|
162
164
|
});
|
|
163
165
|
|
|
@@ -169,9 +171,20 @@ export default class RTCDataChannel extends defineCustomEventTarget(...DATA_CHAN
|
|
|
169
171
|
this._bufferedAmount = ev.bufferedAmount;
|
|
170
172
|
|
|
171
173
|
if (this._bufferedAmount < this.bufferedAmountLowThreshold) {
|
|
172
|
-
// @ts-ignore
|
|
173
174
|
this.dispatchEvent(new RTCDataChannelEvent('bufferedamountlow', { channel: this }));
|
|
174
175
|
}
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
}
|
|
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,11 +1,28 @@
|
|
|
1
|
+
import { Event } from 'event-target-shim';
|
|
1
2
|
|
|
2
3
|
import type RTCDataChannel from './RTCDataChannel';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type DATA_CHANNEL_EVENTS = 'open'| 'message'| 'bufferedamountlow'| 'closing'| 'close'| 'error' | 'datachannel';
|
|
6
|
+
|
|
7
|
+
interface IRTCDataChannelEventInitDict extends Event.EventInit {
|
|
8
|
+
channel: RTCDataChannel;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @eventClass
|
|
14
|
+
* This event is fired whenever the RTCDataChannel has changed in any way.
|
|
15
|
+
* @param {DATA_CHANNEL_EVENTS} type - The type of event.
|
|
16
|
+
* @param {IRTCDataChannelEventInitDict} eventInitDict - The event init properties.
|
|
17
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel#events MDN} for details.
|
|
18
|
+
*/
|
|
19
|
+
export default class RTCDataChannelEvent<
|
|
20
|
+
TEventType extends DATA_CHANNEL_EVENTS
|
|
21
|
+
> extends Event<TEventType> {
|
|
22
|
+
/** @eventProperty */
|
|
6
23
|
channel: RTCDataChannel;
|
|
7
|
-
constructor(type, eventInitDict:
|
|
8
|
-
|
|
24
|
+
constructor(type: TEventType, eventInitDict: IRTCDataChannelEventInitDict) {
|
|
25
|
+
super(type, eventInitDict);
|
|
9
26
|
this.channel = eventInitDict.channel;
|
|
10
27
|
}
|
|
11
28
|
}
|
package/src/RTCErrorEvent.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Event } from 'event-target-shim';
|
|
2
2
|
|
|
3
3
|
type RTCPeerConnectionErrorFunc =
|
|
4
4
|
| 'addTransceiver'
|
|
@@ -10,10 +10,10 @@ type RTCPeerConnectionErrorFunc =
|
|
|
10
10
|
* @brief This class Represents internal error happening on the native side as
|
|
11
11
|
* part of asynchronous invocations to synchronous web APIs.
|
|
12
12
|
*/
|
|
13
|
-
export default class RTCErrorEvent extends
|
|
13
|
+
export default class RTCErrorEvent<TEventType extends RTCPeerConnectionErrorFunc> extends Event<TEventType> {
|
|
14
14
|
readonly func: RTCPeerConnectionErrorFunc;
|
|
15
15
|
readonly message: string;
|
|
16
|
-
constructor(type:
|
|
16
|
+
constructor(type: TEventType, func: RTCPeerConnectionErrorFunc, message: string) {
|
|
17
17
|
super(type);
|
|
18
18
|
this.func = func;
|
|
19
19
|
this.message = message;
|
package/src/RTCIceCandidate.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
interface RTCIceCandidateInfo {
|
|
2
|
+
candidate?: string;
|
|
3
|
+
sdpMLineIndex?: number | null;
|
|
4
|
+
sdpMid?: string | null;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export default class RTCIceCandidate {
|
|
2
8
|
candidate: string;
|
|
3
9
|
sdpMLineIndex: number;
|
|
4
10
|
sdpMid: string;
|
|
5
11
|
|
|
6
|
-
constructor({ candidate = '', sdpMLineIndex = null, sdpMid = null }) {
|
|
12
|
+
constructor({ candidate = '', sdpMLineIndex = null, sdpMid = null }: RTCIceCandidateInfo) {
|
|
7
13
|
if (sdpMLineIndex === null || sdpMid === null) {
|
|
8
14
|
throw new TypeError('`sdpMLineIndex` and `sdpMid` must not null');
|
|
9
15
|
}
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
+
import { Event } from 'event-target-shim';
|
|
1
2
|
|
|
2
3
|
import type RTCIceCandidate from './RTCIceCandidate';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type RTC_ICECANDIDATE_EVENTS = 'icecandidate' | 'icecandidateerror'
|
|
6
|
+
|
|
7
|
+
interface IRTCDataChannelEventInitDict extends Event.EventInit {
|
|
8
|
+
candidate: RTCIceCandidate | null
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @eventClass
|
|
13
|
+
* This event is fired whenever the icecandidate related RTC_EVENTS changed.
|
|
14
|
+
* @type {RTCIceCandidateEvent} for icecandidate related.
|
|
15
|
+
* @param {RTC_ICECANDIDATE_EVENTS} type - The type of event.
|
|
16
|
+
* @param {IRTCDataChannelEventInitDict} eventInitDict - The event init properties.
|
|
17
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection#events MDN} for details.
|
|
18
|
+
*/
|
|
19
|
+
export default class RTCIceCandidateEvent<TEventType extends RTC_ICECANDIDATE_EVENTS> extends Event<TEventType> {
|
|
20
|
+
/** @eventProperty */
|
|
6
21
|
candidate: RTCIceCandidate | null;
|
|
7
|
-
constructor(type, eventInitDict) {
|
|
8
|
-
|
|
22
|
+
constructor(type: TEventType, eventInitDict: IRTCDataChannelEventInitDict) {
|
|
23
|
+
super(type, eventInitDict);
|
|
9
24
|
this.candidate = eventInitDict?.candidate ?? null;
|
|
10
25
|
}
|
|
11
26
|
}
|
package/src/RTCPeerConnection.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineCustomEventTarget } from 'event-target-shim';
|
|
1
|
+
import { EventTarget, Event, defineEventAttribute } from 'event-target-shim';
|
|
3
2
|
import { NativeModules } from 'react-native';
|
|
4
3
|
|
|
5
4
|
import { addListener, removeListener } from './EventEmitter';
|
|
@@ -9,7 +8,6 @@ import MediaStreamTrack from './MediaStreamTrack';
|
|
|
9
8
|
import MediaStreamTrackEvent from './MediaStreamTrackEvent';
|
|
10
9
|
import RTCDataChannel from './RTCDataChannel';
|
|
11
10
|
import RTCDataChannelEvent from './RTCDataChannelEvent';
|
|
12
|
-
import RTCEvent from './RTCEvent';
|
|
13
11
|
import RTCIceCandidate from './RTCIceCandidate';
|
|
14
12
|
import RTCIceCandidateEvent from './RTCIceCandidateEvent';
|
|
15
13
|
import RTCRtpReceiveParameters from './RTCRtpReceiveParameters';
|
|
@@ -47,25 +45,24 @@ type RTCDataChannelInit = {
|
|
|
47
45
|
id?: number
|
|
48
46
|
};
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
'connectionstatechange'
|
|
52
|
-
'icecandidate'
|
|
53
|
-
'icecandidateerror'
|
|
54
|
-
'iceconnectionstatechange'
|
|
55
|
-
'icegatheringstatechange'
|
|
56
|
-
'negotiationneeded'
|
|
57
|
-
'signalingstatechange'
|
|
58
|
-
'datachannel'
|
|
59
|
-
'track'
|
|
60
|
-
'error'
|
|
61
|
-
|
|
48
|
+
type RTCPeerConnectionEventMap = {
|
|
49
|
+
connectionstatechange: Event<'connectionstatechange'>
|
|
50
|
+
icecandidate: RTCIceCandidateEvent<'icecandidate'>
|
|
51
|
+
icecandidateerror: RTCIceCandidateEvent<'icecandidateerror'>
|
|
52
|
+
iceconnectionstatechange: Event<'iceconnectionstatechange'>
|
|
53
|
+
icegatheringstatechange: Event<'icegatheringstatechange'>
|
|
54
|
+
negotiationneeded: Event<'negotiationneeded'>
|
|
55
|
+
signalingstatechange: Event<'signalingstatechange'>
|
|
56
|
+
datachannel: RTCDataChannelEvent<'datachannel'>
|
|
57
|
+
track: RTCTrackEvent<'track'>
|
|
58
|
+
error: Event<'error'>
|
|
59
|
+
}
|
|
62
60
|
|
|
63
61
|
let nextPeerConnectionId = 0;
|
|
64
62
|
|
|
65
|
-
export default class RTCPeerConnection extends
|
|
63
|
+
export default class RTCPeerConnection extends EventTarget<RTCPeerConnectionEventMap> {
|
|
66
64
|
localDescription: RTCSessionDescription | null = null;
|
|
67
65
|
remoteDescription: RTCSessionDescription | null = null;
|
|
68
|
-
|
|
69
66
|
signalingState: RTCSignalingState = 'stable';
|
|
70
67
|
iceGatheringState: RTCIceGatheringState = 'new';
|
|
71
68
|
connectionState: RTCPeerConnectionState = 'new';
|
|
@@ -80,7 +77,10 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
80
77
|
super();
|
|
81
78
|
|
|
82
79
|
this._pcId = nextPeerConnectionId++;
|
|
83
|
-
|
|
80
|
+
|
|
81
|
+
if (!WebRTCModule.peerConnectionInit(configuration, this._pcId)) {
|
|
82
|
+
throw new Error('Failed to initialize PeerConnection, check the native logs!');
|
|
83
|
+
}
|
|
84
84
|
|
|
85
85
|
this._transceivers = [];
|
|
86
86
|
this._remoteStreams = new Map();
|
|
@@ -96,11 +96,27 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
96
96
|
|
|
97
97
|
const {
|
|
98
98
|
sdpInfo,
|
|
99
|
+
newTransceivers,
|
|
99
100
|
transceiversInfo
|
|
100
101
|
} = await WebRTCModule.peerConnectionCreateOffer(this._pcId, RTCUtil.normalizeOfferOptions(options));
|
|
101
102
|
|
|
102
103
|
log.debug(`${this._pcId} createOffer OK`);
|
|
103
104
|
|
|
105
|
+
newTransceivers?.forEach(t => {
|
|
106
|
+
const { transceiverOrder, transceiver } = t;
|
|
107
|
+
const newSender = new RTCRtpSender({ ...transceiver.sender, track: null });
|
|
108
|
+
const remoteTrack
|
|
109
|
+
= transceiver.receiver.track ? new MediaStreamTrack(transceiver.receiver.track) : null;
|
|
110
|
+
const newReceiver = new RTCRtpReceiver({ ...transceiver.receiver, track: remoteTrack });
|
|
111
|
+
const newTransceiver = new RTCRtpTransceiver({
|
|
112
|
+
...transceiver,
|
|
113
|
+
sender: newSender,
|
|
114
|
+
receiver: newReceiver,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this._insertTransceiverSorted(transceiverOrder, newTransceiver);
|
|
118
|
+
});
|
|
119
|
+
|
|
104
120
|
this._updateTransceivers(transceiversInfo);
|
|
105
121
|
|
|
106
122
|
return sdpInfo;
|
|
@@ -253,11 +269,10 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
253
269
|
receiver: transceiver.receiver
|
|
254
270
|
};
|
|
255
271
|
|
|
256
|
-
|
|
272
|
+
|
|
257
273
|
this.dispatchEvent(new RTCTrackEvent('track', eventData));
|
|
258
274
|
|
|
259
275
|
streams.forEach(stream => {
|
|
260
|
-
// @ts-ignore
|
|
261
276
|
stream.dispatchEvent(new MediaStreamTrackEvent('addtrack', { track }));
|
|
262
277
|
});
|
|
263
278
|
|
|
@@ -514,8 +529,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
514
529
|
return;
|
|
515
530
|
}
|
|
516
531
|
|
|
517
|
-
|
|
518
|
-
this.dispatchEvent(new RTCEvent('negotiationneeded'));
|
|
532
|
+
this.dispatchEvent(new Event('negotiationneeded'));
|
|
519
533
|
});
|
|
520
534
|
|
|
521
535
|
addListener(this, 'peerConnectionIceConnectionChanged', (ev: any) => {
|
|
@@ -525,8 +539,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
525
539
|
|
|
526
540
|
this.iceConnectionState = ev.iceConnectionState;
|
|
527
541
|
|
|
528
|
-
|
|
529
|
-
this.dispatchEvent(new RTCEvent('iceconnectionstatechange'));
|
|
542
|
+
this.dispatchEvent(new Event('iceconnectionstatechange'));
|
|
530
543
|
});
|
|
531
544
|
|
|
532
545
|
addListener(this, 'peerConnectionStateChanged', (ev: any) => {
|
|
@@ -536,8 +549,7 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
536
549
|
|
|
537
550
|
this.connectionState = ev.connectionState;
|
|
538
551
|
|
|
539
|
-
|
|
540
|
-
this.dispatchEvent(new RTCEvent('connectionstatechange'));
|
|
552
|
+
this.dispatchEvent(new Event('connectionstatechange'));
|
|
541
553
|
|
|
542
554
|
if (ev.connectionState === 'closed') {
|
|
543
555
|
// This PeerConnection is done, clean up.
|
|
@@ -553,8 +565,8 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
553
565
|
}
|
|
554
566
|
|
|
555
567
|
this.signalingState = ev.signalingState;
|
|
556
|
-
|
|
557
|
-
this.dispatchEvent(new
|
|
568
|
+
|
|
569
|
+
this.dispatchEvent(new Event('signalingstatechange'));
|
|
558
570
|
});
|
|
559
571
|
|
|
560
572
|
// Consider moving away from this event: https://github.com/WebKit/WebKit/pull/3953
|
|
@@ -595,7 +607,6 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
595
607
|
|
|
596
608
|
stream._tracks.splice(trackIdx, 1);
|
|
597
609
|
|
|
598
|
-
// @ts-ignore
|
|
599
610
|
stream.dispatchEvent(new MediaStreamTrackEvent('removetrack', { track }));
|
|
600
611
|
|
|
601
612
|
// Dispatch a mute event for the track.
|
|
@@ -621,7 +632,6 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
621
632
|
|
|
622
633
|
const candidate = new RTCIceCandidate(ev.candidate);
|
|
623
634
|
|
|
624
|
-
// @ts-ignore
|
|
625
635
|
this.dispatchEvent(new RTCIceCandidateEvent('icecandidate', { candidate }));
|
|
626
636
|
});
|
|
627
637
|
|
|
@@ -642,12 +652,10 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
642
652
|
this.localDescription = null;
|
|
643
653
|
}
|
|
644
654
|
|
|
645
|
-
// @ts-ignore
|
|
646
655
|
this.dispatchEvent(new RTCIceCandidateEvent('icecandidate', { candidate: null }));
|
|
647
656
|
}
|
|
648
657
|
|
|
649
|
-
|
|
650
|
-
this.dispatchEvent(new RTCEvent('icegatheringstatechange'));
|
|
658
|
+
this.dispatchEvent(new Event('icegatheringstatechange'));
|
|
651
659
|
});
|
|
652
660
|
|
|
653
661
|
addListener(this, 'peerConnectionDidOpenDataChannel', (ev: any) => {
|
|
@@ -657,7 +665,6 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
657
665
|
|
|
658
666
|
const channel = new RTCDataChannel(ev.dataChannel);
|
|
659
667
|
|
|
660
|
-
// @ts-ignore
|
|
661
668
|
this.dispatchEvent(new RTCDataChannelEvent('datachannel', { channel }));
|
|
662
669
|
});
|
|
663
670
|
|
|
@@ -732,7 +739,10 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
732
739
|
continue;
|
|
733
740
|
}
|
|
734
741
|
|
|
735
|
-
|
|
742
|
+
if (update.currentDirection) {
|
|
743
|
+
transceiver._currentDirection = update.currentDirection;
|
|
744
|
+
}
|
|
745
|
+
|
|
736
746
|
transceiver._mid = update.mid;
|
|
737
747
|
transceiver._stopped = Boolean(update.isStopped);
|
|
738
748
|
transceiver._sender._rtpParameters = new RTCRtpSendParameters(update.senderRtpParameters);
|
|
@@ -757,3 +767,19 @@ export default class RTCPeerConnection extends defineCustomEventTarget(...PEER_C
|
|
|
757
767
|
this._transceivers.sort((a, b) => a.order - b.order);
|
|
758
768
|
}
|
|
759
769
|
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Define the `onxxx` event handlers.
|
|
773
|
+
*/
|
|
774
|
+
const proto = RTCPeerConnection.prototype;
|
|
775
|
+
|
|
776
|
+
defineEventAttribute(proto, 'connectionstatechange');
|
|
777
|
+
defineEventAttribute(proto, 'icecandidate');
|
|
778
|
+
defineEventAttribute(proto, 'icecandidateerror');
|
|
779
|
+
defineEventAttribute(proto, 'iceconnectionstatechange');
|
|
780
|
+
defineEventAttribute(proto, 'icegatheringstatechange');
|
|
781
|
+
defineEventAttribute(proto, 'negotiationneeded');
|
|
782
|
+
defineEventAttribute(proto, 'signalingstatechange');
|
|
783
|
+
defineEventAttribute(proto, 'datachannel');
|
|
784
|
+
defineEventAttribute(proto, 'track');
|
|
785
|
+
defineEventAttribute(proto, 'error');
|
package/src/RTCRtpTransceiver.ts
CHANGED
|
@@ -25,9 +25,9 @@ export default class RTCRtpTransceiver {
|
|
|
25
25
|
receiver: RTCRtpReceiver,
|
|
26
26
|
}) {
|
|
27
27
|
this._peerConnectionId = args.peerConnectionId;
|
|
28
|
-
this._mid = args.mid
|
|
28
|
+
this._mid = args.mid ?? null;
|
|
29
29
|
this._direction = args.direction;
|
|
30
|
-
this._currentDirection = args.currentDirection;
|
|
30
|
+
this._currentDirection = args.currentDirection ?? null;
|
|
31
31
|
this._stopped = Boolean(args.isStopped);
|
|
32
32
|
this._sender = args.sender;
|
|
33
33
|
this._receiver = args.receiver;
|