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