mediasoup-client 3.6.62 → 3.6.64

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.
@@ -1 +1 @@
1
- {"version":3,"file":"DataConsumer.d.ts","sourceRoot":"","sources":["../src/DataConsumer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAIxD,MAAM,MAAM,mBAAmB,GAC/B;IACC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC9B;IACC,cAAc,EAAE,EAAE,CAAC;IACnB,IAAI,EAAE,EAAE,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IACf,KAAK,EAAE,EAAE,CAAC;IACV,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IAEf,QAAQ,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,0BAA0B,GACtC;IACC,KAAK,EAAE,EAAE,CAAC;CACV,CAAC;AAEF,qBAAa,YAAa,SAAQ,oBAAoB,CAAC,kBAAkB,CAAC;IAGzE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAE7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IAEzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiB;IAE9C,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAuB;IAE7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;I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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC;IAgBF;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,CAGf;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,CAG3B;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAGpB;IAED;;OAEG;IACH,IAAI,oBAAoB,IAAI,oBAAoB,CAG/C;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,mBAAmB,CAGpC;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAGrB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,UAAU,CAG3B;IAED;;OAEG;IACH,IAAI,UAAU,CAAC,UAAU,EAAE,UAAU,EAGpC;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGrC;IAED;;OAEG;IAEH,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG3C;IAED,IAAI,QAAQ,IAAI,oBAAoB,CAGnC;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IAiBb;;OAEG;IACH,eAAe,IAAI,IAAI;IAiBvB,OAAO,CAAC,kBAAkB;CA4D1B"}
@@ -143,6 +143,8 @@ class DataConsumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
143
143
  this._closed = true;
144
144
  this.emit('@close');
145
145
  this.safeEmit('close');
146
+ // Emit observer event.
147
+ this._observer.safeEmit('close');
146
148
  });
