@@ -85,7 +85,7 @@ func Test_queue(t *testing.T) {
|
||||
_, err = q.GetPacket(buff, 0)
|
||||
require.ErrorIs(t, err, ErrPacketNotFound)
|
||||
|
||||
// ask for soemething ahead of headSN
|
||||
// ask for something ahead of headSN
|
||||
_, err = q.GetPacket(buff, 11)
|
||||
require.ErrorIs(t, err, ErrPacketNotFound)
|
||||
}
|
||||
|
||||
@@ -9,13 +9,15 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gammazero/deque"
|
||||
"github.com/livekit/livekit-server/pkg/utils"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/sdp/v3"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -4,8 +4,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
)
|
||||
|
||||
type DataStatsParam struct {
|
||||
@@ -83,6 +84,6 @@ func (s *DataStats) ToProtoAggregateOnly() *livekit.RTPStats {
|
||||
EndTime: timestamppb.New(end),
|
||||
Duration: end.Sub(s.startTime).Seconds(),
|
||||
Bytes: uint64(s.windowBytes),
|
||||
Bitrate: float64(s.windowBytes) * 8 / float64(end.Sub(s.startTime).Seconds()),
|
||||
Bitrate: float64(s.windowBytes) * 8 / end.Sub(s.startTime).Seconds(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/rtp/codecs"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -63,7 +63,7 @@ func (n *NackQueue) Pairs() ([]rtcp.NackPair, int) {
|
||||
// set it far back to get the first pair
|
||||
baseSN := n.nacks[0].seqNum - 17
|
||||
|
||||
snsToPurge := []uint16{}
|
||||
snsToPurge := make([]uint16, 0)
|
||||
|
||||
numSeqNumsNacked := 0
|
||||
isPairActive := false
|
||||
|
||||
+12
-11
@@ -6,11 +6,12 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/rtp"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -224,7 +225,7 @@ func (r *RTPStats) Update(rtph *rtp.Header, payloadSize int, paddingSize int, pa
|
||||
"tsDiff", rtph.Timestamp-r.highestTS,
|
||||
"highestTime", r.highestTime,
|
||||
"now", packetTime,
|
||||
"timeDiff(ms)", float64(packetTime-r.highestTime)/float64(1e6),
|
||||
"timeDiff(ms)", float64(packetTime-r.highestTime)/1e6,
|
||||
)
|
||||
}
|
||||
// LK-DEBUG-REMOVE END
|
||||
@@ -290,7 +291,7 @@ func (r *RTPStats) maybeAdjustStartSN(rtph *rtp.Header, packetTime int64) {
|
||||
"tsDiff", rtph.Timestamp-r.highestTS,
|
||||
"highestTime", r.highestTime,
|
||||
"now", packetTime,
|
||||
"timeDiff(ms)", float64(packetTime-r.highestTime)/float64(1e6),
|
||||
"timeDiff(ms)", float64(packetTime-r.highestTime)/1e6,
|
||||
)
|
||||
// LK-DEBUG-REMOVE END
|
||||
// NOTE: current sequence number is counted as loss as it will be deducted in the duplicate check
|
||||
@@ -839,12 +840,12 @@ func (r *RTPStats) getNumPacketsSeen() uint32 {
|
||||
|
||||
func (r *RTPStats) setSeenSN(sn uint16) {
|
||||
idx, rem := getPos(sn)
|
||||
r.seenSNs[idx] |= (1 << rem)
|
||||
r.seenSNs[idx] |= 1 << rem
|
||||
}
|
||||
|
||||
func (r *RTPStats) clearSeenSN(sn uint16) {
|
||||
idx, rem := getPos(sn)
|
||||
r.seenSNs[idx] &^= (1 << rem)
|
||||
r.seenSNs[idx] &^= 1 << rem
|
||||
}
|
||||
|
||||
func (r *RTPStats) isSeenSN(sn uint16) bool {
|
||||
@@ -943,7 +944,7 @@ func (r *RTPStats) getAndResetSnapshot(snapshotId uint32) *Snapshot {
|
||||
|
||||
// ----------------------------------
|
||||
|
||||
func AggregateRTPStats(statses []*livekit.RTPStats) *livekit.RTPStats {
|
||||
func AggregateRTPStats(statsList []*livekit.RTPStats) *livekit.RTPStats {
|
||||
startTime := time.Time{}
|
||||
endTime := time.Time{}
|
||||
|
||||
@@ -958,7 +959,7 @@ func AggregateRTPStats(statses []*livekit.RTPStats) *livekit.RTPStats {
|
||||
frames := uint32(0)
|
||||
keyFrames := uint32(0)
|
||||
lastKeyFrame := time.Time{}
|
||||
jitter := float64(0.0)
|
||||
jitter := 0.0
|
||||
maxJitter := float64(0)
|
||||
gapHistogram := make(map[int32]uint32, GapHistogramNumBins)
|
||||
nacks := uint32(0)
|
||||
@@ -972,7 +973,7 @@ func AggregateRTPStats(statses []*livekit.RTPStats) *livekit.RTPStats {
|
||||
rtt := uint32(0)
|
||||
maxRtt := uint32(0)
|
||||
|
||||
for _, stats := range statses {
|
||||
for _, stats := range statsList {
|
||||
if startTime.IsZero() || startTime.After(stats.StartTime.AsTime()) {
|
||||
startTime = stats.StartTime.AsTime()
|
||||
}
|
||||
@@ -1076,7 +1077,7 @@ func AggregateRTPStats(statses []*livekit.RTPStats) *livekit.RTPStats {
|
||||
FrameRate: frameRate,
|
||||
KeyFrames: keyFrames,
|
||||
LastKeyFrame: timestamppb.New(lastKeyFrame),
|
||||
JitterCurrent: jitter / float64(len(statses)),
|
||||
JitterCurrent: jitter / float64(len(statsList)),
|
||||
JitterMax: maxJitter,
|
||||
GapHistogram: gapHistogram,
|
||||
Nacks: nacks,
|
||||
@@ -1087,7 +1088,7 @@ func AggregateRTPStats(statses []*livekit.RTPStats) *livekit.RTPStats {
|
||||
LastLayerLockPli: timestamppb.New(lastLayerLockPli),
|
||||
Firs: firs,
|
||||
LastFir: timestamppb.New(lastFir),
|
||||
RttCurrent: rtt / uint32(len(statses)),
|
||||
RttCurrent: rtt / uint32(len(statsList)),
|
||||
RttMax: maxRtt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -22,7 +22,7 @@ func Score2Rating(score float32) livekit.ConnectionQuality {
|
||||
return livekit.ConnectionQuality_POOR
|
||||
}
|
||||
|
||||
func mosAudioEmodel(pctLoss float32, rtt uint32, jitter float32) float32 {
|
||||
func mosAudioEModel(pctLoss float32, rtt uint32, jitter float32) float32 {
|
||||
rx := 93.2 - pctLoss
|
||||
ry := 0.18*rx*rx - 27.9*rx + 1126.62
|
||||
|
||||
@@ -68,7 +68,7 @@ func loss2Score(pctLoss float32, reducedQuality bool) float32 {
|
||||
}
|
||||
|
||||
func AudioConnectionScore(pctLoss float32, rtt uint32, jitter float32) float32 {
|
||||
return mosAudioEmodel(pctLoss, rtt, jitter)
|
||||
return mosAudioEModel(pctLoss, rtt, jitter)
|
||||
}
|
||||
|
||||
func VideoConnectionScore(pctLoss float32, reducedQuality bool) float32 {
|
||||
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/sdp/v3"
|
||||
@@ -18,6 +16,9 @@ import (
|
||||
"github.com/pion/webrtc/v3"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/connectionquality"
|
||||
"github.com/livekit/livekit-server/pkg/utils"
|
||||
@@ -241,7 +242,7 @@ func (d *DownTrack) Bind(t webrtc.TrackLocalContext) (webrtc.RTPCodecParameters,
|
||||
d.bound.Store(true)
|
||||
|
||||
d.connectionStats.Start()
|
||||
d.logger.Debugw("binded")
|
||||
d.logger.Debugw("bound")
|
||||
|
||||
return codec, nil
|
||||
}
|
||||
@@ -555,7 +556,7 @@ func (d *DownTrack) Close() {
|
||||
// 1. When transceiver is reused by other participant's video track,
|
||||
// set flush=true to avoid previous video shows before previous stream is displayed.
|
||||
// 2. in case of session migration, participant migrate from other node, video track should
|
||||
// be resumed with same participant, set flush=false since we don't need flush decoder.
|
||||
// be resumed with same participant, set flush=false since we don't need to flush decoder.
|
||||
func (d *DownTrack) CloseWithFlush(flush bool) {
|
||||
d.forwarder.Mute(true)
|
||||
|
||||
@@ -563,7 +564,7 @@ func (d *DownTrack) CloseWithFlush(flush bool) {
|
||||
// Idea here is to send blank 1x1 key frames to flush the decoder buffer at the remote end.
|
||||
// Otherwise, with transceiver re-use last frame from previous stream is held in the
|
||||
// display buffer and there could be a brief moment where the previous stream is displayed.
|
||||
d.logger.Infow("close downtrack", "peerID", d.peerID, "trackID", d.id, "flushBlankFrame", flush)
|
||||
d.logger.Infow("close down track", "peerID", d.peerID, "trackID", d.id, "flushBlankFrame", flush)
|
||||
if flush {
|
||||
_ = d.writeBlankFrameRTP()
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
)
|
||||
|
||||
@@ -298,7 +299,7 @@ func (f *Forwarder) GetForwardingStatus() ForwardingStatus {
|
||||
return ForwardingStatusOff
|
||||
}
|
||||
|
||||
if f.targetLayers.spatial < f.maxLayers.spatial && f.targetLayers.spatial < int32(f.availableLayers[len(f.availableLayers)-1]) {
|
||||
if f.targetLayers.spatial < f.maxLayers.spatial && f.targetLayers.spatial < f.availableLayers[len(f.availableLayers)-1] {
|
||||
return ForwardingStatusPartial
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/testutils"
|
||||
)
|
||||
@@ -1400,7 +1401,7 @@ func TestForwardGetSnTsForBlankFrames(t *testing.T) {
|
||||
require.Equal(t, sntsExpected, snts)
|
||||
|
||||
// now that there is a marker, timestamp should jump on first padding when asked again
|
||||
// also number of padding should be RTPBlnkFramesMax
|
||||
// also number of padding should be RTPBlankFramesMax
|
||||
snts, frameEndNeeded, err = f.GetSnTsForBlankFrames()
|
||||
require.NoError(t, err)
|
||||
require.False(t, frameEndNeeded)
|
||||
|
||||
+2
-1
@@ -5,9 +5,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
+2
-1
@@ -112,8 +112,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gammazero/deque"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
)
|
||||
|
||||
type ProberParams struct {
|
||||
|
||||
+7
-6
@@ -8,13 +8,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/connectionquality"
|
||||
@@ -205,12 +206,12 @@ func (w *WebRTCReceiver) SetRTT(rtt uint32) {
|
||||
buffers := w.buffers
|
||||
w.bufferMu.Unlock()
|
||||
|
||||
for _, buffer := range buffers {
|
||||
if buffer == nil {
|
||||
for _, buff := range buffers {
|
||||
if buff == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
buffer.SetRTT(rtt)
|
||||
buff.SetRTT(rtt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +441,7 @@ func (w *WebRTCReceiver) getQualityParams() *buffer.ConnectionQualityParams {
|
||||
|
||||
packetsExpected := uint32(0)
|
||||
packetsLost := uint32(0)
|
||||
maxJitter := float64(0.0)
|
||||
maxJitter := 0.0
|
||||
maxRtt := uint32(0)
|
||||
for _, buff := range w.buffers {
|
||||
if buff == nil {
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/testutils"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,9 +5,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,13 +7,14 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/pion/interceptor/pkg/cc"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
)
|
||||
|
||||
@@ -864,7 +865,7 @@ func (s *StreamAllocator) finalizeProbe() {
|
||||
// reset probe interval on a successful probe
|
||||
s.resetProbeInterval()
|
||||
|
||||
// probe estimate is same or higher, commit it and try allocate deficient tracks
|
||||
// probe estimate is same or higher, commit it and try to allocate deficient tracks
|
||||
s.params.Logger.Infow(
|
||||
"successful probe, updating channel capacity",
|
||||
"old(bps)", s.committedChannelCapacity,
|
||||
@@ -1597,7 +1598,7 @@ func (c *ChannelObserver) GetHighestEstimate() int64 {
|
||||
}
|
||||
|
||||
func (c *ChannelObserver) GetNackRatio() float64 {
|
||||
ratio := float64(0.0)
|
||||
ratio := 0.0
|
||||
if c.packets != 0 {
|
||||
ratio = float64(c.repeatedNacks) / float64(c.packets)
|
||||
if ratio > 1.0 {
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.uber.org/atomic"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/utils"
|
||||
"github.com/livekit/protocol/logger"
|
||||
"go.uber.org/atomic"
|
||||
)
|
||||
|
||||
type StreamStatus int32
|
||||
@@ -228,12 +229,12 @@ func (s *StreamTracker) Observe(sn uint16, temporalLayer int32, pktSize int) {
|
||||
}
|
||||
|
||||
// BitrateTemporalCumulative returns the current stream bitrate temporal layer accumulated with lower temporal layers.
|
||||
func (s *StreamTracker) BitrateTemporalCumulative() [4]int64 {
|
||||
func (s *StreamTracker) BitrateTemporalCumulative() []int64 {
|
||||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
|
||||
// copy and process
|
||||
var brs [4]int64
|
||||
brs := make([]int64, len(s.bitrate))
|
||||
for i := 0; i < len(s.bitrate); i++ {
|
||||
brs[i] = s.bitrate[i]
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func (s *StreamTrackerManager) GetBitrateTemporalCumulative() Bitrates {
|
||||
|
||||
for i, tracker := range s.trackers {
|
||||
if tracker != nil {
|
||||
var tls [DefaultMaxLayerTemporal + 1]int64
|
||||
tls := make([]int64, DefaultMaxLayerTemporal+1)
|
||||
if s.hasSpatialLayerLocked(int32(i)) {
|
||||
tls = tracker.BitrateTemporalCumulative()
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package sfu
|
||||
|
||||
import (
|
||||
"github.com/elliotchance/orderedmap"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/sfu/buffer"
|
||||
"github.com/livekit/livekit-server/pkg/sfu/testutils"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user