Split out mediatransportutil (#1071)

This commit is contained in:
Raja Subramanian
2022-10-06 23:55:59 +05:30
committed by GitHub
parent c3120679e6
commit 792349cc56
19 changed files with 30 additions and 1568 deletions
-21
View File
@@ -1,14 +1,9 @@
package sfu
import (
"math"
"strings"
"time"
"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
)
// Do a fuzzy find for a codec in the list of codecs
@@ -33,19 +28,3 @@ func codecParametersFuzzySearch(needle webrtc.RTPCodecParameters, haystack []web
}
// -----------------------------------------------
func getRttMs(report *rtcp.ReceptionReport) uint32 {
if report.LastSenderReport == 0 {
return 0
}
// RTT calculation reference: https://datatracker.ietf.org/doc/html/rfc3550#section-6.4.1
// middle 32-bits of current NTP time
now := uint32(buffer.ToNtpTime(time.Now()) >> 16)
if now < (report.LastSenderReport + report.Delay) {
return 0
}
ntpDiff := now - report.LastSenderReport - report.Delay
return uint32(math.Ceil(float64(ntpDiff) * 1000.0 / 65536.0))
}