147
149
  this._dataChannel.addEventListener('message', (event) => {
148
150
  if (this._closed)
@@ -1 +1 @@
1
- {"version":3,"file":"DataProducer.d.ts","sourceRoot":"","sources":["../src/DataProducer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,C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G;IACH,IAAI,0BAA0B,IAAI,MAAM,CAGvC;IAED;;OAEG;IACH,IAAI,0BAA0B,CAAC,0BAA0B,EAAE,MAAM,EAGhE;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGrC;IAED;;OAEG;IAEH,IAAI,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAG3C;IAED,IAAI,QAAQ,IAAI,oBAAoB,CAGnC;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IAiBb;;OAEG;IACH,eAAe,IAAI,IAAI;IAiBvB;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAUrB,OAAO,CAAC,kBAAkB;CAqE1B"}
@@ -154,6 +154,8 @@ class DataProducer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
154
154
  this._closed = true;
155
155
  this.emit('@close');
156
156
  this.safeEmit('close');
157
+ // Emit observer event.
158
+ this._observer.safeEmit('close');
157
159
  });
158
160
  this._dataChannel.addEventListener('message', () => {
159
161
  if (this._closed)
package/lib/Device.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Transport, TransportOptions } from './Transport';
3
3
  import { HandlerFactory } from './handlers/HandlerInterface';
4
4
  import { RtpCapabilities, MediaKind } from './RtpParameters';
5
5
  import { SctpCapabilities } from './SctpParameters';
6
- export type BuiltinHandlerName = 'Chrome74' | 'Chrome70' | 'Chrome67' | 'Chrome55' | 'Firefox60' | 'Safari12' | 'Safari11' | 'Edge11' | 'ReactNative';
6
+ export type BuiltinHandlerName = 'Chrome74' | 'Chrome70' | 'Chrome67' | 'Chrome55' | 'Firefox60' | 'Safari12' | 'Safari11' | 'Edge11' | 'ReactNativeUnifiedPlan' | 'ReactNative';
7
7
  export type DeviceOptions = {
8
8
  /**
9
9
  * The name of one of the builtin handlers.
@@ -1 +1 @@
1
- {"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../src/Device.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4EhB;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAUpC;;;;;OAKG;IACH,mBAAmB,CAClB,EACC,EAAE,EACF,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,OAAO,EACP,EAAE,gBAAgB,GACjB,SAAS;IAoBZ;;;;;OAKG;IACH,mBAAmB,CAClB,EACC,EAAE,EACF,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,OAAO,EACP,EAAE,gBAAgB,GACjB,SAAS;IAoBZ,OAAO,CAAC,gBAAgB;CAuDxB"}
package/lib/Device.js CHANGED
@@ -43,18 +43,26 @@ const Firefox60_1 = require("./handlers/Firefox60");
43
43
  const Safari12_1 = require("./handlers/Safari12");
44
44
  const Safari11_1 = require("./handlers/Safari11");
45
45
  const Edge11_1 = require("./handlers/Edge11");
46
+ const ReactNativeUnifiedPlan_1 = require("./handlers/ReactNativeUnifiedPlan");
46
47
  const ReactNative_1 = require("./handlers/ReactNative");
47
48
  const logger = new Logger_1.Logger('Device');
48
49
  function detectDevice() {
49
50
  // React-Native.
50
51
  // NOTE: react-native-webrtc >= 1.75.0 is required.
52
+ // NOTE: react-native-webrtc with Unified Plan requires version >= 106.0.0.
51
53
  if (typeof navigator === 'object' && navigator.product === 'ReactNative') {
52
54
  if (typeof RTCPeerConnection === 'undefined') {
53
- logger.warn('this._detectDevice() | unsupported ReactNative without RTCPeerConnection');
55
+ logger.warn('this._detectDevice() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?');
54
56
  return undefined;
55
57
  }
56
- logger.debug('this._detectDevice() | ReactNative handler chosen');
57
- return 'ReactNative';
58
+ if (typeof RTCRtpTransceiver !== 'undefined') {
59
+ logger.debug('this._detectDevice() | ReactNative UnifiedPlan handler chosen');
60
+ return 'ReactNativeUnifiedPlan';
61
+ }
62
+ else {
63
+ logger.debug('this._detectDevice() | ReactNative PlanB handler chosen');
64
+ return 'ReactNative';
65
+ }
58
66
  }
59
67
  // Browser.
60
68
  else if (typeof navigator === 'object' && typeof navigator.userAgent === 'string') {
@@ -147,10 +155,12 @@ class Device {
147
155
  // Handle deprecated option.
148
156
  if (Handler) {
149
157
  logger.warn('constructor() | Handler option is DEPRECATED, use handlerName or handlerFactory instead');
150
- if (typeof Handler === 'string')
158
+ if (typeof Handler === 'string') {
151
159
  handlerName = Handler;
152
- else
160
+ }
161
+ else {
153
162
  throw new TypeError('non string Handler option no longer supported, use handlerFactory instead');
163
+ }
154
164
  }
155
165
  if (handlerName && handlerFactory) {
156
166
  throw new TypeError('just one of handlerName or handlerInterface can be given');
@@ -164,10 +174,12 @@ class Device {
164
174
  }
165
175
  else {
166
176
  handlerName = detectDevice();
167
- if (handlerName)
177
+ if (handlerName) {
168
178
  logger.debug('constructor() | detected handler: %s', handlerName);
169
- else
179
+ }
180
+ else {
170
181
  throw new errors_1.UnsupportedError('device not supported');
182
+ }
171
183
  }
172
184
  switch (handlerName) {
173
185
  case 'Chrome74':
@@ -194,6 +206,9 @@ class Device {
194
206
  case 'Edge11':
195
207
  this._handlerFactory = Edge11_1.Edge11.createFactory();
196
208
  break;
209
+ case 'ReactNativeUnifiedPlan':
210
+ this._handlerFactory = ReactNativeUnifiedPlan_1.ReactNativeUnifiedPlan.createFactory();
211
+ break;
197
212
  case 'ReactNative':
198
213
  this._handlerFactory = ReactNative_1.ReactNative.createFactory();
199
214
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNative.d.ts","sourceRoot":"","sources":["../../src/handlers/ReactNative.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,EA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ACpB,EACC,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,QAAQ,EACR,EAAE,6BAA6B,GAC9B,OAAO,CAAC,4BAA4B,CAAC;IAuElC,OAAO,CACZ,WAAW,EAAE,qBAAqB,EAAE,GACjC,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAwG7B,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkChD,cAAc,CAEnB,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7B,eAAe,CAEpB,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7B,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAK1D,kBAAkB,CACvB,EAAE,oBAAoB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gCAAgC,GACzE,OAAO,CAAC,+BAA+B,CAAC;YAiE7B,eAAe;IAuC7B,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,oBAAoB;CAQ5B"}
@@ -395,7 +395,8 @@ class ReactNative extends HandlerInterface_1.HandlerInterface {
395
395
  // NOTE: In React-Native we cannot reuse the same remote MediaStream for new
396
396
  // remote tracks. This is because react-native-webrtc does not react on new
397
397
  // tracks generated within already existing streams, so force the streamId
398
- // to be different.
398
+ // to be different. See:
399
+ // https://github.com/react-native-webrtc/react-native-webrtc/issues/401
399
400
  logger.debug('receive() | forcing a random remote streamId to avoid well known bug in react-native-webrtc');
400
401
  streamId += `-hack-${utils.generateRandomNumber()}`;
401
402
  mapStreamId.set(trackId, streamId);
@@ -0,0 +1,49 @@
1
+ import { HandlerFactory, HandlerInterface, HandlerRunOptions, HandlerSendOptions, HandlerSendResult, HandlerReceiveOptions, HandlerReceiveResult, HandlerSendDataChannelOptions, HandlerSendDataChannelResult, HandlerReceiveDataChannelOptions, HandlerReceiveDataChannelResult } from './HandlerInterface';
2
+ import { IceParameters } from '../Transport';
3
+ import { RtpCapabilities } from '../RtpParameters';
4
+ import { SctpCapabilities } from '../SctpParameters';
5
+ export declare class ReactNativeUnifiedPlan extends HandlerInterface {
6
+ private _direction?;
7
+ private _remoteSdp?;
8
+ private _sendingRtpParametersByKind?;
9
+ private _sendingRemoteRtpParametersByKind?;
10
+ private _forcedLocalDtlsRole?;
11
+ private _pc;
12
+ private readonly _mapMidTransceiver;
13
+ private readonly _sendStream;
14
+ private _hasDataChannelMediaSection;
15
+ private _nextSendSctpStreamId;
16
+ private _transportReady;
17
+ /**
18
+ * Creates a factory function.
19
+ */
20
+ static createFactory(): HandlerFactory;
21
+ constructor();
22
+ get name(): string;
23
+ close(): void;
24
+ getNativeRtpCapabilities(): Promise<RtpCapabilities>;
25
+ getNativeSctpCapabilities(): Promise<SctpCapabilities>;
26
+ run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities }: HandlerRunOptions): void;
27
+ updateIceServers(iceServers: RTCIceServer[]): Promise<void>;
28
+ restartIce(iceParameters: IceParameters): Promise<void>;
29
+ getTransportStats(): Promise<RTCStatsReport>;
30
+ send({ track, encodings, codecOptions, codec }: HandlerSendOptions): Promise<HandlerSendResult>;
31
+ stopSending(localId: string): Promise<void>;
32
+ pauseSending(localId: string): Promise<void>;
33
+ resumeSending(localId: string): Promise<void>;
34
+ replaceTrack(localId: string, track: MediaStreamTrack | null): Promise<void>;
35
+ setMaxSpatialLayer(localId: string, spatialLayer: number): Promise<void>;
36
+ setRtpEncodingParameters(localId: string, params: any): Promise<void>;
37
+ getSenderStats(localId: string): Promise<RTCStatsReport>;
38
+ sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }: HandlerSendDataChannelOptions): Promise<HandlerSendDataChannelResult>;
39
+ receive(optionsList: HandlerReceiveOptions[]): Promise<HandlerReceiveResult[]>;
40
+ stopReceiving(localIds: string[]): Promise<void>;
41
+ pauseReceiving(localIds: string[]): Promise<void>;
42
+ resumeReceiving(localIds: string[]): Promise<void>;
43
+ getReceiverStats(localId: string): Promise<RTCStatsReport>;
44
+ receiveDataChannel({ sctpStreamParameters, label, protocol }: HandlerReceiveDataChannelOptions): Promise<HandlerReceiveDataChannelResult>;
45
+ private _setupTransport;
46
+ private _assertSendDirection;
47
+ private _assertRecvDirection;
48
+ }
49
+ //# sourceMappingURL=ReactNativeUnifiedPlan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactNativeUnifiedPlan.d.ts","sourceRoot":"","sources":["../../src/handlers/ReactNativeUnifiedPlan.ts"],"names":[],"mappings":"AAMA,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAC/B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAY,MAAM,cAAc,CAAC;AACvD,OAAO,EACN,eAAe,EAGf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAM3E,qBAAa,sBAAuB,SAAQ,gBAAgB;IAG3D,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,OAAO,CAAC,UAAU,CAAC,CAAY;IAE/B,OAAO,CAAC,2BAA2B,CAAC,CAAmC;IAGvE,OAAO,CAAC,iCAAiC,CAAC,CAAmC;IAG7E,OAAO,CAAC,oBAAoB,CAAC,CAAW;IAExC,OAAO,CAAC,GAAG,CAAM;IAEjB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CACxB;IAEX,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IAEjD,OAAO,CAAC,2BAA2B,CAAS;IAE5C,OAAO,CAAC,qBAAqB,CAAK;IAElC,OAAO,CAAC,eAAe,CAAS;IAEhC;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O,CAAC,cAAc,CAAC;IAYxD,eAAe,CACpB,EACC,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,QAAQ,EACR,EAAE,6BAA6B,GAC9B,OAAO,CAAC,4BAA4B,CAAC;IAsElC,OAAO,CACZ,WAAW,EAAE,qBAAqB,EAAE,GACjC,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAkG7B,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsChD,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCjD,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkClD,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAY1D,kBAAkB,CACvB,EAAE,oBAAoB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gCAAgC,GACzE,OAAO,CAAC,+BAA+B,CAAC;YAgE7B,eAAe;IAuC7B,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,oBAAoB;CAQ5B"}
@@ -0,0 +1,632 @@
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 HandlerInterface_1 = require("./HandlerInterface");
34
+ const RemoteSdp_1 = require("./sdp/RemoteSdp");
35
+ const scalabilityModes_1 = require("../scalabilityModes");
36
+ const logger = new Logger_1.Logger('ReactNativeUnifiedPlan');
37
+ const SCTP_NUM_STREAMS = { OS: 1024, MIS: 1024 };
38
+ class ReactNativeUnifiedPlan extends HandlerInterface_1.HandlerInterface {
39
+ /**
40
+ * Creates a factory function.
41
+ */
42
+ static createFactory() {
43
+ return () => new ReactNativeUnifiedPlan();
44
+ }
45
+ constructor() {
46
+ super();
47
+ // Map of RTCTransceivers indexed by MID.
48
+ this._mapMidTransceiver = new Map();
49
+ // Local stream for sending.
50
+ this._sendStream = new MediaStream();
51
+ // Whether a DataChannel m=application section has been created.
52
+ this._hasDataChannelMediaSection = false;
53
+ // Sending DataChannel id value counter. Incremented for each new DataChannel.
54
+ this._nextSendSctpStreamId = 0;
55
+ // Got transport local and remote parameters.
56
+ this._transportReady = false;
57
+ }
58
+ get name() {
59
+ return 'ReactNativeUnifiedPlan';
60
+ }
61
+ close() {
62
+ logger.debug('close()');
63
+ // Free/dispose native MediaStream but DO NOT free/dispose native
64
+ // MediaStreamTracks (that is parent's business).
65
+ // @ts-ignore (proprietary API in react-native-webrtc).
66
+ this._sendStream.release(/* releaseTracks */ false);
67
+ // Close RTCPeerConnection.
68
+ if (this._pc) {
69
+ try {
70
+ this._pc.close();
71
+ }
72
+ catch (error) { }
73
+ }
74
+ this.emit('@close');
75
+ }
76
+ async getNativeRtpCapabilities() {
77
+ logger.debug('getNativeRtpCapabilities()');
78
+ const pc = new RTCPeerConnection({
79
+ iceServers: [],
80
+ iceTransportPolicy: 'all',
81
+ bundlePolicy: 'max-bundle',
82
+ rtcpMuxPolicy: 'require',
83
+ sdpSemantics: 'unified-plan'
84
+ });
85
+ try {
86
+ pc.addTransceiver('audio');
87
+ pc.addTransceiver('video');
88
+ const offer = await pc.createOffer();
89
+ try {
90
+ pc.close();
91
+ }
92
+ catch (error) { }
93
+ const sdpObject = sdpTransform.parse(offer.sdp);
94
+ const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities({ sdpObject });
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
+ return {
108
+ numStreams: SCTP_NUM_STREAMS
109
+ };
110
+ }
111
+ run({ direction, iceParameters, iceCandidates, dtlsParameters, sctpParameters, iceServers, iceTransportPolicy, additionalSettings, proprietaryConstraints, extendedRtpCapabilities }) {
112
+ logger.debug('run()');
113
+ this._direction = direction;
114
+ this._remoteSdp = new RemoteSdp_1.RemoteSdp({
115
+ iceParameters,
116
+ iceCandidates,
117
+ dtlsParameters,
118
+ sctpParameters
119
+ });
120
+ this._sendingRtpParametersByKind =
121
+ {
122
+ audio: ortc.getSendingRtpParameters('audio', extendedRtpCapabilities),
123
+ video: ortc.getSendingRtpParameters('video', extendedRtpCapabilities)
124
+ };
125
+ this._sendingRemoteRtpParametersByKind =
126
+ {
127
+ audio: ortc.getSendingRemoteRtpParameters('audio', extendedRtpCapabilities),
128
+ video: ortc.getSendingRemoteRtpParameters('video', extendedRtpCapabilities)
129
+ };
130
+ if (dtlsParameters.role && dtlsParameters.role !== 'auto') {
131
+ this._forcedLocalDtlsRole = dtlsParameters.role === 'server'
132
+ ? 'client'
133
+ : 'server';
134
+ }
135
+ this._pc = new RTCPeerConnection({
136
+ iceServers: iceServers || [],
137
+ iceTransportPolicy: iceTransportPolicy || 'all',
138
+ bundlePolicy: 'max-bundle',
139
+ rtcpMuxPolicy: 'require',
140
+ sdpSemantics: 'unified-plan',
141
+ ...additionalSettings
142
+ }, proprietaryConstraints);
143
+ // Handle RTCPeerConnection connection status.
144
+ this._pc.addEventListener('iceconnectionstatechange', () => {
145
+ switch (this._pc.iceConnectionState) {
146
+ case 'checking':
147
+ this.emit('@connectionstatechange', 'connecting');
148
+ break;
149
+ case 'connected':
150
+ case 'completed':
151
+ this.emit('@connectionstatechange', 'connected');
152
+ break;
153
+ case 'failed':
154
+ this.emit('@connectionstatechange', 'failed');
155
+ break;
156
+ case 'disconnected':
157
+ this.emit('@connectionstatechange', 'disconnected');
158
+ break;
159
+ case 'closed':
160
+ this.emit('@connectionstatechange', 'closed');
161
+ break;
162
+ }
163
+ });
164
+ }
165
+ async updateIceServers(iceServers) {
166
+ logger.debug('updateIceServers()');
167
+ const configuration = this._pc.getConfiguration();
168
+ configuration.iceServers = iceServers;
169
+ this._pc.setConfiguration(configuration);
170
+ }
171
+ async restartIce(iceParameters) {
172
+ logger.debug('restartIce()');
173
+ // Provide the remote SDP handler with new remote ICE parameters.
174
+ this._remoteSdp.updateIceParameters(iceParameters);
175
+ if (!this._transportReady)
176
+ return;
177
+ if (this._direction === 'send') {
178
+ const offer = await this._pc.createOffer({ iceRestart: true });
179
+ logger.debug('restartIce() | calling pc.setLocalDescription() [offer:%o]', offer);
180
+ await this._pc.setLocalDescription(offer);
181
+ const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
182
+ logger.debug('restartIce() | calling pc.setRemoteDescription() [answer:%o]', answer);
183
+ await this._pc.setRemoteDescription(answer);
184
+ }
185
+ else {
186
+ const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
187
+ logger.debug('restartIce() | calling pc.setRemoteDescription() [offer:%o]', offer);
188
+ await this._pc.setRemoteDescription(offer);
189
+ const answer = await this._pc.createAnswer();
190
+ logger.debug('restartIce() | calling pc.setLocalDescription() [answer:%o]', answer);
191
+ await this._pc.setLocalDescription(answer);
192
+ }
193
+ }
194
+ async getTransportStats() {
195
+ return this._pc.getStats();
196
+ }
197
+ async send({ track, encodings, codecOptions, codec }) {
198
+ var _a;
199
+ this._assertSendDirection();
200
+ logger.debug('send() [kind:%s, track.id:%s]', track.kind, track.id);
201
+ if (encodings && encodings.length > 1) {
202
+ encodings.forEach((encoding, idx) => {
203
+ encoding.rid = `r${idx}`;
204
+ });
205
+ }
206
+ const sendingRtpParameters = utils.clone(this._sendingRtpParametersByKind[track.kind], {});
207
+ // This may throw.
208
+ sendingRtpParameters.codecs =
209
+ ortc.reduceCodecs(sendingRtpParameters.codecs, codec);
210
+ const sendingRemoteRtpParameters = utils.clone(this._sendingRemoteRtpParametersByKind[track.kind], {});
211
+ // This may throw.
212
+ sendingRemoteRtpParameters.codecs =
213
+ ortc.reduceCodecs(sendingRemoteRtpParameters.codecs, codec);
214
+ const mediaSectionIdx = this._remoteSdp.getNextMediaSectionIdx();
215
+ const transceiver = this._pc.addTransceiver(track, {
216
+ direction: 'sendonly',
217
+ streams: [this._sendStream],
218
+ sendEncodings: encodings
219
+ });
220
+ let offer = await this._pc.createOffer();
221
+ let localSdpObject = sdpTransform.parse(offer.sdp);
222
+ let offerMediaObject;
223
+ if (!this._transportReady) {
224
+ await this._setupTransport({
225
+ localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
226
+ localSdpObject
227
+ });
228
+ }
229
+ // Special case for VP9 with SVC.
230
+ let hackVp9Svc = false;
231
+ const layers = (0, scalabilityModes_1.parse)((encodings || [{}])[0].scalabilityMode);
232
+ if (encodings &&
233
+ encodings.length === 1 &&
234
+ layers.spatialLayers > 1 &&
235
+ sendingRtpParameters.codecs[0].mimeType.toLowerCase() === 'video/vp9') {
236
+ logger.debug('send() | enabling legacy simulcast for VP9 SVC');
237
+ hackVp9Svc = true;
238
+ localSdpObject = sdpTransform.parse(offer.sdp);
239
+ offerMediaObject = localSdpObject.media[mediaSectionIdx.idx];
240
+ sdpUnifiedPlanUtils.addLegacySimulcast({
241
+ offerMediaObject,
242
+ numStreams: layers.spatialLayers
243
+ });
244
+ offer = { type: 'offer', sdp: sdpTransform.write(localSdpObject) };
245
+ }
246
+ logger.debug('send() | calling pc.setLocalDescription() [offer:%o]', offer);
247
+ await this._pc.setLocalDescription(offer);
248
+ // We can now get the transceiver.mid.
249
+ const localId = transceiver.mid;
250
+ // Set MID.
251
+ sendingRtpParameters.mid = localId;
252
+ localSdpObject = sdpTransform.parse(this._pc.localDescription.sdp);
253
+ offerMediaObject = localSdpObject.media[mediaSectionIdx.idx];
254
+ // Set RTCP CNAME.
255
+ sendingRtpParameters.rtcp.cname =
256
+ sdpCommonUtils.getCname({ offerMediaObject });
257
+ // Set RTP encodings by parsing the SDP offer if no encodings are given.
258
+ if (!encodings) {
259
+ sendingRtpParameters.encodings =
260
+ sdpUnifiedPlanUtils.getRtpEncodings({ offerMediaObject });
261
+ }
262
+ // Set RTP encodings by parsing the SDP offer and complete them with given
263
+ // one if just a single encoding has been given.
264
+ else if (encodings.length === 1) {
265
+ let newEncodings = sdpUnifiedPlanUtils.getRtpEncodings({ offerMediaObject });
266
+ Object.assign(newEncodings[0], encodings[0]);
267
+ // Hack for VP9 SVC.
268
+ if (hackVp9Svc)
269
+ newEncodings = [newEncodings[0]];
270
+ sendingRtpParameters.encodings = newEncodings;
271
+ }
272
+ // Otherwise if more than 1 encoding are given use them verbatim.
273
+ else {
274
+ sendingRtpParameters.encodings = encodings;
275
+ }
276
+ // If VP8 or H264 and there is effective simulcast, add scalabilityMode to
277
+ // each encoding.
278
+ if (sendingRtpParameters.encodings.length > 1 &&
279
+ (sendingRtpParameters.codecs[0].mimeType.toLowerCase() === 'video/vp8' ||
280
+ sendingRtpParameters.codecs[0].mimeType.toLowerCase() === 'video/h264')) {
281
+ for (const encoding of sendingRtpParameters.encodings) {
282
+ encoding.scalabilityMode = 'S1T3';
283
+ }
284
+ }
285
+ this._remoteSdp.send({
286
+ offerMediaObject,
287
+ reuseMid: mediaSectionIdx.reuseMid,
288
+ offerRtpParameters: sendingRtpParameters,
289
+ answerRtpParameters: sendingRemoteRtpParameters,
290
+ codecOptions,
291
+ extmapAllowMixed: true
292
+ });
293
+ const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
294
+ logger.debug('send() | calling pc.setRemoteDescription() [answer:%o]', answer);
295
+ await this._pc.setRemoteDescription(answer);
296
+ // Store in the map.
297
+ this._mapMidTransceiver.set(localId, transceiver);
298
+ return {
299
+ localId,
300
+ rtpParameters: sendingRtpParameters,
301
+ rtpSender: transceiver.sender
302
+ };
303
+ }
304
+ async stopSending(localId) {
305
+ this._assertSendDirection();
306
+ logger.debug('stopSending() [localId:%s]', localId);
307
+ const transceiver = this._mapMidTransceiver.get(localId);
308
+ if (!transceiver)
309
+ throw new Error('associated RTCRtpTransceiver not found');
310
+ transceiver.sender.replaceTrack(null);
311
+ try {
312
+ transceiver.stop();
313
+ }
314
+ catch (error) { }
315
+ this._pc.removeTrack(transceiver.sender);
316
+ this._remoteSdp.closeMediaSection(transceiver.mid);
317
+ const offer = await this._pc.createOffer();
318
+ logger.debug('stopSending() | calling pc.setLocalDescription() [offer:%o]', offer);
319
+ await this._pc.setLocalDescription(offer);
320
+ const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
321
+ logger.debug('stopSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
322
+ await this._pc.setRemoteDescription(answer);
323
+ this._mapMidTransceiver.delete(localId);
324
+ }
325
+ async pauseSending(localId) {
326
+ this._assertSendDirection();
327
+ logger.debug('pauseSending() [localId:%s]', localId);
328
+ const transceiver = this._mapMidTransceiver.get(localId);
329
+ if (!transceiver)
330
+ throw new Error('associated RTCRtpTransceiver not found');
331
+ transceiver.direction = 'inactive';
332
+ this._remoteSdp.pauseMediaSection(localId);
333
+ const offer = await this._pc.createOffer();
334
+ logger.debug('pauseSending() | calling pc.setLocalDescription() [offer:%o]', offer);
335
+ await this._pc.setLocalDescription(offer);
336
+ const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
337
+ logger.debug('pauseSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
338
+ await this._pc.setRemoteDescription(answer);
339
+ }
340
+ async resumeSending(localId) {
341
+ this._assertSendDirection();
342
+ logger.debug('resumeSending() [localId:%s]', localId);
343
+ const transceiver = this._mapMidTransceiver.get(localId);
344
+ this._remoteSdp.resumeSendingMediaSection(localId);
345
+ if (!transceiver)
346
+ throw new Error('associated RTCRtpTransceiver not found');
347
+ transceiver.direction = 'sendonly';
348
+ const offer = await this._pc.createOffer();
349
+ logger.debug('resumeSending() | calling pc.setLocalDescription() [offer:%o]', offer);
350
+ await this._pc.setLocalDescription(offer);
351
+ const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
352
+ logger.debug('resumeSending() | calling pc.setRemoteDescription() [answer:%o]', answer);
353
+ await this._pc.setRemoteDescription(answer);
354
+ }
355
+ async replaceTrack(localId, track) {
356
+ this._assertSendDirection();
357
+ if (track) {
358
+ logger.debug('replaceTrack() [localId:%s, track.id:%s]', localId, track.id);
359
+ }
360
+ else {
361
+ logger.debug('replaceTrack() [localId:%s, no track]', localId);
362
+ }
363
+ const transceiver = this._mapMidTransceiver.get(localId);
364
+ if (!transceiver)
365
+ throw new Error('associated RTCRtpTransceiver not found');
366
+ await transceiver.sender.replaceTrack(track);
367
+ }
368
+ async setMaxSpatialLayer(localId, spatialLayer) {
369
+ this._assertSendDirection();
370
+ logger.debug('setMaxSpatialLayer() [localId:%s, spatialLayer:%s]', localId, spatialLayer);
371
+ const transceiver = this._mapMidTransceiver.get(localId);
372
+ if (!transceiver)
373
+ throw new Error('associated RTCRtpTransceiver not found');
374
+ const parameters = transceiver.sender.getParameters();
375
+ parameters.encodings.forEach((encoding, idx) => {
376
+ if (idx <= spatialLayer)
377
+ encoding.active = true;
378
+ else
379
+ encoding.active = false;
380
+ });
381
+ await transceiver.sender.setParameters(parameters);
382
+ }
383
+ async setRtpEncodingParameters(localId, params) {
384
+ this._assertSendDirection();
385
+ logger.debug('setRtpEncodingParameters() [localId:%s, params:%o]', localId, params);
386
+ const transceiver = this._mapMidTransceiver.get(localId);
387
+ if (!transceiver)
388
+ throw new Error('associated RTCRtpTransceiver not found');
389
+ const parameters = transceiver.sender.getParameters();
390
+ parameters.encodings.forEach((encoding, idx) => {
391
+ parameters.encodings[idx] = { ...encoding, ...params };
392
+ });
393
+ await transceiver.sender.setParameters(parameters);
394
+ }
395
+ async getSenderStats(localId) {
396
+ this._assertSendDirection();
397
+ const transceiver = this._mapMidTransceiver.get(localId);
398
+ if (!transceiver)
399
+ throw new Error('associated RTCRtpTransceiver not found');
400
+ return transceiver.sender.getStats();
401
+ }
402
+ async sendDataChannel({ ordered, maxPacketLifeTime, maxRetransmits, label, protocol }) {
403
+ var _a;
404
+ this._assertSendDirection();
405
+ const options = {
406
+ negotiated: true,
407
+ id: this._nextSendSctpStreamId,
408
+ ordered,
409
+ maxPacketLifeTime,
410
+ maxRetransmits,
411
+ protocol
412
+ };
413
+ logger.debug('sendDataChannel() [options:%o]', options);
414
+ const dataChannel = this._pc.createDataChannel(label, options);
415
+ // Increase next id.
416
+ this._nextSendSctpStreamId =
417
+ ++this._nextSendSctpStreamId % SCTP_NUM_STREAMS.MIS;
418
+ // If this is the first DataChannel we need to create the SDP answer with
419
+ // m=application section.
420
+ if (!this._hasDataChannelMediaSection) {
421
+ const offer = await this._pc.createOffer();
422
+ const localSdpObject = sdpTransform.parse(offer.sdp);
423
+ const offerMediaObject = localSdpObject.media
424
+ .find((m) => m.type === 'application');
425
+ if (!this._transportReady) {
426
+ await this._setupTransport({
427
+ localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
428
+ localSdpObject
429
+ });
430
+ }
431
+ logger.debug('sendDataChannel() | calling pc.setLocalDescription() [offer:%o]', offer);
432
+ await this._pc.setLocalDescription(offer);
433
+ this._remoteSdp.sendSctpAssociation({ offerMediaObject });
434
+ const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };
435
+ logger.debug('sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]', answer);
436
+ await this._pc.setRemoteDescription(answer);
437
+ this._hasDataChannelMediaSection = true;
438
+ }
439
+ const sctpStreamParameters = {
440
+ streamId: options.id,
441
+ ordered: options.ordered,
442
+ maxPacketLifeTime: options.maxPacketLifeTime,
443
+ maxRetransmits: options.maxRetransmits
444
+ };
445
+ return { dataChannel, sctpStreamParameters };
446
+ }
447
+ async receive(optionsList) {
448
+ var _a;
449
+ this._assertRecvDirection();
450
+ const results = [];
451
+ const mapLocalId = new Map();
452
+ for (const options of optionsList) {
453
+ const { trackId, kind, rtpParameters } = options;
454
+ logger.debug('receive() [trackId:%s, kind:%s]', trackId, kind);
455
+ const localId = rtpParameters.mid || String(this._mapMidTransceiver.size);
456
+ mapLocalId.set(trackId, localId);
457
+ this._remoteSdp.receive({
458
+ mid: localId,
459
+ kind,
460
+ offerRtpParameters: rtpParameters,
461
+ streamId: rtpParameters.rtcp.cname,
462
+ trackId
463
+ });
464
+ }
465
+ const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
466
+ logger.debug('receive() | calling pc.setRemoteDescription() [offer:%o]', offer);
467
+ await this._pc.setRemoteDescription(offer);
468
+ let answer = await this._pc.createAnswer();
469
+ const localSdpObject = sdpTransform.parse(answer.sdp);
470
+ for (const options of optionsList) {
471
+ const { trackId, rtpParameters } = options;
472
+ const localId = mapLocalId.get(trackId);
473
+ const answerMediaObject = localSdpObject.media
474
+ .find((m) => String(m.mid) === localId);
475
+ // May need to modify codec parameters in the answer based on codec
476
+ // parameters in the offer.
477
+ sdpCommonUtils.applyCodecParameters({
478
+ offerRtpParameters: rtpParameters,
479
+ answerMediaObject
480
+ });
481
+ }
482
+ answer = { type: 'answer', sdp: sdpTransform.write(localSdpObject) };
483
+ if (!this._transportReady) {
484
+ await this._setupTransport({
485
+ localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
486
+ localSdpObject
487
+ });
488
+ }
489
+ logger.debug('receive() | calling pc.setLocalDescription() [answer:%o]', answer);
490
+ await this._pc.setLocalDescription(answer);
491
+ for (const options of optionsList) {
492
+ const { trackId } = options;
493
+ const localId = mapLocalId.get(trackId);
494
+ const transceiver = this._pc.getTransceivers()
495
+ .find((t) => t.mid === localId);
496
+ if (!transceiver) {
497
+ throw new Error('new RTCRtpTransceiver not found');
498
+ }
499
+ else {
500
+ // Store in the map.
501
+ this._mapMidTransceiver.set(localId, transceiver);
502
+ results.push({
503
+ localId,
504
+ track: transceiver.receiver.track,
505
+ rtpReceiver: transceiver.receiver
506
+ });
507
+ }
508
+ }
509
+ return results;
510
+ }
511
+ async stopReceiving(localIds) {
512
+ this._assertRecvDirection();
513
+ for (const localId of localIds) {
514
+ logger.debug('stopReceiving() [localId:%s]', localId);
515
+ const transceiver = this._mapMidTransceiver.get(localId);
516
+ if (!transceiver)
517
+ throw new Error('associated RTCRtpTransceiver not found');
518
+ this._remoteSdp.closeMediaSection(transceiver.mid);
519
+ }
520
+ const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
521
+ logger.debug('stopReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
522
+ await this._pc.setRemoteDescription(offer);
523
+ const answer = await this._pc.createAnswer();
524
+ logger.debug('stopReceiving() | calling pc.setLocalDescription() [answer:%o]', answer);
525
+ await this._pc.setLocalDescription(answer);
526
+ for (const localId of localIds) {
527
+ this._mapMidTransceiver.delete(localId);
528
+ }
529
+ }
530
+ async pauseReceiving(localIds) {
531
+ this._assertRecvDirection();
532
+ for (const localId of localIds) {
533
+ logger.debug('pauseReceiving() [localId:%s]', localId);
534
+ const transceiver = this._mapMidTransceiver.get(localId);
535
+ if (!transceiver)
536
+ throw new Error('associated RTCRtpTransceiver not found');
537
+ transceiver.direction = 'inactive';
538
+ this._remoteSdp.pauseMediaSection(localId);
539
+ }
540
+ const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
541
+ logger.debug('pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
542
+ await this._pc.setRemoteDescription(offer);
543
+ const answer = await this._pc.createAnswer();
544
+ logger.debug('pauseReceiving() | calling pc.setLocalDescription() [answer:%o]', answer);
545
+ await this._pc.setLocalDescription(answer);
546
+ }
547
+ async resumeReceiving(localIds) {
548
+ this._assertRecvDirection();
549
+ for (const localId of localIds) {
550
+ logger.debug('resumeReceiving() [localId:%s]', localId);
551
+ const transceiver = this._mapMidTransceiver.get(localId);
552
+ if (!transceiver)
553
+ throw new Error('associated RTCRtpTransceiver not found');
554
+ transceiver.direction = 'recvonly';
555
+ this._remoteSdp.resumeReceivingMediaSection(localId);
556
+ }
557
+ const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
558
+ logger.debug('resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]', offer);
559
+ await this._pc.setRemoteDescription(offer);
560
+ const answer = await this._pc.createAnswer();
561
+ logger.debug('resumeReceiving() | calling pc.setLocalDescription() [answer:%o]', answer);
562
+ await this._pc.setLocalDescription(answer);
563
+ }
564
+ async getReceiverStats(localId) {
565
+ this._assertRecvDirection();
566
+ const transceiver = this._mapMidTransceiver.get(localId);
567
+ if (!transceiver)
568
+ throw new Error('associated RTCRtpTransceiver not found');
569
+ return transceiver.receiver.getStats();
570
+ }
571
+ async receiveDataChannel({ sctpStreamParameters, label, protocol }) {
572
+ var _a;
573
+ this._assertRecvDirection();
574
+ const { streamId, ordered, maxPacketLifeTime, maxRetransmits } = sctpStreamParameters;
575
+ const options = {
576
+ negotiated: true,
577
+ id: streamId,
578
+ ordered,
579
+ maxPacketLifeTime,
580
+ maxRetransmits,
581
+ protocol
582
+ };
583
+ logger.debug('receiveDataChannel() [options:%o]', options);
584
+ const dataChannel = this._pc.createDataChannel(label, options);
585
+ // If this is the first DataChannel we need to create the SDP offer with
586
+ // m=application section.
587
+ if (!this._hasDataChannelMediaSection) {
588
+ this._remoteSdp.receiveSctpAssociation();
589
+ const offer = { type: 'offer', sdp: this._remoteSdp.getSdp() };
590
+ logger.debug('receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]', offer);
591
+ await this._pc.setRemoteDescription(offer);
592
+ const answer = await this._pc.createAnswer();
593
+ if (!this._transportReady) {
594
+ const localSdpObject = sdpTransform.parse(answer.sdp);
595
+ await this._setupTransport({
596
+ localDtlsRole: (_a = this._forcedLocalDtlsRole) !== null && _a !== void 0 ? _a : 'client',
597
+ localSdpObject
598
+ });
599
+ }
600
+ logger.debug('receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]', answer);
601
+ await this._pc.setLocalDescription(answer);
602
+ this._hasDataChannelMediaSection = true;
603
+ }
604
+ return { dataChannel };
605
+ }
606
+ async _setupTransport({ localDtlsRole, localSdpObject }) {
607
+ if (!localSdpObject)
608
+ localSdpObject = sdpTransform.parse(this._pc.localDescription.sdp);
609
+ // Get our local DTLS parameters.
610
+ const dtlsParameters = sdpCommonUtils.extractDtlsParameters({ sdpObject: localSdpObject });
611
+ // Set our DTLS role.
612
+ dtlsParameters.role = localDtlsRole;
613
+ // Update the remote DTLS role in the SDP.
614
+ this._remoteSdp.updateDtlsRole(localDtlsRole === 'client' ? 'server' : 'client');
615
+ // Need to tell the remote transport about our parameters.
616
+ await new Promise((resolve, reject) => {
617
+ this.safeEmit('@connect', { dtlsParameters }, resolve, reject);
618
+ });
619
+ this._transportReady = true;
620
+ }
621
+ _assertSendDirection() {
622
+ if (this._direction !== 'send') {
623
+ throw new Error('method can just be called for handlers with "send" direction');
624
+ }
625
+ }
626
+ _assertRecvDirection() {
627
+ if (this._direction !== 'recv') {
628
+ throw new Error('method can just be called for handlers with "recv" direction');
629
+ }
630
+ }
631
+ }
632
+ exports.ReactNativeUnifiedPlan = ReactNativeUnifiedPlan;
package/lib/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { types };
8
8
  /**
9
9
  * Expose mediasoup-client version.
10
10
  */
11
- export declare const version = "3.6.62";
11
+ export declare const version = "3.6.64";
12
12
  /**
13
13
  * Expose Device class and detectDevice() helper.
14
14
  */
package/lib/index.js CHANGED
@@ -37,7 +37,7 @@ exports.types = types;
37
37
  /**
38
38
  * Expose mediasoup-client version.
39
39
  */
40
- exports.version = '3.6.62';
40
+ exports.version = '3.6.64';
41
41
  /**
42
42
  * Expose parseScalabilityMode() function.
43
43
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup-client",
3
- "version": "3.6.62",
3
+ "version": "3.6.64",
4
4
  "description": "mediasoup client side JavaScript library",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -77,10 +77,10 @@
77
77
  "@types/jest": "^29.2.3",
78
78
  "@types/sdp-transform": "^2.4.5",
79
79
  "@types/uuid": "^3.4.9",
80
- "@typescript-eslint/eslint-plugin": "^5.43.0",
81
- "@typescript-eslint/parser": "^5.43.0",
82
- "eslint": "^8.27.0",
83
- "eslint-plugin-jest": "^27.1.5",
80
+ "@typescript-eslint/eslint-plugin": "^5.45.0",
81
+ "@typescript-eslint/parser": "^5.45.0",
82
+ "eslint": "^8.28.0",
83
+ "eslint-plugin-jest": "^27.1.6",
84
84
  "jest": "^29.3.1",
85
85
  "open-cli": "^7.1.0",
86
86
  "ts-jest": "^29.0.3",