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:
@@ -22,8 +22,8 @@ const BANNED_PACKAGES = [
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Packages only a media backend may import. The session speaks MatrixRTC and
|
* Packages only a media backend may import. The session speaks MatrixRTC and
|
||||||
* sees media through `sdk/src/backend/api.ts`; a backend under
|
* sees media through `sdk/src/media-backend/api.ts`; a backend under
|
||||||
* `sdk/src/backend/<name>/` is the one place its protocol's library appears.
|
* `sdk/src/media-backend/<name>/` is the one place its protocol's library appears.
|
||||||
*/
|
*/
|
||||||
const BACKEND_PACKAGES = ["livekit-client", "@livekit/"];
|
const BACKEND_PACKAGES = ["livekit-client", "@livekit/"];
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ const BACKEND_PACKAGES = ["livekit-client", "@livekit/"];
|
|||||||
* outside `sdk/` by relative path (that is `src/`, `component/`,
|
* outside `sdk/` by relative path (that is `src/`, `component/`,
|
||||||
* `playwright/`) or one of the packages above. The development harness under
|
* `playwright/`) or one of the packages above. The development harness under
|
||||||
* `sdk/dev/` is a host, not part of the library, and is exempt. Keeps the
|
* `sdk/dev/` is a host, not part of the library, and is exempt. Keeps the
|
||||||
* session free of any one media backend, too: outside `sdk/src/backend/`,
|
* session free of any one media backend, too: outside `sdk/src/media-backend/`,
|
||||||
* a backend's packages may only be imported for their types, and only in
|
* a backend's packages may only be imported for their types, and only in
|
||||||
* the public API, the errors and the test helpers that have to name them.
|
* the public API, the errors and the test helpers that have to name them.
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +52,7 @@ const rule = ESLintUtils.RuleCreator(
|
|||||||
bannedPackage:
|
bannedPackage:
|
||||||
"The SDK must not import '{{specifier}}': a host supplies that, the SDK has no UI.",
|
"The SDK must not import '{{specifier}}': a host supplies that, the SDK has no UI.",
|
||||||
backendPackage:
|
backendPackage:
|
||||||
"Only a media backend under sdk/src/backend/ may import '{{specifier}}'; the session sees media through backend/api.ts.",
|
"Only a media backend under sdk/src/media-backend/ may import '{{specifier}}'; the session sees media through media-backend/api.ts.",
|
||||||
},
|
},
|
||||||
schema: [],
|
schema: [],
|
||||||
},
|
},
|
||||||
@@ -63,7 +63,7 @@ const rule = ESLintUtils.RuleCreator(
|
|||||||
if (!filename.startsWith(sdkRoot)) return {};
|
if (!filename.startsWith(sdkRoot)) return {};
|
||||||
if (filename.startsWith(resolve(sdkRoot, "dev") + sep)) return {};
|
if (filename.startsWith(resolve(sdkRoot, "dev") + sep)) return {};
|
||||||
const inBackend = filename.startsWith(
|
const inBackend = filename.startsWith(
|
||||||
resolve(sdkRoot, "src", "backend") + sep,
|
resolve(sdkRoot, "src", "media-backend") + sep,
|
||||||
);
|
);
|
||||||
|
|
||||||
const matchesPackage = (specifier, pkg) =>
|
const matchesPackage = (specifier, pkg) =>
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ the media of every member, as observables. It has no UI. Element Call's own
|
|||||||
`CallViewModel` is meant to become one consumer of it. The design is in
|
`CallViewModel` is meant to become one consumer of it. The design is in
|
||||||
[`SdkArchitecture.md`](./SdkArchitecture.md), the migration from the view model
|
[`SdkArchitecture.md`](./SdkArchitecture.md), the migration from the view model
|
||||||
in [`SdkMigration.md`](./SdkMigration.md). Media goes through one media backend
|
in [`SdkMigration.md`](./SdkMigration.md). Media goes through one media backend
|
||||||
behind `MediaBackend`; LiveKit, under `src/backend/livekit/`, is the only one
|
behind `MediaBackend`; LiveKit, under `src/media-backend/livekit/`, is the only one
|
||||||
today and the only place that imports `livekit-client`.
|
today and the only place that imports `livekit-client`.
|
||||||
|
|
||||||
**Status:** first implementation. `createMatrixRTCClient` joins the session, connects to
|
**Status:** first implementation. `createMatrixRTCClient` joins the session, connects to
|
||||||
|
|||||||
+25
-23
@@ -64,10 +64,10 @@ therefore `Element Call → sdk`, never the reverse. The migration from today's
|
|||||||
The left box is MatrixRTC: who is in the session, with which transport, the
|
The left box is MatrixRTC: who is in the session, with which transport, the
|
||||||
keys, the delayed leave, and the join state machine. The right box is a media
|
keys, the delayed leave, and the join state machine. The right box is a media
|
||||||
backend: whatever carries the media, behind the `MediaBackend` interface in
|
backend: whatever carries the media, behind the `MediaBackend` interface in
|
||||||
`sdk/src/backend/api.ts`. The client is the join of the two: a member exists
|
`sdk/src/media-backend/api.ts`. The client is the join of the two: a member exists
|
||||||
once its membership does, and gets its media once the backend has something
|
once its membership does, and gets its media once the backend has something
|
||||||
for that membership on its transport. LiveKit is the one backend today; a
|
for that membership on its transport. LiveKit is the one backend today; a
|
||||||
cascading SFU or full mesh is another folder under `sdk/src/backend/`, handed
|
cascading SFU or full mesh is another folder under `sdk/src/media-backend/`, handed
|
||||||
in through `options.backend`, and nothing in the left box changes.
|
in through `options.backend`, and nothing in the left box changes.
|
||||||
|
|
||||||
### How Element Call uses it
|
### How Element Call uses it
|
||||||
@@ -127,20 +127,20 @@ it, and `leave()` also sends the leave.
|
|||||||
|
|
||||||
## Vocabulary
|
## Vocabulary
|
||||||
|
|
||||||
| Word | Meaning here | Elsewhere |
|
| Word | Meaning here | Elsewhere |
|
||||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
||||||
| client | a `MatrixRTCClient`: one room, one slot, one local member | `MatrixClient` is always written out |
|
| client | a `MatrixRTCClient`: one room, one slot, one local member | `MatrixClient` is always written out |
|
||||||
| membership | one device's MatrixRTC state event, seen by hosts as `RTCMembership`, the js-sdk `CallMembership` behind it | |
|
| membership | one device's MatrixRTC state event, seen by hosts as `RTCMembership`, the js-sdk `CallMembership` behind it | |
|
||||||
| member | an `RTCMember`: a membership plus what the SDK derives from it (display name, transport, media) | Element Call's "matrixLivekitMember" |
|
| member | an `RTCMember`: a membership plus what the SDK derives from it (display name, transport, media) | Element Call's "matrixLivekitMember" |
|
||||||
| media | a `MemberMedia`: what a member sends, once it has arrived on its transport. `null` while waiting for media | Element Call's `MediaViewModel` is a view of it |
|
| media | a `MemberMedia`: what a member sends, once it has arrived on its transport. `null` while waiting for media | Element Call's `MediaViewModel` is a view of it |
|
||||||
| track | a `MediaTrack`: one publication of a member, audio or video, with `source`, `kind`, `id` and the behaviors on it. `LocalAudioMediaTrack` and `LocalVideoMediaTrack` add the controls over our own | LiveKit `TrackPublication` and `Track`, which never leave the SDK |
|
| track | a `MediaTrack`: one publication of a member, audio or video, with `source`, `kind`, `id` and the behaviors on it. `LocalAudioMediaTrack` and `LocalVideoMediaTrack` add the controls over our own | LiveKit `TrackPublication` and `Track`, which never leave the SDK |
|
||||||
| source | a `MediaSource`: what a track is captured from, `microphone`, `camera`, `screenShare`, `screenShareAudio` or `unknown`. Picked out of `tracks$` with `trackBySource$` | LiveKit `Track.Source` |
|
| source | a `MediaSource`: what a track is captured from, `microphone`, `camera`, `screenShare`, `screenShareAudio` or `unknown`. Picked out of `tracks$` with `trackBySource$` | LiveKit `Track.Source` |
|
||||||
| publish request | a `PublishRequest`: a source, where to capture it from and how to encode it. Given at the join in `LocalMediaInputs.publish`, or later to `publish` on the local member | |
|
| publish request | a `PublishRequest`: a source, where to capture it from and how to encode it. Given at the join in `LocalMediaInputs.publish`, or later to `publish` on the local member | |
|
||||||
| active | `isActive$` on an audio track: the track carries sound, as the backend measures it. "Speaking" is a call's reading of it on the microphone track | LiveKit "speaking", `isSpeaking` |
|
| active | `isActive$` on an audio track: the track carries sound, as the backend measures it. "Speaking" is a call's reading of it on the microphone track | LiveKit "speaking", `isSpeaking` |
|
||||||
| attach, detach | handing a `<video>` or `<audio>` element to a track and taking it back. The SDK owns the stream and the observers on the element | LiveKit `Track.attach` |
|
| attach, detach | handing a `<video>` or `<audio>` element to a track and taking it back. The SDK owns the stream and the observers on the element | LiveKit `Track.attach` |
|
||||||
| transport | where media is exchanged: a LiveKit service url today, described by `TransportMetadata` | MSC4143 "focus" |
|
| transport | where media is exchanged: a LiveKit service url today, described by `TransportMetadata` | MSC4143 "focus" |
|
||||||
| media backend | a `MediaBackend`: what carries the media, behind `sdk/src/backend/api.ts`. One per client, chosen with `options.backend`; LiveKit under `sdk/src/backend/livekit/` is the one that exists | "SFU", a LiveKit room, a peer connection |
|
| media backend | a `MediaBackend`: what carries the media, behind `sdk/src/media-backend/api.ts`. One per client, chosen with `options.backend`; LiveKit under `sdk/src/media-backend/livekit/` is the one that exists | "SFU", a LiveKit room, a peer connection |
|
||||||
| application, slot | what the session is for (`m.call`) and which one of them in the room (`ROOM`) | MSC4143 |
|
| application, slot | what the session is for (`m.call`) and which one of them in the room (`ROOM`) | MSC4143 |
|
||||||
|
|
||||||
Names use `RTC` in capitals, as the js-sdk does: `MatrixRTCClient`, `RTCMember`,
|
Names use `RTC` in capitals, as the js-sdk does: `MatrixRTCClient`, `RTCMember`,
|
||||||
`matrixRTCMode`.
|
`matrixRTCMode`.
|
||||||
@@ -489,10 +489,10 @@ call-specific.
|
|||||||
|
|
||||||
The client speaks MatrixRTC: memberships, the transports named in them, the
|
The client speaks MatrixRTC: memberships, the transports named in them, the
|
||||||
delayed leave, the keys. What carries the media is a backend behind one
|
delayed leave, the keys. What carries the media is a backend behind one
|
||||||
interface, `MediaBackend` in `sdk/src/backend/api.ts`, created once per client.
|
interface, `MediaBackend` in `sdk/src/media-backend/api.ts`, created once per client.
|
||||||
LiveKit under `sdk/src/backend/livekit/` is the only backend today, and the only
|
LiveKit under `sdk/src/media-backend/livekit/` is the only backend today, and the only
|
||||||
place in the SDK that imports `livekit-client`; the import boundary lint rule
|
place in the SDK that imports `livekit-client`; the import boundary lint rule
|
||||||
enforces that outside `sdk/src/backend/` the LiveKit packages appear in type
|
enforces that outside `sdk/src/media-backend/` the LiveKit packages appear in type
|
||||||
imports only.
|
imports only.
|
||||||
|
|
||||||
The seam sits above the connection manager on purpose. One connection per
|
The seam sits above the connection manager on purpose. One connection per
|
||||||
@@ -547,7 +547,7 @@ Every member has media. Today, in Element Call, that media _is_ a `livekit-clien
|
|||||||
participant, handed straight through to the view models. In the SDK the participant
|
participant, handed straight through to the view models. In the SDK the participant
|
||||||
is wrapped in a `MemberMedia`, so that nothing outside the SDK imports
|
is wrapped in a `MemberMedia`, so that nothing outside the SDK imports
|
||||||
`Participant`, `TrackPublication`, `Track` or `TrackReference`. The adapter in
|
`Participant`, `TrackPublication`, `Track` or `TrackReference`. The adapter in
|
||||||
`sdk/src/media/` is the only place that reads a participant.
|
`sdk/src/media-backend/livekit/` is the only place that reads a participant.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
export type MediaSource =
|
export type MediaSource =
|
||||||
@@ -709,10 +709,12 @@ sdk/
|
|||||||
src/errors.ts MatrixRTCError and its codes
|
src/errors.ts MatrixRTCError and its codes
|
||||||
src/config.ts MatrixRTCMode, session timings, media quality
|
src/config.ts MatrixRTCMode, session timings, media quality
|
||||||
src/encryption.ts E2eeType, EncryptionSystem
|
src/encryption.ts E2eeType, EncryptionSystem
|
||||||
|
src/MatrixRTCClient.ts createMatrixRTCClient: wires the two folders below
|
||||||
src/reactive/ Behavior, ObservableScope, the observable operators
|
src/reactive/ Behavior, ObservableScope, the observable operators
|
||||||
src/session/ MatrixRTCClient, the local member, publisher, connections,
|
src/matrixrtc/ the MatrixRTC side: the local member, memberships, member
|
||||||
memberships, transports, discovery, JWT, join
|
metadata, transports, discovery, status, the js-sdk join
|
||||||
src/media/ the LiveKit adapter: MemberMedia and MediaTrack
|
src/media-backend/ the MediaBackend interface in api.ts; livekit/ is the one
|
||||||
|
backend: connections, publisher, JWT, keys, MemberMedia, MediaTrack
|
||||||
src/utils/ LazyBehavior, mapScoped, network retry, display names, test helpers
|
src/utils/ LazyBehavior, mapScoped, network retry, display names, test helpers
|
||||||
dev/ the harness (below)
|
dev/ the harness (below)
|
||||||
SdkArchitecture.md this document
|
SdkArchitecture.md this document
|
||||||
|
|||||||
+8
-8
@@ -8,14 +8,14 @@ symbols, so it ages with the code; the architecture document should not.
|
|||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
| Slice | State |
|
| Slice | State |
|
||||||
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
|
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
|
||||||
| 1. Scaffold: `sdk/` packaging, the interface, the harness, the smoke test | done, October 2026 |
|
| 1. Scaffold: `sdk/` packaging, the interface, the harness, the smoke test | done, October 2026 |
|
||||||
| 2. First implementation of `createMatrixRTCClient` under `sdk/src`, the media adapter, the e2e suite | done, 1 October 2026 |
|
| 2. First implementation of `createMatrixRTCClient` under `sdk/src`, the media adapter, the e2e suite | done, 1 October 2026 |
|
||||||
| 3. Copy the shared modules into `sdk/src/` with their tests, drop every `src/` import, turn on the import boundary | done, 2 October 2026 |
|
| 3. Copy the shared modules into `sdk/src/` with their tests, drop every `src/` import, turn on the import boundary | done, 2 October 2026 |
|
||||||
| 4. `createCallViewModel$` consumes the client; media view models take `media$`; Element Call imports the primitives and enums from the SDK and deletes its own copies | done, 2 October 2026 |
|
| 4. `createCallViewModel$` consumes the client; media view models take `media$`; Element Call imports the primitives and enums from the SDK and deletes its own copies | done, 2 October 2026 |
|
||||||
| 5. `sendData`/`data$` on the client; the legacy bundle `sdk-target-based-on-call-view-model/` is rebuilt on the SDK with its interface unchanged, since it is in production use | done, 2 October 2026 |
|
| 5. `sendData`/`data$` on the client; the legacy bundle `sdk-target-based-on-call-view-model/` is rebuilt on the SDK with its interface unchanged, since it is in production use | done, 2 October 2026 |
|
||||||
| 12. The media backend seam: everything LiveKit behind `MediaBackend` in `sdk/src/backend/livekit/`, the `backend` option, the lint guard; see [`MediaBackendPlan.md`](./MediaBackendPlan.md) | done, 4 October 2026 |
|
| 12. The media backend seam: everything LiveKit behind `MediaBackend` in `sdk/src/media-backend/livekit/`, the `backend` option, the lint guard; see [`MediaBackendPlan.md`](./MediaBackendPlan.md) | done, 4 October 2026 |
|
||||||
|
|
||||||
Element Call now consumes the SDK. `InCallView` creates the client from the
|
Element Call now consumes the SDK. `InCallView` creates the client from the
|
||||||
configuration, settings and URL parameters, and hands it to `createCallViewModel$`,
|
configuration, settings and URL parameters, and hands it to `createCallViewModel$`,
|
||||||
|
|||||||
+4
-4
@@ -53,15 +53,15 @@ export {
|
|||||||
} from "./src/errors";
|
} from "./src/errors";
|
||||||
|
|
||||||
export * from "./src/api";
|
export * from "./src/api";
|
||||||
export * from "./src/backend/api";
|
export * from "./src/media-backend/api";
|
||||||
export { trackBySource$, type TrackOfSource } from "./src/utils/tracks";
|
export { trackBySource$, type TrackOfSource } from "./src/utils/tracks";
|
||||||
export { createMatrixRTCClient } from "./src/session/MatrixRTCClient";
|
export { createMatrixRTCClient } from "./src/MatrixRTCClient";
|
||||||
export {
|
export {
|
||||||
createLivekitBackend,
|
createLivekitBackend,
|
||||||
type LivekitBackendOptions,
|
type LivekitBackendOptions,
|
||||||
} from "./src/backend/livekit/LivekitBackend";
|
} from "./src/media-backend/livekit/LivekitBackend";
|
||||||
// For a developer panel to check a transport url before using it
|
// For a developer panel to check a transport url before using it
|
||||||
export {
|
export {
|
||||||
getSFUConfigWithOpenID as authenticateWithTransport,
|
getSFUConfigWithOpenID as authenticateWithTransport,
|
||||||
type TokenEndpoint,
|
type TokenEndpoint,
|
||||||
} from "./src/backend/livekit/openIDSFU";
|
} from "./src/media-backend/livekit/openIDSFU";
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/En
|
|||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import { combineLatest, filter, from, fromEvent, map, Observable } from "rxjs";
|
import { combineLatest, filter, from, fromEvent, map, Observable } from "rxjs";
|
||||||
|
|
||||||
import { defaultSessionTimings, MatrixRTCMode } from "../config";
|
import { defaultSessionTimings, MatrixRTCMode } from "./config";
|
||||||
import { E2eeType } from "../encryption";
|
import { E2eeType } from "./encryption";
|
||||||
import { type ObservableScope } from "../reactive/ObservableScope";
|
import { type ObservableScope } from "./reactive/ObservableScope";
|
||||||
import { filterBehavior, generateItems } from "../reactive/observable";
|
import { filterBehavior, generateItems } from "./reactive/observable";
|
||||||
import { mapScoped } from "../utils/mapScoped";
|
import { mapScoped } from "./utils/mapScoped";
|
||||||
import {
|
import {
|
||||||
type DataMessage,
|
type DataMessage,
|
||||||
type LocalMediaInputs,
|
type LocalMediaInputs,
|
||||||
@@ -30,33 +30,36 @@ import {
|
|||||||
type MatrixRTCClient,
|
type MatrixRTCClient,
|
||||||
type MatrixRTCClientOptions,
|
type MatrixRTCClientOptions,
|
||||||
type RemoteRTCMember,
|
type RemoteRTCMember,
|
||||||
} from "../api";
|
} from "./api";
|
||||||
import {
|
import {
|
||||||
type MediaBackend,
|
type MediaBackend,
|
||||||
type MediaBackendContext,
|
type MediaBackendContext,
|
||||||
type MediaKey,
|
type MediaKey,
|
||||||
} from "../backend/api";
|
} from "./media-backend/api";
|
||||||
import { createLivekitBackend } from "../backend/livekit/LivekitBackend";
|
import { createLivekitBackend } from "./media-backend/livekit/LivekitBackend";
|
||||||
import { MatrixRTCError } from "../errors";
|
import { MatrixRTCError } from "./errors";
|
||||||
import { createHomeserverConnected$ } from "./HomeserverConnected";
|
import { createHomeserverConnected$ } from "./matrixrtc/HomeserverConnected";
|
||||||
import { joinJsSdkSession } from "./joinJsSdkSession";
|
import { joinJsSdkSession } from "./matrixrtc/joinJsSdkSession";
|
||||||
import { createLocalMembership$, type PreparedTransport } from "./LocalMember";
|
import {
|
||||||
import { discoverLocalTransport } from "./LocalTransport";
|
createLocalMembership$,
|
||||||
|
type PreparedTransport,
|
||||||
|
} from "./matrixrtc/LocalMember";
|
||||||
|
import { discoverLocalTransport } from "./matrixrtc/LocalTransport";
|
||||||
import {
|
import {
|
||||||
createMatrixMemberMetadata$,
|
createMatrixMemberMetadata$,
|
||||||
createRoomMembers$,
|
createRoomMembers$,
|
||||||
} from "./MatrixMemberMetadata";
|
} from "./matrixrtc/MatrixMemberMetadata";
|
||||||
import {
|
import {
|
||||||
createLocalRTCMember,
|
createLocalRTCMember,
|
||||||
createRemoteRTCMember,
|
createRemoteRTCMember,
|
||||||
membershipKeys,
|
membershipKeys,
|
||||||
} from "./Members";
|
} from "./matrixrtc/Members";
|
||||||
import {
|
import {
|
||||||
createKeyRotationSuppressed$,
|
createKeyRotationSuppressed$,
|
||||||
createMemberships$,
|
createMemberships$,
|
||||||
} from "./SessionBehaviors";
|
} from "./matrixrtc/JsRtcSessionBehaviors";
|
||||||
import { fatalError, sessionStatus } from "./status";
|
import { fatalError, sessionStatus } from "./matrixrtc/status";
|
||||||
import { createTransportRegistry } from "./Transports";
|
import { createTransportRegistry } from "./matrixrtc/Transports";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes the whole `MatrixClient` rather than a slice of it, and finds the
|
* 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.
|
* is the only way to obtain an implementation of them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
import { type Observable } from "rxjs";
|
import { type Observable } from "rxjs";
|
||||||
|
|
||||||
import { type Behavior } from "./reactive/Behavior";
|
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 EncryptionSystem } from "./encryption";
|
||||||
import {
|
import {
|
||||||
type MatrixRTCMode,
|
type MatrixRTCMode,
|
||||||
|
|||||||
+2
-2
@@ -9,10 +9,10 @@ import { describe, expect, it, vi } from "vitest";
|
|||||||
import { MatrixRTCSessionEvent } from "matrix-js-sdk/lib/matrixrtc";
|
import { MatrixRTCSessionEvent } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
|
|
||||||
import { createKeyRotationSuppressed$ } from "./SessionBehaviors";
|
import { createKeyRotationSuppressed$ } from "./JsRtcSessionBehaviors";
|
||||||
import { testScope } from "../utils/test";
|
import { testScope } from "../utils/test";
|
||||||
|
|
||||||
describe("SessionBehaviors", () => {
|
describe("JsRtcSessionBehaviors", () => {
|
||||||
describe("createKeyRotationSuppressed$", () => {
|
describe("createKeyRotationSuppressed$", () => {
|
||||||
it("emits initial value from isKeyRotationSuppressed and updates when KeyRotationSuppressedChanged event is emitted", () => {
|
it("emits initial value from isKeyRotationSuppressed and updates when KeyRotationSuppressedChanged event is emitted", () => {
|
||||||
const scope = testScope();
|
const scope = testScope();
|
||||||
@@ -12,7 +12,10 @@ import { describe, expect, it, vi } from "vitest";
|
|||||||
|
|
||||||
import { defaultSessionTimings } from "../config";
|
import { defaultSessionTimings } from "../config";
|
||||||
import { MatrixRTCError } from "../errors";
|
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 { type HomeserverConnected } from "./HomeserverConnected";
|
||||||
import {
|
import {
|
||||||
createLocalMembership$,
|
createLocalMembership$,
|
||||||
@@ -42,7 +42,7 @@ import {
|
|||||||
type MediaBackend,
|
type MediaBackend,
|
||||||
MediaConnectionState,
|
MediaConnectionState,
|
||||||
type TransportCapabilities,
|
type TransportCapabilities,
|
||||||
} from "../backend/api";
|
} from "../media-backend/api";
|
||||||
import { type HomeserverConnected } from "./HomeserverConnected";
|
import { type HomeserverConnected } from "./HomeserverConnected";
|
||||||
|
|
||||||
export enum TransportState {
|
export enum TransportState {
|
||||||
@@ -11,7 +11,7 @@ import { type Transport } from "matrix-js-sdk/lib/matrixrtc";
|
|||||||
|
|
||||||
import { type MatrixRTCClientOptions } from "../api";
|
import { type MatrixRTCClientOptions } from "../api";
|
||||||
import { MatrixRTCTransportMissingError } from "../errors";
|
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
|
* The transport the local member advertises: the one the host names, else the
|
||||||
@@ -32,7 +32,7 @@ export async function discoverLocalTransport(
|
|||||||
): Promise<Transport> {
|
): Promise<Transport> {
|
||||||
const transport = transportUrl
|
const transport = transportUrl
|
||||||
? { type: "livekit", livekit_service_url: transportUrl }
|
? { type: "livekit", livekit_service_url: transportUrl }
|
||||||
: await new RtcTransportAutoDiscovery({
|
: await new TransportAutoDiscovery({
|
||||||
client,
|
client,
|
||||||
transportType,
|
transportType,
|
||||||
fallbackTransportUrl,
|
fallbackTransportUrl,
|
||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
type RemoteRTCMember,
|
type RemoteRTCMember,
|
||||||
type RTCMember,
|
type RTCMember,
|
||||||
} from "../api";
|
} from "../api";
|
||||||
import { type LocalMediaBackend } from "../backend/api";
|
import { type LocalMediaBackend } from "../media-backend/api";
|
||||||
import { type TransportRegistry } from "./Transports";
|
import { type TransportRegistry } from "./Transports";
|
||||||
|
|
||||||
/** What every member is built from, besides its own membership and media. */
|
/** 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";
|
} from "matrix-js-sdk/lib/matrixrtc";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
RtcTransportAutoDiscovery,
|
TransportAutoDiscovery,
|
||||||
type RtcTransportAutoDiscoveryProps,
|
type TransportAutoDiscoveryProps,
|
||||||
} from "./RtcTransportAutoDiscovery.ts";
|
} from "./TransportAutoDiscovery.ts";
|
||||||
|
|
||||||
type DiscoveryClient = RtcTransportAutoDiscoveryProps["client"];
|
type DiscoveryClient = TransportAutoDiscoveryProps["client"];
|
||||||
|
|
||||||
const backendTransport: LivekitTransport = {
|
const backendTransport: LivekitTransport = {
|
||||||
type: "livekit",
|
type: "livekit",
|
||||||
@@ -47,7 +47,7 @@ function makeClient(): MockedObject<DiscoveryClient> {
|
|||||||
} as unknown as MockedObject<DiscoveryClient>;
|
} as unknown as MockedObject<DiscoveryClient>;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("RtcTransportAutoDiscovery", () => {
|
describe("TransportAutoDiscovery", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
});
|
});
|
||||||
@@ -62,7 +62,7 @@ describe("RtcTransportAutoDiscovery", () => {
|
|||||||
const client = makeClient();
|
const client = makeClient();
|
||||||
client._unstable_getRTCTransports.mockResolvedValue(transports);
|
client._unstable_getRTCTransports.mockResolvedValue(transports);
|
||||||
|
|
||||||
const discovery = new RtcTransportAutoDiscovery({
|
const discovery = new TransportAutoDiscovery({
|
||||||
client,
|
client,
|
||||||
transportType: "livekit",
|
transportType: "livekit",
|
||||||
fallbackTransportUrl: configTransport.livekit_service_url,
|
fallbackTransportUrl: configTransport.livekit_service_url,
|
||||||
@@ -93,7 +93,7 @@ describe("RtcTransportAutoDiscovery", () => {
|
|||||||
)
|
)
|
||||||
.mockResolvedValue([backendTransport]);
|
.mockResolvedValue([backendTransport]);
|
||||||
|
|
||||||
const discovery = new RtcTransportAutoDiscovery({
|
const discovery = new TransportAutoDiscovery({
|
||||||
client,
|
client,
|
||||||
transportType: "livekit",
|
transportType: "livekit",
|
||||||
fallbackTransportUrl: "https://config.example.org",
|
fallbackTransportUrl: "https://config.example.org",
|
||||||
@@ -117,7 +117,7 @@ describe("RtcTransportAutoDiscovery", () => {
|
|||||||
const client = makeClient();
|
const client = makeClient();
|
||||||
client._unstable_getRTCTransports.mockResolvedValue(transports);
|
client._unstable_getRTCTransports.mockResolvedValue(transports);
|
||||||
|
|
||||||
const discovery = new RtcTransportAutoDiscovery({
|
const discovery = new TransportAutoDiscovery({
|
||||||
client,
|
client,
|
||||||
transportType: "livekit",
|
transportType: "livekit",
|
||||||
fallbackTransportUrl: configTransport.livekit_service_url,
|
fallbackTransportUrl: configTransport.livekit_service_url,
|
||||||
@@ -134,7 +134,7 @@ describe("RtcTransportAutoDiscovery", () => {
|
|||||||
const client = makeClient();
|
const client = makeClient();
|
||||||
client._unstable_getRTCTransports.mockResolvedValue([]);
|
client._unstable_getRTCTransports.mockResolvedValue([]);
|
||||||
|
|
||||||
const discovery = new RtcTransportAutoDiscovery({
|
const discovery = new TransportAutoDiscovery({
|
||||||
client,
|
client,
|
||||||
transportType: "livekit",
|
transportType: "livekit",
|
||||||
fallbackTransportUrl: undefined,
|
fallbackTransportUrl: undefined,
|
||||||
+4
-4
@@ -15,7 +15,7 @@ type TransportDiscoveryClient = Pick<
|
|||||||
"getDomain" | "_unstable_getRTCTransports"
|
"getDomain" | "_unstable_getRTCTransports"
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export interface RtcTransportAutoDiscoveryProps {
|
export interface TransportAutoDiscoveryProps {
|
||||||
client: TransportDiscoveryClient;
|
client: TransportDiscoveryClient;
|
||||||
/** The transport type the media backend serves. */
|
/** The transport type the media backend serves. */
|
||||||
transportType: string;
|
transportType: string;
|
||||||
@@ -24,7 +24,7 @@ export interface RtcTransportAutoDiscoveryProps {
|
|||||||
logger: Logger;
|
logger: Logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RtcTransportAutoDiscovery {
|
export class TransportAutoDiscovery {
|
||||||
private readonly client: TransportDiscoveryClient;
|
private readonly client: TransportDiscoveryClient;
|
||||||
private readonly transportType: string;
|
private readonly transportType: string;
|
||||||
private readonly fallbackTransportUrl: string | undefined;
|
private readonly fallbackTransportUrl: string | undefined;
|
||||||
@@ -35,11 +35,11 @@ export class RtcTransportAutoDiscovery {
|
|||||||
transportType,
|
transportType,
|
||||||
fallbackTransportUrl,
|
fallbackTransportUrl,
|
||||||
logger,
|
logger,
|
||||||
}: RtcTransportAutoDiscoveryProps) {
|
}: TransportAutoDiscoveryProps) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.transportType = transportType;
|
this.transportType = transportType;
|
||||||
this.fallbackTransportUrl = fallbackTransportUrl;
|
this.fallbackTransportUrl = fallbackTransportUrl;
|
||||||
this.logger = logger.getChild("[RtcTransportAutoDiscovery]");
|
this.logger = logger.getChild("[TransportAutoDiscovery]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async discoverPreferredTransport(): Promise<Transport | null> {
|
public async discoverPreferredTransport(): Promise<Transport | null> {
|
||||||
@@ -10,7 +10,10 @@ import { BehaviorSubject } from "rxjs";
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { type ResolvedTransport } from "../api";
|
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 { testScope } from "../utils/test";
|
||||||
import { createTransportRegistry, transportId } from "./Transports";
|
import { createTransportRegistry, transportId } from "./Transports";
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import { distinctUntilChanged, map } from "rxjs";
|
|||||||
import { type Behavior } from "../reactive/Behavior";
|
import { type Behavior } from "../reactive/Behavior";
|
||||||
import { type ObservableScope } from "../reactive/ObservableScope";
|
import { type ObservableScope } from "../reactive/ObservableScope";
|
||||||
import { type TransportMetadata } from "../api";
|
import { type TransportMetadata } from "../api";
|
||||||
import { type MediaBackend, MediaConnectionState } from "../backend/api";
|
import { type MediaBackend, MediaConnectionState } from "../media-backend/api";
|
||||||
|
|
||||||
export interface TransportRegistry {
|
export interface TransportRegistry {
|
||||||
/** The one `TransportMetadata` for a transport, however many memberships name it. */
|
/** 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 { describe, expect, it } from "vitest";
|
||||||
import { Status } from "matrix-js-sdk/lib/matrixrtc";
|
import { Status } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
|
|
||||||
import { MediaConnectionState } from "../backend/api";
|
import { MediaConnectionState } from "../media-backend/api";
|
||||||
import { MatrixRTCError } from "../api";
|
import { MatrixRTCError } from "../api";
|
||||||
import {
|
import {
|
||||||
type LocalMemberState,
|
type LocalMemberState,
|
||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
daveRTL,
|
daveRTL,
|
||||||
} from "./test-fixtures";
|
} from "./test-fixtures";
|
||||||
import { mockMatrixRoom } from "./test";
|
import { mockMatrixRoom } from "./test";
|
||||||
import { roomToMembersMap } from "../session/MatrixMemberMetadata";
|
import { roomToMembersMap } from "../matrixrtc/MatrixMemberMetadata";
|
||||||
|
|
||||||
describe("shouldDisambiguate", () => {
|
describe("shouldDisambiguate", () => {
|
||||||
test("should not disambiguate a solo member", () => {
|
test("should not disambiguate a solo member", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user