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 ¶
- type Config
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) Done() <-chan struct{}
- func (c *Connection) OnMessage(h func([]byte))
- func (c *Connection) RemoteAudioTrack(ctx context.Context) (*webrtc.TrackRemote, error)
- func (c *Connection) SendMessage(data []byte) error
- func (c *Connection) WriteAudio(packet []byte, dur time.Duration) error
- type Transport
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.
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) 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.