@defcomm/meetingsdk 0.3.2 → 0.3.4

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,28 @@ 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?.(
2385
+ participantId,
2386
+ existingRemoteScreen
2387
+ );
2388
+ return;
2389
+ }
2383
2390
  const current = this.state.getParticipant(participantId);
2384
2391
  if (current) {
2385
2392
  this.state.updateParticipantMedia(participantId, {
2386
2393
  isScreenSharing: true,
2387
- screenStream: current.media?.screenStream ?? null
2394
+ screenStream: current.media?.screenStream ?? null,
2395
+ screenTrack: current.media?.screenTrack
2388
2396
  });
2389
2397
  }
2390
2398
  },
@@ -2402,13 +2410,8 @@ var VideoSDKCore = class {
2402
2410
  });
2403
2411
  return;
2404
2412
  }
2405
- const screen = this.remoteScreenStreams.get(participantId);
2406
- screen?.getTracks().forEach((track) => track.stop());
2407
- this.remoteScreenStreams.delete(participantId);
2408
2413
  this.state.updateParticipantMedia(participantId, {
2409
- isScreenSharing: false,
2410
- screenStream: null,
2411
- screenTrack: void 0
2414
+ isScreenSharing: false
2412
2415
  });
2413
2416
  this.events.onScreenShareStopped?.(participantId);
2414
2417
  },
@@ -2432,8 +2435,8 @@ var VideoSDKCore = class {
2432
2435
  await client.getToken(roomId, {
2433
2436
  displayName: name,
2434
2437
  participantId: this.myId,
2435
- audioMuted: this.state.localParticipant?.media?.micEnabled,
2436
- videoMuted: this.state.localParticipant?.media?.camEnabled
2438
+ audioMuted: !(this.localStream?.getAudioTracks()[0]?.enabled ?? true),
2439
+ videoMuted: !(this.localStream?.getVideoTracks()[0]?.enabled ?? true)
2437
2440
  });
2438
2441
  }
2439
2442
  // SFU STATE