Class GeminiLiveCodec
BidiGenerateContent over WebSocket). It
hand-assembles the provider-correct server message JSON frames a client receives, so an application using the
Gemini Live SDK can be tested fully offline. Every user-supplied string is routed through
JsonEscape.escape(String) before embedding.
Message coverage. The codec produces the setupComplete handshake acknowledgement (returned in
response to the client's setup message) and, for one client clientContent turn, a stream of
serverContent messages: per token a modelTurn chunk (parts[].text in text modality;
parts[].inlineData audio + outputTranscription in audio modality), then a
generationComplete marker, and finally a turnComplete message carrying usageMetadata.
Deferred protocol corners (documented rather than half-implemented, see
docs/code/ai-protocol-mocking.md): realtimeInput / realtimeInputAcknowledgement
(streamed audio/video input), toolCall / toolCallCancellation / toolResponse,
goAway and sessionResumptionUpdate, and interruption (interrupted) signalling. The
audio bytes are opaque silence placeholders — the fidelity target is the event protocol, not audio DSP.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<RealtimeEvent>serverContentSequence(RealtimeTurn turn, RealtimeModality modality, RealtimeStreamingPhysics physics) The full orderedserverContentmessage stream emitted for one clientclientContentturn.static StringThesetupCompleteframe returned in response to the client'ssetupmessage.
-
Method Details
-
setupComplete
ThesetupCompleteframe returned in response to the client'ssetupmessage. -
serverContentSequence
public static List<RealtimeEvent> serverContentSequence(RealtimeTurn turn, RealtimeModality modality, RealtimeStreamingPhysics physics) The full orderedserverContentmessage stream emitted for one clientclientContentturn.- Parameters:
turn- the scripted assistant responsemodality-RealtimeModality.AUDIO(inlineData audio + outputTranscription) orRealtimeModality.TEXTphysics- streaming timing (per-delta delay, time-to-first-token)- Returns:
- ordered message frames with per-frame delays
-