livekit

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package livekit implements a jargo transport that joins a LiveKit room as a participant. It subscribes to a remote participant's Opus audio, decodes it to PCM frames for the pipeline, and publishes the pipeline's audio back as an Opus track. Room signaling and the access token are handled by the LiveKit server SDK; the media path mirrors the Pion transport (transport/pionrtc).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// URL is the LiveKit server URL (ws(s)://...). Required.
	URL string `validate:"required"`
	// APIKey is the LiveKit API key. Required.
	APIKey string `validate:"required"`
	// APISecret is the LiveKit API secret. Required.
	APISecret string `validate:"required"`
	// RoomName is the room to join. Required.
	RoomName string `validate:"required"`
	// Identity is this participant's identity. Required.
	Identity string `validate:"required"`
}

Config configures a LiveKit room connection. The SDK mints the participant access token from the API key and secret.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether the configuration is usable.

type Connection

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

Connection wraps a joined LiveKit room for one session. It owns the published audio track and exposes the first subscribed remote audio track. It is safe for concurrent use.

func Connect

func Connect(cfg Config) (*Connection, error)

Connect joins the configured room, publishes an Opus audio track, and returns a Connection ready to be wrapped with NewTransport.

func (*Connection) Close

func (c *Connection) Close() error

Close leaves the room.

func (*Connection) Done

func (c *Connection) Done() <-chan struct{}

Done returns a channel closed when the room disconnects or Close is called.

func (*Connection) OnMessage

func (c *Connection) OnMessage(h func([]byte))

OnMessage registers the handler for data messages received in the room. Any messages that arrived before a handler was set are delivered immediately.

func (*Connection) RemoteAudioTrack

func (c *Connection) RemoteAudioTrack(ctx context.Context) (*webrtc.TrackRemote, error)

RemoteAudioTrack returns the first subscribed remote audio track, blocking until it arrives, ctx is done, or the connection closes.

func (*Connection) SendMessage

func (c *Connection) SendMessage(data []byte) error

SendMessage publishes an application message to the room.

func (*Connection) WriteAudio

func (c *Connection) WriteAudio(packet []byte, dur time.Duration) error

WriteAudio sends one Opus packet on the published track. dur is the packet's playback duration, used to advance RTP timestamps.

type Transport

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

Transport is a LiveKit room transport. It provides the input and output processors for a pipeline.

func NewTransport

func NewTransport(conn *Connection, params transport.Params) *Transport

NewTransport builds a transport over a joined LiveKit connection.

func (*Transport) Input

func (t *Transport) Input() processor.Processor

Input returns the input processor.

func (*Transport) Output

func (t *Transport) Output() processor.Processor

Output returns the output processor.

Jump to

Keyboard shortcuts

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