Key telemetry stats worker using combination of roomID, participantID (#4323)

* Key telemetry stats work using combination of roomID, participantID

With forwarded participant, the same participantID can existing in two
rooms.

NOTE: This does not yet allow a participant session to report its
events/track stats into multiple rooms. That would require regitering
multiple listeners (from rooms a participant is forwarded to).

* missed file

* data channel stats

* PR comments + pass in room name so that telemetry events have proper room name also
This commit is contained in:
Raja Subramanian
2026-02-16 13:56:13 +05:30
committed by GitHub
parent 2d40449faf
commit b81bac0ec3
21 changed files with 1256 additions and 414 deletions
+4 -6
View File
@@ -15,7 +15,6 @@
package rtc package rtc
import ( import (
"context"
"math" "math"
"sync" "sync"
"time" "time"
@@ -86,7 +85,7 @@ type MediaTrackParams struct {
PLIThrottleConfig sfu.PLIThrottleConfig PLIThrottleConfig sfu.PLIThrottleConfig
AudioConfig sfu.AudioConfig AudioConfig sfu.AudioConfig
VideoConfig config.VideoConfig VideoConfig config.VideoConfig
Telemetry telemetry.TelemetryService TelemetryListener types.ParticipantTelemetryListener
Logger logger.Logger Logger logger.Logger
Reporter roomobs.TrackReporter Reporter roomobs.TrackReporter
SimTracks map[uint32]interceptor.SimulcastTrackInfo SimTracks map[uint32]interceptor.SimulcastTrackInfo
@@ -124,7 +123,7 @@ func NewMediaTrack(params MediaTrackParams, ti *livekit.TrackInfo) *MediaTrack {
ReceiverConfig: params.ReceiverConfig, ReceiverConfig: params.ReceiverConfig,
SubscriberConfig: params.SubscriberConfig, SubscriberConfig: params.SubscriberConfig,
AudioConfig: params.AudioConfig, AudioConfig: params.AudioConfig,
Telemetry: params.Telemetry, TelemetryListener: params.TelemetryListener,
Logger: params.Logger, Logger: params.Logger,
RegressionTargetCodec: t.regressionTargetCodec, RegressionTargetCodec: t.regressionTargetCodec,
PreferVideoSizeFromMedia: params.PreferVideoSizeFromMedia, PreferVideoSizeFromMedia: params.PreferVideoSizeFromMedia,
@@ -445,7 +444,7 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track sfu.TrackRe
regressionTargetCodecReceived := t.regressionTargetCodecReceived regressionTargetCodecReceived := t.regressionTargetCodecReceived
t.lock.RUnlock() t.lock.RUnlock()
if priority == 0 || regressionTargetCodecReceived { if priority == 0 || regressionTargetCodecReceived {
t.params.Telemetry.TrackStats(statsKey, stat) t.params.TelemetryListener.OnTrackStats(statsKey, stat)
if cs, ok := telemetry.CondenseStat(stat); ok { if cs, ok := telemetry.CondenseStat(stat); ok {
t.params.Reporter.Tx(func(tx roomobs.TrackTx) { t.params.Reporter.Tx(func(tx roomobs.TrackTx) {
@@ -587,8 +586,7 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track sfu.TrackRe
}) })
buff.OnFinalRtpStats(func(stats *livekit.RTPStats) { buff.OnFinalRtpStats(func(stats *livekit.RTPStats) {
t.params.Telemetry.TrackPublishRTPStats( t.params.TelemetryListener.OnTrackPublishRTPStats(
context.Background(),
t.params.ParticipantID(), t.params.ParticipantID(),
t.ID(), t.ID(),
mimeType, mimeType,
+11 -13
View File
@@ -15,7 +15,6 @@
package rtc package rtc
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"slices" "slices"
@@ -37,7 +36,6 @@ import (
"github.com/livekit/livekit-server/pkg/sfu" "github.com/livekit/livekit-server/pkg/sfu"
"github.com/livekit/livekit-server/pkg/sfu/buffer" "github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/livekit-server/pkg/sfu/rtpstats" "github.com/livekit/livekit-server/pkg/sfu/rtpstats"
"github.com/livekit/livekit-server/pkg/telemetry"
sutils "github.com/livekit/livekit-server/pkg/utils" sutils "github.com/livekit/livekit-server/pkg/utils"
) )
@@ -127,7 +125,7 @@ type MediaTrackReceiverParams struct {
ReceiverConfig ReceiverConfig ReceiverConfig ReceiverConfig
SubscriberConfig DirectionConfig SubscriberConfig DirectionConfig
AudioConfig sfu.AudioConfig AudioConfig sfu.AudioConfig
Telemetry telemetry.TelemetryService TelemetryListener types.ParticipantTelemetryListener
Logger logger.Logger Logger logger.Logger
RegressionTargetCodec mime.MimeType RegressionTargetCodec mime.MimeType
PreferVideoSizeFromMedia bool PreferVideoSizeFromMedia bool
@@ -159,12 +157,12 @@ func NewMediaTrackReceiver(params MediaTrackReceiverParams, ti *livekit.TrackInf
t.trackInfo.Store(utils.CloneProto(ti)) t.trackInfo.Store(utils.CloneProto(ti))
t.MediaTrackSubscriptions = NewMediaTrackSubscriptions(MediaTrackSubscriptionsParams{ t.MediaTrackSubscriptions = NewMediaTrackSubscriptions(MediaTrackSubscriptionsParams{
MediaTrack: params.MediaTrack, MediaTrack: params.MediaTrack,
IsRelayed: params.IsRelayed, IsRelayed: params.IsRelayed,
ReceiverConfig: params.ReceiverConfig, ReceiverConfig: params.ReceiverConfig,
SubscriberConfig: params.SubscriberConfig, SubscriberConfig: params.SubscriberConfig,
Telemetry: params.Telemetry, TelemetryListener: params.TelemetryListener,
Logger: params.Logger, Logger: params.Logger,
}) })
t.MediaTrackSubscriptions.OnDownTrackCreated(t.onDownTrackCreated) t.MediaTrackSubscriptions.OnDownTrackCreated(t.onDownTrackCreated)
return t return t
@@ -937,7 +935,7 @@ func (t *MediaTrackReceiver) UpdateAudioTrack(update *livekit.UpdateLocalAudioTr
t.updateTrackInfoOfReceivers() t.updateTrackInfoOfReceivers()
t.params.Telemetry.TrackPublishedUpdate(context.Background(), t.PublisherID(), clonedInfo) t.params.TelemetryListener.OnTrackPublishedUpdate(t.PublisherID(), clonedInfo)
t.params.Logger.Debugw("updated audio track", "before", logger.Proto(trackInfo), "after", logger.Proto(clonedInfo)) t.params.Logger.Debugw("updated audio track", "before", logger.Proto(trackInfo), "after", logger.Proto(clonedInfo))
} }
@@ -961,7 +959,7 @@ func (t *MediaTrackReceiver) UpdateVideoTrack(update *livekit.UpdateLocalVideoTr
t.updateTrackInfoOfReceivers() t.updateTrackInfoOfReceivers()
t.params.Telemetry.TrackPublishedUpdate(context.Background(), t.PublisherID(), clonedInfo) t.params.TelemetryListener.OnTrackPublishedUpdate(t.PublisherID(), clonedInfo)
t.params.Logger.Debugw("updated video track", "before", logger.Proto(trackInfo), "after", logger.Proto(clonedInfo)) t.params.Logger.Debugw("updated video track", "before", logger.Proto(trackInfo), "after", logger.Proto(clonedInfo))
} }
@@ -1007,7 +1005,7 @@ func (t *MediaTrackReceiver) UpdateVideoSize(mimeType mime.MimeType, sizes []buf
t.updateTrackInfoOfReceivers() t.updateTrackInfoOfReceivers()
t.params.Telemetry.TrackPublishedUpdate(context.Background(), t.PublisherID(), clonedInfo) t.params.TelemetryListener.OnTrackPublishedUpdate(t.PublisherID(), clonedInfo)
t.params.Logger.Debugw("updated video sizes", "before", logger.Proto(trackInfo), "after", logger.Proto(clonedInfo)) t.params.Logger.Debugw("updated video sizes", "before", logger.Proto(trackInfo), "after", logger.Proto(clonedInfo))
} }
@@ -1038,7 +1036,7 @@ func (t *MediaTrackReceiver) NotifyMaxLayerChange(mimeType mime.MimeType, maxLay
} }
} }
t.params.Telemetry.TrackPublishedUpdate(context.Background(), t.PublisherID(), ti) t.params.TelemetryListener.OnTrackPublishedUpdate(t.PublisherID(), ti)
} }
// GetQualityForDimension finds the closest quality to use for desired dimensions // GetQualityForDimension finds the closest quality to use for desired dimensions
+2 -3
View File
@@ -27,7 +27,6 @@ import (
"github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/sfu" "github.com/livekit/livekit-server/pkg/sfu"
"github.com/livekit/livekit-server/pkg/telemetry"
) )
var ( var (
@@ -54,7 +53,7 @@ type MediaTrackSubscriptionsParams struct {
ReceiverConfig ReceiverConfig ReceiverConfig ReceiverConfig
SubscriberConfig DirectionConfig SubscriberConfig DirectionConfig
Telemetry telemetry.TelemetryService TelemetryListener types.ParticipantTelemetryListener
Logger logger.Logger Logger logger.Logger
} }
@@ -112,7 +111,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr *
Subscriber: sub, Subscriber: sub,
MediaTrack: t.params.MediaTrack, MediaTrack: t.params.MediaTrack,
AdaptiveStream: sub.GetAdaptiveStream(), AdaptiveStream: sub.GetAdaptiveStream(),
Telemetry: t.params.Telemetry, TelemetryListener: t.params.TelemetryListener,
WrappedReceiver: wr, WrappedReceiver: wr,
IsRelayed: t.params.IsRelayed, IsRelayed: t.params.IsRelayed,
OnDownTrackCreated: t.onDownTrackCreated, OnDownTrackCreated: t.onDownTrackCreated,
+14 -19
View File
@@ -15,7 +15,6 @@
package rtc package rtc
import ( import (
"context"
"fmt" "fmt"
"io" "io"
"math/rand" "math/rand"
@@ -169,7 +168,7 @@ type ParticipantParams struct {
LimitConfig config.LimitConfig LimitConfig config.LimitConfig
ProtocolVersion types.ProtocolVersion ProtocolVersion types.ProtocolVersion
SessionStartTime time.Time SessionStartTime time.Time
Telemetry telemetry.TelemetryService TelemetryListener types.ParticipantTelemetryListener
Trailer []byte Trailer []byte
PLIThrottleConfig sfu.PLIThrottleConfig PLIThrottleConfig sfu.PLIThrottleConfig
CongestionControlConfig config.CongestionControlConfig CongestionControlConfig config.CongestionControlConfig
@@ -287,7 +286,7 @@ type ParticipantImpl struct {
updateCache *lru.Cache[livekit.ParticipantID, participantUpdateInfo] updateCache *lru.Cache[livekit.ParticipantID, participantUpdateInfo]
updateLock utils.Mutex updateLock utils.Mutex
dataChannelStats *telemetry.BytesTrackStats dataChannelStats *BytesTrackStats
reliableDataInfo reliableDataInfo reliableDataInfo reliableDataInfo
@@ -373,11 +372,11 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
p.setupSignalling() p.setupSignalling()
p.id.Store(params.SID) p.id.Store(params.SID)
p.dataChannelStats = telemetry.NewBytesTrackStats( p.dataChannelStats = NewBytesTrackStats(
p.params.Country, p.params.Country,
telemetry.BytesTrackIDForParticipantID(telemetry.BytesTrackTypeData, p.ID()), BytesTrackIDForParticipantID(BytesTrackTypeData, p.ID()),
p.ID(), p.ID(),
params.Telemetry, params.TelemetryListener,
params.Reporter, params.Reporter,
) )
p.reliableDataInfo.lastPubReliableSeq.Store(params.LastPubReliableSeq) p.reliableDataInfo.lastPubReliableSeq.Store(params.LastPubReliableSeq)
@@ -2038,7 +2037,7 @@ func (p *ParticipantImpl) setupSubscriptionManager() {
DataTrackResolver: func(lp types.LocalParticipant, ti livekit.TrackID) types.DataResolverResult { DataTrackResolver: func(lp types.LocalParticipant, ti livekit.TrackID) types.DataResolverResult {
return p.helper().ResolveDataTrack(lp, ti) return p.helper().ResolveDataTrack(lp, ti)
}, },
Telemetry: p.params.Telemetry, TelemetryListener: p.params.TelemetryListener,
OnTrackSubscribed: p.onTrackSubscribed, OnTrackSubscribed: p.onTrackSubscribed,
OnTrackUnsubscribed: p.onTrackUnsubscribed, OnTrackUnsubscribed: p.onTrackUnsubscribed,
OnSubscriptionError: p.onSubscriptionError, OnSubscriptionError: p.onSubscriptionError,
@@ -2721,8 +2720,7 @@ func (p *ParticipantImpl) onSubscribedMaxQualityChange(
break break
} }
} }
p.params.Telemetry.TrackMaxSubscribedVideoQuality( p.params.TelemetryListener.OnTrackMaxSubscribedVideoQuality(
context.Background(),
p.ID(), p.ID(),
ti, ti,
maxSubscribedQuality.CodecMime, maxSubscribedQuality.CodecMime,
@@ -2961,7 +2959,7 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
} }
} }
p.params.Telemetry.TrackPublishRequested(context.Background(), p.ID(), p.Identity(), utils.CloneProto(ti)) p.params.TelemetryListener.OnTrackPublishRequested(p.ID(), p.Identity(), utils.CloneProto(ti))
if p.supervisor != nil { if p.supervisor != nil {
p.supervisor.AddPublication(livekit.TrackID(ti.Sid)) p.supervisor.AddPublication(livekit.TrackID(ti.Sid))
@@ -3072,9 +3070,9 @@ func (p *ParticipantImpl) setTrackMuted(mute *livekit.MuteTrackRequest, fromAdmi
if trackInfo != nil && changed { if trackInfo != nil && changed {
if mute.Muted { if mute.Muted {
p.params.Telemetry.TrackMuted(context.Background(), p.ID(), trackInfo) p.params.TelemetryListener.OnTrackMuted(p.ID(), trackInfo)
} else { } else {
p.params.Telemetry.TrackUnmuted(context.Background(), p.ID(), trackInfo) p.params.TelemetryListener.OnTrackUnmuted(p.ID(), trackInfo)
} }
} }
@@ -3291,7 +3289,7 @@ func (p *ParticipantImpl) addMediaTrack(signalCid string, ti *livekit.TrackInfo)
ReceiverConfig: p.params.Config.Receiver, ReceiverConfig: p.params.Config.Receiver,
AudioConfig: p.params.AudioConfig, AudioConfig: p.params.AudioConfig,
VideoConfig: p.params.VideoConfig, VideoConfig: p.params.VideoConfig,
Telemetry: p.params.Telemetry, TelemetryListener: p.params.TelemetryListener,
Logger: LoggerWithTrack(p.pubLogger, livekit.TrackID(ti.Sid), false), Logger: LoggerWithTrack(p.pubLogger, livekit.TrackID(ti.Sid), false),
Reporter: p.params.Reporter.WithTrack(ti.Sid), Reporter: p.params.Reporter.WithTrack(ti.Sid),
SubscriberConfig: p.params.Config.Subscriber, SubscriberConfig: p.params.Config.Subscriber,
@@ -3343,8 +3341,7 @@ func (p *ParticipantImpl) addMediaTrack(signalCid string, ti *livekit.TrackInfo)
p.supervisor.ClearPublishedTrack(trackID, mt) p.supervisor.ClearPublishedTrack(trackID, mt)
} }
p.params.Telemetry.TrackUnpublished( p.params.TelemetryListener.OnTrackUnpublished(
context.Background(),
p.ID(), p.ID(),
p.Identity(), p.Identity(),
mt.ToProto(), mt.ToProto(),
@@ -3378,8 +3375,7 @@ func (p *ParticipantImpl) handleTrackPublished(track types.MediaTrack, isMigrate
// send webhook after callbacks are complete, persistence and state handling happens // send webhook after callbacks are complete, persistence and state handling happens
// in `onTrackPublished` cb // in `onTrackPublished` cb
p.params.Telemetry.TrackPublished( p.params.TelemetryListener.OnTrackPublished(
context.Background(),
p.ID(), p.ID(),
p.Identity(), p.Identity(),
track.ToProto(), track.ToProto(),
@@ -4012,8 +4008,7 @@ func (p *ParticipantImpl) MoveToRoom(params types.MoveToRoomParams) {
track.(types.LocalMediaTrack).ClearSubscriberNodes() track.(types.LocalMediaTrack).ClearSubscriberNodes()
trackInfo := track.ToProto() trackInfo := track.ToProto()
p.params.Telemetry.TrackUnpublished( p.params.TelemetryListener.OnTrackUnpublished(
context.Background(),
p.ID(), p.ID(),
p.Identity(), p.Identity(),
trackInfo, trackInfo,
+1 -2
View File
@@ -26,7 +26,6 @@ import (
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/livekit/livekit-server/pkg/sfu/buffer" "github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/livekit-server/pkg/telemetry/telemetryfakes"
"github.com/livekit/protocol/auth" "github.com/livekit/protocol/auth"
protoCodecs "github.com/livekit/protocol/codecs" protoCodecs "github.com/livekit/protocol/codecs"
"github.com/livekit/protocol/codecs/mime" "github.com/livekit/protocol/codecs/mime"
@@ -813,7 +812,7 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p
ClientInfo: ClientInfo{ClientInfo: opts.clientInfo}, ClientInfo: ClientInfo{ClientInfo: opts.clientInfo},
Logger: LoggerWithParticipant(logger.GetLogger(), identity, sid, false), Logger: LoggerWithParticipant(logger.GetLogger(), identity, sid, false),
Reporter: roomobs.NewNoopParticipantSessionReporter(), Reporter: roomobs.NewNoopParticipantSessionReporter(),
Telemetry: &telemetryfakes.FakeTelemetryService{}, TelemetryListener: &typesfakes.FakeParticipantTelemetryListener{},
VersionGenerator: utils.NewDefaultTimedVersionGenerator(), VersionGenerator: utils.NewDefaultTimedVersionGenerator(),
ParticipantListener: &typesfakes.FakeLocalParticipantListener{}, ParticipantListener: &typesfakes.FakeLocalParticipantListener{},
ParticipantHelper: &typesfakes.FakeLocalParticipantHelper{}, ParticipantHelper: &typesfakes.FakeLocalParticipantHelper{},
+75 -2
View File
@@ -28,6 +28,7 @@ import (
"golang.org/x/exp/maps" "golang.org/x/exp/maps"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"github.com/livekit/protocol/codecs/mime"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
"github.com/livekit/protocol/observability/roomobs" "github.com/livekit/protocol/observability/roomobs"
@@ -147,8 +148,9 @@ type Room struct {
dataMessageCache *utils.TimeSizeCache[types.DataMessageCache] dataMessageCache *utils.TimeSizeCache[types.DataMessageCache]
onStateChangeMu sync.Mutex onStateChangeMu sync.Mutex
localParticipantListener types.LocalParticipantListener localParticipantListener types.LocalParticipantListener
participantTelemetryListener types.ParticipantTelemetryListener
} }
type ParticipantOptions struct { type ParticipantOptions struct {
@@ -286,6 +288,7 @@ func NewRoom(
} }
r.trackManager = NewRoomTrackManager(r.logger) r.trackManager = NewRoomTrackManager(r.logger)
r.localParticipantListener = &localParticipantListener{room: r} r.localParticipantListener = &localParticipantListener{room: r}
r.participantTelemetryListener = &participantTelemetryListener{room: r}
if r.protoRoom.EmptyTimeout == 0 { if r.protoRoom.EmptyTimeout == 0 {
r.protoRoom.EmptyTimeout = roomConfig.EmptyTimeout r.protoRoom.EmptyTimeout = roomConfig.EmptyTimeout
@@ -1890,6 +1893,10 @@ func (r *Room) LocalParticipantListener() types.LocalParticipantListener {
return r.localParticipantListener return r.localParticipantListener
} }
func (r *Room) ParticipantTelemetryListener() types.ParticipantTelemetryListener {
return r.participantTelemetryListener
}
// ------------------------------------------------------------ // ------------------------------------------------------------
var _ types.LocalParticipantListener = (*localParticipantListener)(nil) var _ types.LocalParticipantListener = (*localParticipantListener)(nil)
@@ -1983,6 +1990,72 @@ func (l *localParticipantListener) OnLeave(p types.LocalParticipant, closeReason
// ------------------------------------------------------------ // ------------------------------------------------------------
var _ types.ParticipantTelemetryListener = (*participantTelemetryListener)(nil)
type participantTelemetryListener struct {
room *Room
}
func (l participantTelemetryListener) OnTrackPublishRequested(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo) {
l.room.telemetry.TrackPublishRequested(context.Background(), l.room.ID(), l.room.Name(), pID, identity, ti)
}
func (l participantTelemetryListener) OnTrackPublished(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo, shouldSendEvent bool) {
l.room.telemetry.TrackPublished(context.Background(), l.room.ID(), l.room.Name(), pID, identity, ti, shouldSendEvent)
}
func (l participantTelemetryListener) OnTrackUnpublished(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo, shouldSendEvent bool) {
l.room.telemetry.TrackUnpublished(context.Background(), l.room.ID(), l.room.Name(), pID, identity, ti, shouldSendEvent)
}
func (l participantTelemetryListener) OnTrackSubscribeRequested(pID livekit.ParticipantID, ti *livekit.TrackInfo) {
l.room.telemetry.TrackSubscribeRequested(context.Background(), l.room.ID(), l.room.Name(), pID, ti)
}
func (l participantTelemetryListener) OnTrackSubscribed(pID livekit.ParticipantID, ti *livekit.TrackInfo, publisherInfo *livekit.ParticipantInfo, shouldSendEvent bool) {
l.room.telemetry.TrackSubscribed(context.Background(), l.room.ID(), l.room.Name(), pID, ti, publisherInfo, shouldSendEvent)
}
func (l participantTelemetryListener) OnTrackUnsubscribed(pID livekit.ParticipantID, ti *livekit.TrackInfo, shouldSendEvent bool) {
l.room.telemetry.TrackUnsubscribed(context.Background(), l.room.ID(), l.room.Name(), pID, ti, shouldSendEvent)
}
func (l participantTelemetryListener) OnTrackSubscribeFailed(pID livekit.ParticipantID, ti livekit.TrackID, err error, isUserError bool) {
l.room.telemetry.TrackSubscribeFailed(context.Background(), l.room.ID(), l.room.Name(), pID, ti, err, isUserError)
}
func (l participantTelemetryListener) OnTrackMuted(pID livekit.ParticipantID, ti *livekit.TrackInfo) {
l.room.telemetry.TrackMuted(context.Background(), l.room.ID(), l.room.Name(), pID, ti)
}
func (l participantTelemetryListener) OnTrackUnmuted(pID livekit.ParticipantID, ti *livekit.TrackInfo) {
l.room.telemetry.TrackUnmuted(context.Background(), l.room.ID(), l.room.Name(), pID, ti)
}
func (l participantTelemetryListener) OnTrackPublishedUpdate(pID livekit.ParticipantID, ti *livekit.TrackInfo) {
l.room.telemetry.TrackPublishedUpdate(context.Background(), l.room.ID(), l.room.Name(), pID, ti)
}
func (l participantTelemetryListener) OnTrackMaxSubscribedVideoQuality(pID livekit.ParticipantID, ti *livekit.TrackInfo, mime mime.MimeType, maxQuality livekit.VideoQuality) {
l.room.telemetry.TrackMaxSubscribedVideoQuality(context.Background(), l.room.ID(), l.room.Name(), pID, ti, mime, maxQuality)
}
func (l participantTelemetryListener) OnTrackPublishRTPStats(pID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, layer int, stats *livekit.RTPStats) {
l.room.telemetry.TrackPublishRTPStats(context.Background(), l.room.ID(), l.room.Name(), pID, trackID, mimeType, layer, stats)
}
func (l participantTelemetryListener) OnTrackSubscribeRTPStats(pID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, stats *livekit.RTPStats) {
l.room.telemetry.TrackSubscribeRTPStats(context.Background(), l.room.ID(), l.room.Name(), pID, trackID, mimeType, stats)
}
func (l participantTelemetryListener) OnTrackStats(key telemetry.StatsKey, stat *livekit.AnalyticsStat) {
roomID, roomName := l.room.ID(), l.room.Name()
stat.RoomId, stat.RoomName = string(roomID), string(roomName)
l.room.telemetry.TrackStats(roomID, roomName, key, stat)
}
// ------------------------------------------------------------
func BroadcastDataPacketForRoom( func BroadcastDataPacketForRoom(
r types.Room, r types.Room,
source types.LocalParticipant, source types.LocalParticipant,
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package telemetry package rtc
import ( import (
"context" "context"
@@ -23,6 +23,8 @@ import (
"github.com/frostbyte73/core" "github.com/frostbyte73/core"
"go.uber.org/atomic" "go.uber.org/atomic"
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/telemetry"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/observability/roomobs" "github.com/livekit/protocol/observability/roomobs"
"github.com/livekit/protocol/utils" "github.com/livekit/protocol/utils"
@@ -50,13 +52,13 @@ type TrafficTotals struct {
// stats for signal and data channel // stats for signal and data channel
type BytesTrackStats struct { type BytesTrackStats struct {
country string country string
trackID livekit.TrackID
pID livekit.ParticipantID pID livekit.ParticipantID
trackID livekit.TrackID
send, recv atomic.Uint64 send, recv atomic.Uint64
sendMessages, recvMessages atomic.Uint32 sendMessages, recvMessages atomic.Uint32
totalSendBytes, totalRecvBytes atomic.Uint64 totalSendBytes, totalRecvBytes atomic.Uint64
totalSendMessages, totalRecvMessages atomic.Uint32 totalSendMessages, totalRecvMessages atomic.Uint32
telemetry TelemetryService telemetryListener types.ParticipantTelemetryListener
reporter roomobs.TrackReporter reporter roomobs.TrackReporter
done core.Fuse done core.Fuse
} }
@@ -65,15 +67,15 @@ func NewBytesTrackStats(
country string, country string,
trackID livekit.TrackID, trackID livekit.TrackID,
pID livekit.ParticipantID, pID livekit.ParticipantID,
telemetry TelemetryService, telemetryListener types.ParticipantTelemetryListener,
participantReporter roomobs.ParticipantSessionReporter, participantReporter roomobs.ParticipantSessionReporter,
) *BytesTrackStats { ) *BytesTrackStats {
s := &BytesTrackStats{ s := &BytesTrackStats{
country: country, country: country,
trackID: trackID, pID: pID,
pID: pID, trackID: trackID,
telemetry: telemetry, telemetryListener: telemetryListener,
reporter: participantReporter.WithTrack(trackID.String()), reporter: participantReporter.WithTrack(trackID.String()),
} }
go s.worker() go s.worker()
return s return s
@@ -122,8 +124,8 @@ func (s *BytesTrackStats) Stop() {
func (s *BytesTrackStats) report() { func (s *BytesTrackStats) report() {
if recv := s.recv.Swap(0); recv > 0 { if recv := s.recv.Swap(0); recv > 0 {
packets := s.recvMessages.Swap(0) packets := s.recvMessages.Swap(0)
s.telemetry.TrackStats( s.telemetryListener.OnTrackStats(
StatsKeyForData(s.country, livekit.StreamType_UPSTREAM, s.pID, s.trackID), telemetry.StatsKeyForData(s.country, livekit.StreamType_UPSTREAM, s.pID, s.trackID),
&livekit.AnalyticsStat{ &livekit.AnalyticsStat{
Streams: []*livekit.AnalyticsStream{ Streams: []*livekit.AnalyticsStream{
{ {
@@ -137,8 +139,8 @@ func (s *BytesTrackStats) report() {
if send := s.send.Swap(0); send > 0 { if send := s.send.Swap(0); send > 0 {
packets := s.sendMessages.Swap(0) packets := s.sendMessages.Swap(0)
s.telemetry.TrackStats( s.telemetryListener.OnTrackStats(
StatsKeyForData(s.country, livekit.StreamType_DOWNSTREAM, s.pID, s.trackID), telemetry.StatsKeyForData(s.country, livekit.StreamType_DOWNSTREAM, s.pID, s.trackID),
&livekit.AnalyticsStat{ &livekit.AnalyticsStat{
Streams: []*livekit.AnalyticsStream{ Streams: []*livekit.AnalyticsStream{
{ {
@@ -170,11 +172,14 @@ func (s *BytesTrackStats) worker() {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
var _ types.ParticipantTelemetryListener = (*BytesSignalStats)(nil)
type BytesSignalStats struct { type BytesSignalStats struct {
BytesTrackStats BytesTrackStats
ctx context.Context ctx context.Context
guard *ReferenceGuard telemetry telemetry.TelemetryService
guard *telemetry.ReferenceGuard
participantResolver roomobs.ParticipantReporterResolver participantResolver roomobs.ParticipantReporterResolver
trackResolver roomobs.KeyResolver trackResolver roomobs.KeyResolver
@@ -183,25 +188,29 @@ type BytesSignalStats struct {
ri *livekit.Room ri *livekit.Room
pi *livekit.ParticipantInfo pi *livekit.ParticipantInfo
stopped chan struct{} stopped chan struct{}
types.NullParticipantTelemetryListener
} }
func NewBytesSignalStats( func NewBytesSignalStats(
ctx context.Context, ctx context.Context,
telemetry TelemetryService, telemetryService telemetry.TelemetryService,
) *BytesSignalStats { ) *BytesSignalStats {
projectReporter := telemetry.RoomProjectReporter(ctx) projectReporter := telemetryService.RoomProjectReporter(ctx)
participantReporter, participantReporterResolver := roomobs.DeferredParticipantReporter(projectReporter) participantReporter, participantReporterResolver := roomobs.DeferredParticipantReporter(projectReporter)
trackReporter, trackReporterResolver := participantReporter.WithDeferredTrack() trackReporter, trackReporterResolver := participantReporter.WithDeferredTrack()
return &BytesSignalStats{ b := &BytesSignalStats{
BytesTrackStats: BytesTrackStats{
telemetry: telemetry,
reporter: trackReporter,
},
ctx: ctx, ctx: ctx,
guard: &ReferenceGuard{}, telemetry: telemetryService,
guard: &telemetry.ReferenceGuard{},
participantResolver: participantReporterResolver, participantResolver: participantReporterResolver,
trackResolver: trackReporterResolver, trackResolver: trackReporterResolver,
} }
b.BytesTrackStats = BytesTrackStats{
telemetryListener: b,
reporter: trackReporter,
}
return b
} }
func (s *BytesSignalStats) ResolveRoom(ri *livekit.Room) { func (s *BytesSignalStats) ResolveRoom(ri *livekit.Room) {
@@ -236,7 +245,7 @@ func (s *BytesSignalStats) Reset() {
<-s.stopped <-s.stopped
s.stopped = nil s.stopped = nil
s.done = core.Fuse{} s.done = core.Fuse{}
s.guard = &ReferenceGuard{} s.guard = &telemetry.ReferenceGuard{}
} }
s.ri = nil s.ri = nil
s.pi = nil s.pi = nil
@@ -272,6 +281,11 @@ func (s *BytesSignalStats) worker() {
close(s.stopped) close(s.stopped)
} }
func (s *BytesSignalStats) OnTrackStats(key telemetry.StatsKey, stat *livekit.AnalyticsStat) {
stat.RoomId, stat.RoomName = s.ri.Sid, s.ri.Name
s.telemetry.TrackStats(livekit.RoomID(s.ri.Sid), livekit.RoomName(s.ri.Name), key, stat)
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
func BytesTrackIDForParticipantID(typ BytesTrackType, participantID livekit.ParticipantID) livekit.TrackID { func BytesTrackIDForParticipantID(typ BytesTrackType, participantID livekit.ParticipantID) livekit.TrackID {
+2 -2
View File
@@ -48,7 +48,7 @@ type SubscribedTrackParams struct {
Subscriber types.LocalParticipant Subscriber types.LocalParticipant
MediaTrack types.MediaTrack MediaTrack types.MediaTrack
AdaptiveStream bool AdaptiveStream bool
Telemetry telemetry.TelemetryService TelemetryListener types.ParticipantTelemetryListener
WrappedReceiver *WrappedReceiver WrappedReceiver *WrappedReceiver
IsRelayed bool IsRelayed bool
OnDownTrackCreated func(downTrack *sfu.DownTrack) OnDownTrackCreated func(downTrack *sfu.DownTrack)
@@ -403,7 +403,7 @@ func (t *SubscribedTrack) OnBindAndConnected() {
} }
func (t *SubscribedTrack) OnStatsUpdate(stat *livekit.AnalyticsStat) { func (t *SubscribedTrack) OnStatsUpdate(stat *livekit.AnalyticsStat) {
t.params.Telemetry.TrackStats(t.statsKey, stat) t.params.TelemetryListener.OnTrackStats(t.statsKey, stat)
if cs, ok := telemetry.CondenseStat(stat); ok { if cs, ok := telemetry.CondenseStat(stat); ok {
ti := t.params.WrappedReceiver.TrackInfo() ti := t.params.WrappedReceiver.TrackInfo()
+14 -18
View File
@@ -28,7 +28,6 @@ import (
"github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/sfu" "github.com/livekit/livekit-server/pkg/sfu"
"github.com/livekit/livekit-server/pkg/telemetry"
"github.com/livekit/livekit-server/pkg/telemetry/prometheus" "github.com/livekit/livekit-server/pkg/telemetry/prometheus"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
@@ -57,7 +56,7 @@ type SubscriptionManagerParams struct {
OnTrackSubscribed func(subTrack types.SubscribedTrack) OnTrackSubscribed func(subTrack types.SubscribedTrack)
OnTrackUnsubscribed func(subTrack types.SubscribedTrack) OnTrackUnsubscribed func(subTrack types.SubscribedTrack)
OnSubscriptionError func(trackID livekit.TrackID, fatal bool, err error) OnSubscriptionError func(trackID livekit.TrackID, fatal bool, err error)
Telemetry telemetry.TelemetryService TelemetryListener types.ParticipantTelemetryListener
SubscriptionLimitVideo, SubscriptionLimitAudio int32 SubscriptionLimitVideo, SubscriptionLimitAudio int32
@@ -472,8 +471,7 @@ func (m *SubscriptionManager) reconcileSubscription(s *mediaTrackSubscription) {
numAttempts := s.getNumAttempts() numAttempts := s.getNumAttempts()
if numAttempts == 0 { if numAttempts == 0 {
m.params.Telemetry.TrackSubscribeRequested( m.params.TelemetryListener.OnTrackSubscribeRequested(
context.Background(),
s.subscriberID, s.subscriberID,
&livekit.TrackInfo{ &livekit.TrackInfo{
Sid: string(s.trackID), Sid: string(s.trackID),
@@ -493,14 +491,14 @@ func (m *SubscriptionManager) reconcileSubscription(s *mediaTrackSubscription) {
// - ErrSubscriptionLimitExceeded: the participant have reached the limit of subscriptions, wait for the other subscription to be unsubscribed // - ErrSubscriptionLimitExceeded: the participant have reached the limit of subscriptions, wait for the other subscription to be unsubscribed
// We'll still log an event to reflect this in telemetry since it's been too long // We'll still log an event to reflect this in telemetry since it's been too long
if s.durationSinceStart() > subscriptionTimeout { if s.durationSinceStart() > subscriptionTimeout {
s.maybeRecordError(m.params.Telemetry, s.subscriberID, err, true) s.maybeRecordError(m.params.TelemetryListener, err, true)
} }
case ErrTrackNotFound: case ErrTrackNotFound:
// source track was never published or closed // source track was never published or closed
// if after timeout we'd unsubscribe from it. // if after timeout we'd unsubscribe from it.
// this is the *only* case we'd change desired state // this is the *only* case we'd change desired state
if s.durationSinceStart() > notFoundTimeout { if s.durationSinceStart() > notFoundTimeout {
s.maybeRecordError(m.params.Telemetry, s.subscriberID, err, true) s.maybeRecordError(m.params.TelemetryListener, err, true)
s.logger.Infow("unsubscribing from track after notFoundTimeout", "error", err) s.logger.Infow("unsubscribing from track after notFoundTimeout", "error", err)
s.setDesired(false) s.setDesired(false)
m.queueReconcile(s.trackID) m.queueReconcile(s.trackID)
@@ -513,7 +511,7 @@ func (m *SubscriptionManager) reconcileSubscription(s *mediaTrackSubscription) {
"failed to subscribe, triggering error handler", err, "failed to subscribe, triggering error handler", err,
"attempt", s.getNumAttempts(), "attempt", s.getNumAttempts(),
) )
s.maybeRecordError(m.params.Telemetry, s.subscriberID, err, false) s.maybeRecordError(m.params.TelemetryListener, err, false)
m.params.OnSubscriptionError(s.trackID, true, err) m.params.OnSubscriptionError(s.trackID, true, err)
} else { } else {
s.logger.Debugw( s.logger.Debugw(
@@ -552,7 +550,7 @@ func (m *SubscriptionManager) reconcileSubscription(s *mediaTrackSubscription) {
wait := min(time.Since(activeAt), s.durationSinceStart()) wait := min(time.Since(activeAt), s.durationSinceStart())
if wait > subscriptionTimeout { if wait > subscriptionTimeout {
s.logger.Warnw("track not bound after timeout", nil) s.logger.Warnw("track not bound after timeout", nil)
s.maybeRecordError(m.params.Telemetry, s.subscriberID, ErrTrackNotBound, false) s.maybeRecordError(m.params.TelemetryListener, ErrTrackNotBound, false)
m.params.OnSubscriptionError(s.trackID, true, ErrTrackNotBound) m.params.OnSubscriptionError(s.trackID, true, ErrTrackNotBound)
} }
} }
@@ -839,13 +837,13 @@ func (m *SubscriptionManager) addSubscriber(sub *mediaTrackSubscription, track t
subTrack.AddOnBind(func(err error) { subTrack.AddOnBind(func(err error) {
if err != nil { if err != nil {
sub.logger.Infow("failed to bind track", "err", err) sub.logger.Infow("failed to bind track", "err", err)
sub.maybeRecordError(m.params.Telemetry, sub.subscriberID, err, true) sub.maybeRecordError(m.params.TelemetryListener, err, true)
m.UnsubscribeFromTrack(trackID) m.UnsubscribeFromTrack(trackID)
m.params.OnSubscriptionError(trackID, false, err) m.params.OnSubscriptionError(trackID, false, err)
return return
} }
sub.setBound() sub.setBound()
sub.maybeRecordSuccess(m.params.Telemetry, sub.subscriberID) sub.maybeRecordSuccess(m.params.TelemetryListener)
}) })
sub.setSubscribedTrack(subTrack) sub.setSubscribedTrack(subTrack)
@@ -967,8 +965,7 @@ func (m *SubscriptionManager) handleSubscribedTrackClose(s *mediaTrackSubscripti
// * the participant isn't closing // * the participant isn't closing
// * it's not a migration // * it's not a migration
if wasBound { if wasBound {
m.params.Telemetry.TrackUnsubscribed( m.params.TelemetryListener.OnTrackUnsubscribed(
context.Background(),
s.subscriberID, s.subscriberID,
&livekit.TrackInfo{Sid: string(s.trackID), Type: subTrack.MediaTrack().Kind()}, &livekit.TrackInfo{Sid: string(s.trackID), Type: subTrack.MediaTrack().Kind()},
!isExpectedToResume, !isExpectedToResume,
@@ -978,8 +975,7 @@ func (m *SubscriptionManager) handleSubscribedTrackClose(s *mediaTrackSubscripti
if dt != nil { if dt != nil {
stats := dt.GetTrackStats() stats := dt.GetTrackStats()
if stats != nil { if stats != nil {
m.params.Telemetry.TrackSubscribeRTPStats( m.params.TelemetryListener.OnTrackSubscribeRTPStats(
context.Background(),
s.subscriberID, s.subscriberID,
s.trackID, s.trackID,
dt.Mime(), dt.Mime(),
@@ -1437,15 +1433,15 @@ func (s *mediaTrackSubscription) isBound() bool {
return s.bound return s.bound
} }
func (s *mediaTrackSubscription) maybeRecordError(ts telemetry.TelemetryService, pID livekit.ParticipantID, err error, isUserError bool) { func (s *mediaTrackSubscription) maybeRecordError(tl types.ParticipantTelemetryListener, err error, isUserError bool) {
if s.eventSent.Swap(true) { if s.eventSent.Swap(true) {
return return
} }
ts.TrackSubscribeFailed(context.Background(), pID, s.trackID, err, isUserError) tl.OnTrackSubscribeFailed(s.subscriberID, s.trackID, err, isUserError)
} }
func (s *mediaTrackSubscription) maybeRecordSuccess(ts telemetry.TelemetryService, pID livekit.ParticipantID) { func (s *mediaTrackSubscription) maybeRecordSuccess(tl types.ParticipantTelemetryListener) {
subTrack := s.getSubscribedTrack() subTrack := s.getSubscribedTrack()
if subTrack == nil { if subTrack == nil {
return return
@@ -1474,7 +1470,7 @@ func (s *mediaTrackSubscription) maybeRecordSuccess(ts telemetry.TelemetryServic
Identity: string(subTrack.PublisherIdentity()), Identity: string(subTrack.PublisherIdentity()),
Sid: string(subTrack.PublisherID()), Sid: string(subTrack.PublisherID()),
} }
ts.TrackSubscribed(context.Background(), pID, mediaTrack.ToProto(), pi, !eventSent) tl.OnTrackSubscribed(s.subscriberID, mediaTrack.ToProto(), pi, !eventSent)
} }
func (s *mediaTrackSubscription) isCanceled() bool { func (s *mediaTrackSubscription) isCanceled() bool {
+17 -18
View File
@@ -26,7 +26,6 @@ import (
"github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/rtc/types/typesfakes" "github.com/livekit/livekit-server/pkg/rtc/types/typesfakes"
"github.com/livekit/livekit-server/pkg/telemetry/telemetryfakes"
"github.com/livekit/livekit-server/pkg/utils" "github.com/livekit/livekit-server/pkg/utils"
"github.com/livekit/protocol/livekit" "github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger" "github.com/livekit/protocol/logger"
@@ -83,8 +82,8 @@ func TestSubscribe(t *testing.T) {
require.Equal(t, "pubID", string(sm.GetSubscribedParticipants()[0])) require.Equal(t, "pubID", string(sm.GetSubscribedParticipants()[0]))
// ensure telemetry events are sent // ensure telemetry events are sent
tm := sm.params.Telemetry.(*telemetryfakes.FakeTelemetryService) tl := sm.params.TelemetryListener.(*typesfakes.FakeParticipantTelemetryListener)
require.Equal(t, 1, tm.TrackSubscribeRequestedCallCount()) require.Equal(t, 1, tl.OnTrackSubscribeRequestedCallCount())
// ensure bound // ensure bound
setTestSubscribedTrackBound(t, s.getSubscribedTrack()) setTestSubscribedTrackBound(t, s.getSubscribedTrack())
@@ -93,7 +92,7 @@ func TestSubscribe(t *testing.T) {
}, subSettleTimeout, subCheckInterval, "track was not bound") }, subSettleTimeout, subCheckInterval, "track was not bound")
// telemetry event should have been sent // telemetry event should have been sent
require.Equal(t, 1, tm.TrackSubscribedCallCount()) require.Equal(t, 1, tl.OnTrackSubscribedCallCount())
time.Sleep(notFoundTimeout) time.Sleep(notFoundTimeout)
require.False(t, failed.Load()) require.False(t, failed.Load())
@@ -142,9 +141,9 @@ func TestSubscribe(t *testing.T) {
require.Len(t, sm.GetSubscribedTracks(), 0) require.Len(t, sm.GetSubscribedTracks(), 0)
// trackSubscribed telemetry not sent // trackSubscribed telemetry not sent
tm := sm.params.Telemetry.(*telemetryfakes.FakeTelemetryService) tl := sm.params.TelemetryListener.(*typesfakes.FakeParticipantTelemetryListener)
require.Equal(t, 1, tm.TrackSubscribeRequestedCallCount()) require.Equal(t, 1, tl.OnTrackSubscribeRequestedCallCount())
require.Equal(t, 0, tm.TrackSubscribedCallCount()) require.Equal(t, 0, tl.OnTrackSubscribedCallCount())
// give permissions now // give permissions now
resolver.lock.Lock() resolver.lock.Lock()
@@ -254,8 +253,8 @@ func TestUnsubscribe(t *testing.T) {
require.Len(t, sm.GetSubscribedTracks(), 0) require.Len(t, sm.GetSubscribedTracks(), 0)
require.False(t, res.TrackChangedNotifier.HasObservers()) require.False(t, res.TrackChangedNotifier.HasObservers())
tm := sm.params.Telemetry.(*telemetryfakes.FakeTelemetryService) tl := sm.params.TelemetryListener.(*typesfakes.FakeParticipantTelemetryListener)
require.Equal(t, 1, tm.TrackUnsubscribedCallCount()) require.Equal(t, 1, tl.OnTrackUnsubscribedCallCount())
} }
func TestSubscribeStatusChanged(t *testing.T) { func TestSubscribeStatusChanged(t *testing.T) {
@@ -394,8 +393,8 @@ func TestSubscriptionLimits(t *testing.T) {
require.Equal(t, "pubID", string(sm.GetSubscribedParticipants()[0])) require.Equal(t, "pubID", string(sm.GetSubscribedParticipants()[0]))
// ensure telemetry events are sent // ensure telemetry events are sent
tm := sm.params.Telemetry.(*telemetryfakes.FakeTelemetryService) tl := sm.params.TelemetryListener.(*typesfakes.FakeParticipantTelemetryListener)
require.Equal(t, 1, tm.TrackSubscribeRequestedCallCount()) require.Equal(t, 1, tl.OnTrackSubscribeRequestedCallCount())
// ensure bound // ensure bound
setTestSubscribedTrackBound(t, s.getSubscribedTrack()) setTestSubscribedTrackBound(t, s.getSubscribedTrack())
@@ -404,15 +403,15 @@ func TestSubscriptionLimits(t *testing.T) {
}, subSettleTimeout, subCheckInterval, "track was not bound") }, subSettleTimeout, subCheckInterval, "track was not bound")
// telemetry event should have been sent // telemetry event should have been sent
require.Equal(t, 1, tm.TrackSubscribedCallCount()) require.Equal(t, 1, tl.OnTrackSubscribedCallCount())
// reach subscription limit, subscribe pending // reach subscription limit, subscribe pending
sm.SubscribeToTrack("track2", false) sm.SubscribeToTrack("track2", false)
s2 := sm.subscriptions["track2"] s2 := sm.subscriptions["track2"]
time.Sleep(subscriptionTimeout * 2) time.Sleep(subscriptionTimeout * 2)
require.True(t, s2.needsSubscribe()) require.True(t, s2.needsSubscribe())
require.Equal(t, 2, tm.TrackSubscribeRequestedCallCount()) require.Equal(t, 2, tl.OnTrackSubscribeRequestedCallCount())
require.Equal(t, 1, tm.TrackSubscribeFailedCallCount()) require.Equal(t, 1, tl.OnTrackSubscribeFailedCallCount())
require.Len(t, sm.GetSubscribedTracks(), 1) require.Len(t, sm.GetSubscribedTracks(), 1)
// unsubscribe track1, then track2 should be subscribed // unsubscribe track1, then track2 should be subscribed
@@ -429,7 +428,7 @@ func TestSubscriptionLimits(t *testing.T) {
require.False(t, s2.needsSubscribe()) require.False(t, s2.needsSubscribe())
require.EqualValues(t, 2, subCount.Load()) require.EqualValues(t, 2, subCount.Load())
require.NotNil(t, s2.getSubscribedTrack()) require.NotNil(t, s2.getSubscribedTrack())
require.Equal(t, 2, tm.TrackSubscribeRequestedCallCount()) require.Equal(t, 2, tl.OnTrackSubscribeRequestedCallCount())
require.Len(t, sm.GetSubscribedTracks(), 1) require.Len(t, sm.GetSubscribedTracks(), 1)
// ensure bound // ensure bound
@@ -444,8 +443,8 @@ func TestSubscriptionLimits(t *testing.T) {
require.True(t, s.isDesired()) require.True(t, s.isDesired())
time.Sleep(subscriptionTimeout * 2) time.Sleep(subscriptionTimeout * 2)
require.True(t, s.needsSubscribe()) require.True(t, s.needsSubscribe())
require.Equal(t, 3, tm.TrackSubscribeRequestedCallCount()) require.Equal(t, 3, tl.OnTrackSubscribeRequestedCallCount())
require.Equal(t, 2, tm.TrackSubscribeFailedCallCount()) require.Equal(t, 2, tl.OnTrackSubscribeFailedCallCount())
require.Len(t, sm.GetSubscribedTracks(), 1) require.Len(t, sm.GetSubscribedTracks(), 1)
} }
@@ -473,7 +472,7 @@ func newTestSubscriptionManagerWithParams(params testSubscriptionParams) *Subscr
TrackResolver: func(sub types.LocalParticipant, trackID livekit.TrackID) types.MediaResolverResult { TrackResolver: func(sub types.LocalParticipant, trackID livekit.TrackID) types.MediaResolverResult {
return types.MediaResolverResult{} return types.MediaResolverResult{}
}, },
Telemetry: &telemetryfakes.FakeTelemetryService{}, TelemetryListener: &typesfakes.FakeParticipantTelemetryListener{},
SubscriptionLimitAudio: params.SubscriptionLimitAudio, SubscriptionLimitAudio: params.SubscriptionLimitAudio,
SubscriptionLimitVideo: params.SubscriptionLimitVideo, SubscriptionLimitVideo: params.SubscriptionLimitVideo,
}) })
+1 -2
View File
@@ -41,7 +41,6 @@ import (
"github.com/livekit/livekit-server/pkg/sfu/datachannel" "github.com/livekit/livekit-server/pkg/sfu/datachannel"
"github.com/livekit/livekit-server/pkg/sfu/interceptor" "github.com/livekit/livekit-server/pkg/sfu/interceptor"
"github.com/livekit/livekit-server/pkg/sfu/pacer" "github.com/livekit/livekit-server/pkg/sfu/pacer"
"github.com/livekit/livekit-server/pkg/telemetry"
) )
const ( const (
@@ -95,7 +94,7 @@ type TransportManagerParams struct {
Logger logger.Logger Logger logger.Logger
PublisherHandler transport.Handler PublisherHandler transport.Handler
SubscriberHandler transport.Handler SubscriberHandler transport.Handler
DataChannelStats *telemetry.BytesTrackStats DataChannelStats *BytesTrackStats
UseOneShotSignallingMode bool UseOneShotSignallingMode bool
FireOnTrackBySdp bool FireOnTrackBySdp bool
EnableDataTracks bool EnableDataTracks bool
+55
View File
@@ -636,6 +636,61 @@ func (*NullLocalParticipantListener) OnLeave(LocalParticipant, ParticipantCloseR
// --------------------------------------------- // ---------------------------------------------
//counterfeiter:generate . ParticipantTelemetryListener
type ParticipantTelemetryListener interface {
OnTrackPublishRequested(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo)
OnTrackPublished(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo, shouldSendEvent bool)
OnTrackUnpublished(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo, shouldSendEvent bool)
OnTrackSubscribeRequested(pID livekit.ParticipantID, ti *livekit.TrackInfo)
OnTrackSubscribed(pID livekit.ParticipantID, ti *livekit.TrackInfo, publisherInfo *livekit.ParticipantInfo, shouldSendEvent bool)
OnTrackUnsubscribed(pID livekit.ParticipantID, ti *livekit.TrackInfo, shouldSendEvent bool)
OnTrackSubscribeFailed(pID livekit.ParticipantID, ti livekit.TrackID, err error, isUserError bool)
OnTrackMuted(pID livekit.ParticipantID, ti *livekit.TrackInfo)
OnTrackUnmuted(pID livekit.ParticipantID, ti *livekit.TrackInfo)
OnTrackPublishedUpdate(pID livekit.ParticipantID, ti *livekit.TrackInfo)
OnTrackMaxSubscribedVideoQuality(pID livekit.ParticipantID, ti *livekit.TrackInfo, mime mime.MimeType, maxQuality livekit.VideoQuality)
OnTrackPublishRTPStats(pID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, layer int, stats *livekit.RTPStats)
OnTrackSubscribeRTPStats(pID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, stats *livekit.RTPStats)
OnTrackStats(key telemetry.StatsKey, stat *livekit.AnalyticsStat)
}
var _ ParticipantTelemetryListener = (*NullParticipantTelemetryListener)(nil)
type NullParticipantTelemetryListener struct{}
func (NullParticipantTelemetryListener) OnTrackPublishRequested(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo) {
}
func (NullParticipantTelemetryListener) OnTrackPublished(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo, shouldSendEvent bool) {
}
func (NullParticipantTelemetryListener) OnTrackUnpublished(pID livekit.ParticipantID, identity livekit.ParticipantIdentity, ti *livekit.TrackInfo, shouldSendEvent bool) {
}
func (NullParticipantTelemetryListener) OnTrackSubscribeRequested(pID livekit.ParticipantID, ti *livekit.TrackInfo) {
}
func (NullParticipantTelemetryListener) OnTrackSubscribed(pID livekit.ParticipantID, ti *livekit.TrackInfo, publisherInfo *livekit.ParticipantInfo, shouldSendEvent bool) {
}
func (NullParticipantTelemetryListener) OnTrackUnsubscribed(pID livekit.ParticipantID, ti *livekit.TrackInfo, shouldSendEvent bool) {
}
func (NullParticipantTelemetryListener) OnTrackSubscribeFailed(pID livekit.ParticipantID, ti livekit.TrackID, err error, isUserError bool) {
}
func (NullParticipantTelemetryListener) OnTrackMuted(pID livekit.ParticipantID, ti *livekit.TrackInfo) {
}
func (NullParticipantTelemetryListener) OnTrackUnmuted(pID livekit.ParticipantID, ti *livekit.TrackInfo) {
}
func (NullParticipantTelemetryListener) OnTrackPublishedUpdate(pID livekit.ParticipantID, ti *livekit.TrackInfo) {
}
func (NullParticipantTelemetryListener) OnTrackMaxSubscribedVideoQuality(pID livekit.ParticipantID, ti *livekit.TrackInfo, mime mime.MimeType, maxQuality livekit.VideoQuality) {
}
func (NullParticipantTelemetryListener) OnTrackPublishRTPStats(pID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, layer int, stats *livekit.RTPStats) {
}
func (NullParticipantTelemetryListener) OnTrackSubscribeRTPStats(pID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, stats *livekit.RTPStats) {
}
func (NullParticipantTelemetryListener) OnTrackStats(key telemetry.StatsKey, stat *livekit.AnalyticsStat) {
}
// ---------------------------------------------
// Room is a container of participants, and can provide room-level actions // Room is a container of participants, and can provide room-level actions
// //
//counterfeiter:generate . Room //counterfeiter:generate . Room
@@ -0,0 +1,620 @@
// Code generated by counterfeiter. DO NOT EDIT.
package typesfakes
import (
"sync"
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/telemetry"
"github.com/livekit/protocol/codecs/mime"
"github.com/livekit/protocol/livekit"
)
type FakeParticipantTelemetryListener struct {
OnTrackMaxSubscribedVideoQualityStub func(livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality)
onTrackMaxSubscribedVideoQualityMutex sync.RWMutex
onTrackMaxSubscribedVideoQualityArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
arg3 mime.MimeType
arg4 livekit.VideoQuality
}
OnTrackMutedStub func(livekit.ParticipantID, *livekit.TrackInfo)
onTrackMutedMutex sync.RWMutex
onTrackMutedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
}
OnTrackPublishRTPStatsStub func(livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats)
onTrackPublishRTPStatsMutex sync.RWMutex
onTrackPublishRTPStatsArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 livekit.TrackID
arg3 mime.MimeType
arg4 int
arg5 *livekit.RTPStats
}
OnTrackPublishRequestedStub func(livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)
onTrackPublishRequestedMutex sync.RWMutex
onTrackPublishRequestedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 livekit.ParticipantIdentity
arg3 *livekit.TrackInfo
}
OnTrackPublishedStub func(livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)
onTrackPublishedMutex sync.RWMutex
onTrackPublishedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 livekit.ParticipantIdentity
arg3 *livekit.TrackInfo
arg4 bool
}
OnTrackPublishedUpdateStub func(livekit.ParticipantID, *livekit.TrackInfo)
onTrackPublishedUpdateMutex sync.RWMutex
onTrackPublishedUpdateArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
}
OnTrackStatsStub func(telemetry.StatsKey, *livekit.AnalyticsStat)
onTrackStatsMutex sync.RWMutex
onTrackStatsArgsForCall []struct {
arg1 telemetry.StatsKey
arg2 *livekit.AnalyticsStat
}
OnTrackSubscribeFailedStub func(livekit.ParticipantID, livekit.TrackID, error, bool)
onTrackSubscribeFailedMutex sync.RWMutex
onTrackSubscribeFailedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 livekit.TrackID
arg3 error
arg4 bool
}
OnTrackSubscribeRTPStatsStub func(livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats)
onTrackSubscribeRTPStatsMutex sync.RWMutex
onTrackSubscribeRTPStatsArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 livekit.TrackID
arg3 mime.MimeType
arg4 *livekit.RTPStats
}
OnTrackSubscribeRequestedStub func(livekit.ParticipantID, *livekit.TrackInfo)
onTrackSubscribeRequestedMutex sync.RWMutex
onTrackSubscribeRequestedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
}
OnTrackSubscribedStub func(livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool)
onTrackSubscribedMutex sync.RWMutex
onTrackSubscribedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
arg3 *livekit.ParticipantInfo
arg4 bool
}
OnTrackUnmutedStub func(livekit.ParticipantID, *livekit.TrackInfo)
onTrackUnmutedMutex sync.RWMutex
onTrackUnmutedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
}
OnTrackUnpublishedStub func(livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)
onTrackUnpublishedMutex sync.RWMutex
onTrackUnpublishedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 livekit.ParticipantIdentity
arg3 *livekit.TrackInfo
arg4 bool
}
OnTrackUnsubscribedStub func(livekit.ParticipantID, *livekit.TrackInfo, bool)
onTrackUnsubscribedMutex sync.RWMutex
onTrackUnsubscribedArgsForCall []struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
arg3 bool
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeParticipantTelemetryListener) OnTrackMaxSubscribedVideoQuality(arg1 livekit.ParticipantID, arg2 *livekit.TrackInfo, arg3 mime.MimeType, arg4 livekit.VideoQuality) {
fake.onTrackMaxSubscribedVideoQualityMutex.Lock()
fake.onTrackMaxSubscribedVideoQualityArgsForCall = append(fake.onTrackMaxSubscribedVideoQualityArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
arg3 mime.MimeType
arg4 livekit.VideoQuality
}{arg1, arg2, arg3, arg4})
stub := fake.OnTrackMaxSubscribedVideoQualityStub
fake.recordInvocation("OnTrackMaxSubscribedVideoQuality", []interface{}{arg1, arg2, arg3, arg4})
fake.onTrackMaxSubscribedVideoQualityMutex.Unlock()
if stub != nil {
fake.OnTrackMaxSubscribedVideoQualityStub(arg1, arg2, arg3, arg4)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackMaxSubscribedVideoQualityCallCount() int {
fake.onTrackMaxSubscribedVideoQualityMutex.RLock()
defer fake.onTrackMaxSubscribedVideoQualityMutex.RUnlock()
return len(fake.onTrackMaxSubscribedVideoQualityArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackMaxSubscribedVideoQualityCalls(stub func(livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality)) {
fake.onTrackMaxSubscribedVideoQualityMutex.Lock()
defer fake.onTrackMaxSubscribedVideoQualityMutex.Unlock()
fake.OnTrackMaxSubscribedVideoQualityStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackMaxSubscribedVideoQualityArgsForCall(i int) (livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality) {
fake.onTrackMaxSubscribedVideoQualityMutex.RLock()
defer fake.onTrackMaxSubscribedVideoQualityMutex.RUnlock()
argsForCall := fake.onTrackMaxSubscribedVideoQualityArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
}
func (fake *FakeParticipantTelemetryListener) OnTrackMuted(arg1 livekit.ParticipantID, arg2 *livekit.TrackInfo) {
fake.onTrackMutedMutex.Lock()
fake.onTrackMutedArgsForCall = append(fake.onTrackMutedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
}{arg1, arg2})
stub := fake.OnTrackMutedStub
fake.recordInvocation("OnTrackMuted", []interface{}{arg1, arg2})
fake.onTrackMutedMutex.Unlock()
if stub != nil {
fake.OnTrackMutedStub(arg1, arg2)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackMutedCallCount() int {
fake.onTrackMutedMutex.RLock()
defer fake.onTrackMutedMutex.RUnlock()
return len(fake.onTrackMutedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackMutedCalls(stub func(livekit.ParticipantID, *livekit.TrackInfo)) {
fake.onTrackMutedMutex.Lock()
defer fake.onTrackMutedMutex.Unlock()
fake.OnTrackMutedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackMutedArgsForCall(i int) (livekit.ParticipantID, *livekit.TrackInfo) {
fake.onTrackMutedMutex.RLock()
defer fake.onTrackMutedMutex.RUnlock()
argsForCall := fake.onTrackMutedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishRTPStats(arg1 livekit.ParticipantID, arg2 livekit.TrackID, arg3 mime.MimeType, arg4 int, arg5 *livekit.RTPStats) {
fake.onTrackPublishRTPStatsMutex.Lock()
fake.onTrackPublishRTPStatsArgsForCall = append(fake.onTrackPublishRTPStatsArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 livekit.TrackID
arg3 mime.MimeType
arg4 int
arg5 *livekit.RTPStats
}{arg1, arg2, arg3, arg4, arg5})
stub := fake.OnTrackPublishRTPStatsStub
fake.recordInvocation("OnTrackPublishRTPStats", []interface{}{arg1, arg2, arg3, arg4, arg5})
fake.onTrackPublishRTPStatsMutex.Unlock()
if stub != nil {
fake.OnTrackPublishRTPStatsStub(arg1, arg2, arg3, arg4, arg5)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishRTPStatsCallCount() int {
fake.onTrackPublishRTPStatsMutex.RLock()
defer fake.onTrackPublishRTPStatsMutex.RUnlock()
return len(fake.onTrackPublishRTPStatsArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishRTPStatsCalls(stub func(livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats)) {
fake.onTrackPublishRTPStatsMutex.Lock()
defer fake.onTrackPublishRTPStatsMutex.Unlock()
fake.OnTrackPublishRTPStatsStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishRTPStatsArgsForCall(i int) (livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats) {
fake.onTrackPublishRTPStatsMutex.RLock()
defer fake.onTrackPublishRTPStatsMutex.RUnlock()
argsForCall := fake.onTrackPublishRTPStatsArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishRequested(arg1 livekit.ParticipantID, arg2 livekit.ParticipantIdentity, arg3 *livekit.TrackInfo) {
fake.onTrackPublishRequestedMutex.Lock()
fake.onTrackPublishRequestedArgsForCall = append(fake.onTrackPublishRequestedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 livekit.ParticipantIdentity
arg3 *livekit.TrackInfo
}{arg1, arg2, arg3})
stub := fake.OnTrackPublishRequestedStub
fake.recordInvocation("OnTrackPublishRequested", []interface{}{arg1, arg2, arg3})
fake.onTrackPublishRequestedMutex.Unlock()
if stub != nil {
fake.OnTrackPublishRequestedStub(arg1, arg2, arg3)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishRequestedCallCount() int {
fake.onTrackPublishRequestedMutex.RLock()
defer fake.onTrackPublishRequestedMutex.RUnlock()
return len(fake.onTrackPublishRequestedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishRequestedCalls(stub func(livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)) {
fake.onTrackPublishRequestedMutex.Lock()
defer fake.onTrackPublishRequestedMutex.Unlock()
fake.OnTrackPublishRequestedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishRequestedArgsForCall(i int) (livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo) {
fake.onTrackPublishRequestedMutex.RLock()
defer fake.onTrackPublishRequestedMutex.RUnlock()
argsForCall := fake.onTrackPublishRequestedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublished(arg1 livekit.ParticipantID, arg2 livekit.ParticipantIdentity, arg3 *livekit.TrackInfo, arg4 bool) {
fake.onTrackPublishedMutex.Lock()
fake.onTrackPublishedArgsForCall = append(fake.onTrackPublishedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 livekit.ParticipantIdentity
arg3 *livekit.TrackInfo
arg4 bool
}{arg1, arg2, arg3, arg4})
stub := fake.OnTrackPublishedStub
fake.recordInvocation("OnTrackPublished", []interface{}{arg1, arg2, arg3, arg4})
fake.onTrackPublishedMutex.Unlock()
if stub != nil {
fake.OnTrackPublishedStub(arg1, arg2, arg3, arg4)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishedCallCount() int {
fake.onTrackPublishedMutex.RLock()
defer fake.onTrackPublishedMutex.RUnlock()
return len(fake.onTrackPublishedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishedCalls(stub func(livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)) {
fake.onTrackPublishedMutex.Lock()
defer fake.onTrackPublishedMutex.Unlock()
fake.OnTrackPublishedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishedArgsForCall(i int) (livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool) {
fake.onTrackPublishedMutex.RLock()
defer fake.onTrackPublishedMutex.RUnlock()
argsForCall := fake.onTrackPublishedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishedUpdate(arg1 livekit.ParticipantID, arg2 *livekit.TrackInfo) {
fake.onTrackPublishedUpdateMutex.Lock()
fake.onTrackPublishedUpdateArgsForCall = append(fake.onTrackPublishedUpdateArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
}{arg1, arg2})
stub := fake.OnTrackPublishedUpdateStub
fake.recordInvocation("OnTrackPublishedUpdate", []interface{}{arg1, arg2})
fake.onTrackPublishedUpdateMutex.Unlock()
if stub != nil {
fake.OnTrackPublishedUpdateStub(arg1, arg2)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishedUpdateCallCount() int {
fake.onTrackPublishedUpdateMutex.RLock()
defer fake.onTrackPublishedUpdateMutex.RUnlock()
return len(fake.onTrackPublishedUpdateArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishedUpdateCalls(stub func(livekit.ParticipantID, *livekit.TrackInfo)) {
fake.onTrackPublishedUpdateMutex.Lock()
defer fake.onTrackPublishedUpdateMutex.Unlock()
fake.OnTrackPublishedUpdateStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackPublishedUpdateArgsForCall(i int) (livekit.ParticipantID, *livekit.TrackInfo) {
fake.onTrackPublishedUpdateMutex.RLock()
defer fake.onTrackPublishedUpdateMutex.RUnlock()
argsForCall := fake.onTrackPublishedUpdateArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2
}
func (fake *FakeParticipantTelemetryListener) OnTrackStats(arg1 telemetry.StatsKey, arg2 *livekit.AnalyticsStat) {
fake.onTrackStatsMutex.Lock()
fake.onTrackStatsArgsForCall = append(fake.onTrackStatsArgsForCall, struct {
arg1 telemetry.StatsKey
arg2 *livekit.AnalyticsStat
}{arg1, arg2})
stub := fake.OnTrackStatsStub
fake.recordInvocation("OnTrackStats", []interface{}{arg1, arg2})
fake.onTrackStatsMutex.Unlock()
if stub != nil {
fake.OnTrackStatsStub(arg1, arg2)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackStatsCallCount() int {
fake.onTrackStatsMutex.RLock()
defer fake.onTrackStatsMutex.RUnlock()
return len(fake.onTrackStatsArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackStatsCalls(stub func(telemetry.StatsKey, *livekit.AnalyticsStat)) {
fake.onTrackStatsMutex.Lock()
defer fake.onTrackStatsMutex.Unlock()
fake.OnTrackStatsStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackStatsArgsForCall(i int) (telemetry.StatsKey, *livekit.AnalyticsStat) {
fake.onTrackStatsMutex.RLock()
defer fake.onTrackStatsMutex.RUnlock()
argsForCall := fake.onTrackStatsArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeFailed(arg1 livekit.ParticipantID, arg2 livekit.TrackID, arg3 error, arg4 bool) {
fake.onTrackSubscribeFailedMutex.Lock()
fake.onTrackSubscribeFailedArgsForCall = append(fake.onTrackSubscribeFailedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 livekit.TrackID
arg3 error
arg4 bool
}{arg1, arg2, arg3, arg4})
stub := fake.OnTrackSubscribeFailedStub
fake.recordInvocation("OnTrackSubscribeFailed", []interface{}{arg1, arg2, arg3, arg4})
fake.onTrackSubscribeFailedMutex.Unlock()
if stub != nil {
fake.OnTrackSubscribeFailedStub(arg1, arg2, arg3, arg4)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeFailedCallCount() int {
fake.onTrackSubscribeFailedMutex.RLock()
defer fake.onTrackSubscribeFailedMutex.RUnlock()
return len(fake.onTrackSubscribeFailedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeFailedCalls(stub func(livekit.ParticipantID, livekit.TrackID, error, bool)) {
fake.onTrackSubscribeFailedMutex.Lock()
defer fake.onTrackSubscribeFailedMutex.Unlock()
fake.OnTrackSubscribeFailedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeFailedArgsForCall(i int) (livekit.ParticipantID, livekit.TrackID, error, bool) {
fake.onTrackSubscribeFailedMutex.RLock()
defer fake.onTrackSubscribeFailedMutex.RUnlock()
argsForCall := fake.onTrackSubscribeFailedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeRTPStats(arg1 livekit.ParticipantID, arg2 livekit.TrackID, arg3 mime.MimeType, arg4 *livekit.RTPStats) {
fake.onTrackSubscribeRTPStatsMutex.Lock()
fake.onTrackSubscribeRTPStatsArgsForCall = append(fake.onTrackSubscribeRTPStatsArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 livekit.TrackID
arg3 mime.MimeType
arg4 *livekit.RTPStats
}{arg1, arg2, arg3, arg4})
stub := fake.OnTrackSubscribeRTPStatsStub
fake.recordInvocation("OnTrackSubscribeRTPStats", []interface{}{arg1, arg2, arg3, arg4})
fake.onTrackSubscribeRTPStatsMutex.Unlock()
if stub != nil {
fake.OnTrackSubscribeRTPStatsStub(arg1, arg2, arg3, arg4)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeRTPStatsCallCount() int {
fake.onTrackSubscribeRTPStatsMutex.RLock()
defer fake.onTrackSubscribeRTPStatsMutex.RUnlock()
return len(fake.onTrackSubscribeRTPStatsArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeRTPStatsCalls(stub func(livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats)) {
fake.onTrackSubscribeRTPStatsMutex.Lock()
defer fake.onTrackSubscribeRTPStatsMutex.Unlock()
fake.OnTrackSubscribeRTPStatsStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeRTPStatsArgsForCall(i int) (livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats) {
fake.onTrackSubscribeRTPStatsMutex.RLock()
defer fake.onTrackSubscribeRTPStatsMutex.RUnlock()
argsForCall := fake.onTrackSubscribeRTPStatsArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeRequested(arg1 livekit.ParticipantID, arg2 *livekit.TrackInfo) {
fake.onTrackSubscribeRequestedMutex.Lock()
fake.onTrackSubscribeRequestedArgsForCall = append(fake.onTrackSubscribeRequestedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
}{arg1, arg2})
stub := fake.OnTrackSubscribeRequestedStub
fake.recordInvocation("OnTrackSubscribeRequested", []interface{}{arg1, arg2})
fake.onTrackSubscribeRequestedMutex.Unlock()
if stub != nil {
fake.OnTrackSubscribeRequestedStub(arg1, arg2)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeRequestedCallCount() int {
fake.onTrackSubscribeRequestedMutex.RLock()
defer fake.onTrackSubscribeRequestedMutex.RUnlock()
return len(fake.onTrackSubscribeRequestedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeRequestedCalls(stub func(livekit.ParticipantID, *livekit.TrackInfo)) {
fake.onTrackSubscribeRequestedMutex.Lock()
defer fake.onTrackSubscribeRequestedMutex.Unlock()
fake.OnTrackSubscribeRequestedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribeRequestedArgsForCall(i int) (livekit.ParticipantID, *livekit.TrackInfo) {
fake.onTrackSubscribeRequestedMutex.RLock()
defer fake.onTrackSubscribeRequestedMutex.RUnlock()
argsForCall := fake.onTrackSubscribeRequestedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribed(arg1 livekit.ParticipantID, arg2 *livekit.TrackInfo, arg3 *livekit.ParticipantInfo, arg4 bool) {
fake.onTrackSubscribedMutex.Lock()
fake.onTrackSubscribedArgsForCall = append(fake.onTrackSubscribedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
arg3 *livekit.ParticipantInfo
arg4 bool
}{arg1, arg2, arg3, arg4})
stub := fake.OnTrackSubscribedStub
fake.recordInvocation("OnTrackSubscribed", []interface{}{arg1, arg2, arg3, arg4})
fake.onTrackSubscribedMutex.Unlock()
if stub != nil {
fake.OnTrackSubscribedStub(arg1, arg2, arg3, arg4)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribedCallCount() int {
fake.onTrackSubscribedMutex.RLock()
defer fake.onTrackSubscribedMutex.RUnlock()
return len(fake.onTrackSubscribedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribedCalls(stub func(livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool)) {
fake.onTrackSubscribedMutex.Lock()
defer fake.onTrackSubscribedMutex.Unlock()
fake.OnTrackSubscribedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackSubscribedArgsForCall(i int) (livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool) {
fake.onTrackSubscribedMutex.RLock()
defer fake.onTrackSubscribedMutex.RUnlock()
argsForCall := fake.onTrackSubscribedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnmuted(arg1 livekit.ParticipantID, arg2 *livekit.TrackInfo) {
fake.onTrackUnmutedMutex.Lock()
fake.onTrackUnmutedArgsForCall = append(fake.onTrackUnmutedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
}{arg1, arg2})
stub := fake.OnTrackUnmutedStub
fake.recordInvocation("OnTrackUnmuted", []interface{}{arg1, arg2})
fake.onTrackUnmutedMutex.Unlock()
if stub != nil {
fake.OnTrackUnmutedStub(arg1, arg2)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnmutedCallCount() int {
fake.onTrackUnmutedMutex.RLock()
defer fake.onTrackUnmutedMutex.RUnlock()
return len(fake.onTrackUnmutedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnmutedCalls(stub func(livekit.ParticipantID, *livekit.TrackInfo)) {
fake.onTrackUnmutedMutex.Lock()
defer fake.onTrackUnmutedMutex.Unlock()
fake.OnTrackUnmutedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnmutedArgsForCall(i int) (livekit.ParticipantID, *livekit.TrackInfo) {
fake.onTrackUnmutedMutex.RLock()
defer fake.onTrackUnmutedMutex.RUnlock()
argsForCall := fake.onTrackUnmutedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnpublished(arg1 livekit.ParticipantID, arg2 livekit.ParticipantIdentity, arg3 *livekit.TrackInfo, arg4 bool) {
fake.onTrackUnpublishedMutex.Lock()
fake.onTrackUnpublishedArgsForCall = append(fake.onTrackUnpublishedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 livekit.ParticipantIdentity
arg3 *livekit.TrackInfo
arg4 bool
}{arg1, arg2, arg3, arg4})
stub := fake.OnTrackUnpublishedStub
fake.recordInvocation("OnTrackUnpublished", []interface{}{arg1, arg2, arg3, arg4})
fake.onTrackUnpublishedMutex.Unlock()
if stub != nil {
fake.OnTrackUnpublishedStub(arg1, arg2, arg3, arg4)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnpublishedCallCount() int {
fake.onTrackUnpublishedMutex.RLock()
defer fake.onTrackUnpublishedMutex.RUnlock()
return len(fake.onTrackUnpublishedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnpublishedCalls(stub func(livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)) {
fake.onTrackUnpublishedMutex.Lock()
defer fake.onTrackUnpublishedMutex.Unlock()
fake.OnTrackUnpublishedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnpublishedArgsForCall(i int) (livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool) {
fake.onTrackUnpublishedMutex.RLock()
defer fake.onTrackUnpublishedMutex.RUnlock()
argsForCall := fake.onTrackUnpublishedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnsubscribed(arg1 livekit.ParticipantID, arg2 *livekit.TrackInfo, arg3 bool) {
fake.onTrackUnsubscribedMutex.Lock()
fake.onTrackUnsubscribedArgsForCall = append(fake.onTrackUnsubscribedArgsForCall, struct {
arg1 livekit.ParticipantID
arg2 *livekit.TrackInfo
arg3 bool
}{arg1, arg2, arg3})
stub := fake.OnTrackUnsubscribedStub
fake.recordInvocation("OnTrackUnsubscribed", []interface{}{arg1, arg2, arg3})
fake.onTrackUnsubscribedMutex.Unlock()
if stub != nil {
fake.OnTrackUnsubscribedStub(arg1, arg2, arg3)
}
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnsubscribedCallCount() int {
fake.onTrackUnsubscribedMutex.RLock()
defer fake.onTrackUnsubscribedMutex.RUnlock()
return len(fake.onTrackUnsubscribedArgsForCall)
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnsubscribedCalls(stub func(livekit.ParticipantID, *livekit.TrackInfo, bool)) {
fake.onTrackUnsubscribedMutex.Lock()
defer fake.onTrackUnsubscribedMutex.Unlock()
fake.OnTrackUnsubscribedStub = stub
}
func (fake *FakeParticipantTelemetryListener) OnTrackUnsubscribedArgsForCall(i int) (livekit.ParticipantID, *livekit.TrackInfo, bool) {
fake.onTrackUnsubscribedMutex.RLock()
defer fake.onTrackUnsubscribedMutex.RUnlock()
argsForCall := fake.onTrackUnsubscribedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
}
func (fake *FakeParticipantTelemetryListener) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
for key, value := range fake.invocations {
copiedInvocations[key] = value
}
return copiedInvocations
}
func (fake *FakeParticipantTelemetryListener) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ types.ParticipantTelemetryListener = new(FakeParticipantTelemetryListener)
+1 -1
View File
@@ -469,7 +469,7 @@ func (r *RoomManager) StartSession(
LimitConfig: r.config.Limit, LimitConfig: r.config.Limit,
ProtocolVersion: pv, ProtocolVersion: pv,
SessionStartTime: sessionStartTime, SessionStartTime: sessionStartTime,
Telemetry: r.telemetry, TelemetryListener: room.ParticipantTelemetryListener(),
Trailer: room.Trailer(), Trailer: room.Trailer(),
PLIThrottleConfig: r.config.RTC.PLIThrottle, PLIThrottleConfig: r.config.RTC.PLIThrottle,
CongestionControlConfig: r.config.RTC.CongestionControl, CongestionControlConfig: r.config.RTC.CongestionControl,
+1 -1
View File
@@ -382,7 +382,7 @@ func (s *RTCService) serve(w http.ResponseWriter, r *http.Request, needsJoinRequ
resolveLogger(false) resolveLogger(false)
} }
signalStats := telemetry.NewBytesSignalStats(r.Context(), s.telemetry) signalStats := rtc.NewBytesSignalStats(r.Context(), s.telemetry)
if join := initialResponse.GetJoin(); join != nil { if join := initialResponse.GetJoin(); join != nil {
signalStats.ResolveRoom(join.GetRoom()) signalStats.ResolveRoom(join.GetRoom())
signalStats.ResolveParticipant(join.GetParticipant()) signalStats.ResolveParticipant(join.GetParticipant())
+52 -28
View File
@@ -188,7 +188,7 @@ func (t *telemetryService) ParticipantLeft(ctx context.Context,
) { ) {
t.enqueue(func() { t.enqueue(func() {
isConnected := false isConnected := false
if worker, ok := t.getWorker(livekit.ParticipantID(participant.Sid)); ok { if worker, ok := t.getWorker(livekit.RoomID(room.Sid), livekit.ParticipantID(participant.Sid)); ok {
isConnected = worker.IsConnected() isConnected = worker.IsConnected()
if worker.Close(guard) { if worker.Close(guard) {
prometheus.SubParticipant() prometheus.SubParticipant()
@@ -224,13 +224,15 @@ func (t *telemetryService) ParticipantLeft(ctx context.Context,
func (t *telemetryService) TrackPublishRequested( func (t *telemetryService) TrackPublishRequested(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
identity livekit.ParticipantIdentity, identity livekit.ParticipantIdentity,
track *livekit.TrackInfo, track *livekit.TrackInfo,
) { ) {
t.enqueue(func() { t.enqueue(func() {
prometheus.RecordTrackPublishAttempt(track.Type.String()) prometheus.RecordTrackPublishAttempt(track.Type.String())
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_PUBLISH_REQUESTED, room, participantID, track) ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_PUBLISH_REQUESTED, room, participantID, track)
if ev.Participant != nil { if ev.Participant != nil {
ev.Participant.Identity = string(identity) ev.Participant.Identity = string(identity)
@@ -241,6 +243,8 @@ func (t *telemetryService) TrackPublishRequested(
func (t *telemetryService) TrackPublished( func (t *telemetryService) TrackPublished(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
identity livekit.ParticipantIdentity, identity livekit.ParticipantIdentity,
track *livekit.TrackInfo, track *livekit.TrackInfo,
@@ -253,7 +257,7 @@ func (t *telemetryService) TrackPublished(
return return
} }
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
participant := &livekit.ParticipantInfo{ participant := &livekit.ParticipantInfo{
Sid: string(participantID), Sid: string(participantID),
Identity: string(identity), Identity: string(identity),
@@ -271,22 +275,30 @@ func (t *telemetryService) TrackPublished(
}) })
} }
func (t *telemetryService) TrackPublishedUpdate(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) { func (t *telemetryService) TrackPublishedUpdate(
ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID,
track *livekit.TrackInfo,
) {
t.enqueue(func() { t.enqueue(func() {
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
t.SendEvent(ctx, newTrackEvent(livekit.AnalyticsEventType_TRACK_PUBLISHED_UPDATE, room, participantID, track)) t.SendEvent(ctx, newTrackEvent(livekit.AnalyticsEventType_TRACK_PUBLISHED_UPDATE, room, participantID, track))
}) })
} }
func (t *telemetryService) TrackMaxSubscribedVideoQuality( func (t *telemetryService) TrackMaxSubscribedVideoQuality(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
track *livekit.TrackInfo, track *livekit.TrackInfo,
mime mime.MimeType, mime mime.MimeType,
maxQuality livekit.VideoQuality, maxQuality livekit.VideoQuality,
) { ) {
t.enqueue(func() { t.enqueue(func() {
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_MAX_SUBSCRIBED_VIDEO_QUALITY, room, participantID, track) ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_MAX_SUBSCRIBED_VIDEO_QUALITY, room, participantID, track)
ev.MaxSubscribedVideoQuality = maxQuality ev.MaxSubscribedVideoQuality = maxQuality
ev.Mime = mime.String() ev.Mime = mime.String()
@@ -296,13 +308,15 @@ func (t *telemetryService) TrackMaxSubscribedVideoQuality(
func (t *telemetryService) TrackSubscribeRequested( func (t *telemetryService) TrackSubscribeRequested(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
track *livekit.TrackInfo, track *livekit.TrackInfo,
) { ) {
t.enqueue(func() { t.enqueue(func() {
prometheus.RecordTrackSubscribeAttempt() prometheus.RecordTrackSubscribeAttempt()
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_SUBSCRIBE_REQUESTED, room, participantID, track) ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_SUBSCRIBE_REQUESTED, room, participantID, track)
t.SendEvent(ctx, ev) t.SendEvent(ctx, ev)
}) })
@@ -310,6 +324,8 @@ func (t *telemetryService) TrackSubscribeRequested(
func (t *telemetryService) TrackSubscribed( func (t *telemetryService) TrackSubscribed(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
track *livekit.TrackInfo, track *livekit.TrackInfo,
publisher *livekit.ParticipantInfo, publisher *livekit.ParticipantInfo,
@@ -322,7 +338,7 @@ func (t *telemetryService) TrackSubscribed(
return return
} }
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_SUBSCRIBED, room, participantID, track) ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_SUBSCRIBED, room, participantID, track)
ev.Publisher = publisher ev.Publisher = publisher
t.SendEvent(ctx, ev) t.SendEvent(ctx, ev)
@@ -331,6 +347,8 @@ func (t *telemetryService) TrackSubscribed(
func (t *telemetryService) TrackSubscribeFailed( func (t *telemetryService) TrackSubscribeFailed(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
trackID livekit.TrackID, trackID livekit.TrackID,
err error, err error,
@@ -339,7 +357,7 @@ func (t *telemetryService) TrackSubscribeFailed(
t.enqueue(func() { t.enqueue(func() {
prometheus.RecordTrackSubscribeFailure(err, isUserError) prometheus.RecordTrackSubscribeFailure(err, isUserError)
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_SUBSCRIBE_FAILED, room, participantID, &livekit.TrackInfo{ ev := newTrackEvent(livekit.AnalyticsEventType_TRACK_SUBSCRIBE_FAILED, room, participantID, &livekit.TrackInfo{
Sid: string(trackID), Sid: string(trackID),
}) })
@@ -350,6 +368,8 @@ func (t *telemetryService) TrackSubscribeFailed(
func (t *telemetryService) TrackUnsubscribed( func (t *telemetryService) TrackUnsubscribed(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
track *livekit.TrackInfo, track *livekit.TrackInfo,
shouldSendEvent bool, shouldSendEvent bool,
@@ -358,7 +378,7 @@ func (t *telemetryService) TrackUnsubscribed(
prometheus.RecordTrackUnsubscribed(track.Type.String()) prometheus.RecordTrackUnsubscribed(track.Type.String())
if shouldSendEvent { if shouldSendEvent {
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
t.SendEvent(ctx, newTrackEvent(livekit.AnalyticsEventType_TRACK_UNSUBSCRIBED, room, participantID, track)) t.SendEvent(ctx, newTrackEvent(livekit.AnalyticsEventType_TRACK_UNSUBSCRIBED, room, participantID, track))
} }
}) })
@@ -366,6 +386,8 @@ func (t *telemetryService) TrackUnsubscribed(
func (t *telemetryService) TrackUnpublished( func (t *telemetryService) TrackUnpublished(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
identity livekit.ParticipantIdentity, identity livekit.ParticipantIdentity,
track *livekit.TrackInfo, track *livekit.TrackInfo,
@@ -377,7 +399,7 @@ func (t *telemetryService) TrackUnpublished(
return return
} }
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
participant := &livekit.ParticipantInfo{ participant := &livekit.ParticipantInfo{
Sid: string(participantID), Sid: string(participantID),
Identity: string(identity), Identity: string(identity),
@@ -395,28 +417,34 @@ func (t *telemetryService) TrackUnpublished(
func (t *telemetryService) TrackMuted( func (t *telemetryService) TrackMuted(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
track *livekit.TrackInfo, track *livekit.TrackInfo,
) { ) {
t.enqueue(func() { t.enqueue(func() {
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
t.SendEvent(ctx, newTrackEvent(livekit.AnalyticsEventType_TRACK_MUTED, room, participantID, track)) t.SendEvent(ctx, newTrackEvent(livekit.AnalyticsEventType_TRACK_MUTED, room, participantID, track))
}) })
} }
func (t *telemetryService) TrackUnmuted( func (t *telemetryService) TrackUnmuted(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
track *livekit.TrackInfo, track *livekit.TrackInfo,
) { ) {
t.enqueue(func() { t.enqueue(func() {
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
t.SendEvent(ctx, newTrackEvent(livekit.AnalyticsEventType_TRACK_UNMUTED, room, participantID, track)) t.SendEvent(ctx, newTrackEvent(livekit.AnalyticsEventType_TRACK_UNMUTED, room, participantID, track))
}) })
} }
func (t *telemetryService) TrackPublishRTPStats( func (t *telemetryService) TrackPublishRTPStats(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
trackID livekit.TrackID, trackID livekit.TrackID,
mimeType mime.MimeType, mimeType mime.MimeType,
@@ -424,7 +452,7 @@ func (t *telemetryService) TrackPublishRTPStats(
stats *livekit.RTPStats, stats *livekit.RTPStats,
) { ) {
t.enqueue(func() { t.enqueue(func() {
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
ev := newRoomEvent(livekit.AnalyticsEventType_TRACK_PUBLISH_STATS, room) ev := newRoomEvent(livekit.AnalyticsEventType_TRACK_PUBLISH_STATS, room)
ev.ParticipantId = string(participantID) ev.ParticipantId = string(participantID)
ev.TrackId = string(trackID) ev.TrackId = string(trackID)
@@ -437,13 +465,15 @@ func (t *telemetryService) TrackPublishRTPStats(
func (t *telemetryService) TrackSubscribeRTPStats( func (t *telemetryService) TrackSubscribeRTPStats(
ctx context.Context, ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
participantID livekit.ParticipantID, participantID livekit.ParticipantID,
trackID livekit.TrackID, trackID livekit.TrackID,
mimeType mime.MimeType, mimeType mime.MimeType,
stats *livekit.RTPStats, stats *livekit.RTPStats,
) { ) {
t.enqueue(func() { t.enqueue(func() {
room := t.getRoomDetails(participantID) room := toMinimalRoomProto(roomID, roomName)
ev := newRoomEvent(livekit.AnalyticsEventType_TRACK_SUBSCRIBE_STATS, room) ev := newRoomEvent(livekit.AnalyticsEventType_TRACK_SUBSCRIBE_STATS, room)
ev.ParticipantId = string(participantID) ev.ParticipantId = string(participantID)
ev.TrackId = string(trackID) ev.TrackId = string(trackID)
@@ -560,19 +590,6 @@ func (t *telemetryService) Webhook(ctx context.Context, webhookInfo *livekit.Web
}) })
} }
// returns a livekit.Room with only name and sid filled out
// returns nil if room is not found
func (t *telemetryService) getRoomDetails(participantID livekit.ParticipantID) *livekit.Room {
if worker, ok := t.getWorker(participantID); ok {
return &livekit.Room{
Sid: string(worker.roomID),
Name: string(worker.roomName),
}
}
return nil
}
func newRoomEvent(event livekit.AnalyticsEventType, room *livekit.Room) *livekit.AnalyticsEvent { func newRoomEvent(event livekit.AnalyticsEventType, room *livekit.Room) *livekit.AnalyticsEvent {
ev := &livekit.AnalyticsEvent{ ev := &livekit.AnalyticsEvent{
Type: event, Type: event,
@@ -623,3 +640,10 @@ func newIngressEvent(event livekit.AnalyticsEventType, ingress *livekit.IngressI
Ingress: ingress, Ingress: ingress,
} }
} }
func toMinimalRoomProto(roomID livekit.RoomID, roomName livekit.RoomName) *livekit.Room {
return &livekit.Room{
Sid: string(roomID),
Name: string(roomName),
}
}
+4 -2
View File
@@ -103,6 +103,8 @@ func Test_OnTrackUpdate_EventIsSent(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
roomID := "room1"
roomName := "RoomName"
partID := "part1" partID := "part1"
trackID := "track1" trackID := "track1"
layer := &livekit.VideoLayer{ layer := &livekit.VideoLayer{
@@ -122,7 +124,7 @@ func Test_OnTrackUpdate_EventIsSent(t *testing.T) {
} }
// do // do
fixture.sut.TrackPublishedUpdate(context.Background(), livekit.ParticipantID(partID), trackInfo) fixture.sut.TrackPublishedUpdate(context.Background(), livekit.RoomID(roomID), livekit.RoomName(roomName), livekit.ParticipantID(partID), trackInfo)
time.Sleep(time.Millisecond * 500) time.Sleep(time.Millisecond * 500)
// test // test
@@ -226,7 +228,7 @@ func Test_OnTrackSubscribed_EventIsSent(t *testing.T) {
require.Equal(t, room, event.Room) require.Equal(t, room, event.Room)
// do // do
fixture.sut.TrackSubscribed(context.Background(), livekit.ParticipantID(partSID), trackInfo, publisherInfo, true) fixture.sut.TrackSubscribed(context.Background(), livekit.RoomID(room.Sid), livekit.RoomName(room.Name), livekit.ParticipantID(partSID), trackInfo, publisherInfo, true)
time.Sleep(time.Millisecond * 500) time.Sleep(time.Millisecond * 500)
require.Eventually(t, func() bool { require.Eventually(t, func() bool {
+2 -2
View File
@@ -62,7 +62,7 @@ func StatsKeyForData(
} }
} }
func (t *telemetryService) TrackStats(key StatsKey, stat *livekit.AnalyticsStat) { func (t *telemetryService) TrackStats(roomID livekit.RoomID, _roomName livekit.RoomName, key StatsKey, stat *livekit.AnalyticsStat) {
t.enqueue(func() { t.enqueue(func() {
direction := prometheus.Incoming direction := prometheus.Incoming
if key.streamType == livekit.StreamType_DOWNSTREAM { if key.streamType == livekit.StreamType_DOWNSTREAM {
@@ -107,7 +107,7 @@ func (t *telemetryService) TrackStats(key StatsKey, stat *livekit.AnalyticsStat)
prometheus.IncrementBytes(key.country, direction, retransmitBytes, true) prometheus.IncrementBytes(key.country, direction, retransmitBytes, true)
} }
if worker, ok := t.getWorker(key.participantID); ok { if worker, ok := t.getWorker(roomID, key.participantID); ok {
worker.OnTrackStat(key.trackID, key.streamType, stat) worker.OnTrackStat(key.trackID, key.streamType, stat)
} }
}) })
+32 -32
View File
@@ -58,7 +58,7 @@ func Test_ParticipantAndRoomDataAreSentWithAnalytics(t *testing.T) {
// do // do
packet := 33 packet := 33
stat := &livekit.AnalyticsStat{Streams: []*livekit.AnalyticsStream{{PrimaryBytes: uint64(packet)}}} stat := &livekit.AnalyticsStat{Streams: []*livekit.AnalyticsStream{{PrimaryBytes: uint64(packet)}}}
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, ""), stat) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, ""), stat)
// flush // flush
fixture.flush() fixture.flush()
@@ -77,7 +77,7 @@ func Test_OnDownstreamPackets(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
clientInfo := &livekit.ClientInfo{Sdk: 2} clientInfo := &livekit.ClientInfo{Sdk: 2}
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
@@ -91,7 +91,7 @@ func Test_OnDownstreamPackets(t *testing.T) {
trackID := livekit.TrackID("trackID") trackID := livekit.TrackID("trackID")
for i := range packets { for i := range packets {
stat := &livekit.AnalyticsStat{Streams: []*livekit.AnalyticsStream{{PrimaryBytes: uint64(packets[i]), PrimaryPackets: uint32(1)}}} stat := &livekit.AnalyticsStat{Streams: []*livekit.AnalyticsStream{{PrimaryBytes: uint64(packets[i]), PrimaryPackets: uint32(1)}}}
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat)
} }
// flush // flush
@@ -111,7 +111,7 @@ func Test_OnDownstreamPackets_SeveralTracks(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
clientInfo := &livekit.ClientInfo{Sdk: 2} clientInfo := &livekit.ClientInfo{Sdk: 2}
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
@@ -122,12 +122,12 @@ func Test_OnDownstreamPackets_SeveralTracks(t *testing.T) {
packet1 := 33 packet1 := 33
trackID1 := livekit.TrackID("trackID1") trackID1 := livekit.TrackID("trackID1")
stat1 := &livekit.AnalyticsStat{Streams: []*livekit.AnalyticsStream{{PrimaryBytes: uint64(packet1), PrimaryPackets: 1}}} stat1 := &livekit.AnalyticsStat{Streams: []*livekit.AnalyticsStream{{PrimaryBytes: uint64(packet1), PrimaryPackets: 1}}}
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID1), stat1) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID1), stat1)
packet2 := 23 packet2 := 23
trackID2 := livekit.TrackID("trackID2") trackID2 := livekit.TrackID("trackID2")
stat2 := &livekit.AnalyticsStat{Streams: []*livekit.AnalyticsStream{{PrimaryBytes: uint64(packet2), PrimaryPackets: 1}}} stat2 := &livekit.AnalyticsStat{Streams: []*livekit.AnalyticsStream{{PrimaryBytes: uint64(packet2), PrimaryPackets: 1}}}
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID2), stat2) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID2), stat2)
// flush // flush
fixture.flush() fixture.flush()
@@ -158,7 +158,7 @@ func Test_OnDownStreamStat(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
guard := &telemetry.ReferenceGuard{} guard := &telemetry.ReferenceGuard{}
@@ -179,7 +179,7 @@ func Test_OnDownStreamStat(t *testing.T) {
}, },
} }
trackID := livekit.TrackID("trackID1") trackID := livekit.TrackID("trackID1")
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat1) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat1)
stat2 := &livekit.AnalyticsStat{ stat2 := &livekit.AnalyticsStat{
Streams: []*livekit.AnalyticsStream{ Streams: []*livekit.AnalyticsStream{
@@ -195,7 +195,7 @@ func Test_OnDownStreamStat(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat2) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat2)
// flush // flush
fixture.flush() fixture.flush()
@@ -218,7 +218,7 @@ func Test_PacketLostDiffShouldBeSentToTelemetry(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
guard := &telemetry.ReferenceGuard{} guard := &telemetry.ReferenceGuard{}
@@ -235,7 +235,7 @@ func Test_PacketLostDiffShouldBeSentToTelemetry(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat1) // there should be bytes reported so that stats are sent fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat1) // there should be bytes reported so that stats are sent
// flush // flush
fixture.flush() fixture.flush()
@@ -249,7 +249,7 @@ func Test_PacketLostDiffShouldBeSentToTelemetry(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat2) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID), stat2)
// flush // flush
fixture.flush() fixture.flush()
@@ -271,7 +271,7 @@ func Test_OnDownStreamRTCP_SeveralTracks(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
guard := &telemetry.ReferenceGuard{} guard := &telemetry.ReferenceGuard{}
@@ -288,7 +288,7 @@ func Test_OnDownStreamRTCP_SeveralTracks(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID1), stat1) // there should be bytes reported so that stats are sent fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID1), stat1) // there should be bytes reported so that stats are sent
stat2 := &livekit.AnalyticsStat{ stat2 := &livekit.AnalyticsStat{
Streams: []*livekit.AnalyticsStream{ Streams: []*livekit.AnalyticsStream{
@@ -299,7 +299,7 @@ func Test_OnDownStreamRTCP_SeveralTracks(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID1), stat2) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID1), stat2)
stat3 := &livekit.AnalyticsStat{ stat3 := &livekit.AnalyticsStat{
Streams: []*livekit.AnalyticsStream{ Streams: []*livekit.AnalyticsStream{
@@ -310,7 +310,7 @@ func Test_OnDownStreamRTCP_SeveralTracks(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID2), stat3) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, trackID2), stat3)
// flush // flush
fixture.flush() fixture.flush()
@@ -341,7 +341,7 @@ func Test_OnUpstreamStat(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
guard := &telemetry.ReferenceGuard{} guard := &telemetry.ReferenceGuard{}
@@ -364,7 +364,7 @@ func Test_OnUpstreamStat(t *testing.T) {
} }
trackID := livekit.TrackID("trackID") trackID := livekit.TrackID("trackID")
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID), stat1) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID), stat1)
stat2 := &livekit.AnalyticsStat{ stat2 := &livekit.AnalyticsStat{
Streams: []*livekit.AnalyticsStream{ Streams: []*livekit.AnalyticsStream{
@@ -380,7 +380,7 @@ func Test_OnUpstreamStat(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID), stat2) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID), stat2)
// flush // flush
fixture.flush() fixture.flush()
@@ -403,7 +403,7 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
identity := livekit.ParticipantIdentity("part1Identity") identity := livekit.ParticipantIdentity("part1Identity")
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID), Identity: string(identity)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID), Identity: string(identity)}
@@ -424,8 +424,8 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID1), stat1) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID1), stat1)
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID2), stat1) // using same buffer is not correct but for test it is fine fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID2), stat1) // using same buffer is not correct but for test it is fine
// do // do
totalBytes++ totalBytes++
@@ -439,7 +439,7 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID1), stat2) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID1), stat2)
stat3 := &livekit.AnalyticsStat{ stat3 := &livekit.AnalyticsStat{
Streams: []*livekit.AnalyticsStream{ Streams: []*livekit.AnalyticsStream{
@@ -450,7 +450,7 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID2), stat3) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID2), stat3)
// flush // flush
fixture.flush() fixture.flush()
@@ -479,7 +479,7 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) {
require.True(t, found2) require.True(t, found2)
// remove 1 track - track stats were flushed above, so no more calls to SendStats // remove 1 track - track stats were flushed above, so no more calls to SendStats
fixture.sut.TrackUnpublished(context.Background(), partSID, identity, &livekit.TrackInfo{Sid: string(trackID2)}, true) fixture.sut.TrackUnpublished(context.Background(), livekit.RoomID(room.Sid), livekit.RoomName(room.Name), partSID, identity, &livekit.TrackInfo{Sid: string(trackID2)}, true)
// flush // flush
fixture.flush() fixture.flush()
@@ -509,7 +509,7 @@ func Test_AddUpTrack(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
guard := &telemetry.ReferenceGuard{} guard := &telemetry.ReferenceGuard{}
@@ -528,7 +528,7 @@ func Test_AddUpTrack(t *testing.T) {
}, },
} }
trackID := livekit.TrackID("trackID") trackID := livekit.TrackID("trackID")
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID), stat) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID), stat)
// flush // flush
fixture.flush() fixture.flush()
@@ -547,7 +547,7 @@ func Test_AddUpTrack_SeveralBuffers_Simulcast(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
guard := &telemetry.ReferenceGuard{} guard := &telemetry.ReferenceGuard{}
@@ -567,7 +567,7 @@ func Test_AddUpTrack_SeveralBuffers_Simulcast(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID), stat1) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, trackID), stat1)
// flush // flush
fixture.flush() fixture.flush()
@@ -587,7 +587,7 @@ func Test_BothDownstreamAndUpstreamStatsAreSentTogether(t *testing.T) {
fixture := createFixture() fixture := createFixture()
// prepare // prepare
room := &livekit.Room{} room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"}
partSID := livekit.ParticipantID("part1") partSID := livekit.ParticipantID("part1")
participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)}
guard := &telemetry.ReferenceGuard{} guard := &telemetry.ReferenceGuard{}
@@ -603,7 +603,7 @@ func Test_BothDownstreamAndUpstreamStatsAreSentTogether(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, "trackID"), stat1) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_UPSTREAM, partSID, "trackID"), stat1)
// downstream bytes // downstream bytes
stat2 := &livekit.AnalyticsStat{ stat2 := &livekit.AnalyticsStat{
Streams: []*livekit.AnalyticsStream{ Streams: []*livekit.AnalyticsStream{
@@ -613,7 +613,7 @@ func Test_BothDownstreamAndUpstreamStatsAreSentTogether(t *testing.T) {
}, },
}, },
} }
fixture.sut.TrackStats(telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, "trackID1"), stat2) fixture.sut.TrackStats(livekit.RoomID(room.Sid), livekit.RoomName(room.Name), telemetry.StatsKeyForData("test", livekit.StreamType_DOWNSTREAM, partSID, "trackID1"), stat2)
// flush // flush
fixture.flush() fixture.flush()
@@ -169,119 +169,147 @@ type FakeTelemetryService struct {
arg1 context.Context arg1 context.Context
arg2 []*livekit.AnalyticsStat arg2 []*livekit.AnalyticsStat
} }
TrackMaxSubscribedVideoQualityStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality) TrackMaxSubscribedVideoQualityStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality)
trackMaxSubscribedVideoQualityMutex sync.RWMutex trackMaxSubscribedVideoQualityMutex sync.RWMutex
trackMaxSubscribedVideoQualityArgsForCall []struct { trackMaxSubscribedVideoQualityArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 mime.MimeType arg4 livekit.ParticipantID
arg5 livekit.VideoQuality arg5 *livekit.TrackInfo
arg6 mime.MimeType
arg7 livekit.VideoQuality
} }
TrackMutedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo) TrackMutedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo)
trackMutedMutex sync.RWMutex trackMutedMutex sync.RWMutex
trackMutedArgsForCall []struct { trackMutedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
} }
TrackPublishRTPStatsStub func(context.Context, livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats) TrackPublishRTPStatsStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats)
trackPublishRTPStatsMutex sync.RWMutex trackPublishRTPStatsMutex sync.RWMutex
trackPublishRTPStatsArgsForCall []struct { trackPublishRTPStatsArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.TrackID arg3 livekit.RoomName
arg4 mime.MimeType arg4 livekit.ParticipantID
arg5 int arg5 livekit.TrackID
arg6 *livekit.RTPStats arg6 mime.MimeType
arg7 int
arg8 *livekit.RTPStats
} }
TrackPublishRequestedStub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo) TrackPublishRequestedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)
trackPublishRequestedMutex sync.RWMutex trackPublishRequestedMutex sync.RWMutex
trackPublishRequestedArgsForCall []struct { trackPublishRequestedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.ParticipantIdentity arg3 livekit.RoomName
arg4 *livekit.TrackInfo arg4 livekit.ParticipantID
arg5 livekit.ParticipantIdentity
arg6 *livekit.TrackInfo
} }
TrackPublishedStub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool) TrackPublishedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)
trackPublishedMutex sync.RWMutex trackPublishedMutex sync.RWMutex
trackPublishedArgsForCall []struct { trackPublishedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.ParticipantIdentity arg3 livekit.RoomName
arg4 *livekit.TrackInfo arg4 livekit.ParticipantID
arg5 bool arg5 livekit.ParticipantIdentity
arg6 *livekit.TrackInfo
arg7 bool
} }
TrackPublishedUpdateStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo) TrackPublishedUpdateStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo)
trackPublishedUpdateMutex sync.RWMutex trackPublishedUpdateMutex sync.RWMutex
trackPublishedUpdateArgsForCall []struct { trackPublishedUpdateArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
} }
TrackStatsStub func(telemetry.StatsKey, *livekit.AnalyticsStat) TrackStatsStub func(livekit.RoomID, livekit.RoomName, telemetry.StatsKey, *livekit.AnalyticsStat)
trackStatsMutex sync.RWMutex trackStatsMutex sync.RWMutex
trackStatsArgsForCall []struct { trackStatsArgsForCall []struct {
arg1 telemetry.StatsKey arg1 livekit.RoomID
arg2 *livekit.AnalyticsStat arg2 livekit.RoomName
arg3 telemetry.StatsKey
arg4 *livekit.AnalyticsStat
} }
TrackSubscribeFailedStub func(context.Context, livekit.ParticipantID, livekit.TrackID, error, bool) TrackSubscribeFailedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, error, bool)
trackSubscribeFailedMutex sync.RWMutex trackSubscribeFailedMutex sync.RWMutex
trackSubscribeFailedArgsForCall []struct { trackSubscribeFailedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.TrackID arg3 livekit.RoomName
arg4 error arg4 livekit.ParticipantID
arg5 bool arg5 livekit.TrackID
arg6 error
arg7 bool
} }
TrackSubscribeRTPStatsStub func(context.Context, livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats) TrackSubscribeRTPStatsStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats)
trackSubscribeRTPStatsMutex sync.RWMutex trackSubscribeRTPStatsMutex sync.RWMutex
trackSubscribeRTPStatsArgsForCall []struct { trackSubscribeRTPStatsArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.TrackID arg3 livekit.RoomName
arg4 mime.MimeType arg4 livekit.ParticipantID
arg5 *livekit.RTPStats arg5 livekit.TrackID
arg6 mime.MimeType
arg7 *livekit.RTPStats
} }
TrackSubscribeRequestedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo) TrackSubscribeRequestedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo)
trackSubscribeRequestedMutex sync.RWMutex trackSubscribeRequestedMutex sync.RWMutex
trackSubscribeRequestedArgsForCall []struct { trackSubscribeRequestedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
} }
TrackSubscribedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool) TrackSubscribedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool)
trackSubscribedMutex sync.RWMutex trackSubscribedMutex sync.RWMutex
trackSubscribedArgsForCall []struct { trackSubscribedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 *livekit.ParticipantInfo arg4 livekit.ParticipantID
arg5 bool arg5 *livekit.TrackInfo
arg6 *livekit.ParticipantInfo
arg7 bool
} }
TrackUnmutedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo) TrackUnmutedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo)
trackUnmutedMutex sync.RWMutex trackUnmutedMutex sync.RWMutex
trackUnmutedArgsForCall []struct { trackUnmutedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
} }
TrackUnpublishedStub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool) TrackUnpublishedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)
trackUnpublishedMutex sync.RWMutex trackUnpublishedMutex sync.RWMutex
trackUnpublishedArgsForCall []struct { trackUnpublishedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.ParticipantIdentity arg3 livekit.RoomName
arg4 *livekit.TrackInfo arg4 livekit.ParticipantID
arg5 bool arg5 livekit.ParticipantIdentity
arg6 *livekit.TrackInfo
arg7 bool
} }
TrackUnsubscribedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo, bool) TrackUnsubscribedStub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, bool)
trackUnsubscribedMutex sync.RWMutex trackUnsubscribedMutex sync.RWMutex
trackUnsubscribedArgsForCall []struct { trackUnsubscribedArgsForCall []struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 bool arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
arg6 bool
} }
WebhookStub func(context.Context, *livekit.WebhookInfo) WebhookStub func(context.Context, *livekit.WebhookInfo)
webhookMutex sync.RWMutex webhookMutex sync.RWMutex
@@ -1092,20 +1120,22 @@ func (fake *FakeTelemetryService) SendStatsArgsForCall(i int) (context.Context,
return argsForCall.arg1, argsForCall.arg2 return argsForCall.arg1, argsForCall.arg2
} }
func (fake *FakeTelemetryService) TrackMaxSubscribedVideoQuality(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo, arg4 mime.MimeType, arg5 livekit.VideoQuality) { func (fake *FakeTelemetryService) TrackMaxSubscribedVideoQuality(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 *livekit.TrackInfo, arg6 mime.MimeType, arg7 livekit.VideoQuality) {
fake.trackMaxSubscribedVideoQualityMutex.Lock() fake.trackMaxSubscribedVideoQualityMutex.Lock()
fake.trackMaxSubscribedVideoQualityArgsForCall = append(fake.trackMaxSubscribedVideoQualityArgsForCall, struct { fake.trackMaxSubscribedVideoQualityArgsForCall = append(fake.trackMaxSubscribedVideoQualityArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 mime.MimeType arg4 livekit.ParticipantID
arg5 livekit.VideoQuality arg5 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4, arg5}) arg6 mime.MimeType
arg7 livekit.VideoQuality
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
stub := fake.TrackMaxSubscribedVideoQualityStub stub := fake.TrackMaxSubscribedVideoQualityStub
fake.recordInvocation("TrackMaxSubscribedVideoQuality", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.recordInvocation("TrackMaxSubscribedVideoQuality", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
fake.trackMaxSubscribedVideoQualityMutex.Unlock() fake.trackMaxSubscribedVideoQualityMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackMaxSubscribedVideoQualityStub(arg1, arg2, arg3, arg4, arg5) fake.TrackMaxSubscribedVideoQualityStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
} }
} }
@@ -1115,31 +1145,33 @@ func (fake *FakeTelemetryService) TrackMaxSubscribedVideoQualityCallCount() int
return len(fake.trackMaxSubscribedVideoQualityArgsForCall) return len(fake.trackMaxSubscribedVideoQualityArgsForCall)
} }
func (fake *FakeTelemetryService) TrackMaxSubscribedVideoQualityCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality)) { func (fake *FakeTelemetryService) TrackMaxSubscribedVideoQualityCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality)) {
fake.trackMaxSubscribedVideoQualityMutex.Lock() fake.trackMaxSubscribedVideoQualityMutex.Lock()
defer fake.trackMaxSubscribedVideoQualityMutex.Unlock() defer fake.trackMaxSubscribedVideoQualityMutex.Unlock()
fake.TrackMaxSubscribedVideoQualityStub = stub fake.TrackMaxSubscribedVideoQualityStub = stub
} }
func (fake *FakeTelemetryService) TrackMaxSubscribedVideoQualityArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality) { func (fake *FakeTelemetryService) TrackMaxSubscribedVideoQualityArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, mime.MimeType, livekit.VideoQuality) {
fake.trackMaxSubscribedVideoQualityMutex.RLock() fake.trackMaxSubscribedVideoQualityMutex.RLock()
defer fake.trackMaxSubscribedVideoQualityMutex.RUnlock() defer fake.trackMaxSubscribedVideoQualityMutex.RUnlock()
argsForCall := fake.trackMaxSubscribedVideoQualityArgsForCall[i] argsForCall := fake.trackMaxSubscribedVideoQualityArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7
} }
func (fake *FakeTelemetryService) TrackMuted(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackMuted(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 *livekit.TrackInfo) {
fake.trackMutedMutex.Lock() fake.trackMutedMutex.Lock()
fake.trackMutedArgsForCall = append(fake.trackMutedArgsForCall, struct { fake.trackMutedArgsForCall = append(fake.trackMutedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
}{arg1, arg2, arg3}) arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4, arg5})
stub := fake.TrackMutedStub stub := fake.TrackMutedStub
fake.recordInvocation("TrackMuted", []interface{}{arg1, arg2, arg3}) fake.recordInvocation("TrackMuted", []interface{}{arg1, arg2, arg3, arg4, arg5})
fake.trackMutedMutex.Unlock() fake.trackMutedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackMutedStub(arg1, arg2, arg3) fake.TrackMutedStub(arg1, arg2, arg3, arg4, arg5)
} }
} }
@@ -1149,34 +1181,36 @@ func (fake *FakeTelemetryService) TrackMutedCallCount() int {
return len(fake.trackMutedArgsForCall) return len(fake.trackMutedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackMutedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) { func (fake *FakeTelemetryService) TrackMutedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo)) {
fake.trackMutedMutex.Lock() fake.trackMutedMutex.Lock()
defer fake.trackMutedMutex.Unlock() defer fake.trackMutedMutex.Unlock()
fake.TrackMutedStub = stub fake.TrackMutedStub = stub
} }
func (fake *FakeTelemetryService) TrackMutedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackMutedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo) {
fake.trackMutedMutex.RLock() fake.trackMutedMutex.RLock()
defer fake.trackMutedMutex.RUnlock() defer fake.trackMutedMutex.RUnlock()
argsForCall := fake.trackMutedArgsForCall[i] argsForCall := fake.trackMutedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
} }
func (fake *FakeTelemetryService) TrackPublishRTPStats(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.TrackID, arg4 mime.MimeType, arg5 int, arg6 *livekit.RTPStats) { func (fake *FakeTelemetryService) TrackPublishRTPStats(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 livekit.TrackID, arg6 mime.MimeType, arg7 int, arg8 *livekit.RTPStats) {
fake.trackPublishRTPStatsMutex.Lock() fake.trackPublishRTPStatsMutex.Lock()
fake.trackPublishRTPStatsArgsForCall = append(fake.trackPublishRTPStatsArgsForCall, struct { fake.trackPublishRTPStatsArgsForCall = append(fake.trackPublishRTPStatsArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.TrackID arg3 livekit.RoomName
arg4 mime.MimeType arg4 livekit.ParticipantID
arg5 int arg5 livekit.TrackID
arg6 *livekit.RTPStats arg6 mime.MimeType
}{arg1, arg2, arg3, arg4, arg5, arg6}) arg7 int
arg8 *livekit.RTPStats
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8})
stub := fake.TrackPublishRTPStatsStub stub := fake.TrackPublishRTPStatsStub
fake.recordInvocation("TrackPublishRTPStats", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6}) fake.recordInvocation("TrackPublishRTPStats", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8})
fake.trackPublishRTPStatsMutex.Unlock() fake.trackPublishRTPStatsMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackPublishRTPStatsStub(arg1, arg2, arg3, arg4, arg5, arg6) fake.TrackPublishRTPStatsStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
} }
} }
@@ -1186,32 +1220,34 @@ func (fake *FakeTelemetryService) TrackPublishRTPStatsCallCount() int {
return len(fake.trackPublishRTPStatsArgsForCall) return len(fake.trackPublishRTPStatsArgsForCall)
} }
func (fake *FakeTelemetryService) TrackPublishRTPStatsCalls(stub func(context.Context, livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats)) { func (fake *FakeTelemetryService) TrackPublishRTPStatsCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats)) {
fake.trackPublishRTPStatsMutex.Lock() fake.trackPublishRTPStatsMutex.Lock()
defer fake.trackPublishRTPStatsMutex.Unlock() defer fake.trackPublishRTPStatsMutex.Unlock()
fake.TrackPublishRTPStatsStub = stub fake.TrackPublishRTPStatsStub = stub
} }
func (fake *FakeTelemetryService) TrackPublishRTPStatsArgsForCall(i int) (context.Context, livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats) { func (fake *FakeTelemetryService) TrackPublishRTPStatsArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats) {
fake.trackPublishRTPStatsMutex.RLock() fake.trackPublishRTPStatsMutex.RLock()
defer fake.trackPublishRTPStatsMutex.RUnlock() defer fake.trackPublishRTPStatsMutex.RUnlock()
argsForCall := fake.trackPublishRTPStatsArgsForCall[i] argsForCall := fake.trackPublishRTPStatsArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7, argsForCall.arg8
} }
func (fake *FakeTelemetryService) TrackPublishRequested(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.ParticipantIdentity, arg4 *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackPublishRequested(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 livekit.ParticipantIdentity, arg6 *livekit.TrackInfo) {
fake.trackPublishRequestedMutex.Lock() fake.trackPublishRequestedMutex.Lock()
fake.trackPublishRequestedArgsForCall = append(fake.trackPublishRequestedArgsForCall, struct { fake.trackPublishRequestedArgsForCall = append(fake.trackPublishRequestedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.ParticipantIdentity arg3 livekit.RoomName
arg4 *livekit.TrackInfo arg4 livekit.ParticipantID
}{arg1, arg2, arg3, arg4}) arg5 livekit.ParticipantIdentity
arg6 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4, arg5, arg6})
stub := fake.TrackPublishRequestedStub stub := fake.TrackPublishRequestedStub
fake.recordInvocation("TrackPublishRequested", []interface{}{arg1, arg2, arg3, arg4}) fake.recordInvocation("TrackPublishRequested", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6})
fake.trackPublishRequestedMutex.Unlock() fake.trackPublishRequestedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackPublishRequestedStub(arg1, arg2, arg3, arg4) fake.TrackPublishRequestedStub(arg1, arg2, arg3, arg4, arg5, arg6)
} }
} }
@@ -1221,33 +1257,35 @@ func (fake *FakeTelemetryService) TrackPublishRequestedCallCount() int {
return len(fake.trackPublishRequestedArgsForCall) return len(fake.trackPublishRequestedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackPublishRequestedCalls(stub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)) { func (fake *FakeTelemetryService) TrackPublishRequestedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)) {
fake.trackPublishRequestedMutex.Lock() fake.trackPublishRequestedMutex.Lock()
defer fake.trackPublishRequestedMutex.Unlock() defer fake.trackPublishRequestedMutex.Unlock()
fake.TrackPublishRequestedStub = stub fake.TrackPublishRequestedStub = stub
} }
func (fake *FakeTelemetryService) TrackPublishRequestedArgsForCall(i int) (context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackPublishRequestedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo) {
fake.trackPublishRequestedMutex.RLock() fake.trackPublishRequestedMutex.RLock()
defer fake.trackPublishRequestedMutex.RUnlock() defer fake.trackPublishRequestedMutex.RUnlock()
argsForCall := fake.trackPublishRequestedArgsForCall[i] argsForCall := fake.trackPublishRequestedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6
} }
func (fake *FakeTelemetryService) TrackPublished(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.ParticipantIdentity, arg4 *livekit.TrackInfo, arg5 bool) { func (fake *FakeTelemetryService) TrackPublished(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 livekit.ParticipantIdentity, arg6 *livekit.TrackInfo, arg7 bool) {
fake.trackPublishedMutex.Lock() fake.trackPublishedMutex.Lock()
fake.trackPublishedArgsForCall = append(fake.trackPublishedArgsForCall, struct { fake.trackPublishedArgsForCall = append(fake.trackPublishedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.ParticipantIdentity arg3 livekit.RoomName
arg4 *livekit.TrackInfo arg4 livekit.ParticipantID
arg5 bool arg5 livekit.ParticipantIdentity
}{arg1, arg2, arg3, arg4, arg5}) arg6 *livekit.TrackInfo
arg7 bool
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
stub := fake.TrackPublishedStub stub := fake.TrackPublishedStub
fake.recordInvocation("TrackPublished", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.recordInvocation("TrackPublished", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
fake.trackPublishedMutex.Unlock() fake.trackPublishedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackPublishedStub(arg1, arg2, arg3, arg4, arg5) fake.TrackPublishedStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
} }
} }
@@ -1257,31 +1295,33 @@ func (fake *FakeTelemetryService) TrackPublishedCallCount() int {
return len(fake.trackPublishedArgsForCall) return len(fake.trackPublishedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackPublishedCalls(stub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)) { func (fake *FakeTelemetryService) TrackPublishedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)) {
fake.trackPublishedMutex.Lock() fake.trackPublishedMutex.Lock()
defer fake.trackPublishedMutex.Unlock() defer fake.trackPublishedMutex.Unlock()
fake.TrackPublishedStub = stub fake.TrackPublishedStub = stub
} }
func (fake *FakeTelemetryService) TrackPublishedArgsForCall(i int) (context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool) { func (fake *FakeTelemetryService) TrackPublishedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool) {
fake.trackPublishedMutex.RLock() fake.trackPublishedMutex.RLock()
defer fake.trackPublishedMutex.RUnlock() defer fake.trackPublishedMutex.RUnlock()
argsForCall := fake.trackPublishedArgsForCall[i] argsForCall := fake.trackPublishedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7
} }
func (fake *FakeTelemetryService) TrackPublishedUpdate(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackPublishedUpdate(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 *livekit.TrackInfo) {
fake.trackPublishedUpdateMutex.Lock() fake.trackPublishedUpdateMutex.Lock()
fake.trackPublishedUpdateArgsForCall = append(fake.trackPublishedUpdateArgsForCall, struct { fake.trackPublishedUpdateArgsForCall = append(fake.trackPublishedUpdateArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
}{arg1, arg2, arg3}) arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4, arg5})
stub := fake.TrackPublishedUpdateStub stub := fake.TrackPublishedUpdateStub
fake.recordInvocation("TrackPublishedUpdate", []interface{}{arg1, arg2, arg3}) fake.recordInvocation("TrackPublishedUpdate", []interface{}{arg1, arg2, arg3, arg4, arg5})
fake.trackPublishedUpdateMutex.Unlock() fake.trackPublishedUpdateMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackPublishedUpdateStub(arg1, arg2, arg3) fake.TrackPublishedUpdateStub(arg1, arg2, arg3, arg4, arg5)
} }
} }
@@ -1291,30 +1331,32 @@ func (fake *FakeTelemetryService) TrackPublishedUpdateCallCount() int {
return len(fake.trackPublishedUpdateArgsForCall) return len(fake.trackPublishedUpdateArgsForCall)
} }
func (fake *FakeTelemetryService) TrackPublishedUpdateCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) { func (fake *FakeTelemetryService) TrackPublishedUpdateCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo)) {
fake.trackPublishedUpdateMutex.Lock() fake.trackPublishedUpdateMutex.Lock()
defer fake.trackPublishedUpdateMutex.Unlock() defer fake.trackPublishedUpdateMutex.Unlock()
fake.TrackPublishedUpdateStub = stub fake.TrackPublishedUpdateStub = stub
} }
func (fake *FakeTelemetryService) TrackPublishedUpdateArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackPublishedUpdateArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo) {
fake.trackPublishedUpdateMutex.RLock() fake.trackPublishedUpdateMutex.RLock()
defer fake.trackPublishedUpdateMutex.RUnlock() defer fake.trackPublishedUpdateMutex.RUnlock()
argsForCall := fake.trackPublishedUpdateArgsForCall[i] argsForCall := fake.trackPublishedUpdateArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
} }
func (fake *FakeTelemetryService) TrackStats(arg1 telemetry.StatsKey, arg2 *livekit.AnalyticsStat) { func (fake *FakeTelemetryService) TrackStats(arg1 livekit.RoomID, arg2 livekit.RoomName, arg3 telemetry.StatsKey, arg4 *livekit.AnalyticsStat) {
fake.trackStatsMutex.Lock() fake.trackStatsMutex.Lock()
fake.trackStatsArgsForCall = append(fake.trackStatsArgsForCall, struct { fake.trackStatsArgsForCall = append(fake.trackStatsArgsForCall, struct {
arg1 telemetry.StatsKey arg1 livekit.RoomID
arg2 *livekit.AnalyticsStat arg2 livekit.RoomName
}{arg1, arg2}) arg3 telemetry.StatsKey
arg4 *livekit.AnalyticsStat
}{arg1, arg2, arg3, arg4})
stub := fake.TrackStatsStub stub := fake.TrackStatsStub
fake.recordInvocation("TrackStats", []interface{}{arg1, arg2}) fake.recordInvocation("TrackStats", []interface{}{arg1, arg2, arg3, arg4})
fake.trackStatsMutex.Unlock() fake.trackStatsMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackStatsStub(arg1, arg2) fake.TrackStatsStub(arg1, arg2, arg3, arg4)
} }
} }
@@ -1324,33 +1366,35 @@ func (fake *FakeTelemetryService) TrackStatsCallCount() int {
return len(fake.trackStatsArgsForCall) return len(fake.trackStatsArgsForCall)
} }
func (fake *FakeTelemetryService) TrackStatsCalls(stub func(telemetry.StatsKey, *livekit.AnalyticsStat)) { func (fake *FakeTelemetryService) TrackStatsCalls(stub func(livekit.RoomID, livekit.RoomName, telemetry.StatsKey, *livekit.AnalyticsStat)) {
fake.trackStatsMutex.Lock() fake.trackStatsMutex.Lock()
defer fake.trackStatsMutex.Unlock() defer fake.trackStatsMutex.Unlock()
fake.TrackStatsStub = stub fake.TrackStatsStub = stub
} }
func (fake *FakeTelemetryService) TrackStatsArgsForCall(i int) (telemetry.StatsKey, *livekit.AnalyticsStat) { func (fake *FakeTelemetryService) TrackStatsArgsForCall(i int) (livekit.RoomID, livekit.RoomName, telemetry.StatsKey, *livekit.AnalyticsStat) {
fake.trackStatsMutex.RLock() fake.trackStatsMutex.RLock()
defer fake.trackStatsMutex.RUnlock() defer fake.trackStatsMutex.RUnlock()
argsForCall := fake.trackStatsArgsForCall[i] argsForCall := fake.trackStatsArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
} }
func (fake *FakeTelemetryService) TrackSubscribeFailed(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.TrackID, arg4 error, arg5 bool) { func (fake *FakeTelemetryService) TrackSubscribeFailed(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 livekit.TrackID, arg6 error, arg7 bool) {
fake.trackSubscribeFailedMutex.Lock() fake.trackSubscribeFailedMutex.Lock()
fake.trackSubscribeFailedArgsForCall = append(fake.trackSubscribeFailedArgsForCall, struct { fake.trackSubscribeFailedArgsForCall = append(fake.trackSubscribeFailedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.TrackID arg3 livekit.RoomName
arg4 error arg4 livekit.ParticipantID
arg5 bool arg5 livekit.TrackID
}{arg1, arg2, arg3, arg4, arg5}) arg6 error
arg7 bool
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
stub := fake.TrackSubscribeFailedStub stub := fake.TrackSubscribeFailedStub
fake.recordInvocation("TrackSubscribeFailed", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.recordInvocation("TrackSubscribeFailed", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
fake.trackSubscribeFailedMutex.Unlock() fake.trackSubscribeFailedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackSubscribeFailedStub(arg1, arg2, arg3, arg4, arg5) fake.TrackSubscribeFailedStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
} }
} }
@@ -1360,33 +1404,35 @@ func (fake *FakeTelemetryService) TrackSubscribeFailedCallCount() int {
return len(fake.trackSubscribeFailedArgsForCall) return len(fake.trackSubscribeFailedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackSubscribeFailedCalls(stub func(context.Context, livekit.ParticipantID, livekit.TrackID, error, bool)) { func (fake *FakeTelemetryService) TrackSubscribeFailedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, error, bool)) {
fake.trackSubscribeFailedMutex.Lock() fake.trackSubscribeFailedMutex.Lock()
defer fake.trackSubscribeFailedMutex.Unlock() defer fake.trackSubscribeFailedMutex.Unlock()
fake.TrackSubscribeFailedStub = stub fake.TrackSubscribeFailedStub = stub
} }
func (fake *FakeTelemetryService) TrackSubscribeFailedArgsForCall(i int) (context.Context, livekit.ParticipantID, livekit.TrackID, error, bool) { func (fake *FakeTelemetryService) TrackSubscribeFailedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, error, bool) {
fake.trackSubscribeFailedMutex.RLock() fake.trackSubscribeFailedMutex.RLock()
defer fake.trackSubscribeFailedMutex.RUnlock() defer fake.trackSubscribeFailedMutex.RUnlock()
argsForCall := fake.trackSubscribeFailedArgsForCall[i] argsForCall := fake.trackSubscribeFailedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7
} }
func (fake *FakeTelemetryService) TrackSubscribeRTPStats(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.TrackID, arg4 mime.MimeType, arg5 *livekit.RTPStats) { func (fake *FakeTelemetryService) TrackSubscribeRTPStats(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 livekit.TrackID, arg6 mime.MimeType, arg7 *livekit.RTPStats) {
fake.trackSubscribeRTPStatsMutex.Lock() fake.trackSubscribeRTPStatsMutex.Lock()
fake.trackSubscribeRTPStatsArgsForCall = append(fake.trackSubscribeRTPStatsArgsForCall, struct { fake.trackSubscribeRTPStatsArgsForCall = append(fake.trackSubscribeRTPStatsArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.TrackID arg3 livekit.RoomName
arg4 mime.MimeType arg4 livekit.ParticipantID
arg5 *livekit.RTPStats arg5 livekit.TrackID
}{arg1, arg2, arg3, arg4, arg5}) arg6 mime.MimeType
arg7 *livekit.RTPStats
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
stub := fake.TrackSubscribeRTPStatsStub stub := fake.TrackSubscribeRTPStatsStub
fake.recordInvocation("TrackSubscribeRTPStats", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.recordInvocation("TrackSubscribeRTPStats", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
fake.trackSubscribeRTPStatsMutex.Unlock() fake.trackSubscribeRTPStatsMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackSubscribeRTPStatsStub(arg1, arg2, arg3, arg4, arg5) fake.TrackSubscribeRTPStatsStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
} }
} }
@@ -1396,31 +1442,33 @@ func (fake *FakeTelemetryService) TrackSubscribeRTPStatsCallCount() int {
return len(fake.trackSubscribeRTPStatsArgsForCall) return len(fake.trackSubscribeRTPStatsArgsForCall)
} }
func (fake *FakeTelemetryService) TrackSubscribeRTPStatsCalls(stub func(context.Context, livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats)) { func (fake *FakeTelemetryService) TrackSubscribeRTPStatsCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats)) {
fake.trackSubscribeRTPStatsMutex.Lock() fake.trackSubscribeRTPStatsMutex.Lock()
defer fake.trackSubscribeRTPStatsMutex.Unlock() defer fake.trackSubscribeRTPStatsMutex.Unlock()
fake.TrackSubscribeRTPStatsStub = stub fake.TrackSubscribeRTPStatsStub = stub
} }
func (fake *FakeTelemetryService) TrackSubscribeRTPStatsArgsForCall(i int) (context.Context, livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats) { func (fake *FakeTelemetryService) TrackSubscribeRTPStatsArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.TrackID, mime.MimeType, *livekit.RTPStats) {
fake.trackSubscribeRTPStatsMutex.RLock() fake.trackSubscribeRTPStatsMutex.RLock()
defer fake.trackSubscribeRTPStatsMutex.RUnlock() defer fake.trackSubscribeRTPStatsMutex.RUnlock()
argsForCall := fake.trackSubscribeRTPStatsArgsForCall[i] argsForCall := fake.trackSubscribeRTPStatsArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7
} }
func (fake *FakeTelemetryService) TrackSubscribeRequested(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackSubscribeRequested(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 *livekit.TrackInfo) {
fake.trackSubscribeRequestedMutex.Lock() fake.trackSubscribeRequestedMutex.Lock()
fake.trackSubscribeRequestedArgsForCall = append(fake.trackSubscribeRequestedArgsForCall, struct { fake.trackSubscribeRequestedArgsForCall = append(fake.trackSubscribeRequestedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
}{arg1, arg2, arg3}) arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4, arg5})
stub := fake.TrackSubscribeRequestedStub stub := fake.TrackSubscribeRequestedStub
fake.recordInvocation("TrackSubscribeRequested", []interface{}{arg1, arg2, arg3}) fake.recordInvocation("TrackSubscribeRequested", []interface{}{arg1, arg2, arg3, arg4, arg5})
fake.trackSubscribeRequestedMutex.Unlock() fake.trackSubscribeRequestedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackSubscribeRequestedStub(arg1, arg2, arg3) fake.TrackSubscribeRequestedStub(arg1, arg2, arg3, arg4, arg5)
} }
} }
@@ -1430,33 +1478,35 @@ func (fake *FakeTelemetryService) TrackSubscribeRequestedCallCount() int {
return len(fake.trackSubscribeRequestedArgsForCall) return len(fake.trackSubscribeRequestedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackSubscribeRequestedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) { func (fake *FakeTelemetryService) TrackSubscribeRequestedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo)) {
fake.trackSubscribeRequestedMutex.Lock() fake.trackSubscribeRequestedMutex.Lock()
defer fake.trackSubscribeRequestedMutex.Unlock() defer fake.trackSubscribeRequestedMutex.Unlock()
fake.TrackSubscribeRequestedStub = stub fake.TrackSubscribeRequestedStub = stub
} }
func (fake *FakeTelemetryService) TrackSubscribeRequestedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackSubscribeRequestedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo) {
fake.trackSubscribeRequestedMutex.RLock() fake.trackSubscribeRequestedMutex.RLock()
defer fake.trackSubscribeRequestedMutex.RUnlock() defer fake.trackSubscribeRequestedMutex.RUnlock()
argsForCall := fake.trackSubscribeRequestedArgsForCall[i] argsForCall := fake.trackSubscribeRequestedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
} }
func (fake *FakeTelemetryService) TrackSubscribed(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo, arg4 *livekit.ParticipantInfo, arg5 bool) { func (fake *FakeTelemetryService) TrackSubscribed(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 *livekit.TrackInfo, arg6 *livekit.ParticipantInfo, arg7 bool) {
fake.trackSubscribedMutex.Lock() fake.trackSubscribedMutex.Lock()
fake.trackSubscribedArgsForCall = append(fake.trackSubscribedArgsForCall, struct { fake.trackSubscribedArgsForCall = append(fake.trackSubscribedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 *livekit.ParticipantInfo arg4 livekit.ParticipantID
arg5 bool arg5 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4, arg5}) arg6 *livekit.ParticipantInfo
arg7 bool
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
stub := fake.TrackSubscribedStub stub := fake.TrackSubscribedStub
fake.recordInvocation("TrackSubscribed", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.recordInvocation("TrackSubscribed", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
fake.trackSubscribedMutex.Unlock() fake.trackSubscribedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackSubscribedStub(arg1, arg2, arg3, arg4, arg5) fake.TrackSubscribedStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
} }
} }
@@ -1466,31 +1516,33 @@ func (fake *FakeTelemetryService) TrackSubscribedCallCount() int {
return len(fake.trackSubscribedArgsForCall) return len(fake.trackSubscribedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackSubscribedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool)) { func (fake *FakeTelemetryService) TrackSubscribedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool)) {
fake.trackSubscribedMutex.Lock() fake.trackSubscribedMutex.Lock()
defer fake.trackSubscribedMutex.Unlock() defer fake.trackSubscribedMutex.Unlock()
fake.TrackSubscribedStub = stub fake.TrackSubscribedStub = stub
} }
func (fake *FakeTelemetryService) TrackSubscribedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool) { func (fake *FakeTelemetryService) TrackSubscribedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, *livekit.ParticipantInfo, bool) {
fake.trackSubscribedMutex.RLock() fake.trackSubscribedMutex.RLock()
defer fake.trackSubscribedMutex.RUnlock() defer fake.trackSubscribedMutex.RUnlock()
argsForCall := fake.trackSubscribedArgsForCall[i] argsForCall := fake.trackSubscribedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7
} }
func (fake *FakeTelemetryService) TrackUnmuted(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackUnmuted(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 *livekit.TrackInfo) {
fake.trackUnmutedMutex.Lock() fake.trackUnmutedMutex.Lock()
fake.trackUnmutedArgsForCall = append(fake.trackUnmutedArgsForCall, struct { fake.trackUnmutedArgsForCall = append(fake.trackUnmutedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
}{arg1, arg2, arg3}) arg4 livekit.ParticipantID
arg5 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4, arg5})
stub := fake.TrackUnmutedStub stub := fake.TrackUnmutedStub
fake.recordInvocation("TrackUnmuted", []interface{}{arg1, arg2, arg3}) fake.recordInvocation("TrackUnmuted", []interface{}{arg1, arg2, arg3, arg4, arg5})
fake.trackUnmutedMutex.Unlock() fake.trackUnmutedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackUnmutedStub(arg1, arg2, arg3) fake.TrackUnmutedStub(arg1, arg2, arg3, arg4, arg5)
} }
} }
@@ -1500,33 +1552,35 @@ func (fake *FakeTelemetryService) TrackUnmutedCallCount() int {
return len(fake.trackUnmutedArgsForCall) return len(fake.trackUnmutedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackUnmutedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) { func (fake *FakeTelemetryService) TrackUnmutedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo)) {
fake.trackUnmutedMutex.Lock() fake.trackUnmutedMutex.Lock()
defer fake.trackUnmutedMutex.Unlock() defer fake.trackUnmutedMutex.Unlock()
fake.TrackUnmutedStub = stub fake.TrackUnmutedStub = stub
} }
func (fake *FakeTelemetryService) TrackUnmutedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) { func (fake *FakeTelemetryService) TrackUnmutedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo) {
fake.trackUnmutedMutex.RLock() fake.trackUnmutedMutex.RLock()
defer fake.trackUnmutedMutex.RUnlock() defer fake.trackUnmutedMutex.RUnlock()
argsForCall := fake.trackUnmutedArgsForCall[i] argsForCall := fake.trackUnmutedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
} }
func (fake *FakeTelemetryService) TrackUnpublished(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.ParticipantIdentity, arg4 *livekit.TrackInfo, arg5 bool) { func (fake *FakeTelemetryService) TrackUnpublished(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 livekit.ParticipantIdentity, arg6 *livekit.TrackInfo, arg7 bool) {
fake.trackUnpublishedMutex.Lock() fake.trackUnpublishedMutex.Lock()
fake.trackUnpublishedArgsForCall = append(fake.trackUnpublishedArgsForCall, struct { fake.trackUnpublishedArgsForCall = append(fake.trackUnpublishedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 livekit.ParticipantIdentity arg3 livekit.RoomName
arg4 *livekit.TrackInfo arg4 livekit.ParticipantID
arg5 bool arg5 livekit.ParticipantIdentity
}{arg1, arg2, arg3, arg4, arg5}) arg6 *livekit.TrackInfo
arg7 bool
}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
stub := fake.TrackUnpublishedStub stub := fake.TrackUnpublishedStub
fake.recordInvocation("TrackUnpublished", []interface{}{arg1, arg2, arg3, arg4, arg5}) fake.recordInvocation("TrackUnpublished", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6, arg7})
fake.trackUnpublishedMutex.Unlock() fake.trackUnpublishedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackUnpublishedStub(arg1, arg2, arg3, arg4, arg5) fake.TrackUnpublishedStub(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
} }
} }
@@ -1536,32 +1590,34 @@ func (fake *FakeTelemetryService) TrackUnpublishedCallCount() int {
return len(fake.trackUnpublishedArgsForCall) return len(fake.trackUnpublishedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackUnpublishedCalls(stub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)) { func (fake *FakeTelemetryService) TrackUnpublishedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)) {
fake.trackUnpublishedMutex.Lock() fake.trackUnpublishedMutex.Lock()
defer fake.trackUnpublishedMutex.Unlock() defer fake.trackUnpublishedMutex.Unlock()
fake.TrackUnpublishedStub = stub fake.TrackUnpublishedStub = stub
} }
func (fake *FakeTelemetryService) TrackUnpublishedArgsForCall(i int) (context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool) { func (fake *FakeTelemetryService) TrackUnpublishedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool) {
fake.trackUnpublishedMutex.RLock() fake.trackUnpublishedMutex.RLock()
defer fake.trackUnpublishedMutex.RUnlock() defer fake.trackUnpublishedMutex.RUnlock()
argsForCall := fake.trackUnpublishedArgsForCall[i] argsForCall := fake.trackUnpublishedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6, argsForCall.arg7
} }
func (fake *FakeTelemetryService) TrackUnsubscribed(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo, arg4 bool) { func (fake *FakeTelemetryService) TrackUnsubscribed(arg1 context.Context, arg2 livekit.RoomID, arg3 livekit.RoomName, arg4 livekit.ParticipantID, arg5 *livekit.TrackInfo, arg6 bool) {
fake.trackUnsubscribedMutex.Lock() fake.trackUnsubscribedMutex.Lock()
fake.trackUnsubscribedArgsForCall = append(fake.trackUnsubscribedArgsForCall, struct { fake.trackUnsubscribedArgsForCall = append(fake.trackUnsubscribedArgsForCall, struct {
arg1 context.Context arg1 context.Context
arg2 livekit.ParticipantID arg2 livekit.RoomID
arg3 *livekit.TrackInfo arg3 livekit.RoomName
arg4 bool arg4 livekit.ParticipantID
}{arg1, arg2, arg3, arg4}) arg5 *livekit.TrackInfo
arg6 bool
}{arg1, arg2, arg3, arg4, arg5, arg6})
stub := fake.TrackUnsubscribedStub stub := fake.TrackUnsubscribedStub
fake.recordInvocation("TrackUnsubscribed", []interface{}{arg1, arg2, arg3, arg4}) fake.recordInvocation("TrackUnsubscribed", []interface{}{arg1, arg2, arg3, arg4, arg5, arg6})
fake.trackUnsubscribedMutex.Unlock() fake.trackUnsubscribedMutex.Unlock()
if stub != nil { if stub != nil {
fake.TrackUnsubscribedStub(arg1, arg2, arg3, arg4) fake.TrackUnsubscribedStub(arg1, arg2, arg3, arg4, arg5, arg6)
} }
} }
@@ -1571,17 +1627,17 @@ func (fake *FakeTelemetryService) TrackUnsubscribedCallCount() int {
return len(fake.trackUnsubscribedArgsForCall) return len(fake.trackUnsubscribedArgsForCall)
} }
func (fake *FakeTelemetryService) TrackUnsubscribedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo, bool)) { func (fake *FakeTelemetryService) TrackUnsubscribedCalls(stub func(context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, bool)) {
fake.trackUnsubscribedMutex.Lock() fake.trackUnsubscribedMutex.Lock()
defer fake.trackUnsubscribedMutex.Unlock() defer fake.trackUnsubscribedMutex.Unlock()
fake.TrackUnsubscribedStub = stub fake.TrackUnsubscribedStub = stub
} }
func (fake *FakeTelemetryService) TrackUnsubscribedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo, bool) { func (fake *FakeTelemetryService) TrackUnsubscribedArgsForCall(i int) (context.Context, livekit.RoomID, livekit.RoomName, livekit.ParticipantID, *livekit.TrackInfo, bool) {
fake.trackUnsubscribedMutex.RLock() fake.trackUnsubscribedMutex.RLock()
defer fake.trackUnsubscribedMutex.RUnlock() defer fake.trackUnsubscribedMutex.RUnlock()
argsForCall := fake.trackUnsubscribedArgsForCall[i] argsForCall := fake.trackUnsubscribedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5, argsForCall.arg6
} }
func (fake *FakeTelemetryService) Webhook(arg1 context.Context, arg2 *livekit.WebhookInfo) { func (fake *FakeTelemetryService) Webhook(arg1 context.Context, arg2 *livekit.WebhookInfo) {
+53 -38
View File
@@ -31,11 +31,12 @@ import (
//counterfeiter:generate . TelemetryService //counterfeiter:generate . TelemetryService
type TelemetryService interface { type TelemetryService interface {
// TrackStats is called periodically for each track in both directions (published/subscribed) // TrackStats is called periodically for each track in both directions (published/subscribed)
TrackStats(key StatsKey, stat *livekit.AnalyticsStat) TrackStats(roomID livekit.RoomID, roomName livekit.RoomName, key StatsKey, stat *livekit.AnalyticsStat)
// events // events
RoomStarted(ctx context.Context, room *livekit.Room) RoomStarted(ctx context.Context, room *livekit.Room)
RoomEnded(ctx context.Context, room *livekit.Room) RoomEnded(ctx context.Context, room *livekit.Room)
// ParticipantJoined - a participant establishes signal connection to a room // ParticipantJoined - a participant establishes signal connection to a room
ParticipantJoined(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, clientInfo *livekit.ClientInfo, clientMeta *livekit.AnalyticsClientMeta, shouldSendEvent bool, guard *ReferenceGuard) ParticipantJoined(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, clientInfo *livekit.ClientInfo, clientMeta *livekit.AnalyticsClientMeta, shouldSendEvent bool, guard *ReferenceGuard)
// ParticipantActive - a participant establishes media connection // ParticipantActive - a participant establishes media connection
@@ -45,40 +46,46 @@ type TelemetryService interface {
// ParticipantLeft - the participant leaves the room, only sent if ParticipantActive has been called before // ParticipantLeft - the participant leaves the room, only sent if ParticipantActive has been called before
ParticipantLeft(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, shouldSendEvent bool, guard *ReferenceGuard) ParticipantLeft(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, shouldSendEvent bool, guard *ReferenceGuard)
// TrackPublishRequested - a publication attempt has been received // TrackPublishRequested - a publication attempt has been received
TrackPublishRequested(ctx context.Context, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo) TrackPublishRequested(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo)
// TrackPublished - a publication attempt has been successful // TrackPublished - a publication attempt has been successful
TrackPublished(ctx context.Context, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo, shouldSendEvent bool) TrackPublished(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo, shouldSendEvent bool)
// TrackUnpublished - a participant unpublished a track // TrackUnpublished - a participant unpublished a track
TrackUnpublished(ctx context.Context, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo, shouldSendEvent bool) TrackUnpublished(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo, shouldSendEvent bool)
// TrackSubscribeRequested - a participant requested to subscribe to a track // TrackSubscribeRequested - a participant requested to subscribe to a track
TrackSubscribeRequested(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) TrackSubscribeRequested(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo)
// TrackSubscribed - a participant subscribed to a track successfully // TrackSubscribed - a participant subscribed to a track successfully
TrackSubscribed(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo, publisher *livekit.ParticipantInfo, shouldSendEvent bool) TrackSubscribed(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo, publisher *livekit.ParticipantInfo, shouldSendEvent bool)
// TrackUnsubscribed - a participant unsubscribed from a track successfully // TrackUnsubscribed - a participant unsubscribed from a track successfully
TrackUnsubscribed(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo, shouldSendEvent bool) TrackUnsubscribed(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo, shouldSendEvent bool)
// TrackSubscribeFailed - failure to subscribe to a track // TrackSubscribeFailed - failure to subscribe to a track
TrackSubscribeFailed(ctx context.Context, participantID livekit.ParticipantID, trackID livekit.TrackID, err error, isUserError bool) TrackSubscribeFailed(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, trackID livekit.TrackID, err error, isUserError bool)
// TrackMuted - the publisher has muted the Track // TrackMuted - the publisher has muted the Track
TrackMuted(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) TrackMuted(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo)
// TrackUnmuted - the publisher has muted the Track // TrackUnmuted - the publisher has muted the Track
TrackUnmuted(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) TrackUnmuted(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo)
// TrackPublishedUpdate - track metadata has been updated // TrackPublishedUpdate - track metadata has been updated
TrackPublishedUpdate(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) TrackPublishedUpdate(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo)
// TrackMaxSubscribedVideoQuality - publisher is notified of the max quality subscribers desire // TrackMaxSubscribedVideoQuality - publisher is notified of the max quality subscribers desire
TrackMaxSubscribedVideoQuality(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo, mime mime.MimeType, maxQuality livekit.VideoQuality) TrackMaxSubscribedVideoQuality(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo, mime mime.MimeType, maxQuality livekit.VideoQuality)
TrackPublishRTPStats(ctx context.Context, participantID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, layer int, stats *livekit.RTPStats) TrackPublishRTPStats(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, layer int, stats *livekit.RTPStats)
TrackSubscribeRTPStats(ctx context.Context, participantID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, stats *livekit.RTPStats) TrackSubscribeRTPStats(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, stats *livekit.RTPStats)
EgressStarted(ctx context.Context, info *livekit.EgressInfo) EgressStarted(ctx context.Context, info *livekit.EgressInfo)
EgressUpdated(ctx context.Context, info *livekit.EgressInfo) EgressUpdated(ctx context.Context, info *livekit.EgressInfo)
EgressEnded(ctx context.Context, info *livekit.EgressInfo) EgressEnded(ctx context.Context, info *livekit.EgressInfo)
IngressCreated(ctx context.Context, info *livekit.IngressInfo) IngressCreated(ctx context.Context, info *livekit.IngressInfo)
IngressDeleted(ctx context.Context, info *livekit.IngressInfo) IngressDeleted(ctx context.Context, info *livekit.IngressInfo)
IngressStarted(ctx context.Context, info *livekit.IngressInfo) IngressStarted(ctx context.Context, info *livekit.IngressInfo)
IngressUpdated(ctx context.Context, info *livekit.IngressInfo) IngressUpdated(ctx context.Context, info *livekit.IngressInfo)
IngressEnded(ctx context.Context, info *livekit.IngressInfo) IngressEnded(ctx context.Context, info *livekit.IngressInfo)
LocalRoomState(ctx context.Context, info *livekit.AnalyticsNodeRooms) LocalRoomState(ctx context.Context, info *livekit.AnalyticsNodeRooms)
Report(ctx context.Context, reportInfo *livekit.ReportInfo) Report(ctx context.Context, reportInfo *livekit.ReportInfo)
APICall(ctx context.Context, apiCallInfo *livekit.APICallInfo) APICall(ctx context.Context, apiCallInfo *livekit.APICallInfo)
Webhook(ctx context.Context, webhookInfo *livekit.WebhookInfo) Webhook(ctx context.Context, webhookInfo *livekit.WebhookInfo)
// helpers // helpers
@@ -95,9 +102,10 @@ type NullTelemetryService struct {
NullAnalyticService NullAnalyticService
} }
func (n NullTelemetryService) TrackStats(key StatsKey, stat *livekit.AnalyticsStat) {} func (n NullTelemetryService) TrackStats(roomID livekit.RoomID, roomName livekit.RoomName, key StatsKey, stat *livekit.AnalyticsStat) {
func (n NullTelemetryService) RoomStarted(ctx context.Context, room *livekit.Room) {} }
func (n NullTelemetryService) RoomEnded(ctx context.Context, room *livekit.Room) {} func (n NullTelemetryService) RoomStarted(ctx context.Context, room *livekit.Room) {}
func (n NullTelemetryService) RoomEnded(ctx context.Context, room *livekit.Room) {}
func (n NullTelemetryService) ParticipantJoined(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, clientInfo *livekit.ClientInfo, clientMeta *livekit.AnalyticsClientMeta, shouldSendEvent bool, guard *ReferenceGuard) { func (n NullTelemetryService) ParticipantJoined(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, clientInfo *livekit.ClientInfo, clientMeta *livekit.AnalyticsClientMeta, shouldSendEvent bool, guard *ReferenceGuard) {
} }
func (n NullTelemetryService) ParticipantActive(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, clientMeta *livekit.AnalyticsClientMeta, isMigration bool, guard *ReferenceGuard) { func (n NullTelemetryService) ParticipantActive(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, clientMeta *livekit.AnalyticsClientMeta, isMigration bool, guard *ReferenceGuard) {
@@ -106,31 +114,31 @@ func (n NullTelemetryService) ParticipantResumed(ctx context.Context, room *live
} }
func (n NullTelemetryService) ParticipantLeft(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, shouldSendEvent bool, guard *ReferenceGuard) { func (n NullTelemetryService) ParticipantLeft(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, shouldSendEvent bool, guard *ReferenceGuard) {
} }
func (n NullTelemetryService) TrackPublishRequested(ctx context.Context, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo) { func (n NullTelemetryService) TrackPublishRequested(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo) {
} }
func (n NullTelemetryService) TrackPublished(ctx context.Context, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo, shouldSendEvent bool) { func (n NullTelemetryService) TrackPublished(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo, shouldSendEvent bool) {
} }
func (n NullTelemetryService) TrackUnpublished(ctx context.Context, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo, shouldSendEvent bool) { func (n NullTelemetryService) TrackUnpublished(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, identity livekit.ParticipantIdentity, track *livekit.TrackInfo, shouldSendEvent bool) {
} }
func (n NullTelemetryService) TrackSubscribeRequested(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) { func (n NullTelemetryService) TrackSubscribeRequested(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo) {
} }
func (n NullTelemetryService) TrackSubscribed(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo, publisher *livekit.ParticipantInfo, shouldSendEvent bool) { func (n NullTelemetryService) TrackSubscribed(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo, publisher *livekit.ParticipantInfo, shouldSendEvent bool) {
} }
func (n NullTelemetryService) TrackUnsubscribed(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo, shouldSendEvent bool) { func (n NullTelemetryService) TrackUnsubscribed(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo, shouldSendEvent bool) {
} }
func (n NullTelemetryService) TrackSubscribeFailed(ctx context.Context, participantID livekit.ParticipantID, trackID livekit.TrackID, err error, isUserError bool) { func (n NullTelemetryService) TrackSubscribeFailed(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, trackID livekit.TrackID, err error, isUserError bool) {
} }
func (n NullTelemetryService) TrackMuted(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) { func (n NullTelemetryService) TrackMuted(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo) {
} }
func (n NullTelemetryService) TrackUnmuted(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) { func (n NullTelemetryService) TrackUnmuted(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo) {
} }
func (n NullTelemetryService) TrackPublishedUpdate(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo) { func (n NullTelemetryService) TrackPublishedUpdate(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo) {
} }
func (n NullTelemetryService) TrackMaxSubscribedVideoQuality(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo, mime mime.MimeType, maxQuality livekit.VideoQuality) { func (n NullTelemetryService) TrackMaxSubscribedVideoQuality(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, track *livekit.TrackInfo, mime mime.MimeType, maxQuality livekit.VideoQuality) {
} }
func (n NullTelemetryService) TrackPublishRTPStats(ctx context.Context, participantID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, layer int, stats *livekit.RTPStats) { func (n NullTelemetryService) TrackPublishRTPStats(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, layer int, stats *livekit.RTPStats) {
} }
func (n NullTelemetryService) TrackSubscribeRTPStats(ctx context.Context, participantID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, stats *livekit.RTPStats) { func (n NullTelemetryService) TrackSubscribeRTPStats(ctx context.Context, roomID livekit.RoomID, roomName livekit.RoomName, participantID livekit.ParticipantID, trackID livekit.TrackID, mimeType mime.MimeType, stats *livekit.RTPStats) {
} }
func (n NullTelemetryService) EgressStarted(ctx context.Context, info *livekit.EgressInfo) {} func (n NullTelemetryService) EgressStarted(ctx context.Context, info *livekit.EgressInfo) {}
func (n NullTelemetryService) EgressUpdated(ctx context.Context, info *livekit.EgressInfo) {} func (n NullTelemetryService) EgressUpdated(ctx context.Context, info *livekit.EgressInfo) {}
@@ -157,6 +165,11 @@ const (
telemetryStatsUpdateInterval = time.Second * 30 telemetryStatsUpdateInterval = time.Second * 30
) )
type statsWorkerKey struct {
roomID livekit.RoomID
participantID livekit.ParticipantID
}
type telemetryService struct { type telemetryService struct {
AnalyticsService AnalyticsService
@@ -164,7 +177,7 @@ type telemetryService struct {
jobsQueue *utils.OpsQueue jobsQueue *utils.OpsQueue
workersMu sync.RWMutex workersMu sync.RWMutex
workers map[livekit.ParticipantID]*StatsWorker workers map[statsWorkerKey]*StatsWorker
workerList *StatsWorker workerList *StatsWorker
flushMu sync.Mutex flushMu sync.Mutex
@@ -180,7 +193,7 @@ func NewTelemetryService(notifier webhook.QueuedNotifier, analytics AnalyticsSer
FlushOnStop: true, FlushOnStop: true,
Logger: logger.GetLogger(), Logger: logger.GetLogger(),
}), }),
workers: make(map[livekit.ParticipantID]*StatsWorker), workers: make(map[statsWorkerKey]*StatsWorker),
} }
if t.notifier != nil { if t.notifier != nil {
t.notifier.RegisterProcessedHook(func(ctx context.Context, whi *livekit.WebhookInfo) { t.notifier.RegisterProcessedHook(func(ctx context.Context, whi *livekit.WebhookInfo) {
@@ -234,8 +247,9 @@ func (t *telemetryService) FlushStats() {
if reap != nil { if reap != nil {
t.workersMu.Lock() t.workersMu.Lock()
for reap != nil { for reap != nil {
if reap == t.workers[reap.participantID] { key := statsWorkerKey{reap.roomID, reap.participantID}
delete(t.workers, reap.participantID) if reap == t.workers[key] {
delete(t.workers, key)
} }
reap = reap.next reap = reap.next
} }
@@ -253,11 +267,11 @@ func (t *telemetryService) enqueue(op func()) {
t.jobsQueue.Enqueue(op) t.jobsQueue.Enqueue(op)
} }
func (t *telemetryService) getWorker(participantID livekit.ParticipantID) (worker *StatsWorker, ok bool) { func (t *telemetryService) getWorker(roomID livekit.RoomID, participantID livekit.ParticipantID) (worker *StatsWorker, ok bool) {
t.workersMu.RLock() t.workersMu.RLock()
defer t.workersMu.RUnlock() defer t.workersMu.RUnlock()
worker, ok = t.workers[participantID] worker, ok = t.workers[statsWorkerKey{roomID, participantID}]
return return
} }
@@ -272,7 +286,8 @@ func (t *telemetryService) getOrCreateWorker(
t.workersMu.Lock() t.workersMu.Lock()
defer t.workersMu.Unlock() defer t.workersMu.Unlock()
worker, ok := t.workers[participantID] key := statsWorkerKey{roomID, participantID}
worker, ok := t.workers[key]
if ok && !worker.Closed(guard) { if ok && !worker.Closed(guard) {
return worker, true return worker, true
} }
@@ -295,7 +310,7 @@ func (t *telemetryService) getOrCreateWorker(
worker.SetConnected() worker.SetConnected()
} }
t.workers[participantID] = worker t.workers[key] = worker
worker.next = t.workerList worker.next = t.workerList
t.workerList = worker t.workerList = worker