mirror of
https://github.com/vector-im/element-call.git
synced 2026-10-16 23:45:50 +00:00
renames and restructure
- session -> matrixrtc (folder) - move MatrixRtcClient to top level of sdk - RtcTransport -> Transport - backend -> media-backend
This commit is contained in:
@@ -18,11 +18,11 @@ import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/En
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { combineLatest, filter, from, fromEvent, map, Observable } from "rxjs";
|
||||
|
||||
import { defaultSessionTimings, MatrixRTCMode } from "../config";
|
||||
import { E2eeType } from "../encryption";
|
||||
import { type ObservableScope } from "../reactive/ObservableScope";
|
||||
import { filterBehavior, generateItems } from "../reactive/observable";
|
||||
import { mapScoped } from "../utils/mapScoped";
|
||||
import { defaultSessionTimings, MatrixRTCMode } from "./config";
|
||||
import { E2eeType } from "./encryption";
|
||||
import { type ObservableScope } from "./reactive/ObservableScope";
|
||||
import { filterBehavior, generateItems } from "./reactive/observable";
|
||||
import { mapScoped } from "./utils/mapScoped";
|
||||
import {
|
||||
type DataMessage,
|
||||
type LocalMediaInputs,
|
||||
@@ -30,33 +30,36 @@ import {
|
||||
type MatrixRTCClient,
|
||||
type MatrixRTCClientOptions,
|
||||
type RemoteRTCMember,
|
||||
} from "../api";
|
||||
} from "./api";
|
||||
import {
|
||||
type MediaBackend,
|
||||
type MediaBackendContext,
|
||||
type MediaKey,
|
||||
} from "../backend/api";
|
||||
import { createLivekitBackend } from "../backend/livekit/LivekitBackend";
|
||||
import { MatrixRTCError } from "../errors";
|
||||
import { createHomeserverConnected$ } from "./HomeserverConnected";
|
||||
import { joinJsSdkSession } from "./joinJsSdkSession";
|
||||
import { createLocalMembership$, type PreparedTransport } from "./LocalMember";
|
||||
import { discoverLocalTransport } from "./LocalTransport";
|
||||
} from "./media-backend/api";
|
||||
import { createLivekitBackend } from "./media-backend/livekit/LivekitBackend";
|
||||
import { MatrixRTCError } from "./errors";
|
||||
import { createHomeserverConnected$ } from "./matrixrtc/HomeserverConnected";
|
||||
import { joinJsSdkSession } from "./matrixrtc/joinJsSdkSession";
|
||||
import {
|
||||
createLocalMembership$,
|
||||
type PreparedTransport,
|
||||
} from "./matrixrtc/LocalMember";
|
||||
import { discoverLocalTransport } from "./matrixrtc/LocalTransport";
|
||||
import {
|
||||
createMatrixMemberMetadata$,
|
||||
createRoomMembers$,
|
||||
} from "./MatrixMemberMetadata";
|
||||
} from "./matrixrtc/MatrixMemberMetadata";
|
||||
import {
|
||||
createLocalRTCMember,
|
||||
createRemoteRTCMember,
|
||||
membershipKeys,
|
||||
} from "./Members";
|
||||
} from "./matrixrtc/Members";
|
||||
import {
|
||||
createKeyRotationSuppressed$,
|
||||
createMemberships$,
|
||||
} from "./SessionBehaviors";
|
||||
import { fatalError, sessionStatus } from "./status";
|
||||
import { createTransportRegistry } from "./Transports";
|
||||
} from "./matrixrtc/JsRtcSessionBehaviors";
|
||||
import { fatalError, sessionStatus } from "./matrixrtc/status";
|
||||
import { createTransportRegistry } from "./matrixrtc/Transports";
|
||||
|
||||
/**
|
||||
* Takes the whole `MatrixClient` rather than a slice of it, and finds the
|
||||
+2
-2
@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The public types of the SDK. `createMatrixRTCClient` in `session/MatrixRTCClient.ts`
|
||||
* The public types of the SDK. `createMatrixRTCClient` in `MatrixRTCClient.ts`
|
||||
* is the only way to obtain an implementation of them.
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
import { type Observable } from "rxjs";
|
||||
|
||||
import { type Behavior } from "./reactive/Behavior";
|
||||
import { type MediaBackendFactory } from "./backend/api";
|
||||
import { type MediaBackendFactory } from "./media-backend/api";
|
||||
import { type EncryptionSystem } from "./encryption";
|
||||
import {
|
||||
type MatrixRTCMode,
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import { MatrixRTCSessionEvent } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
import { createKeyRotationSuppressed$ } from "./SessionBehaviors";
|
||||
import { createKeyRotationSuppressed$ } from "./JsRtcSessionBehaviors";
|
||||
import { testScope } from "../utils/test";
|
||||
|
||||
describe("SessionBehaviors", () => {
|
||||
describe("JsRtcSessionBehaviors", () => {
|
||||
describe("createKeyRotationSuppressed$", () => {
|
||||
it("emits initial value from isKeyRotationSuppressed and updates when KeyRotationSuppressedChanged event is emitted", () => {
|
||||
const scope = testScope();
|
||||
@@ -12,7 +12,10 @@ import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { defaultSessionTimings } from "../config";
|
||||
import { MatrixRTCError } from "../errors";
|
||||
import { type LocalMediaBackend, MediaConnectionState } from "../backend/api";
|
||||
import {
|
||||
type LocalMediaBackend,
|
||||
MediaConnectionState,
|
||||
} from "../media-backend/api";
|
||||
import { type HomeserverConnected } from "./HomeserverConnected";
|
||||
import {
|
||||
createLocalMembership$,
|
||||
@@ -42,7 +42,7 @@ import {
|
||||
type MediaBackend,
|
||||
MediaConnectionState,
|
||||
type TransportCapabilities,
|
||||
} from "../backend/api";
|
||||
} from "../media-backend/api";
|
||||
import { type HomeserverConnected } from "./HomeserverConnected";
|
||||
|
||||
export enum TransportState {
|
||||
@@ -11,7 +11,7 @@ import { type Transport } from "matrix-js-sdk/lib/matrixrtc";
|
||||
|
||||
import { type MatrixRTCClientOptions } from "../api";
|
||||
import { MatrixRTCTransportMissingError } from "../errors";
|
||||
import { RtcTransportAutoDiscovery } from "./RtcTransportAutoDiscovery";
|
||||
import { TransportAutoDiscovery } from "./TransportAutoDiscovery";
|
||||
|
||||
/**
|
||||
* The transport the local member advertises: the one the host names, else the
|
||||
@@ -32,7 +32,7 @@ export async function discoverLocalTransport(
|
||||
): Promise<Transport> {
|
||||
const transport = transportUrl
|
||||
? { type: "livekit", livekit_service_url: transportUrl }
|
||||
: await new RtcTransportAutoDiscovery({
|
||||
: await new TransportAutoDiscovery({
|
||||
client,
|
||||
transportType,
|
||||
fallbackTransportUrl,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
type RemoteRTCMember,
|
||||
type RTCMember,
|
||||
} from "../api";
|
||||
import { type LocalMediaBackend } from "../backend/api";
|
||||
import { type LocalMediaBackend } from "../media-backend/api";
|
||||
import { type TransportRegistry } from "./Transports";
|
||||
|
||||
/** What every member is built from, besides its own membership and media. */
|
||||
+9
-9
@@ -21,11 +21,11 @@ import {
|
||||
} from "matrix-js-sdk/lib/matrixrtc";
|
||||
|
||||
import {
|
||||
RtcTransportAutoDiscovery,
|
||||
type RtcTransportAutoDiscoveryProps,
|
||||
} from "./RtcTransportAutoDiscovery.ts";
|
||||
TransportAutoDiscovery,
|
||||
type TransportAutoDiscoveryProps,
|
||||
} from "./TransportAutoDiscovery.ts";
|
||||
|
||||
type DiscoveryClient = RtcTransportAutoDiscoveryProps["client"];
|
||||
type DiscoveryClient = TransportAutoDiscoveryProps["client"];
|
||||
|
||||
const backendTransport: LivekitTransport = {
|
||||
type: "livekit",
|
||||
@@ -47,7 +47,7 @@ function makeClient(): MockedObject<DiscoveryClient> {
|
||||
} as unknown as MockedObject<DiscoveryClient>;
|
||||
}
|
||||
|
||||
describe("RtcTransportAutoDiscovery", () => {
|
||||
describe("TransportAutoDiscovery", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
@@ -62,7 +62,7 @@ describe("RtcTransportAutoDiscovery", () => {
|
||||
const client = makeClient();
|
||||
client._unstable_getRTCTransports.mockResolvedValue(transports);
|
||||
|
||||
const discovery = new RtcTransportAutoDiscovery({
|
||||
const discovery = new TransportAutoDiscovery({
|
||||
client,
|
||||
transportType: "livekit",
|
||||
fallbackTransportUrl: configTransport.livekit_service_url,
|
||||
@@ -93,7 +93,7 @@ describe("RtcTransportAutoDiscovery", () => {
|
||||
)
|
||||
.mockResolvedValue([backendTransport]);
|
||||
|
||||
const discovery = new RtcTransportAutoDiscovery({
|
||||
const discovery = new TransportAutoDiscovery({
|
||||
client,
|
||||
transportType: "livekit",
|
||||
fallbackTransportUrl: "https://config.example.org",
|
||||
@@ -117,7 +117,7 @@ describe("RtcTransportAutoDiscovery", () => {
|
||||
const client = makeClient();
|
||||
client._unstable_getRTCTransports.mockResolvedValue(transports);
|
||||
|
||||
const discovery = new RtcTransportAutoDiscovery({
|
||||
const discovery = new TransportAutoDiscovery({
|
||||
client,
|
||||
transportType: "livekit",
|
||||
fallbackTransportUrl: configTransport.livekit_service_url,
|
||||
@@ -134,7 +134,7 @@ describe("RtcTransportAutoDiscovery", () => {
|
||||
const client = makeClient();
|
||||
client._unstable_getRTCTransports.mockResolvedValue([]);
|
||||
|
||||
const discovery = new RtcTransportAutoDiscovery({
|
||||
const discovery = new TransportAutoDiscovery({
|
||||
client,
|
||||
transportType: "livekit",
|
||||
fallbackTransportUrl: undefined,
|
||||
+4
-4
@@ -15,7 +15,7 @@ type TransportDiscoveryClient = Pick<
|
||||
"getDomain" | "_unstable_getRTCTransports"
|
||||
>;
|
||||
|
||||
export interface RtcTransportAutoDiscoveryProps {
|
||||
export interface TransportAutoDiscoveryProps {
|
||||
client: TransportDiscoveryClient;
|
||||
/** The transport type the media backend serves. */
|
||||
transportType: string;
|
||||
@@ -24,7 +24,7 @@ export interface RtcTransportAutoDiscoveryProps {
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
export class RtcTransportAutoDiscovery {
|
||||
export class TransportAutoDiscovery {
|
||||
private readonly client: TransportDiscoveryClient;
|
||||
private readonly transportType: string;
|
||||
private readonly fallbackTransportUrl: string | undefined;
|
||||
@@ -35,11 +35,11 @@ export class RtcTransportAutoDiscovery {
|
||||
transportType,
|
||||
fallbackTransportUrl,
|
||||
logger,
|
||||
}: RtcTransportAutoDiscoveryProps) {
|
||||
}: TransportAutoDiscoveryProps) {
|
||||
this.client = client;
|
||||
this.transportType = transportType;
|
||||
this.fallbackTransportUrl = fallbackTransportUrl;
|
||||
this.logger = logger.getChild("[RtcTransportAutoDiscovery]");
|
||||
this.logger = logger.getChild("[TransportAutoDiscovery]");
|
||||
}
|
||||
|
||||
public async discoverPreferredTransport(): Promise<Transport | null> {
|
||||
@@ -10,7 +10,10 @@ import { BehaviorSubject } from "rxjs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { type ResolvedTransport } from "../api";
|
||||
import { type BackendConnection, MediaConnectionState } from "../backend/api";
|
||||
import {
|
||||
type BackendConnection,
|
||||
MediaConnectionState,
|
||||
} from "../media-backend/api";
|
||||
import { testScope } from "../utils/test";
|
||||
import { createTransportRegistry, transportId } from "./Transports";
|
||||
|
||||
@@ -11,7 +11,7 @@ import { distinctUntilChanged, map } from "rxjs";
|
||||
import { type Behavior } from "../reactive/Behavior";
|
||||
import { type ObservableScope } from "../reactive/ObservableScope";
|
||||
import { type TransportMetadata } from "../api";
|
||||
import { type MediaBackend, MediaConnectionState } from "../backend/api";
|
||||
import { type MediaBackend, MediaConnectionState } from "../media-backend/api";
|
||||
|
||||
export interface TransportRegistry {
|
||||
/** The one `TransportMetadata` for a transport, however many memberships name it. */
|
||||
@@ -8,7 +8,7 @@ Please see LICENSE in the repository root for full details.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { Status } from "matrix-js-sdk/lib/matrixrtc";
|
||||
|
||||
import { MediaConnectionState } from "../backend/api";
|
||||
import { MediaConnectionState } from "../media-backend/api";
|
||||
import { MatrixRTCError } from "../api";
|
||||
import {
|
||||
type LocalMemberState,
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
daveRTL,
|
||||
} from "./test-fixtures";
|
||||
import { mockMatrixRoom } from "./test";
|
||||
import { roomToMembersMap } from "../session/MatrixMemberMetadata";
|
||||
import { roomToMembersMap } from "../matrixrtc/MatrixMemberMetadata";
|
||||
|
||||
describe("shouldDisambiguate", () => {
|
||||
test("should not disambiguate a solo member", () => {
|
||||
|
||||
Reference in New Issue
Block a user