@@ -471,11 +471,6 @@ class Connection {
|
|||||||
this.stopped = false;
|
this.stopped = false;
|
||||||
const { url, jwt } = await this.sfuConfig;
|
const { url, jwt } = await this.sfuConfig;
|
||||||
if (!this.stopped) await this.livekitRoom.connect(url, jwt);
|
if (!this.stopped) await this.livekitRoom.connect(url, jwt);
|
||||||
// TODO-MULTI-SFU in this livekit room we really do not want to publish any tracks.
|
|
||||||
// this is only for testing purposes
|
|
||||||
const tracks = await this.livekitRoom.localParticipant.createTracks({
|
|
||||||
audio: { deviceId: "default" },
|
|
||||||
});
|
|
||||||
await this.livekitRoom.localParticipant.publishTrack(tracks[0]);
|
await this.livekitRoom.localParticipant.publishTrack(tracks[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,9 +478,10 @@ class Connection {
|
|||||||
this.stopped = false;
|
this.stopped = false;
|
||||||
const { url, jwt } = await this.sfuConfig;
|
const { url, jwt } = await this.sfuConfig;
|
||||||
if (!this.stopped) await this.livekitRoom.connect(url, jwt);
|
if (!this.stopped) await this.livekitRoom.connect(url, jwt);
|
||||||
|
|
||||||
if (!this.stopped) {
|
if (!this.stopped) {
|
||||||
const tracks = await this.livekitRoom.localParticipant.createTracks({
|
const tracks = await this.livekitRoom.localParticipant.createTracks({
|
||||||
audio: { deviceId: "default" },
|
audio: true,
|
||||||
video: true,
|
video: true,
|
||||||
});
|
});
|
||||||
for (const track of tracks) {
|
for (const track of tracks) {
|
||||||
@@ -524,30 +520,11 @@ class Connection {
|
|||||||
|
|
||||||
const publishingP = publishingMembers
|
const publishingP = publishingMembers
|
||||||
.map((m) => {
|
.map((m) => {
|
||||||
logger.log(
|
|
||||||
"Publishing participants: all participants at: ",
|
|
||||||
this.livekitAlias,
|
|
||||||
this.serviceUrl,
|
|
||||||
participants,
|
|
||||||
);
|
|
||||||
return participants.find((p) => {
|
return participants.find((p) => {
|
||||||
logger.log(
|
|
||||||
"Publishing participants: compare",
|
|
||||||
p.identity,
|
|
||||||
"===",
|
|
||||||
`${m.sender}:${m.deviceId}`,
|
|
||||||
);
|
|
||||||
return p.identity === `${m.sender}:${m.deviceId}`;
|
return p.identity === `${m.sender}:${m.deviceId}`;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.filter((p): p is RemoteParticipant => !!p);
|
.filter((p): p is RemoteParticipant => !!p);
|
||||||
logger.log(
|
|
||||||
"Publishing participants: find participants for url ",
|
|
||||||
this.serviceUrl,
|
|
||||||
publishingMembers,
|
|
||||||
"Publishing participants: ",
|
|
||||||
publishingP,
|
|
||||||
);
|
|
||||||
return publishingP;
|
return publishingP;
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
@@ -612,21 +589,22 @@ export class CallViewModel extends ViewModel {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
private readonly remoteConnections$ = combineLatest([
|
private readonly remoteConnections$ = this.scope.behavior(
|
||||||
this.localFocus,
|
combineLatest([this.localFocus, this.foci$]).pipe(
|
||||||
this.foci$,
|
accumulate(new Map<string, Connection>(), (prev, [localFocus, foci]) => {
|
||||||
]).pipe(
|
const stopped = new Map(prev);
|
||||||
accumulate(new Map<string, Connection>(), (prev, [localFocus, foci]) => {
|
const next = new Map<string, Connection>();
|
||||||
const stopped = new Map(prev);
|
for (const focus of foci) {
|
||||||
const next = new Map<string, Connection>();
|
if (focus !== localFocus.livekit_service_url) {
|
||||||
|
stopped.delete(focus);
|
||||||
|
|
||||||
for (const focus of foci) {
|
let nextConnection = prev.get(focus);
|
||||||
if (focus !== localFocus.livekit_service_url) {
|
if (!nextConnection) {
|
||||||
stopped.delete(focus);
|
logger.log(
|
||||||
next.set(
|
"SFU remoteConnections$ construct new connection: ",
|
||||||
focus,
|
focus,
|
||||||
prev.get(focus) ??
|
);
|
||||||
new Connection(
|
nextConnection = new Connection(
|
||||||
new LivekitRoom({
|
new LivekitRoom({
|
||||||
...defaultLiveKitOptions,
|
...defaultLiveKitOptions,
|
||||||
e2ee: this.e2eeOptions,
|
e2ee: this.e2eeOptions,
|
||||||
@@ -636,14 +614,18 @@ export class CallViewModel extends ViewModel {
|
|||||||
this.matrixRTCSession.room.client,
|
this.matrixRTCSession.room.client,
|
||||||
this.scope,
|
this.scope,
|
||||||
this.matrixRTCSession,
|
this.matrixRTCSession,
|
||||||
),
|
);
|
||||||
);
|
} else {
|
||||||
|
logger.log("SFU remoteConnections$ use prev connection: ", focus);
|
||||||
|
}
|
||||||
|
next.set(focus, nextConnection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (const connection of stopped.values()) connection.stop();
|
for (const connection of stopped.values()) connection.stop();
|
||||||
return next;
|
return next;
|
||||||
}),
|
}),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
private readonly joined$ = new Subject<void>();
|
private readonly joined$ = new Subject<void>();
|
||||||
|
|||||||
Reference in New Issue
Block a user