Documentation
¶
Index ¶
- Constants
- type AddSubscriberParams
- type AddTrackParams
- type ICEConnectionType
- type IceConfig
- type LocalMediaTrack
- type LocalParticipant
- type MediaTrack
- type MigrateState
- type OperationMonitor
- type OperationMonitorData
- type OperationMonitorEvent
- type Participant
- type ParticipantCloseReason
- type PreferCandidateType
- type ProtocolVersion
- func (v ProtocolVersion) HandlesDataPackets() bool
- func (v ProtocolVersion) SubscriberAsPrimary() bool
- func (v ProtocolVersion) SupportFastStart() bool
- func (v ProtocolVersion) SupportsConnectionQuality() bool
- func (v ProtocolVersion) SupportsICELite() bool
- func (v ProtocolVersion) SupportsPackedStreamId() bool
- func (v ProtocolVersion) SupportsProtobuf() bool
- func (v ProtocolVersion) SupportsSessionMigrate() bool
- func (v ProtocolVersion) SupportsSpeakerChanged() bool
- func (v ProtocolVersion) SupportsTransceiverReuse() bool
- func (v ProtocolVersion) SupportsUnpublish() bool
- type Room
- type SubscribedCodecQuality
- type SubscribedTrack
- type WebsocketClient
Constants ¶
const CurrentProtocol = 8
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddSubscriberParams ¶ added in v0.15.2
type AddTrackParams ¶ added in v1.2.5
type AddTrackParams struct {
Stereo bool
}
type ICEConnectionType ¶ added in v1.2.1
type ICEConnectionType string
const ( ICEConnectionTypeUDP ICEConnectionType = "udp" ICEConnectionTypeTCP ICEConnectionType = "tcp" ICEConnectionTypeTURN ICEConnectionType = "turn" ICEConnectionTypeUnknown ICEConnectionType = "unknown" )
type IceConfig ¶ added in v1.1.0
type IceConfig struct {
PreferSub PreferCandidateType
PreferPub PreferCandidateType
}
type LocalMediaTrack ¶ added in v0.15.3
type LocalMediaTrack interface {
MediaTrack
Restart()
SignalCid() string
HasSdpCid(cid string) bool
GetAudioLevel() (level float64, active bool)
GetConnectionScore() float32
SetRTT(rtt uint32)
NotifySubscriberNodeMaxQuality(nodeID livekit.NodeID, qualities []SubscribedCodecQuality)
NotifySubscriberNodeMediaLoss(nodeID livekit.NodeID, fractionalLoss uint8)
}
type LocalParticipant ¶ added in v0.15.3
type LocalParticipant interface {
Participant
// getters
GetLogger() logger.Logger
GetAdaptiveStream() bool
ProtocolVersion() ProtocolVersion
ConnectedAt() time.Time
State() livekit.ParticipantInfo_State
IsReady() bool
SubscriberAsPrimary() bool
GetClientConfiguration() *livekit.ClientConfiguration
GetICEConnectionType() ICEConnectionType
SetResponseSink(sink routing.MessageSink)
CloseSignalConnection()
// permissions
ClaimGrants() *auth.ClaimGrants
SetPermission(permission *livekit.ParticipantPermission) bool
CanPublish() bool
CanSubscribe() bool
CanPublishData() bool
// PeerConnection
AddICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget)
HandleOffer(sdp webrtc.SessionDescription)
AddTrack(req *livekit.AddTrackRequest)
SetTrackMuted(trackID livekit.TrackID, muted bool, fromAdmin bool)
HandleAnswer(sdp webrtc.SessionDescription)
Negotiate(force bool)
ICERestart(iceConfig *IceConfig)
AddTrackToSubscriber(trackLocal webrtc.TrackLocal, params AddTrackParams) (*webrtc.RTPSender, *webrtc.RTPTransceiver, error)
AddTransceiverFromTrackToSubscriber(trackLocal webrtc.TrackLocal, params AddTrackParams) (*webrtc.RTPSender, *webrtc.RTPTransceiver, error)
RemoveTrackFromSubscriber(sender *webrtc.RTPSender) error
// subscriptions
AddSubscribedTrack(st SubscribedTrack)
RemoveSubscribedTrack(st SubscribedTrack)
UpdateSubscribedTrackSettings(trackID livekit.TrackID, settings *livekit.UpdateTrackSettings) error
GetSubscribedTracks() []SubscribedTrack
// returns list of participant identities that the current participant is subscribed to
GetSubscribedParticipants() []livekit.ParticipantID
IsSubscribedTo(sid livekit.ParticipantID) bool
IsPublisher() bool
GetAudioLevel() (smoothedLevel float64, active bool)
GetConnectionQuality() *livekit.ConnectionQualityInfo
// server sent messages
SendJoinResponse(joinResponse *livekit.JoinResponse) error
SendParticipantUpdate(participants []*livekit.ParticipantInfo) error
SendSpeakerUpdate(speakers []*livekit.SpeakerInfo) error
SendDataPacket(packet *livekit.DataPacket) error
SendRoomUpdate(room *livekit.Room) error
SendConnectionQualityUpdate(update *livekit.ConnectionQualityUpdate) error
SubscriptionPermissionUpdate(publisherID livekit.ParticipantID, trackID livekit.TrackID, allowed bool)
SendRefreshToken(token string) error
// callbacks
OnStateChange(func(p LocalParticipant, oldState livekit.ParticipantInfo_State))
// OnTrackPublished - remote added a track
OnTrackPublished(func(LocalParticipant, MediaTrack))
// OnTrackUpdated - one of its publishedTracks changed in status
OnTrackUpdated(callback func(LocalParticipant, MediaTrack))
// OnParticipantUpdate - metadata or permission is updated
OnParticipantUpdate(callback func(LocalParticipant))
OnDataPacket(callback func(LocalParticipant, *livekit.DataPacket))
OnSubscribedTo(callback func(LocalParticipant, livekit.ParticipantID))
OnClose(callback func(LocalParticipant, map[livekit.TrackID]livekit.ParticipantID))
OnClaimsChanged(callback func(LocalParticipant))
// session migration
MaybeStartMigration(force bool, onStart func()) bool
SetMigrateState(s MigrateState)
MigrateState() MigrateState
SetMigrateInfo(previousOffer, previousAnswer *webrtc.SessionDescription, mediaTracks []*livekit.TrackPublishedResponse, dataChannels []*livekit.DataChannelInfo)
UpdateRTT(rtt uint32)
CacheDownTrack(trackID livekit.TrackID, rtpTransceiver *webrtc.RTPTransceiver, downTrackState sfu.DownTrackState)
UncacheDownTrack(rtpTransceiver *webrtc.RTPTransceiver)
GetCachedDownTrack(trackID livekit.TrackID) (*webrtc.RTPTransceiver, sfu.DownTrackState)
EnqueueSubscribeTrack(trackID livekit.TrackID, isRelayed bool, f func(sub LocalParticipant) error)
EnqueueUnsubscribeTrack(trackID livekit.TrackID, isRelayed bool, willBeResumed bool, f func(subscriberID livekit.ParticipantID, willBeResumed bool) error)
ProcessSubscriptionRequestsQueue(trackID livekit.TrackID)
ClearInProgressAndProcessSubscriptionRequestsQueue(trackID livekit.TrackID)
SetICEConfig(iceConfig IceConfig)
OnICEConfigChanged(callback func(participant LocalParticipant, iceConfig IceConfig))
UpdateSubscribedQuality(nodeID livekit.NodeID, trackID livekit.TrackID, maxQualities []SubscribedCodecQuality) error
UpdateMediaLoss(nodeID livekit.NodeID, trackID livekit.TrackID, fractionalLoss uint32) error
}
type MediaTrack ¶ added in v0.15.0
type MediaTrack interface {
ID() livekit.TrackID
Kind() livekit.TrackType
Name() string
Source() livekit.TrackSource
ToProto() *livekit.TrackInfo
PublisherID() livekit.ParticipantID
PublisherIdentity() livekit.ParticipantIdentity
PublisherVersion() uint32
IsMuted() bool
SetMuted(muted bool)
UpdateVideoLayers(layers []*livekit.VideoLayer)
IsSimulcast() bool
Close(willBeResumed bool)
// callbacks
AddOnClose(func())
// subscribers
AddSubscriber(participant LocalParticipant) error
RemoveSubscriber(participantID livekit.ParticipantID, willBeResumed bool)
IsSubscriber(subID livekit.ParticipantID) bool
RevokeDisallowedSubscribers(allowedSubscriberIdentities []livekit.ParticipantIdentity) []livekit.ParticipantIdentity
GetAllSubscribers() []livekit.ParticipantID
GetNumSubscribers() int
// returns quality information that's appropriate for width & height
GetQualityForDimension(width, height uint32) livekit.VideoQuality
Receivers() []sfu.TrackReceiver
ClearAllReceivers(willBeResumed bool)
}
MediaTrack represents a media track
type MigrateState ¶ added in v0.15.3
type MigrateState int32
const ( MigrateStateInit MigrateState = iota MigrateStateSync MigrateStateComplete )
func (MigrateState) String ¶ added in v0.15.3
func (m MigrateState) String() string
type OperationMonitor ¶ added in v1.2.2
type OperationMonitor interface {
PostEvent(ome OperationMonitorEvent, omd OperationMonitorData)
Check() error
IsIdle() bool
}
type OperationMonitorData ¶ added in v1.2.2
type OperationMonitorData interface{}
type OperationMonitorEvent ¶ added in v1.2.2
type OperationMonitorEvent int
Supervisor/operation monitor related definitions
const ( OperationMonitorEventUpdateSubscription OperationMonitorEvent = iota OperationMonitorEventSetSubscribedTrack OperationMonitorEventClearSubscribedTrack OperationMonitorEventPublisherPeerConnectionConnected OperationMonitorEventAddPendingPublication OperationMonitorEventSetPublicationMute OperationMonitorEventSetPublishedTrack OperationMonitorEventClearPublishedTrack )
func (OperationMonitorEvent) String ¶ added in v1.2.2
func (o OperationMonitorEvent) String() string
type Participant ¶
type Participant interface {
ID() livekit.ParticipantID
Identity() livekit.ParticipantIdentity
ToProto() *livekit.ParticipantInfo
SetMetadata(metadata string)
GetPublishedTrack(sid livekit.TrackID) MediaTrack
GetPublishedTracks() []MediaTrack
RemovePublishedTrack(track MediaTrack, willBeResumed bool, shouldClose bool)
AddSubscriber(op LocalParticipant, params AddSubscriberParams) (int, error)
RemoveSubscriber(op LocalParticipant, trackID livekit.TrackID, resume bool)
// permissions
Hidden() bool
IsRecorder() bool
Start()
Close(sendLeave bool, reason ParticipantCloseReason) error
SubscriptionPermission() (*livekit.SubscriptionPermission, *livekit.TimedVersion)
// updates from remotes
UpdateSubscriptionPermission(
subscriptionPermission *livekit.SubscriptionPermission,
timedVersion *livekit.TimedVersion,
resolverByIdentity func(participantIdentity livekit.ParticipantIdentity) LocalParticipant,
resolverBySid func(participantID livekit.ParticipantID) LocalParticipant,
) error
UpdateVideoLayers(updateVideoLayers *livekit.UpdateVideoLayers) error
DebugInfo() map[string]interface{}
}
type ParticipantCloseReason ¶ added in v1.1.0
type ParticipantCloseReason int
const ( ParticipantCloseReasonClientRequestLeave ParticipantCloseReason = iota ParticipantCloseReasonRoomManagerStop ParticipantCloseReasonRoomClose ParticipantCloseReasonVerifyFailed ParticipantCloseReasonJoinFailed ParticipantCloseReasonJoinTimeout ParticipantCloseReasonStateDisconnected ParticipantCloseReasonPeerConnectionDisconnected ParticipantCloseReasonDuplicateIdentity ParticipantCloseReasonMigrationComplete ParticipantCloseReasonStale ParticipantCloseReasonServiceRequestRemoveParticipant ParticipantCloseReasonServiceRequestDeleteRoom ParticipantCloseReasonSimulateMigration ParticipantCloseReasonSimulateNodeFailure ParticipantCloseReasonSimulateServerLeave ParticipantCloseReasonNegotiateFailed ParticipantCloseReasonMigrationRequested ParticipantCloseReasonOvercommitted )
func (ParticipantCloseReason) String ¶ added in v1.1.0
func (p ParticipantCloseReason) String() string
func (ParticipantCloseReason) ToDisconnectReason ¶ added in v1.1.1
func (p ParticipantCloseReason) ToDisconnectReason() livekit.DisconnectReason
type PreferCandidateType ¶ added in v1.2.0
type PreferCandidateType int
const ( PreferNone PreferCandidateType = iota PreferTcp PreferTls )
type ProtocolVersion ¶
type ProtocolVersion int
func (ProtocolVersion) HandlesDataPackets ¶
func (v ProtocolVersion) HandlesDataPackets() bool
func (ProtocolVersion) SubscriberAsPrimary ¶ added in v0.13.0
func (v ProtocolVersion) SubscriberAsPrimary() bool
SubscriberAsPrimary indicates clients initiate subscriber connection as primary
func (ProtocolVersion) SupportFastStart ¶ added in v1.1.0
func (v ProtocolVersion) SupportFastStart() bool
SupportFastStart - if client supports fast start, server side will send media streams in the first offer
func (ProtocolVersion) SupportsConnectionQuality ¶ added in v0.14.0
func (v ProtocolVersion) SupportsConnectionQuality() bool
SupportsConnectionQuality - avoid sending frequent ConnectionQuality updates for lower protocol versions
func (ProtocolVersion) SupportsICELite ¶ added in v0.15.4
func (v ProtocolVersion) SupportsICELite() bool
func (ProtocolVersion) SupportsPackedStreamId ¶
func (v ProtocolVersion) SupportsPackedStreamId() bool
func (ProtocolVersion) SupportsProtobuf ¶ added in v0.11.0
func (v ProtocolVersion) SupportsProtobuf() bool
func (ProtocolVersion) SupportsSessionMigrate ¶ added in v0.15.3
func (v ProtocolVersion) SupportsSessionMigrate() bool
func (ProtocolVersion) SupportsSpeakerChanged ¶ added in v0.13.0
func (v ProtocolVersion) SupportsSpeakerChanged() bool
SupportsSpeakerChanged - if client handles speaker info deltas, instead of a comprehensive list
func (ProtocolVersion) SupportsTransceiverReuse ¶ added in v0.13.3
func (v ProtocolVersion) SupportsTransceiverReuse() bool
SupportsTransceiverReuse - if transceiver reuse is supported, optimizes SDP size
func (ProtocolVersion) SupportsUnpublish ¶ added in v0.15.6
func (v ProtocolVersion) SupportsUnpublish() bool
type Room ¶ added in v0.15.0
type Room interface {
Name() livekit.RoomName
ID() livekit.RoomID
RemoveParticipant(identity livekit.ParticipantIdentity, reason ParticipantCloseReason)
UpdateSubscriptions(participant LocalParticipant, trackIDs []livekit.TrackID, participantTracks []*livekit.ParticipantTracks, subscribe bool) error
UpdateSubscriptionPermission(participant LocalParticipant, permissions *livekit.SubscriptionPermission) error
SyncState(participant LocalParticipant, state *livekit.SyncState) error
SimulateScenario(participant LocalParticipant, scenario *livekit.SimulateScenario) error
SetParticipantPermission(participant LocalParticipant, permission *livekit.ParticipantPermission) error
UpdateVideoLayers(participant Participant, updateVideoLayers *livekit.UpdateVideoLayers) error
}
Room is a container of participants, and can provide room-level actions
type SubscribedCodecQuality ¶ added in v1.1.0
type SubscribedCodecQuality struct {
CodecMime string
Quality livekit.VideoQuality
}
type SubscribedTrack ¶
type SubscribedTrack interface {
OnBind(f func())
ID() livekit.TrackID
PublisherID() livekit.ParticipantID
PublisherIdentity() livekit.ParticipantIdentity
PublisherVersion() uint32
SubscriberID() livekit.ParticipantID
SubscriberIdentity() livekit.ParticipantIdentity
Subscriber() LocalParticipant
DownTrack() *sfu.DownTrack
MediaTrack() MediaTrack
IsMuted() bool
SetPublisherMuted(muted bool)
UpdateSubscriberSettings(settings *livekit.UpdateTrackSettings)
// selects appropriate video layer according to subscriber preferences
UpdateVideoLayer()
}
MediaTrack is the main interface representing a track published to the room