Fix decryption errors
The code had regressed to a state where it was attempting to use one encryption worker for all LiveKit rooms, which does not currently work.
This commit is contained in:
@@ -8,12 +8,10 @@ Please see LICENSE in the repository root for full details.
|
|||||||
import {
|
import {
|
||||||
type BaseKeyProvider,
|
type BaseKeyProvider,
|
||||||
type ConnectionState,
|
type ConnectionState,
|
||||||
type E2EEOptions,
|
|
||||||
ExternalE2EEKeyProvider,
|
ExternalE2EEKeyProvider,
|
||||||
type Room as LivekitRoom,
|
type Room as LivekitRoom,
|
||||||
type RoomOptions,
|
type RoomOptions,
|
||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
import E2EEWorker from "livekit-client/e2ee-worker?worker";
|
|
||||||
import { type Room as MatrixRoom } from "matrix-js-sdk";
|
import { type Room as MatrixRoom } from "matrix-js-sdk";
|
||||||
import {
|
import {
|
||||||
combineLatest,
|
combineLatest,
|
||||||
@@ -179,19 +177,11 @@ export class CallViewModel {
|
|||||||
private readonly userId = this.matrixRoom.client.getUserId()!;
|
private readonly userId = this.matrixRoom.client.getUserId()!;
|
||||||
private readonly deviceId = this.matrixRoom.client.getDeviceId()!;
|
private readonly deviceId = this.matrixRoom.client.getDeviceId()!;
|
||||||
|
|
||||||
private readonly livekitE2EEKeyProvider = getE2eeKeyProvider(
|
private readonly livekitKeyProvider = getE2eeKeyProvider(
|
||||||
this.options.encryptionSystem,
|
this.options.encryptionSystem,
|
||||||
this.matrixRTCSession,
|
this.matrixRTCSession,
|
||||||
);
|
);
|
||||||
|
|
||||||
private readonly e2eeLivekitOptions: E2EEOptions | undefined = this
|
|
||||||
.livekitE2EEKeyProvider
|
|
||||||
? {
|
|
||||||
keyProvider: this.livekitE2EEKeyProvider,
|
|
||||||
worker: new E2EEWorker(),
|
|
||||||
}
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
private memberships$ = createMemberships$(this.scope, this.matrixRTCSession);
|
private memberships$ = createMemberships$(this.scope, this.matrixRTCSession);
|
||||||
|
|
||||||
private membershipsAndTransports = membershipsAndTransports$(
|
private membershipsAndTransports = membershipsAndTransports$(
|
||||||
@@ -215,7 +205,7 @@ export class CallViewModel {
|
|||||||
this.matrixRoom.client,
|
this.matrixRoom.client,
|
||||||
this.mediaDevices,
|
this.mediaDevices,
|
||||||
this.trackProcessorState$,
|
this.trackProcessorState$,
|
||||||
this.e2eeLivekitOptions,
|
this.livekitKeyProvider,
|
||||||
getUrlParams().controlledAudioDevices,
|
getUrlParams().controlledAudioDevices,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -251,7 +241,7 @@ export class CallViewModel {
|
|||||||
private connectOptions$ = this.scope.behavior(
|
private connectOptions$ = this.scope.behavior(
|
||||||
matrixRTCMode.value$.pipe(
|
matrixRTCMode.value$.pipe(
|
||||||
map((mode) => ({
|
map((mode) => ({
|
||||||
encryptMedia: this.e2eeLivekitOptions !== undefined,
|
encryptMedia: this.livekitKeyProvider !== undefined,
|
||||||
// TODO. This might need to get called again on each cahnge of matrixRTCMode...
|
// TODO. This might need to get called again on each cahnge of matrixRTCMode...
|
||||||
matrixRTCMode: mode,
|
matrixRTCMode: mode,
|
||||||
})),
|
})),
|
||||||
@@ -266,7 +256,6 @@ export class CallViewModel {
|
|||||||
matrixRTCSession: this.matrixRTCSession,
|
matrixRTCSession: this.matrixRTCSession,
|
||||||
matrixRoom: this.matrixRoom,
|
matrixRoom: this.matrixRoom,
|
||||||
localTransport$: this.localTransport$,
|
localTransport$: this.localTransport$,
|
||||||
e2eeLivekitOptions: this.e2eeLivekitOptions,
|
|
||||||
trackProcessorState$: this.trackProcessorState$,
|
trackProcessorState$: this.trackProcessorState$,
|
||||||
widget,
|
widget,
|
||||||
options: this.connectOptions$,
|
options: this.connectOptions$,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Please see LICENSE in the repository root for full details.
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
type LocalTrack,
|
type LocalTrack,
|
||||||
type E2EEOptions,
|
|
||||||
type Participant,
|
type Participant,
|
||||||
ParticipantEvent,
|
ParticipantEvent,
|
||||||
type LocalParticipant,
|
type LocalParticipant,
|
||||||
@@ -105,7 +104,6 @@ interface Props {
|
|||||||
matrixRTCSession: MatrixRTCSession;
|
matrixRTCSession: MatrixRTCSession;
|
||||||
matrixRoom: MatrixRoom;
|
matrixRoom: MatrixRoom;
|
||||||
localTransport$: Behavior<LivekitTransport | null>;
|
localTransport$: Behavior<LivekitTransport | null>;
|
||||||
e2eeLivekitOptions: E2EEOptions | undefined;
|
|
||||||
trackProcessorState$: Behavior<ProcessorState>;
|
trackProcessorState$: Behavior<ProcessorState>;
|
||||||
widget: WidgetHelpers | null;
|
widget: WidgetHelpers | null;
|
||||||
}
|
}
|
||||||
@@ -132,7 +130,6 @@ export const createLocalMembership$ = ({
|
|||||||
matrixRTCSession,
|
matrixRTCSession,
|
||||||
localTransport$,
|
localTransport$,
|
||||||
matrixRoom,
|
matrixRoom,
|
||||||
e2eeLivekitOptions,
|
|
||||||
trackProcessorState$,
|
trackProcessorState$,
|
||||||
widget,
|
widget,
|
||||||
}: Props): {
|
}: Props): {
|
||||||
@@ -252,7 +249,6 @@ export const createLocalMembership$ = ({
|
|||||||
connection,
|
connection,
|
||||||
mediaDevices,
|
mediaDevices,
|
||||||
muteStates,
|
muteStates,
|
||||||
e2eeLivekitOptions,
|
|
||||||
trackProcessorState$,
|
trackProcessorState$,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
type E2EEOptions,
|
|
||||||
LocalVideoTrack,
|
LocalVideoTrack,
|
||||||
type Room as LivekitRoom,
|
type Room as LivekitRoom,
|
||||||
Track,
|
Track,
|
||||||
@@ -55,7 +54,6 @@ export class Publisher {
|
|||||||
private connection: Connection,
|
private connection: Connection,
|
||||||
devices: MediaDevices,
|
devices: MediaDevices,
|
||||||
private readonly muteStates: MuteStates,
|
private readonly muteStates: MuteStates,
|
||||||
e2eeLivekitOptions: E2EEOptions | undefined,
|
|
||||||
trackerProcessorState$: Behavior<ProcessorState>,
|
trackerProcessorState$: Behavior<ProcessorState>,
|
||||||
private logger?: Logger,
|
private logger?: Logger,
|
||||||
) {
|
) {
|
||||||
@@ -64,7 +62,7 @@ export class Publisher {
|
|||||||
|
|
||||||
const room = connection.livekitRoom;
|
const room = connection.livekitRoom;
|
||||||
|
|
||||||
room.setE2EEEnabled(e2eeLivekitOptions !== undefined)?.catch((e: Error) => {
|
room.setE2EEEnabled(room.options.e2ee !== undefined)?.catch((e: Error) => {
|
||||||
this.logger?.error("Failed to set E2EE enabled on room", e);
|
this.logger?.error("Failed to set E2EE enabled on room", e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import {
|
|||||||
type E2EEOptions,
|
type E2EEOptions,
|
||||||
Room as LivekitRoom,
|
Room as LivekitRoom,
|
||||||
type RoomOptions,
|
type RoomOptions,
|
||||||
|
type BaseKeyProvider,
|
||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
import { type Logger } from "matrix-js-sdk/lib/logger";
|
import { type Logger } from "matrix-js-sdk/lib/logger";
|
||||||
|
import E2EEWorker from "livekit-client/e2ee-worker?worker";
|
||||||
|
|
||||||
import { type ObservableScope } from "../../ObservableScope.ts";
|
import { type ObservableScope } from "../../ObservableScope.ts";
|
||||||
import { Connection } from "./Connection.ts";
|
import { Connection } from "./Connection.ts";
|
||||||
@@ -46,7 +48,7 @@ export class ECConnectionFactory implements ConnectionFactory {
|
|||||||
private client: OpenIDClientParts,
|
private client: OpenIDClientParts,
|
||||||
private devices: MediaDevices,
|
private devices: MediaDevices,
|
||||||
private processorState$: Behavior<ProcessorState>,
|
private processorState$: Behavior<ProcessorState>,
|
||||||
private e2eeLivekitOptions: E2EEOptions | undefined,
|
livekitKeyProvider: BaseKeyProvider | undefined,
|
||||||
private controlledAudioDevices: boolean,
|
private controlledAudioDevices: boolean,
|
||||||
livekitRoomFactory?: () => LivekitRoom,
|
livekitRoomFactory?: () => LivekitRoom,
|
||||||
) {
|
) {
|
||||||
@@ -55,7 +57,12 @@ export class ECConnectionFactory implements ConnectionFactory {
|
|||||||
generateRoomOption(
|
generateRoomOption(
|
||||||
this.devices,
|
this.devices,
|
||||||
this.processorState$.value,
|
this.processorState$.value,
|
||||||
this.e2eeLivekitOptions,
|
livekitKeyProvider && {
|
||||||
|
keyProvider: livekitKeyProvider,
|
||||||
|
// It's important that every room use a separate E2EE worker.
|
||||||
|
// They get confused if given streams from multiple rooms.
|
||||||
|
worker: new E2EEWorker(),
|
||||||
|
},
|
||||||
this.controlledAudioDevices,
|
this.controlledAudioDevices,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user