service

package
v0.0.0-...-c2cc3df Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 73 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionKey = "livekit_version"

	// RoomsKey is hash of room_name => Room proto
	RoomsKey        = "rooms"
	RoomInternalKey = "room_internal"

	// EgressKey is a hash of egressID => egress info
	EgressKey        = "egress"
	EndedEgressKey   = "ended_egress"
	RoomEgressPrefix = "egress:room:"

	// IngressKey is a hash of ingressID => ingress info
	IngressKey         = "ingress"
	StreamKeyKey       = "{ingress}_stream_key"
	IngressStatePrefix = "{ingress}_state:"
	RoomIngressPrefix  = "room_{ingress}:"

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

	// RoomLockPrefix is a simple key containing a provided lock uid
	RoomLockPrefix = "room_lock:"

	// Agents
	AgentDispatchPrefix = "agent_dispatch:"
	AgentJobPrefix      = "agent_job:"
)
View Source
const (
	SIPTrunkKey         = "sip_trunk"
	SIPInboundTrunkKey  = "sip_inbound_trunk"
	SIPOutboundTrunkKey = "sip_outbound_trunk"
	SIPDispatchRuleKey  = "sip_dispatch_rule"
)
View Source
const (
	LivekitRealm = "livekit"
)

Variables

View Source
var (
	ErrPermissionDenied          = errors.New("permissions denied")
	ErrMissingAuthorization      = errors.New("invalid authorization header. Must start with " + bearerPrefix)
	ErrInvalidAuthorizationToken = errors.New("invalid authorization token")
	ErrInvalidAPIKey             = errors.New("invalid API key")
)
View Source
var (
	ErrEgressNotFound                   = psrpc.NewErrorf(psrpc.NotFound, "egress does not exist")
	ErrEgressNotConnected               = psrpc.NewErrorf(psrpc.Internal, "egress not connected (redis required)")
	ErrIdentityEmpty                    = psrpc.NewErrorf(psrpc.InvalidArgument, "identity cannot be empty")
	ErrIngressNotConnected              = psrpc.NewErrorf(psrpc.Internal, "ingress not connected (redis required)")
	ErrIngressNotFound                  = psrpc.NewErrorf(psrpc.NotFound, "ingress does not exist")
	ErrIngressNonReusable               = psrpc.NewErrorf(psrpc.InvalidArgument, "ingress is not reusable and cannot be modified")
	ErrNameExceedsLimits                = psrpc.NewErrorf(psrpc.InvalidArgument, "name length exceeds limits")
	ErrMetadataExceedsLimits            = psrpc.NewErrorf(psrpc.InvalidArgument, "metadata size exceeds limits")
	ErrAttributeExceedsLimits           = psrpc.NewErrorf(psrpc.InvalidArgument, "attribute size exceeds limits")
	ErrRoomNameExceedsLimits            = psrpc.NewErrorf(psrpc.InvalidArgument, "room name length exceeds limits")
	ErrParticipantIdentityExceedsLimits = psrpc.NewErrorf(psrpc.InvalidArgument, "participant identity length exceeds limits")
	ErrOperationFailed                  = psrpc.NewErrorf(psrpc.Internal, "operation cannot be completed")
	ErrParticipantNotFound              = psrpc.NewErrorf(psrpc.NotFound, "participant does not exist")
	ErrRoomNotFound                     = psrpc.NewErrorf(psrpc.NotFound, "requested room does not exist")
	ErrRoomLockFailed                   = psrpc.NewErrorf(psrpc.Internal, "could not lock room")
	ErrRoomUnlockFailed                 = psrpc.NewErrorf(psrpc.Internal, "could not unlock room, lock token does not match")
	ErrRemoteUnmuteNoteEnabled          = psrpc.NewErrorf(psrpc.FailedPrecondition, "remote unmute not enabled")
	ErrTrackNotFound                    = psrpc.NewErrorf(psrpc.NotFound, "track is not found")
	ErrWebHookMissingAPIKey             = psrpc.NewErrorf(psrpc.InvalidArgument, "api_key is required to use webhooks")
	ErrSIPNotConnected                  = psrpc.NewErrorf(psrpc.Internal, "sip not connected (redis required)")
	ErrSIPTrunkNotFound                 = psrpc.NewErrorf(psrpc.NotFound, "requested sip trunk does not exist")
	ErrSIPDispatchRuleNotFound          = psrpc.NewErrorf(psrpc.NotFound, "requested sip dispatch rule does not exist")
	ErrSIPParticipantNotFound           = psrpc.NewErrorf(psrpc.NotFound, "requested sip participant does not exist")
)

Functions

func AppendLogFields

func AppendLogFields(ctx context.Context, fields ...interface{})

func DispatchAgentWorkerSignal

func DispatchAgentWorkerSignal(c agent.SignalConn, h agent.WorkerSignalHandler, l logger.Logger) bool

func EnsureAdminPermission

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

func EnsureCreatePermission

func EnsureCreatePermission(ctx context.Context) error

func EnsureIngressAdminPermission

func EnsureIngressAdminPermission(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

func EnsureRecordPermission(ctx context.Context) error

func EnsureSIPAdminPermission

func EnsureSIPAdminPermission(ctx context.Context) error

func EnsureSIPCallPermission

func EnsureSIPCallPermission(ctx context.Context) error

func GenBasicAuthMiddleware

func GenBasicAuthMiddleware(username string, password string) func(http.ResponseWriter, *http.Request, http.HandlerFunc)

func GetAPIKey

func GetAPIKey(ctx context.Context) string

func GetClientIP

func GetClientIP(r *http.Request) string

func GetGrants

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

func GetRoomConfiguration

func GetRoomConfiguration(ctx context.Context) string

func HandshakeAgentWorker

func HandshakeAgentWorker(c agent.SignalConn, serverInfo *livekit.ServerInfo, protocol agent.WorkerProtocolVersion, l logger.Logger) (r agent.WorkerRegistration, ok bool)

func InitializeRouter

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

func IsValidDomain

func IsValidDomain(domain string) bool

func IsWebSocketCloseError

func IsWebSocketCloseError(err error) bool

IsWebSocketCloseError checks that error is normal/expected closure

func NewEgressLauncher

func NewEgressLauncher(client rpc.EgressClient, io IOClient) rtc.EgressLauncher

func NewTurnServer

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

func RemoveDoubleSlashes

func RemoveDoubleSlashes(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func SetAuthorizationToken

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

func TwirpLogger

func TwirpLogger() *twirp.ServerHooks

logging handling inspired by https://github.com/bakins/twirpzap License: Apache-2.0

func TwirpRequestStatusReporter

func TwirpRequestStatusReporter() *twirp.ServerHooks

func WithAPIKey

func WithAPIKey(ctx context.Context, grants *auth.ClaimGrants, apiKey string) context.Context

func WithGrants

func WithGrants(ctx context.Context, grants *auth.ClaimGrants, apiKey string) context.Context

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 AgentDispatchService

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

func NewAgentDispatchService

func NewAgentDispatchService(agentDispatchClient rpc.TypedAgentDispatchInternalClient, topicFormatter rpc.TopicFormatter) *AgentDispatchService

func (*AgentDispatchService) CreateDispatch

func (*AgentDispatchService) DeleteDispatch

func (*AgentDispatchService) ListDispatch

type AgentHandler

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

func NewAgentHandler

func NewAgentHandler(
	agentServer rpc.AgentInternalServer,
	keyProvider auth.KeyProvider,
	logger logger.Logger,
	serverInfo *livekit.ServerInfo,
	roomTopic string,
	publisherTopic string,
) *AgentHandler

func (*AgentHandler) CheckEnabled

func (*AgentHandler) DrainConnections

func (h *AgentHandler) DrainConnections(interval time.Duration)

func (*AgentHandler) HandleConnection

func (h *AgentHandler) HandleConnection(ctx context.Context, conn agent.SignalConn, protocol agent.WorkerProtocolVersion)

func (*AgentHandler) JobRequest

func (h *AgentHandler) JobRequest(ctx context.Context, job *livekit.Job) (*rpc.JobRequestResponse, error)

func (*AgentHandler) JobRequestAffinity

func (h *AgentHandler) JobRequestAffinity(ctx context.Context, job *livekit.Job) float32

func (*AgentHandler) JobTerminate

type AgentService

type AgentService struct {
	*AgentHandler
	// contains filtered or unexported fields
}

func NewAgentService

func NewAgentService(conf *config.Config,
	currentNode routing.LocalNode,
	bus psrpc.MessageBus,
	keyProvider auth.KeyProvider,
) (*AgentService, error)

func (*AgentService) ServeHTTP

func (s *AgentService) ServeHTTP(writer http.ResponseWriter, r *http.Request)

type AgentSocketUpgrader

type AgentSocketUpgrader struct {
	websocket.Upgrader
}

func (AgentSocketUpgrader) Upgrade

type AgentStore

type AgentStore interface {
	StoreAgentDispatch(ctx context.Context, dispatch *livekit.AgentDispatch) error
	DeleteAgentDispatch(ctx context.Context, dispatch *livekit.AgentDispatch) error
	ListAgentDispatches(ctx context.Context, roomName livekit.RoomName) ([]*livekit.AgentDispatch, error)

	StoreAgentJob(ctx context.Context, job *livekit.Job) error
	DeleteAgentJob(ctx context.Context, job *livekit.Job) error
}

type EgressService

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

func NewEgressService

func NewEgressService(
	client rpc.EgressClient,
	launcher rtc.EgressLauncher,
	store ServiceStore,
	io IOClient,
	rs livekit.RoomService,
) *EgressService

func (*EgressService) ListEgress

func (*EgressService) StartParticipantEgress

func (s *EgressService) StartParticipantEgress(ctx context.Context, req *livekit.ParticipantEgressRequest) (*livekit.EgressInfo, error)

func (*EgressService) StartRoomCompositeEgress

func (s *EgressService) StartRoomCompositeEgress(ctx context.Context, req *livekit.RoomCompositeEgressRequest) (*livekit.EgressInfo, error)

func (*EgressService) StartTrackCompositeEgress

func (s *EgressService) StartTrackCompositeEgress(ctx context.Context, req *livekit.TrackCompositeEgressRequest) (*livekit.EgressInfo, error)

func (*EgressService) StartTrackEgress

func (s *EgressService) StartTrackEgress(ctx context.Context, req *livekit.TrackEgressRequest) (*livekit.EgressInfo, error)

func (*EgressService) StartWebEgress

func (s *EgressService) StartWebEgress(ctx context.Context, req *livekit.WebEgressRequest) (*livekit.EgressInfo, error)

func (*EgressService) StopEgress

func (*EgressService) UpdateLayout

func (*EgressService) UpdateStream

type EgressStore

type EgressStore interface {
	StoreEgress(ctx context.Context, info *livekit.EgressInfo) error
	LoadEgress(ctx context.Context, egressID string) (*livekit.EgressInfo, error)
	ListEgress(ctx context.Context, roomName livekit.RoomName, active bool) ([]*livekit.EgressInfo, error)
	UpdateEgress(ctx context.Context, info *livekit.EgressInfo) error
}

type IOClient

type IOClient interface {
	CreateEgress(ctx context.Context, info *livekit.EgressInfo) (*emptypb.Empty, error)
	GetEgress(ctx context.Context, req *rpc.GetEgressRequest) (*livekit.EgressInfo, error)
	ListEgress(ctx context.Context, req *livekit.ListEgressRequest) (*livekit.ListEgressResponse, error)
	CreateIngress(ctx context.Context, req *livekit.IngressInfo) (*emptypb.Empty, error)
	UpdateIngressState(ctx context.Context, req *rpc.UpdateIngressStateRequest) (*emptypb.Empty, error)
}

type IOInfoService

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

func (*IOInfoService) CreateEgress

func (s *IOInfoService) CreateEgress(ctx context.Context, info *livekit.EgressInfo) (*emptypb.Empty, error)

func (*IOInfoService) CreateIngress

func (s *IOInfoService) CreateIngress(ctx context.Context, info *livekit.IngressInfo) (*emptypb.Empty, error)

func (*IOInfoService) GetEgress

func (*IOInfoService) GetIngressInfo

func (*IOInfoService) ListEgress

func (*IOInfoService) Start

func (s *IOInfoService) Start() error

func (*IOInfoService) Stop

func (s *IOInfoService) Stop()

func (*IOInfoService) UpdateEgress

func (s *IOInfoService) UpdateEgress(ctx context.Context, info *livekit.EgressInfo) (*emptypb.Empty, error)

func (*IOInfoService) UpdateIngressState

func (s *IOInfoService) UpdateIngressState(ctx context.Context, req *rpc.UpdateIngressStateRequest) (*emptypb.Empty, error)

func (*IOInfoService) UpdateMetrics

func (s *IOInfoService) UpdateMetrics(ctx context.Context, req *rpc.UpdateMetricsRequest) (*emptypb.Empty, error)

func (*IOInfoService) UpdateSIPCallState

func (s *IOInfoService) UpdateSIPCallState(ctx context.Context, req *rpc.UpdateSIPCallStateRequest) (*emptypb.Empty, error)

type IngressLauncher

type IngressLauncher interface {
	LaunchPullIngress(ctx context.Context, info *livekit.IngressInfo) (*livekit.IngressInfo, error)
}

type IngressService

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

func NewIngressService

func NewIngressService(
	conf *config.IngressConfig,
	nodeID livekit.NodeID,
	bus psrpc.MessageBus,
	psrpcClient rpc.IngressClient,
	store IngressStore,
	io IOClient,
	ts telemetry.TelemetryService,
) *IngressService

func NewIngressServiceWithIngressLauncher

func NewIngressServiceWithIngressLauncher(
	conf *config.IngressConfig,
	nodeID livekit.NodeID,
	bus psrpc.MessageBus,
	psrpcClient rpc.IngressClient,
	store IngressStore,
	io IOClient,
	ts telemetry.TelemetryService,
	launcher IngressLauncher,
) *IngressService

func (*IngressService) CreateIngress

func (*IngressService) CreateIngressWithUrl

func (s *IngressService) CreateIngressWithUrl(ctx context.Context, urlStr string, req *livekit.CreateIngressRequest) (*livekit.IngressInfo, error)

func (*IngressService) DeleteIngress

func (*IngressService) LaunchPullIngress

func (s *IngressService) LaunchPullIngress(ctx context.Context, info *livekit.IngressInfo) (*livekit.IngressInfo, error)

func (*IngressService) ListIngress

func (*IngressService) UpdateIngress

type IngressStore

type IngressStore interface {
	StoreIngress(ctx context.Context, info *livekit.IngressInfo) error
	LoadIngress(ctx context.Context, ingressID string) (*livekit.IngressInfo, error)
	LoadIngressFromStreamKey(ctx context.Context, streamKey string) (*livekit.IngressInfo, error)
	ListIngress(ctx context.Context, roomName livekit.RoomName) ([]*livekit.IngressInfo, error)
	UpdateIngress(ctx context.Context, info *livekit.IngressInfo) error
	UpdateIngressState(ctx context.Context, ingressId string, state *livekit.IngressState) error
	DeleteIngress(ctx context.Context, info *livekit.IngressInfo) error
}

type LayoutMetadata

type LayoutMetadata struct {
	Layout string `json:"layout"`
}

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,
	agentDispatchService *AgentDispatchService,
	egressService *EgressService,
	ingressService *IngressService,
	sipService *SIPService,
	ioService *IOInfoService,
	rtcService *RTCService,
	agentService *AgentService,
	keyProvider auth.KeyProvider,
	router routing.Router,
	roomManager *RoomManager,
	signalServer *SignalServer,
	turnServer *turn.Server,
	currentNode routing.LocalNode,
) (s *LivekitServer, err error)

func (*LivekitServer) HTTPPort

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

func (s *LivekitServer) RoomManager() *RoomManager

func (*LivekitServer) Start

func (s *LivekitServer) Start() error

func (*LivekitServer) Stop

func (s *LivekitServer) Stop(force bool)

type LocalStore

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

encapsulates CRUD operations for room settings

func NewLocalStore

func NewLocalStore() *LocalStore

func (*LocalStore) DeleteAgentDispatch

func (s *LocalStore) DeleteAgentDispatch(ctx context.Context, dispatch *livekit.AgentDispatch) error

func (*LocalStore) DeleteAgentJob

func (s *LocalStore) DeleteAgentJob(ctx context.Context, job *livekit.Job) error

func (*LocalStore) DeleteParticipant

func (s *LocalStore) DeleteParticipant(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) error

func (*LocalStore) DeleteRoom

func (s *LocalStore) DeleteRoom(ctx context.Context, roomName livekit.RoomName) error

func (*LocalStore) ListAgentDispatches

func (s *LocalStore) ListAgentDispatches(ctx context.Context, roomName livekit.RoomName) ([]*livekit.AgentDispatch, error)

func (*LocalStore) ListParticipants

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

func (*LocalStore) ListRooms

func (s *LocalStore) ListRooms(_ context.Context, roomNames []livekit.RoomName) ([]*livekit.Room, error)

func (*LocalStore) LoadParticipant

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

func (*LocalStore) LoadRoom

func (s *LocalStore) LoadRoom(_ context.Context, roomName livekit.RoomName, includeInternal bool) (*livekit.Room, *livekit.RoomInternal, error)

func (*LocalStore) LockRoom

func (*LocalStore) StoreAgentDispatch

func (s *LocalStore) StoreAgentDispatch(ctx context.Context, dispatch *livekit.AgentDispatch) error

func (*LocalStore) StoreAgentJob

func (s *LocalStore) StoreAgentJob(ctx context.Context, job *livekit.Job) error

func (*LocalStore) StoreParticipant

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

func (*LocalStore) StoreRoom

func (s *LocalStore) StoreRoom(_ context.Context, room *livekit.Room, internal *livekit.RoomInternal) error

func (*LocalStore) UnlockRoom

func (s *LocalStore) UnlockRoom(_ context.Context, _ livekit.RoomName, _ string) error

type ObjectStore

type ObjectStore interface {
	ServiceStore

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

	StoreRoom(ctx context.Context, room *livekit.Room, internal *livekit.RoomInternal) 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 RTCService

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

func NewRTCService

func NewRTCService(
	conf *config.Config,
	ra RoomAllocator,
	store ServiceStore,
	router routing.MessageRouter,
	currentNode routing.LocalNode,
	telemetry telemetry.TelemetryService,
) *RTCService

func (*RTCService) DrainConnections

func (s *RTCService) DrainConnections(interval time.Duration)

func (*RTCService) ParseClientInfo

func (s *RTCService) ParseClientInfo(r *http.Request) *livekit.ClientInfo

func (*RTCService) ServeHTTP

func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*RTCService) Validate

func (s *RTCService) Validate(w http.ResponseWriter, r *http.Request)

type RedisStore

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

func NewRedisStore

func NewRedisStore(rc redis.UniversalClient) *RedisStore

func (*RedisStore) CleanEndedEgress

func (s *RedisStore) CleanEndedEgress() error

func (*RedisStore) DeleteAgentDispatch

func (s *RedisStore) DeleteAgentDispatch(_ context.Context, dispatch *livekit.AgentDispatch) error

This will not delete the jobs created by the dispatch

func (*RedisStore) DeleteAgentJob

func (s *RedisStore) DeleteAgentJob(_ context.Context, job *livekit.Job) error

func (*RedisStore) DeleteIngress

func (s *RedisStore) DeleteIngress(_ context.Context, info *livekit.IngressInfo) error

func (*RedisStore) DeleteParticipant

func (s *RedisStore) DeleteParticipant(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) error

func (*RedisStore) DeleteRoom

func (s *RedisStore) DeleteRoom(ctx context.Context, roomName livekit.RoomName) error

func (*RedisStore) DeleteSIPDispatchRule

func (s *RedisStore) DeleteSIPDispatchRule(ctx context.Context, info *livekit.SIPDispatchRuleInfo) error

func (*RedisStore) DeleteSIPTrunk

func (s *RedisStore) DeleteSIPTrunk(ctx context.Context, id string) error

func (*RedisStore) ListAgentDispatches

func (s *RedisStore) ListAgentDispatches(_ context.Context, roomName livekit.RoomName) ([]*livekit.AgentDispatch, error)

func (*RedisStore) ListEgress

func (s *RedisStore) ListEgress(_ context.Context, roomName livekit.RoomName, active bool) ([]*livekit.EgressInfo, error)

func (*RedisStore) ListIngress

func (s *RedisStore) ListIngress(_ context.Context, roomName livekit.RoomName) ([]*livekit.IngressInfo, error)

func (*RedisStore) ListParticipants

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

func (*RedisStore) ListRooms

func (s *RedisStore) ListRooms(_ context.Context, roomNames []livekit.RoomName) ([]*livekit.Room, error)

func (*RedisStore) ListSIPDispatchRule

func (s *RedisStore) ListSIPDispatchRule(ctx context.Context) (infos []*livekit.SIPDispatchRuleInfo, err error)

func (*RedisStore) ListSIPInboundTrunk

func (s *RedisStore) ListSIPInboundTrunk(ctx context.Context) (infos []*livekit.SIPInboundTrunkInfo, err error)

func (*RedisStore) ListSIPOutboundTrunk

func (s *RedisStore) ListSIPOutboundTrunk(ctx context.Context) (infos []*livekit.SIPOutboundTrunkInfo, err error)

func (*RedisStore) ListSIPTrunk

func (s *RedisStore) ListSIPTrunk(ctx context.Context) ([]*livekit.SIPTrunkInfo, error)

func (*RedisStore) LoadEgress

func (s *RedisStore) LoadEgress(_ context.Context, egressID string) (*livekit.EgressInfo, error)

func (*RedisStore) LoadIngress

func (s *RedisStore) LoadIngress(_ context.Context, ingressId string) (*livekit.IngressInfo, error)

func (*RedisStore) LoadIngressFromStreamKey

func (s *RedisStore) LoadIngressFromStreamKey(_ context.Context, streamKey string) (*livekit.IngressInfo, error)

func (*RedisStore) LoadParticipant

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

func (*RedisStore) LoadRoom

func (s *RedisStore) LoadRoom(_ context.Context, roomName livekit.RoomName, includeInternal bool) (*livekit.Room, *livekit.RoomInternal, error)

func (*RedisStore) LoadSIPDispatchRule

func (s *RedisStore) LoadSIPDispatchRule(ctx context.Context, sipDispatchRuleId string) (*livekit.SIPDispatchRuleInfo, error)

func (*RedisStore) LoadSIPInboundTrunk

func (s *RedisStore) LoadSIPInboundTrunk(ctx context.Context, id string) (*livekit.SIPInboundTrunkInfo, error)

func (*RedisStore) LoadSIPOutboundTrunk

func (s *RedisStore) LoadSIPOutboundTrunk(ctx context.Context, id string) (*livekit.SIPOutboundTrunkInfo, error)

func (*RedisStore) LoadSIPTrunk

func (s *RedisStore) LoadSIPTrunk(ctx context.Context, id string) (*livekit.SIPTrunkInfo, error)

func (*RedisStore) LockRoom

func (s *RedisStore) LockRoom(_ context.Context, roomName livekit.RoomName, duration time.Duration) (string, error)

func (*RedisStore) Start

func (s *RedisStore) Start() error

func (*RedisStore) Stop

func (s *RedisStore) Stop()

func (*RedisStore) StoreAgentDispatch

func (s *RedisStore) StoreAgentDispatch(_ context.Context, dispatch *livekit.AgentDispatch) error

func (*RedisStore) StoreAgentJob

func (s *RedisStore) StoreAgentJob(_ context.Context, job *livekit.Job) error

func (*RedisStore) StoreEgress

func (s *RedisStore) StoreEgress(_ context.Context, info *livekit.EgressInfo) error

func (*RedisStore) StoreIngress

func (s *RedisStore) StoreIngress(ctx context.Context, info *livekit.IngressInfo) error

func (*RedisStore) StoreParticipant

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

func (*RedisStore) StoreRoom

func (s *RedisStore) StoreRoom(_ context.Context, room *livekit.Room, internal *livekit.RoomInternal) error

func (*RedisStore) StoreSIPDispatchRule

func (s *RedisStore) StoreSIPDispatchRule(ctx context.Context, info *livekit.SIPDispatchRuleInfo) error

func (*RedisStore) StoreSIPInboundTrunk

func (s *RedisStore) StoreSIPInboundTrunk(ctx context.Context, info *livekit.SIPInboundTrunkInfo) error

func (*RedisStore) StoreSIPOutboundTrunk

func (s *RedisStore) StoreSIPOutboundTrunk(ctx context.Context, info *livekit.SIPOutboundTrunkInfo) error

func (*RedisStore) StoreSIPTrunk

func (s *RedisStore) StoreSIPTrunk(ctx context.Context, info *livekit.SIPTrunkInfo) error

func (*RedisStore) UnlockRoom

func (s *RedisStore) UnlockRoom(_ context.Context, roomName livekit.RoomName, uid string) error

func (*RedisStore) UpdateEgress

func (s *RedisStore) UpdateEgress(_ context.Context, info *livekit.EgressInfo) error

func (*RedisStore) UpdateIngress

func (s *RedisStore) UpdateIngress(ctx context.Context, info *livekit.IngressInfo) error

func (*RedisStore) UpdateIngressState

func (s *RedisStore) UpdateIngressState(ctx context.Context, ingressId string, state *livekit.IngressState) error

type RoomAllocator

type RoomAllocator interface {
	CreateRoomEnabled() bool
	SelectRoomNode(ctx context.Context, roomName livekit.RoomName, nodeID livekit.NodeID) error
	CreateRoom(ctx context.Context, req *livekit.CreateRoomRequest, isExplicit bool) (*livekit.Room, *livekit.RoomInternal, bool, error)
	ValidateCreateRoom(ctx context.Context, roomName livekit.RoomName) error
}

func NewRoomAllocator

func NewRoomAllocator(conf *config.Config, router routing.Router, rs ObjectStore) (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

func NewLocalRoomManager(
	conf *config.Config,
	roomStore ObjectStore,
	currentNode routing.LocalNode,
	router routing.Router,
	roomAllocator RoomAllocator,
	telemetry telemetry.TelemetryService,
	clientConfManager clientconfiguration.ClientConfigurationManager,
	agentClient agent.Client,
	agentStore AgentStore,
	egressLauncher rtc.EgressLauncher,
	versionGenerator utils.TimedVersionGenerator,
	turnAuthHandler *TURNAuthHandler,
	bus psrpc.MessageBus,
	forwardStats *sfu.ForwardStats,
) (*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) CreateDispatch

func (r *RoomManager) CreateDispatch(ctx context.Context, req *livekit.AgentDispatch) (*livekit.AgentDispatch, error)

func (*RoomManager) CreateRoom

func (r *RoomManager) CreateRoom(ctx context.Context, req *livekit.CreateRoomRequest) (*livekit.Room, error)

func (*RoomManager) DeleteDispatch

func (*RoomManager) DeleteRoom

func (*RoomManager) GetRoom

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

func (*RoomManager) HasParticipants

func (r *RoomManager) HasParticipants() bool

func (*RoomManager) LockRoom

func (r *RoomManager) LockRoom(ctx context.Context, roomName livekit.RoomName, timeout time.Duration) (string, error)

func (*RoomManager) MutePublishedTrack

func (*RoomManager) PublicDeleteRoom

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

func (*RoomManager) RemoveParticipant

func (*RoomManager) SendData

func (*RoomManager) StartSession

func (r *RoomManager) StartSession(
	ctx context.Context,
	createRoom *livekit.CreateRoomRequest,
	pi routing.ParticipantInit,
	requestSource routing.MessageSource,
	responseSink routing.MessageSink,
) error

StartSession starts WebRTC session when a new participant is connected, takes place on RTC node

func (*RoomManager) Stop

func (r *RoomManager) Stop()

func (*RoomManager) UnlockRoom

func (r *RoomManager) UnlockRoom(ctx context.Context, roomName livekit.RoomName, token string) error

func (*RoomManager) UpdateParticipant

func (*RoomManager) UpdateRoomMetadata

func (r *RoomManager) UpdateRoomMetadata(ctx context.Context, req *livekit.UpdateRoomMetadataRequest) (*livekit.Room, error)

type RoomService

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

func NewRoomService

func NewRoomService(
	limitConf config.LimitConfig,
	apiConf config.APIConfig,
	router routing.MessageRouter,
	roomAllocator RoomAllocator,
	serviceStore ServiceStore,
	egressLauncher rtc.EgressLauncher,
	topicFormatter rpc.TopicFormatter,
	roomClient rpc.TypedRoomClient,
	participantClient rpc.TypedParticipantClient,
) (svc *RoomService, err error)

func (*RoomService) CreateRoom

func (s *RoomService) CreateRoom(ctx context.Context, req *livekit.CreateRoomRequest) (*livekit.Room, error)

func (*RoomService) DeleteRoom

func (*RoomService) GetParticipant

func (*RoomService) ListParticipants

func (*RoomService) ListRooms

func (*RoomService) MutePublishedTrack

func (*RoomService) RemoveParticipant

func (*RoomService) SendData

func (*RoomService) UpdateParticipant

func (*RoomService) UpdateRoomMetadata

func (s *RoomService) UpdateRoomMetadata(ctx context.Context, req *livekit.UpdateRoomMetadataRequest) (*livekit.Room, error)

type SIPService

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

func NewSIPService

func NewSIPService(
	conf *config.SIPConfig,
	nodeID livekit.NodeID,
	bus psrpc.MessageBus,
	psrpcClient rpc.SIPClient,
	store SIPStore,
	rs livekit.RoomService,
	ts telemetry.TelemetryService,
) *SIPService

func (*SIPService) CreateSIPDispatchRule

func (*SIPService) CreateSIPInboundTrunk

func (*SIPService) CreateSIPOutboundTrunk

func (*SIPService) CreateSIPParticipant

func (*SIPService) CreateSIPParticipantRequest

func (s *SIPService) CreateSIPParticipantRequest(ctx context.Context, req *livekit.CreateSIPParticipantRequest, projectID, host, wsUrl, token string) (*rpc.InternalCreateSIPParticipantRequest, error)

func (*SIPService) CreateSIPTrunk

func (*SIPService) DeleteSIPDispatchRule

func (*SIPService) DeleteSIPTrunk

func (*SIPService) ListSIPTrunk

deprecated: ListSIPTrunk will be removed in the future

func (*SIPService) TransferSIPParticipant

func (s *SIPService) TransferSIPParticipant(ctx context.Context, req *livekit.TransferSIPParticipantRequest) (*emptypb.Empty, error)

type SIPStore

type SIPStore interface {
	StoreSIPTrunk(ctx context.Context, info *livekit.SIPTrunkInfo) error
	StoreSIPInboundTrunk(ctx context.Context, info *livekit.SIPInboundTrunkInfo) error
	StoreSIPOutboundTrunk(ctx context.Context, info *livekit.SIPOutboundTrunkInfo) error
	LoadSIPTrunk(ctx context.Context, sipTrunkID string) (*livekit.SIPTrunkInfo, error)
	LoadSIPInboundTrunk(ctx context.Context, sipTrunkID string) (*livekit.SIPInboundTrunkInfo, error)
	LoadSIPOutboundTrunk(ctx context.Context, sipTrunkID string) (*livekit.SIPOutboundTrunkInfo, error)
	ListSIPTrunk(ctx context.Context) ([]*livekit.SIPTrunkInfo, error)
	ListSIPInboundTrunk(ctx context.Context) ([]*livekit.SIPInboundTrunkInfo, error)
	ListSIPOutboundTrunk(ctx context.Context) ([]*livekit.SIPOutboundTrunkInfo, error)
	DeleteSIPTrunk(ctx context.Context, sipTrunkID string) error

	StoreSIPDispatchRule(ctx context.Context, info *livekit.SIPDispatchRuleInfo) error
	LoadSIPDispatchRule(ctx context.Context, sipDispatchRuleID string) (*livekit.SIPDispatchRuleInfo, error)
	ListSIPDispatchRule(ctx context.Context) ([]*livekit.SIPDispatchRuleInfo, error)
	DeleteSIPDispatchRule(ctx context.Context, info *livekit.SIPDispatchRuleInfo) error
}

type ServiceStore

type ServiceStore interface {
	LoadRoom(ctx context.Context, roomName livekit.RoomName, includeInternal bool) (*livekit.Room, *livekit.RoomInternal, error)
	DeleteRoom(ctx context.Context, roomName livekit.RoomName) error

	// ListRooms returns currently active rooms. if names is not nil, it'll filter and return
	// only rooms that match
	ListRooms(ctx context.Context, roomNames []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 SessionHandler

type SessionHandler interface {
	Logger(ctx context.Context) logger.Logger

	HandleSession(
		ctx context.Context,
		createRoom *livekit.CreateRoomRequest,
		pi routing.ParticipantInit,
		connectionID livekit.ConnectionID,
		requestSource routing.MessageSource,
		responseSink routing.MessageSink,
	) error
}

type SignalServer

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

func NewDefaultSignalServer

func NewDefaultSignalServer(
	currentNode routing.LocalNode,
	bus psrpc.MessageBus,
	config config.SignalRelayConfig,
	router routing.Router,
	roomManager *RoomManager,
) (r *SignalServer, err error)

func NewSignalServer

func NewSignalServer(
	nodeID livekit.NodeID,
	region string,
	bus psrpc.MessageBus,
	config config.SignalRelayConfig,
	sessionHandler SessionHandler,
) (*SignalServer, error)

func (*SignalServer) Start

func (s *SignalServer) Start() error

func (*SignalServer) Stop

func (r *SignalServer) Stop()

type StandardRoomAllocator

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

func (*StandardRoomAllocator) CreateRoom

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

func (*StandardRoomAllocator) CreateRoomEnabled

func (r *StandardRoomAllocator) CreateRoomEnabled() bool

func (*StandardRoomAllocator) SelectRoomNode

func (r *StandardRoomAllocator) SelectRoomNode(ctx context.Context, roomName livekit.RoomName, nodeID livekit.NodeID) error

func (*StandardRoomAllocator) ValidateCreateRoom

func (r *StandardRoomAllocator) ValidateCreateRoom(ctx context.Context, roomName livekit.RoomName) error

type TURNAuthHandler

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

func NewTURNAuthHandler

func NewTURNAuthHandler(keyProvider auth.KeyProvider) *TURNAuthHandler

func (*TURNAuthHandler) CreatePassword

func (h *TURNAuthHandler) CreatePassword(apiKey string, pID livekit.ParticipantID) (string, error)

func (*TURNAuthHandler) CreateUsername

func (h *TURNAuthHandler) CreateUsername(apiKey string, pID livekit.ParticipantID) string

func (*TURNAuthHandler) HandleAuth

func (h *TURNAuthHandler) HandleAuth(username, realm string, srcAddr net.Addr) (key []byte, ok bool)

type WSSignalConnection

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

func NewWSSignalConnection

func NewWSSignalConnection(conn types.WebsocketClient) *WSSignalConnection

func (*WSSignalConnection) Close

func (c *WSSignalConnection) Close() error

func (*WSSignalConnection) ReadRequest

func (c *WSSignalConnection) ReadRequest() (*livekit.SignalRequest, int, error)

func (*WSSignalConnection) ReadWorkerMessage

func (c *WSSignalConnection) ReadWorkerMessage() (*livekit.WorkerMessage, int, error)

func (*WSSignalConnection) SetReadDeadline

func (c *WSSignalConnection) SetReadDeadline(deadline time.Time) error

func (*WSSignalConnection) WriteResponse

func (c *WSSignalConnection) WriteResponse(msg *livekit.SignalResponse) (int, error)

func (*WSSignalConnection) WriteServerMessage

func (c *WSSignalConnection) WriteServerMessage(msg *livekit.ServerMessage) (int, 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