rtcbridge

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package rtcbridge multiplexes one LiveKit RoomCallback into bounded, context-first subscriptions. It is dependency-neutral so the worker can install it while constructing a Room, before higher-level RoomIO exists.

Index

Constants

View Source
const DefaultRTCEventCapacity = 256

Variables

View Source
var (
	ErrRTCBridgeClosed  = errors.New("roomio: RTC bridge is closed")
	ErrRTCEventOverflow = errors.New("roomio: RTC event queue overflow")
)

Functions

This section is empty.

Types

type CallbackPanicError

type CallbackPanicError struct {
	Callback string
	Panic    any
	Stack    []byte
}

CallbackPanicError reports a panic recovered at an application callback boundary. A user callback can therefore not take down an RTC or RoomIO lifecycle goroutine.

func (*CallbackPanicError) Error

func (e *CallbackPanicError) Error() string

type RTCBridge

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

RTCBridge multiplexes one RoomCallback into bounded RoomIO subscriptions. The callback returned by Callback must be installed when the room is created; server-sdk-go v2.18.1 does not expose post-construction callback registration.

func NewRTCBridge

func NewRTCBridge(base *lksdk.RoomCallback, options RTCBridgeOptions) *RTCBridge

NewRTCBridge composes base callbacks with a nonblocking bounded event bridge. base may be nil. Existing callback behavior is preserved, with panics isolated and reported through OnCallbackPanic.

func NewRoom

func NewRoom(base *lksdk.RoomCallback, options RTCBridgeOptions) (*lksdk.Room, *RTCBridge)

NewRoom creates a server-SDK Room with the bridge callback installed. RoomIO never disconnects this room; the caller retains room and E2EE ownership.

func (*RTCBridge) Callback

func (b *RTCBridge) Callback() *lksdk.RoomCallback

func (*RTCBridge) Close

func (b *RTCBridge) Close() error

func (*RTCBridge) Subscribe

func (b *RTCBridge) Subscribe(capacity int) (*RTCSubscription, error)

func (*RTCBridge) SubscribeTypes

func (b *RTCBridge) SubscribeTypes(capacity int, events ...RTCEventType) (*RTCSubscription, error)

SubscribeTypes limits a subscription to the listed event types. Internal media actors use this to avoid allocating and dispatching high-volume data or transcription events they do not consume. With no event types it is equivalent to Subscribe.

type RTCBridgeOptions

type RTCBridgeOptions struct {
	// EventCapacity is the default capacity of each subscription. A subscriber
	// that cannot keep up is failed visibly with ErrRTCEventOverflow; RTC
	// callbacks are never blocked and lifecycle events are never silently lost.
	EventCapacity   int
	OnCallbackPanic func(error)
}

type RTCEvent

type RTCEvent struct {
	Type RTCEventType

	Participant       *lksdk.RemoteParticipant
	ChangedAttributes map[string]string
	Track             *webrtc.TrackRemote
	Publication       *lksdk.RemoteTrackPublication
	LocalPublication  *lksdk.LocalTrackPublication
	DisconnectReason  livekit.DisconnectReason
	DataPacket        lksdk.DataPacket
	DataReceiveParams lksdk.DataReceiveParams

	TranscriptionSegments  []*lksdk.TranscriptionSegment
	TranscribedParticipant lksdk.Participant
	TranscribedPublication lksdk.TrackPublication
}

RTCEvent contains only SDK-owned handles whose public methods are safe to call after the callback returns. TranscriptionSegments and data payloads are defensively copied by the bridge.

type RTCEventType

type RTCEventType string

RTCEventType is the lossless control-event vocabulary emitted by RTCBridge.

const (
	RTCEventParticipantConnected         RTCEventType = "participant_connected"
	RTCEventParticipantDisconnected      RTCEventType = "participant_disconnected"
	RTCEventParticipantAttributesChanged RTCEventType = "participant_attributes_changed"
	RTCEventTrackPublished               RTCEventType = "track_published"
	RTCEventTrackUnpublished             RTCEventType = "track_unpublished"
	RTCEventTrackSubscribed              RTCEventType = "track_subscribed"
	RTCEventTrackUnsubscribed            RTCEventType = "track_unsubscribed"
	RTCEventLocalTrackPublished          RTCEventType = "local_track_published"
	RTCEventLocalTrackUnpublished        RTCEventType = "local_track_unpublished"
	RTCEventLocalTrackSubscribed         RTCEventType = "local_track_subscribed"
	RTCEventReconnecting                 RTCEventType = "reconnecting"
	RTCEventReconnected                  RTCEventType = "reconnected"
	RTCEventDisconnected                 RTCEventType = "disconnected"
	RTCEventDataPacket                   RTCEventType = "data_packet"
	RTCEventTranscription                RTCEventType = "transcription"
)

type RTCSubscription

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

RTCSubscription is a single-consumer, explicitly closable event stream.

func (*RTCSubscription) Close

func (s *RTCSubscription) Close() error

func (*RTCSubscription) Recv

func (s *RTCSubscription) Recv(ctx context.Context) (RTCEvent, error)

Jump to

Keyboard shortcuts

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