Handle embedding

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2023-08-30 11:37:37 +02:00
parent fa5b014abe
commit b45c8924a6
13 changed files with 124 additions and 58 deletions
+17 -11
View File
@@ -15,11 +15,7 @@ limitations under the License.
*/
import { logger } from "@sentry/utils";
import {
BaseKeyProvider,
KeyProviderOptions,
createKeyMaterialFromString,
} from "livekit-client";
import { BaseKeyProvider, createKeyMaterialFromString } from "livekit-client";
import { CallMembership } from "matrix-js-sdk/src/matrixrtc/CallMembership";
import {
MatrixRTCSession,
@@ -27,19 +23,29 @@ import {
} from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
export class MatrixKeyProvider extends BaseKeyProvider {
constructor(
private rtcSession: MatrixRTCSession,
keyProviderOptions: Partial<KeyProviderOptions> = {}
) {
super(keyProviderOptions);
private rtcSession?: MatrixRTCSession;
const encryptionKey = this.rtcSession.activeEncryptionKey;
public setRTCSession(rtcSession: MatrixRTCSession) {
const encryptionKey = rtcSession.activeEncryptionKey;
if (!encryptionKey) {
throw new Error(
"MatrixKeyProvider requires the given MatrixRTCSession to have an activeEncryptionKey"
);
}
if (this.rtcSession) {
this.rtcSession.off(
MatrixRTCSessionEvent.MembershipsChanged,
this.onMemberShipsChanged
);
this.rtcSession.off(
MatrixRTCSessionEvent.ActiveEncryptionKeyChanged,
this.onEncryptionKeyChanged
);
}
this.rtcSession = rtcSession;
this.rtcSession.on(
MatrixRTCSessionEvent.MembershipsChanged,
this.onMemberShipsChanged