@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 60 lines 2.08 KB
Raw
1 import type * as kv from "@distilled.cloud/aws/kinesis-video";
2 import type * as kvm from "@distilled.cloud/aws/kinesis-video-media";
3 import * as Binding from "alchemy/Binding";
4 import type * as Effect from "effect/Effect";
5 import type { Stream } from "./Stream.ts";
6
7 export interface GetMediaRequest extends Omit<kvm.GetMediaInput, "StreamName" | "StreamARN"> {}
8
9 /**
10 * Runtime binding for `kinesisvideo:GetMedia` (media data plane).
11 *
12 * Bind this operation to a `Stream` inside a function runtime to get a
13 * callable that resolves the per-stream data endpoint (`GetDataEndpoint`)
14 * and opens a media stream starting at the requested selector. The
15 * response `Payload` is a streaming body of MKV-packaged media.
16 * ### Reading Media
17 * **Example:** Read Media from the Earliest Fragment
18 * ```typescript
19 * // init
20 * const getMedia = yield* AWS.KinesisVideo.GetMedia(stream);
21 *
22 * // runtime
23 * const media = yield* getMedia({
24 * StartSelector: { StartSelectorType: "EARLIEST" },
25 * });
26 * ```
27 *
28 * **Example:** Wire into a Lambda Function
29 * ```typescript
30 * // Provide the GetMediaHttp layer on the Function's init Effect; merge
31 * // with the other KinesisVideo layers when using several bindings.
32 * export default MediaFunction.make(
33 * { main: import.meta.url, functionUrl: true, timeout: Duration.seconds(30) },
34 * Effect.gen(function* () {
35 * const stream = yield* AWS.KinesisVideo.Stream("Camera", {
36 * mediaType: "video/h264",
37 * dataRetention: "24 hours",
38 * });
39 * const getMedia = yield* AWS.KinesisVideo.GetMedia(stream);
40 * // ... read media.Payload in the fetch handler
41 * return { fetch: handler };
42 * }).pipe(Effect.provide(AWS.KinesisVideo.GetMediaHttp)),
43 * );
44 * ```
45 *
46 * @binding
47 */
48 export interface GetMedia extends Binding.Service<
49 GetMedia,
50 "AWS.KinesisVideo.GetMedia",
51 <S extends Stream>(
52 stream: S,
53 ) => Effect.Effect<
54 (
55 request: GetMediaRequest,
56 ) => Effect.Effect<kvm.GetMediaOutput, kvm.GetMediaError | kv.GetDataEndpointError>
57 >
58 > {}
59
60 export const GetMedia = Binding.Service<GetMedia>("AWS.KinesisVideo.GetMedia");