Documentation
¶
Overview ¶
Package nativeroom provides experimental opt-in LiveKit session transports.
Build with nativeinprocess to use NewInProcess. Pass the returned transport to worker.StartSessionOptions.Transport before connecting the job's Pion room. Pre-connect audio is enabled by default; RoomOptions controls its timeout and opt-out. Native owns receive playout, reconnect, and both media directions.
One FFI runtime is shared by all native sessions in the process. Close session transports first, then call CloseInProcessRuntime once during worker shutdown. Runtime disposal is terminal; the native library cannot be swapped or reopened. Construction does not select a transport globally or load the native library.
New retains the existing helper-process transport. Neither constructor changes the worker's default transport. See examples/starter/packaging/INPROCESS.md for build, library installation and rollback instructions.
Index ¶
- Variables
- func DownloadNativeLibrary(ctx context.Context) error
- func NativeLibraryPath() (string, error)
- func NewProvider(Config, string, string) (worker.SessionTransportProvider, error)
- type Cleanup
- type Config
- type Continuity
- type Room
- func (r *Room) AttachRoom(*worker.SDKRoom)
- func (r *Room) BeginShutdown()
- func (r *Room) CleanupDiagnostics() (Cleanup, bool)
- func (r *Room) Close() error
- func (r *Room) GetCallback() *worker.RoomCallback
- func (r *Room) PopulateSessionReport(report *agent.SessionReport)
- func (r *Room) ReconcileParticipants()
- func (r *Room) Start(ctx context.Context) error
- func (r *Room) StartRecorder(path string, rate int) error
- func (r *Room) StopRecorder() error
Constants ¶
This section is empty.
Variables ¶
var ErrSourceEnded = errors.New("native room source ended")
Functions ¶
func DownloadNativeLibrary ¶
DownloadNativeLibrary installs the pinned runtime, verifying the archive before atomically replacing the destination. It never changes transport selection.
func NativeLibraryPath ¶
NativeLibraryPath resolves the explicit override or the application-local install. It does not download or load the library.
func NewProvider ¶
Types ¶
type Cleanup ¶
type Cleanup struct {
Mode string `json:"mode,omitempty"`
NativeCleanupMS float64 `json:"native_cleanup_ms"`
PID int `json:"pid"`
Reaped bool `json:"reaped"`
ExitCode int `json:"exit_code"`
KillAttempted bool `json:"kill_attempted"`
CleanupMS float64 `json:"cleanup_ms"`
ShutdownSeen bool `json:"shutdown_seen"`
DisconnectCallback bool `json:"disconnect_callback"`
HandlesReleased bool `json:"handles_released"`
RuntimeDisposed bool `json:"runtime_disposed"`
CallbackOverflow bool `json:"callback_overflow"`
}
Cleanup is published after connection teardown and PCM-consumer shutdown. Helper mode reports child/native shutdown flags. In-process mode never sets Reaped or RuntimeDisposed: global disposal belongs to worker shutdown.
type Config ¶
type Config struct {
// ParticipantDisconnected runs off the FFI owner, before source-ended job shutdown.
// The callback must return promptly and must not synchronously close this room.
ParticipantDisconnected func(string)
Binary, Library string
URL, Token, Participant, TrackSID string
// contains filtered or unexported fields
}
type Continuity ¶
type Continuity struct {
WallSeconds float64 `json:"wall_seconds"`
PCMSeconds float64 `json:"pcm_seconds"`
TotalPCMSeconds float64 `json:"total_pcm_seconds"`
MaxGapMS float64 `json:"max_gap_ms"`
SinceLastFrameMS float64 `json:"since_last_frame_ms"`
FirstFrameDelayMS float64 `json:"first_frame_delay_ms"`
}
Continuity measures application callback delivery using the parent's monotonic clock. It observes PCM; it never schedules, drops, or synthesizes frames.
type Room ¶
type Room struct {
Config Config
APIKey, APISecret string
Job *worker.JobContext
Session *agent.AgentSession
DeleteRoomOnClose bool
// contains filtered or unexported fields
}
Room owns one native connection and uses the worker-assigned primary token. It never connects the prepared Pion room or creates a second agent identity.
func New ¶
func New(job *worker.JobContext, session *agent.AgentSession, cfg Config, key, secret string) *Room
func (*Room) AttachRoom ¶
func (*Room) BeginShutdown ¶
func (r *Room) BeginShutdown()
func (*Room) CleanupDiagnostics ¶
CleanupDiagnostics returns a stable snapshot only once the child is reaped.
func (*Room) GetCallback ¶
func (r *Room) GetCallback() *worker.RoomCallback
func (*Room) PopulateSessionReport ¶
func (r *Room) PopulateSessionReport(report *agent.SessionReport)
func (*Room) ReconcileParticipants ¶
func (r *Room) ReconcileParticipants()