nativeinprocess

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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")
)
View Source
var ErrDTMFBusy = errors.New("native DTMF send still in flight")
View Source
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

type ClientState struct {
	Agent               string
	AgentData, UserData []byte
}

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 DTMF

type DTMF struct {
	Code          uint32
	Digit, Sender string
}

type DataPacket

type DataPacket struct {
	Topic   string
	Payload []byte
}

type Frame

type Frame struct {
	At  int64
	PCM []int16
}

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

type RecordingFrame struct {
	TrackSID string
	Frame    Frame
}

RecordingFrame is auxiliary microphone PCM, never agent input.

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

func Open

func Open(path string) (*Runtime, error)

Open claims the native runtime for the process lifetime. Reinitialization and unloading are deliberately unsupported. Native threads can outlive dispose.

func (*Runtime) Close

func (r *Runtime) Close(ctx context.Context) error

func (*Runtime) Connect

func (r *Runtime) Connect(ctx context.Context, url, token string) (*Session, error)

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.

func (*Runtime) ConnectMicrophoneRecording

func (r *Runtime) ConnectMicrophoneRecording(ctx context.Context, url, token, participant, sid string, chat, record bool) (*Session, error)

ConnectMicrophoneRecording enables recording before native room events begin.

func (*Runtime) ConnectSelected

func (r *Runtime) ConnectSelected(ctx context.Context, url, token, participant, sid string) (*Session, error)

ConnectSelected pins the caller and publication discovered by the agent.

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) BeginHold

func (s *Session) BeginHold(ctx context.Context) error

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

func (s *Session) Capture(ctx context.Context, pcm []int16) error

Capture waits for native acknowledgement. Cancellation stops waiting, not an already-submitted native capture. A second in-flight capture is rejected.

func (*Session) CaptureHold

func (s *Session) CaptureHold(ctx context.Context, pcm []int16) error

func (*Session) Chats

func (s *Session) Chats() <-chan Chat

func (*Session) Clear

func (s *Session) Clear(ctx context.Context) error

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 (s *Session) ClientStateErrors() <-chan error

func (*Session) Close

func (s *Session) Close(ctx context.Context) error

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) DTMF

func (s *Session) DTMF() <-chan DTMF

func (*Session) Done

func (s *Session) Done() <-chan struct{}

func (*Session) EndHold

func (s *Session) EndHold(ctx context.Context) error

func (*Session) Err

func (s *Session) Err() error

func (*Session) Frames

func (s *Session) Frames() <-chan Frame

func (*Session) InputSubscribed

func (s *Session) InputSubscribed() <-chan struct{}

InputSubscribed closes when the selected microphone first becomes available.

func (*Session) InputTrackSID

func (s *Session) InputTrackSID() string

func (*Session) OutputTrackSID

func (s *Session) OutputTrackSID(ctx context.Context) (string, error)

OutputTrackSID is available after WaitReady. The published track identity is retained across native reconnects, like the output source itself.

func (*Session) ParticipantDepartures

func (s *Session) ParticipantDepartures() <-chan string

func (*Session) ParticipantIdentities

func (s *Session) ParticipantIdentities() []string

func (*Session) Pause

func (s *Session) Pause(ctx context.Context) error

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

func (s *Session) PublishCaption(ctx context.Context, req *pb.FfiRequest) error

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

func (s *Session) PublishData(ctx context.Context, topic string, data []byte) error

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) Resume

func (s *Session) Resume(ctx context.Context) error

func (*Session) SendDTMF

func (s *Session) SendDTMF(ctx context.Context, code uint32, digit string) error

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 (s *Session) SetOutputEnabled(ctx context.Context, enabled bool) error

func (*Session) StopClientState

func (s *Session) StopClientState(ctx context.Context) error

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.

func (*Session) WaitOutputSubscribed

func (s *Session) WaitOutputSubscribed(ctx context.Context) error

func (*Session) WaitReady

func (s *Session) WaitReady(ctx context.Context) error

func (*Session) WaitSubscribed

func (s *Session) WaitSubscribed(ctx context.Context) error

WaitSubscribed waits for the selected native input sink, not the first packet.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL