Code inspection (#581)

* Code inspection

* fix [4]int64 conversiong
This commit is contained in:
David Colburn
2022-03-30 13:49:53 -07:00
committed by GitHub
parent 26f7bb498a
commit 0b8a180554
77 changed files with 228 additions and 151 deletions
+3 -2
View File
@@ -4,11 +4,12 @@ import (
"errors"
"net"
"github.com/livekit/protocol/logger"
"github.com/pion/ice/v2"
"github.com/pion/sdp/v3"
"github.com/pion/webrtc/v3"
"github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/config"
logging "github.com/livekit/livekit-server/pkg/logger"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
@@ -184,7 +185,7 @@ func NewWebRTCConfig(conf *config.Config, externalIP string) (*WebRTCConfig, err
includes := rtcConf.Interfaces.Includes
excludes := rtcConf.Interfaces.Excludes
s.SetInterfaceFilter(func(s string) bool {
//filter by include interfaces
// filter by include interfaces
if len(includes) > 0 {
for _, iface := range includes {
if iface == s {
+2 -1
View File
@@ -3,8 +3,9 @@ package rtc
import (
"strings"
"github.com/livekit/protocol/livekit"
"github.com/pion/webrtc/v3"
"github.com/livekit/protocol/livekit"
)
func registerCodecs(me *webrtc.MediaEngine, codecs []*livekit.Codec, rtcpFeedback RTCPFeedbackConfig) error {
+2 -1
View File
@@ -3,9 +3,10 @@ package rtc
import (
"testing"
"github.com/livekit/protocol/livekit"
"github.com/pion/webrtc/v3"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/livekit"
)
func TestIsCodecEnabled(t *testing.T) {
+4 -4
View File
@@ -4,18 +4,18 @@ import (
"context"
"sync"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"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"
"github.com/livekit/livekit-server/pkg/sfu"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/livekit-server/pkg/sfu/twcc"
"github.com/livekit/livekit-server/pkg/telemetry"
"go.uber.org/atomic"
)
// MediaTrack represents a WebRTC track that needs to be forwarded
+4 -2
View File
@@ -4,9 +4,11 @@ import (
"testing"
"time"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/protocol/livekit"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/livekit"
"github.com/livekit/livekit-server/pkg/config"
)
func TestTrackInfo(t *testing.T) {
+6 -4
View File
@@ -6,14 +6,14 @@ import (
"sync"
"time"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/pion/rtcp"
"go.uber.org/atomic"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/pion/rtcp"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/sfu"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/livekit-server/pkg/telemetry"
@@ -205,7 +205,9 @@ func (t *MediaTrackReceiver) AddSubscriber(sub types.LocalParticipant) error {
downTrack.AddReceiverReportListener(t.handleMaxLossFeedback)
}
receiver.AddDownTrack(downTrack)
if err = receiver.AddDownTrack(downTrack); err != nil {
logger.Errorw("could not add down track", err, "participant", sub.Identity(), "pID", sub.ID())
}
}
return nil
}
+3 -2
View File
@@ -7,12 +7,13 @@ import (
"time"
"github.com/bep/debounce"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v3/pkg/rtcerr"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/sfu"
+11 -7
View File
@@ -8,16 +8,17 @@ import (
"time"
lru "github.com/hashicorp/golang-lru"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"github.com/pkg/errors"
"go.uber.org/atomic"
"google.golang.org/protobuf/proto"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/pkg/rtc/types"
@@ -607,7 +608,10 @@ func (p *ParticipantImpl) SetMigrateState(s types.MigrateState) {
p.handlePendingDataChannels()
}
if pendingOffer != nil {
p.HandleOffer(*pendingOffer)
_, err := p.HandleOffer(*pendingOffer)
if err != nil {
p.GetLogger().Errorw("could not handle offer", err)
}
}
}
@@ -671,7 +675,7 @@ func (p *ParticipantImpl) GetConnectionQuality() *livekit.ConnectionQualityInfo
return &livekit.ConnectionQualityInfo{
ParticipantSid: string(p.ID()),
Quality: rating,
Score: float32(avgScore),
Score: avgScore,
}
}
@@ -1321,7 +1325,7 @@ func (p *ParticipantImpl) mediaTrackReceived(track *webrtc.TrackRemote, rtpRecei
p.pendingTracksLock.Lock()
newTrack := false
// use existing mediatrack to handle simulcast
// use existing media track to handle simulcast
mt, ok := p.getPublishedTrackBySdpCid(track.ID()).(*MediaTrack)
if !ok {
signalCid, ti := p.getPendingTrack(track.ID(), ToProtoTrackKind(track.Kind()))
+2 -1
View File
@@ -4,10 +4,11 @@ import (
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
"github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
+5 -3
View File
@@ -3,11 +3,13 @@ package rtc
import (
"fmt"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/version"
"github.com/livekit/protocol/livekit"
"github.com/pion/webrtc/v3"
"google.golang.org/protobuf/proto"
"github.com/livekit/protocol/livekit"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/version"
)
func (p *ParticipantImpl) GetResponseSink() routing.MessageSink {
+4 -3
View File
@@ -7,11 +7,12 @@ import (
"sync"
"time"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"go.uber.org/atomic"
"google.golang.org/protobuf/proto"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/pkg/rtc/types"
@@ -664,7 +665,7 @@ func (r *Room) onDataPacket(source types.LocalParticipant, dp *livekit.DataPacke
}
err := op.SendDataPacket(dp)
if err != nil {
r.Logger.Infow("send datapacket error", "error", err, "participant", op.Identity())
r.Logger.Infow("send data packet error", "error", err, "participant", op.Identity())
}
}
}
+3 -2
View File
@@ -5,10 +5,10 @@ import (
"testing"
"time"
"github.com/livekit/livekit-server/pkg/telemetry/telemetryfakes"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/webhook"
"github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/config"
serverlogger "github.com/livekit/livekit-server/pkg/logger"
@@ -16,6 +16,7 @@ import (
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/rtc/types/typesfakes"
"github.com/livekit/livekit-server/pkg/telemetry"
"github.com/livekit/livekit-server/pkg/telemetry/telemetryfakes"
"github.com/livekit/livekit-server/pkg/testutils"
)
+2 -1
View File
@@ -4,10 +4,11 @@ import (
"time"
"github.com/bep/debounce"
"github.com/livekit/protocol/livekit"
"github.com/pion/webrtc/v3"
"go.uber.org/atomic"
"github.com/livekit/protocol/livekit"
"github.com/livekit/livekit-server/pkg/rtc/types"
"github.com/livekit/livekit-server/pkg/sfu"
)
+4 -3
View File
@@ -8,8 +8,6 @@ import (
"github.com/bep/debounce"
"github.com/go-logr/logr"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/pion/interceptor"
"github.com/pion/interceptor/pkg/cc"
"github.com/pion/interceptor/pkg/gcc"
@@ -17,6 +15,9 @@ import (
"github.com/pion/sdp/v3"
"github.com/pion/webrtc/v3"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/livekit-server/pkg/config"
serverlogger "github.com/livekit/livekit-server/pkg/logger"
"github.com/livekit/livekit-server/pkg/rtc/types"
@@ -391,7 +392,7 @@ func (t *PCTransport) preparePC(previousAnswer webrtc.SessionDescription) error
//
// Simulate client side peer connection and set DTLS role from previous answer.
// Role needs to be set properly (one side needs to be server and the other side
// eeds to be the client) for DTLS connection to form properly. As this is
// needs to be the client) for DTLS connection to form properly. As this is
// trying to replicate previous setup, read from previous answer and use that role.
//
se := webrtc.SettingEngine{}
+2 -1
View File
@@ -4,11 +4,12 @@ import (
"testing"
"time"
"github.com/livekit/protocol/livekit"
"github.com/pion/webrtc/v3"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
"github.com/livekit/protocol/livekit"
"github.com/livekit/livekit-server/pkg/testutils"
)
+2 -1
View File
@@ -4,10 +4,11 @@ import (
"fmt"
"time"
"github.com/pion/webrtc/v3"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/pion/webrtc/v3"
"github.com/livekit/livekit-server/pkg/routing"
"github.com/livekit/livekit-server/pkg/sfu"
+2 -1
View File
@@ -3,9 +3,10 @@ package rtc
import (
"testing"
"github.com/livekit/protocol/livekit"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/livekit"
"github.com/livekit/livekit-server/pkg/rtc/types/typesfakes"
)
+2 -1
View File
@@ -7,9 +7,10 @@ import (
"strings"
"github.com/go-logr/logr"
"github.com/pion/webrtc/v3"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/pion/webrtc/v3"
"github.com/livekit/livekit-server/pkg/rtc/types"
)
+2 -1
View File
@@ -3,8 +3,9 @@ package rtc
import (
"testing"
"github.com/livekit/protocol/livekit"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/livekit"
)
func TestPackStreamId(t *testing.T) {