1import type * as kv from "@distilled.cloud/aws/kinesis-video";
2import type * as kvws from "@distilled.cloud/aws/kinesis-video-webrtc-storage";
3import type * as Effect from "effect/Effect";
4import * as Binding from "../../Binding.ts";
5import type { SignalingEndpointUnavailable } from "./internal.ts";
6import type { SignalingChannel } from "./SignalingChannel.ts";
7
8/**
9 * Runtime binding for `kinesisvideo:JoinStorageSession` (WebRTC storage
10 * data plane).
11 *
12 * Bind this operation to a `SignalingChannel` inside a function runtime to
13 * get a callable that resolves the per-channel WEBRTC storage endpoint
14 * (`GetSignalingChannelEndpoint`) and joins the ongoing WebRTC session as
15 * the video-producing master so the media is recorded into the channel's
16 * associated Kinesis Video stream.
17 *
18 * Requires the channel's media storage to be configured (an ENABLED
19 * `MediaStorageConfiguration` linking the channel to a stream); without it
20 * the endpoint discovery fails with the typed `SignalingEndpointUnavailable`
21 * error.
22 * ### WebRTC Storage
23 * **Example:** Join a Storage Session as Master
24 * ```typescript
25 * // init
26 * const joinStorage = yield* AWS.KinesisVideo.JoinStorageSession(channel);
27 *
28 * // runtime
29 * yield* joinStorage();
30 * ```
31 *
32 * @binding
33 */
34export interface JoinStorageSession extends Binding.Service<
35 JoinStorageSession,
36 "AWS.KinesisVideo.JoinStorageSession",
37 <C extends SignalingChannel>(
38 channel: C,
39 ) => Effect.Effect<
40 () => Effect.Effect<
41 kvws.JoinStorageSessionResponse,
42 | kvws.JoinStorageSessionError
43 | kv.GetSignalingChannelEndpointError
44 | SignalingEndpointUnavailable
45 >
46 >
47> {}
48
49export const JoinStorageSession = Binding.Service<JoinStorageSession>(
50 "AWS.KinesisVideo.JoinStorageSession",
51);