@defcomm/meetingsdk 0.2.5 → 0.2.6

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
@@ -259,7 +259,6 @@ interface SFUClientOptions {
259
259
  onParticipantJoined?: (participant: ParticipantInfo) => void;
260
260
  onParticipantLeft?: (participant: string | ParticipantInfo) => void;
261
261
  onParticipantPresence?: (participantId: string, presence: string) => void;
262
- onParticipantMediaState?: (participantId: string, audioMuted: boolean, videoMuted: boolean) => void;
263
262
  onTrackPublished?: (track: TrackInfo) => void;
264
263
  onTrackUnpublished?: (track: TrackInfo) => void;
265
264
  onRemoteTrack?: (track: MediaStreamTrack, stream: MediaStream, metadata: TrackInfo) => void;
@@ -338,7 +337,6 @@ declare class SFUClient {
338
337
  private onParticipantJoined;
339
338
  private onParticipantLeft;
340
339
  private onParticipantPresence;
341
- private onParticipantMediaState;
342
340
  private onTrackPublished;
343
341
  private onTrackUnpublished;
344
342
  private onRemoteTrack;
@@ -354,7 +352,6 @@ declare class SFUClient {
354
352
  private onTrackStateChanged;
355
353
  private onRecordingStarted;
356
354
  private onRecordingStopped;
357
- private lastRecordingId;
358
355
  private onError;
359
356
  private autoSubscribe;
360
357
  constructor(options?: SFUClientOptions);
@@ -387,8 +384,6 @@ declare class SFUClient {
387
384
  displayName?: string;
388
385
  avatarUrl?: string;
389
386
  participantId?: string;
390
- audioMuted?: boolean;
391
- videoMuted?: boolean;
392
387
  }): Promise<void>;
393
388
  private refreshAccessToken;
394
389
  private connect;
@@ -397,7 +392,6 @@ declare class SFUClient {
397
392
  private failJoin;
398
393
  private resolveJoin;
399
394
  private handleServerMessage;
400
- private reconcileRoomState;
401
395
  private rememberTrack;
402
396
  private handleJoined;
403
397
  private initializePeerConnections;
package/dist/index.d.ts CHANGED
@@ -259,7 +259,6 @@ interface SFUClientOptions {
259
259
  onParticipantJoined?: (participant: ParticipantInfo) => void;
260
260
  onParticipantLeft?: (participant: string | ParticipantInfo) => void;
261
261
  onParticipantPresence?: (participantId: string, presence: string) => void;
262
- onParticipantMediaState?: (participantId: string, audioMuted: boolean, videoMuted: boolean) => void;
263
262
  onTrackPublished?: (track: TrackInfo) => void;
264
263
  onTrackUnpublished?: (track: TrackInfo) => void;
265
264
  onRemoteTrack?: (track: MediaStreamTrack, stream: MediaStream, metadata: TrackInfo) => void;
@@ -338,7 +337,6 @@ declare class SFUClient {
338
337
  private onParticipantJoined;
339
338
  private onParticipantLeft;
340
339
  private onParticipantPresence;
341
- private onParticipantMediaState;
342
340
  private onTrackPublished;
343
341
  private onTrackUnpublished;
344
342
  private onRemoteTrack;
@@ -354,7 +352,6 @@ declare class SFUClient {
354
352
  private onTrackStateChanged;
355
353
  private onRecordingStarted;
356
354
  private onRecordingStopped;
357
- private lastRecordingId;
358
355
  private onError;
359
356
  private autoSubscribe;
360
357
  constructor(options?: SFUClientOptions);
@@ -387,8 +384,6 @@ declare class SFUClient {
387
384
  displayName?: string;
388
385
  avatarUrl?: string;
389
386
  participantId?: string;
390
- audioMuted?: boolean;
391
- videoMuted?: boolean;
392
387
  }): Promise<void>;
393
388
  private refreshAccessToken;
394
389
  private connect;
@@ -397,7 +392,6 @@ declare class SFUClient {
397
392
  private failJoin;
398
393
  private resolveJoin;
399
394
  private handleServerMessage;
400
- private reconcileRoomState;
401
395
  private rememberTrack;
402
396
  private handleJoined;
403
397
  private initializePeerConnections;
package/dist/index.js CHANGED
@@ -428,7 +428,6 @@ var SFUClient = class {
428
428
  this.trackToSource = /* @__PURE__ */ new Map();
429
429
  this.localTrackIds = /* @__PURE__ */ new Map();
430
430
  this.subscriberStatsTimer = null;
431
- this.lastRecordingId = null;
432
431
  this.heartbeatTimer = null;
433
432
  this.apiBase = options.apiBase || "https://api.example.com/api";
434
433
  this.wsBase = options.wsBase || "wss://api.example.com/ws";
@@ -441,8 +440,6 @@ var SFUClient = class {
441
440
  });
442
441
  this.onParticipantPresence = options.onParticipantPresence || (() => {
443
442
  });
444
- this.onParticipantMediaState = options.onParticipantMediaState || (() => {
445
- });
446
443
  this.onTrackPublished = options.onTrackPublished || (() => {
447
444
  });
448
445
  this.onTrackUnpublished = options.onTrackUnpublished || (() => {
@@ -593,9 +590,7 @@ var SFUClient = class {
593
590
  this.room = nextRoom;
594
591
  this.joinOptions = {
595
592
  displayName: options.displayName,
596
- avatarUrl: options.avatarUrl,
597
- audioMuted: options.audioMuted,
598
- videoMuted: options.videoMuted
593
+ avatarUrl: options.avatarUrl
599
594
  };
600
595
  if (options.participantId) this.participantId = options.participantId;
601
596
  if (!this.resumeToken) {
@@ -664,9 +659,7 @@ var SFUClient = class {
664
659
  room_code: this.room,
665
660
  resume_token: this.resumeToken,
666
661
  display_name: options.displayName,
667
- avatar_url: options.avatarUrl,
668
- audio_muted: options.audioMuted ?? this.joinOptions.audioMuted ?? false,
669
- video_muted: options.videoMuted ?? this.joinOptions.videoMuted ?? false
662
+ avatar_url: options.avatarUrl
670
663
  };
671
664
  if (this.pendingJoinRequestId) {
672
665
  this.send({
@@ -780,9 +773,7 @@ var SFUClient = class {
780
773
  room_code: this.room,
781
774
  resume_token: this.resumeToken,
782
775
  display_name: this.joinOptions.displayName,
783
- avatar_url: this.joinOptions.avatarUrl,
784
- audio_muted: this.joinOptions.audioMuted ?? false,
785
- video_muted: this.joinOptions.videoMuted ?? false
776
+ avatar_url: this.joinOptions.avatarUrl
786
777
  }
787
778
  });
788
779
  }
@@ -923,7 +914,6 @@ var SFUClient = class {
923
914
  break;
924
915
  }
925
916
  case "recording_started": {
926
- this.lastRecordingId = payload.recording_id || this.lastRecordingId;
927
917
  this.onRecordingStarted({
928
918
  recording_id: payload.recording_id,
929
919
  started_at: payload.started_at
@@ -931,7 +921,6 @@ var SFUClient = class {
931
921
  break;
932
922
  }
933
923
  case "recording_stopped": {
934
- this.lastRecordingId = null;
935
924
  this.onRecordingStopped({
936
925
  recording_id: payload.recording_id,
937
926
  stopped_at: payload.stopped_at
@@ -967,29 +956,6 @@ var SFUClient = class {
967
956
  this.onScreenShareStopped(participantId, trackId);
968
957
  break;
969
958
  }
970
- case "room_state": {
971
- await this.reconcileRoomState(payload);
972
- break;
973
- }
974
- case "participant_media_state": {
975
- const participantId = payload.participant_id;
976
- if (participantId) {
977
- const current = this.participants.get(participantId);
978
- if (current) {
979
- this.participants.set(participantId, {
980
- ...current,
981
- audio_muted: Boolean(payload.audio_muted),
982
- video_muted: Boolean(payload.video_muted)
983
- });
984
- }
985
- }
986
- this.onParticipantMediaState?.(
987
- participantId,
988
- Boolean(payload.audio_muted),
989
- Boolean(payload.video_muted)
990
- );
991
- break;
992
- }
993
959
  case "error": {
994
960
  const message2 = payload.message || "SFU signaling error";
995
961
  if (this.state === "reconnecting" && message2.includes("participant session is stale")) {
@@ -1012,90 +978,6 @@ var SFUClient = class {
1012
978
  console.debug("[SFU] Ignoring unknown server message", message);
1013
979
  }
1014
980
  }
1015
- async reconcileRoomState(payload) {
1016
- const nextParticipants = /* @__PURE__ */ new Map();
1017
- for (const participant of payload.participants || []) {
1018
- if (participant?.participant_id) {
1019
- nextParticipants.set(participant.participant_id, participant);
1020
- }
1021
- }
1022
- for (const participantId of this.participants.keys()) {
1023
- if (participantId !== this.currentParticipantId && !nextParticipants.has(participantId)) {
1024
- this.participants.delete(participantId);
1025
- this.onParticipantLeft(participantId);
1026
- }
1027
- }
1028
- for (const participant of nextParticipants.values()) {
1029
- if (participant.participant_id === this.currentParticipantId) continue;
1030
- const previous = this.participants.get(participant.participant_id);
1031
- const wasScreenSharing = Boolean(previous?.screen_sharing);
1032
- const isScreenSharing = Boolean(participant.screen_sharing);
1033
- this.participants.set(participant.participant_id, participant);
1034
- if (!previous) {
1035
- this.onParticipantJoined(participant);
1036
- }
1037
- if (participant.presence) {
1038
- this.onParticipantPresence(
1039
- participant.participant_id,
1040
- String(participant.presence).toLowerCase()
1041
- );
1042
- }
1043
- this.onParticipantMediaState(
1044
- participant.participant_id,
1045
- Boolean(participant.audio_muted),
1046
- Boolean(participant.video_muted)
1047
- );
1048
- if (!wasScreenSharing && isScreenSharing) {
1049
- this.onScreenShareStarted(participant.participant_id, void 0);
1050
- } else if (wasScreenSharing && !isScreenSharing) {
1051
- this.onScreenShareStopped(
1052
- participant.participant_id,
1053
- participant.screen_track_id || void 0
1054
- );
1055
- }
1056
- }
1057
- const nextTracks = /* @__PURE__ */ new Map();
1058
- for (const track of payload.tracks || []) {
1059
- if (track?.track_id) {
1060
- nextTracks.set(track.track_id, track);
1061
- this.rememberTrack(track);
1062
- }
1063
- }
1064
- for (const [trackId, oldTrack] of [...this.trackMetadata.entries()]) {
1065
- if (!nextTracks.has(trackId)) {
1066
- this.trackMetadata.delete(trackId);
1067
- this.trackToParticipant.delete(trackId);
1068
- this.trackToSource.delete(trackId);
1069
- this.subscribedTracks.delete(trackId);
1070
- if (oldTrack.participant_id !== this.currentParticipantId) {
1071
- this.onTrackUnpublished(oldTrack);
1072
- }
1073
- }
1074
- }
1075
- if (this.autoSubscribe) {
1076
- const missing = [...nextTracks.values()].filter(
1077
- (track) => track.participant_id !== this.currentParticipantId && !this.subscribedTracks.has(track.track_id)
1078
- ).map((track) => track.track_id);
1079
- if (missing.length) await this.subscribeMultiple(missing);
1080
- }
1081
- const nextRecordingId = payload.recording?.recording_id || null;
1082
- if (payload.recording) {
1083
- if (this.lastRecordingId !== nextRecordingId) {
1084
- this.lastRecordingId = nextRecordingId;
1085
- this.onRecordingStarted({
1086
- recording_id: payload.recording.recording_id,
1087
- started_at: payload.recording.started_at
1088
- });
1089
- }
1090
- } else if (this.lastRecordingId) {
1091
- const recordingId = this.lastRecordingId;
1092
- this.lastRecordingId = null;
1093
- this.onRecordingStopped({
1094
- recording_id: recordingId,
1095
- stopped_at: (/* @__PURE__ */ new Date()).toISOString()
1096
- });
1097
- }
1098
- }
1099
981
  rememberTrack(track) {
1100
982
  this.trackMetadata.set(track.track_id, track);
1101
983
  this.trackToParticipant.set(track.track_id, track.participant_id);
@@ -1582,25 +1464,31 @@ var SFUClient = class {
1582
1464
  this.localStream?.getAudioTracks().forEach((track) => {
1583
1465
  track.enabled = !muted;
1584
1466
  });
1585
- this.send({
1586
- type: "set_media_state",
1587
- payload: {
1588
- audio_muted: muted,
1589
- video_muted: !(this.localStream?.getVideoTracks()[0]?.enabled ?? true)
1590
- }
1591
- });
1467
+ const trackId = this.localTrackIds.get("audio");
1468
+ if (trackId) {
1469
+ this.send({
1470
+ type: "track_state",
1471
+ payload: {
1472
+ track_id: trackId,
1473
+ muted
1474
+ }
1475
+ });
1476
+ }
1592
1477
  }
1593
1478
  muteVideo(muted) {
1594
1479
  this.localStream?.getVideoTracks().forEach((track) => {
1595
1480
  track.enabled = !muted;
1596
1481
  });
1597
- this.send({
1598
- type: "set_media_state",
1599
- payload: {
1600
- audio_muted: !(this.localStream?.getAudioTracks()[0]?.enabled ?? true),
1601
- video_muted: muted
1602
- }
1603
- });
1482
+ const trackId = this.localTrackIds.get("camera");
1483
+ if (trackId) {
1484
+ this.send({
1485
+ type: "track_state",
1486
+ payload: {
1487
+ track_id: trackId,
1488
+ muted
1489
+ }
1490
+ });
1491
+ }
1604
1492
  }
1605
1493
  async startRecording() {
1606
1494
  if (!this.send({ type: "start_recording" })) {
@@ -2059,11 +1947,7 @@ var VideoSDKCore = class {
2059
1947
  console.log(`[SFU] ${resumed ? "Resumed" : "Joined"} room`, payload);
2060
1948
  this.state.updateLocalParticipant({
2061
1949
  id: this.myId,
2062
- name: this.participantName,
2063
- media: {
2064
- micEnabled: this.localStream?.getAudioTracks()[0]?.enabled ?? true,
2065
- camEnabled: this.localStream?.getVideoTracks()[0]?.enabled ?? true
2066
- }
1950
+ name: this.participantName
2067
1951
  });
2068
1952
  },
2069
1953
  onDisconnected: () => {
@@ -2075,11 +1959,6 @@ var VideoSDKCore = class {
2075
1959
  // ADMISSION CONTROL
2076
1960
  onJoinPending: (info) => {
2077
1961
  console.log("[SFU] Join request pending", info);
2078
- this.events.onEntryRequested?.({
2079
- requestId: info.request_id,
2080
- participantId: this.myId,
2081
- name: this.participantName
2082
- });
2083
1962
  },
2084
1963
  onJoinApproved: (requestId) => {
2085
1964
  console.log("[SFU] Join approved", requestId);
@@ -2132,44 +2011,22 @@ var VideoSDKCore = class {
2132
2011
  return;
2133
2012
  }
2134
2013
  const pname = participant.user_metadata?.name || participant.display_name || "Participant";
2135
- const participantMedia = participant.media || {};
2136
- const participantState = {
2014
+ this.state.addParticipant({
2137
2015
  id: pid,
2138
2016
  name: pname,
2139
- connectionState: participant.presence === "reconnecting" ? "reconnecting" : "connected",
2017
+ connectionState: "connected",
2140
2018
  media: {
2141
- micEnabled: !Boolean(participant.audio_muted),
2142
- camEnabled: !Boolean(participant.video_muted),
2143
- isScreenSharing: Boolean(participant.screen_sharing),
2144
- screenStream: participantMedia.screenStream ?? null,
2019
+ micEnabled: true,
2020
+ camEnabled: true,
2021
+ isScreenSharing: false,
2145
2022
  stream: null
2146
2023
  }
2147
- };
2148
- if (!this.state.addParticipant(participantState)) {
2149
- this.state.updateParticipantMedia(pid, participantState.media);
2150
- }
2024
+ });
2151
2025
  this.events.onUserJoined?.({
2152
2026
  id: pid,
2153
2027
  name: pname
2154
2028
  });
2155
2029
  },
2156
- onParticipantMediaState: (participantId, audioMuted, videoMuted) => {
2157
- if (participantId === this.myId) {
2158
- this.state.updateLocalParticipant({
2159
- media: {
2160
- micEnabled: !audioMuted,
2161
- camEnabled: !videoMuted
2162
- }
2163
- });
2164
- return;
2165
- }
2166
- this.state.updateParticipantMedia(participantId, {
2167
- micEnabled: !audioMuted,
2168
- camEnabled: !videoMuted
2169
- });
2170
- this.events.onMuteStateChanged?.(participantId, "audio", audioMuted);
2171
- this.events.onMuteStateChanged?.(participantId, "video", videoMuted);
2172
- },
2173
2030
  onParticipantPresence: (participantId, presence) => {
2174
2031
  if (participantId === this.myId) {
2175
2032
  return;
@@ -2333,9 +2190,7 @@ var VideoSDKCore = class {
2333
2190
  client.setLocalStream(this.localStream);
2334
2191
  await client.getToken(roomId, {
2335
2192
  displayName: name,
2336
- participantId: this.myId,
2337
- audioMuted: !this.localStream?.getAudioTracks()[0]?.enabled,
2338
- videoMuted: !this.localStream?.getVideoTracks()[0]?.enabled
2193
+ participantId: this.myId
2339
2194
  });
2340
2195
  }
2341
2196
  // SFU STATE
@@ -2499,7 +2354,6 @@ var VideoSDKCore = class {
2499
2354
  screenTrack: this.screenStream.getVideoTracks()[0]
2500
2355
  }
2501
2356
  });
2502
- this.state.setPresenterId(this.myId);
2503
2357
  return this.screenStream;
2504
2358
  } catch (err) {
2505
2359
  this.emitError(
@@ -2521,9 +2375,6 @@ var VideoSDKCore = class {
2521
2375
  this.screenStream.getTracks().forEach((track) => track.stop());
2522
2376
  this.screenStream = null;
2523
2377
  this.isScreenSharing = false;
2524
- if (this.state.presenterId === this.myId) {
2525
- this.state.setPresenterId(null);
2526
- }
2527
2378
  this.state.updateLocalParticipant({
2528
2379
  media: {
2529
2380
  isScreenSharing: false,