Documentation ¶
Index ¶
- Constants
- Variables
- func CreateKeyProvider(conf *config.Config) (auth.KeyProvider, error)
- func CreateNodeSelector(conf *config.Config) (routing.NodeSelector, error)
- func CreateWebhookNotifier(conf *config.Config, provider auth.KeyProvider) (webhook.Notifier, error)
- func EnsureAdminPermission(ctx context.Context, room string) error
- func EnsureCreatePermission(ctx context.Context) error
- func EnsureJoinPermission(ctx context.Context) (name string, err error)
- func EnsureListPermission(ctx context.Context) error
- func EnsureRecordPermission(ctx context.Context) error
- func GetGrants(ctx context.Context) *auth.ClaimGrants
- func InitializeRouter(conf *config.Config, currentNode routing.LocalNode) (routing.Router, error)
- func IsValidDomain(domain string) bool
- func NewTurnServer(conf *config.Config, roomStore RoomStore, node routing.LocalNode) (*turn.Server, error)
- func SetAuthorizationToken(r *http.Request, token string)
- type APIKeyAuthMiddleware
- type LivekitServer
- type LocalRoomManager
- func (r *LocalRoomManager) CleanupRooms() error
- func (r *LocalRoomManager) CloseIdleRooms()
- func (r *LocalRoomManager) DeleteRoom(ctx context.Context, roomName string) error
- func (r *LocalRoomManager) GetRoom(ctx context.Context, roomName string) *rtc.Room
- func (r *LocalRoomManager) HasParticipants() bool
- func (r *LocalRoomManager) StartSession(ctx context.Context, roomName string, pi routing.ParticipantInit, ...)
- func (r *LocalRoomManager) Stop()
- type LocalRoomStore
- func (p *LocalRoomStore) DeleteParticipant(ctx context.Context, roomName, identity string) error
- func (p *LocalRoomStore) DeleteRoom(ctx context.Context, idOrName string) error
- func (p *LocalRoomStore) ListParticipants(ctx context.Context, roomName string) ([]*livekit.ParticipantInfo, error)
- func (p *LocalRoomStore) ListRooms(ctx context.Context) ([]*livekit.Room, error)
- func (p *LocalRoomStore) LoadParticipant(ctx context.Context, roomName, identity string) (*livekit.ParticipantInfo, error)
- func (p *LocalRoomStore) LoadRoom(ctx context.Context, idOrName string) (*livekit.Room, error)
- func (p *LocalRoomStore) LockRoom(ctx context.Context, name string, duration time.Duration) (string, error)
- func (p *LocalRoomStore) StoreParticipant(ctx context.Context, roomName string, participant *livekit.ParticipantInfo) error
- func (p *LocalRoomStore) StoreRoom(ctx context.Context, room *livekit.Room) error
- func (p *LocalRoomStore) UnlockRoom(ctx context.Context, name string, uid string) error
- type RTCService
- type RecordingService
- func (s *RecordingService) AddOutput(ctx context.Context, req *livekit.AddOutputRequest) (*emptypb.Empty, error)
- func (s *RecordingService) EndRecording(ctx context.Context, req *livekit.EndRecordingRequest) (*emptypb.Empty, error)
- func (s *RecordingService) RemoveOutput(ctx context.Context, req *livekit.RemoveOutputRequest) (*emptypb.Empty, error)
- func (s *RecordingService) Start()
- func (s *RecordingService) StartRecording(ctx context.Context, req *livekit.StartRecordingRequest) (*livekit.StartRecordingResponse, error)
- func (s *RecordingService) Stop()
- type RedisRoomStore
- func (p *RedisRoomStore) DeleteParticipant(ctx context.Context, roomName, identity string) error
- func (p *RedisRoomStore) DeleteRoom(ctx context.Context, idOrName string) error
- func (p *RedisRoomStore) ListParticipants(ctx context.Context, roomName string) ([]*livekit.ParticipantInfo, error)
- func (p *RedisRoomStore) ListRooms(ctx context.Context) ([]*livekit.Room, error)
- func (p *RedisRoomStore) LoadParticipant(ctx context.Context, roomName, identity string) (*livekit.ParticipantInfo, error)
- func (p *RedisRoomStore) LoadRoom(ctx context.Context, idOrName string) (*livekit.Room, error)
- func (p *RedisRoomStore) LockRoom(ctx context.Context, name string, duration time.Duration) (string, error)
- func (p *RedisRoomStore) StoreParticipant(ctx context.Context, roomName string, participant *livekit.ParticipantInfo) error
- func (p *RedisRoomStore) StoreRoom(ctx context.Context, room *livekit.Room) error
- func (p *RedisRoomStore) UnlockRoom(ctx context.Context, name string, uid string) error
- type RoomAllocator
- type RoomManager
- type RoomService
- func (s *RoomService) CreateRoom(ctx context.Context, req *livekit.CreateRoomRequest) (rm *livekit.Room, err error)
- func (s *RoomService) DeleteRoom(ctx context.Context, req *livekit.DeleteRoomRequest) (*livekit.DeleteRoomResponse, error)
- func (s *RoomService) GetParticipant(ctx context.Context, req *livekit.RoomParticipantIdentity) (res *livekit.ParticipantInfo, err error)
- func (s *RoomService) ListParticipants(ctx context.Context, req *livekit.ListParticipantsRequest) (res *livekit.ListParticipantsResponse, err error)
- func (s *RoomService) ListRooms(ctx context.Context, req *livekit.ListRoomsRequest) (res *livekit.ListRoomsResponse, err error)
- func (s *RoomService) MutePublishedTrack(ctx context.Context, req *livekit.MuteRoomTrackRequest) (res *livekit.MuteRoomTrackResponse, err error)
- func (s *RoomService) RemoveParticipant(ctx context.Context, req *livekit.RoomParticipantIdentity) (res *livekit.RemoveParticipantResponse, err error)
- func (s *RoomService) SendData(ctx context.Context, req *livekit.SendDataRequest) (*livekit.SendDataResponse, error)
- func (s *RoomService) UpdateParticipant(ctx context.Context, req *livekit.UpdateParticipantRequest) (*livekit.ParticipantInfo, error)
- func (s *RoomService) UpdateRoomMetadata(ctx context.Context, req *livekit.UpdateRoomMetadataRequest) (*livekit.Room, error)
- func (s *RoomService) UpdateSubscriptions(ctx context.Context, req *livekit.UpdateSubscriptionsRequest) (*livekit.UpdateSubscriptionsResponse, error)
- type RoomStore
- type WSSignalConnection
Constants ¶
const ( // RoomsKey is hash of room_name => Room proto RoomsKey = "rooms" // RoomIdMap is hash of room_id => room name RoomIdMap = "room_id_map" // RoomParticipantsPrefix is hash of participant_name => ParticipantInfo // a key for each room, with expiration RoomParticipantsPrefix = "room_participants:" // RoomLockPrefix is a simple key containing a provided lock uid RoomLockPrefix = "room_lock:" )
Variables ¶
var ( ErrRoomNotFound = errors.New("requested room does not exist") ErrRoomLockFailed = errors.New("could not lock room") ErrRoomUnlockFailed = errors.New("could not unlock room, lock token does not match") ErrParticipantNotFound = errors.New("participant does not exist") ErrTrackNotFound = errors.New("track is not found") ErrWebHookMissingAPIKey = errors.New("api_key is required to use webhooks") ErrUnsupportedSelector = errors.New("unsupported node selector") )
var (
ErrPermissionDenied = errors.New("permissions denied")
)
var ServiceSet = wire.NewSet( createRedisClient, createMessageBus, createRouter, createStore, CreateKeyProvider, CreateWebhookNotifier, CreateNodeSelector, NewRecordingService, NewRoomAllocator, NewRoomService, NewRTCService, NewLivekitServer, NewLocalRoomManager, NewTurnServer, config.GetAudioConfig, wire.Bind(new(RoomManager), new(*LocalRoomManager)), wire.Bind(new(livekit.RoomService), new(*RoomService)), )
Functions ¶
func CreateKeyProvider ¶ added in v0.12.5
func CreateKeyProvider(conf *config.Config) (auth.KeyProvider, error)
func CreateNodeSelector ¶ added in v0.12.5
func CreateNodeSelector(conf *config.Config) (routing.NodeSelector, error)
func CreateWebhookNotifier ¶ added in v0.12.5
func EnsureCreatePermission ¶
func EnsureListPermission ¶
func EnsureRecordPermission ¶ added in v0.12.1
func InitializeRouter ¶ added in v0.12.2
func IsValidDomain ¶ added in v0.12.2
func NewTurnServer ¶
func SetAuthorizationToken ¶
Types ¶
type APIKeyAuthMiddleware ¶
type APIKeyAuthMiddleware struct {
// contains filtered or unexported fields
}
authentication middleware
func NewAPIKeyAuthMiddleware ¶
func NewAPIKeyAuthMiddleware(provider auth.KeyProvider) *APIKeyAuthMiddleware
func (*APIKeyAuthMiddleware) ServeHTTP ¶
func (m *APIKeyAuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type LivekitServer ¶
type LivekitServer struct {
// contains filtered or unexported fields
}
func InitializeServer ¶
func NewLivekitServer ¶
func NewLivekitServer(conf *config.Config, roomService livekit.RoomService, recService *RecordingService, rtcService *RTCService, keyProvider auth.KeyProvider, router routing.Router, roomManager *LocalRoomManager, turnServer *turn.Server, currentNode routing.LocalNode, ) (s *LivekitServer, err error)
func (*LivekitServer) IsRunning ¶
func (s *LivekitServer) IsRunning() bool
func (*LivekitServer) Node ¶
func (s *LivekitServer) Node() *livekit.Node
func (*LivekitServer) RoomManager ¶ added in v0.9.2
func (s *LivekitServer) RoomManager() RoomManager
func (*LivekitServer) Start ¶
func (s *LivekitServer) Start() error
func (*LivekitServer) Stop ¶
func (s *LivekitServer) Stop(force bool)
type LocalRoomManager ¶ added in v0.12.4
type LocalRoomManager struct { RoomStore // contains filtered or unexported fields }
LocalRoomManager manages rooms and its interaction with participants. It's responsible for creating, deleting rooms, as well as running sessions for participants
func NewLocalRoomManager ¶ added in v0.12.4
func (*LocalRoomManager) CleanupRooms ¶ added in v0.12.4
func (r *LocalRoomManager) CleanupRooms() error
CleanupRooms cleans up after old rooms that have been around for awhile
func (*LocalRoomManager) CloseIdleRooms ¶ added in v0.12.4
func (r *LocalRoomManager) CloseIdleRooms()
func (*LocalRoomManager) DeleteRoom ¶ added in v0.12.4
func (r *LocalRoomManager) DeleteRoom(ctx context.Context, roomName string) error
DeleteRoom completely deletes all room information, including active sessions, room store, and routing info
func (*LocalRoomManager) HasParticipants ¶ added in v0.13.0
func (r *LocalRoomManager) HasParticipants() bool
func (*LocalRoomManager) StartSession ¶ added in v0.12.4
func (r *LocalRoomManager) StartSession(ctx context.Context, roomName string, pi routing.ParticipantInit, requestSource routing.MessageSource, responseSink routing.MessageSink)
StartSession starts WebRTC session when a new participant is connected, takes place on RTC node
func (*LocalRoomManager) Stop ¶ added in v0.12.4
func (r *LocalRoomManager) Stop()
type LocalRoomStore ¶
type LocalRoomStore struct {
// contains filtered or unexported fields
}
encapsulates CRUD operations for room settings
func NewLocalRoomStore ¶
func NewLocalRoomStore() *LocalRoomStore
func (*LocalRoomStore) DeleteParticipant ¶
func (p *LocalRoomStore) DeleteParticipant(ctx context.Context, roomName, identity string) error
func (*LocalRoomStore) DeleteRoom ¶
func (p *LocalRoomStore) DeleteRoom(ctx context.Context, idOrName string) error
func (*LocalRoomStore) ListParticipants ¶
func (p *LocalRoomStore) ListParticipants(ctx context.Context, roomName string) ([]*livekit.ParticipantInfo, error)
func (*LocalRoomStore) LoadParticipant ¶ added in v0.12.4
func (p *LocalRoomStore) LoadParticipant(ctx context.Context, roomName, identity string) (*livekit.ParticipantInfo, error)
func (*LocalRoomStore) StoreParticipant ¶ added in v0.12.4
func (p *LocalRoomStore) StoreParticipant(ctx context.Context, roomName string, participant *livekit.ParticipantInfo) error
func (*LocalRoomStore) UnlockRoom ¶ added in v0.10.6
type RTCService ¶
type RTCService struct {
// contains filtered or unexported fields
}
func NewRTCService ¶
func NewRTCService(conf *config.Config, ra *RoomAllocator, router routing.Router, currentNode routing.LocalNode) *RTCService
func (*RTCService) ServeHTTP ¶
func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*RTCService) Validate ¶ added in v0.11.0
func (s *RTCService) Validate(w http.ResponseWriter, r *http.Request)
type RecordingService ¶ added in v0.12.1
type RecordingService struct {
// contains filtered or unexported fields
}
func NewRecordingService ¶ added in v0.12.1
func NewRecordingService(mb utils.MessageBus, notifier webhook.Notifier) *RecordingService
func (*RecordingService) AddOutput ¶ added in v0.13.2
func (s *RecordingService) AddOutput(ctx context.Context, req *livekit.AddOutputRequest) (*emptypb.Empty, error)
func (*RecordingService) EndRecording ¶ added in v0.12.1
func (s *RecordingService) EndRecording(ctx context.Context, req *livekit.EndRecordingRequest) (*emptypb.Empty, error)
func (*RecordingService) RemoveOutput ¶ added in v0.13.2
func (s *RecordingService) RemoveOutput(ctx context.Context, req *livekit.RemoveOutputRequest) (*emptypb.Empty, error)
func (*RecordingService) Start ¶ added in v0.13.0
func (s *RecordingService) Start()
func (*RecordingService) StartRecording ¶ added in v0.12.1
func (s *RecordingService) StartRecording(ctx context.Context, req *livekit.StartRecordingRequest) (*livekit.StartRecordingResponse, error)
func (*RecordingService) Stop ¶ added in v0.13.0
func (s *RecordingService) Stop()
type RedisRoomStore ¶
type RedisRoomStore struct {
// contains filtered or unexported fields
}
func NewRedisRoomStore ¶
func NewRedisRoomStore(rc *redis.Client) *RedisRoomStore
func (*RedisRoomStore) DeleteParticipant ¶
func (p *RedisRoomStore) DeleteParticipant(ctx context.Context, roomName, identity string) error
func (*RedisRoomStore) DeleteRoom ¶
func (p *RedisRoomStore) DeleteRoom(ctx context.Context, idOrName string) error
func (*RedisRoomStore) ListParticipants ¶
func (p *RedisRoomStore) ListParticipants(ctx context.Context, roomName string) ([]*livekit.ParticipantInfo, error)
func (*RedisRoomStore) LoadParticipant ¶ added in v0.12.4
func (p *RedisRoomStore) LoadParticipant(ctx context.Context, roomName, identity string) (*livekit.ParticipantInfo, error)
func (*RedisRoomStore) StoreParticipant ¶ added in v0.12.4
func (p *RedisRoomStore) StoreParticipant(ctx context.Context, roomName string, participant *livekit.ParticipantInfo) error
func (*RedisRoomStore) UnlockRoom ¶ added in v0.10.6
type RoomAllocator ¶ added in v0.13.0
type RoomAllocator struct {
// contains filtered or unexported fields
}
func NewRoomAllocator ¶ added in v0.13.0
func NewRoomAllocator(conf *config.Config, router routing.Router, selector routing.NodeSelector, rs RoomStore) *RoomAllocator
func (*RoomAllocator) CreateRoom ¶ added in v0.13.0
func (r *RoomAllocator) CreateRoom(ctx context.Context, req *livekit.CreateRoomRequest) (*livekit.Room, error)
CreateRoom creates a new room from a request and allocates it to a node to handle it'll also monitor its state, and cleans it up when appropriate
type RoomManager ¶
type RoomManager interface { RoomStore GetRoom(ctx context.Context, roomName string) *rtc.Room DeleteRoom(ctx context.Context, roomName string) error StartSession(ctx context.Context, roomName string, pi routing.ParticipantInit, requestSource routing.MessageSource, responseSink routing.MessageSink) CleanupRooms() error CloseIdleRooms() HasParticipants() bool Stop() }
type RoomService ¶
type RoomService struct {
// contains filtered or unexported fields
}
A rooms service that supports a single node
func NewRoomService ¶
func NewRoomService(ra *RoomAllocator, rs RoomStore, router routing.Router) (svc *RoomService, err error)
func (*RoomService) CreateRoom ¶
func (s *RoomService) CreateRoom(ctx context.Context, req *livekit.CreateRoomRequest) (rm *livekit.Room, err error)
func (*RoomService) DeleteRoom ¶
func (s *RoomService) DeleteRoom(ctx context.Context, req *livekit.DeleteRoomRequest) (*livekit.DeleteRoomResponse, error)
func (*RoomService) GetParticipant ¶
func (s *RoomService) GetParticipant(ctx context.Context, req *livekit.RoomParticipantIdentity) (res *livekit.ParticipantInfo, err error)
func (*RoomService) ListParticipants ¶
func (s *RoomService) ListParticipants(ctx context.Context, req *livekit.ListParticipantsRequest) (res *livekit.ListParticipantsResponse, err error)
func (*RoomService) ListRooms ¶
func (s *RoomService) ListRooms(ctx context.Context, req *livekit.ListRoomsRequest) (res *livekit.ListRoomsResponse, err error)
func (*RoomService) MutePublishedTrack ¶
func (s *RoomService) MutePublishedTrack(ctx context.Context, req *livekit.MuteRoomTrackRequest) (res *livekit.MuteRoomTrackResponse, err error)
func (*RoomService) RemoveParticipant ¶
func (s *RoomService) RemoveParticipant(ctx context.Context, req *livekit.RoomParticipantIdentity) (res *livekit.RemoveParticipantResponse, err error)
func (*RoomService) SendData ¶ added in v0.12.2
func (s *RoomService) SendData(ctx context.Context, req *livekit.SendDataRequest) (*livekit.SendDataResponse, error)
func (*RoomService) UpdateParticipant ¶
func (s *RoomService) UpdateParticipant(ctx context.Context, req *livekit.UpdateParticipantRequest) (*livekit.ParticipantInfo, error)
func (*RoomService) UpdateRoomMetadata ¶ added in v0.13.1
func (s *RoomService) UpdateRoomMetadata(ctx context.Context, req *livekit.UpdateRoomMetadataRequest) (*livekit.Room, error)
func (*RoomService) UpdateSubscriptions ¶ added in v0.9.14
func (s *RoomService) UpdateSubscriptions(ctx context.Context, req *livekit.UpdateSubscriptionsRequest) (*livekit.UpdateSubscriptionsResponse, error)
type RoomStore ¶
type RoomStore interface { StoreRoom(ctx context.Context, room *livekit.Room) error LoadRoom(ctx context.Context, idOrName string) (*livekit.Room, error) ListRooms(ctx context.Context) ([]*livekit.Room, error) DeleteRoom(ctx context.Context, idOrName string) error // enable locking on a specific room to prevent race // returns a (lock uuid, error) LockRoom(ctx context.Context, name string, duration time.Duration) (string, error) UnlockRoom(ctx context.Context, name string, uid string) error StoreParticipant(ctx context.Context, roomName string, participant *livekit.ParticipantInfo) error LoadParticipant(ctx context.Context, roomName, identity string) (*livekit.ParticipantInfo, error) ListParticipants(ctx context.Context, roomName string) ([]*livekit.ParticipantInfo, error) DeleteParticipant(ctx context.Context, roomName, identity string) error }
encapsulates CRUD operations for room settings look up participant
type WSSignalConnection ¶
type WSSignalConnection struct {
// contains filtered or unexported fields
}
func NewWSSignalConnection ¶
func NewWSSignalConnection(conn types.WebsocketClient) *WSSignalConnection
func (*WSSignalConnection) ReadRequest ¶
func (c *WSSignalConnection) ReadRequest() (*livekit.SignalRequest, error)
func (*WSSignalConnection) WriteResponse ¶
func (c *WSSignalConnection) WriteResponse(msg *livekit.SignalResponse) error