mediasoup-client 3.6.89 → 3.6.90
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/lib/index.d.ts +1435 -14
- package/lib/index.js +11884 -43
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +11860 -0
- package/lib/index.mjs.map +1 -0
- package/npm-scripts.mjs +17 -11
- package/package.json +12 -8
- package/lib/Consumer.d.ts +0 -115
- package/lib/Consumer.d.ts.map +0 -1
- package/lib/Consumer.js +0 -190
- package/lib/DataConsumer.d.ts +0 -93
- package/lib/DataConsumer.d.ts.map +0 -1
- package/lib/DataConsumer.js +0 -162
- package/lib/DataProducer.d.ts +0 -97
- package/lib/DataProducer.d.ts.map +0 -1
- package/lib/DataProducer.js +0 -180
- package/lib/Device.d.ts +0 -92
- package/lib/Device.d.ts.map +0 -1
- package/lib/Device.js +0 -464
- package/lib/EnhancedEventEmitter.d.ts +0 -24
- package/lib/EnhancedEventEmitter.d.ts.map +0 -1
- package/lib/EnhancedEventEmitter.js +0 -70
- package/lib/Logger.d.ts +0 -11
- package/lib/Logger.d.ts.map +0 -1
- package/lib/Logger.js +0 -37
- package/lib/Producer.d.ts +0 -169
- package/lib/Producer.d.ts.map +0 -1
- package/lib/Producer.js +0 -287
- package/lib/RtpParameters.d.ts +0 -306
- package/lib/RtpParameters.d.ts.map +0 -1
- package/lib/RtpParameters.js +0 -6
- package/lib/SctpParameters.d.ts +0 -68
- package/lib/SctpParameters.d.ts.map +0 -1
- package/lib/SctpParameters.js +0 -2
- package/lib/Transport.d.ts +0 -243
- package/lib/Transport.d.ts.map +0 -1
- package/lib/Transport.js +0 -824
- package/lib/errors.d.ts +0 -13
- package/lib/errors.d.ts.map +0 -1
- package/lib/errors.js +0 -39
- package/lib/handlers/Chrome111.d.ts +0 -49
- package/lib/handlers/Chrome111.d.ts.map +0 -1
- package/lib/handlers/Chrome111.js +0 -658
- package/lib/handlers/Chrome55.d.ts +0 -51
- package/lib/handlers/Chrome55.d.ts.map +0 -1
- package/lib/handlers/Chrome55.js +0 -542
- package/lib/handlers/Chrome67.d.ts +0 -51
- package/lib/handlers/Chrome67.d.ts.map +0 -1
- package/lib/handlers/Chrome67.js +0 -598
- package/lib/handlers/Chrome70.d.ts +0 -49
- package/lib/handlers/Chrome70.d.ts.map +0 -1
- package/lib/handlers/Chrome70.js +0 -627
- package/lib/handlers/Chrome74.d.ts +0 -49
- package/lib/handlers/Chrome74.d.ts.map +0 -1
- package/lib/handlers/Chrome74.js +0 -675
- package/lib/handlers/Edge11.d.ts +0 -55
- package/lib/handlers/Edge11.d.ts.map +0 -1
- package/lib/handlers/Edge11.js +0 -447
- package/lib/handlers/FakeHandler.d.ts +0 -49
- package/lib/handlers/FakeHandler.d.ts.map +0 -1
- package/lib/handlers/FakeHandler.js +0 -276
- package/lib/handlers/Firefox60.d.ts +0 -48
- package/lib/handlers/Firefox60.d.ts.map +0 -1
- package/lib/handlers/Firefox60.js +0 -681
- package/lib/handlers/HandlerInterface.d.ts +0 -97
- package/lib/handlers/HandlerInterface.d.ts.map +0 -1
- package/lib/handlers/HandlerInterface.js +0 -10
- package/lib/handlers/ReactNative.d.ts +0 -51
- package/lib/handlers/ReactNative.d.ts.map +0 -1
- package/lib/handlers/ReactNative.js +0 -558
- package/lib/handlers/ReactNativeUnifiedPlan.d.ts +0 -49
- package/lib/handlers/ReactNativeUnifiedPlan.d.ts.map +0 -1
- package/lib/handlers/ReactNativeUnifiedPlan.js +0 -694
- package/lib/handlers/Safari11.d.ts +0 -51
- package/lib/handlers/Safari11.d.ts.map +0 -1
- package/lib/handlers/Safari11.js +0 -592
- package/lib/handlers/Safari12.d.ts +0 -49
- package/lib/handlers/Safari12.d.ts.map +0 -1
- package/lib/handlers/Safari12.js +0 -648
- package/lib/handlers/ortc/edgeUtils.d.ts +0 -11
- package/lib/handlers/ortc/edgeUtils.d.ts.map +0 -1
- package/lib/handlers/ortc/edgeUtils.js +0 -86
- package/lib/handlers/ortc/utils.d.ts +0 -6
- package/lib/handlers/ortc/utils.d.ts.map +0 -1
- package/lib/handlers/ortc/utils.js +0 -20
- package/lib/handlers/sdp/MediaSection.d.ts +0 -68
- package/lib/handlers/sdp/MediaSection.d.ts.map +0 -1
- package/lib/handlers/sdp/MediaSection.js +0 -589
- package/lib/handlers/sdp/RemoteSdp.d.ts +0 -75
- package/lib/handlers/sdp/RemoteSdp.d.ts.map +0 -1
- package/lib/handlers/sdp/RemoteSdp.js +0 -303
- package/lib/handlers/sdp/commonUtils.d.ts +0 -24
- package/lib/handlers/sdp/commonUtils.d.ts.map +0 -1
- package/lib/handlers/sdp/commonUtils.js +0 -224
- package/lib/handlers/sdp/plainRtpUtils.d.ts +0 -14
- package/lib/handlers/sdp/plainRtpUtils.d.ts.map +0 -1
- package/lib/handlers/sdp/plainRtpUtils.js +0 -33
- package/lib/handlers/sdp/planBUtils.d.ts +0 -14
- package/lib/handlers/sdp/planBUtils.d.ts.map +0 -1
- package/lib/handlers/sdp/planBUtils.js +0 -155
- package/lib/handlers/sdp/unifiedPlanUtils.d.ts +0 -12
- package/lib/handlers/sdp/unifiedPlanUtils.d.ts.map +0 -1
- package/lib/handlers/sdp/unifiedPlanUtils.js +0 -131
- package/lib/index.d.ts.map +0 -1
- package/lib/ortc.d.ts +0 -123
- package/lib/ortc.d.ts.map +0 -1
- package/lib/ortc.js +0 -943
- package/lib/scalabilityModes.d.ts +0 -6
- package/lib/scalabilityModes.d.ts.map +0 -1
- package/lib/scalabilityModes.js +0 -20
- package/lib/tests/fakeParameters.d.ts +0 -20
- package/lib/tests/fakeParameters.d.ts.map +0 -1
- package/lib/tests/fakeParameters.js +0 -659
- package/lib/tests/test.d.ts +0 -6
- package/lib/tests/test.d.ts.map +0 -1
- package/lib/tests/test.js +0 -1297
- package/lib/tests/uaTestCases.d.ts +0 -9
- package/lib/tests/uaTestCases.d.ts.map +0 -1
- package/lib/tests/uaTestCases.js +0 -85
- package/lib/types.d.ts +0 -15
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -26
- package/lib/utils.d.ts +0 -9
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -20
|
@@ -1,694 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ReactNativeUnifiedPlan = void 0;
|
|
27
|
-
const sdpTransform = __importStar(require("sdp-transform"));
|
|
28
|
-
const Logger_1 = require("../Logger");
|
|
29
|
-
const utils = __importStar(require("../utils"));
|
|
30
|
-
const ortc = __importStar(require("../ortc"));
|
|
31
|
-
const sdpCommonUtils = __importStar(require("./sdp/commonUtils"));
|
|
32
|
-
const sdpUnifiedPlanUtils = __importStar(require("./sdp/unifiedPlanUtils"));
|
|
33
|
-
const ortcUtils = __importStar(require("./ortc/utils"));
|
|
34
|
-
const HandlerInterface_1 = require("./HandlerInterface");
|
|
35
|
-
const RemoteSdp_1 = require("./sdp/RemoteSdp");
|
|
36
|
-
const scalabilityModes_1 = require("../scalabilityModes");
|
|
37
|
-
const logger = new Logger_1.Logger('ReactNativeUnifiedPlan');
|
|
38
|
-
const SCTP_NUM_STREAMS = { OS: 1024, MIS: 1024 };
|
|
39
|
-
class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
|
|
40
|
-
/**
|
|
41
|
-
* Creates a factory function.
|
|
42
|
-
*/
|
|
43
|
-
static createFactory() {
|
|
44
|
-
return () => new ReactNativeUnifiedPlan();
|
|
45
|
-
}
|
|
46
|
-
constructor() {
|
|
47
|
-
super();
|
|
48
|
-
// Map of RTCTransceivers indexed by MID.
|
|
49
|
-
this._mapMidTransceiver = new Map();
|
|
50
|
-
// Local stream for sending.
|
|
51
|
-
this._sendStream = new MediaStream();
|
|
52
|
-
// Whether a DataChannel m=application section has been created.
|
|
53
|
-
this._hasDataChannelMediaSection = false;
|
|
54
|
-
// Sending DataChannel id value counter. Incremented for each new DataChannel.
|
|
55
|
-
this._nextSendSctpStreamId = 0;
|
|
56
|
-
// Got transport local and remote parameters.
|
|
57
|
-
this._transportReady = false;
|
|
58
|
-
}
|
|
59
|
-
get name() {
|
|
60
|
-
return 'ReactNativeUnifiedPlan';
|
|
61
|
-
}
|
|
62
|
-
close() {
|
|
63
|
-
logger.debug('close()');
|
|
64
|
-
// Free/dispose native MediaStream but DO NOT free/dispose native
|
|
65
|
-
// MediaStreamTracks (that is parent's business).
|
|
66
|
-
// @ts-ignore (proprietary API in react-native-webrtc).
|
|
67
|
-
this._sendStream.release(/* releaseTracks */ false);
|
|
68
|
-
// Close RTCPeerConnection.
|
|
69
|
-
if (this._pc) {
|
|
70
|
-
try {
|
|
71
|
-
this._pc.close();
|
|
72
|
-
}
|
|
73
|
-
catch (error) { }
|
|
74
|
-
}
|
|
75
|
-
this.emit('@close');
|
|
76
|
-
}
|
|
77
|
-
async getNativeRtpCapabilities() {
|
|
78
|
-
logger.debug('getNativeRtpCapabilities()');
|
|
79
|
-
const pc = new RTCPeerConnection({
|
|
80
|
-
iceServers: [],
|
|
81
|
-
iceTransportPolicy: 'all',
|
|
82
|
-
bundlePolicy: 'max-bundle',
|
|
83
|
-
rtcpMuxPolicy: 'require',
|
|
84
|
-
sdpSemantics: 'unified-plan'
|
|
85
|
-
});
|
|
86
|
-
try {
|
|
87
|
-
pc.addTransceiver('audio');
|
|
88
|
-
pc.addTransceiver('video');
|
|
89
|
-
const offer = await pc.createOffer();
|
|
90
|
-
try {
|
|
91
|
-
pc.close();
|
|
92
|
-
}
|
|
93
|
-
catch (error) { }
|
|
94
|
-
const sdpObject = sdpTransform.parse(offer.sdp);
|
|
95
|
-
const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities({ sdpObject });
|
|
96
|
-
// libwebrtc supports NACK for OPUS but doesn't announce it.
|
|
97
|
-
ortcUtils.addNackSuppportForOpus(nativeRtpCapabilities);
|
|
98
|
-
return nativeRtpCapabilities;
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
try {
|
|
102
|
-
pc.close();
|
|
103
|
-
}
|
|
104
|
-
catch (error2) { }
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async getNativeSctpCapabilities() {
|
|
109
|
-
logger.debug('getNativeSctpCapabilities()');
|
|
110
|
-
return {
|
|
111
|
-
numStreams: SCTP_NUM_STREAMS
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities }) {
|
|
115
|
-
logger.debug('run()');
|
|
116
|
-
this._direction = direction;
|
|
117
|
-
this._remoteSdp = new RemoteSdp_1.RemoteSdp({
|
|
118
|
-
iceParameters,
|
|
119
|
-
iceCandidates,
|
|
120
|
-
dtlsParameters,
|
|
121
|
-
sctpParameters
|
|
122
|
-
});
|
|
123
|
-
this._sendingRtpParametersByKind =
|
|
124
|
-
{
|
|
125
|
-
audio: ortc.getSendingRtpParameters('audio', extendedRtpCapabilities),
|
|
126
|
-
video: ortc.getSendingRtpParameters('video', extendedRtpCapabilities)
|
|
127
|
-
};
|
|
128
|
-
this._sendingRemoteRtpParametersByKind =
|
|
129
|
-
{
|
|
130
|
-
audio: ortc.getSendingRemoteRtpParameters('audio', extendedRtpCapabilities),
|
|
131
|
-
video: ortc.getSendingRemoteRtpParameters('video', extendedRtpCapabilities)
|
|
132
|
-
};
|
|
133
|
-
if (dtlsParameters.role && dtlsParameters.role !== 'auto') {
|
|
134
|
-
this._forcedLocalDtlsRole = dtlsParameters.role === 'server'
|
|
135
|
-
? 'client'
|
|
136
|
-
: 'server';
|
|
137
|
-
}
|
|
138
|
-
this._pc = new RTCPeerConnection({
|
|
139
|
-
iceServers: iceServers || [],
|
|
140
|
-
iceTransportPolicy: iceTransportPolicy || 'all',
|
|
141
|
-
bundlePolicy: 'max-bundle',
|
|
142
|
-
rtcpMuxPolicy: 'require',
|
|
143
|
-
sdpSemantics: 'unified-plan',
|
|
144
|
-
...additionalSettings
|
|
145
|
-
}, proprietaryConstraints);
|
|
146
|
-
if (this._pc.connectionState) {
|
|
147
|
-
this._pc.addEventListener('connectionstatechange', () => {
|
|
148
|
-
this.emit('@connectionstatechange', this._pc.connectionState);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
this._pc.addEventListener('iceconnectionstatechange', () => {
|
|
153
|
-
logger.warn('run() | pc.connectionState not supported, using pc.iceConnectionState');
|
|
154
|
-
switch (this._pc.iceConnectionState) {
|
|
155
|
-
case 'checking':
|
|
156
|
-
this.emit('@connectionstatechange', 'connecting');
|
|
157
|
-
break;
|
|
158
|
-
case 'connected':
|
|
159
|
-
case 'completed':
|
|
160
|
-
this.emit('@connectionstatechange', 'connected');
|
|
161
|
-
break;
|
|
162
|
-
case 'failed':
|
|
163
|
-
this.emit('@connectionstatechange', 'failed');
|
|
164
|
-
break;
|
|
165
|
-
case 'disconnected':
|
|
166
|
-
this.emit('@connectionstatechange', 'disconnected');
|
|
167
|
-
break;
|
|
168
|
-
case 'closed':
|
|
169
|
-
this.emit('@connectionstatechange', 'closed');
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
async updateIceServers(iceServers) {
|
|
176
|
-
logger.debug('updateIceServers()');
|
|
177
|
-
const configuration = this._pc.getConfiguration();
|
|
178
|
-
configuration.iceServers = iceServers;
|
|
179
|
-
this._pc.setConfiguration(configuration);
|
|
180
|
-
}
|
|
181
|
-
async restartIce(iceParameters) {
|
|
182
|
-
logger.debug('restartIce()');
|
|
183
|
-
// Provide the remote SDP handler with new remote ICE parameters.
|
|
184
|
-
this._remoteSdp.updateIceParameters(iceParameters);
|
|
185
|
-
if (!this._transportReady) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (this._direction === 'send') {
|
|
189
|
-
const offer = await this._pc.createOffer({ iceRestart: true });
|
|
190
|
-
logger.debug('restartIce() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
191
|
-
await this._pc.setLocalDescription(offer);
|
|
192
|
-
const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
|
|
193
|
-
logger.debug('restartIce() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
194
|
-
await this._pc.setRemoteDescription(answer);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
|
|
198
|
-
logger.debug('restartIce() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
199
|
-
await this._pc.setRemoteDescription(offer);
|
|
200
|
-
const answer = await this._pc.createAnswer();
|
|
201
|
-
logger.debug('restartIce() | calling pc.setLocalDescription() [answer:%o]', answer);
|
|
202
|
-
await this._pc.setLocalDescription(answer);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
async getTransportStats() {
|
|
206
|
-
return this._pc.getStats();
|
|
207
|
-
}
|
|
208
|
-
async send({ track, encodings, codecOptions, codec }) {
|
|
209
|
-
var _a, _b;
|
|
210
|
-
this.assertSendDirection();
|
|
211
|
-
logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
|
|
212
|
-
if (encodings && encodings.length > 1) {
|
|
213
|
-
encodings.forEach((encoding, idx) => {
|
|
214
|
-
encoding.rid = `r${idx}`;
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
const sendingRtpParameters = utils.clone(this._sendingRtpParametersByKind[track.kind], {});
|
|
218
|
-
// This may throw.
|
|
219
|
-
sendingRtpParameters.codecs =
|
|
220
|
-
ortc.reduceCodecs(sendingRtpParameters.codecs, codec);
|
|
221
|
-
const sendingRemoteRtpParameters = utils.clone(this._sendingRemoteRtpParametersByKind[track.kind], {});
|
|
222
|
-
// This may throw.
|
|
223
|
-
sendingRemoteRtpParameters.codecs =
|
|
224
|
-
ortc.reduceCodecs(sendingRemoteRtpParameters.codecs, codec);
|
|
225
|
-
const mediaSectionIdx = this._remoteSdp.getNextMediaSectionIdx();
|
|
226
|
-
const transceiver = this._pc.addTransceiver(track, {
|
|
227
|
-
direction: 'sendonly',
|
|
228
|
-
streams: [this._sendStream],
|
|
229
|
-
sendEncodings: encodings
|
|
230
|
-
});
|
|
231
|
-
let offer = await this._pc.createOffer();
|
|
232
|
-
let localSdpObject = sdpTransform.parse(offer.sdp);
|
|
233
|
-
let offerMediaObject;
|
|
234
|
-
if (!this._transportReady) {
|
|
235
|
-
await this.setupTransport({
|
|
236
|
-
localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
|
|
237
|
-
localSdpObject
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
// Special case for VP9 with SVC.
|
|
241
|
-
let hackVp9Svc = false;
|
|
242
|
-
const layers = (0, scalabilityModes_1.parse)((encodings || [{}])[0].scalabilityMode);
|
|
243
|
-
if (encodings &&
|
|
244
|
-
encodings.length === 1 &&
|
|
245
|
-
layers.spatialLayers > 1 &&
|
|
246
|
-
sendingRtpParameters.codecs[0].mimeType.toLowerCase() === 'video/vp9') {
|
|
247
|
-
logger.debug('send() | enabling legacy simulcast for VP9 SVC');
|
|
248
|
-
hackVp9Svc = true;
|
|
249
|
-
localSdpObject = sdpTransform.parse(offer.sdp);
|
|
250
|
-
offerMediaObject = localSdpObject.media[mediaSectionIdx.idx];
|
|
251
|
-
sdpUnifiedPlanUtils.addLegacySimulcast({
|
|
252
|
-
offerMediaObject,
|
|
253
|
-
numStreams: layers.spatialLayers
|
|
254
|
-
});
|
|
255
|
-
offer = { type: 'offer', sdp: sdpTransform.write(localSdpObject) };
|
|
256
|
-
}
|
|
257
|
-
logger.debug('send() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
258
|
-
await this._pc.setLocalDescription(offer);
|
|
259
|
-
// We can now get the transceiver.mid.
|
|
260
|
-
// NOTE: We cannot read generated MID on iOS react-native-webrtc 111.0.0
|
|
261
|
-
// because transceiver.mid is not available until setRemoteDescription()
|
|
262
|
-
// is called, so this is best effort.
|
|
263
|
-
// Issue: https://github.com/react-native-webrtc/react-native-webrtc/issues/1404
|
|
264
|
-
// NOTE: So let's fill MID in sendingRtpParameters later.
|
|
265
|
-
let localId = (_b = transceiver.mid) !== null && _b !== void 0 ? _b : undefined;
|
|
266
|
-
if (!localId) {
|
|
267
|
-
logger.warn('send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround');
|
|
268
|
-
}
|
|
269
|
-
// Set MID.
|
|
270
|
-
// NOTE: As per above, it could be unset yet.
|
|
271
|
-
sendingRtpParameters.mid = localId;
|
|
272
|
-
localSdpObject = sdpTransform.parse(this._pc.localDescription.sdp);
|
|
273
|
-
offerMediaObject = localSdpObject.media[mediaSectionIdx.idx];
|
|
274
|
-
// Set RTCP CNAME.
|
|
275
|
-
sendingRtpParameters.rtcp.cname =
|
|
276
|
-
sdpCommonUtils.getCname({ offerMediaObject });
|
|
277
|
-
// Set RTP encodings by parsing the SDP offer if no encodings are given.
|
|
278
|
-
if (!encodings) {
|
|
279
|
-
sendingRtpParameters.encodings =
|
|
280
|
-
sdpUnifiedPlanUtils.getRtpEncodings({ offerMediaObject });
|
|
281
|
-
}
|
|
282
|
-
// Set RTP encodings by parsing the SDP offer and complete them with given
|
|
283
|
-
// one if just a single encoding has been given.
|
|
284
|
-
else if (encodings.length === 1) {
|
|
285
|
-
let newEncodings = sdpUnifiedPlanUtils.getRtpEncodings({ offerMediaObject });
|
|
286
|
-
Object.assign(newEncodings[0], encodings[0]);
|
|
287
|
-
// Hack for VP9 SVC.
|
|
288
|
-
if (hackVp9Svc) {
|
|
289
|
-
newEncodings = [newEncodings[0]];
|
|
290
|
-
}
|
|
291
|
-
sendingRtpParameters.encodings = newEncodings;
|
|
292
|
-
}
|
|
293
|
-
// Otherwise if more than 1 encoding are given use them verbatim.
|
|
294
|
-
else {
|
|
295
|
-
sendingRtpParameters.encodings = encodings;
|
|
296
|
-
}
|
|
297
|
-
// If VP8 or H264 and there is effective simulcast, add scalabilityMode to
|
|
298
|
-
// each encoding.
|
|
299
|
-
if (sendingRtpParameters.encodings.length > 1 &&
|
|
300
|
-
(sendingRtpParameters.codecs[0].mimeType.toLowerCase() === 'video/vp8' ||
|
|
301
|
-
sendingRtpParameters.codecs[0].mimeType.toLowerCase() === 'video/h264')) {
|
|
302
|
-
for (const encoding of sendingRtpParameters.encodings) {
|
|
303
|
-
if (encoding.scalabilityMode) {
|
|
304
|
-
encoding.scalabilityMode = `L1T${layers.temporalLayers}`;
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
encoding.scalabilityMode = 'L1T3';
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
this._remoteSdp.send({
|
|
312
|
-
offerMediaObject,
|
|
313
|
-
reuseMid: mediaSectionIdx.reuseMid,
|
|
314
|
-
offerRtpParameters: sendingRtpParameters,
|
|
315
|
-
answerRtpParameters: sendingRemoteRtpParameters,
|
|
316
|
-
codecOptions,
|
|
317
|
-
extmapAllowMixed: true
|
|
318
|
-
});
|
|
319
|
-
const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
|
|
320
|
-
logger.debug('send() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
321
|
-
await this._pc.setRemoteDescription(answer);
|
|
322
|
-
// Follow up of iOS react-native-webrtc 111.0.0 issue told above. Now yes,
|
|
323
|
-
// we can read generated MID (if not done above) and fill sendingRtpParameters.
|
|
324
|
-
if (!localId) {
|
|
325
|
-
localId = transceiver.mid;
|
|
326
|
-
sendingRtpParameters.mid = localId;
|
|
327
|
-
}
|
|
328
|
-
// Store in the map.
|
|
329
|
-
this._mapMidTransceiver.set(localId, transceiver);
|
|
330
|
-
return {
|
|
331
|
-
localId,
|
|
332
|
-
rtpParameters: sendingRtpParameters,
|
|
333
|
-
rtpSender: transceiver.sender
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
async stopSending(localId) {
|
|
337
|
-
this.assertSendDirection();
|
|
338
|
-
logger.debug('stopSending() [localId:%s]', localId);
|
|
339
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
340
|
-
if (!transceiver) {
|
|
341
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
342
|
-
}
|
|
343
|
-
transceiver.sender.replaceTrack(null);
|
|
344
|
-
this._pc.removeTrack(transceiver.sender);
|
|
345
|
-
const mediaSectionClosed = this._remoteSdp.closeMediaSection(transceiver.mid);
|
|
346
|
-
if (mediaSectionClosed) {
|
|
347
|
-
try {
|
|
348
|
-
transceiver.stop();
|
|
349
|
-
}
|
|
350
|
-
catch (error) { }
|
|
351
|
-
}
|
|
352
|
-
const offer = await this._pc.createOffer();
|
|
353
|
-
logger.debug('stopSending() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
354
|
-
await this._pc.setLocalDescription(offer);
|
|
355
|
-
const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
|
|
356
|
-
logger.debug('stopSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
357
|
-
await this._pc.setRemoteDescription(answer);
|
|
358
|
-
this._mapMidTransceiver.delete(localId);
|
|
359
|
-
}
|
|
360
|
-
async pauseSending(localId) {
|
|
361
|
-
this.assertSendDirection();
|
|
362
|
-
logger.debug('pauseSending() [localId:%s]', localId);
|
|
363
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
364
|
-
if (!transceiver) {
|
|
365
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
366
|
-
}
|
|
367
|
-
transceiver.direction = 'inactive';
|
|
368
|
-
this._remoteSdp.pauseMediaSection(localId);
|
|
369
|
-
const offer = await this._pc.createOffer();
|
|
370
|
-
logger.debug('pauseSending() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
371
|
-
await this._pc.setLocalDescription(offer);
|
|
372
|
-
const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
|
|
373
|
-
logger.debug('pauseSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
374
|
-
await this._pc.setRemoteDescription(answer);
|
|
375
|
-
}
|
|
376
|
-
async resumeSending(localId) {
|
|
377
|
-
this.assertSendDirection();
|
|
378
|
-
logger.debug('resumeSending() [localId:%s]', localId);
|
|
379
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
380
|
-
this._remoteSdp.resumeSendingMediaSection(localId);
|
|
381
|
-
if (!transceiver) {
|
|
382
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
383
|
-
}
|
|
384
|
-
transceiver.direction = 'sendonly';
|
|
385
|
-
const offer = await this._pc.createOffer();
|
|
386
|
-
logger.debug('resumeSending() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
387
|
-
await this._pc.setLocalDescription(offer);
|
|
388
|
-
const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
|
|
389
|
-
logger.debug('resumeSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
390
|
-
await this._pc.setRemoteDescription(answer);
|
|
391
|
-
}
|
|
392
|
-
async replaceTrack(localId, track) {
|
|
393
|
-
this.assertSendDirection();
|
|
394
|
-
if (track) {
|
|
395
|
-
logger.debug('replaceTrack() [localId:%s, track.id:%s]', localId, track.id);
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
logger.debug('replaceTrack() [localId:%s, no track]', localId);
|
|
399
|
-
}
|
|
400
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
401
|
-
if (!transceiver) {
|
|
402
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
403
|
-
}
|
|
404
|
-
await transceiver.sender.replaceTrack(track);
|
|
405
|
-
}
|
|
406
|
-
async setMaxSpatialLayer(localId, spatialLayer) {
|
|
407
|
-
this.assertSendDirection();
|
|
408
|
-
logger.debug('setMaxSpatialLayer() [localId:%s, spatialLayer:%s]', localId, spatialLayer);
|
|
409
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
410
|
-
if (!transceiver) {
|
|
411
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
412
|
-
}
|
|
413
|
-
const parameters = transceiver.sender.getParameters();
|
|
414
|
-
parameters.encodings.forEach((encoding, idx) => {
|
|
415
|
-
if (idx <= spatialLayer) {
|
|
416
|
-
encoding.active = true;
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
encoding.active = false;
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
await transceiver.sender.setParameters(parameters);
|
|
423
|
-
this._remoteSdp.muxMediaSectionSimulcast(localId, parameters.encodings);
|
|
424
|
-
const offer = await this._pc.createOffer();
|
|
425
|
-
logger.debug('setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
426
|
-
await this._pc.setLocalDescription(offer);
|
|
427
|
-
const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
|
|
428
|
-
logger.debug('setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
429
|
-
await this._pc.setRemoteDescription(answer);
|
|
430
|
-
}
|
|
431
|
-
async setRtpEncodingParameters(localId, params) {
|
|
432
|
-
this.assertSendDirection();
|
|
433
|
-
logger.debug('setRtpEncodingParameters() [localId:%s, params:%o]', localId, params);
|
|
434
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
435
|
-
if (!transceiver) {
|
|
436
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
437
|
-
}
|
|
438
|
-
const parameters = transceiver.sender.getParameters();
|
|
439
|
-
parameters.encodings.forEach((encoding, idx) => {
|
|
440
|
-
parameters.encodings[idx] = { ...encoding, ...params };
|
|
441
|
-
});
|
|
442
|
-
await transceiver.sender.setParameters(parameters);
|
|
443
|
-
this._remoteSdp.muxMediaSectionSimulcast(localId, parameters.encodings);
|
|
444
|
-
const offer = await this._pc.createOffer();
|
|
445
|
-
logger.debug('setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
446
|
-
await this._pc.setLocalDescription(offer);
|
|
447
|
-
const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
|
|
448
|
-
logger.debug('setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
449
|
-
await this._pc.setRemoteDescription(answer);
|
|
450
|
-
}
|
|
451
|
-
async getSenderStats(localId) {
|
|
452
|
-
this.assertSendDirection();
|
|
453
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
454
|
-
if (!transceiver) {
|
|
455
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
456
|
-
}
|
|
457
|
-
return transceiver.sender.getStats();
|
|
458
|
-
}
|
|
459
|
-
async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }) {
|
|
460
|
-
var _a;
|
|
461
|
-
this.assertSendDirection();
|
|
462
|
-
const options = {
|
|
463
|
-
negotiated: true,
|
|
464
|
-
id: this._nextSendSctpStreamId,
|
|
465
|
-
ordered,
|
|
466
|
-
maxPacketLifeTime,
|
|
467
|
-
maxRetransmits,
|
|
468
|
-
protocol
|
|
469
|
-
};
|
|
470
|
-
logger.debug('sendDataChannel() [options:%o]', options);
|
|
471
|
-
const dataChannel = this._pc.createDataChannel(label, options);
|
|
472
|
-
// Increase next id.
|
|
473
|
-
this._nextSendSctpStreamId =
|
|
474
|
-
++this._nextSendSctpStreamId % SCTP_NUM_STREAMS.MIS;
|
|
475
|
-
// If this is the first DataChannel we need to create the SDP answer with
|
|
476
|
-
// m=application section.
|
|
477
|
-
if (!this._hasDataChannelMediaSection) {
|
|
478
|
-
const offer = await this._pc.createOffer();
|
|
479
|
-
const localSdpObject = sdpTransform.parse(offer.sdp);
|
|
480
|
-
const offerMediaObject = localSdpObject.media
|
|
481
|
-
.find((m) => m.type === 'application');
|
|
482
|
-
if (!this._transportReady) {
|
|
483
|
-
await this.setupTransport({
|
|
484
|
-
localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
|
|
485
|
-
localSdpObject
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
logger.debug('sendDataChannel() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
489
|
-
await this._pc.setLocalDescription(offer);
|
|
490
|
-
this._remoteSdp.sendSctpAssociation({ offerMediaObject });
|
|
491
|
-
const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
|
|
492
|
-
logger.debug('sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
493
|
-
await this._pc.setRemoteDescription(answer);
|
|
494
|
-
this._hasDataChannelMediaSection = true;
|
|
495
|
-
}
|
|
496
|
-
const sctpStreamParameters = {
|
|
497
|
-
streamId: options.id,
|
|
498
|
-
ordered: options.ordered,
|
|
499
|
-
maxPacketLifeTime: options.maxPacketLifeTime,
|
|
500
|
-
maxRetransmits: options.maxRetransmits
|
|
501
|
-
};
|
|
502
|
-
return { dataChannel, sctpStreamParameters };
|
|
503
|
-
}
|
|
504
|
-
async receive(optionsList) {
|
|
505
|
-
var _a;
|
|
506
|
-
this.assertRecvDirection();
|
|
507
|
-
const results = [];
|
|
508
|
-
const mapLocalId = new Map();
|
|
509
|
-
for (const options of optionsList) {
|
|
510
|
-
const { trackId, kind, rtpParameters, streamId } = options;
|
|
511
|
-
logger.debug('receive() [trackId:%s, kind:%s]', trackId, kind);
|
|
512
|
-
const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
|
|
513
|
-
mapLocalId.set(trackId, localId);
|
|
514
|
-
this._remoteSdp.receive({
|
|
515
|
-
mid: localId,
|
|
516
|
-
kind,
|
|
517
|
-
offerRtpParameters: rtpParameters,
|
|
518
|
-
streamId: streamId || rtpParameters.rtcp.cname,
|
|
519
|
-
trackId
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
|
|
523
|
-
logger.debug('receive() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
524
|
-
await this._pc.setRemoteDescription(offer);
|
|
525
|
-
let answer = await this._pc.createAnswer();
|
|
526
|
-
const localSdpObject = sdpTransform.parse(answer.sdp);
|
|
527
|
-
for (const options of optionsList) {
|
|
528
|
-
const { trackId, rtpParameters } = options;
|
|
529
|
-
const localId = mapLocalId.get(trackId);
|
|
530
|
-
const answerMediaObject = localSdpObject.media
|
|
531
|
-
.find((m) => String(m.mid) === localId);
|
|
532
|
-
// May need to modify codec parameters in the answer based on codec
|
|
533
|
-
// parameters in the offer.
|
|
534
|
-
sdpCommonUtils.applyCodecParameters({
|
|
535
|
-
offerRtpParameters: rtpParameters,
|
|
536
|
-
answerMediaObject
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
answer = { type: 'answer', sdp: sdpTransform.write(localSdpObject) };
|
|
540
|
-
if (!this._transportReady) {
|
|
541
|
-
await this.setupTransport({
|
|
542
|
-
localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
|
|
543
|
-
localSdpObject
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
logger.debug('receive() | calling pc.setLocalDescription() [answer:%o]', answer);
|
|
547
|
-
await this._pc.setLocalDescription(answer);
|
|
548
|
-
for (const options of optionsList) {
|
|
549
|
-
const { trackId } = options;
|
|
550
|
-
const localId = mapLocalId.get(trackId);
|
|
551
|
-
const transceiver = this._pc.getTransceivers()
|
|
552
|
-
.find((t) => t.mid === localId);
|
|
553
|
-
if (!transceiver) {
|
|
554
|
-
throw new Error('new RTCRtpTransceiver not found');
|
|
555
|
-
}
|
|
556
|
-
else {
|
|
557
|
-
// Store in the map.
|
|
558
|
-
this._mapMidTransceiver.set(localId, transceiver);
|
|
559
|
-
results.push({
|
|
560
|
-
localId,
|
|
561
|
-
track: transceiver.receiver.track,
|
|
562
|
-
rtpReceiver: transceiver.receiver
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
return results;
|
|
567
|
-
}
|
|
568
|
-
async stopReceiving(localIds) {
|
|
569
|
-
this.assertRecvDirection();
|
|
570
|
-
for (const localId of localIds) {
|
|
571
|
-
logger.debug('stopReceiving() [localId:%s]', localId);
|
|
572
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
573
|
-
if (!transceiver) {
|
|
574
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
575
|
-
}
|
|
576
|
-
this._remoteSdp.closeMediaSection(transceiver.mid);
|
|
577
|
-
}
|
|
578
|
-
const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
|
|
579
|
-
logger.debug('stopReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
580
|
-
await this._pc.setRemoteDescription(offer);
|
|
581
|
-
const answer = await this._pc.createAnswer();
|
|
582
|
-
logger.debug('stopReceiving() | calling pc.setLocalDescription() [answer:%o]', answer);
|
|
583
|
-
await this._pc.setLocalDescription(answer);
|
|
584
|
-
for (const localId of localIds) {
|
|
585
|
-
this._mapMidTransceiver.delete(localId);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
async pauseReceiving(localIds) {
|
|
589
|
-
this.assertRecvDirection();
|
|
590
|
-
for (const localId of localIds) {
|
|
591
|
-
logger.debug('pauseReceiving() [localId:%s]', localId);
|
|
592
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
593
|
-
if (!transceiver) {
|
|
594
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
595
|
-
}
|
|
596
|
-
transceiver.direction = 'inactive';
|
|
597
|
-
this._remoteSdp.pauseMediaSection(localId);
|
|
598
|
-
}
|
|
599
|
-
const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
|
|
600
|
-
logger.debug('pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
601
|
-
await this._pc.setRemoteDescription(offer);
|
|
602
|
-
const answer = await this._pc.createAnswer();
|
|
603
|
-
logger.debug('pauseReceiving() | calling pc.setLocalDescription() [answer:%o]', answer);
|
|
604
|
-
await this._pc.setLocalDescription(answer);
|
|
605
|
-
}
|
|
606
|
-
async resumeReceiving(localIds) {
|
|
607
|
-
this.assertRecvDirection();
|
|
608
|
-
for (const localId of localIds) {
|
|
609
|
-
logger.debug('resumeReceiving() [localId:%s]', localId);
|
|
610
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
611
|
-
if (!transceiver) {
|
|
612
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
613
|
-
}
|
|
614
|
-
transceiver.direction = 'recvonly';
|
|
615
|
-
this._remoteSdp.resumeReceivingMediaSection(localId);
|
|
616
|
-
}
|
|
617
|
-
const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
|
|
618
|
-
logger.debug('resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
619
|
-
await this._pc.setRemoteDescription(offer);
|
|
620
|
-
const answer = await this._pc.createAnswer();
|
|
621
|
-
logger.debug('resumeReceiving() | calling pc.setLocalDescription() [answer:%o]', answer);
|
|
622
|
-
await this._pc.setLocalDescription(answer);
|
|
623
|
-
}
|
|
624
|
-
async getReceiverStats(localId) {
|
|
625
|
-
this.assertRecvDirection();
|
|
626
|
-
const transceiver = this._mapMidTransceiver.get(localId);
|
|
627
|
-
if (!transceiver) {
|
|
628
|
-
throw new Error('associated RTCRtpTransceiver not found');
|
|
629
|
-
}
|
|
630
|
-
return transceiver.receiver.getStats();
|
|
631
|
-
}
|
|
632
|
-
async receiveDataChannel({ sctpStreamParameters, label, protocol }) {
|
|
633
|
-
var _a;
|
|
634
|
-
this.assertRecvDirection();
|
|
635
|
-
const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
|
|
636
|
-
const options = {
|
|
637
|
-
negotiated: true,
|
|
638
|
-
id: streamId,
|
|
639
|
-
ordered,
|
|
640
|
-
maxPacketLifeTime,
|
|
641
|
-
maxRetransmits,
|
|
642
|
-
protocol
|
|
643
|
-
};
|
|
644
|
-
logger.debug('receiveDataChannel() [options:%o]', options);
|
|
645
|
-
const dataChannel = this._pc.createDataChannel(label, options);
|
|
646
|
-
// If this is the first DataChannel we need to create the SDP offer with
|
|
647
|
-
// m=application section.
|
|
648
|
-
if (!this._hasDataChannelMediaSection) {
|
|
649
|
-
this._remoteSdp.receiveSctpAssociation();
|
|
650
|
-
const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
|
|
651
|
-
logger.debug('receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
652
|
-
await this._pc.setRemoteDescription(offer);
|
|
653
|
-
const answer = await this._pc.createAnswer();
|
|
654
|
-
if (!this._transportReady) {
|
|
655
|
-
const localSdpObject = sdpTransform.parse(answer.sdp);
|
|
656
|
-
await this.setupTransport({
|
|
657
|
-
localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
|
|
658
|
-
localSdpObject
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
logger.debug('receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
662
|
-
await this._pc.setLocalDescription(answer);
|
|
663
|
-
this._hasDataChannelMediaSection = true;
|
|
664
|
-
}
|
|
665
|
-
return { dataChannel };
|
|
666
|
-
}
|
|
667
|
-
async setupTransport({ localDtlsRole, localSdpObject }) {
|
|
668
|
-
if (!localSdpObject) {
|
|
669
|
-
localSdpObject = sdpTransform.parse(this._pc.localDescription.sdp);
|
|
670
|
-
}
|
|
671
|
-
// Get our local DTLS parameters.
|
|
672
|
-
const dtlsParameters = sdpCommonUtils.extractDtlsParameters({ sdpObject: localSdpObject });
|
|
673
|
-
// Set our DTLS role.
|
|
674
|
-
dtlsParameters.role = localDtlsRole;
|
|
675
|
-
// Update the remote DTLS role in the SDP.
|
|
676
|
-
this._remoteSdp.updateDtlsRole(localDtlsRole === 'client' ? 'server' : 'client');
|
|
677
|
-
// Need to tell the remote transport about our parameters.
|
|
678
|
-
await new Promise((resolve, reject) => {
|
|
679
|
-
this.safeEmit('@connect', { dtlsParameters }, resolve, reject);
|
|
680
|
-
});
|
|
681
|
-
this._transportReady = true;
|
|
682
|
-
}
|
|
683
|
-
assertSendDirection() {
|
|
684
|
-
if (this._direction !== 'send') {
|
|
685
|
-
throw new Error('method can just be called for handlers with "send" direction');
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
assertRecvDirection() {
|
|
689
|
-
if (this._direction !== 'recv') {
|
|
690
|
-
throw new Error('method can just be called for handlers with "recv" direction');
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
exports.ReactNativeUnifiedPlan = ReactNativeUnifiedPlan;
|