mediasoup-client 3.13.0 → 3.14.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/lib/Consumer.d.ts.map +1 -1
- package/lib/Consumer.js +3 -0
- package/lib/DataConsumer.d.ts.map +1 -1
- package/lib/DataConsumer.js +8 -8
- package/lib/DataProducer.d.ts.map +1 -1
- package/lib/DataProducer.js +8 -7
- package/lib/Device.d.ts +2 -2
- package/lib/Device.d.ts.map +1 -1
- package/lib/Device.js +53 -70
- package/lib/Producer.d.ts.map +1 -1
- package/lib/Producer.js +3 -0
- package/lib/RtpParameters.d.ts +8 -8
- package/lib/RtpParameters.d.ts.map +1 -1
- package/lib/Transport.d.ts +4 -4
- package/lib/Transport.d.ts.map +1 -1
- package/lib/Transport.js +9 -7
- package/lib/enhancedEvents.d.ts +4 -0
- package/lib/enhancedEvents.d.ts.map +1 -1
- package/lib/enhancedEvents.js +7 -0
- package/lib/handlers/Chrome111.d.ts +13 -13
- package/lib/handlers/Chrome111.d.ts.map +1 -1
- package/lib/handlers/Chrome111.js +175 -124
- package/lib/handlers/Chrome74.d.ts +13 -13
- package/lib/handlers/Chrome74.d.ts.map +1 -1
- package/lib/handlers/Chrome74.js +175 -120
- package/lib/handlers/FakeHandler.d.ts +8 -10
- package/lib/handlers/FakeHandler.d.ts.map +1 -1
- package/lib/handlers/FakeHandler.js +204 -61
- package/lib/handlers/Firefox120.d.ts +13 -13
- package/lib/handlers/Firefox120.d.ts.map +1 -1
- package/lib/handlers/Firefox120.js +200 -147
- package/lib/handlers/HandlerInterface.d.ts +11 -9
- package/lib/handlers/HandlerInterface.d.ts.map +1 -1
- package/lib/handlers/ReactNative106.d.ts +13 -13
- package/lib/handlers/ReactNative106.d.ts.map +1 -1
- package/lib/handlers/ReactNative106.js +181 -127
- package/lib/handlers/Safari12.d.ts +13 -13
- package/lib/handlers/Safari12.d.ts.map +1 -1
- package/lib/handlers/Safari12.js +178 -116
- package/lib/handlers/sdp/MediaSection.d.ts +5 -5
- package/lib/handlers/sdp/MediaSection.d.ts.map +1 -1
- package/lib/handlers/sdp/MediaSection.js +43 -45
- package/lib/handlers/sdp/RemoteSdp.d.ts +5 -6
- package/lib/handlers/sdp/RemoteSdp.d.ts.map +1 -1
- package/lib/handlers/sdp/RemoteSdp.js +5 -8
- package/lib/handlers/sdp/commonUtils.d.ts +5 -4
- package/lib/handlers/sdp/commonUtils.d.ts.map +1 -1
- package/lib/handlers/sdp/commonUtils.js +2 -2
- package/lib/handlers/sdp/plainRtpUtils.d.ts +4 -3
- package/lib/handlers/sdp/plainRtpUtils.d.ts.map +1 -1
- package/lib/handlers/sdp/plainRtpUtils.js +2 -2
- package/lib/handlers/sdp/unifiedPlanUtils.d.ts +3 -2
- package/lib/handlers/sdp/unifiedPlanUtils.d.ts.map +1 -1
- package/lib/handlers/sdp/unifiedPlanUtils.js +10 -8
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/ortc.d.ts +7 -6
- package/lib/ortc.d.ts.map +1 -1
- package/lib/ortc.js +13 -14
- package/lib/privateTypes.d.ts +27 -0
- package/lib/privateTypes.d.ts.map +1 -0
- package/lib/privateTypes.js +2 -0
- package/lib/test/test.js +22 -3
- package/lib/utils.d.ts +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +5 -4
- package/package.json +8 -9
package/lib/handlers/Chrome74.js
CHANGED
|
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Chrome74 = void 0;
|
|
4
4
|
const sdpTransform = require("sdp-transform");
|
|
5
5
|
const Logger_1 = require("../Logger");
|
|
6
|
+
const enhancedEvents_1 = require("../enhancedEvents");
|
|
6
7
|
const utils = require("../utils");
|
|
7
8
|
const ortc = require("../ortc");
|
|
9
|
+
const errors_1 = require("../errors");
|
|
10
|
+
const scalabilityModes_1 = require("../scalabilityModes");
|
|
8
11
|
const sdpCommonUtils = require("./sdp/commonUtils");
|
|
9
12
|
const sdpUnifiedPlanUtils = require("./sdp/unifiedPlanUtils");
|
|
10
13
|
const ortcUtils = require("./ortc/utils");
|
|
11
|
-
const errors_1 = require("../errors");
|
|
12
|
-
const HandlerInterface_1 = require("./HandlerInterface");
|
|
13
14
|
const RemoteSdp_1 = require("./sdp/RemoteSdp");
|
|
14
|
-
const scalabilityModes_1 = require("../scalabilityModes");
|
|
15
15
|
const logger = new Logger_1.Logger('Chrome74');
|
|
16
16
|
const NAME = 'Chrome74';
|
|
17
17
|
const SCTP_NUM_STREAMS = { OS: 1024, MIS: 1024 };
|
|
18
|
-
class Chrome74 extends
|
|
18
|
+
class Chrome74 extends enhancedEvents_1.EnhancedEventEmitter {
|
|
19
19
|
// Closed flag.
|
|
20
20
|
_closed = false;
|
|
21
21
|
// Handler direction.
|
|
@@ -46,70 +46,54 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
46
46
|
* Creates a factory function.
|
|
47
47
|
*/
|
|
48
48
|
static createFactory() {
|
|
49
|
-
return () => new Chrome74();
|
|
50
|
-
}
|
|
51
|
-
constructor() {
|
|
52
|
-
super();
|
|
53
|
-
}
|
|
54
|
-
get name() {
|
|
55
|
-
return NAME;
|
|
56
|
-
}
|
|
57
|
-
close() {
|
|
58
|
-
logger.debug('close()');
|
|
59
|
-
if (this._closed) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
this._closed = true;
|
|
63
|
-
// Close RTCPeerConnection.
|
|
64
|
-
if (this._pc) {
|
|
65
|
-
try {
|
|
66
|
-
this._pc.close();
|
|
67
|
-
}
|
|
68
|
-
catch (error) { }
|
|
69
|
-
}
|
|
70
|
-
this.emit('@close');
|
|
71
|
-
}
|
|
72
|
-
async getNativeRtpCapabilities() {
|
|
73
|
-
logger.debug('getNativeRtpCapabilities()');
|
|
74
|
-
const pc = new RTCPeerConnection({
|
|
75
|
-
iceServers: [],
|
|
76
|
-
iceTransportPolicy: 'all',
|
|
77
|
-
bundlePolicy: 'max-bundle',
|
|
78
|
-
rtcpMuxPolicy: 'require',
|
|
79
|
-
sdpSemantics: 'unified-plan',
|
|
80
|
-
});
|
|
81
|
-
try {
|
|
82
|
-
pc.addTransceiver('audio');
|
|
83
|
-
pc.addTransceiver('video');
|
|
84
|
-
const offer = await pc.createOffer();
|
|
85
|
-
try {
|
|
86
|
-
pc.close();
|
|
87
|
-
}
|
|
88
|
-
catch (error) { }
|
|
89
|
-
const sdpObject = sdpTransform.parse(offer.sdp);
|
|
90
|
-
const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities({
|
|
91
|
-
sdpObject,
|
|
92
|
-
});
|
|
93
|
-
// libwebrtc supports NACK for OPUS but doesn't announce it.
|
|
94
|
-
ortcUtils.addNackSupportForOpus(nativeRtpCapabilities);
|
|
95
|
-
return nativeRtpCapabilities;
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
try {
|
|
99
|
-
pc.close();
|
|
100
|
-
}
|
|
101
|
-
catch (error2) { }
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async getNativeSctpCapabilities() {
|
|
106
|
-
logger.debug('getNativeSctpCapabilities()');
|
|
107
49
|
return {
|
|
108
|
-
|
|
50
|
+
name: NAME,
|
|
51
|
+
factory: (options) => new Chrome74(options),
|
|
52
|
+
getNativeRtpCapabilities: async () => {
|
|
53
|
+
logger.debug('getNativeRtpCapabilities()');
|
|
54
|
+
let pc = new RTCPeerConnection({
|
|
55
|
+
iceServers: [],
|
|
56
|
+
iceTransportPolicy: 'all',
|
|
57
|
+
bundlePolicy: 'max-bundle',
|
|
58
|
+
rtcpMuxPolicy: 'require',
|
|
59
|
+
});
|
|
60
|
+
try {
|
|
61
|
+
pc.addTransceiver('audio');
|
|
62
|
+
pc.addTransceiver('video');
|
|
63
|
+
const offer = await pc.createOffer();
|
|
64
|
+
try {
|
|
65
|
+
pc.close();
|
|
66
|
+
}
|
|
67
|
+
catch (error) { }
|
|
68
|
+
pc = undefined;
|
|
69
|
+
const sdpObject = sdpTransform.parse(offer.sdp);
|
|
70
|
+
const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities({
|
|
71
|
+
sdpObject,
|
|
72
|
+
});
|
|
73
|
+
// libwebrtc supports NACK for OPUS but doesn't announce it.
|
|
74
|
+
ortcUtils.addNackSupportForOpus(nativeRtpCapabilities);
|
|
75
|
+
return nativeRtpCapabilities;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
try {
|
|
79
|
+
pc?.close();
|
|
80
|
+
}
|
|
81
|
+
catch (error2) { }
|
|
82
|
+
pc = undefined;
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
getNativeSctpCapabilities: async () => {
|
|
87
|
+
logger.debug('getNativeSctpCapabilities()');
|
|
88
|
+
return {
|
|
89
|
+
numStreams: SCTP_NUM_STREAMS,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
109
92
|
};
|
|
110
93
|
}
|
|
111
|
-
|
|
112
|
-
|
|
94
|
+
constructor({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, extendedRtpCapabilities, }) {
|
|
95
|
+
super();
|
|
96
|
+
logger.debug('constructor()');
|
|
113
97
|
this._direction = direction;
|
|
114
98
|
this._remoteSdp = new RemoteSdp_1.RemoteSdp({
|
|
115
99
|
iceParameters,
|
|
@@ -134,49 +118,40 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
134
118
|
iceTransportPolicy: iceTransportPolicy ?? 'all',
|
|
135
119
|
bundlePolicy: 'max-bundle',
|
|
136
120
|
rtcpMuxPolicy: 'require',
|
|
137
|
-
sdpSemantics: 'unified-plan',
|
|
138
121
|
...additionalSettings,
|
|
139
|
-
}, proprietaryConstraints);
|
|
140
|
-
this._pc.addEventListener('icegatheringstatechange', () => {
|
|
141
|
-
this.emit('@icegatheringstatechange', this._pc.iceGatheringState);
|
|
142
|
-
});
|
|
143
|
-
this._pc.addEventListener('icecandidateerror', (event) => {
|
|
144
|
-
this.emit('@icecandidateerror', event);
|
|
145
122
|
});
|
|
123
|
+
this._pc.addEventListener('icegatheringstatechange', this.onIceGatheringStateChange);
|
|
124
|
+
this._pc.addEventListener('icecandidateerror', this.onIceCandidateError);
|
|
146
125
|
if (this._pc.connectionState) {
|
|
147
|
-
this._pc.addEventListener('connectionstatechange',
|
|
148
|
-
this.emit('@connectionstatechange', this._pc.connectionState);
|
|
149
|
-
});
|
|
126
|
+
this._pc.addEventListener('connectionstatechange', this.onConnectionStateChange);
|
|
150
127
|
}
|
|
151
128
|
else {
|
|
152
129
|
logger.warn('run() | pc.connectionState not supported, using pc.iceConnectionState');
|
|
153
|
-
this._pc.addEventListener('iceconnectionstatechange',
|
|
154
|
-
switch (this._pc.iceConnectionState) {
|
|
155
|
-
case 'checking': {
|
|
156
|
-
this.emit('@connectionstatechange', 'connecting');
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
case 'connected':
|
|
160
|
-
case 'completed': {
|
|
161
|
-
this.emit('@connectionstatechange', 'connected');
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
case 'failed': {
|
|
165
|
-
this.emit('@connectionstatechange', 'failed');
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
case 'disconnected': {
|
|
169
|
-
this.emit('@connectionstatechange', 'disconnected');
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
case 'closed': {
|
|
173
|
-
this.emit('@connectionstatechange', 'closed');
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
});
|
|
130
|
+
this._pc.addEventListener('iceconnectionstatechange', this.onIceConnectionStateChange);
|
|
178
131
|
}
|
|
179
132
|
}
|
|
133
|
+
get name() {
|
|
134
|
+
return NAME;
|
|
135
|
+
}
|
|
136
|
+
close() {
|
|
137
|
+
logger.debug('close()');
|
|
138
|
+
if (this._closed) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this._closed = true;
|
|
142
|
+
// Close RTCPeerConnection.
|
|
143
|
+
try {
|
|
144
|
+
this._pc.close();
|
|
145
|
+
}
|
|
146
|
+
catch (error) { }
|
|
147
|
+
this._pc.removeEventListener('icegatheringstatechange', this.onIceGatheringStateChange);
|
|
148
|
+
this._pc.removeEventListener('icecandidateerror', this.onIceCandidateError);
|
|
149
|
+
this._pc.removeEventListener('connectionstatechange', this.onConnectionStateChange);
|
|
150
|
+
this._pc.removeEventListener('iceconnectionstatechange', this.onIceConnectionStateChange);
|
|
151
|
+
this.emit('@close');
|
|
152
|
+
// Invoke close() in EnhancedEventEmitter classes.
|
|
153
|
+
super.close();
|
|
154
|
+
}
|
|
180
155
|
async updateIceServers(iceServers) {
|
|
181
156
|
this.assertNotClosed();
|
|
182
157
|
logger.debug('updateIceServers()');
|
|
@@ -196,12 +171,18 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
196
171
|
const offer = await this._pc.createOffer({ iceRestart: true });
|
|
197
172
|
logger.debug('restartIce() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
198
173
|
await this._pc.setLocalDescription(offer);
|
|
199
|
-
const answer = {
|
|
174
|
+
const answer = {
|
|
175
|
+
type: 'answer',
|
|
176
|
+
sdp: this._remoteSdp.getSdp(),
|
|
177
|
+
};
|
|
200
178
|
logger.debug('restartIce() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
201
179
|
await this._pc.setRemoteDescription(answer);
|
|
202
180
|
}
|
|
203
181
|
else {
|
|
204
|
-
const offer = {
|
|
182
|
+
const offer = {
|
|
183
|
+
type: 'offer',
|
|
184
|
+
sdp: this._remoteSdp.getSdp(),
|
|
185
|
+
};
|
|
205
186
|
logger.debug('restartIce() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
206
187
|
await this._pc.setRemoteDescription(offer);
|
|
207
188
|
const answer = await this._pc.createAnswer();
|
|
@@ -236,8 +217,6 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
236
217
|
});
|
|
237
218
|
let offer = await this._pc.createOffer();
|
|
238
219
|
let localSdpObject = sdpTransform.parse(offer.sdp);
|
|
239
|
-
// @ts-expect-error --- sdpTransform.SessionDescription type doesn't
|
|
240
|
-
// define extmapAllowMixed field.
|
|
241
220
|
if (localSdpObject.extmapAllowMixed) {
|
|
242
221
|
this._remoteSdp.setSessionExtmapAllowMixed();
|
|
243
222
|
}
|
|
@@ -263,7 +242,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
263
242
|
offerMediaObject,
|
|
264
243
|
numStreams: layers.spatialLayers,
|
|
265
244
|
});
|
|
266
|
-
offer = {
|
|
245
|
+
offer = {
|
|
246
|
+
type: 'offer',
|
|
247
|
+
sdp: sdpTransform.write(localSdpObject),
|
|
248
|
+
};
|
|
267
249
|
}
|
|
268
250
|
logger.debug('send() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
269
251
|
await this._pc.setLocalDescription(offer);
|
|
@@ -321,7 +303,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
321
303
|
answerRtpParameters: sendingRemoteRtpParameters,
|
|
322
304
|
codecOptions,
|
|
323
305
|
});
|
|
324
|
-
const answer = {
|
|
306
|
+
const answer = {
|
|
307
|
+
type: 'answer',
|
|
308
|
+
sdp: this._remoteSdp.getSdp(),
|
|
309
|
+
};
|
|
325
310
|
logger.debug('send() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
326
311
|
await this._pc.setRemoteDescription(answer);
|
|
327
312
|
// Store in the map.
|
|
@@ -354,7 +339,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
354
339
|
const offer = await this._pc.createOffer();
|
|
355
340
|
logger.debug('stopSending() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
356
341
|
await this._pc.setLocalDescription(offer);
|
|
357
|
-
const answer = {
|
|
342
|
+
const answer = {
|
|
343
|
+
type: 'answer',
|
|
344
|
+
sdp: this._remoteSdp.getSdp(),
|
|
345
|
+
};
|
|
358
346
|
logger.debug('stopSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
359
347
|
await this._pc.setRemoteDescription(answer);
|
|
360
348
|
this._mapMidTransceiver.delete(localId);
|
|
@@ -372,7 +360,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
372
360
|
const offer = await this._pc.createOffer();
|
|
373
361
|
logger.debug('pauseSending() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
374
362
|
await this._pc.setLocalDescription(offer);
|
|
375
|
-
const answer = {
|
|
363
|
+
const answer = {
|
|
364
|
+
type: 'answer',
|
|
365
|
+
sdp: this._remoteSdp.getSdp(),
|
|
366
|
+
};
|
|
376
367
|
logger.debug('pauseSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
377
368
|
await this._pc.setRemoteDescription(answer);
|
|
378
369
|
}
|
|
@@ -389,7 +380,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
389
380
|
const offer = await this._pc.createOffer();
|
|
390
381
|
logger.debug('resumeSending() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
391
382
|
await this._pc.setLocalDescription(offer);
|
|
392
|
-
const answer = {
|
|
383
|
+
const answer = {
|
|
384
|
+
type: 'answer',
|
|
385
|
+
sdp: this._remoteSdp.getSdp(),
|
|
386
|
+
};
|
|
393
387
|
logger.debug('resumeSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
394
388
|
await this._pc.setRemoteDescription(answer);
|
|
395
389
|
}
|
|
@@ -430,7 +424,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
430
424
|
const offer = await this._pc.createOffer();
|
|
431
425
|
logger.debug('setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
432
426
|
await this._pc.setLocalDescription(offer);
|
|
433
|
-
const answer = {
|
|
427
|
+
const answer = {
|
|
428
|
+
type: 'answer',
|
|
429
|
+
sdp: this._remoteSdp.getSdp(),
|
|
430
|
+
};
|
|
434
431
|
logger.debug('setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
435
432
|
await this._pc.setRemoteDescription(answer);
|
|
436
433
|
}
|
|
@@ -451,7 +448,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
451
448
|
const offer = await this._pc.createOffer();
|
|
452
449
|
logger.debug('setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
453
450
|
await this._pc.setLocalDescription(offer);
|
|
454
|
-
const answer = {
|
|
451
|
+
const answer = {
|
|
452
|
+
type: 'answer',
|
|
453
|
+
sdp: this._remoteSdp.getSdp(),
|
|
454
|
+
};
|
|
455
455
|
logger.debug('setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
456
456
|
await this._pc.setRemoteDescription(answer);
|
|
457
457
|
}
|
|
@@ -485,7 +485,7 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
485
485
|
if (!this._hasDataChannelMediaSection) {
|
|
486
486
|
const offer = await this._pc.createOffer();
|
|
487
487
|
const localSdpObject = sdpTransform.parse(offer.sdp);
|
|
488
|
-
const offerMediaObject = localSdpObject.media.find(
|
|
488
|
+
const offerMediaObject = localSdpObject.media.find(m => m.type === 'application');
|
|
489
489
|
if (!this._transportReady) {
|
|
490
490
|
await this.setupTransport({
|
|
491
491
|
localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
|
|
@@ -495,7 +495,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
495
495
|
logger.debug('sendDataChannel() | calling pc.setLocalDescription() [offer:%o]', offer);
|
|
496
496
|
await this._pc.setLocalDescription(offer);
|
|
497
497
|
this._remoteSdp.sendSctpAssociation({ offerMediaObject });
|
|
498
|
-
const answer = {
|
|
498
|
+
const answer = {
|
|
499
|
+
type: 'answer',
|
|
500
|
+
sdp: this._remoteSdp.getSdp(),
|
|
501
|
+
};
|
|
499
502
|
logger.debug('sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]', answer);
|
|
500
503
|
await this._pc.setRemoteDescription(answer);
|
|
501
504
|
this._hasDataChannelMediaSection = true;
|
|
@@ -526,7 +529,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
526
529
|
trackId,
|
|
527
530
|
});
|
|
528
531
|
}
|
|
529
|
-
const offer = {
|
|
532
|
+
const offer = {
|
|
533
|
+
type: 'offer',
|
|
534
|
+
sdp: this._remoteSdp.getSdp(),
|
|
535
|
+
};
|
|
530
536
|
logger.debug('receive() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
531
537
|
await this._pc.setRemoteDescription(offer);
|
|
532
538
|
let answer = await this._pc.createAnswer();
|
|
@@ -534,7 +540,7 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
534
540
|
for (const options of optionsList) {
|
|
535
541
|
const { trackId, rtpParameters } = options;
|
|
536
542
|
const localId = mapLocalId.get(trackId);
|
|
537
|
-
const answerMediaObject = localSdpObject.media.find(
|
|
543
|
+
const answerMediaObject = localSdpObject.media.find(m => String(m.mid) === localId);
|
|
538
544
|
// May need to modify codec parameters in the answer based on codec
|
|
539
545
|
// parameters in the offer.
|
|
540
546
|
sdpCommonUtils.applyCodecParameters({
|
|
@@ -542,7 +548,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
542
548
|
answerMediaObject,
|
|
543
549
|
});
|
|
544
550
|
}
|
|
545
|
-
answer = {
|
|
551
|
+
answer = {
|
|
552
|
+
type: 'answer',
|
|
553
|
+
sdp: sdpTransform.write(localSdpObject),
|
|
554
|
+
};
|
|
546
555
|
if (!this._transportReady) {
|
|
547
556
|
await this.setupTransport({
|
|
548
557
|
localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
|
|
@@ -585,7 +594,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
585
594
|
}
|
|
586
595
|
this._remoteSdp.closeMediaSection(transceiver.mid);
|
|
587
596
|
}
|
|
588
|
-
const offer = {
|
|
597
|
+
const offer = {
|
|
598
|
+
type: 'offer',
|
|
599
|
+
sdp: this._remoteSdp.getSdp(),
|
|
600
|
+
};
|
|
589
601
|
logger.debug('stopReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
590
602
|
await this._pc.setRemoteDescription(offer);
|
|
591
603
|
const answer = await this._pc.createAnswer();
|
|
@@ -607,7 +619,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
607
619
|
transceiver.direction = 'inactive';
|
|
608
620
|
this._remoteSdp.pauseMediaSection(localId);
|
|
609
621
|
}
|
|
610
|
-
const offer = {
|
|
622
|
+
const offer = {
|
|
623
|
+
type: 'offer',
|
|
624
|
+
sdp: this._remoteSdp.getSdp(),
|
|
625
|
+
};
|
|
611
626
|
logger.debug('pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
612
627
|
await this._pc.setRemoteDescription(offer);
|
|
613
628
|
const answer = await this._pc.createAnswer();
|
|
@@ -626,7 +641,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
626
641
|
transceiver.direction = 'recvonly';
|
|
627
642
|
this._remoteSdp.resumeReceivingMediaSection(localId);
|
|
628
643
|
}
|
|
629
|
-
const offer = {
|
|
644
|
+
const offer = {
|
|
645
|
+
type: 'offer',
|
|
646
|
+
sdp: this._remoteSdp.getSdp(),
|
|
647
|
+
};
|
|
630
648
|
logger.debug('resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
631
649
|
await this._pc.setRemoteDescription(offer);
|
|
632
650
|
const answer = await this._pc.createAnswer();
|
|
@@ -660,7 +678,10 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
660
678
|
// m=application section.
|
|
661
679
|
if (!this._hasDataChannelMediaSection) {
|
|
662
680
|
this._remoteSdp.receiveSctpAssociation();
|
|
663
|
-
const offer = {
|
|
681
|
+
const offer = {
|
|
682
|
+
type: 'offer',
|
|
683
|
+
sdp: this._remoteSdp.getSdp(),
|
|
684
|
+
};
|
|
664
685
|
logger.debug('receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]', offer);
|
|
665
686
|
await this._pc.setRemoteDescription(offer);
|
|
666
687
|
const answer = await this._pc.createAnswer();
|
|
@@ -695,6 +716,40 @@ class Chrome74 extends HandlerInterface_1.HandlerInterface {
|
|
|
695
716
|
});
|
|
696
717
|
this._transportReady = true;
|
|
697
718
|
}
|
|
719
|
+
onIceGatheringStateChange = () => {
|
|
720
|
+
this.emit('@icegatheringstatechange', this._pc.iceGatheringState);
|
|
721
|
+
};
|
|
722
|
+
onIceCandidateError = (event) => {
|
|
723
|
+
this.emit('@icecandidateerror', event);
|
|
724
|
+
};
|
|
725
|
+
onConnectionStateChange = () => {
|
|
726
|
+
this.emit('@connectionstatechange', this._pc.connectionState);
|
|
727
|
+
};
|
|
728
|
+
onIceConnectionStateChange = () => {
|
|
729
|
+
switch (this._pc.iceConnectionState) {
|
|
730
|
+
case 'checking': {
|
|
731
|
+
this.emit('@connectionstatechange', 'connecting');
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
734
|
+
case 'connected':
|
|
735
|
+
case 'completed': {
|
|
736
|
+
this.emit('@connectionstatechange', 'connected');
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
739
|
+
case 'failed': {
|
|
740
|
+
this.emit('@connectionstatechange', 'failed');
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
case 'disconnected': {
|
|
744
|
+
this.emit('@connectionstatechange', 'disconnected');
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
case 'closed': {
|
|
748
|
+
this.emit('@connectionstatechange', 'closed');
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
};
|
|
698
753
|
assertNotClosed() {
|
|
699
754
|
if (this._closed) {
|
|
700
755
|
throw new errors_1.InvalidStateError('method called in a closed handler');
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnhancedEventEmitter } from '../enhancedEvents';
|
|
2
2
|
import type { IceParameters, DtlsParameters, IceGatheringState, ConnectionState } from '../Transport';
|
|
3
3
|
import type { RtpCapabilities } from '../RtpParameters';
|
|
4
4
|
import type { SctpCapabilities } from '../SctpParameters';
|
|
5
|
+
import type { HandlerFactory, HandlerInterface, HandlerEvents, HandlerSendOptions, HandlerSendResult, HandlerReceiveOptions, HandlerReceiveResult, HandlerSendDataChannelOptions, HandlerSendDataChannelResult, HandlerReceiveDataChannelOptions, HandlerReceiveDataChannelResult } from './HandlerInterface';
|
|
5
6
|
export type FakeParameters = {
|
|
6
7
|
generateNativeRtpCapabilities: () => RtpCapabilities;
|
|
7
8
|
generateNativeSctpCapabilities: () => SctpCapabilities;
|
|
8
9
|
generateLocalDtlsParameters: () => DtlsParameters;
|
|
9
10
|
};
|
|
10
|
-
export declare class FakeHandler extends HandlerInterface {
|
|
11
|
+
export declare class FakeHandler extends EnhancedEventEmitter<HandlerEvents> implements HandlerInterface {
|
|
11
12
|
private _closed;
|
|
12
|
-
private
|
|
13
|
-
private _rtpParametersByKind
|
|
13
|
+
private _fakeParameters;
|
|
14
|
+
private _rtpParametersByKind;
|
|
14
15
|
private _cname;
|
|
15
16
|
private _transportReady;
|
|
16
17
|
private _nextLocalId;
|
|
@@ -19,15 +20,12 @@ export declare class FakeHandler extends HandlerInterface {
|
|
|
19
20
|
/**
|
|
20
21
|
* Creates a factory function.
|
|
21
22
|
*/
|
|
22
|
-
static createFactory(fakeParameters: FakeParameters):
|
|
23
|
-
constructor(
|
|
23
|
+
static createFactory(fakeParameters: FakeParameters): HandlerFactory;
|
|
24
|
+
private constructor();
|
|
24
25
|
get name(): string;
|
|
25
26
|
close(): void;
|
|
26
27
|
setIceGatheringState(iceGatheringState: IceGatheringState): void;
|
|
27
28
|
setConnectionState(connectionState: ConnectionState): void;
|
|
28
|
-
getNativeRtpCapabilities(): Promise<RtpCapabilities>;
|
|
29
|
-
getNativeSctpCapabilities(): Promise<SctpCapabilities>;
|
|
30
|
-
run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, proprietaryConstraints, extendedRtpCapabilities, }: HandlerRunOptions): void;
|
|
31
29
|
updateIceServers(iceServers: RTCIceServer[]): Promise<void>;
|
|
32
30
|
restartIce(iceParameters: IceParameters): Promise<void>;
|
|
33
31
|
getTransportStats(): Promise<RTCStatsReport>;
|
|
@@ -37,7 +35,7 @@ export declare class FakeHandler extends HandlerInterface {
|
|
|
37
35
|
resumeSending(localId: string): Promise<void>;
|
|
38
36
|
replaceTrack(localId: string, track: MediaStreamTrack | null): Promise<void>;
|
|
39
37
|
setMaxSpatialLayer(localId: string, spatialLayer: number): Promise<void>;
|
|
40
|
-
setRtpEncodingParameters(localId: string, params:
|
|
38
|
+
setRtpEncodingParameters(localId: string, params: Partial<RTCRtpEncodingParameters>): Promise<void>;
|
|
41
39
|
getSenderStats(localId: string): Promise<RTCStatsReport>;
|
|
42
40
|
sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol, }: HandlerSendDataChannelOptions): Promise<HandlerSendDataChannelResult>;
|
|
43
41
|
receive(optionsList: HandlerReceiveOptions[]): Promise<HandlerReceiveResult[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakeHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/FakeHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FakeHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/FakeHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAKzD,OAAO,KAAK,EACX,aAAa,EACb,cAAc,EAEd,iBAAiB,EACjB,eAAe,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACX,eAAe,EAGf,MAAM,kBAAkB,CAAC;AA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