service

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: Apache-2.0 Imports: 44 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// RoomsKey is hash of room_name => Room proto
	RoomsKey = "rooms"

	// RoomParticipantsPrefix is hash of participant_name => ParticipantInfo
	RoomParticipantsPrefix = "room_participants:"

	// RoomLockPrefix is a simple key containing a provided lock uid
	RoomLockPrefix = "room_lock:"
)
View Source
const (
	LivekitRealm = "livekit"
)

Variables

View Source
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")
	ErrOperationFailed      = errors.New("operation cannot be completed")
)
View Source
var (
	ErrPermissionDenied = errors.New("permissions denied")
)

Functions

func EnsureAdminPermission

func EnsureAdminPermission(ctx context.Context, room livekit.RoomName) error

func EnsureCreatePermission

func EnsureCreatePermission(ctx context.Context) error

func EnsureJoinPermission

func EnsureJoinPermission(ctx context.Context) (name livekit.RoomName, err error)

func EnsureListPermission

func EnsureListPermission(ctx context.Context) error

func EnsureRecordPermission added in v0.12.1

func EnsureRecordPermission(ctx context.Context) error

func GetGrants

func GetGrants(ctx context.Context) *auth.ClaimGrants

func InitializeRouter added in v0.12.2

func InitializeRouter(conf *config.Config, currentNode routing.LocalNode) (routing.Router, error)

func IsValidDomain added in v0.12.2

func IsValidDomain(domain string) bool

func NewTurnServer

func NewTurnServer(conf *config.Config, authHandler turn.AuthHandler) (*turn.Server, error)

func ParseClientInfo added in v0.15.3

func ParseClientInfo(values url.Values) *livekit.ClientInfo

func SetAuthorizationToken

func SetAuthorizationToken(r *http.Request, token string)

Types

type APIKeyAuthMiddleware

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

authentication middleware

func NewAPIKeyAuthMiddleware

func NewAPIKeyAuthMiddleware(provider auth.KeyProvider) *APIKeyAuthMiddleware

func (*APIKeyAuthMiddleware) ServeHTTP

type LivekitServer

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

func InitializeServer

func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*LivekitServer, error)

func NewLivekitServer

func NewLivekitServer(conf *config.Config,
	roomService livekit.RoomService,
	recService *RecordingService,
	rtcService *RTCService,
	keyProvider auth.KeyProvider,
	router routing.Router,
	roomManager *RoomManager,
	turnServer *turn.Server,
	currentNode routing.LocalNode,
) (s *LivekitServer, err error)

func (*LivekitServer) HTTPPort added in v0.15.3

func (s *LivekitServer) HTTPPort() int

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 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(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) error

func (*LocalRoomStore) DeleteRoom

func (p *LocalRoomStore) DeleteRoom(ctx context.Context, name livekit.RoomName) error

func (*LocalRoomStore) ListParticipants

func (p *LocalRoomStore) ListParticipants(_ context.Context, roomName livekit.RoomName) ([]*livekit.ParticipantInfo, error)

func (*LocalRoomStore) ListRooms

func (p *LocalRoomStore) ListRooms(_ context.Context, names []livekit.RoomName) ([]*livekit.Room, error)

func (*LocalRoomStore) LoadParticipant added in v0.12.4

func (p *LocalRoomStore) LoadParticipant(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error)

func (*LocalRoomStore) LoadRoom added in v0.12.4

func (p *LocalRoomStore) LoadRoom(_ context.Context, name livekit.RoomName) (*livekit.Room, error)

func (*LocalRoomStore) LockRoom added in v0.10.6

func (*LocalRoomStore) StoreParticipant added in v0.12.4

func (p *LocalRoomStore) StoreParticipant(_ context.Context, roomName livekit.RoomName, participant *livekit.ParticipantInfo) error

func (*LocalRoomStore) StoreRoom added in v0.12.4

func (p *LocalRoomStore) StoreRoom(_ context.Context, room *livekit.Room) error

func (*LocalRoomStore) UnlockRoom added in v0.10.6

func (p *LocalRoomStore) UnlockRoom(_ context.Context, _ livekit.RoomName, _ string) error

type RORoomStore added in v0.14.2

type RORoomStore interface {
	LoadRoom(ctx context.Context, name livekit.RoomName) (*livekit.Room, error)
	// ListRooms returns currently active rooms. if names is not nil, it'll filter and return
	// only rooms that match
	ListRooms(ctx context.Context, names []livekit.RoomName) ([]*livekit.Room, error)

	LoadParticipant(ctx context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error)
	ListParticipants(ctx context.Context, roomName livekit.RoomName) ([]*livekit.ParticipantInfo, error)
}

type RTCService

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

func NewRTCService

