Analytics events + stats (#187)

* events

* bump

* update incoming stats

* publisher stats

* outgoing rtcp

* stats

* remove unnecessary struct

* merge mediaTrack

* put comment back
This commit is contained in:
David Colburn
2021-11-12 16:36:10 -06:00
committed by GitHub
parent 6500ce262d
commit 92838d75a8
12 changed files with 414 additions and 160 deletions
+2 -20
View File
@@ -1,9 +1,9 @@
package telemetry
import (
livekit "github.com/livekit/protocol/proto"
"github.com/pion/interceptor"
"github.com/pion/rtcp"
"github.com/pion/rtp"
)
type StatsInterceptorFactory struct {
@@ -28,29 +28,11 @@ type StatsInterceptor struct {
identity string
}
// BindRTCPReader lets you modify any incoming RTCP packets. It is called once per sender/receiver, however this might
// change in the future. The returned method will be called once per packet batch.
func (s *StatsInterceptor) BindRTCPReader(reader interceptor.RTCPReader) interceptor.RTCPReader {
return interceptor.RTCPReaderFunc(func(bytes []byte, attributes interceptor.Attributes) (int, interceptor.Attributes, error) {
s.t.HandleIncomingRTCP(s.participantID, s.identity, bytes)
return reader.Read(bytes, attributes)
})
}
// BindRTCPWriter lets you modify any outgoing RTCP packets. It is called once per PeerConnection. The returned method
// will be called once per packet batch.
func (s *StatsInterceptor) BindRTCPWriter(writer interceptor.RTCPWriter) interceptor.RTCPWriter {
return interceptor.RTCPWriterFunc(func(pkts []rtcp.Packet, attributes interceptor.Attributes) (int, error) {
s.t.HandleOutgoingRTCP(s.participantID, s.identity, pkts)
s.t.HandleRTCP(livekit.StreamType_UPSTREAM, s.participantID, pkts)
return writer.Write(pkts, attributes)
})
}
// BindLocalStream lets you modify any outgoing RTP packets. It is called once for per LocalStream. The returned method
// will be called once per rtp packet.
func (s *StatsInterceptor) BindLocalStream(_ *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter {
return interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error) {
s.t.HandleOutgoingRTP(s.participantID, s.identity, uint64(len(payload)))
return writer.Write(header, payload, attributes)
})
}