Co-authored-by: Valere <bill.carson@valrsoft.com>
This commit is contained in:
Timo K
2025-10-29 12:37:14 +01:00
parent cfe05f1ed9
commit 3de0bbcfc9
2 changed files with 118 additions and 38 deletions

View File

@@ -16,8 +16,10 @@ import {
type RemoteParticipant,
Room as LivekitRoom,
type RoomOptions,
Participant,
} from "livekit-client";
import {
ParticipantId,
type CallMembership,
type LivekitTransport,
} from "matrix-js-sdk/lib/matrixrtc";
@@ -37,6 +39,8 @@ import {
SFURoomCreationRestrictedError,
} from "../../utils/errors.ts";
export type PublishingParticipant = Participant;
export interface ConnectionOpts {
/** The media transport to connect to. */
transport: LivekitTransport;
@@ -72,21 +76,6 @@ export type ConnectionState =
}
| { state: "Stopped"; transport: LivekitTransport };
/**
* Represents participant publishing or expected to publish on the connection.
* It is paired with its associated rtc membership.
*/
export type PublishingParticipant = {
/**
* The LiveKit participant publishing on this connection, or undefined if the participant is not currently (yet) connected to the livekit room.
*/
participant: RemoteParticipant | undefined;
/**
* The rtc call membership associated with this participant.
*/
membership: CallMembership;
};
/**
* A connection to a Matrix RTC LiveKit backend.
*
@@ -205,7 +194,11 @@ export class Connection {
* This is derived from `participantsIncludingSubscribers$` and `remoteTransports$`.
* It filters the participants to only those that are associated with a membership that claims to publish on this connection.
*/
public readonly publishingParticipants$: Behavior<PublishingParticipant[]>;
public readonly participantsWithPublishTrack$: Behavior<
PublishingParticipant[]
>;
/**
* The media transport to connect to.
@@ -233,12 +226,15 @@ export class Connection {
this.transport = transport;
this.client = client;
const participantsIncludingSubscribers$: Behavior<RemoteParticipant[]> =
scope.behavior(connectedParticipantsObserver(this.livekitRoom), []);
this.participantsWithPublishTrack$ = scope.behavior(
connectedParticipantsObserver(this.livekitRoom),
[],
);
// Legacy using callMemberships
this.publishingParticipants$ = scope.behavior(
combineLatest(
[participantsIncludingSubscribers$, membershipsWithTransport$],
[this.participantsIncludingSubscribers$, membershipsWithTransport$],
(participants, remoteTransports) =>
remoteTransports
// Find all members that claim to publish on this connection