Merge branch 'livekit' into local-remote-confusion
This commit is contained in:
@@ -323,12 +323,14 @@ export const createLocalMembership$ = ({
|
|||||||
// - overwrite current publisher
|
// - overwrite current publisher
|
||||||
scope.reconcile(localConnection$, async (connection) => {
|
scope.reconcile(localConnection$, async (connection) => {
|
||||||
if (connection !== null) {
|
if (connection !== null) {
|
||||||
publisher$.next(createPublisherFactory(connection));
|
const publisher = createPublisherFactory(connection);
|
||||||
|
publisher$.next(publisher);
|
||||||
|
// Clean-up callback
|
||||||
|
return Promise.resolve(async (): Promise<void> => {
|
||||||
|
await publisher.stopPublishing();
|
||||||
|
publisher.stopTracks();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return Promise.resolve(async (): Promise<void> => {
|
|
||||||
await publisher$?.value?.stopPublishing();
|
|
||||||
publisher$?.value?.stopTracks();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Use reconcile here to not run concurrent createAndSetupTracks calls
|
// Use reconcile here to not run concurrent createAndSetupTracks calls
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
type LivekitTransport,
|
type LivekitTransport,
|
||||||
type ParticipantId,
|
type ParticipantId,
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
} from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import { BehaviorSubject, combineLatest, map, of, switchMap, tap } from "rxjs";
|
import { combineLatest, map, of, switchMap, tap } from "rxjs";
|
||||||
import { type Logger } from "matrix-js-sdk/lib/logger";
|
import { type Logger } from "matrix-js-sdk/lib/logger";
|
||||||
import { type RemoteParticipant } from "livekit-client";
|
import { type RemoteParticipant } from "livekit-client";
|
||||||
|
|
||||||
@@ -55,11 +55,7 @@ export class ConnectionManagerData {
|
|||||||
transport: LivekitTransport,
|
transport: LivekitTransport,
|
||||||
): RemoteParticipant[] {
|
): RemoteParticipant[] {
|
||||||
const key = transport.livekit_service_url + "|" + transport.livekit_alias;
|
const key = transport.livekit_service_url + "|" + transport.livekit_alias;
|
||||||
const existing = this.store.get(key);
|
return this.store.get(key)?.[1] ?? [];
|
||||||
if (existing) {
|
|
||||||
return existing[1];
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get all connections where the given participant is publishing.
|
* Get all connections where the given participant is publishing.
|
||||||
@@ -110,9 +106,6 @@ export function createConnectionManager$({
|
|||||||
logger: parentLogger,
|
logger: parentLogger,
|
||||||
}: Props): IConnectionManager {
|
}: Props): IConnectionManager {
|
||||||
const logger = parentLogger.getChild("[ConnectionManager]");
|
const logger = parentLogger.getChild("[ConnectionManager]");
|
||||||
|
|
||||||
const running$ = new BehaviorSubject(true);
|
|
||||||
scope.onEnd(() => running$.next(false));
|
|
||||||
// TODO logger: only construct one logger from the client and make it compatible via a EC specific sing
|
// TODO logger: only construct one logger from the client and make it compatible via a EC specific sing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,10 +117,7 @@ export function createConnectionManager$({
|
|||||||
* externally this is modified via `registerTransports()`.
|
* externally this is modified via `registerTransports()`.
|
||||||
*/
|
*/
|
||||||
const transports$ = scope.behavior(
|
const transports$ = scope.behavior(
|
||||||
combineLatest([running$, inputTransports$]).pipe(
|
inputTransports$.pipe(
|
||||||
map(([running, transports]) =>
|
|
||||||
transports.mapInner((transport) => (running ? transport : [])),
|
|
||||||
),
|
|
||||||
map((transports) => transports.mapInner(removeDuplicateTransports)),
|
map((transports) => transports.mapInner(removeDuplicateTransports)),
|
||||||
tap(({ value: transports }) => {
|
tap(({ value: transports }) => {
|
||||||
logger.trace(
|
logger.trace(
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export function createMatrixLivekitMembers$({
|
|||||||
// Each update where the key of the generator array do not change will result in updates to the `data$` observable in the factory.
|
// Each update where the key of the generator array do not change will result in updates to the `data$` observable in the factory.
|
||||||
(scope, data$, participantId, userId) => {
|
(scope, data$, participantId, userId) => {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Updating data$ for participantId: ${participantId}, userId: ${userId}`,
|
`Generating member for participantId: ${participantId}, userId: ${userId}`,
|
||||||
);
|
);
|
||||||
const { participant$, ...rest } = scope.splitBehavior(data$);
|
const { participant$, ...rest } = scope.splitBehavior(data$);
|
||||||
// will only get called once per `participantId, userId` pair.
|
// will only get called once per `participantId, userId` pair.
|
||||||
|
|||||||
Reference in New Issue
Block a user