/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Observable } from "@matter/general"; import { PeerAddress } from "@matter/protocol"; import { WebRtcTransportDefinitions } from "@matter/types/clusters/web-rtc-transport-definitions"; import { WebRtcTransportRequestor } from "@matter/types/clusters/web-rtc-transport-requestor"; import { WebRtcTransportRequestorBehavior } from "./WebRtcTransportRequestorBehavior.js"; type WebRtcSession = WebRtcTransportDefinitions.WebRtcSession; /** * This is the default server implementation of {@link WebRtcTransportRequestorBehavior}. * * This cluster lives on the controller side of a WebRTC stream (e.g. a camera controller). The peer camera/provider * drives signaling by invoking the Offer, Answer, IceCandidates and End commands on this cluster. The default * implementation validates each command against the session's originating fabric and peer node, tracks live sessions in * the `currentSessions` attribute, and re-emits the signaling through the {@link WebRtcTransportRequestorServer.Events} * observables so you can drive your own WebRTC peer connection. * * To use it: * * Register a session with {@link upsertSession} when you initiate a stream, so the peer's subsequent commands for that * session are accepted; commands naming a session id this cluster does not track for the peer's fabric and node are * rejected with NotFound. * * Subscribe to the `offer` / `answer` / `iceCandidates` / `end` events to feed your WebRTC stack. A session is removed * from tracking automatically when the peer sends End. * * Call {@link removeSession} when you tear a stream down locally. * * On the first commissioned fabric the implementation installs an Operate-privilege ACL entry granting that fabric * access to this cluster, so the peer can reach the signaling commands without further configuration. */ export declare class WebRtcTransportRequestorServer extends WebRtcTransportRequestorBehavior { #private; readonly events: WebRtcTransportRequestorServer.Events; initialize(): Promise; /** * Register or update a WebRTC session you have initiated with a peer. A session must be registered before the peer's * signaling commands for it are accepted, and registration populates the `currentSessions` attribute. Re-registering * a session with the same {@link WebRtcTransportRequestorServer.SessionKey} replaces the entry. */ upsertSession(session: WebRtcSession): void; /** Stop tracking a session, e.g. after you tear down the stream locally. No-op if no session matches the key. */ removeSession(key: WebRtcTransportRequestorServer.SessionKey): void; /** * Invoked by the peer to deliver an SDP offer. Surfaces it via the {@link WebRtcTransportRequestorServer.Events} * `offer` event. */ offer(request: WebRtcTransportRequestor.OfferRequest): Promise; /** * Invoked by the peer to deliver an SDP answer. Surfaces it via the {@link WebRtcTransportRequestorServer.Events} * `answer` event. */ answer(request: WebRtcTransportRequestor.AnswerRequest): Promise; /** Invoked by the peer to deliver ICE candidates. Surfaces them via the {@link WebRtcTransportRequestorServer.Events} * `iceCandidates` event. */ iceCandidates(request: WebRtcTransportRequestor.IceCandidatesRequest): Promise; /** Invoked by the peer to end a session. Removes it from tracking and surfaces it via the * {@link WebRtcTransportRequestorServer.Events} `end` event. */ end(request: WebRtcTransportRequestor.EndRequest): Promise; } export declare namespace WebRtcTransportRequestorServer { /** * Identifies a tracked session. The session id alone is not unique because each provider node allocates its own, so * two peers, or one peer on two fabrics, may use the same id at the same time. * * @see {@link MatterSpecification.v161.Cluster} § 11.4.5.1, § 11.6.5.1 */ type SessionKey = Pick; /** Transport-signaling events the peer triggers; subscribe to these to drive your WebRTC peer connection. */ class Events extends WebRtcTransportRequestorBehavior.Events { /** Peer sent an SDP offer for a tracked session; apply it to your peer connection. */ offer: Observable<[session: WebRtcTransportDefinitions.WebRtcSession, args: WebRtcTransportRequestor.OfferRequest], void>; /** Peer sent an SDP answer for a tracked session. */ answer: Observable<[session: WebRtcTransportDefinitions.WebRtcSession, sdp: string], void>; /** Peer sent ICE candidates for a tracked session; add them to your peer connection. */ iceCandidates: Observable<[session: WebRtcTransportDefinitions.WebRtcSession, candidates: WebRtcTransportDefinitions.IceCandidate[]], void>; /** Peer ended a session; the session is already removed from tracking when this fires. */ end: Observable<[session: WebRtcTransportDefinitions.WebRtcSession, reason: WebRtcTransportDefinitions.WebRtcEndReason], void>; /** * Peer signaled against a session this cluster does not track for it, which it answered `NotFound`. The session * id is the one the peer named, so a listener sees which id was refused rather than only that something was. * * Signaling this cluster never sees is not reported here: a command whose fields break their own constraints is * refused by schema validation before any of this runs. */ refused: Observable<[signal: SignalKind, webRtcSessionId: number, peer: PeerAddress], void>; } /** The signaling commands a peer invokes on this cluster. */ type SignalKind = "offer" | "answer" | "iceCandidates" | "end"; } export {}; //# sourceMappingURL=WebRtcTransportRequestorServer.d.ts.map