@whereby.com/media 1.24.0 → 1.25.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/index.cjs CHANGED
@@ -2578,15 +2578,30 @@ const SCREEN_SHARE_SIMULCAST_SETTINGS = {
2578
2578
  { scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
2579
2579
  ],
2580
2580
  };
2581
+ const ADDITIONAL_SCREEN_SHARE_SETTINGS = {
2582
+ encodings: [
2583
+ { scaleResolutionDownBy: 4, dtx: true, maxBitrate: 150000 },
2584
+ { scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
2585
+ { scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
2586
+ ],
2587
+ };
2588
+ const ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9 = {
2589
+ encodings: [{ scalabilityMode: "L2T2_KEY", dtx: true, maxBitrate: 1500000 }],
2590
+ };
2581
2591
  const SCREEN_SHARE_SETTINGS_VP9 = {
2582
2592
  encodings: [{ dtx: true }],
2583
2593
  };
2584
- const getMediaSettings = (kind, isScreenShare, features) => {
2594
+ const getMediaSettings = (kind, isScreenShare, features, isSomeoneAlreadyPresenting = false) => {
2585
2595
  const { lowDataModeEnabled, simulcastScreenshareOn, lowBandwidth, vp9On } = features;
2586
2596
  if (kind === "audio") {
2587
2597
  return AUDIO_SETTINGS;
2588
2598
  }
2589
2599
  if (isScreenShare) {
2600
+ if (isSomeoneAlreadyPresenting) {
2601
+ if (vp9On)
2602
+ return ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9;
2603
+ return ADDITIONAL_SCREEN_SHARE_SETTINGS;
2604
+ }
2590
2605
  if (lowBandwidth && !vp9On)
2591
2606
  return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
2592
2607
  if (vp9On)
@@ -5706,7 +5721,7 @@ class VegaRtcManager {
5706
5721
  this._screenVideoProducerPromise = null;
5707
5722
  return;
5708
5723
  }
5709
- const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }))), { appData: {
5724
+ const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }), this._getIsSomeoneAlreadyPresenting())), { appData: {
5710
5725
  streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
5711
5726
  sourceClientId: this._selfId,
5712
5727
  screenShare: true,
@@ -5846,6 +5861,9 @@ class VegaRtcManager {
5846
5861
  producer.appData.localClosed = true;
5847
5862
  producer.close();
5848
5863
  }
5864
+ _getIsSomeoneAlreadyPresenting() {
5865
+ return !![...this._clientStates.values()].find((state) => state.hasAcceptedScreenStream && state.screenStream);
5866
+ }
5849
5867
  isInitializedWith({ selfId, roomName, isSfu }) {
5850
5868
  return this._selfId === selfId && this._room.name === roomName && Boolean(isSfu);
5851
5869
  }
@@ -5875,8 +5893,8 @@ class VegaRtcManager {
5875
5893
  disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
5876
5894
  var _a;
5877
5895
  logger$3.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
5878
- if (this._clientStates.has(clientIdOrStreamId)) {
5879
- const clientState = this._clientStates.get(clientIdOrStreamId);
5896
+ const clientState = this._clientStates.get(clientIdOrStreamId);
5897
+ if (clientState) {
5880
5898
  clientState.hasAcceptedWebcamStream = false;
5881
5899
  clientState.hasAcceptedScreenStream = false;
5882
5900
  this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
@@ -6324,13 +6342,13 @@ class VegaRtcManager {
6324
6342
  this._streamIdToVideoConsumerId.delete(stream.id);
6325
6343
  this._streamIdToVideoResolution.delete(stream.id);
6326
6344
  if (screenShare) {
6327
- clientState.screenStream = null;
6345
+ clientState.screenStream = undefined;
6328
6346
  clientState.hasEmittedScreenStream = false;
6329
- clientState.screenShareStreamId = null;
6347
+ clientState.screenShareStreamId = undefined;
6330
6348
  }
6331
6349
  else {
6332
6350
  clientState.hasEmittedWebcamStream = false;
6333
- clientState.camStreamId = null;
6351
+ clientState.camStreamId = undefined;
6334
6352
  }
6335
6353
  }
6336
6354
  }
@@ -6396,10 +6414,6 @@ class VegaRtcManager {
6396
6414
  hasAcceptedScreenStream: false,
6397
6415
  hasEmittedWebcamStream: false,
6398
6416
  hasEmittedScreenStream: false,
6399
- webcamStream: null,
6400
- screenStream: null,
6401
- screenShareStreamId: null,
6402
- camStreamId: null,
6403
6417
  };
6404
6418
  this._clientStates.set(clientId, clientState);
6405
6419
  }
package/dist/index.d.cts CHANGED
@@ -601,7 +601,7 @@ declare const getMediaSettings: (kind: string, isScreenShare: boolean, features:
601
601
  simulcastScreenshareOn?: boolean;
602
602
  lowBandwidth?: boolean;
603
603
  vp9On?: boolean;
604
- }) => {
604
+ }, isSomeoneAlreadyPresenting?: boolean) => {
605
605
  encodings: {}[];
606
606
  };
607
607
  declare const modifyMediaCapabilities: (routerRtpCapabilities: any, features: {
@@ -1355,6 +1355,19 @@ declare function createVegaConnectionManager(config: {
1355
1355
  networkIsPossiblyDown: () => void;
1356
1356
  };
1357
1357
 
1358
+ type MediaSteamWhichMayHaveInboundId = MediaStream & {
1359
+ inboundId?: string;
1360
+ };
1361
+ type ClientState = {
1362
+ hasAcceptedWebcamStream: Boolean;
1363
+ hasAcceptedScreenStream: Boolean;
1364
+ hasEmittedWebcamStream: Boolean;
1365
+ hasEmittedScreenStream: Boolean;
1366
+ webcamStream?: MediaSteamWhichMayHaveInboundId;
1367
+ screenStream?: MediaSteamWhichMayHaveInboundId;
1368
+ screenShareStreamId?: string;
1369
+ camStreamId?: string;
1370
+ };
1358
1371
  declare class VegaRtcManager implements RtcManager {
1359
1372
  _selfId: any;
1360
1373
  _room: any;
@@ -1371,7 +1384,7 @@ declare class VegaRtcManager implements RtcManager {
1371
1384
  _routerRtpCapabilities: any;
1372
1385
  _sendTransport: any;
1373
1386
  _receiveTransport: any;
1374
- _clientStates: any;
1387
+ _clientStates: Map<string, ClientState>;
1375
1388
  _streamIdToVideoConsumerId: any;
1376
1389
  _streamIdToVideoResolution: Map<string, {
1377
1390
  width: number;
@@ -1463,6 +1476,7 @@ declare class VegaRtcManager implements RtcManager {
1463
1476
  _replaceScreenAudioTrack(): Promise<void>;
1464
1477
  _sendScreenAudio(track: MediaStreamTrack): Promise<void>;
1465
1478
  _stopProducer(producer: any): void;
1479
+ _getIsSomeoneAlreadyPresenting(): boolean;
1466
1480
  isInitializedWith({ selfId, roomName, isSfu }: {
1467
1481
  selfId: string;
1468
1482
  roomName: string;
@@ -1534,13 +1548,13 @@ declare class VegaRtcManager implements RtcManager {
1534
1548
  }): void;
1535
1549
  _consumerClosedCleanup(consumer: any): void;
1536
1550
  _syncIncomingStreamsWithPWA(clientId: string): void;
1537
- _getOrCreateClientState(clientId: string): any;
1551
+ _getOrCreateClientState(clientId: string): ClientState;
1538
1552
  _emitToPWA(eventName: string, data?: any): void;
1539
1553
  _emitToSignal(eventName: string, data?: any, callback?: any): void;
1540
1554
  shouldAcceptStreamsFromBothSides(): boolean;
1541
1555
  setMicAnalyserDebugger(analyserDebugger: any): void;
1542
1556
  setMicAnalyserParams(params: any): void;
1543
- hasClient(clientId: string): any;
1557
+ hasClient(clientId: string): boolean;
1544
1558
  }
1545
1559
 
1546
1560
  declare const EVENTS: Record<string, keyof RtcEvents>;
package/dist/index.d.mts CHANGED
@@ -601,7 +601,7 @@ declare const getMediaSettings: (kind: string, isScreenShare: boolean, features:
601
601
  simulcastScreenshareOn?: boolean;
602
602
  lowBandwidth?: boolean;
603
603
  vp9On?: boolean;
604
- }) => {
604
+ }, isSomeoneAlreadyPresenting?: boolean) => {
605
605
  encodings: {}[];
606
606
  };
607
607
  declare const modifyMediaCapabilities: (routerRtpCapabilities: any, features: {
@@ -1355,6 +1355,19 @@ declare function createVegaConnectionManager(config: {
1355
1355
  networkIsPossiblyDown: () => void;
1356
1356
  };
1357
1357
 
1358
+ type MediaSteamWhichMayHaveInboundId = MediaStream & {
1359
+ inboundId?: string;
1360
+ };
1361
+ type ClientState = {
1362
+ hasAcceptedWebcamStream: Boolean;
1363
+ hasAcceptedScreenStream: Boolean;
1364
+ hasEmittedWebcamStream: Boolean;
1365
+ hasEmittedScreenStream: Boolean;
1366
+ webcamStream?: MediaSteamWhichMayHaveInboundId;
1367
+ screenStream?: MediaSteamWhichMayHaveInboundId;
1368
+ screenShareStreamId?: string;
1369
+ camStreamId?: string;
1370
+ };
1358
1371
  declare class VegaRtcManager implements RtcManager {
1359
1372
  _selfId: any;
1360
1373
  _room: any;
@@ -1371,7 +1384,7 @@ declare class VegaRtcManager implements RtcManager {
1371
1384
  _routerRtpCapabilities: any;
1372
1385
  _sendTransport: any;
1373
1386
  _receiveTransport: any;
1374
- _clientStates: any;
1387
+ _clientStates: Map<string, ClientState>;
1375
1388
  _streamIdToVideoConsumerId: any;
1376
1389
  _streamIdToVideoResolution: Map<string, {
1377
1390
  width: number;
@@ -1463,6 +1476,7 @@ declare class VegaRtcManager implements RtcManager {
1463
1476
  _replaceScreenAudioTrack(): Promise<void>;
1464
1477
  _sendScreenAudio(track: MediaStreamTrack): Promise<void>;
1465
1478
  _stopProducer(producer: any): void;
1479
+ _getIsSomeoneAlreadyPresenting(): boolean;
1466
1480
  isInitializedWith({ selfId, roomName, isSfu }: {
1467
1481
  selfId: string;
1468
1482
  roomName: string;
@@ -1534,13 +1548,13 @@ declare class VegaRtcManager implements RtcManager {
1534
1548
  }): void;
1535
1549
  _consumerClosedCleanup(consumer: any): void;
1536
1550
  _syncIncomingStreamsWithPWA(clientId: string): void;
1537
- _getOrCreateClientState(clientId: string): any;
1551
+ _getOrCreateClientState(clientId: string): ClientState;
1538
1552
  _emitToPWA(eventName: string, data?: any): void;
1539
1553
  _emitToSignal(eventName: string, data?: any, callback?: any): void;
1540
1554
  shouldAcceptStreamsFromBothSides(): boolean;
1541
1555
  setMicAnalyserDebugger(analyserDebugger: any): void;
1542
1556
  setMicAnalyserParams(params: any): void;
1543
- hasClient(clientId: string): any;
1557
+ hasClient(clientId: string): boolean;
1544
1558
  }
1545
1559
 
1546
1560
  declare const EVENTS: Record<string, keyof RtcEvents>;
package/dist/index.d.ts CHANGED
@@ -601,7 +601,7 @@ declare const getMediaSettings: (kind: string, isScreenShare: boolean, features:
601
601
  simulcastScreenshareOn?: boolean;
602
602
  lowBandwidth?: boolean;
603
603
  vp9On?: boolean;
604
- }) => {
604
+ }, isSomeoneAlreadyPresenting?: boolean) => {
605
605
  encodings: {}[];
606
606
  };
607
607
  declare const modifyMediaCapabilities: (routerRtpCapabilities: any, features: {
@@ -1355,6 +1355,19 @@ declare function createVegaConnectionManager(config: {
1355
1355
  networkIsPossiblyDown: () => void;
1356
1356
  };
1357
1357
 
1358
+ type MediaSteamWhichMayHaveInboundId = MediaStream & {
1359
+ inboundId?: string;
1360
+ };
1361
+ type ClientState = {
1362
+ hasAcceptedWebcamStream: Boolean;
1363
+ hasAcceptedScreenStream: Boolean;
1364
+ hasEmittedWebcamStream: Boolean;
1365
+ hasEmittedScreenStream: Boolean;
1366
+ webcamStream?: MediaSteamWhichMayHaveInboundId;
1367
+ screenStream?: MediaSteamWhichMayHaveInboundId;
1368
+ screenShareStreamId?: string;
1369
+ camStreamId?: string;
1370
+ };
1358
1371
  declare class VegaRtcManager implements RtcManager {
1359
1372
  _selfId: any;
1360
1373
  _room: any;
@@ -1371,7 +1384,7 @@ declare class VegaRtcManager implements RtcManager {
1371
1384
  _routerRtpCapabilities: any;
1372
1385
  _sendTransport: any;
1373
1386
  _receiveTransport: any;
1374
- _clientStates: any;
1387
+ _clientStates: Map<string, ClientState>;
1375
1388
  _streamIdToVideoConsumerId: any;
1376
1389
  _streamIdToVideoResolution: Map<string, {
1377
1390
  width: number;
@@ -1463,6 +1476,7 @@ declare class VegaRtcManager implements RtcManager {
1463
1476
  _replaceScreenAudioTrack(): Promise<void>;
1464
1477
  _sendScreenAudio(track: MediaStreamTrack): Promise<void>;
1465
1478
  _stopProducer(producer: any): void;
1479
+ _getIsSomeoneAlreadyPresenting(): boolean;
1466
1480
  isInitializedWith({ selfId, roomName, isSfu }: {
1467
1481
  selfId: string;
1468
1482
  roomName: string;
@@ -1534,13 +1548,13 @@ declare class VegaRtcManager implements RtcManager {
1534
1548
  }): void;
1535
1549
  _consumerClosedCleanup(consumer: any): void;
1536
1550
  _syncIncomingStreamsWithPWA(clientId: string): void;
1537
- _getOrCreateClientState(clientId: string): any;
1551
+ _getOrCreateClientState(clientId: string): ClientState;
1538
1552
  _emitToPWA(eventName: string, data?: any): void;
1539
1553
  _emitToSignal(eventName: string, data?: any, callback?: any): void;
1540
1554
  shouldAcceptStreamsFromBothSides(): boolean;
1541
1555
  setMicAnalyserDebugger(analyserDebugger: any): void;
1542
1556
  setMicAnalyserParams(params: any): void;
1543
- hasClient(clientId: string): any;
1557
+ hasClient(clientId: string): boolean;
1544
1558
  }
1545
1559
 
1546
1560
  declare const EVENTS: Record<string, keyof RtcEvents>;
package/dist/index.mjs CHANGED
@@ -2553,15 +2553,30 @@ const SCREEN_SHARE_SIMULCAST_SETTINGS = {
2553
2553
  { scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
2554
2554
  ],
2555
2555
  };
2556
+ const ADDITIONAL_SCREEN_SHARE_SETTINGS = {
2557
+ encodings: [
2558
+ { scaleResolutionDownBy: 4, dtx: true, maxBitrate: 150000 },
2559
+ { scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
2560
+ { scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
2561
+ ],
2562
+ };
2563
+ const ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9 = {
2564
+ encodings: [{ scalabilityMode: "L2T2_KEY", dtx: true, maxBitrate: 1500000 }],
2565
+ };
2556
2566
  const SCREEN_SHARE_SETTINGS_VP9 = {
2557
2567
  encodings: [{ dtx: true }],
2558
2568
  };
2559
- const getMediaSettings = (kind, isScreenShare, features) => {
2569
+ const getMediaSettings = (kind, isScreenShare, features, isSomeoneAlreadyPresenting = false) => {
2560
2570
  const { lowDataModeEnabled, simulcastScreenshareOn, lowBandwidth, vp9On } = features;
2561
2571
  if (kind === "audio") {
2562
2572
  return AUDIO_SETTINGS;
2563
2573
  }
2564
2574
  if (isScreenShare) {
2575
+ if (isSomeoneAlreadyPresenting) {
2576
+ if (vp9On)
2577
+ return ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9;
2578
+ return ADDITIONAL_SCREEN_SHARE_SETTINGS;
2579
+ }
2565
2580
  if (lowBandwidth && !vp9On)
2566
2581
  return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
2567
2582
  if (vp9On)
@@ -5681,7 +5696,7 @@ class VegaRtcManager {
5681
5696
  this._screenVideoProducerPromise = null;
5682
5697
  return;
5683
5698
  }
5684
- const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }))), { appData: {
5699
+ const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }), this._getIsSomeoneAlreadyPresenting())), { appData: {
5685
5700
  streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
5686
5701
  sourceClientId: this._selfId,
5687
5702
  screenShare: true,
@@ -5821,6 +5836,9 @@ class VegaRtcManager {
5821
5836
  producer.appData.localClosed = true;
5822
5837
  producer.close();
5823
5838
  }
5839
+ _getIsSomeoneAlreadyPresenting() {
5840
+ return !![...this._clientStates.values()].find((state) => state.hasAcceptedScreenStream && state.screenStream);
5841
+ }
5824
5842
  isInitializedWith({ selfId, roomName, isSfu }) {
5825
5843
  return this._selfId === selfId && this._room.name === roomName && Boolean(isSfu);
5826
5844
  }
@@ -5850,8 +5868,8 @@ class VegaRtcManager {
5850
5868
  disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
5851
5869
  var _a;
5852
5870
  logger$3.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
5853
- if (this._clientStates.has(clientIdOrStreamId)) {
5854
- const clientState = this._clientStates.get(clientIdOrStreamId);
5871
+ const clientState = this._clientStates.get(clientIdOrStreamId);
5872
+ if (clientState) {
5855
5873
  clientState.hasAcceptedWebcamStream = false;
5856
5874
  clientState.hasAcceptedScreenStream = false;
5857
5875
  this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
@@ -6299,13 +6317,13 @@ class VegaRtcManager {
6299
6317
  this._streamIdToVideoConsumerId.delete(stream.id);
6300
6318
  this._streamIdToVideoResolution.delete(stream.id);
6301
6319
  if (screenShare) {
6302
- clientState.screenStream = null;
6320
+ clientState.screenStream = undefined;
6303
6321
  clientState.hasEmittedScreenStream = false;
6304
- clientState.screenShareStreamId = null;
6322
+ clientState.screenShareStreamId = undefined;
6305
6323
  }
6306
6324
  else {
6307
6325
  clientState.hasEmittedWebcamStream = false;
6308
- clientState.camStreamId = null;
6326
+ clientState.camStreamId = undefined;
6309
6327
  }
6310
6328
  }
6311
6329
  }
@@ -6371,10 +6389,6 @@ class VegaRtcManager {
6371
6389
  hasAcceptedScreenStream: false,
6372
6390
  hasEmittedWebcamStream: false,
6373
6391
  hasEmittedScreenStream: false,
6374
- webcamStream: null,
6375
- screenStream: null,
6376
- screenShareStreamId: null,
6377
- camStreamId: null,
6378
6392
  };
6379
6393
  this._clientStates.set(clientId, clientState);
6380
6394
  }
@@ -2553,15 +2553,30 @@ const SCREEN_SHARE_SIMULCAST_SETTINGS = {
2553
2553
  { scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
2554
2554
  ],
2555
2555
  };
2556
+ const ADDITIONAL_SCREEN_SHARE_SETTINGS = {
2557
+ encodings: [
2558
+ { scaleResolutionDownBy: 4, dtx: true, maxBitrate: 150000 },
2559
+ { scaleResolutionDownBy: 2, dtx: true, maxBitrate: 500000 },
2560
+ { scaleResolutionDownBy: 1, dtx: true, maxBitrate: 1500000 },
2561
+ ],
2562
+ };
2563
+ const ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9 = {
2564
+ encodings: [{ scalabilityMode: "L2T2_KEY", dtx: true, maxBitrate: 1500000 }],
2565
+ };
2556
2566
  const SCREEN_SHARE_SETTINGS_VP9 = {
2557
2567
  encodings: [{ dtx: true }],
2558
2568
  };
2559
- const getMediaSettings = (kind, isScreenShare, features) => {
2569
+ const getMediaSettings = (kind, isScreenShare, features, isSomeoneAlreadyPresenting = false) => {
2560
2570
  const { lowDataModeEnabled, simulcastScreenshareOn, lowBandwidth, vp9On } = features;
2561
2571
  if (kind === "audio") {
2562
2572
  return AUDIO_SETTINGS;
2563
2573
  }
2564
2574
  if (isScreenShare) {
2575
+ if (isSomeoneAlreadyPresenting) {
2576
+ if (vp9On)
2577
+ return ADDITIONAL_SCREEN_SHARE_SETTINGS_VP9;
2578
+ return ADDITIONAL_SCREEN_SHARE_SETTINGS;
2579
+ }
2565
2580
  if (lowBandwidth && !vp9On)
2566
2581
  return SCREEN_SHARE_SETTINGS_LOW_BANDWIDTH;
2567
2582
  if (vp9On)
@@ -5681,7 +5696,7 @@ class VegaRtcManager {
5681
5696
  this._screenVideoProducerPromise = null;
5682
5697
  return;
5683
5698
  }
5684
- const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }))), { appData: {
5699
+ const producer = yield this._sendTransport.produce(Object.assign(Object.assign({ track: this._screenVideoTrack, disableTrackOnPause: false, stopTracks: false }, getMediaSettings("video", true, Object.assign(Object.assign({}, this._features), { vp9On: this._features.sfuVp9On }), this._getIsSomeoneAlreadyPresenting())), { appData: {
5685
5700
  streamId: OUTBOUND_SCREEN_OUTBOUND_STREAM_ID,
5686
5701
  sourceClientId: this._selfId,
5687
5702
  screenShare: true,
@@ -5821,6 +5836,9 @@ class VegaRtcManager {
5821
5836
  producer.appData.localClosed = true;
5822
5837
  producer.close();
5823
5838
  }
5839
+ _getIsSomeoneAlreadyPresenting() {
5840
+ return !![...this._clientStates.values()].find((state) => state.hasAcceptedScreenStream && state.screenStream);
5841
+ }
5824
5842
  isInitializedWith({ selfId, roomName, isSfu }) {
5825
5843
  return this._selfId === selfId && this._room.name === roomName && Boolean(isSfu);
5826
5844
  }
@@ -5850,8 +5868,8 @@ class VegaRtcManager {
5850
5868
  disconnect(clientIdOrStreamId, _activeBreakout, eventClaim) {
5851
5869
  var _a;
5852
5870
  logger$3.info("disconnect() [clientIdOrStreamId:%s, eventClaim:%s]", clientIdOrStreamId, eventClaim);
5853
- if (this._clientStates.has(clientIdOrStreamId)) {
5854
- const clientState = this._clientStates.get(clientIdOrStreamId);
5871
+ const clientState = this._clientStates.get(clientIdOrStreamId);
5872
+ if (clientState) {
5855
5873
  clientState.hasAcceptedWebcamStream = false;
5856
5874
  clientState.hasAcceptedScreenStream = false;
5857
5875
  this._syncIncomingStreamsWithPWA(clientIdOrStreamId);
@@ -6299,13 +6317,13 @@ class VegaRtcManager {
6299
6317
  this._streamIdToVideoConsumerId.delete(stream.id);
6300
6318
  this._streamIdToVideoResolution.delete(stream.id);
6301
6319
  if (screenShare) {
6302
- clientState.screenStream = null;
6320
+ clientState.screenStream = undefined;
6303
6321
  clientState.hasEmittedScreenStream = false;
6304
- clientState.screenShareStreamId = null;
6322
+ clientState.screenShareStreamId = undefined;
6305
6323
  }
6306
6324
  else {
6307
6325
  clientState.hasEmittedWebcamStream = false;
6308
- clientState.camStreamId = null;
6326
+ clientState.camStreamId = undefined;
6309
6327
  }
6310
6328
  }
6311
6329
  }
@@ -6371,10 +6389,6 @@ class VegaRtcManager {
6371
6389
  hasAcceptedScreenStream: false,
6372
6390
  hasEmittedWebcamStream: false,
6373
6391
  hasEmittedScreenStream: false,
6374
- webcamStream: null,
6375
- screenStream: null,
6376
- screenShareStreamId: null,
6377
- camStreamId: null,
6378
6392
  };
6379
6393
  this._clientStates.set(clientId, clientState);
6380
6394
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whereby.com/media",
3
3
  "description": "Media library for Whereby",
4
- "version": "1.24.0",
4
+ "version": "1.25.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/whereby/sdk",
7
7
  "repository": {