Merge branch 'livekit' into toger5/tiles_based_on_rtc_member

This commit is contained in:
Hugh Nimmo-Smith 2024-11-21 11:28:30 +00:00
commit 8f62cb675c
3 changed files with 30 additions and 14 deletions

View File

@ -31,7 +31,7 @@ import {
mockLivekitRoom, mockLivekitRoom,
mockLocalParticipant, mockLocalParticipant,
mockMatrixRoom, mockMatrixRoom,
mockRoomMember, mockMatrixRoomMember,
mockRemoteParticipant, mockRemoteParticipant,
withTestScheduler, withTestScheduler,
mockRtcMembership, mockRtcMembership,
@ -50,10 +50,10 @@ const aliceRtcMember = mockRtcMembership("@alice:example.org", "AAAA");
const bobRtcMember = mockRtcMembership("@bob:example.org", "BBBB"); const bobRtcMember = mockRtcMembership("@bob:example.org", "BBBB");
const daveRtcMember = mockRtcMembership("@dave:example.org", "DDDD"); const daveRtcMember = mockRtcMembership("@dave:example.org", "DDDD");
const alice = mockRoomMember(aliceRtcMember); const alice = mockMatrixRoomMember(aliceRtcMember);
const bob = mockRoomMember(bobRtcMember); const bob = mockMatrixRoomMember(bobRtcMember);
const carol = mockRoomMember(localRtcMember); const carol = mockMatrixRoomMember(localRtcMember);
const dave = mockRoomMember(daveRtcMember); const dave = mockMatrixRoomMember(daveRtcMember);
const aliceId = `${alice.userId}:${aliceRtcMember.deviceId}`; const aliceId = `${alice.userId}:${aliceRtcMember.deviceId}`;
const bobId = `${bob.userId}:${bobRtcMember.deviceId}`; const bobId = `${bob.userId}:${bobRtcMember.deviceId}`;

View File

@ -375,12 +375,16 @@ export class CallViewModel extends ViewModel {
}), }),
); );
private readonly rawRemoteParticipants = connectedParticipantsObserver( /**
this.livekitRoom, * The raw list of RemoteParticipants as reported by LiveKit
).pipe(this.scope.state()); */
private readonly rawRemoteParticipants: Observable<RemoteParticipant[]> =
connectedParticipantsObserver(this.livekitRoom).pipe(this.scope.state());
// Lists of RemoteParticipants to "hold" on display, even if LiveKit claims that /**
// they've left * Lists of RemoteParticipants to "hold" on display, even if LiveKit claims that
* they've left
*/
private readonly remoteParticipantHolds: Observable<RemoteParticipant[][]> = private readonly remoteParticipantHolds: Observable<RemoteParticipant[][]> =
this.connectionState.pipe( this.connectionState.pipe(
withLatestFrom(this.rawRemoteParticipants), withLatestFrom(this.rawRemoteParticipants),
@ -415,6 +419,9 @@ export class CallViewModel extends ViewModel {
), ),
); );
/**
* The RemoteParticipants including those that are being "held" on the screen
*/
private readonly remoteParticipants: Observable<RemoteParticipant[]> = private readonly remoteParticipants: Observable<RemoteParticipant[]> =
combineLatest( combineLatest(
[this.rawRemoteParticipants, this.remoteParticipantHolds], [this.rawRemoteParticipants, this.remoteParticipantHolds],
@ -436,6 +443,9 @@ export class CallViewModel extends ViewModel {
}, },
); );
/**
* List of MediaItems that we want to display
*/
private readonly mediaItems: Observable<MediaItem[]> = combineLatest([ private readonly mediaItems: Observable<MediaItem[]> = combineLatest([
this.remoteParticipants, this.remoteParticipants,
observeParticipantMedia(this.livekitRoom.localParticipant), observeParticipantMedia(this.livekitRoom.localParticipant),
@ -541,12 +551,18 @@ export class CallViewModel extends ViewModel {
this.scope.state(), this.scope.state(),
); );
/**
* List of MediaItems that we want to display, that are of type UserMedia
*/
private readonly userMedia: Observable<UserMedia[]> = this.mediaItems.pipe( private readonly userMedia: Observable<UserMedia[]> = this.mediaItems.pipe(
map((mediaItems) => map((mediaItems) =>
mediaItems.filter((m): m is UserMedia => m instanceof UserMedia), mediaItems.filter((m): m is UserMedia => m instanceof UserMedia),
), ),
); );
/**
* List of MediaItems that we want to display, that are of type ScreenShare
*/
private readonly screenShares: Observable<ScreenShare[]> = private readonly screenShares: Observable<ScreenShare[]> =
this.mediaItems.pipe( this.mediaItems.pipe(
map((mediaItems) => map((mediaItems) =>
@ -1021,7 +1037,7 @@ export class CallViewModel extends ViewModel {
this.scope.state(), this.scope.state(),
); );
public readonly showFooter = this.windowMode.pipe( public readonly showFooter: Observable<boolean> = this.windowMode.pipe(
switchMap((mode) => { switchMap((mode) => {
switch (mode) { switch (mode) {
case "pip": case "pip":

View File

@ -134,7 +134,7 @@ export function mockRtcMembership(
// Maybe it'd be good to move this to matrix-js-sdk? Our testing needs are // Maybe it'd be good to move this to matrix-js-sdk? Our testing needs are
// rather simple, but if one util to mock a member is good enough for us, maybe // rather simple, but if one util to mock a member is good enough for us, maybe
// it's useful for matrix-js-sdk consumers in general. // it's useful for matrix-js-sdk consumers in general.
export function mockRoomMember( export function mockMatrixRoomMember(
rtcMembership: CallMembership, rtcMembership: CallMembership,
member: Partial<RoomMember> = {}, member: Partial<RoomMember> = {},
): RoomMember { ): RoomMember {
@ -192,7 +192,7 @@ export async function withLocalMedia(
const localParticipant = mockLocalParticipant({}); const localParticipant = mockLocalParticipant({});
const vm = new LocalUserMediaViewModel( const vm = new LocalUserMediaViewModel(
"local", "local",
mockRoomMember(localRtcMember, roomMember), mockMatrixRoomMember(localRtcMember, roomMember),
of(localParticipant), of(localParticipant),
{ {
kind: E2eeType.PER_PARTICIPANT, kind: E2eeType.PER_PARTICIPANT,
@ -228,7 +228,7 @@ export async function withRemoteMedia(
const remoteParticipant = mockRemoteParticipant(participant); const remoteParticipant = mockRemoteParticipant(participant);
const vm = new RemoteUserMediaViewModel( const vm = new RemoteUserMediaViewModel(
"remote", "remote",
mockRoomMember(localRtcMember, roomMember), mockMatrixRoomMember(localRtcMember, roomMember),
of(remoteParticipant), of(remoteParticipant),
{ {
kind: E2eeType.PER_PARTICIPANT, kind: E2eeType.PER_PARTICIPANT,