diff --git a/sdk/SdkArchitecture.md b/sdk/SdkArchitecture.md index 6ab774e33..83993c571 100644 --- a/sdk/SdkArchitecture.md +++ b/sdk/SdkArchitecture.md @@ -707,7 +707,8 @@ Layout: ``` sdk/ index.ts the entry point: re-exports the API and the primitives - src/api.ts the public types above + src/api.ts the public types above: client, members, transports + src/media-api.ts the public media types: publish requests, tracks, MemberMedia src/errors.ts MatrixRTCError and its codes src/config.ts MatrixRTCMode, session timings, media quality src/encryption.ts E2eeType, EncryptionSystem diff --git a/sdk/index.ts b/sdk/index.ts index 787f0e2c7..1784d3b23 100644 --- a/sdk/index.ts +++ b/sdk/index.ts @@ -53,6 +53,7 @@ export { } from "./src/errors"; export * from "./src/api"; +export * from "./src/media-api"; export * from "./src/media-backend/api"; export { trackBySource$, type TrackOfSource } from "./src/utils/tracks"; export { createMatrixRTCClient } from "./src/MatrixRTCClient"; diff --git a/sdk/src/api.ts b/sdk/src/api.ts index 0207e31ec..bea8327bb 100644 --- a/sdk/src/api.ts +++ b/sdk/src/api.ts @@ -6,8 +6,9 @@ Please see LICENSE in the repository root for full details. */ /** - * The public types of the SDK. `createMatrixRTCClient` in `MatrixRTCClient.ts` - * is the only way to obtain an implementation of them. + * The public types of the SDK: the client, its members and transports. What a + * member sends is in `media-api.ts`. `createMatrixRTCClient` in + * `MatrixRTCClient.ts` is the only way to obtain an implementation of them. */ import { @@ -15,14 +16,16 @@ import { type RTCNotificationType, type Transport, } from "matrix-js-sdk/lib/matrixrtc"; -import { - type Track, - type TrackProcessor, - type VideoCodec, -} from "livekit-client"; import { type Observable } from "rxjs"; import { type Behavior } from "./reactive/Behavior"; +import { + type LocalAudioMediaTrack, + type LocalMemberMedia, + type LocalVideoMediaTrack, + type MemberMedia, + type PublishRequest, +} from "./media-api"; import { type MediaBackendFactory } from "./media-backend/api"; import { type EncryptionSystem } from "./encryption"; import { @@ -72,40 +75,6 @@ export interface MatrixRTCClientOptions { backend?: MediaBackendFactory; } -export interface AudioCaptureSettings { - echoCancellation?: boolean; - noiseSuppression?: boolean; - autoGainControl?: boolean; -} - -export interface VideoCaptureSettings { - resolution?: { width: number; height: number; frameRate?: number }; - maxBitrate?: number; - maxFramerate?: number; - codec?: VideoCodec; -} - -/** - * One thing to publish: a source, where to capture it from and how to encode - * it. Where the device and the settings are left out, the browser's and - * LiveKit's defaults apply. - */ -export type PublishRequest = - | { source: "microphone"; deviceId?: string; capture?: AudioCaptureSettings } - | { - source: "camera"; - deviceId?: string; - /** Background blur and the like. */ - processor?: TrackProcessor; - capture?: VideoCaptureSettings; - } - | { - source: "screenShare"; - /** Whether to capture the screen's audio too. Default true. */ - audio?: boolean; - capture?: VideoCaptureSettings; - }; - export type ConnectionStatus = | "waitingForTransport" | "connecting" @@ -276,112 +245,3 @@ export interface LocalRTCMember extends RTCMember { /** Removes one of our tracks; a screen share takes its audio with it. */ unpublish(id: string): Promise; } - -// --------------------------------------------------------------------------- -// Media - -export type MediaSource = - | "microphone" - | "camera" - | "screenShare" - | "screenShareAudio" - /** Published without a source; the application knows what it is. */ - | "unknown"; - -export type MediaStreamStats = - | RTCInboundRtpStreamStats - | RTCOutboundRtpStreamStats - | undefined; - -/** One published track of a member. */ -export interface MediaTrack { - source: MediaSource; - kind: "audio" | "video"; - /** Stable for the life of the track. */ - id: string; - muted$: Behavior; - /** False when the SFU reports the track as unencrypted. */ - encrypted$: Behavior; - /** Polled while subscribed. */ - stats$: Behavior; - /** - * Rendering. The view hands its `