mediasoup-client 3.12.4 → 3.13.0

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.
Files changed (51) hide show
  1. package/lib/Device.d.ts +1 -1
  2. package/lib/Device.d.ts.map +1 -1
  3. package/lib/Device.js +8 -81
  4. package/lib/RtpParameters.d.ts +1 -1
  5. package/lib/RtpParameters.d.ts.map +1 -1
  6. package/lib/handlers/{ReactNativeUnifiedPlan.d.ts → ReactNative106.d.ts} +2 -2
  7. package/lib/handlers/ReactNative106.d.ts.map +1 -0
  8. package/lib/handlers/{ReactNativeUnifiedPlan.js → ReactNative106.js} +6 -6
  9. package/lib/handlers/sdp/MediaSection.d.ts +3 -15
  10. package/lib/handlers/sdp/MediaSection.d.ts.map +1 -1
  11. package/lib/handlers/sdp/MediaSection.js +6 -113
  12. package/lib/handlers/sdp/RemoteSdp.d.ts +1 -7
  13. package/lib/handlers/sdp/RemoteSdp.d.ts.map +1 -1
  14. package/lib/handlers/sdp/RemoteSdp.js +18 -41
  15. package/lib/index.d.ts +1 -1
  16. package/lib/index.js +1 -1
  17. package/lib/test/fakeParameters.d.ts.map +1 -1
  18. package/lib/test/fakeParameters.js +0 -14
  19. package/lib/test/test.js +0 -112
  20. package/lib/test/uaTestCases.d.ts.map +1 -1
  21. package/lib/test/uaTestCases.js +0 -25
  22. package/npm-scripts.mjs +26 -14
  23. package/package.json +8 -8
  24. package/lib/handlers/Chrome55.d.ts +0 -51
  25. package/lib/handlers/Chrome55.d.ts.map +0 -1
  26. package/lib/handlers/Chrome55.js +0 -554
  27. package/lib/handlers/Chrome67.d.ts +0 -51
  28. package/lib/handlers/Chrome67.d.ts.map +0 -1
  29. package/lib/handlers/Chrome67.js +0 -609
  30. package/lib/handlers/Chrome70.d.ts +0 -49
  31. package/lib/handlers/Chrome70.d.ts.map +0 -1
  32. package/lib/handlers/Chrome70.js +0 -634
  33. package/lib/handlers/Edge11.d.ts +0 -55
  34. package/lib/handlers/Edge11.d.ts.map +0 -1
  35. package/lib/handlers/Edge11.js +0 -447
  36. package/lib/handlers/Firefox60.d.ts +0 -50
  37. package/lib/handlers/Firefox60.d.ts.map +0 -1
  38. package/lib/handlers/Firefox60.js +0 -721
  39. package/lib/handlers/ReactNative.d.ts +0 -51
  40. package/lib/handlers/ReactNative.d.ts.map +0 -1
  41. package/lib/handlers/ReactNative.js +0 -569
  42. package/lib/handlers/ReactNativeUnifiedPlan.d.ts.map +0 -1
  43. package/lib/handlers/Safari11.d.ts +0 -51
  44. package/lib/handlers/Safari11.d.ts.map +0 -1
  45. package/lib/handlers/Safari11.js +0 -604
  46. package/lib/handlers/ortc/edgeUtils.d.ts +0 -11
  47. package/lib/handlers/ortc/edgeUtils.d.ts.map +0 -1
  48. package/lib/handlers/ortc/edgeUtils.js +0 -70
  49. package/lib/handlers/sdp/planBUtils.d.ts +0 -14
  50. package/lib/handlers/sdp/planBUtils.d.ts.map +0 -1
  51. package/lib/handlers/sdp/planBUtils.js +0 -150
