mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-13 09:07:34 +02:00
Add WebRTC candidate metrics (#18)
* stats: add protocol to iceCandidates. * add ice candidates used metric. * NewICECandidate use whole struct.
This commit is contained in:
parent
b49f545094
commit
fb8462b56a
2 changed files with 86 additions and 9 deletions
|
@ -545,13 +545,31 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, bitrate int)
|
|||
manager.metrics.SetSctpTransportStats(session, data)
|
||||
}
|
||||
|
||||
remoteCandidates := map[string]webrtc.ICECandidateStats{}
|
||||
nominatedRemoteCandidates := map[string]struct{}{}
|
||||
for _, entry := range stats {
|
||||
// only remote ice candidate stats
|
||||
candidate, ok := entry.(webrtc.ICECandidateStats)
|
||||
if ok && candidate.Type == webrtc.StatsTypeRemoteCandidate {
|
||||
manager.metrics.NewICECandidate(session, candidate.ID)
|
||||
manager.metrics.NewICECandidate(session, candidate)
|
||||
remoteCandidates[candidate.ID] = candidate
|
||||
}
|
||||
|
||||
// only nominated ice candidate pair stats
|
||||
pair, ok := entry.(webrtc.ICECandidatePairStats)
|
||||
if ok && pair.Nominated {
|
||||
nominatedRemoteCandidates[pair.RemoteCandidateID] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
iceCandidatesUsed := []webrtc.ICECandidateStats{}
|
||||
for id := range nominatedRemoteCandidates {
|
||||
if candidate, ok := remoteCandidates[id]; ok {
|
||||
iceCandidatesUsed = append(iceCandidatesUsed, candidate)
|
||||
}
|
||||
}
|
||||
|
||||
manager.metrics.SetICECandidatesUsed(session, iceCandidatesUsed)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue