@defcomm/meetingsdk 0.3.2 → 0.3.3

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.d.mts CHANGED
@@ -392,6 +392,7 @@ declare class SFUClient {
392
392
  getResumeToken(): string | null;
393
393
  getLocalStream(): MediaStream | null;
394
394
  getScreenStream(): MediaStream | null;
395
+ getRemoteScreenStream(participantId: string): MediaStream | null;
395
396
  setLocalStream(stream: MediaStream | null): void;
396
397
  private nextRequestId;
397
398
  private request;
package/dist/index.d.ts CHANGED
@@ -392,6 +392,7 @@ declare class SFUClient {
392
392
  getResumeToken(): string | null;
393
393
  getLocalStream(): MediaStream | null;
394
394
  getScreenStream(): MediaStream | null;
395
+ getRemoteScreenStream(participantId: string): MediaStream | null;
395
396
  setLocalStream(stream: MediaStream | null): void;
396
397
  private nextRequestId;
397
398
  private request;
package/dist/index.js CHANGED
@@ -548,6 +548,9 @@ var SFUClient = class {
548
548
  getScreenStream() {
549
549
  return this.screenStream;
550
550
  }
551
+ getRemoteScreenStream(participantId) {
552
+ return this.remoteScreenStreams.get(participantId) || null;
553
+ }
551
554
  setLocalStream(stream) {
552
555
  this.localStream = stream;
553
556
  }
@@ -967,19 +970,7 @@ var SFUClient = class {
967
970
  }
968
971
  case "screen_share_stopped": {
969
972
  const participantId = payload.participant_id;
970
- const screenStream = participantId ? this.remoteScreenStreams.get(participantId) : null;
971
973
  const trackId = payload.track_id;
972
- if (screenStream) {
973
- for (const track of screenStream.getVideoTracks()) {
974
- if (!trackId || this.normalizeRemoteTrackId(track.id) === String(trackId)) {
975
- screenStream.removeTrack(track);
976
- track.stop();
977
- }
978
- }
979
- if (screenStream.getTracks().length === 0 && participantId) {
980
- this.remoteScreenStreams.delete(participantId);
981
- }
982
- }
983
974
  this.onScreenShareStopped(participantId, trackId);
984
975
  break;
985
976
  }
@@ -2366,11 +2357,11 @@ var VideoSDKCore = class {
2366
2357
  // SCREEN SHARE
2367
2358
  onScreenShareStarted: (participantId, _track) => {
2368
2359
  console.log("[SFU] Screen share started", participantId);
2369
- if (participantId === this.myId && !this.screenStream) {
2370
- this.screenStream = this.sfuClient?.getScreenStream() ?? null;
2371
- }
2372
- this.state.setPresenterId(participantId);
2373
2360
  if (participantId === this.myId) {
2361
+ if (!this.screenStream) {
2362
+ this.screenStream = this.sfuClient?.getScreenStream() ?? null;
2363
+ }
2364
+ this.state.setPresenterId(participantId);
2374
2365
  this.state.updateLocalParticipant({
2375
2366
  media: {
2376
2367
  isScreenSharing: true,
@@ -2380,11 +2371,25 @@ var VideoSDKCore = class {
2380
2371
  });
2381
2372
  return;
2382
2373
  }
2374
+ this.state.setPresenterId(participantId);
2375
+ const existingRemoteScreen = this.sfuClient?.getRemoteScreenStream(participantId) ?? this.remoteScreenStreams.get(participantId) ?? null;
2376
+ if (existingRemoteScreen) {
2377
+ this.remoteScreenStreams.set(participantId, existingRemoteScreen);
2378
+ const screenTrack = existingRemoteScreen.getVideoTracks()[0];
2379
+ this.state.updateParticipantMedia(participantId, {
2380
+ isScreenSharing: true,
2381
+ screenStream: existingRemoteScreen,
2382
+ screenTrack
2383
+ });
2384
+ this.events.onScreenShareStarted?.(participantId, existingRemoteScreen);
2385
+ return;
2386
+ }
2383
2387
  const current = this.state.getParticipant(participantId);
2384
2388
  if (current) {
2385
2389
  this.state.updateParticipantMedia(participantId, {
2386
2390
  isScreenSharing: true,
2387
- screenStream: current.media?.screenStream ?? null
2391
+ screenStream: current.media?.screenStream ?? null,
2392
+ screenTrack: current.media?.screenTrack
2388
2393
  });
2389
2394
  }
2390
2395
  },
@@ -2402,13 +2407,8 @@ var VideoSDKCore = class {
2402
2407
  });
2403
2408
  return;
2404
2409
  }
2405
- const screen = this.remoteScreenStreams.get(participantId);
2406
- screen?.getTracks().forEach((track) => track.stop());
2407
- this.remoteScreenStreams.delete(participantId);
2408
2410
  this.state.updateParticipantMedia(participantId, {
2409
- isScreenSharing: false,
2410
- screenStream: null,
2411
- screenTrack: void 0
2411
+ isScreenSharing: false
2412
2412
  });
2413
2413
  this.events.onScreenShareStopped?.(participantId);
2414
2414
  },