add local storage + more readable + remoteParticipants + use publishingParticipants

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo K
2025-08-28 10:34:43 +02:00
parent 55b46b3f33
commit 8ffb360114
2 changed files with 38 additions and 11 deletions

View File

@@ -44,6 +44,16 @@ async function makeFocusInternal(
// Prioritize the .well-known/matrix/client, if available, over the configured SFU // Prioritize the .well-known/matrix/client, if available, over the configured SFU
const domain = rtcSession.room.client.getDomain(); const domain = rtcSession.room.client.getDomain();
if (localStorage.getItem("timo-focus-url")) {
const timoFocusUrl = JSON.parse(localStorage.getItem("timo-focus-url")!);
const focusFromUrl: LivekitFocus = {
type: "livekit",
livekit_service_url: timoFocusUrl,
livekit_alias: livekitAlias,
};
logger.log("Using LiveKit focus from localStorage: ", timoFocusUrl);
return focusFromUrl;
}
if (domain) { if (domain) {
// we use AutoDiscovery instead of relying on the MatrixClient having already // we use AutoDiscovery instead of relying on the MatrixClient having already
// been fully configured and started // been fully configured and started

View File

@@ -66,7 +66,7 @@ import { logger } from "matrix-js-sdk/lib/logger";
import { import {
type CallMembership, type CallMembership,
isLivekitFocusConfig, isLivekitFocusConfig,
LivekitFocusConfig, type LivekitFocusConfig,
type MatrixRTCSession, type MatrixRTCSession,
MatrixRTCSessionEvent, MatrixRTCSessionEvent,
type MatrixRTCSessionEventHandlerMap, type MatrixRTCSessionEventHandlerMap,
@@ -501,7 +501,7 @@ class Connection {
this.stopped = true; this.stopped = true;
} }
public readonly participantsIncludingJustSubscribers$ = this.scope.behavior( public readonly participantsIncludingSubscribers$ = this.scope.behavior(
connectedParticipantsObserver(this.livekitRoom), connectedParticipantsObserver(this.livekitRoom),
[], [],
); );
@@ -570,12 +570,14 @@ export class CallViewModel extends ViewModel {
), ),
); );
private readonly memberships$ = fromEvent( private readonly memberships$ = this.scope.behavior(
this.matrixRTCSession, fromEvent(
MatrixRTCSessionEvent.MembershipsChanged, this.matrixRTCSession,
).pipe( MatrixRTCSessionEvent.MembershipsChanged,
startWith(null), ).pipe(
map(() => this.matrixRTCSession.memberships), startWith(null),
map(() => this.matrixRTCSession.memberships),
),
); );
private readonly foci$ = this.memberships$.pipe( private readonly foci$ = this.memberships$.pipe(
@@ -725,9 +727,24 @@ export class CallViewModel extends ViewModel {
* The RemoteParticipants including those that are being "held" on the screen * The RemoteParticipants including those that are being "held" on the screen
*/ */
private readonly remoteParticipants$ = this.scope private readonly remoteParticipants$ = this.scope
.behavior< .behavior<RemoteParticipant[]>(
RemoteParticipant[] combineLatest(
>(combineLatest([this.localConnection, this.remoteConnections$], (localConnection, remoteConnections) => combineLatest([localConnection.participantsIncludingJustSubscribers$, ...[...remoteConnections.values()].map((c) => c.participantsIncludingJustSubscribers$)], (...ps) => ps.flat(1))).pipe(switchAll(), startWith([]))) [this.localConnection, this.remoteConnections$],
(localConnection, remoteConnections) => {
const remoteConnectionsParticipants = [
...remoteConnections.values(),
].map((c) => c.publishingParticipants$(this.memberships$));
return combineLatest(
[
localConnection.publishingParticipants$(this.memberships$),
...remoteConnectionsParticipants,
],
(...ps) => ps.flat(1),
);
},
).pipe(switchAll(), startWith([])),
)
.pipe(pauseWhen(this.pretendToBeDisconnected$)); .pipe(pauseWhen(this.pretendToBeDisconnected$));
private readonly memberships$ = this.scope.behavior( private readonly memberships$ = this.scope.behavior(