@defcomm/meetingsdk 0.2.4 → 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 +0 -18
- package/dist/index.d.ts +0 -18
- package/dist/index.js +29 -244
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -244
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -272,7 +272,6 @@ interface SFUClientOptions {
|
|
|
272
272
|
onScreenShareStarted?: (participantId: string, track?: TrackInfo) => void;
|
|
273
273
|
onScreenShareStopped?: (participantId: string, trackId?: string) => void;
|
|
274
274
|
onTrackStateChanged?: (track: TrackInfo) => void;
|
|
275
|
-
onParticipantMediaState?: (participantId: string, audioMuted: boolean, videoMuted: boolean) => void;
|
|
276
275
|
onRecordingStarted?: (recording: {
|
|
277
276
|
recording_id: string;
|
|
278
277
|
started_at: string;
|
|
@@ -281,8 +280,6 @@ interface SFUClientOptions {
|
|
|
281
280
|
recording_id: string;
|
|
282
281
|
stopped_at: string;
|
|
283
282
|
}) => void;
|
|
284
|
-
/** Authoritative room snapshot received after join/reconnect/resync. */
|
|
285
|
-
onRoomState?: (state: any) => void;
|
|
286
283
|
onError?: (error: any) => void;
|
|
287
284
|
autoSubscribe?: boolean;
|
|
288
285
|
}
|
|
@@ -296,9 +293,6 @@ declare class SFUClient {
|
|
|
296
293
|
private localStream;
|
|
297
294
|
private screenStream;
|
|
298
295
|
private videoSender;
|
|
299
|
-
private audioMuted;
|
|
300
|
-
private videoMuted;
|
|
301
|
-
private activeRecording;
|
|
302
296
|
private audioSender;
|
|
303
297
|
private screenSender;
|
|
304
298
|
private audioTransceiver;
|
|
@@ -339,8 +333,6 @@ declare class SFUClient {
|
|
|
339
333
|
private trackToSource;
|
|
340
334
|
private localTrackIds;
|
|
341
335
|
private subscriberStatsTimer;
|
|
342
|
-
private roomSyncTimer;
|
|
343
|
-
private roomSyncInFlight;
|
|
344
336
|
private onStateChange;
|
|
345
337
|
private onParticipantJoined;
|
|
346
338
|
private onParticipantLeft;
|
|
@@ -358,19 +350,14 @@ declare class SFUClient {
|
|
|
358
350
|
private onScreenShareStarted;
|
|
359
351
|
private onScreenShareStopped;
|
|
360
352
|
private onTrackStateChanged;
|
|
361
|
-
private onParticipantMediaState;
|
|
362
353
|
private onRecordingStarted;
|
|
363
354
|
private onRecordingStopped;
|
|
364
|
-
private onRoomState;
|
|
365
355
|
private onError;
|
|
366
356
|
private autoSubscribe;
|
|
367
357
|
constructor(options?: SFUClientOptions);
|
|
368
358
|
private heartbeatTimer;
|
|
369
359
|
private startHeartbeat;
|
|
370
360
|
private stopHeartbeat;
|
|
371
|
-
private startRoomStateSync;
|
|
372
|
-
private stopRoomStateSync;
|
|
373
|
-
private syncRoomState;
|
|
374
361
|
private createId;
|
|
375
362
|
private resumeStorageKey;
|
|
376
363
|
private loadResumeToken;
|
|
@@ -397,8 +384,6 @@ declare class SFUClient {
|
|
|
397
384
|
displayName?: string;
|
|
398
385
|
avatarUrl?: string;
|
|
399
386
|
participantId?: string;
|
|
400
|
-
audioMuted?: boolean;
|
|
401
|
-
videoMuted?: boolean;
|
|
402
387
|
}): Promise<void>;
|
|
403
388
|
private refreshAccessToken;
|
|
404
389
|
private connect;
|
|
@@ -407,7 +392,6 @@ declare class SFUClient {
|
|
|
407
392
|
private failJoin;
|
|
408
393
|
private resolveJoin;
|
|
409
394
|
private handleServerMessage;
|
|
410
|
-
private applyRoomState;
|
|
411
395
|
private rememberTrack;
|
|
412
396
|
private handleJoined;
|
|
413
397
|
private initializePeerConnections;
|
|
@@ -485,7 +469,6 @@ type MeetingContextValue = {
|
|
|
485
469
|
onEntryRequested: (cb: (req: any) => void) => () => void;
|
|
486
470
|
onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
|
|
487
471
|
onMeetingLeft: (cb: () => void) => () => void;
|
|
488
|
-
onRoomUpdate: (cb: (data: any) => void) => () => void;
|
|
489
472
|
onTrackStateChanged: (cb: (track: any) => void) => () => void;
|
|
490
473
|
onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
|
|
491
474
|
onRecordingStopped: (cb: (recording: any) => void) => () => void;
|
|
@@ -544,7 +527,6 @@ declare const useMeeting: (handlers?: {
|
|
|
544
527
|
onEntryRequested: (cb: (req: any) => void) => () => void;
|
|
545
528
|
onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
|
|
546
529
|
onMeetingLeft: (cb: () => void) => () => void;
|
|
547
|
-
onRoomUpdate: (cb: (data: any) => void) => () => void;
|
|
548
530
|
onTrackStateChanged: (cb: (track: any) => void) => () => void;
|
|
549
531
|
onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
|
|
550
532
|
onRecordingStopped: (cb: (recording: any) => void) => () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -272,7 +272,6 @@ interface SFUClientOptions {
|
|
|
272
272
|
onScreenShareStarted?: (participantId: string, track?: TrackInfo) => void;
|
|
273
273
|
onScreenShareStopped?: (participantId: string, trackId?: string) => void;
|
|
274
274
|
onTrackStateChanged?: (track: TrackInfo) => void;
|
|
275
|
-
onParticipantMediaState?: (participantId: string, audioMuted: boolean, videoMuted: boolean) => void;
|
|
276
275
|
onRecordingStarted?: (recording: {
|
|
277
276
|
recording_id: string;
|
|
278
277
|
started_at: string;
|
|
@@ -281,8 +280,6 @@ interface SFUClientOptions {
|
|
|
281
280
|
recording_id: string;
|
|
282
281
|
stopped_at: string;
|
|
283
282
|
}) => void;
|
|
284
|
-
/** Authoritative room snapshot received after join/reconnect/resync. */
|
|
285
|
-
onRoomState?: (state: any) => void;
|
|
286
283
|
onError?: (error: any) => void;
|
|
287
284
|
autoSubscribe?: boolean;
|
|
288
285
|
}
|
|
@@ -296,9 +293,6 @@ declare class SFUClient {
|
|
|
296
293
|
private localStream;
|
|
297
294
|
private screenStream;
|
|
298
295
|
private videoSender;
|
|
299
|
-
private audioMuted;
|
|
300
|
-
private videoMuted;
|
|
301
|
-
private activeRecording;
|
|
302
296
|
private audioSender;
|
|
303
297
|
private screenSender;
|
|
304
298
|
private audioTransceiver;
|
|
@@ -339,8 +333,6 @@ declare class SFUClient {
|
|
|
339
333
|
private trackToSource;
|
|
340
334
|
private localTrackIds;
|
|
341
335
|
private subscriberStatsTimer;
|
|
342
|
-
private roomSyncTimer;
|
|
343
|
-
private roomSyncInFlight;
|
|
344
336
|
private onStateChange;
|
|
345
337
|
private onParticipantJoined;
|
|
346
338
|
private onParticipantLeft;
|
|
@@ -358,19 +350,14 @@ declare class SFUClient {
|
|
|
358
350
|
private onScreenShareStarted;
|
|
359
351
|
private onScreenShareStopped;
|
|
360
352
|
private onTrackStateChanged;
|
|
361
|
-
private onParticipantMediaState;
|
|
362
353
|
private onRecordingStarted;
|
|
363
354
|
private onRecordingStopped;
|
|
364
|
-
private onRoomState;
|
|
365
355
|
private onError;
|
|
366
356
|
private autoSubscribe;
|
|
367
357
|
constructor(options?: SFUClientOptions);
|
|
368
358
|
private heartbeatTimer;
|
|
369
359
|
private startHeartbeat;
|
|
370
360
|
private stopHeartbeat;
|
|
371
|
-
private startRoomStateSync;
|
|
372
|
-
private stopRoomStateSync;
|
|
373
|
-
private syncRoomState;
|
|
374
361
|
private createId;
|
|
375
362
|
private resumeStorageKey;
|
|
376
363
|
private loadResumeToken;
|
|
@@ -397,8 +384,6 @@ declare class SFUClient {
|
|
|
397
384
|
displayName?: string;
|
|
398
385
|
avatarUrl?: string;
|
|
399
386
|
participantId?: string;
|
|
400
|
-
audioMuted?: boolean;
|
|
401
|
-
videoMuted?: boolean;
|
|
402
387
|
}): Promise<void>;
|
|
403
388
|
private refreshAccessToken;
|
|
404
389
|
private connect;
|
|
@@ -407,7 +392,6 @@ declare class SFUClient {
|
|
|
407
392
|
private failJoin;
|
|
408
393
|
private resolveJoin;
|
|
409
394
|
private handleServerMessage;
|
|
410
|
-
private applyRoomState;
|
|
411
395
|
private rememberTrack;
|
|
412
396
|
private handleJoined;
|
|
413
397
|
private initializePeerConnections;
|
|
@@ -485,7 +469,6 @@ type MeetingContextValue = {
|
|
|
485
469
|
onEntryRequested: (cb: (req: any) => void) => () => void;
|
|
486
470
|
onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
|
|
487
471
|
onMeetingLeft: (cb: () => void) => () => void;
|
|
488
|
-
onRoomUpdate: (cb: (data: any) => void) => () => void;
|
|
489
472
|
onTrackStateChanged: (cb: (track: any) => void) => () => void;
|
|
490
473
|
onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
|
|
491
474
|
onRecordingStopped: (cb: (recording: any) => void) => () => void;
|
|
@@ -544,7 +527,6 @@ declare const useMeeting: (handlers?: {
|
|
|
544
527
|
onEntryRequested: (cb: (req: any) => void) => () => void;
|
|
545
528
|
onEntryResponded: (cb: (payload: any, decision?: any) => void) => () => void;
|
|
546
529
|
onMeetingLeft: (cb: () => void) => () => void;
|
|
547
|
-
onRoomUpdate: (cb: (data: any) => void) => () => void;
|
|
548
530
|
onTrackStateChanged: (cb: (track: any) => void) => () => void;
|
|
549
531
|
onRecordingStarted: (cb: (recording: Recording) => void) => () => void;
|
|
550
532
|
onRecordingStopped: (cb: (recording: any) => void) => () => void;
|
package/dist/index.js
CHANGED
|
@@ -385,9 +385,6 @@ var SFUClient = class {
|
|
|
385
385
|
this.localStream = null;
|
|
386
386
|
this.screenStream = null;
|
|
387
387
|
this.videoSender = null;
|
|
388
|
-
this.audioMuted = false;
|
|
389
|
-
this.videoMuted = false;
|
|
390
|
-
this.activeRecording = null;
|
|
391
388
|
this.audioSender = null;
|
|
392
389
|
this.screenSender = null;
|
|
393
390
|
this.audioTransceiver = null;
|
|
@@ -408,7 +405,7 @@ var SFUClient = class {
|
|
|
408
405
|
this.joiningWithResume = false;
|
|
409
406
|
this.reconnectTimer = null;
|
|
410
407
|
this.reconnectAttempt = 0;
|
|
411
|
-
this.maxReconnectAttempts =
|
|
408
|
+
this.maxReconnectAttempts = 8;
|
|
412
409
|
this.reconnectBaseMs = 750;
|
|
413
410
|
this.joinWaiter = null;
|
|
414
411
|
this.transportRecoveryInProgress = false;
|
|
@@ -431,8 +428,6 @@ var SFUClient = class {
|
|
|
431
428
|
this.trackToSource = /* @__PURE__ */ new Map();
|
|
432
429
|
this.localTrackIds = /* @__PURE__ */ new Map();
|
|
433
430
|
this.subscriberStatsTimer = null;
|
|
434
|
-
this.roomSyncTimer = null;
|
|
435
|
-
this.roomSyncInFlight = false;
|
|
436
431
|
this.heartbeatTimer = null;
|
|
437
432
|
this.apiBase = options.apiBase || "https://api.example.com/api";
|
|
438
433
|
this.wsBase = options.wsBase || "wss://api.example.com/ws";
|
|
@@ -471,14 +466,10 @@ var SFUClient = class {
|
|
|
471
466
|
});
|
|
472
467
|
this.onTrackStateChanged = options.onTrackStateChanged || (() => {
|
|
473
468
|
});
|
|
474
|
-
this.onParticipantMediaState = options.onParticipantMediaState || (() => {
|
|
475
|
-
});
|
|
476
469
|
this.onRecordingStarted = options.onRecordingStarted || (() => {
|
|
477
470
|
});
|
|
478
471
|
this.onRecordingStopped = options.onRecordingStopped || (() => {
|
|
479
472
|
});
|
|
480
|
-
this.onRoomState = options.onRoomState || (() => {
|
|
481
|
-
});
|
|
482
473
|
this.onError = options.onError || console.error;
|
|
483
474
|
this.autoSubscribe = options.autoSubscribe !== false;
|
|
484
475
|
}
|
|
@@ -500,29 +491,6 @@ var SFUClient = class {
|
|
|
500
491
|
this.heartbeatTimer = null;
|
|
501
492
|
}
|
|
502
493
|
}
|
|
503
|
-
startRoomStateSync() {
|
|
504
|
-
this.stopRoomStateSync();
|
|
505
|
-
this.roomSyncTimer = setInterval(() => {
|
|
506
|
-
if (this.state !== "connected") return;
|
|
507
|
-
void this.syncRoomState();
|
|
508
|
-
}, 5e3);
|
|
509
|
-
}
|
|
510
|
-
stopRoomStateSync() {
|
|
511
|
-
if (this.roomSyncTimer) {
|
|
512
|
-
clearInterval(this.roomSyncTimer);
|
|
513
|
-
this.roomSyncTimer = null;
|
|
514
|
-
}
|
|
515
|
-
this.roomSyncInFlight = false;
|
|
516
|
-
}
|
|
517
|
-
async syncRoomState() {
|
|
518
|
-
if (this.roomSyncInFlight || !this.isSocketOpen()) return;
|
|
519
|
-
this.roomSyncInFlight = true;
|
|
520
|
-
try {
|
|
521
|
-
this.send({ type: "sync_room_state" });
|
|
522
|
-
} finally {
|
|
523
|
-
this.roomSyncInFlight = false;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
494
|
createId() {
|
|
527
495
|
return typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : `id_${Math.random().toString(36).slice(2)}_${Date.now()}`;
|
|
528
496
|
}
|
|
@@ -620,13 +588,9 @@ var SFUClient = class {
|
|
|
620
588
|
this.resumeToken = null;
|
|
621
589
|
}
|
|
622
590
|
this.room = nextRoom;
|
|
623
|
-
this.audioMuted = Boolean(options.audioMuted);
|
|
624
|
-
this.videoMuted = Boolean(options.videoMuted);
|
|
625
591
|
this.joinOptions = {
|
|
626
592
|
displayName: options.displayName,
|
|
627
|
-
avatarUrl: options.avatarUrl
|
|
628
|
-
audioMuted: this.audioMuted,
|
|
629
|
-
videoMuted: this.videoMuted
|
|
593
|
+
avatarUrl: options.avatarUrl
|
|
630
594
|
};
|
|
631
595
|
if (options.participantId) this.participantId = options.participantId;
|
|
632
596
|
if (!this.resumeToken) {
|
|
@@ -695,9 +659,7 @@ var SFUClient = class {
|
|
|
695
659
|
room_code: this.room,
|
|
696
660
|
resume_token: this.resumeToken,
|
|
697
661
|
display_name: options.displayName,
|
|
698
|
-
avatar_url: options.avatarUrl
|
|
699
|
-
audio_muted: this.audioMuted,
|
|
700
|
-
video_muted: this.videoMuted
|
|
662
|
+
avatar_url: options.avatarUrl
|
|
701
663
|
};
|
|
702
664
|
if (this.pendingJoinRequestId) {
|
|
703
665
|
this.send({
|
|
@@ -738,20 +700,8 @@ var SFUClient = class {
|
|
|
738
700
|
scheduleReconnect() {
|
|
739
701
|
if (this.reconnectTimer || this.intentionalClose) return;
|
|
740
702
|
if (this.reconnectAttempt >= this.maxReconnectAttempts) {
|
|
741
|
-
const error = new Error("SFU reconnect attempts exhausted");
|
|
742
|
-
console.error("[SFU] Reconnect attempts exhausted; leaving meeting", error);
|
|
743
|
-
this.intentionalClose = true;
|
|
744
|
-
this.stopHeartbeat();
|
|
745
|
-
this.stopRoomStateSync();
|
|
746
|
-
this.cleanupAll();
|
|
747
703
|
this.setState("disconnected");
|
|
748
|
-
this.
|
|
749
|
-
code: "RECONNECT_TIMEOUT",
|
|
750
|
-
message: error.message,
|
|
751
|
-
recoverable: false
|
|
752
|
-
});
|
|
753
|
-
this.onDisconnected();
|
|
754
|
-
this.failJoin(error);
|
|
704
|
+
this.failJoin(new Error("SFU reconnect attempts exhausted"));
|
|
755
705
|
return;
|
|
756
706
|
}
|
|
757
707
|
this.reconnectAttempt += 1;
|
|
@@ -823,9 +773,7 @@ var SFUClient = class {
|
|
|
823
773
|
room_code: this.room,
|
|
824
774
|
resume_token: this.resumeToken,
|
|
825
775
|
display_name: this.joinOptions.displayName,
|
|
826
|
-
avatar_url: this.joinOptions.avatarUrl
|
|
827
|
-
audio_muted: this.audioMuted,
|
|
828
|
-
video_muted: this.videoMuted
|
|
776
|
+
avatar_url: this.joinOptions.avatarUrl
|
|
829
777
|
}
|
|
830
778
|
});
|
|
831
779
|
}
|
|
@@ -900,8 +848,22 @@ var SFUClient = class {
|
|
|
900
848
|
if (!track?.track_id) break;
|
|
901
849
|
this.rememberTrack(track);
|
|
902
850
|
if (track.participant_id === this.currentParticipantId) {
|
|
903
|
-
if (track.source === "audio")
|
|
904
|
-
|
|
851
|
+
if (track.source === "audio") {
|
|
852
|
+
this.localTrackIds.set("audio", track.track_id);
|
|
853
|
+
const muted = !(this.localStream?.getAudioTracks()[0]?.enabled ?? true);
|
|
854
|
+
this.send({
|
|
855
|
+
type: "track_state",
|
|
856
|
+
payload: { track_id: track.track_id, muted }
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
if (track.source === "camera") {
|
|
860
|
+
this.localTrackIds.set("camera", track.track_id);
|
|
861
|
+
const muted = !(this.localStream?.getVideoTracks()[0]?.enabled ?? true);
|
|
862
|
+
this.send({
|
|
863
|
+
type: "track_state",
|
|
864
|
+
payload: { track_id: track.track_id, muted }
|
|
865
|
+
});
|
|
866
|
+
}
|
|
905
867
|
if (track.source === "screen")
|
|
906
868
|
this.localTrackIds.set("screen", track.track_id);
|
|
907
869
|
break;
|
|
@@ -930,27 +892,6 @@ var SFUClient = class {
|
|
|
930
892
|
this.onTrackUnpublished(track);
|
|
931
893
|
break;
|
|
932
894
|
}
|
|
933
|
-
case "participant_media_state": {
|
|
934
|
-
const participantId = payload.participant_id;
|
|
935
|
-
if (!participantId) break;
|
|
936
|
-
const participant = this.participants.get(participantId);
|
|
937
|
-
if (participant) {
|
|
938
|
-
participant.audio_muted = Boolean(payload.audio_muted);
|
|
939
|
-
participant.video_muted = Boolean(payload.video_muted);
|
|
940
|
-
this.participants.set(participantId, participant);
|
|
941
|
-
}
|
|
942
|
-
for (const track of this.trackMetadata.values()) {
|
|
943
|
-
if (track.participant_id !== participantId) continue;
|
|
944
|
-
if (track.source === "audio") track.muted = Boolean(payload.audio_muted);
|
|
945
|
-
if (track.source === "camera") track.muted = Boolean(payload.video_muted);
|
|
946
|
-
}
|
|
947
|
-
this.onParticipantMediaState(
|
|
948
|
-
participantId,
|
|
949
|
-
Boolean(payload.audio_muted),
|
|
950
|
-
Boolean(payload.video_muted)
|
|
951
|
-
);
|
|
952
|
-
break;
|
|
953
|
-
}
|
|
954
895
|
case "track_state_changed": {
|
|
955
896
|
const trackId = payload.track_id || payload.track?.track_id;
|
|
956
897
|
if (!trackId) break;
|
|
@@ -972,20 +913,14 @@ var SFUClient = class {
|
|
|
972
913
|
case "subscription_updated": {
|
|
973
914
|
break;
|
|
974
915
|
}
|
|
975
|
-
case "room_state": {
|
|
976
|
-
await this.applyRoomState(payload);
|
|
977
|
-
break;
|
|
978
|
-
}
|
|
979
916
|
case "recording_started": {
|
|
980
|
-
this.
|
|
917
|
+
this.onRecordingStarted({
|
|
981
918
|
recording_id: payload.recording_id,
|
|
982
919
|
started_at: payload.started_at
|
|
983
|
-
};
|
|
984
|
-
this.onRecordingStarted(this.activeRecording);
|
|
920
|
+
});
|
|
985
921
|
break;
|
|
986
922
|
}
|
|
987
923
|
case "recording_stopped": {
|
|
988
|
-
this.activeRecording = null;
|
|
989
924
|
this.onRecordingStopped({
|
|
990
925
|
recording_id: payload.recording_id,
|
|
991
926
|
stopped_at: payload.stopped_at
|
|
@@ -1043,67 +978,6 @@ var SFUClient = class {
|
|
|
1043
978
|
console.debug("[SFU] Ignoring unknown server message", message);
|
|
1044
979
|
}
|
|
1045
980
|
}
|
|
1046
|
-
async applyRoomState(payload) {
|
|
1047
|
-
const authoritative = /* @__PURE__ */ new Map();
|
|
1048
|
-
for (const participant of payload?.participants || []) {
|
|
1049
|
-
if (participant?.participant_id) authoritative.set(participant.participant_id, participant);
|
|
1050
|
-
}
|
|
1051
|
-
for (const id of [...this.participants.keys()]) {
|
|
1052
|
-
if (!authoritative.has(id) && id !== this.currentParticipantId) {
|
|
1053
|
-
this.participants.delete(id);
|
|
1054
|
-
this.removeRemoteParticipant(id);
|
|
1055
|
-
this.onParticipantLeft(id);
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
for (const [id, participant] of authoritative) {
|
|
1059
|
-
if (id === this.currentParticipantId) continue;
|
|
1060
|
-
const previous = this.participants.get(id);
|
|
1061
|
-
this.participants.set(id, {
|
|
1062
|
-
...previous,
|
|
1063
|
-
...participant,
|
|
1064
|
-
audio_muted: Boolean(participant.audio_muted),
|
|
1065
|
-
video_muted: Boolean(participant.video_muted)
|
|
1066
|
-
});
|
|
1067
|
-
if (!previous) this.onParticipantJoined(participant);
|
|
1068
|
-
if (participant.presence) this.onParticipantPresence(id, String(participant.presence));
|
|
1069
|
-
}
|
|
1070
|
-
const nextTracks = /* @__PURE__ */ new Map();
|
|
1071
|
-
for (const track of payload?.tracks || []) {
|
|
1072
|
-
if (!track?.track_id) continue;
|
|
1073
|
-
nextTracks.set(track.track_id, track);
|
|
1074
|
-
this.rememberTrack(track);
|
|
1075
|
-
}
|
|
1076
|
-
for (const id of [...this.trackMetadata.keys()]) {
|
|
1077
|
-
if (!nextTracks.has(id)) {
|
|
1078
|
-
this.trackMetadata.delete(id);
|
|
1079
|
-
this.subscribedTracks.delete(id);
|
|
1080
|
-
this.trackToParticipant.delete(id);
|
|
1081
|
-
this.trackToSource.delete(id);
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
if (payload?.recording) {
|
|
1085
|
-
const current = {
|
|
1086
|
-
recording_id: payload.recording.recording_id,
|
|
1087
|
-
started_at: payload.recording.started_at
|
|
1088
|
-
};
|
|
1089
|
-
if (!this.activeRecording || this.activeRecording.recording_id !== current.recording_id) {
|
|
1090
|
-
this.activeRecording = current;
|
|
1091
|
-
this.onRecordingStarted(current);
|
|
1092
|
-
}
|
|
1093
|
-
} else if (this.activeRecording) {
|
|
1094
|
-
const previous = this.activeRecording;
|
|
1095
|
-
this.activeRecording = null;
|
|
1096
|
-
this.onRecordingStopped({
|
|
1097
|
-
recording_id: previous.recording_id,
|
|
1098
|
-
stopped_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
if (this.autoSubscribe) {
|
|
1102
|
-
const missing = [...nextTracks.values()].filter((t) => t.participant_id !== this.currentParticipantId && !this.subscribedTracks.has(t.track_id)).map((t) => t.track_id);
|
|
1103
|
-
if (missing.length) await this.subscribeMultiple(missing);
|
|
1104
|
-
}
|
|
1105
|
-
this.onRoomState(payload);
|
|
1106
|
-
}
|
|
1107
981
|
rememberTrack(track) {
|
|
1108
982
|
this.trackMetadata.set(track.track_id, track);
|
|
1109
983
|
this.trackToParticipant.set(track.track_id, track.participant_id);
|
|
@@ -1133,23 +1007,8 @@ var SFUClient = class {
|
|
|
1133
1007
|
for (const track of payload.tracks || []) {
|
|
1134
1008
|
if (track?.track_id) this.rememberTrack(track);
|
|
1135
1009
|
}
|
|
1136
|
-
if (payload.recording) {
|
|
1137
|
-
this.activeRecording = {
|
|
1138
|
-
recording_id: payload.recording.recording_id,
|
|
1139
|
-
started_at: payload.recording.started_at
|
|
1140
|
-
};
|
|
1141
|
-
this.onRecordingStarted(this.activeRecording);
|
|
1142
|
-
} else if (this.activeRecording) {
|
|
1143
|
-
const previous = this.activeRecording;
|
|
1144
|
-
this.activeRecording = null;
|
|
1145
|
-
this.onRecordingStopped({
|
|
1146
|
-
recording_id: previous.recording_id,
|
|
1147
|
-
stopped_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
1010
|
await this.initializePeerConnections();
|
|
1151
1011
|
this.setState("connected");
|
|
1152
|
-
this.startRoomStateSync();
|
|
1153
1012
|
this.onConnected(payload, resumed);
|
|
1154
1013
|
for (const participant of this.participants.values()) {
|
|
1155
1014
|
if (participant.participant_id !== this.currentParticipantId) {
|
|
@@ -1704,7 +1563,6 @@ var SFUClient = class {
|
|
|
1704
1563
|
}
|
|
1705
1564
|
async leave() {
|
|
1706
1565
|
this.stopHeartbeat();
|
|
1707
|
-
this.stopRoomStateSync();
|
|
1708
1566
|
this.intentionalClose = true;
|
|
1709
1567
|
this.setState("leaving");
|
|
1710
1568
|
if (this.reconnectTimer) {
|
|
@@ -2072,13 +1930,9 @@ var VideoSDKCore = class {
|
|
|
2072
1930
|
);
|
|
2073
1931
|
return;
|
|
2074
1932
|
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
throw new Error(
|
|
2079
|
-
`SFU client already exists in state "${state}". Disconnect explicitly before creating another connection.`
|
|
2080
|
-
);
|
|
2081
|
-
}
|
|
1933
|
+
throw new Error(
|
|
1934
|
+
`SFU client already exists in state "${state}". Disconnect explicitly before creating another connection.`
|
|
1935
|
+
);
|
|
2082
1936
|
}
|
|
2083
1937
|
const client = new SFUClient({
|
|
2084
1938
|
apiBase: this.apiBase,
|
|
@@ -2096,48 +1950,6 @@ var VideoSDKCore = class {
|
|
|
2096
1950
|
name: this.participantName
|
|
2097
1951
|
});
|
|
2098
1952
|
},
|
|
2099
|
-
onRoomState: (roomState) => {
|
|
2100
|
-
for (const participant of roomState?.participants || []) {
|
|
2101
|
-
const pid = participant?.participant_id;
|
|
2102
|
-
if (!pid || pid === this.myId) continue;
|
|
2103
|
-
const current = this.state.getParticipant(pid);
|
|
2104
|
-
if (!current) continue;
|
|
2105
|
-
this.state.updateParticipantMedia(pid, {
|
|
2106
|
-
stream: current.media?.stream ?? null,
|
|
2107
|
-
micEnabled: !Boolean(participant.audio_muted),
|
|
2108
|
-
camEnabled: !Boolean(participant.video_muted),
|
|
2109
|
-
isScreenSharing: Boolean(participant.screen_sharing)
|
|
2110
|
-
});
|
|
2111
|
-
}
|
|
2112
|
-
const presenters = /* @__PURE__ */ new Set();
|
|
2113
|
-
for (const participant of roomState?.participants || []) {
|
|
2114
|
-
const pid = participant?.participant_id;
|
|
2115
|
-
if (!pid || pid === this.myId) continue;
|
|
2116
|
-
const current = this.state.getParticipant(pid);
|
|
2117
|
-
if (!current) continue;
|
|
2118
|
-
if (participant.screen_sharing) {
|
|
2119
|
-
presenters.add(pid);
|
|
2120
|
-
this.state.updateParticipantMedia(pid, {
|
|
2121
|
-
isScreenSharing: true,
|
|
2122
|
-
screenStream: current.media?.screenStream ?? null
|
|
2123
|
-
});
|
|
2124
|
-
} else if (current.media?.isScreenSharing) {
|
|
2125
|
-
const screen = this.remoteScreenStreams.get(pid);
|
|
2126
|
-
screen?.getTracks().forEach((track) => track.stop());
|
|
2127
|
-
this.remoteScreenStreams.delete(pid);
|
|
2128
|
-
this.state.updateParticipantMedia(pid, {
|
|
2129
|
-
isScreenSharing: false,
|
|
2130
|
-
screenStream: null,
|
|
2131
|
-
screenTrack: void 0
|
|
2132
|
-
});
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
const presenter = [...presenters][0] ?? null;
|
|
2136
|
-
if (this.state.presenterId !== presenter) {
|
|
2137
|
-
this.state.setPresenterId(presenter);
|
|
2138
|
-
}
|
|
2139
|
-
this.events.onRoomUpdate?.(roomState);
|
|
2140
|
-
},
|
|
2141
1953
|
onDisconnected: () => {
|
|
2142
1954
|
console.log("[SFU] Signaling WebSocket disconnected; reconnecting");
|
|
2143
1955
|
},
|
|
@@ -2147,11 +1959,6 @@ var VideoSDKCore = class {
|
|
|
2147
1959
|
// ADMISSION CONTROL
|
|
2148
1960
|
onJoinPending: (info) => {
|
|
2149
1961
|
console.log("[SFU] Join request pending", info);
|
|
2150
|
-
this.events.onEntryRequested?.({
|
|
2151
|
-
requestId: info.request_id,
|
|
2152
|
-
participantId: this.myId,
|
|
2153
|
-
name: this.participantName
|
|
2154
|
-
});
|
|
2155
1962
|
},
|
|
2156
1963
|
onJoinApproved: (requestId) => {
|
|
2157
1964
|
console.log("[SFU] Join approved", requestId);
|
|
@@ -2209,8 +2016,8 @@ var VideoSDKCore = class {
|
|
|
2209
2016
|
name: pname,
|
|
2210
2017
|
connectionState: "connected",
|
|
2211
2018
|
media: {
|
|
2212
|
-
micEnabled:
|
|
2213
|
-
camEnabled:
|
|
2019
|
+
micEnabled: true,
|
|
2020
|
+
camEnabled: true,
|
|
2214
2021
|
isScreenSharing: false,
|
|
2215
2022
|
stream: null
|
|
2216
2023
|
}
|
|
@@ -2283,18 +2090,6 @@ var VideoSDKCore = class {
|
|
|
2283
2090
|
camEnabled: track.kind === "video" ? false : current.media?.camEnabled ?? true
|
|
2284
2091
|
});
|
|
2285
2092
|
},
|
|
2286
|
-
onParticipantMediaState: (participantId, audioMuted, videoMuted) => {
|
|
2287
|
-
if (participantId === this.myId) return;
|
|
2288
|
-
const current = this.state.getParticipant(participantId);
|
|
2289
|
-
if (!current) return;
|
|
2290
|
-
this.state.updateParticipantMedia(participantId, {
|
|
2291
|
-
stream: current.media?.stream ?? null,
|
|
2292
|
-
micEnabled: !audioMuted,
|
|
2293
|
-
camEnabled: !videoMuted
|
|
2294
|
-
});
|
|
2295
|
-
this.events.onMuteStateChanged?.(participantId, "audio", audioMuted);
|
|
2296
|
-
this.events.onMuteStateChanged?.(participantId, "video", videoMuted);
|
|
2297
|
-
},
|
|
2298
2093
|
onTrackStateChanged: (track) => {
|
|
2299
2094
|
const pid = track.participant_id;
|
|
2300
2095
|
if (!pid || pid === this.myId) {
|
|
@@ -2395,9 +2190,7 @@ var VideoSDKCore = class {
|
|
|
2395
2190
|
client.setLocalStream(this.localStream);
|
|
2396
2191
|
await client.getToken(roomId, {
|
|
2397
2192
|
displayName: name,
|
|
2398
|
-
participantId: this.myId
|
|
2399
|
-
audioMuted: this.state.localParticipant?.media?.micEnabled,
|
|
2400
|
-
videoMuted: this.state.localParticipant?.media?.camEnabled
|
|
2193
|
+
participantId: this.myId
|
|
2401
2194
|
});
|
|
2402
2195
|
}
|
|
2403
2196
|
// SFU STATE
|
|
@@ -2711,7 +2504,6 @@ var MeetingProvider = ({
|
|
|
2711
2504
|
/* @__PURE__ */ new Set()
|
|
2712
2505
|
);
|
|
2713
2506
|
const meetingLeftListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
2714
|
-
const roomUpdateListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
2715
2507
|
const trackStateListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
2716
2508
|
const recordingStartedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
2717
2509
|
const recordingStoppedListeners = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
@@ -2736,9 +2528,6 @@ var MeetingProvider = ({
|
|
|
2736
2528
|
onMeetingLeft: () => {
|
|
2737
2529
|
meetingLeftListeners.current.forEach((fn) => fn());
|
|
2738
2530
|
},
|
|
2739
|
-
onRoomUpdate: (data) => {
|
|
2740
|
-
roomUpdateListeners.current.forEach((fn) => fn(data));
|
|
2741
|
-
},
|
|
2742
2531
|
onTrackStateChanged: (track) => {
|
|
2743
2532
|
trackStateListeners.current.forEach((fn) => fn(track));
|
|
2744
2533
|
},
|
|
@@ -2837,10 +2626,6 @@ var MeetingProvider = ({
|
|
|
2837
2626
|
meetingLeftListeners.current.delete(cb);
|
|
2838
2627
|
};
|
|
2839
2628
|
},
|
|
2840
|
-
onRoomUpdate: (cb) => {
|
|
2841
|
-
roomUpdateListeners.current.add(cb);
|
|
2842
|
-
return () => roomUpdateListeners.current.delete(cb);
|
|
2843
|
-
},
|
|
2844
2629
|
onTrackStateChanged: (cb) => {
|
|
2845
2630
|
trackStateListeners.current.add(cb);
|
|
2846
2631
|
return () => trackStateListeners.current.delete(cb);
|