-
Hi, I'm trying to get general stats for my WebRTC application, including received bytes, packet loss, delay, etc. I wrote a small function to check if I can access this information: func getInboundRTPStreamStats(peerConnection *webrtc.PeerConnection) {
stats := peerConnection.GetStats()
for k, stat := range stats {
log.Infof("Stats %v :: %v\n", k, stats)
if inboundStat, ok := stat.(webrtc.InboundRTPStreamStats); ok {
log.Infof("Bytes Received: %d, Packets Lost: %d\n",
inboundStat.BytesReceived, inboundStat.PacketsLost)
}
}
} I run it inside peerConnection.OnTrack: peerConnection.OnTrack(func(t *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
// ...
go func() {
for {
time.Sleep(1 * time.Second)
getInboundRTPStreamStats(peerConnection)
}
}()
// ...
} While I do receive some stats, I am not getting I would appreciate any help on this! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @asmdv I think the issue is you need to use the stats interceptor like this example We should work on getting this all under one API. The issue is that we have tried to put all our RTP subsystems in the interceptor repo and created some complexity here. Sorry about that! |
Beta Was this translation helpful? Give feedback.
Hi @asmdv
I think the issue is you need to use the stats interceptor like this example
We should work on getting this all under one API. The issue is that we have tried to put all our RTP subsystems in the interceptor repo and created some complexity here.
Sorry about that!