react-native-webrtc 106.0.0-beta.5 → 106.0.0-beta.7
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 +2 -2
- package/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +18 -24
- package/android/src/main/java/com/oney/WebRTCModule/VideoTrackAdapter.java +1 -1
- package/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +59 -68
- package/ios/RCTWebRTC/RCTConvert+WebRTC.m +10 -0
- package/ios/RCTWebRTC/SerializeUtils.m +4 -2
- package/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +73 -60
- package/ios/RCTWebRTC/WebRTCModule+Transceivers.m +23 -22
- package/ios/RCTWebRTC/WebRTCModule+VideoTrackAdapter.m +1 -1
- package/ios/RCTWebRTC/WebRTCModule.h +0 -8
- package/ios/RCTWebRTC/WebRTCModule.m +1 -20
- package/lib/commonjs/MediaStreamTrack.js +24 -7
- package/lib/commonjs/MediaStreamTrack.js.map +1 -1
- package/lib/commonjs/RTCIceCandidate.js +14 -4
- package/lib/commonjs/RTCIceCandidate.js.map +1 -1
- package/lib/commonjs/RTCPeerConnection.js +129 -132
- package/lib/commonjs/RTCPeerConnection.js.map +1 -1
- package/lib/commonjs/RTCRtpSender.js +6 -5
- package/lib/commonjs/RTCRtpSender.js.map +1 -1
- package/lib/commonjs/RTCRtpTransceiver.js +11 -49
- package/lib/commonjs/RTCRtpTransceiver.js.map +1 -1
- package/lib/commonjs/RTCView.js +0 -55
- package/lib/commonjs/RTCView.js.map +1 -1
- package/lib/commonjs/index.js +3 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/MediaStreamTrack.js +25 -8
- package/lib/module/MediaStreamTrack.js.map +1 -1
- package/lib/module/RTCIceCandidate.js +14 -4
- package/lib/module/RTCIceCandidate.js.map +1 -1
- package/lib/module/RTCPeerConnection.js +129 -130
- package/lib/module/RTCPeerConnection.js.map +1 -1
- package/lib/module/RTCRtpSender.js +6 -5
- package/lib/module/RTCRtpSender.js.map +1 -1
- package/lib/module/RTCRtpTransceiver.js +11 -44
- package/lib/module/RTCRtpTransceiver.js.map +1 -1
- package/lib/module/RTCView.js +0 -49
- package/lib/module/RTCView.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/MediaStreamTrack.d.ts +11 -3
- package/lib/typescript/RTCIceCandidate.d.ts +5 -1
- package/lib/typescript/RTCPeerConnection.d.ts +5 -5
- package/lib/typescript/RTCRtpTransceiver.d.ts +2 -8
- package/lib/typescript/RTCView.d.ts +53 -46
- package/package.json +2 -2
- package/src/MediaStreamTrack.ts +23 -7
- package/src/RTCIceCandidate.ts +8 -5
- package/src/RTCPeerConnection.ts +133 -126
- package/src/RTCRtpSender.ts +6 -7
- package/src/RTCRtpTransceiver.ts +15 -45
- package/src/RTCView.ts +53 -49
- package/src/index.ts +2 -0
|
@@ -94,6 +94,7 @@ RCT_EXPORT_METHOD(senderSetParameters:(nonnull NSNumber *) objectID
|
|
|
94
94
|
if (peerConnection == nil) {
|
|
95
95
|
RCTLogWarn(@"PeerConnection %@ not found in senderSetParameters()", objectID);
|
|
96
96
|
reject(@"E_INVALID", @"Peer Connection is not initialized", nil);
|
|
97
|
+
return;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
RTCRtpTransceiver *transceiver = nil;
|
|
@@ -106,22 +107,28 @@ RCT_EXPORT_METHOD(senderSetParameters:(nonnull NSNumber *) objectID
|
|
|
106
107
|
|
|
107
108
|
if (transceiver == nil) {
|
|
108
109
|
RCTLogWarn(@"senderSetParameters() transceiver is null");
|
|
109
|
-
reject(@"E_INVALID", @"Could not get
|
|
110
|
+
reject(@"E_INVALID", @"Could not get transceiver", nil);
|
|
111
|
+
return;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
RTCRtpSender *sender = transceiver.sender;
|
|
113
115
|
RTCRtpParameters *parameters = sender.parameters;
|
|
114
116
|
[sender setParameters:[self updateParametersWithOptions: options params: parameters]];
|
|
117
|
+
|
|
118
|
+
resolve([SerializeUtils parametersToJSON: sender.parameters]);
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
RCT_EXPORT_METHOD(transceiverSetDirection:(nonnull NSNumber *) objectID
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
senderId:(NSString *)senderId
|
|
123
|
+
direction:(NSString *)direction
|
|
124
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
125
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
120
126
|
{
|
|
121
127
|
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
|
|
122
128
|
|
|
123
129
|
if (peerConnection == nil) {
|
|
124
130
|
RCTLogWarn(@"transceiverSetDirection() PeerConnection %@ not found in transceiverSetDirection()", objectID);
|
|
131
|
+
reject(@"E_INVALID", @"Peer Connection is not initialized", nil);
|
|
125
132
|
return;
|
|
126
133
|
}
|
|
127
134
|
|
|
@@ -135,34 +142,30 @@ RCT_EXPORT_METHOD(transceiverSetDirection:(nonnull NSNumber *) objectID
|
|
|
135
142
|
|
|
136
143
|
if (transceiver == nil) {
|
|
137
144
|
RCTLogWarn(@"transceiverSetDirection() transceiver is null");
|
|
145
|
+
reject(@"E_INVALID", @"Could not get transceiver", nil);
|
|
138
146
|
return;
|
|
139
147
|
}
|
|
140
|
-
|
|
141
|
-
NSMutableDictionary *identifier = [NSMutableDictionary new];
|
|
142
|
-
identifier[@"peerConnectionId"] = objectID;
|
|
143
|
-
identifier[@"transceiverId"] = senderId;
|
|
144
|
-
|
|
145
|
-
NSMutableDictionary *params = [NSMutableDictionary new];
|
|
146
|
-
RTCRtpTransceiverDirection oldDirrection = transceiver.direction;
|
|
147
|
-
params[@"oldDirection"] = [SerializeUtils serializeDirection: oldDirrection];
|
|
148
|
+
|
|
148
149
|
NSError *error;
|
|
149
150
|
[transceiver setDirection:[SerializeUtils parseDirection:direction] error: &error];
|
|
150
|
-
|
|
151
|
+
|
|
151
152
|
if (error) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
info: nil];
|
|
153
|
+
reject(@"E_SET_DIRECTION", @"Could not set direction", error);
|
|
154
|
+
} else {
|
|
155
|
+
resolve(@true);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
RCT_EXPORT_METHOD(transceiverStop:(nonnull NSNumber *) objectID
|
|
160
|
-
|
|
160
|
+
senderId:(NSString *)senderId
|
|
161
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
162
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
161
163
|
{
|
|
162
164
|
RTCPeerConnection *peerConnection = self.peerConnections[objectID];
|
|
163
165
|
|
|
164
166
|
if (peerConnection == nil) {
|
|
165
167
|
RCTLogWarn(@"PeerConnection %@ not found in transceiverStop()", objectID);
|
|
168
|
+
reject(@"E_INVALID", @"Peer Connection is not initialized", nil);
|
|
166
169
|
return;
|
|
167
170
|
}
|
|
168
171
|
|
|
@@ -176,15 +179,13 @@ RCT_EXPORT_METHOD(transceiverStop:(nonnull NSNumber *) objectID
|
|
|
176
179
|
|
|
177
180
|
if (transceiver == nil) {
|
|
178
181
|
RCTLogWarn(@"senderSetParameters() transceiver is null");
|
|
182
|
+
reject(@"E_INVALID", @"Could not get transceiver", nil);
|
|
179
183
|
return;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
[transceiver stopInternal];
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
@"peerConnectionId": objectID,
|
|
186
|
-
@"transceiverId": senderId
|
|
187
|
-
}];
|
|
187
|
+
|
|
188
|
+
resolve(@true);
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
- (RTCRtpParameters *) updateParametersWithOptions: (NSDictionary *) options
|
|
@@ -70,7 +70,7 @@ static const NSTimeInterval MUTE_DELAY = 1.5;
|
|
|
70
70
|
- (void)emitMuteEvent:(BOOL)muted {
|
|
71
71
|
[self.module sendEventWithName:kEventMediaStreamTrackMuteChanged
|
|
72
72
|
body:@{
|
|
73
|
-
@"
|
|
73
|
+
@"pcId": self.peerConnectionId,
|
|
74
74
|
@"trackId": self.trackId,
|
|
75
75
|
@"muted": @(muted)
|
|
76
76
|
}];
|
|
@@ -30,12 +30,9 @@ static NSString *const kEventPeerConnectionDidOpenDataChannel = @"peerConnection
|
|
|
30
30
|
static NSString *const kEventDataChannelStateChanged = @"dataChannelStateChanged";
|
|
31
31
|
static NSString *const kEventDataChannelReceiveMessage = @"dataChannelReceiveMessage";
|
|
32
32
|
static NSString *const kEventMediaStreamTrackMuteChanged = @"mediaStreamTrackMuteChanged";
|
|
33
|
-
static NSString *const kEventTransceiverStopSuccessful = @"transceiverStopSuccessful";
|
|
34
33
|
static NSString *const kEventTransceiverOnError = @"transceiverOnError";
|
|
35
34
|
static NSString *const kEventPeerConnectionOnRemoveTrack = @"peerConnectionOnRemoveTrack";
|
|
36
|
-
static NSString *const kEventPeerConnectionOnRemoveTrackSuccessful = @"peerConnectionOnRemoveTrackSuccessful";
|
|
37
35
|
static NSString *const kEventPeerConnectionOnTrack = @"peerConnectionOnTrack";
|
|
38
|
-
static NSString *const kEventPeerConnectionOnError = @"peerConnectionOnError";
|
|
39
36
|
|
|
40
37
|
@interface WebRTCModule : RCTEventEmitter <RCTBridgeModule>
|
|
41
38
|
|
|
@@ -54,9 +51,4 @@ static NSString *const kEventPeerConnectionOnError = @"peerConnectionOnError";
|
|
|
54
51
|
|
|
55
52
|
- (RTCMediaStream*)streamForReactTag:(NSString*)reactTag;
|
|
56
53
|
|
|
57
|
-
- (void)sendErrorWithEventName: (NSString *) eventName
|
|
58
|
-
funcName: (NSString *) funcName
|
|
59
|
-
message: (NSString *) message
|
|
60
|
-
info: (NSDictionary *) info;
|
|
61
|
-
|
|
62
54
|
@end
|
|
@@ -94,22 +94,6 @@
|
|
|
94
94
|
return stream;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
- (void)sendErrorWithEventName: (NSString *) eventName
|
|
98
|
-
funcName: (NSString *) funcName
|
|
99
|
-
message: (NSString *) message
|
|
100
|
-
info: (NSDictionary *) info {
|
|
101
|
-
NSMutableDictionary *errorInfo = [NSMutableDictionary new];
|
|
102
|
-
|
|
103
|
-
errorInfo[@"func"] = funcName;
|
|
104
|
-
if (info)
|
|
105
|
-
errorInfo[@"info"] = info;
|
|
106
|
-
if (message)
|
|
107
|
-
errorInfo[@"message"] = message;
|
|
108
|
-
|
|
109
|
-
[self sendEventWithName: kEventPeerConnectionOnError
|
|
110
|
-
body: errorInfo];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
97
|
RCT_EXPORT_MODULE();
|
|
114
98
|
|
|
115
99
|
- (dispatch_queue_t)methodQueue
|
|
@@ -129,12 +113,9 @@ RCT_EXPORT_MODULE();
|
|
|
129
113
|
kEventDataChannelStateChanged,
|
|
130
114
|
kEventDataChannelReceiveMessage,
|
|
131
115
|
kEventMediaStreamTrackMuteChanged,
|
|
132
|
-
kEventTransceiverStopSuccessful,
|
|
133
116
|
kEventTransceiverOnError,
|
|
134
117
|
kEventPeerConnectionOnRemoveTrack,
|
|
135
|
-
|
|
136
|
-
kEventPeerConnectionOnTrack,
|
|
137
|
-
kEventPeerConnectionOnError
|
|
118
|
+
kEventPeerConnectionOnTrack
|
|
138
119
|
];
|
|
139
120
|
}
|
|
140
121
|
|
|
@@ -32,14 +32,14 @@ class MediaStreamTrack extends (0, _eventTargetShim.defineCustomEventTarget)(...
|
|
|
32
32
|
|
|
33
33
|
_defineProperty(this, "_peerConnectionId", void 0);
|
|
34
34
|
|
|
35
|
+
_defineProperty(this, "_readyState", void 0);
|
|
36
|
+
|
|
35
37
|
_defineProperty(this, "id", void 0);
|
|
36
38
|
|
|
37
39
|
_defineProperty(this, "kind", void 0);
|
|
38
40
|
|
|
39
41
|
_defineProperty(this, "label", '');
|
|
40
42
|
|
|
41
|
-
_defineProperty(this, "readyState", void 0);
|
|
42
|
-
|
|
43
43
|
_defineProperty(this, "remote", void 0);
|
|
44
44
|
|
|
45
45
|
this._constraints = info.constraints || {};
|
|
@@ -47,13 +47,10 @@ class MediaStreamTrack extends (0, _eventTargetShim.defineCustomEventTarget)(...
|
|
|
47
47
|
this._settings = info.settings || {};
|
|
48
48
|
this._muted = false;
|
|
49
49
|
this._peerConnectionId = info.peerConnectionId;
|
|
50
|
+
this._readyState = info.readyState;
|
|
50
51
|
this.id = info.id;
|
|
51
52
|
this.kind = info.kind;
|
|
52
53
|
this.remote = info.remote;
|
|
53
|
-
|
|
54
|
-
const _readyState = info.readyState.toLowerCase();
|
|
55
|
-
|
|
56
|
-
this.readyState = _readyState === 'initializing' || _readyState === 'live' ? 'live' : 'ended';
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
get enabled() {
|
|
@@ -73,9 +70,13 @@ class MediaStreamTrack extends (0, _eventTargetShim.defineCustomEventTarget)(...
|
|
|
73
70
|
return this._muted;
|
|
74
71
|
}
|
|
75
72
|
|
|
73
|
+
get readyState() {
|
|
74
|
+
return this._readyState;
|
|
75
|
+
}
|
|
76
|
+
|
|
76
77
|
stop() {
|
|
77
78
|
WebRTCModule.mediaStreamTrackSetEnabled(this.id, false);
|
|
78
|
-
this.
|
|
79
|
+
this._readyState = 'ended'; // TODO: save some stopped flag?
|
|
79
80
|
}
|
|
80
81
|
/**
|
|
81
82
|
* Private / custom API for switching the cameras on the fly, without the
|
|
@@ -109,6 +110,22 @@ class MediaStreamTrack extends (0, _eventTargetShim.defineCustomEventTarget)(...
|
|
|
109
110
|
|
|
110
111
|
WebRTCModule.mediaStreamTrackSetVideoEffect(this.id, name);
|
|
111
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Internal function which is used to set the muted state on remote tracks and
|
|
115
|
+
* emit the mute / unmute event.
|
|
116
|
+
*
|
|
117
|
+
* @param muted Whether the track should be marked as muted / unmuted.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
_setMutedInternal(muted) {
|
|
122
|
+
if (!this.remote) {
|
|
123
|
+
throw new Error('Track is not remote!');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
this._muted = muted;
|
|
127
|
+
this.dispatchEvent(new _eventTargetShim.Event(muted ? 'mute' : 'unmute'));
|
|
128
|
+
}
|
|
112
129
|
|
|
113
130
|
applyConstraints() {
|
|
114
131
|
throw new Error('Not implemented.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["MediaStreamTrack.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_TRACK_EVENTS","MediaStreamTrack","constructor","info","_constraints","constraints","_enabled","enabled","_settings","settings","_muted","_peerConnectionId","peerConnectionId","
|
|
1
|
+
{"version":3,"sources":["MediaStreamTrack.ts"],"names":["WebRTCModule","NativeModules","MEDIA_STREAM_TRACK_EVENTS","MediaStreamTrack","constructor","info","_constraints","constraints","_enabled","enabled","_settings","settings","_muted","_peerConnectionId","peerConnectionId","_readyState","readyState","id","kind","remote","mediaStreamTrackSetEnabled","muted","stop","_switchCamera","Error","mediaStreamTrackSwitchCamera","_setVideoEffect","name","mediaStreamTrackSetVideoEffect","_setMutedInternal","dispatchEvent","Event","applyConstraints","clone","getCapabilities","getConstraints","getSettings","release","mediaStreamTrackRelease"],"mappings":"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","sourcesContent":["\nimport { defineCustomEventTarget, Event } from 'event-target-shim';\nimport { NativeModules } from 'react-native';\n\nimport { deepClone } from './RTCUtil';\n\nconst { WebRTCModule } = NativeModules;\n\nconst MEDIA_STREAM_TRACK_EVENTS = [ 'ended', 'mute', 'unmute' ];\n\ntype MediaStreamTrackState = 'live' | 'ended';\n\nclass MediaStreamTrack extends defineCustomEventTarget(...MEDIA_STREAM_TRACK_EVENTS) {\n _constraints: object;\n _enabled: boolean;\n _settings: object;\n _muted: boolean;\n _peerConnectionId: number;\n _readyState: MediaStreamTrackState;\n\n readonly id: string;\n readonly kind: string;\n readonly label: string = '';\n readonly remote: boolean;\n\n constructor(info) {\n super();\n\n this._constraints = info.constraints || {};\n this._enabled = info.enabled;\n this._settings = info.settings || {};\n this._muted = false;\n this._peerConnectionId = info.peerConnectionId;\n this._readyState = info.readyState;\n\n this.id = info.id;\n this.kind = info.kind;\n this.remote = info.remote;\n }\n\n get enabled(): boolean {\n return this._enabled;\n }\n\n set enabled(enabled: boolean) {\n if (enabled === this._enabled) {\n return;\n }\n\n WebRTCModule.mediaStreamTrackSetEnabled(this.id, !this._enabled);\n this._enabled = !this._enabled;\n }\n\n get muted(): boolean {\n return this._muted;\n }\n\n get readyState(): string {\n return this._readyState;\n }\n\n stop(): void {\n WebRTCModule.mediaStreamTrackSetEnabled(this.id, false);\n this._readyState = 'ended';\n // TODO: save some stopped flag?\n }\n\n /**\n * Private / custom API for switching the cameras on the fly, without the\n * need for adding / removing tracks or doing any SDP renegotiation.\n *\n * This is how the reference application (AppRTCMobile) implements camera\n * switching.\n */\n _switchCamera(): void {\n if (this.remote) {\n throw new Error('Not implemented for remote tracks');\n }\n\n if (this.kind !== 'video') {\n throw new Error('Only implemented for video tracks');\n }\n\n WebRTCModule.mediaStreamTrackSwitchCamera(this.id);\n }\n\n _setVideoEffect(name:string) {\n if (this.remote) {\n throw new Error('Not implemented for remote tracks');\n }\n\n if (this.kind !== 'video') {\n throw new Error('Only implemented for video tracks');\n }\n\n WebRTCModule.mediaStreamTrackSetVideoEffect(this.id, name);\n }\n\n /**\n * Internal function which is used to set the muted state on remote tracks and\n * emit the mute / unmute event.\n *\n * @param muted Whether the track should be marked as muted / unmuted.\n */\n _setMutedInternal(muted: boolean) {\n if (!this.remote) {\n throw new Error('Track is not remote!');\n }\n\n this._muted = muted;\n this.dispatchEvent(new Event(muted ? 'mute' : 'unmute'));\n }\n\n applyConstraints(): never {\n throw new Error('Not implemented.');\n }\n\n clone(): never {\n throw new Error('Not implemented.');\n }\n\n getCapabilities(): never {\n throw new Error('Not implemented.');\n }\n\n getConstraints() {\n return deepClone(this._constraints);\n }\n\n getSettings() {\n return deepClone(this._settings);\n }\n\n release(): void {\n WebRTCModule.mediaStreamTrackRelease(this.id);\n }\n}\n\nexport default MediaStreamTrack;\n"]}
|
|
@@ -8,16 +8,26 @@ exports.default = void 0;
|
|
|
8
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
9
|
|
|
10
10
|
class RTCIceCandidate {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(_ref) {
|
|
12
|
+
let {
|
|
13
|
+
candidate = '',
|
|
14
|
+
sdpMLineIndex = null,
|
|
15
|
+
sdpMid = null
|
|
16
|
+
} = _ref;
|
|
17
|
+
|
|
12
18
|
_defineProperty(this, "candidate", void 0);
|
|
13
19
|
|
|
14
20
|
_defineProperty(this, "sdpMLineIndex", void 0);
|
|
15
21
|
|
|
16
22
|
_defineProperty(this, "sdpMid", void 0);
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
if (sdpMLineIndex === null || sdpMid === null) {
|
|
25
|
+
throw new TypeError('`sdpMLineIndex` and `sdpMid` must not null');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.candidate = candidate;
|
|
29
|
+
this.sdpMLineIndex = sdpMLineIndex;
|
|
30
|
+
this.sdpMid = sdpMid;
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
toJSON() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RTCIceCandidate.ts"],"names":["RTCIceCandidate","constructor","
|
|
1
|
+
{"version":3,"sources":["RTCIceCandidate.ts"],"names":["RTCIceCandidate","constructor","candidate","sdpMLineIndex","sdpMid","TypeError","toJSON"],"mappings":";;;;;;;;;AAAe,MAAMA,eAAN,CAAsB;AAKjCC,EAAAA,WAAW,OAA0D;AAAA,QAAzD;AAAEC,MAAAA,SAAS,GAAG,EAAd;AAAkBC,MAAAA,aAAa,GAAG,IAAlC;AAAwCC,MAAAA,MAAM,GAAG;AAAjD,KAAyD;;AAAA;;AAAA;;AAAA;;AACjE,QAAID,aAAa,KAAK,IAAlB,IAA0BC,MAAM,KAAK,IAAzC,EAA+C;AAC3C,YAAM,IAAIC,SAAJ,CAAc,4CAAd,CAAN;AACH;;AAED,SAAKH,SAAL,GAAiBA,SAAjB;AACA,SAAKC,aAAL,GAAqBA,aAArB;AACA,SAAKC,MAAL,GAAcA,MAAd;AACH;;AAEDE,EAAAA,MAAM,GAAG;AACL,WAAO;AACHJ,MAAAA,SAAS,EAAE,KAAKA,SADb;AAEHC,MAAAA,aAAa,EAAE,KAAKA,aAFjB;AAGHC,MAAAA,MAAM,EAAE,KAAKA;AAHV,KAAP;AAKH;;AArBgC","sourcesContent":["export default class RTCIceCandidate {\n candidate: string;\n sdpMLineIndex: number;\n sdpMid: string;\n\n constructor({ candidate = '', sdpMLineIndex = null, sdpMid = null }) {\n if (sdpMLineIndex === null || sdpMid === null) {\n throw new TypeError('`sdpMLineIndex` and `sdpMid` must not null');\n }\n\n this.candidate = candidate;\n this.sdpMLineIndex = sdpMLineIndex;\n this.sdpMid = sdpMid;\n }\n\n toJSON() {\n return {\n candidate: this.candidate,\n sdpMLineIndex: this.sdpMLineIndex,\n sdpMid: this.sdpMid\n };\n }\n}\n"]}
|