Documentation
¶
Overview ¶
Package voicertc implements WebRTC voice sessions through the voice gateway protocol.
Index ¶
- type Bridge
- func (b *Bridge) Close(sessionID string)
- func (b *Bridge) CloseAll(ctx context.Context)
- func (b *Bridge) DiagnoseVoiceRTC(_ context.Context, sessionID string, client *voicev2.VoiceRTCClientDiagnostics) voicev2.VoiceRTCDiagnosticsResp
- func (b *Bridge) HandleChoiceOffer(ctx context.Context, sdpOffer, choiceID string) (sdpAnswer, sessionID string, err error)
- func (b *Bridge) HandleOffer(ctx context.Context, sdpOffer string) (sdpAnswer, sessionID string, err error)
- func (b *Bridge) HasSession(sessionID string) bool
- func (b *Bridge) ServeTextChoice(ctx context.Context, w http.ResponseWriter, r *http.Request, choiceID string) error
- func (b *Bridge) ServeTextSession(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (b *Bridge) SetOnSessionClosed(callback func(string))
- func (b *Bridge) VoiceChoices() voicev2.VoiceChoicesResp
- func (b *Bridge) VoiceRTCError(sessionID string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge manages voice choices and sessions on one shared WebRTC transport.
func NewBridge ¶
func NewBridge(ctx context.Context, cfg *voicegateway.ResolvedConfig, webrtc voicegateway.WebRTCConfig, activityLogDir string) (*Bridge, error)
NewBridge creates a Bridge that multiplexes WebRTC traffic through a single UDP port and, unless webrtc.DisableUPnP, eagerly verifies its UPnP publication.
Credentials use each provider's native environment variables or, for OpenAI Codex authentication, the file-backed Codex login. Configured choices share the UDP listener on webrtc.UDPPort and advertise webrtc.STUNServers to clients; the caller validates webrtc with its configuration.
Choice discovery and transport setup happen during construction. Managed local model runtimes load on first use through the shared capacity and idle-eviction pool. A construction failure closes all backends already initialized.
func (*Bridge) Close ¶
Close tears down a session by ID. No-op if not found. It waits at most five seconds; cleanup and the close callback may continue after it returns.
func (*Bridge) CloseAll ¶
CloseAll tears down all sessions and the UDP mux. Called on server shutdown.
func (*Bridge) DiagnoseVoiceRTC ¶
func (b *Bridge) DiagnoseVoiceRTC(_ context.Context, sessionID string, client *voicev2.VoiceRTCClientDiagnostics) voicev2.VoiceRTCDiagnosticsResp
DiagnoseVoiceRTC returns structured connectivity diagnostics for a session.
func (*Bridge) HandleChoiceOffer ¶
func (b *Bridge) HandleChoiceOffer(ctx context.Context, sdpOffer, choiceID string) (sdpAnswer, sessionID string, err error)
HandleChoiceOffer opens a session bound to the selected backend.
func (*Bridge) HandleOffer ¶
func (b *Bridge) HandleOffer(ctx context.Context, sdpOffer string) (sdpAnswer, sessionID string, err error)
HandleOffer processes a WebRTC SDP offer and returns the SDP answer.
func (*Bridge) HasSession ¶
HasSession reports whether the bridge still owns the session ID.
func (*Bridge) ServeTextChoice ¶
func (b *Bridge) ServeTextChoice(ctx context.Context, w http.ResponseWriter, r *http.Request, choiceID string) error
ServeTextChoice runs a text session bound to the selected backend.
func (*Bridge) ServeTextSession ¶
func (b *Bridge) ServeTextSession(ctx context.Context, w http.ResponseWriter, r *http.Request) error
ServeTextSession upgrades the HTTP request to a client-speech text session that shares the bridge's language model. When the configured backend has no language model, it writes a 503 response and returns the error.
func (*Bridge) SetOnSessionClosed ¶
SetOnSessionClosed registers a callback for every session removed from this bridge. The callback runs outside the session lock after resources close.
func (*Bridge) VoiceChoices ¶
func (b *Bridge) VoiceChoices() voicev2.VoiceChoicesResp
VoiceChoices returns the choices available on this bridge.
func (*Bridge) VoiceRTCError ¶
VoiceRTCError returns the latest gateway error retained for v1 diagnostics.
Source Files
¶
- activity_log.go
- backend.go
- bridge.go
- compat.go
- localstack.go
- localstack_genai.go
- localstack_pool.go
- localstack_servers.go
- microphone.go
- net.go
- opus.go
- opus_encoder.go
- playback.go
- protocol.go
- provider.go
- realtime.go
- realtime_audio.go
- sentence_fragmenter.go
- speech_live.go
- speech_native.go
- speech_pcm.go
- staged.go
- streaming_asr.go
- text.go
- upnp.go
- upnp_route_other.go
- usage.go