Server side metrics (#3198)
* mbb WIP * deps * WIP * WIP * remove unused file * Switch to enabled * misc * deps * mediatransportutil update * Typo * Set ParticipantIdentity in metrics data packets * use uint32 as JSON decoder does not unmarshal time.Duration
This commit is contained in:
+19
-4
@@ -81,6 +81,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNoICETransport = errors.New("no ICE transport")
|
||||
ErrIceRestartWithoutLocalSDP = errors.New("ICE restart without local SDP settled")
|
||||
ErrIceRestartOnClosedPeerConnection = errors.New("ICE restart on closed peer connection")
|
||||
ErrNoTransceiver = errors.New("no transceiver")
|
||||
@@ -178,9 +179,10 @@ type trackDescription struct {
|
||||
|
||||
// PCTransport is a wrapper around PeerConnection, with some helper methods
|
||||
type PCTransport struct {
|
||||
params TransportParams
|
||||
pc *webrtc.PeerConnection
|
||||
me *webrtc.MediaEngine
|
||||
params TransportParams
|
||||
pc *webrtc.PeerConnection
|
||||
iceTransport *webrtc.ICETransport
|
||||
me *webrtc.MediaEngine
|
||||
|
||||
lock sync.RWMutex
|
||||
|
||||
@@ -506,7 +508,11 @@ func (t *PCTransport) createPeerConnection() error {
|
||||
t.pc.OnDataChannel(t.onDataChannel)
|
||||
t.pc.OnTrack(t.params.Handler.OnTrack)
|
||||
|
||||
t.pc.SCTP().Transport().ICETransport().OnSelectedCandidatePairChange(func(pair *webrtc.ICECandidatePair) {
|
||||
t.iceTransport = t.pc.SCTP().Transport().ICETransport()
|
||||
if t.iceTransport == nil {
|
||||
return ErrNoICETransport
|
||||
}
|
||||
t.iceTransport.OnSelectedCandidatePairChange(func(pair *webrtc.ICECandidatePair) {
|
||||
t.params.Logger.Debugw("selected ICE candidate pair changed", "pair", wrappedICECandidatePairLogger{pair})
|
||||
t.connectionDetails.SetSelectedPair(pair)
|
||||
existingPair := t.selectedPair.Load()
|
||||
@@ -942,6 +948,15 @@ func (t *PCTransport) CreateDataChannelIfEmpty(dcLabel string, dci *webrtc.DataC
|
||||
return dc.Label(), *dc.ID(), false, nil
|
||||
}
|
||||
|
||||
func (t *PCTransport) GetRTT() (float64, bool) {
|
||||
scps, ok := t.iceTransport.GetSelectedCandidatePairStats()
|
||||
if !ok {
|
||||
return 0.0, false
|
||||
}
|
||||
|
||||
return scps.CurrentRoundTripTime, true
|
||||
}
|
||||
|
||||
// IsEstablished returns true if the PeerConnection has been established
|
||||
func (t *PCTransport) IsEstablished() bool {
|
||||
return t.pc.ConnectionState() != webrtc.PeerConnectionStateNew
|
||||
|
||||
Reference in New Issue
Block a user