| 1 | import type * as kv from "@distilled.cloud/aws/kinesis-video"; |
| 2 | import type * as kvam from "@distilled.cloud/aws/kinesis-video-archived-media"; |
| 3 | import type * as Effect from "effect/Effect"; |
| 4 | import * as Binding from "../../Binding.ts"; |
| 5 | import type { Stream } from "./Stream.ts"; |
| 6 | |
| 7 | export interface GetHLSStreamingSessionURLRequest extends Omit< |
| 8 | kvam.GetHLSStreamingSessionURLInput, |
| 9 | "StreamName" | "StreamARN" |
| 10 | > {} |
| 11 | |
| 12 | /** |
| 13 | * Runtime binding for `kinesisvideo:GetHLSStreamingSessionURL` (archived |
| 14 | * media data plane). |
| 15 | * |
| 16 | * Bind this operation to a `Stream` inside a function runtime to get a |
| 17 | * callable that resolves the per-stream data endpoint (`GetDataEndpoint`) |
| 18 | * and returns a short-lived HLS playback URL. |
| 19 | * ### Reading Media |
| 20 | * **Example:** Live HLS Playback URL |
| 21 | * ```typescript |
| 22 | * // init |
| 23 | * const getHls = yield* AWS.KinesisVideo.GetHLSStreamingSessionURL(stream); |
| 24 | * |
| 25 | * // runtime |
| 26 | * const { HLSStreamingSessionURL } = yield* getHls({ |
| 27 | * PlaybackMode: "LIVE", |
| 28 | * }); |
| 29 | * ``` |
| 30 | * |
| 31 | * **Example:** Wire into a Lambda Function |
| 32 | * ```typescript |
| 33 | * // Provide the GetHLSStreamingSessionURLHttp layer on the Function's |
| 34 | * // init Effect. Data-plane calls fan out to GetDataEndpoint first, so |
| 35 | * // allow a generous timeout. |
| 36 | * export default PlaybackFunction.make( |
| 37 | * { main: import.meta.url, functionUrl: true, timeout: Duration.seconds(30) }, |
| 38 | * Effect.gen(function* () { |
| 39 | * const stream = yield* AWS.KinesisVideo.Stream("Camera", { |
| 40 | * mediaType: "video/h264", |
| 41 | * dataRetention: "24 hours", |
| 42 | * }); |
| 43 | * const getHls = yield* AWS.KinesisVideo.GetHLSStreamingSessionURL(stream); |
| 44 | * return { |
| 45 | * fetch: Effect.gen(function* () { |
| 46 | * const { HLSStreamingSessionURL } = yield* getHls({ |
| 47 | * PlaybackMode: "LIVE", |
| 48 | * }); |
| 49 | * return HttpServerResponse.json({ url: HLSStreamingSessionURL }); |
| 50 | * }), |
| 51 | * }; |
| 52 | * }).pipe(Effect.provide(AWS.KinesisVideo.GetHLSStreamingSessionURLHttp)), |
| 53 | * ); |
| 54 | * ``` |
| 55 | * |
| 56 | * @binding |
| 57 | */ |
| 58 | export interface GetHLSStreamingSessionURL extends Binding.Service< |
| 59 | GetHLSStreamingSessionURL, |
| 60 | "AWS.KinesisVideo.GetHLSStreamingSessionURL", |
| 61 | <S extends Stream>( |
| 62 | stream: S, |
| 63 | ) => Effect.Effect< |
| 64 | ( |
| 65 | request?: GetHLSStreamingSessionURLRequest, |
| 66 | ) => Effect.Effect< |
| 67 | kvam.GetHLSStreamingSessionURLOutput, |
| 68 | kvam.GetHLSStreamingSessionURLError | kv.GetDataEndpointError |
| 69 | > |
| 70 | > |
| 71 | > {} |
| 72 | |
| 73 | export const GetHLSStreamingSessionURL = |
| 74 | Binding.Service<GetHLSStreamingSessionURL>( |
| 75 | "AWS.KinesisVideo.GetHLSStreamingSessionURL", |
| 76 | ); |