@webex/web-client-media-engine 1.33.2 → 1.34.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.
package/dist/esm/index.js CHANGED
@@ -9434,41 +9434,42 @@ class MultistreamConnection extends EventEmitter {
9434
9434
  this.overuseUpdateCallback = () => { };
9435
9435
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
9436
9436
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
9437
- this.pc = new PeerConnection();
9438
- this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state));
9437
+ this.initializePeerConnection();
9439
9438
  this.streamSignalerManager = new StreamSignalerManager(this.options.streamSignalingMode);
9440
9439
  this.overuseStateManager = new OveruseStateManager((overuseState) => this.overuseUpdateCallback(overuseState));
9441
9440
  this.overuseStateManager.start();
9442
9441
  this.statsManager = new StatsManager(() => this.pc.getStats(), (stats) => this.preProcessStats(stats));
9443
- this.attachMetricsObserver();
9444
9442
  const mainSceneId = generateSceneId();
9445
- const videoMainEncodingOptions = !this.options.disableSimulcast
9446
- ? [
9447
- { scaleResolutionDownBy: 4, active: false },
9448
- { scaleResolutionDownBy: 2, active: false },
9449
- { active: false },
9450
- ]
9451
- : [{ active: false }];
9443
+ const videoMainEncodingOptions = this.getVideoEncodingOptions();
9452
9444
  this.createSendTransceiver(MediaType.VideoMain, mainSceneId, videoMainEncodingOptions);
9453
9445
  this.createSendTransceiver(MediaType.AudioMain, mainSceneId);
9454
9446
  if (this.options.floorControlledPresentation) {
9455
- const videoPresentationEncodingOptions = !this.options
9456
- .disableSimulcast
9457
- ? [
9458
- { scaleResolutionDownBy: 4, active: false },
9459
- { scaleResolutionDownBy: 2, active: false },
9460
- { active: false },
9461
- ]
9462
- : [{ active: false }];
9447
+ const videoPresentationEncodingOptions = this.getVideoEncodingOptions();
9463
9448
  const contentSceneId = generateSceneId();
9464
9449
  this.createSendTransceiver(MediaType.VideoSlides, contentSceneId, videoPresentationEncodingOptions);
9465
9450
  this.createSendTransceiver(MediaType.AudioSlides, contentSceneId);
9466
9451
  }
9452
+ }
9453
+ initializePeerConnection() {
9454
+ var _a;
9455
+ (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
9456
+ this.pc = new PeerConnection();
9457
+ this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state));
9458
+ this.attachMetricsObserver();
9467
9459
  this.createDataChannel();
9468
9460
  }
9469
9461
  getConnectionState() {
9470
9462
  return this.pc.getConnectionState();
9471
9463
  }
9464
+ getVideoEncodingOptions() {
9465
+ return !this.options.disableSimulcast
9466
+ ? [
9467
+ { scaleResolutionDownBy: 4, active: false },
9468
+ { scaleResolutionDownBy: 2, active: false },
9469
+ { active: false },
9470
+ ]
9471
+ : [{ active: false }];
9472
+ }
9472
9473
  createSendTransceiver(mediaType, sceneId, sendEncodingsOptions) {
9473
9474
  const rtcTransceiver = this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
9474
9475
  direction: 'sendrecv',
@@ -9476,6 +9477,9 @@ class MultistreamConnection extends EventEmitter {
9476
9477
  });
9477
9478
  const csi = generateCsi(getMediaFamily(mediaType), sceneId);
9478
9479
  this.sendTransceivers.set(mediaType, new SendOnlyTransceiver(rtcTransceiver, csi));
9480
+ this.createJmpSession(mediaType);
9481
+ }
9482
+ createJmpSession(mediaType) {
9479
9483
  const jmpSession = new JmpSession(getMediaFamily(mediaType), getMediaContent(mediaType));
9480
9484
  jmpSession.setTxCallback((msg) => {
9481
9485
  var _a;
@@ -9920,13 +9924,26 @@ class MultistreamConnection extends EventEmitter {
9920
9924
  this.pendingJmpTasks.push(task);
9921
9925
  }
9922
9926
  }
9923
- renewPeerConnection() {
9924
- var _a;
9925
- (_a = this.pc) === null || _a === void 0 ? void 0 : _a.close();
9926
- this.pc = new PeerConnection();
9927
- this.attachMetricsObserver();
9928
- this.createDataChannel();
9929
- this.sendTransceivers.forEach((transceiver, mediaType) => transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType))));
9927
+ renewPeerConnection(userOptions) {
9928
+ if (userOptions) {
9929
+ this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
9930
+ }
9931
+ logger.info(`Renewing multistream connection with options ${JSON.stringify(this.options)}`);
9932
+ this.initializePeerConnection();
9933
+ this.streamSignalerManager = new StreamSignalerManager(this.options.streamSignalingMode);
9934
+ const mainSceneId = generateSceneId();
9935
+ this.sendTransceivers.forEach((transceiver, mediaType) => {
9936
+ var _a;
9937
+ transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
9938
+ direction: 'sendrecv',
9939
+ sendEncodings: getMediaFamily(mediaType) === MediaFamily.Video
9940
+ ? this.getVideoEncodingOptions()
9941
+ : undefined,
9942
+ }));
9943
+ transceiver.csi = generateCsi(getMediaFamily(mediaType), mainSceneId);
9944
+ (_a = this.jmpSessions.get(mediaType)) === null || _a === void 0 ? void 0 : _a.close();
9945
+ this.createJmpSession(mediaType);
9946
+ });
9930
9947
  this.recvTransceivers.forEach((transceivers, mediaType) => {
9931
9948
  transceivers.forEach((t) => {
9932
9949
  t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {