Imlement analytics per track statistics (#281)

New tests for telemetry + implementation of per track statistics
This commit is contained in:
Artur Shellunts
2021-12-29 19:29:24 +01:00
committed by GitHub
parent 9d78619ca3
commit 828d490755
10 changed files with 559 additions and 154 deletions
+7 -4
View File
@@ -286,13 +286,13 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
go t.sendDownTrackBindingReports(sub)
})
downTrack.OnPacketSent(func(_ *sfu.DownTrack, size int) {
t.params.Telemetry.OnDownstreamPacket(subscriberID, size)
t.params.Telemetry.OnDownstreamPacket(subscriberID, t.ID(), size)
})
downTrack.OnPaddingSent(func(_ *sfu.DownTrack, size int) {
t.params.Telemetry.OnDownstreamPacket(subscriberID, size)
t.params.Telemetry.OnDownstreamPacket(subscriberID, t.ID(), size)
})
downTrack.OnRTCP(func(pkts []rtcp.Packet) {
t.params.Telemetry.HandleRTCP(livekit.StreamType_DOWNSTREAM, subscriberID, pkts)
t.params.Telemetry.HandleRTCP(livekit.StreamType_DOWNSTREAM, subscriberID, t.ID(), pkts)
})
downTrack.OnCloseHandler(func() {
@@ -437,7 +437,7 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
}
t.receiver.AddUpTrack(track, buff)
t.params.Telemetry.AddUpTrack(t.params.ParticipantID, buff)
t.params.Telemetry.AddUpTrack(t.params.ParticipantID, t.ID(), buff)
atomic.AddUint32(&t.numUpTracks, 1)
// LK-TODO: can remove this completely when VideoLayers protocol becomes the default as it has info from client or if we decide to use TrackInfo.Simulcast
@@ -631,6 +631,9 @@ func (t *MediaTrack) handlePublisherFeedback(packets []rtcp.Packet) {
var totalLost uint32
var maxSeqNum uint32
//forward to telemetry
t.params.Telemetry.HandleRTCP(livekit.StreamType_UPSTREAM, t.params.ParticipantID, t.ID(), packets)
for _, p := range packets {
switch pkt := p.(type) {
// sfu.Buffer generates ReceiverReports for the publisher
-8
View File
@@ -7,7 +7,6 @@ import (
"github.com/bep/debounce"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/pion/interceptor"
"github.com/pion/webrtc/v3"
"github.com/livekit/livekit-server/pkg/rtc/types"
@@ -70,16 +69,9 @@ func newPeerConnection(params TransportParams) (*webrtc.PeerConnection, *webrtc.
se := params.Config.SettingEngine
se.DisableMediaEngineCopy(true)
ir := &interceptor.Registry{}
// intercept pub -> SFU rtcp for analytics
if params.Telemetry != nil && params.Target == livekit.SignalTarget_PUBLISHER {
f := params.Telemetry.NewStatsInterceptorFactory(params.ParticipantID, params.ParticipantIdentity)
ir.Add(f)
}
api := webrtc.NewAPI(
webrtc.WithMediaEngine(me),
webrtc.WithSettingEngine(se),
webrtc.WithInterceptorRegistry(ir),
)
pc, err := api.NewPeerConnection(params.Config.Configuration)
return pc, me, err