Documentation
¶
Overview ¶
Package nativeinprocess is an isolated, experimental process-lifetime FFI owner. The starter uses it only with the explicit experimental opt-in. Only one owner may initialize the process-global LiveKit FFI; other FFI clients must not coexist in that process.
Index ¶
- Variables
- type Chat
- type ClientState
- type DTMF
- type DataPacket
- type Frame
- type PreConnectAudio
- type RecordingFrame
- type Runtime
- func (r *Runtime) Close(ctx context.Context) error
- func (r *Runtime) Connect(ctx context.Context, url, token string) (*Session, error)
- func (r *Runtime) ConnectMicrophone(ctx context.Context, url, token, participant, sid string) (*Session, error)
- func (r *Runtime) ConnectMicrophoneCall(ctx context.Context, url, token, participant, sid string, chat, record bool) (*Session, error)
- func (r *Runtime) ConnectMicrophoneCallWithPreConnect(ctx context.Context, url, token, participant, sid string, chat, record bool, ...) (*Session, error)
- func (r *Runtime) ConnectMicrophoneChat(ctx context.Context, url, token, participant, sid string, enabled bool) (*Session, error)
- func (r *Runtime) ConnectMicrophoneRecording(ctx context.Context, url, token, participant, sid string, chat, record bool) (*Session, error)
- func (r *Runtime) ConnectSelected(ctx context.Context, url, token, participant, sid string) (*Session, error)
- type Session
- func (s *Session) BeginHold(ctx context.Context) error
- func (s *Session) Capture(ctx context.Context, pcm []int16) error
- func (s *Session) CaptureHold(ctx context.Context, pcm []int16) error
- func (s *Session) Chats() <-chan Chat
- func (s *Session) Clear(ctx context.Context) error
- func (s *Session) ClientStateErrors() <-chan error
- func (s *Session) Close(ctx context.Context) error
- func (s *Session) DTMF() <-chan DTMF
- func (s *Session) Done() <-chan struct{}
- func (s *Session) EndHold(ctx context.Context) error
- func (s *Session) Err() error
- func (s *Session) Frames() <-chan Frame
- func (s *Session) InputSubscribed() <-chan struct{}
- func (s *Session) InputTrackSID() string
- func (s *Session) OutputTrackSID(ctx context.Context) (string, error)
- func (s *Session) ParticipantDepartures() <-chan string
- func (s *Session) ParticipantIdentities() []string
- func (s *Session) Pause(ctx context.Context) error
- func (s *Session) PreConnectAudio() <-chan PreConnectAudio
- func (s *Session) PublishCaption(ctx context.Context, req *pb.FfiRequest) error
- func (s *Session) PublishData(ctx context.Context, topic string, data []byte) error
- func (s *Session) RecordingFrames() <-chan RecordingFrame
- func (s *Session) Resume(ctx context.Context) error
- func (s *Session) SendDTMF(ctx context.Context, code uint32, digit string) error
- func (s *Session) SetOutputEnabled(ctx context.Context, enabled bool) error
- func (s *Session) StopClientState(ctx context.Context) error
- func (s *Session) StopPreConnectAudio()
- func (s *Session) UpdateClientState(ctx context.Context, v ClientState) error
- func (s *Session) WaitOutputSubscribed(ctx context.Context) error
- func (s *Session) WaitReady(ctx context.Context) error
- func (s *Session) WaitSubscribed(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrBackpressure = errors.New("native session PCM delivery queue full") ErrClosed = errors.New("native runtime/session closed") ErrCaptureBusy = errors.New("native session capture already in flight") ErrControlBusy = errors.New("native playback control already pending") ErrSourceEnded = errors.New("native input source ended") )
var ErrDTMFBusy = errors.New("native DTMF send still in flight")
var ErrDTMFOverflow = errors.New("native incoming DTMF queue full")
Functions ¶
This section is empty.
Types ¶
type Chat ¶
type Chat struct {
Text, Sender string
Info *pb.TextStreamInfo
}
Chat is a completed lk.chat stream; metadata and text are owned Go values.
type ClientState ¶
ClientState is a current-state snapshot, not an event-history queue. Payloads use the application's existing client mapping; the native wrapper owns ordering.
type DataPacket ¶
type Frame ¶
Frame owns Go memory; PCM is mono PCM16 at 24 kHz. At is native callback monotonic nanoseconds, not a wall timestamp or an RTP timestamp.
type PreConnectAudio ¶
type PreConnectAudio struct {
Info *pb.ByteStreamInfo
Chunks [][]byte
Received time.Time
}
PreConnectAudio owns a completed byte stream. Chunk boundaries are retained for encoded packets; decoding and replay belong to the room adapter, off the FFI loop.
type RecordingFrame ¶
RecordingFrame is auxiliary microphone PCM, never agent input.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func Open ¶
Open claims the native runtime for the process lifetime. Reinitialization and unloading are deliberately unsupported. Native threads can outlive dispose.
func (*Runtime) Connect ¶
Connect starts asynchronous room setup. ctx governs the session lifetime. Delivery is bounded to 25 native 20ms frames (500ms), with no silent drops: saturation fails/disconnects only this session, never pads or retimes PCM.
func (*Runtime) ConnectMicrophone ¶
func (r *Runtime) ConnectMicrophone(ctx context.Context, url, token, participant, sid string) (*Session, error)
ConnectMicrophone keeps the selected caller across microphone republishing. ConnectSelected retains its exact-publication contract for existing probes.
func (*Runtime) ConnectMicrophoneCall ¶
func (r *Runtime) ConnectMicrophoneCall(ctx context.Context, url, token, participant, sid string, chat, record bool) (*Session, error)
ConnectMicrophoneCall enables bounded participant-departure delivery as well as recording. The caller must drain ParticipantDepartures until the session closes.
func (*Runtime) ConnectMicrophoneCallWithPreConnect ¶
func (r *Runtime) ConnectMicrophoneCallWithPreConnect(ctx context.Context, url, token, participant, sid string, chat, record bool, timeout time.Duration) (*Session, error)
ConnectMicrophoneCallWithPreConnect adds bounded startup audio delivery. A zero timeout disables it. Existing connect APIs retain their audio-only behavior.
func (*Runtime) ConnectMicrophoneChat ¶
func (r *Runtime) ConnectMicrophoneChat(ctx context.Context, url, token, participant, sid string, enabled bool) (*Session, error)
ConnectMicrophoneChat enables bounded lk.chat receive before connecting. Existing connect methods retain their audio-only behavior.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func (*Session) BeginHold ¶
Hold has its own native audio source and publication on the same connection. It never enters speech playback accounting or the receive playout path.
func (*Session) Capture ¶
Capture waits for native acknowledgement. Cancellation stops waiting, not an already-submitted native capture. A second in-flight capture is rejected.
func (*Session) Clear ¶
Clear is a hard interruption: cancel parked PCM, drain in-flight capture, clear native output and unpause. It does not replay already acknowledged samples.
func (*Session) ClientStateErrors ¶
func (*Session) Close ¶
Close cancels this session and waits for native disconnect/handle release. A timed-out wait does not drop the runtime's ownership of a late connection.
func (*Session) InputSubscribed ¶
func (s *Session) InputSubscribed() <-chan struct{}
InputSubscribed closes when the selected microphone first becomes available.
func (*Session) InputTrackSID ¶
func (*Session) OutputTrackSID ¶
OutputTrackSID is available after WaitReady. The published track identity is retained across native reconnects, like the output source itself.
func (*Session) ParticipantDepartures ¶
func (*Session) ParticipantIdentities ¶
func (*Session) Pause ¶
Pause waits for an in-flight capture acknowledgement, then clears the native source. Unsubmitted PCM stays bounded to one parked Capture and resumes in order. Native-queued audio is discarded, matching the helper's interruption contract.
func (*Session) PreConnectAudio ¶
func (s *Session) PreConnectAudio() <-chan PreConnectAudio
func (*Session) PublishCaption ¶
PublishCaption submits only caption packet/stream requests. Session ownership and async IDs are supplied by the runtime, never by callers. PCM delivery does not wait for publication callbacks. At most eight caption requests per session can remain in flight, including timed-out calls awaiting late callbacks.
func (*Session) PublishData ¶
PublishData sends reliable data from the native agent identity. A canceled request is not replayed; its pending slot remains owned until acknowledgement.
func (*Session) RecordingFrames ¶
func (s *Session) RecordingFrames() <-chan RecordingFrame
func (*Session) SendDTMF ¶
SendDTMF never retries. A timeout/cancellation after submission means delivery is uncertain. Keep the slot until native acknowledgement or session teardown.
func (*Session) SetOutputEnabled ¶
func (*Session) StopClientState ¶
StopClientState prevents any remaining snapshot stages from being published. The in-flight request is still owned until callback or session teardown.
func (*Session) StopPreConnectAudio ¶
func (s *Session) StopPreConnectAudio()
StopPreConnectAudio stops accepting late startup streams after replay or timeout.
func (*Session) UpdateClientState ¶
func (s *Session) UpdateClientState(ctx context.Context, v ClientState) error
UpdateClientState acknowledges ownership, not remote receipt. Publication errors arrive on ClientStateErrors. Only the latest pending snapshot is kept.