react-native-webrtc 1.94.2 → 1.100.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java +17 -21
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +3 -0
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +3 -0
- package/ios/RCTWebRTC/ScreenCaptureController.m +4 -0
- package/ios/RCTWebRTC/ScreenCapturer.m +8 -0
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +3 -1
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.h +1 -1
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.m +3 -9
- package/lib/commonjs/EventEmitter.js +16 -0
- package/lib/commonjs/EventEmitter.js.map +1 -0
- package/lib/commonjs/MediaDevices.js +61 -0
- package/lib/commonjs/MediaDevices.js.map +1 -0
- package/lib/commonjs/MediaStream.js +158 -0
- package/lib/commonjs/MediaStream.js.map +1 -0
- package/lib/commonjs/MediaStreamError.js +26 -0
- package/lib/commonjs/MediaStreamError.js.map +1 -0
- package/lib/commonjs/MediaStreamErrorEvent.js +23 -0
- package/lib/commonjs/MediaStreamErrorEvent.js.map +1 -0
- package/lib/commonjs/MediaStreamEvent.js +23 -0
- package/lib/commonjs/MediaStreamEvent.js.map +1 -0
- package/lib/commonjs/MediaStreamTrack.js +127 -0
- package/lib/commonjs/MediaStreamTrack.js.map +1 -0
- package/lib/commonjs/MediaStreamTrackEvent.js +23 -0
- package/lib/commonjs/MediaStreamTrackEvent.js.map +1 -0
- package/lib/commonjs/MessageEvent.js +23 -0
- package/lib/commonjs/MessageEvent.js.map +1 -0
- package/lib/commonjs/Permissions.js +125 -0
- package/lib/commonjs/Permissions.js.map +1 -0
- package/lib/commonjs/RTCDataChannel.js +198 -0
- package/lib/commonjs/RTCDataChannel.js.map +1 -0
- package/lib/commonjs/RTCDataChannelEvent.js +23 -0
- package/lib/commonjs/RTCDataChannelEvent.js.map +1 -0
- package/lib/commonjs/RTCEvent.js +20 -0
- package/lib/commonjs/RTCEvent.js.map +1 -0
- package/lib/commonjs/RTCIceCandidate.js +34 -0
- package/lib/commonjs/RTCIceCandidate.js.map +1 -0
- package/lib/commonjs/RTCIceCandidateEvent.js +25 -0
- package/lib/commonjs/RTCIceCandidateEvent.js.map +1 -0
- package/lib/commonjs/RTCPeerConnection.js +371 -0
- package/lib/commonjs/RTCPeerConnection.js.map +1 -0
- package/lib/commonjs/RTCSessionDescription.js +43 -0
- package/lib/commonjs/RTCSessionDescription.js.map +1 -0
- package/lib/commonjs/RTCUtil.js +218 -0
- package/lib/commonjs/RTCUtil.js.map +1 -0
- package/lib/commonjs/RTCView.js +68 -0
- package/lib/commonjs/RTCView.js.map +1 -0
- package/lib/commonjs/ScreenCapturePickerView.js +13 -0
- package/lib/commonjs/ScreenCapturePickerView.js.map +1 -0
- package/lib/commonjs/getDisplayMedia.js +39 -0
- package/lib/commonjs/getDisplayMedia.js.map +1 -0
- package/lib/commonjs/getUserMedia.js +122 -0
- package/lib/commonjs/getUserMedia.js.map +1 -0
- package/lib/commonjs/index.js +101 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/typings.d.js +2 -0
- package/lib/commonjs/typings.d.js.map +1 -0
- package/lib/module/EventEmitter.js +7 -0
- package/lib/module/EventEmitter.js.map +1 -0
- package/lib/module/MediaDevices.js +46 -0
- package/lib/module/MediaDevices.js.map +1 -0
- package/lib/module/MediaStream.js +142 -0
- package/lib/module/MediaStream.js.map +1 -0
- package/lib/module/MediaStreamError.js +17 -0
- package/lib/module/MediaStreamError.js.map +1 -0
- package/lib/module/MediaStreamErrorEvent.js +14 -0
- package/lib/module/MediaStreamErrorEvent.js.map +1 -0
- package/lib/module/MediaStreamEvent.js +14 -0
- package/lib/module/MediaStreamEvent.js.map +1 -0
- package/lib/module/MediaStreamTrack.js +116 -0
- package/lib/module/MediaStreamTrack.js.map +1 -0
- package/lib/module/MediaStreamTrackEvent.js +14 -0
- package/lib/module/MediaStreamTrackEvent.js.map +1 -0
- package/lib/module/MessageEvent.js +14 -0
- package/lib/module/MessageEvent.js.map +1 -0
- package/lib/module/Permissions.js +115 -0
- package/lib/module/Permissions.js.map +1 -0
- package/lib/module/RTCDataChannel.js +176 -0
- package/lib/module/RTCDataChannel.js.map +1 -0
- package/lib/module/RTCDataChannelEvent.js +14 -0
- package/lib/module/RTCDataChannelEvent.js.map +1 -0
- package/lib/module/RTCEvent.js +11 -0
- package/lib/module/RTCEvent.js.map +1 -0
- package/lib/module/RTCIceCandidate.js +25 -0
- package/lib/module/RTCIceCandidate.js.map +1 -0
- package/lib/module/RTCIceCandidateEvent.js +16 -0
- package/lib/module/RTCIceCandidateEvent.js.map +1 -0
- package/lib/module/RTCPeerConnection.js +342 -0
- package/lib/module/RTCPeerConnection.js.map +1 -0
- package/lib/module/RTCSessionDescription.js +34 -0
- package/lib/module/RTCSessionDescription.js.map +1 -0
- package/lib/module/RTCUtil.js +207 -0
- package/lib/module/RTCUtil.js.map +1 -0
- package/lib/module/RTCView.js +59 -0
- package/lib/module/RTCView.js.map +1 -0
- package/lib/module/ScreenCapturePickerView.js +3 -0
- package/lib/module/ScreenCapturePickerView.js.map +1 -0
- package/lib/module/getDisplayMedia.js +26 -0
- package/lib/module/getDisplayMedia.js.map +1 -0
- package/lib/module/getUserMedia.js +103 -0
- package/lib/module/getUserMedia.js.map +1 -0
- package/lib/module/index.js +31 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/typings.d.js +2 -0
- package/lib/module/typings.d.js.map +1 -0
- package/lib/typescript/EventEmitter.d.ts +3 -0
- package/lib/typescript/MediaDevices.d.ts +27 -0
- package/lib/typescript/MediaStream.d.ts +39 -0
- package/lib/typescript/MediaStreamError.d.ts +6 -0
- package/lib/typescript/MediaStreamErrorEvent.d.ts +6 -0
- package/lib/typescript/MediaStreamEvent.d.ts +8 -0
- package/lib/typescript/MediaStreamTrack.d.ts +34 -0
- package/lib/typescript/MediaStreamTrackEvent.d.ts +8 -0
- package/lib/typescript/MessageEvent.d.ts +9 -0
- package/lib/typescript/Permissions.d.ts +55 -0
- package/lib/typescript/RTCDataChannel.d.ts +33 -0
- package/lib/typescript/RTCDataChannelEvent.d.ts +8 -0
- package/lib/typescript/RTCEvent.d.ts +4 -0
- package/lib/typescript/RTCIceCandidate.d.ts +11 -0
- package/lib/typescript/RTCIceCandidateEvent.d.ts +6 -0
- package/lib/typescript/RTCPeerConnection.d.ts +58 -0
- package/lib/typescript/RTCSessionDescription.d.ts +14 -0
- package/lib/typescript/RTCUtil.d.ts +28 -0
- package/lib/typescript/RTCView.d.ts +53 -0
- package/lib/typescript/ScreenCapturePickerView.d.ts +2 -0
- package/lib/typescript/getDisplayMedia.d.ts +1 -0
- package/lib/typescript/getUserMedia.d.ts +6 -0
- package/lib/typescript/index.d.ts +11 -0
- package/package.json +24 -8
- package/src/{EventEmitter.js → EventEmitter.ts} +0 -0
- package/src/{MediaDevices.js → MediaDevices.ts} +2 -3
- package/src/{MediaStream.js → MediaStream.ts} +1 -1
- package/src/{MediaStreamError.js → MediaStreamError.ts} +2 -2
- package/src/{MediaStreamErrorEvent.js → MediaStreamErrorEvent.ts} +1 -1
- package/src/{MediaStreamEvent.js → MediaStreamEvent.ts} +2 -2
- package/src/{MediaStreamTrack.js → MediaStreamTrack.ts} +9 -7
- package/src/{MediaStreamTrackEvent.js → MediaStreamTrackEvent.ts} +2 -2
- package/src/MessageEvent.ts +11 -0
- package/src/{Permissions.js → Permissions.ts} +6 -6
- package/src/{RTCDataChannel.js → RTCDataChannel.ts} +12 -8
- package/src/{RTCDataChannelEvent.js → RTCDataChannelEvent.ts} +2 -2
- package/src/{RTCEvent.js → RTCEvent.ts} +1 -2
- package/src/{RTCIceCandidate.js → RTCIceCandidate.ts} +0 -0
- package/src/{RTCIceCandidateEvent.js → RTCIceCandidateEvent.ts} +2 -6
- package/src/{RTCPeerConnection.js → RTCPeerConnection.ts} +28 -19
- package/src/{RTCSessionDescription.js → RTCSessionDescription.ts} +6 -3
- package/src/{RTCUtil.js → RTCUtil.ts} +5 -1
- package/src/{RTCView.js → RTCView.ts} +0 -0
- package/src/{ScreenCapturePickerView.js → ScreenCapturePickerView.ts} +0 -0
- package/src/{getDisplayMedia.js → getDisplayMedia.ts} +0 -0
- package/src/{getUserMedia.js → getUserMedia.ts} +7 -2
- package/src/{index.js → index.ts} +6 -7
- package/src/typings.d.ts +1 -0
- package/tools/build-webrtc.py +25 -19
- package/tsconfig.json +14 -0
- package/src/MessageEvent.js +0 -10
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Everyone is welcome to our [Discourse community](https://react-native-webrtc.dis
|
|
|
15
15
|
|
|
16
16
|
## WebRTC Revision
|
|
17
17
|
|
|
18
|
-
* Currently used revision: [
|
|
18
|
+
* Currently used revision: [M100](https://github.com/jitsi/webrtc/releases/tag/v100.0.0)
|
|
19
19
|
* Supported architectures
|
|
20
20
|
* Android: armeabi-v7a, arm64-v8a, x86, x86_64
|
|
21
21
|
* iOS: arm64, x86_64 (for bitcode support, run [this script](https://github.com/react-native-webrtc/react-native-webrtc/blob/master/tools/downloadBitcode.sh))
|
|
@@ -349,7 +349,7 @@ class PeerConnectionObserver implements PeerConnection.Observer {
|
|
|
349
349
|
trackInfo.putBoolean("remote", true);
|
|
350
350
|
tracks.pushMap(trackInfo);
|
|
351
351
|
|
|
352
|
-
videoTrackAdapters.addAdapter(
|
|
352
|
+
videoTrackAdapters.addAdapter(track);
|
|
353
353
|
}
|
|
354
354
|
for (int i = 0; i < mediaStream.audioTracks.size(); i++) {
|
|
355
355
|
AudioTrack track = mediaStream.audioTracks.get(i);
|
|
@@ -35,31 +35,31 @@ public class VideoTrackAdapter {
|
|
|
35
35
|
this.webRTCModule = webRTCModule;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
public void addAdapter(
|
|
38
|
+
public void addAdapter(VideoTrack videoTrack) {
|
|
39
39
|
String trackId = videoTrack.id();
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Log.d(TAG, "Created adapter for " + trackId);
|
|
44
|
-
muteImplMap.put(trackId, onMuteImpl);
|
|
45
|
-
videoTrack.addSink(onMuteImpl);
|
|
46
|
-
onMuteImpl.start();
|
|
47
|
-
} else {
|
|
48
|
-
Log.w(
|
|
49
|
-
TAG, "Attempted to add adapter twice for track ID: " + trackId);
|
|
40
|
+
if (muteImplMap.containsKey(trackId)) {
|
|
41
|
+
Log.w(TAG, "Attempted to add adapter twice for track ID: " + trackId);
|
|
42
|
+
return;
|
|
50
43
|
}
|
|
44
|
+
|
|
45
|
+
TrackMuteUnmuteImpl onMuteImpl = new TrackMuteUnmuteImpl(trackId);
|
|
46
|
+
Log.d(TAG, "Created adapter for " + trackId);
|
|
47
|
+
muteImplMap.put(trackId, onMuteImpl);
|
|
48
|
+
videoTrack.addSink(onMuteImpl);
|
|
49
|
+
onMuteImpl.start();
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
public void removeAdapter(VideoTrack videoTrack) {
|
|
54
53
|
String trackId = videoTrack.id();
|
|
55
54
|
TrackMuteUnmuteImpl onMuteImpl = muteImplMap.remove(trackId);
|
|
56
|
-
if (onMuteImpl
|
|
57
|
-
videoTrack.removeSink(onMuteImpl);
|
|
58
|
-
onMuteImpl.dispose();
|
|
59
|
-
Log.d(TAG, "Deleted adapter for " + trackId);
|
|
60
|
-
} else {
|
|
55
|
+
if (onMuteImpl == null) {
|
|
61
56
|
Log.w(TAG, "removeAdapter - no adapter for " + trackId);
|
|
57
|
+
return;
|
|
62
58
|
}
|
|
59
|
+
|
|
60
|
+
videoTrack.removeSink(onMuteImpl);
|
|
61
|
+
onMuteImpl.dispose();
|
|
62
|
+
Log.d(TAG, "Deleted adapter for " + trackId);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -71,11 +71,9 @@ public class VideoTrackAdapter {
|
|
|
71
71
|
private volatile boolean disposed;
|
|
72
72
|
private AtomicInteger frameCounter;
|
|
73
73
|
private boolean mutedState;
|
|
74
|
-
private final String streamReactTag;
|
|
75
74
|
private final String trackId;
|
|
76
75
|
|
|
77
|
-
TrackMuteUnmuteImpl(String
|
|
78
|
-
this.streamReactTag = streamReactTag;
|
|
76
|
+
TrackMuteUnmuteImpl(String trackId) {
|
|
79
77
|
this.trackId = trackId;
|
|
80
78
|
this.frameCounter = new AtomicInteger();
|
|
81
79
|
}
|
|
@@ -118,14 +116,12 @@ public class VideoTrackAdapter {
|
|
|
118
116
|
private void emitMuteEvent(boolean muted) {
|
|
119
117
|
WritableMap params = Arguments.createMap();
|
|
120
118
|
params.putInt("peerConnectionId", peerConnectionId);
|
|
121
|
-
params.putString("streamReactTag", streamReactTag);
|
|
122
119
|
params.putString("trackId", trackId);
|
|
123
120
|
params.putBoolean("muted", muted);
|
|
124
121
|
|
|
125
122
|
Log.d(TAG,
|
|
126
123
|
(muted ? "Mute" : "Unmute" )
|
|
127
124
|
+ " event pcId: " + peerConnectionId
|
|
128
|
-
+ " streamTag: " + streamReactTag
|
|
129
125
|
+ " trackId: " + trackId);
|
|
130
126
|
|
|
131
127
|
VideoTrackAdapter.this.webRTCModule.sendEvent(
|
|
@@ -210,6 +210,9 @@ public class WebRTCModule extends ReactContextBaseJavaModule {
|
|
|
210
210
|
// Required for perfect negotiation.
|
|
211
211
|
conf.enableImplicitRollback = true;
|
|
212
212
|
|
|
213
|
+
// Plan B, just a little longer.
|
|
214
|
+
conf.sdpSemantics = PeerConnection.SdpSemantics.PLAN_B;
|
|
215
|
+
|
|
213
216
|
if (map == null) {
|
|
214
217
|
return conf;
|
|
215
218
|
}
|
|
@@ -141,6 +141,13 @@ const NSUInteger kMaxReadLength = 10 * 1024;
|
|
|
141
141
|
return self;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
- (void)setConnection:(SocketConnection *)connection {
|
|
145
|
+
if (_connection != connection) {
|
|
146
|
+
[_connection close];
|
|
147
|
+
_connection = connection;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
144
151
|
- (void)startCaptureWithConnection:(SocketConnection *)connection {
|
|
145
152
|
_startTimeStampNs = -1;
|
|
146
153
|
|
|
@@ -152,6 +159,7 @@ const NSUInteger kMaxReadLength = 10 * 1024;
|
|
|
152
159
|
|
|
153
160
|
- (void)stopCapture {
|
|
154
161
|
[self.connection close];
|
|
162
|
+
self.connection = nil;
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
// MARK: Private Methods
|
|
@@ -444,6 +444,8 @@ RCT_EXPORT_METHOD(peerConnectionRestartIce:(nonnull NSNumber *)objectID)
|
|
|
444
444
|
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
445
445
|
[s appendString:jsonString];
|
|
446
446
|
}
|
|
447
|
+
} else if ([statisticsValue isKindOfClass:[NSNumber class]]) {
|
|
448
|
+
[s appendString:[NSString stringWithFormat:@"%@", statisticsValue]];
|
|
447
449
|
} else {
|
|
448
450
|
[s appendString:@"\""];
|
|
449
451
|
[s appendString:[NSString stringWithFormat:@"%@", statisticsValue]];
|
|
@@ -513,7 +515,7 @@ RCT_EXPORT_METHOD(peerConnectionRestartIce:(nonnull NSNumber *)objectID)
|
|
|
513
515
|
NSMutableArray *tracks = [NSMutableArray array];
|
|
514
516
|
for (RTCVideoTrack *track in stream.videoTracks) {
|
|
515
517
|
peerConnection.remoteTracks[track.trackId] = track;
|
|
516
|
-
[peerConnection addVideoTrackAdapter:
|
|
518
|
+
[peerConnection addVideoTrackAdapter:track];
|
|
517
519
|
[tracks addObject:@{@"id": track.trackId, @"kind": track.kind, @"label": track.trackId, @"enabled": @(track.isEnabled), @"remote": @(YES), @"readyState": @"live"}];
|
|
518
520
|
}
|
|
519
521
|
for (RTCAudioTrack *track in stream.audioTracks) {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
@property (nonatomic, strong) NSMutableDictionary<NSString *, id> *videoTrackAdapters;
|
|
8
8
|
|
|
9
|
-
- (void)addVideoTrackAdapter:(
|
|
9
|
+
- (void)addVideoTrackAdapter:(RTCVideoTrack*)track;
|
|
10
10
|
- (void)removeVideoTrackAdapter:(RTCVideoTrack*)track;
|
|
11
11
|
|
|
12
12
|
@end
|
|
@@ -23,13 +23,12 @@ static const NSTimeInterval MUTE_DELAY = 1.5;
|
|
|
23
23
|
|
|
24
24
|
/* Entity responsible for detecting track mute / unmute events. It's implemented
|
|
25
25
|
* as a video renderer, which counts the number of frames, and if it sees them
|
|
26
|
-
* stalled for the default interval it will emit a mute event. If
|
|
26
|
+
* stalled for the default interval it will emit a mute event. If frames keep
|
|
27
27
|
* being received, the track unmute event will be emitted.
|
|
28
28
|
*/
|
|
29
29
|
@interface TrackMuteDetector : NSObject<RTCVideoRenderer>
|
|
30
30
|
|
|
31
31
|
@property (copy, nonatomic) NSNumber *peerConnectionId;
|
|
32
|
-
@property (copy, nonatomic) NSString *streamReactTag;
|
|
33
32
|
@property (copy, nonatomic) NSString *trackId;
|
|
34
33
|
@property (weak, nonatomic) WebRTCModule *module;
|
|
35
34
|
|
|
@@ -43,13 +42,11 @@ static const NSTimeInterval MUTE_DELAY = 1.5;
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
- (instancetype)initWith:(NSNumber*)peerConnectionId
|
|
46
|
-
streamReactTag:(NSString*)streamReactTag
|
|
47
45
|
trackId:(NSString*)trackId
|
|
48
46
|
webRTCModule:(WebRTCModule*)module {
|
|
49
47
|
self = [super init];
|
|
50
48
|
if (self) {
|
|
51
49
|
self.peerConnectionId = peerConnectionId;
|
|
52
|
-
self.streamReactTag = streamReactTag;
|
|
53
50
|
self.trackId = trackId;
|
|
54
51
|
self.module = module;
|
|
55
52
|
|
|
@@ -74,14 +71,12 @@ static const NSTimeInterval MUTE_DELAY = 1.5;
|
|
|
74
71
|
[self.module sendEventWithName:kEventMediaStreamTrackMuteChanged
|
|
75
72
|
body:@{
|
|
76
73
|
@"peerConnectionId": self.peerConnectionId,
|
|
77
|
-
@"streamReactTag": self.streamReactTag,
|
|
78
74
|
@"trackId": self.trackId,
|
|
79
75
|
@"muted": @(muted)
|
|
80
76
|
}];
|
|
81
|
-
RCTLog(@"[VideoTrackAdapter] %@ event for
|
|
77
|
+
RCTLog(@"[VideoTrackAdapter] %@ event for pc %@ track %@",
|
|
82
78
|
muted ? @"Mute" : @"Unmute",
|
|
83
79
|
self.peerConnectionId,
|
|
84
|
-
self.streamReactTag,
|
|
85
80
|
self.trackId);
|
|
86
81
|
}
|
|
87
82
|
|
|
@@ -144,7 +139,7 @@ static const NSTimeInterval MUTE_DELAY = 1.5;
|
|
|
144
139
|
objc_setAssociatedObject(self, @selector(videoTrackAdapters), videoTrackAdapters, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
145
140
|
}
|
|
146
141
|
|
|
147
|
-
- (void)addVideoTrackAdapter:(
|
|
142
|
+
- (void)addVideoTrackAdapter:(RTCVideoTrack*)track {
|
|
148
143
|
NSString* trackId = track.trackId;
|
|
149
144
|
if ([self.videoTrackAdapters objectForKey:trackId] != nil) {
|
|
150
145
|
RCTLogWarn(@"[VideoTrackAdapter] Adapter already exists for track %@", trackId);
|
|
@@ -153,7 +148,6 @@ static const NSTimeInterval MUTE_DELAY = 1.5;
|
|
|
153
148
|
|
|
154
149
|
TrackMuteDetector* muteDetector
|
|
155
150
|
= [[TrackMuteDetector alloc] initWith:self.reactTag
|
|
156
|
-
streamReactTag:streamReactId
|
|
157
151
|
trackId:trackId
|
|
158
152
|
webRTCModule:self.webRTCModule];
|
|
159
153
|
[self.videoTrackAdapters setObject:muteDetector forKey:trackId];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
WebRTCModule
|
|
12
|
+
} = _reactNative.NativeModules;
|
|
13
|
+
const EventEmitter = new _reactNative.NativeEventEmitter(WebRTCModule);
|
|
14
|
+
var _default = EventEmitter;
|
|
15
|
+
exports.default = _default;
|
|
16
|
+
//# sourceMappingURL=EventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["EventEmitter.ts"],"names":["WebRTCModule","NativeModules","EventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AAEA,MAAMC,YAAY,GAAG,IAAIC,+BAAJ,CAAuBH,YAAvB,CAArB;eAEeE,Y","sourcesContent":["import { NativeModules, NativeEventEmitter } from 'react-native';\n\nconst { WebRTCModule } = NativeModules;\n\nconst EventEmitter = new NativeEventEmitter(WebRTCModule);\n\nexport default EventEmitter;\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
var _eventTargetShim = require("event-target-shim");
|
|
11
|
+
|
|
12
|
+
var _getDisplayMedia = _interopRequireDefault(require("./getDisplayMedia"));
|
|
13
|
+
|
|
14
|
+
var _getUserMedia = _interopRequireDefault(require("./getUserMedia"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
WebRTCModule
|
|
20
|
+
} = _reactNative.NativeModules;
|
|
21
|
+
const MEDIA_DEVICES_EVENTS = ['devicechange'];
|
|
22
|
+
|
|
23
|
+
class MediaDevices extends (0, _eventTargetShim.defineCustomEventTarget)(...MEDIA_DEVICES_EVENTS) {
|
|
24
|
+
/**
|
|
25
|
+
* W3C "Media Capture and Streams" compatible {@code enumerateDevices}
|
|
26
|
+
* implementation.
|
|
27
|
+
*/
|
|
28
|
+
enumerateDevices() {
|
|
29
|
+
return new Promise(resolve => WebRTCModule.enumerateDevices(resolve));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* W3C "Screen Capture" compatible {@code getDisplayMedia} implementation.
|
|
33
|
+
* See: https://w3c.github.io/mediacapture-screen-share/
|
|
34
|
+
*
|
|
35
|
+
* @returns {Promise}
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
getDisplayMedia() {
|
|
40
|
+
return (0, _getDisplayMedia.default)();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* W3C "Media Capture and Streams" compatible {@code getUserMedia}
|
|
44
|
+
* implementation.
|
|
45
|
+
* See: https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-enumeratedevices
|
|
46
|
+
*
|
|
47
|
+
* @param {*} constraints
|
|
48
|
+
* @returns {Promise}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
getUserMedia(constraints) {
|
|
53
|
+
return (0, _getUserMedia.default)(constraints);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var _default = new MediaDevices();
|
|
59
|
+
|
|
60
|
+
exports.default = _default;
|
|
61
|
+
//# sourceMappingURL=MediaDevices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MediaDevices.ts"],"names":["WebRTCModule","NativeModules","MEDIA_DEVICES_EVENTS","MediaDevices","enumerateDevices","Promise","resolve","getDisplayMedia","getUserMedia","constraints"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AAEA,MAAMC,oBAAoB,GAAG,CAAC,cAAD,CAA7B;;AAEA,MAAMC,YAAN,SAA2B,8CAAwB,GAAGD,oBAA3B,CAA3B,CAA4E;AACxE;AACJ;AACA;AACA;AACIE,EAAAA,gBAAgB,GAAG;AACf,WAAO,IAAIC,OAAJ,CAAYC,OAAO,IAAIN,YAAY,CAACI,gBAAb,CAA8BE,OAA9B,CAAvB,CAAP;AACH;AAED;AACJ;AACA;AACA;AACA;AACA;;;AACIC,EAAAA,eAAe,GAAG;AACd,WAAO,+BAAP;AACH;AAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;;AACIC,EAAAA,YAAY,CAACC,WAAD,EAAc;AACtB,WAAO,2BAAaA,WAAb,CAAP;AACH;;AA7BuE;;eAgC7D,IAAIN,YAAJ,E","sourcesContent":["\nimport { NativeModules } from 'react-native';\nimport { defineCustomEventTarget } from 'event-target-shim';\n\nimport getDisplayMedia from './getDisplayMedia';\nimport getUserMedia from './getUserMedia';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_DEVICES_EVENTS = ['devicechange'];\n\nclass MediaDevices extends defineCustomEventTarget(...MEDIA_DEVICES_EVENTS) {\n /**\n * W3C \"Media Capture and Streams\" compatible {@code enumerateDevices}\n * implementation.\n */\n enumerateDevices() {\n return new Promise(resolve => WebRTCModule.enumerateDevices(resolve));\n }\n\n /**\n * W3C \"Screen Capture\" compatible {@code getDisplayMedia} implementation.\n * See: https://w3c.github.io/mediacapture-screen-share/\n *\n * @returns {Promise}\n */\n getDisplayMedia() {\n return getDisplayMedia();\n }\n\n /**\n * W3C \"Media Capture and Streams\" compatible {@code getUserMedia}\n * implementation.\n * See: https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-enumeratedevices\n *\n * @param {*} constraints\n * @returns {Promise}\n */\n getUserMedia(constraints) {\n return getUserMedia(constraints);\n }\n}\n\nexport default new MediaDevices();\n"]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
var _eventTargetShim = require("event-target-shim");
|
|
11
|
+
|
|
12
|
+
var _RTCUtil = require("./RTCUtil");
|
|
13
|
+
|
|
14
|
+
var _MediaStreamTrack = _interopRequireDefault(require("./MediaStreamTrack"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
WebRTCModule
|
|
22
|
+
} = _reactNative.NativeModules;
|
|
23
|
+
const MEDIA_STREAM_EVENTS = ['active', 'inactive', 'addtrack', 'removetrack'];
|
|
24
|
+
|
|
25
|
+
class MediaStream extends (0, _eventTargetShim.defineCustomEventTarget)(...MEDIA_STREAM_EVENTS) {
|
|
26
|
+
/**
|
|
27
|
+
* The identifier of this MediaStream unique within the associated
|
|
28
|
+
* WebRTCModule instance. As the id of a remote MediaStream instance is unique
|
|
29
|
+
* only within the associated RTCPeerConnection, it is not sufficiently unique
|
|
30
|
+
* to identify this MediaStream across multiple RTCPeerConnections and to
|
|
31
|
+
* unambiguously differentiate it from a local MediaStream instance not added
|
|
32
|
+
* to an RTCPeerConnection.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A MediaStream can be constructed in several ways, depending on the paramters
|
|
37
|
+
* that are passed here.
|
|
38
|
+
*
|
|
39
|
+
* - undefined: just a new stream, with no tracks.
|
|
40
|
+
* - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.
|
|
41
|
+
* - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.
|
|
42
|
+
* - object: a new stream instance, represented by the passed info object, this is always
|
|
43
|
+
* done internally, when the stream is first created in native and the JS wrapper is
|
|
44
|
+
* built afterwards.
|
|
45
|
+
*/
|
|
46
|
+
constructor(arg) {
|
|
47
|
+
super(); // Assigm a UUID to start with. It may get overridden for remote streams.
|
|
48
|
+
|
|
49
|
+
_defineProperty(this, "id", void 0);
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "active", true);
|
|
52
|
+
|
|
53
|
+
_defineProperty(this, "_tracks", []);
|
|
54
|
+
|
|
55
|
+
_defineProperty(this, "_reactTag", void 0);
|
|
56
|
+
|
|
57
|
+
this.id = (0, _RTCUtil.uniqueID)(); // Local MediaStreams are created by WebRTCModule to have their id and
|
|
58
|
+
// reactTag equal because WebRTCModule follows the respective standard's
|
|
59
|
+
// recommendation for id generation i.e. uses UUID which is unique enough
|
|
60
|
+
// for the purposes of reactTag.
|
|
61
|
+
|
|
62
|
+
this._reactTag = this.id;
|
|
63
|
+
|
|
64
|
+
if (typeof arg === 'undefined') {
|
|
65
|
+
WebRTCModule.mediaStreamCreate(this.id);
|
|
66
|
+
} else if (arg instanceof MediaStream) {
|
|
67
|
+
WebRTCModule.mediaStreamCreate(this.id);
|
|
68
|
+
|
|
69
|
+
for (const track of arg.getTracks()) {
|
|
70
|
+
this.addTrack(track);
|
|
71
|
+
}
|
|
72
|
+
} else if (Array.isArray(arg)) {
|
|
73
|
+
WebRTCModule.mediaStreamCreate(this.id);
|
|
74
|
+
|
|
75
|
+
for (const track of arg) {
|
|
76
|
+
this.addTrack(track);
|
|
77
|
+
}
|
|
78
|
+
} else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {
|
|
79
|
+
this.id = arg.streamId;
|
|
80
|
+
this._reactTag = arg.streamReactTag;
|
|
81
|
+
|
|
82
|
+
for (const trackInfo of arg.tracks) {
|
|
83
|
+
// We are not using addTrack here because the track is already part of the
|
|
84
|
+
// stream, so there is no need to add it on the native side.
|
|
85
|
+
this._tracks.push(new _MediaStreamTrack.default(trackInfo));
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
throw new TypeError(`invalid type: ${typeof arg}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
addTrack(track) {
|
|
93
|
+
const index = this._tracks.indexOf(track);
|
|
94
|
+
|
|
95
|
+
if (index !== -1) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
this._tracks.push(track);
|
|
100
|
+
|
|
101
|
+
WebRTCModule.mediaStreamAddTrack(this._reactTag, track.id);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
removeTrack(track) {
|
|
105
|
+
const index = this._tracks.indexOf(track);
|
|
106
|
+
|
|
107
|
+
if (index === -1) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this._tracks.splice(index, 1);
|
|
112
|
+
|
|
113
|
+
WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.id);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
getTracks() {
|
|
117
|
+
return this._tracks.slice();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
getTrackById(trackId) {
|
|
121
|
+
return this._tracks.find(track => track.id === trackId);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
getAudioTracks() {
|
|
125
|
+
return this._tracks.filter(track => track.kind === 'audio');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
getVideoTracks() {
|
|
129
|
+
return this._tracks.filter(track => track.kind === 'video');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
clone() {
|
|
133
|
+
throw new Error('Not implemented.');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
toURL() {
|
|
137
|
+
return this._reactTag;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
release() {
|
|
141
|
+
let releaseTracks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
142
|
+
const tracks = [...this._tracks];
|
|
143
|
+
|
|
144
|
+
for (const track of tracks) {
|
|
145
|
+
this.removeTrack(track);
|
|
146
|
+
|
|
147
|
+
if (releaseTracks) {
|
|
148
|
+
track.release();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
WebRTCModule.mediaStreamRelease(this._reactTag);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
exports.default = MediaStream;
|
|
158
|
+
//# sourceMappingURL=MediaStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MediaStream.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_EVENTS","MediaStream","constructor","arg","id","_reactTag","mediaStreamCreate","track","getTracks","addTrack","Array","isArray","streamId","streamReactTag","tracks","trackInfo","_tracks","push","MediaStreamTrack","TypeError","index","indexOf","mediaStreamAddTrack","removeTrack","splice","mediaStreamRemoveTrack","slice","getTrackById","trackId","find","getAudioTracks","filter","kind","getVideoTracks","clone","Error","toURL","release","releaseTracks","mediaStreamRelease"],"mappings":"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","sourcesContent":["\nimport { NativeModules } from 'react-native';\nimport { defineCustomEventTarget } from 'event-target-shim';\nimport { uniqueID } from './RTCUtil';\n\nimport MediaStreamTrack from './MediaStreamTrack';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_STREAM_EVENTS = ['active', 'inactive', 'addtrack', 'removetrack'];\n\nexport default class MediaStream extends defineCustomEventTarget(...MEDIA_STREAM_EVENTS) {\n id: string;\n active: boolean = true;\n\n _tracks: Array<MediaStreamTrack> = [];\n\n /**\n * The identifier of this MediaStream unique within the associated\n * WebRTCModule instance. As the id of a remote MediaStream instance is unique\n * only within the associated RTCPeerConnection, it is not sufficiently unique\n * to identify this MediaStream across multiple RTCPeerConnections and to\n * unambiguously differentiate it from a local MediaStream instance not added\n * to an RTCPeerConnection.\n */\n _reactTag: string;\n\n /**\n * A MediaStream can be constructed in several ways, depending on the paramters\n * that are passed here.\n *\n * - undefined: just a new stream, with no tracks.\n * - MediaStream instance: a new stream, with a copy of the tracks of the passed stream.\n * - Array of MediaStreamTrack: a new stream with a copy of the tracks in the array.\n * - object: a new stream instance, represented by the passed info object, this is always\n * done internally, when the stream is first created in native and the JS wrapper is\n * built afterwards.\n */\n constructor(arg) {\n super();\n\n // Assigm a UUID to start with. It may get overridden for remote streams.\n this.id = uniqueID();\n // Local MediaStreams are created by WebRTCModule to have their id and\n // reactTag equal because WebRTCModule follows the respective standard's\n // recommendation for id generation i.e. uses UUID which is unique enough\n // for the purposes of reactTag.\n this._reactTag = this.id;\n\n if (typeof arg === 'undefined') {\n WebRTCModule.mediaStreamCreate(this.id);\n } else if (arg instanceof MediaStream) {\n WebRTCModule.mediaStreamCreate(this.id);\n for (const track of arg.getTracks()) {\n this.addTrack(track);\n }\n } else if (Array.isArray(arg)) {\n WebRTCModule.mediaStreamCreate(this.id);\n for (const track of arg) {\n this.addTrack(track);\n }\n } else if (typeof arg === 'object' && arg.streamId && arg.streamReactTag && arg.tracks) {\n this.id = arg.streamId;\n this._reactTag = arg.streamReactTag;\n for (const trackInfo of arg.tracks) {\n // We are not using addTrack here because the track is already part of the\n // stream, so there is no need to add it on the native side.\n this._tracks.push(new MediaStreamTrack(trackInfo));\n }\n } else {\n throw new TypeError(`invalid type: ${typeof arg}`);\n }\n }\n\n addTrack(track: MediaStreamTrack) {\n const index = this._tracks.indexOf(track);\n if (index !== -1) {\n return;\n }\n this._tracks.push(track);\n WebRTCModule.mediaStreamAddTrack(this._reactTag, track.id);\n }\n\n removeTrack(track: MediaStreamTrack) {\n const index = this._tracks.indexOf(track);\n if (index === -1) {\n return;\n }\n this._tracks.splice(index, 1);\n WebRTCModule.mediaStreamRemoveTrack(this._reactTag, track.id);\n }\n\n getTracks(): Array<MediaStreamTrack> {\n return this._tracks.slice();\n }\n\n getTrackById(trackId): MediaStreamTrack | undefined {\n return this._tracks.find(track => track.id === trackId);\n }\n\n getAudioTracks(): Array<MediaStreamTrack> {\n return this._tracks.filter(track => track.kind === 'audio');\n }\n\n getVideoTracks(): Array<MediaStreamTrack> {\n return this._tracks.filter(track => track.kind === 'video');\n }\n\n clone() {\n throw new Error('Not implemented.');\n }\n\n toURL() {\n return this._reactTag;\n }\n\n release(releaseTracks = true) {\n const tracks = [...this._tracks];\n for (const track of tracks) {\n this.removeTrack(track);\n if (releaseTracks) {\n track.release();\n }\n }\n\n WebRTCModule.mediaStreamRelease(this._reactTag);\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
class MediaStreamError {
|
|
11
|
+
constructor(error) {
|
|
12
|
+
_defineProperty(this, "name", void 0);
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "message", void 0);
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "constraintName", void 0);
|
|
17
|
+
|
|
18
|
+
this.name = error.name;
|
|
19
|
+
this.message = error.message;
|
|
20
|
+
this.constraintName = error.constraintName;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.default = MediaStreamError;
|
|
26
|
+
//# sourceMappingURL=MediaStreamError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MediaStreamError.ts"],"names":["MediaStreamError","constructor","error","name","message","constraintName"],"mappings":";;;;;;;;;AACe,MAAMA,gBAAN,CAAuB;AAKlCC,EAAAA,WAAW,CAACC,KAAD,EAAQ;AAAA;;AAAA;;AAAA;;AACf,SAAKC,IAAL,GAAYD,KAAK,CAACC,IAAlB;AACA,SAAKC,OAAL,GAAeF,KAAK,CAACE,OAArB;AACA,SAAKC,cAAL,GAAsBH,KAAK,CAACG,cAA5B;AACH;;AATiC","sourcesContent":["\nexport default class MediaStreamError {\n name: string;\n message?: string;\n constraintName?: string;\n\n constructor(error) {\n this.name = error.name;\n this.message = error.message;\n this.constraintName = error.constraintName;\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
class MediaStreamErrorEvent {
|
|
11
|
+
constructor(type, eventInitDict) {
|
|
12
|
+
_defineProperty(this, "type", void 0);
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "error", void 0);
|
|
15
|
+
|
|
16
|
+
this.type = type.toString();
|
|
17
|
+
Object.assign(this, eventInitDict);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.default = MediaStreamErrorEvent;
|
|
23
|
+
//# sourceMappingURL=MediaStreamErrorEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MediaStreamErrorEvent.ts"],"names":["MediaStreamErrorEvent","constructor","type","eventInitDict","toString","Object","assign"],"mappings":";;;;;;;;;AAGe,MAAMA,qBAAN,CAA4B;AAGvCC,EAAAA,WAAW,CAACC,IAAD,EAAOC,aAAP,EAAsB;AAAA;;AAAA;;AAC7B,SAAKD,IAAL,GAAYA,IAAI,CAACE,QAAL,EAAZ;AACAC,IAAAA,MAAM,CAACC,MAAP,CAAc,IAAd,EAAoBH,aAApB;AACH;;AANsC","sourcesContent":["\nimport type MediaStreamError from './MediaStreamError';\n\nexport default class MediaStreamErrorEvent {\n type: string;\n error?: MediaStreamError;\n constructor(type, eventInitDict) {\n this.type = type.toString();\n Object.assign(this, eventInitDict);\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
class MediaStreamEvent {
|
|
11
|
+
constructor(type, eventInitDict) {
|
|
12
|
+
_defineProperty(this, "type", void 0);
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "stream", void 0);
|
|
15
|
+
|
|
16
|
+
this.type = type.toString();
|
|
17
|
+
this.stream = eventInitDict.stream;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.default = MediaStreamEvent;
|
|
23
|
+
//# sourceMappingURL=MediaStreamEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["MediaStreamEvent.ts"],"names":["MediaStreamEvent","constructor","type","eventInitDict","toString","stream"],"mappings":";;;;;;;;;AAGe,MAAMA,gBAAN,CAAuB;AAGlCC,EAAAA,WAAW,CAACC,IAAD,EAAOC,aAAP,EAA+C;AAAA;;AAAA;;AACtD,SAAKD,IAAL,GAAYA,IAAI,CAACE,QAAL,EAAZ;AACA,SAAKC,MAAL,GAAcF,aAAa,CAACE,MAA5B;AACH;;AANiC","sourcesContent":["\nimport type MediaStream from './MediaStream';\n\nexport default class MediaStreamEvent {\n type: string;\n stream: MediaStream;\n constructor(type, eventInitDict: { stream: MediaStream }) {\n this.type = type.toString();\n this.stream = eventInitDict.stream;\n }\n}\n"]}
|