@@ -1,554 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Chrome55 = void 0;
4
- const sdpTransform = require("sdp-transform");
5
- const Logger_1 = require("../Logger");
6
- const errors_1 = require("../errors");
7
- const utils = require("../utils");
8
- const ortc = require("../ortc");
9
- const sdpCommonUtils = require("./sdp/commonUtils");
10
- const sdpPlanBUtils = require("./sdp/planBUtils");
11
- const HandlerInterface_1 = require("./HandlerInterface");
12
- const RemoteSdp_1 = require("./sdp/RemoteSdp");
13
- const logger = new Logger_1.Logger('Chrome55');
14
- const NAME = 'Chrome55';
15
- const SCTP_NUM_STREAMS = { OS: 1024, MIS: 1024 };
16
- class Chrome55 extends HandlerInterface_1.HandlerInterface {
17
- // Handler direction.
18
- _direction;
19
- // Remote SDP handler.
20
- _remoteSdp;
21
- // Generic sending RTP parameters for audio and video.
22
- _sendingRtpParametersByKind;
23
- // Generic sending RTP parameters for audio and video suitable for the SDP
24
- // remote answer.
25
- _sendingRemoteRtpParametersByKind;
26
- // Initial server side DTLS role. If not 'auto', it will force the opposite
27
- // value in client side.
28
- _forcedLocalDtlsRole;
29
- // RTCPeerConnection instance.
30
- _pc;
31
- // Local stream for sending.
32
- _sendStream = new MediaStream();
33
- // Map of sending MediaStreamTracks indexed by localId.
34
- _mapSendLocalIdTrack = new Map();
35
- // Next sending localId.
36
- _nextSendLocalId = 0;
37
- // Map of MID, RTP parameters and RTCRtpReceiver indexed by local id.
38
- // Value is an Object with mid, rtpParameters and rtpReceiver.
39
- _mapRecvLocalIdInfo = new Map();
40
- // Whether a DataChannel m=application section has been created.
41
- _hasDataChannelMediaSection = false;
42
- // Sending DataChannel id value counter. Incremented for each new DataChannel.
43
- _nextSendSctpStreamId = 0;
44
- // Got transport local and remote parameters.
45
- _transportReady = false;
46
- /**
47
- * Creates a factory function.
48
- */
49
- static createFactory() {
50
- return () => new Chrome55();
51
- }
52
- constructor() {
53
- super();
54
- }
55
- get name() {
56
- return NAME;
57
- }
58
- close() {
59
- logger.debug('close()');
60
- // Close RTCPeerConnection.
61
- if (this._pc) {
62
- try {
63
- this._pc.close();
64
- }
65
- catch (error) { }
66
- }
67
- this.emit('@close');
68
- }
69
- async getNativeRtpCapabilities() {
70
- logger.debug('getNativeRtpCapabilities()');
71
- const pc = new RTCPeerConnection({
72
- iceServers: [],
73
- iceTransportPolicy: 'all',
74
- bundlePolicy: 'max-bundle',
75
- rtcpMuxPolicy: 'require',
76
- sdpSemantics: 'plan-b',
77
- });
78
- try {
79
- const offer = await pc.createOffer({
80
- offerToReceiveAudio: true,
81
- offerToReceiveVideo: true,
82
- });
83
- try {
84
- pc.close();
85
- }
86
- catch (error) { }
87
- const sdpObject = sdpTransform.parse(offer.sdp);
88
- const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities({
89
- sdpObject,
90
- });
91
- return nativeRtpCapabilities;
92
- }
93
- catch (error) {
94
- try {
95
- pc.close();
96
- }
97
- catch (error2) { }
98
- throw error;
99
- }
100
- }
101
- async getNativeSctpCapabilities() {
102
- logger.debug('getNativeSctpCapabilities()');
103
- return {
104
- numStreams: SCTP_NUM_STREAMS,
105
- };
106
- }
107
- run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities, }) {
108
- logger.debug('run()');
109
- this._direction = direction;
110
- this._remoteSdp = new RemoteSdp_1.RemoteSdp({
111
- iceParameters,
112
- iceCandidates,
113
- dtlsParameters,
114
- sctpParameters,
115
- planB: true,
116
- });
117
- this._sendingRtpParametersByKind = {
118
- audio: ortc.getSendingRtpParameters('audio', extendedRtpCapabilities),
119
- video: ortc.getSendingRtpParameters('video', extendedRtpCapabilities),
120
- };
121
- this._sendingRemoteRtpParametersByKind = {
122
- audio: ortc.getSendingRemoteRtpParameters('audio', extendedRtpCapabilities),
123
- video: ortc.getSendingRemoteRtpParameters('video', extendedRtpCapabilities),
124
- };
125
- if (dtlsParameters.role && dtlsParameters.role !== 'auto') {
126
- this._forcedLocalDtlsRole =
127
- dtlsParameters.role === 'server' ? 'client' : 'server';
128
- }
129
- this._pc = new RTCPeerConnection({
130
- iceServers: iceServers ?? [],
131
- iceTransportPolicy: iceTransportPolicy ?? 'all',
132
- bundlePolicy: 'max-bundle',
133
- rtcpMuxPolicy: 'require',
134
- sdpSemantics: 'plan-b',
135
- ...additionalSettings,
136
- }, proprietaryConstraints);
137
- this._pc.addEventListener('icegatheringstatechange', () => {
138
- this.emit('@icegatheringstatechange', this._pc.iceGatheringState);
139
- });
140
- this._pc.addEventListener('icecandidateerror', (event) => {
141
- this.emit('@icecandidateerror', event);
142
- });
143
- if (this._pc.connectionState) {
144
- this._pc.addEventListener('connectionstatechange', () => {
145
- this.emit('@connectionstatechange', this._pc.connectionState);
146
- });
147
- }
148
- else {
149
- this._pc.addEventListener('iceconnectionstatechange', () => {
150
- logger.warn('run() | pc.connectionState not supported, using pc.iceConnectionState');
151
- switch (this._pc.iceConnectionState) {
152
- case 'checking': {
153
- this.emit('@connectionstatechange', 'connecting');
154
- break;
155
- }
156
- case 'connected':
157
- case 'completed': {
158
- this.emit('@connectionstatechange', 'connected');
159
- break;
160
- }
161
- case 'failed': {
162
- this.emit('@connectionstatechange', 'failed');
163
- break;
164
- }
165
- case 'disconnected': {
166
- this.emit('@connectionstatechange', 'disconnected');
167
- break;
168
- }
169
- case 'closed': {
170
- this.emit('@connectionstatechange', 'closed');
171
- break;
172
- }
173
- }
174
- });
175
- }
176
- }
177
- async updateIceServers(iceServers) {
178
- logger.debug('updateIceServers()');
179
- const configuration = this._pc.getConfiguration();
180
- configuration.iceServers = iceServers;
181
- this._pc.setConfiguration(configuration);
182
- }
183
- async restartIce(iceParameters) {
184
- logger.debug('restartIce()');
185
- // Provide the remote SDP handler with new remote ICE parameters.
186
- this._remoteSdp.updateIceParameters(iceParameters);
187
- if (!this._transportReady) {
188
- return;
189
- }
190
- if (this._direction === 'send') {
191
- const offer = await this._pc.createOffer({ iceRestart: true });
192
- logger.debug('restartIce() | calling pc.setLocalDescription() [offer:%o]', offer);
193
- await this._pc.setLocalDescription(offer);
194
- const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
195
- logger.debug('restartIce() | calling pc.setRemoteDescription() [answer:%o]', answer);
196
- await this._pc.setRemoteDescription(answer);
197
- }
198
- else {
199
- const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
200
- logger.debug('restartIce() | calling pc.setRemoteDescription() [offer:%o]', offer);
201
- await this._pc.setRemoteDescription(offer);
202
- const answer = await this._pc.createAnswer();
203
- logger.debug('restartIce() | calling pc.setLocalDescription() [answer:%o]', answer);
204
- await this._pc.setLocalDescription(answer);
205
- }
206
- }
207
- async getTransportStats() {
208
- return this._pc.getStats();
209
- }
210
- async send({ track, encodings, codecOptions, codec, }) {
211
- this.assertSendDirection();
212
- logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
213
- if (codec) {
214
- logger.warn('send() | codec selection is not available in %s handler', this.name);
215
- }
216
- this._sendStream.addTrack(track);
217
- this._pc.addStream(this._sendStream);
218
- let offer = await this._pc.createOffer();
219
- let localSdpObject = sdpTransform.parse(offer.sdp);
220
- // @ts-expect-error --- sdpTransform.SessionDescription type doesn't
221
- // define extmapAllowMixed field.
222
- if (localSdpObject.extmapAllowMixed) {
223
- this._remoteSdp.setSessionExtmapAllowMixed();
224
- }
225
- let offerMediaObject;
226
- const sendingRtpParameters = utils.clone(this._sendingRtpParametersByKind[track.kind]);
227
- sendingRtpParameters.codecs = ortc.reduceCodecs(sendingRtpParameters.codecs);
228
- const sendingRemoteRtpParameters = utils.clone(this._sendingRemoteRtpParametersByKind[track.kind]);
229
- sendingRemoteRtpParameters.codecs = ortc.reduceCodecs(sendingRemoteRtpParameters.codecs);
230
- if (!this._transportReady) {
231
- await this.setupTransport({
232
- localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
233
- localSdpObject,
234
- });
235
- }
236
- if (track.kind === 'video' && encodings && encodings.length > 1) {
237
- logger.debug('send() | enabling simulcast');
238
- localSdpObject = sdpTransform.parse(offer.sdp);
239
- offerMediaObject = localSdpObject.media.find((m) => m.type === 'video');
240
- sdpPlanBUtils.addLegacySimulcast({
241
- offerMediaObject,
242
- track,
243
- numStreams: encodings.length,
244
- });
245
- offer = { type: 'offer', sdp: sdpTransform.write(localSdpObject) };
246
- }
247
- logger.debug('send() | calling pc.setLocalDescription() [offer:%o]', offer);
248
- await this._pc.setLocalDescription(offer);
249
- localSdpObject = sdpTransform.parse(this._pc.localDescription.sdp);
250
- offerMediaObject = localSdpObject.media.find((m) => m.type === track.kind);
251
- // Set RTCP CNAME.
252
- sendingRtpParameters.rtcp.cname = sdpCommonUtils.getCname({
253
- offerMediaObject,
254
- });
255
- // Set RTP encodings.
256
- sendingRtpParameters.encodings = sdpPlanBUtils.getRtpEncodings({
257
- offerMediaObject,
258
- track,
259
- });
260
- // Complete encodings with given values.
261
- if (encodings) {
262
- for (let idx = 0; idx < sendingRtpParameters.encodings.length; ++idx) {
263
- if (encodings[idx]) {
264
- Object.assign(sendingRtpParameters.encodings[idx], encodings[idx]);
265
- }
266
- }
267
- }
268
- // If VP8 and there is effective simulcast, add scalabilityMode to each
269
- // encoding.
270
- if (sendingRtpParameters.encodings.length > 1 &&
271
- sendingRtpParameters.codecs[0].mimeType.toLowerCase() === 'video/vp8') {
272
- for (const encoding of sendingRtpParameters.encodings) {
273
- encoding.scalabilityMode = 'L1T3';
274
- }
275
- }
276
- this._remoteSdp.send({
277
- offerMediaObject,
278
- offerRtpParameters: sendingRtpParameters,
279
- answerRtpParameters: sendingRemoteRtpParameters,
280
- codecOptions,
281
- });
282
- const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
283
- logger.debug('send() | calling pc.setRemoteDescription() [answer:%o]', answer);
284
- await this._pc.setRemoteDescription(answer);
285
- const localId = String(this._nextSendLocalId);
286
- this._nextSendLocalId++;
287
- // Insert into the map.
288
- this._mapSendLocalIdTrack.set(localId, track);
289
- return {
290
- localId: localId,
291
- rtpParameters: sendingRtpParameters,
292
- };
293
- }
294
- async stopSending(localId) {
295
- this.assertSendDirection();
296
- logger.debug('stopSending() [localId:%s]', localId);
297
- const track = this._mapSendLocalIdTrack.get(localId);
298
- if (!track) {
299
- throw new Error('track not found');
300
- }
301
- this._mapSendLocalIdTrack.delete(localId);
302
- this._sendStream.removeTrack(track);
303
- this._pc.addStream(this._sendStream);
304
- const offer = await this._pc.createOffer();
305
- logger.debug('stopSending() | calling pc.setLocalDescription() [offer:%o]', offer);
306
- try {
307
- await this._pc.setLocalDescription(offer);
308
- }
309
- catch (error) {
310
- // NOTE: If there are no sending tracks, setLocalDescription() will fail with
311
- // "Failed to create channels". If so, ignore it.
312
- if (this._sendStream.getTracks().length === 0) {
313
- logger.warn('stopSending() | ignoring expected error due no sending tracks: %s', error.toString());
314
- return;
315
- }
316
- throw error;
317
- }
318
- if (this._pc.signalingState === 'stable') {
319
- return;
320
- }
321
- const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
322
- logger.debug('stopSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
323
- await this._pc.setRemoteDescription(answer);
324
- }
325
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
326
- async pauseSending(localId) {
327
- // Unimplemented.
328
- }
329
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
330
- async resumeSending(localId) {
331
- // Unimplemented.
332
- }
333
- async replaceTrack(
334
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
335
- localId,
336
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
337
- track) {
338
- throw new errors_1.UnsupportedError('not implemented');
339
- }
340
- async setMaxSpatialLayer(
341
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
342
- localId,
343
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
344
- spatialLayer) {
345
- throw new errors_1.UnsupportedError(' not implemented');
346
- }
347
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
348
- async setRtpEncodingParameters(localId, params) {
349
- throw new errors_1.UnsupportedError('not supported');
350
- }
351
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
352
- async getSenderStats(localId) {
353
- throw new errors_1.UnsupportedError('not implemented');
354
- }
355
- async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol, }) {
356
- this.assertSendDirection();
357
- const options = {
358
- negotiated: true,
359
- id: this._nextSendSctpStreamId,
360
- ordered,
361
- maxPacketLifeTime,
362
- maxRetransmitTime: maxPacketLifeTime, // NOTE: Old spec.
363
- maxRetransmits,
364
- protocol,
365
- };
366
- logger.debug('sendDataChannel() [options:%o]', options);
367
- const dataChannel = this._pc.createDataChannel(label, options);
368
- // Increase next id.
369
- this._nextSendSctpStreamId =
370
- ++this._nextSendSctpStreamId % SCTP_NUM_STREAMS.MIS;
371
- // If this is the first DataChannel we need to create the SDP answer with
372
- // m=application section.
373
- if (!this._hasDataChannelMediaSection) {
374
- const offer = await this._pc.createOffer();
375
- const localSdpObject = sdpTransform.parse(offer.sdp);
376
- const offerMediaObject = localSdpObject.media.find((m) => m.type === 'application');
377
- if (!this._transportReady) {
378
- await this.setupTransport({
379
- localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
380
- localSdpObject,
381
- });
382
- }
383
- logger.debug('sendDataChannel() | calling pc.setLocalDescription() [offer:%o]', offer);
384
- await this._pc.setLocalDescription(offer);
385
- this._remoteSdp.sendSctpAssociation({ offerMediaObject });
386
- const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
387
- logger.debug('sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]', answer);
388
- await this._pc.setRemoteDescription(answer);
389
- this._hasDataChannelMediaSection = true;
390
- }
391
- const sctpStreamParameters = {
392
- streamId: options.id,
393
- ordered: options.ordered,
394
- maxPacketLifeTime: options.maxPacketLifeTime,
395
- maxRetransmits: options.maxRetransmits,
396
- };
397
- return { dataChannel, sctpStreamParameters };
398
- }
399
- async receive(optionsList) {
400
- this.assertRecvDirection();
401
- const results = [];
402
- for (const options of optionsList) {
403
- const { trackId, kind, rtpParameters, streamId } = options;
404
- logger.debug('receive() [trackId:%s, kind:%s]', trackId, kind);
405
- const mid = kind;
406
- this._remoteSdp.receive({
407
- mid,
408
- kind,
409
- offerRtpParameters: rtpParameters,
410
- streamId: streamId ?? rtpParameters.rtcp.cname,
411
- trackId,
412
- });
413
- }
414
- const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
415
- logger.debug('receive() | calling pc.setRemoteDescription() [offer:%o]', offer);
416
- await this._pc.setRemoteDescription(offer);
417
- let answer = await this._pc.createAnswer();
418
- const localSdpObject = sdpTransform.parse(answer.sdp);
419
- for (const options of optionsList) {
420
- const { kind, rtpParameters } = options;
421
- const mid = kind;
422
- const answerMediaObject = localSdpObject.media.find((m) => String(m.mid) === mid);
423
- // May need to modify codec parameters in the answer based on codec
424
- // parameters in the offer.
425
- sdpCommonUtils.applyCodecParameters({
426
- offerRtpParameters: rtpParameters,
427
- answerMediaObject,
428
- });
429
- }
430
- answer = { type: 'answer', sdp: sdpTransform.write(localSdpObject) };
431
- if (!this._transportReady) {
432
- await this.setupTransport({
433
- localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
434
- localSdpObject,
435
- });
436
- }
437
- logger.debug('receive() | calling pc.setLocalDescription() [answer:%o]', answer);
438
- await this._pc.setLocalDescription(answer);
439
- for (const options of optionsList) {
440
- const { kind, trackId, rtpParameters } = options;
441
- const mid = kind;
442
- const localId = trackId;
443
- const streamId = options.streamId ?? rtpParameters.rtcp.cname;
444
- const stream = this._pc
445
- .getRemoteStreams()
446
- .find((s) => s.id === streamId);
447
- const track = stream.getTrackById(localId);
448
- if (!track) {
449
- throw new Error('remote track not found');
450
- }
451
- // Insert into the map.
452
- this._mapRecvLocalIdInfo.set(localId, { mid, rtpParameters });
453
- results.push({ localId, track });
454
- }
455
- return results;
456
- }
457
- async stopReceiving(localIds) {
458
- this.assertRecvDirection();
459
- for (const localId of localIds) {
460
- logger.debug('stopReceiving() [localId:%s]', localId);
461
- const { mid, rtpParameters } = this._mapRecvLocalIdInfo.get(localId) ?? {};
462
- // Remove from the map.
463
- this._mapRecvLocalIdInfo.delete(localId);
464
- this._remoteSdp.planBStopReceiving({
465
- mid: mid,
466
- offerRtpParameters: rtpParameters,
467
- });
468
- }
469
- const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
470
- logger.debug('stopReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
471
- await this._pc.setRemoteDescription(offer);
472
- const answer = await this._pc.createAnswer();
473
- logger.debug('stopReceiving() | calling pc.setLocalDescription() [answer:%o]', answer);
474
- await this._pc.setLocalDescription(answer);
475
- }
476
- async pauseReceiving(
477
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
478
- localIds) {
479
- // Unimplemented.
480
- }
481
- async resumeReceiving(
482
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
483
- localIds) {
484
- // Unimplemented.
485
- }
486
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
487
- async getReceiverStats(localId) {
488
- throw new errors_1.UnsupportedError('not implemented');
489
- }
490
- async receiveDataChannel({ sctpStreamParameters, label, protocol, }) {
491
- this.assertRecvDirection();
492
- const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
493
- const options = {
494
- negotiated: true,
495
- id: streamId,
496
- ordered,
497
- maxPacketLifeTime,
498
- maxRetransmitTime: maxPacketLifeTime, // NOTE: Old spec.
499
- maxRetransmits,
500
- protocol,
501
- };
502
- logger.debug('receiveDataChannel() [options:%o]', options);
503
- const dataChannel = this._pc.createDataChannel(label, options);
504
- // If this is the first DataChannel we need to create the SDP offer with
505
- // m=application section.
506
- if (!this._hasDataChannelMediaSection) {
507
- this._remoteSdp.receiveSctpAssociation({ oldDataChannelSpec: true });
508
- const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
509
- logger.debug('receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]', offer);
510
- await this._pc.setRemoteDescription(offer);
511
- const answer = await this._pc.createAnswer();
512
- if (!this._transportReady) {
513
- const localSdpObject = sdpTransform.parse(answer.sdp);
514
- await this.setupTransport({
515
- localDtlsRole: this._forcedLocalDtlsRole ?? 'client',
516
- localSdpObject,
517
- });
518
- }
519
- logger.debug('receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]', answer);
520
- await this._pc.setLocalDescription(answer);
521
- this._hasDataChannelMediaSection = true;
522
- }
523
- return { dataChannel };
524
- }
525
- async setupTransport({ localDtlsRole, localSdpObject, }) {
526
- if (!localSdpObject) {
527
- localSdpObject = sdpTransform.parse(this._pc.localDescription.sdp);
528
- }
529
- // Get our local DTLS parameters.
530
- const dtlsParameters = sdpCommonUtils.extractDtlsParameters({
531
- sdpObject: localSdpObject,
532
- });
533
- // Set our DTLS role.
534
- dtlsParameters.role = localDtlsRole;
535
- // Update the remote DTLS role in the SDP.
536
- this._remoteSdp.updateDtlsRole(localDtlsRole === 'client' ? 'server' : 'client');
537
- // Need to tell the remote transport about our parameters.
538
- await new Promise((resolve, reject) => {
539
- this.safeEmit('@connect', { dtlsParameters }, resolve, reject);
540
- });
541
- this._transportReady = true;
542
- }
543
- assertSendDirection() {
544
- if (this._direction !== 'send') {
545
- throw new Error('method can just be called for handlers with "send" direction');
546
- }
547
- }
548
- assertRecvDirection() {
549
- if (this._direction !== 'recv') {
550
- throw new Error('method can just be called for handlers with "recv" direction');
551
- }
552
- }
553
- }
554
- exports.Chrome55 = Chrome55;
@@ -1,51 +0,0 @@
1
- import { type HandlerFactory, HandlerInterface, type HandlerRunOptions, type HandlerSendOptions, type HandlerSendResult, type HandlerReceiveOptions, type HandlerReceiveResult, type HandlerSendDataChannelOptions, type HandlerSendDataChannelResult, type HandlerReceiveDataChannelOptions, type HandlerReceiveDataChannelResult } from './HandlerInterface';
2
- import type { IceParameters } from '../Transport';
3
- import type { RtpCapabilities } from '../RtpParameters';
4
- import type { SctpCapabilities } from '../SctpParameters';
5
- export declare class Chrome67 extends HandlerInterface {
6
- private _direction?;
7
- private _remoteSdp?;
8
- private _sendingRtpParametersByKind?;
9
- private _sendingRemoteRtpParametersByKind?;
10
- private _forcedLocalDtlsRole?;
11
- private _pc;
12
- private readonly _sendStream;
13
- private readonly _mapSendLocalIdRtpSender;
14
- private _nextSendLocalId;
15
- private readonly _mapRecvLocalIdInfo;
16
- private _hasDataChannelMediaSection;
17
- private _nextSendSctpStreamId;
18
- private _transportReady;
19
- /**
20
- * Creates a factory function.
21
- */
22
- static createFactory(): HandlerFactory;
23
- constructor();
24
- get name(): string;
25
- close(): void;
26
- getNativeRtpCapabilities(): Promise<RtpCapabilities>;
27
- getNativeSctpCapabilities(): Promise<SctpCapabilities>;
28
- run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities, }: HandlerRunOptions): void;
29
- updateIceServers(iceServers: RTCIceServer[]): Promise<void>;
30
- restartIce(iceParameters: IceParameters): Promise<void>;
31
- getTransportStats(): Promise<RTCStatsReport>;
32
- send({ track, encodings, codecOptions, codec, }: HandlerSendOptions): Promise<HandlerSendResult>;
33
- stopSending(localId: string): Promise<void>;
34
- pauseSending(localId: string): Promise<void>;
35
- resumeSending(localId: string): Promise<void>;
36
- replaceTrack(localId: string, track: MediaStreamTrack | null): Promise<void>;
37
- setMaxSpatialLayer(localId: string, spatialLayer: number): Promise<void>;
38
- setRtpEncodingParameters(localId: string, params: any): Promise<void>;
39
- getSenderStats(localId: string): Promise<RTCStatsReport>;
40
- sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol, }: HandlerSendDataChannelOptions): Promise<HandlerSendDataChannelResult>;
41
- receive(optionsList: HandlerReceiveOptions[]): Promise<HandlerReceiveResult[]>;
42
- stopReceiving(localIds: string[]): Promise<void>;
43
- pauseReceiving(localIds: string[]): Promise<void>;
44
- resumeReceiving(localIds: string[]): Promise<void>;
45
- getReceiverStats(localId: string): Promise<RTCStatsReport>;
46
- receiveDataChannel({ sctpStreamParameters, label, protocol, }: HandlerReceiveDataChannelOptions): Promise<HandlerReceiveDataChannelResult>;
47
- private setupTransport;
48
- private assertSendDirection;
49
- private assertRecvDirection;
50
- }
51
- //# sourceMappingURL=Chrome67.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Chrome67.d.ts","sourceRoot":"","sources":["../../src/handlers/Chrome67.ts"],"names":[],"mappings":"AAMA,OAAO,EACN,KAAK,cAAc,EACnB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACjC,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,kBAAkB,CAA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