adk_live_media (erlang_adk v0.7.0)

View Source

Strict, provider-neutral realtime media values.

Live media deliberately does not use adk_content. PCM MIME parameters and short-lived audio/video chunks have different lifetime and pressure semantics from durable model content. Raw bytes remain Erlang binaries until a provider codec crosses its JSON boundary.

Summary

Functions

Decode a Gemini Live Blob without retaining its base64 representation.

Convert a checked media value to the Gemini Live Blob JSON shape.

Types

error_reason/0

-type error_reason() ::
          invalid_media | invalid_audio_data | invalid_sample_rate | invalid_channels |
          audio_chunk_too_large | invalid_video_frame | video_frame_too_large | unsupported_media_type |
          invalid_base64.

media/0

-type media() ::
          #{schema_version := 1,
            kind := audio | video,
            format := pcm_s16le | jpeg | png,
            data := binary(),
            sample_rate => pos_integer(),
            channels => pos_integer()}.

Functions

audio_pcm(Data, SampleRate, Channels)

-spec audio_pcm(binary(), pos_integer(), pos_integer()) -> {ok, media()} | {error, error_reason()}.

bytes(_)

-spec bytes(media()) -> non_neg_integer().

from_gemini_blob(MimeType, Encoded)

-spec from_gemini_blob(binary(), binary()) -> {ok, media()} | {error, error_reason()}.

Decode a Gemini Live Blob without retaining its base64 representation.

to_gemini_blob(Media)

-spec to_gemini_blob(media()) -> {ok, map()} | {error, error_reason()}.

Convert a checked media value to the Gemini Live Blob JSON shape.

validate(Media)

-spec validate(term()) -> ok | {error, error_reason()}.

video_frame(Format, Data)

-spec video_frame(jpeg | png, binary()) -> {ok, media()} | {error, error_reason()}.