func NewRTCService(
	conf *config.Config,
	ra RoomAllocator,
	store RORoomStore,
	router routing.MessageRouter,
	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, telemetry telemetry.TelemetryService) *RecordingService

func (*RecordingService) AddOutput added in v0.13.2

func (*RecordingService) EndRecording added in v0.12.1

func (*RecordingService) RemoveOutput added in v0.13.2

func (*RecordingService) Start added in v0.13.0

func (s *RecordingService) Start()

func (*RecordingService) StartRecording added in v0.12.1

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(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) error

func (*RedisRoomStore) DeleteRoom

func (p *RedisRoomStore) DeleteRoom(ctx context.Context, name livekit.RoomName) error

func (*RedisRoomStore) ListParticipants

func (p *RedisRoomStore) ListParticipants(_ context.Context, roomName livekit.RoomName) ([]*livekit.ParticipantInfo, error)

func (*RedisRoomStore) ListRooms

func (p *RedisRoomStore) ListRooms(_ context.Context, names []livekit.RoomName) ([]*livekit.Room, error)

func (*RedisRoomStore) LoadParticipant added in v0.12.4

func (p *RedisRoomStore) LoadParticipant(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error)

func (*RedisRoomStore) LoadRoom added in v0.12.4

func (p *RedisRoomStore) LoadRoom(_ context.Context, name livekit.RoomName) (*livekit.Room, error)

func (*RedisRoomStore) LockRoom added in v0.10.6

func (p *RedisRoomStore) LockRoom(_ context.Context, name livekit.RoomName, duration time.Duration) (string, error)

func (*RedisRoomStore) StoreParticipant added in v0.12.4

func (p *RedisRoomStore) StoreParticipant(_ context.Context, roomName livekit.RoomName, participant *livekit.ParticipantInfo) error

func (*RedisRoomStore) StoreRoom added in v0.12.4

func (p *RedisRoomStore) StoreRoom(_ context.Context, room *livekit.Room) error

func (*RedisRoomStore) UnlockRoom added in v0.10.6

func (p *RedisRoomStore) UnlockRoom(_ context.Context, name livekit.RoomName, uid string) error

type RoomAllocator added in v0.13.0

type RoomAllocator interface {
	CreateRoom(ctx context.Context, req *livekit.CreateRoomRequest) (*livekit.Room, error)
}

func NewRoomAllocator added in v0.13.0

func NewRoomAllocator(conf *config.Config, router routing.Router, rs RoomStore) (RoomAllocator, error)

type RoomManager

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

RoomManager 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 NewLocalRoomManager(
	conf *config.Config,
	roomStore RoomStore,
	currentNode routing.LocalNode,
	router routing.Router,
	telemetry telemetry.TelemetryService,
) (*RoomManager, error)

func (*RoomManager) CleanupRooms

func (r *RoomManager) CleanupRooms() error

CleanupRooms cleans up after old rooms that have been around for a while

func (*RoomManager) CloseIdleRooms

func (r *RoomManager) CloseIdleRooms()

func (*RoomManager) DeleteRoom

func (r *RoomManager) DeleteRoom(ctx context.Context, roomName livekit.RoomName) error

DeleteRoom completely deletes all room information, including active sessions, room store, and routing info

func (*RoomManager) GetRoom added in v0.9.2

func (r *RoomManager) GetRoom(_ context.Context, roomName livekit.RoomName) *rtc.Room

func (*RoomManager) HasParticipants added in v0.13.0

func (r *RoomManager) HasParticipants() bool

func (*RoomManager) StartSession

func (r *RoomManager) StartSession(ctx context.Context, roomName livekit.RoomName, 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 (*RoomManager) Stop

func (r *RoomManager) 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 RORoomStore, router routing.MessageRouter) (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 (*RoomService) GetParticipant

func (s *RoomService) GetParticipant(ctx context.Context, req *livekit.RoomParticipantIdentity) (res *livekit.ParticipantInfo, err error)

func (*RoomService) ListParticipants

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 (*RoomService) SendData added in v0.12.2

func (*RoomService) UpdateParticipant

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

type RoomStore

type RoomStore interface {
	RORoomStore

	// enable locking on a specific room to prevent race
	// returns a (lock uuid, error)
	LockRoom(ctx context.Context, name livekit.RoomName, duration time.Duration) (string, error)
	UnlockRoom(ctx context.Context, name livekit.RoomName, uid string) error

	StoreRoom(ctx context.Context, room *livekit.Room) error
	DeleteRoom(ctx context.Context, name livekit.RoomName) error

	StoreParticipant(ctx context.Context, roomName livekit.RoomName, participant *livekit.ParticipantInfo) error
	DeleteParticipant(ctx context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) error
}

encapsulates CRUD operations for room settings

type StandardRoomAllocator added in v0.13.7

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

func (*StandardRoomAllocator) CreateRoom added in v0.13.7

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 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

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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