chore: pin GH commits and switch to golangci-lint (#4444)
* chore: pin GH commits * switch to golangci-lint-action * fix lint issues
This commit is contained in:
@@ -28,17 +28,17 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
- uses: shogo82148/actions-setup-redis@v1
|
- uses: shogo82148/actions-setup-redis@2f3253b148c73d7a0682eae73e862b777a4fa74e # v1
|
||||||
with:
|
with:
|
||||||
redis-version: "6.x"
|
redis-version: "6.x"
|
||||||
auto-start: true
|
auto-start: true
|
||||||
- run: redis-cli ping
|
- run: redis-cli ping
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
|
||||||
with:
|
with:
|
||||||
go-version: "^1.24"
|
go-version: "^1.25"
|
||||||
|
|
||||||
- name: Set up gotestfmt
|
- name: Set up gotestfmt
|
||||||
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@v2.4.1
|
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@v2.4.1
|
||||||
@@ -54,16 +54,15 @@ jobs:
|
|||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
- name: Mage Build
|
- name: Mage Build
|
||||||
uses: magefile/mage-action@v3
|
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b # v3
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: build
|
args: build
|
||||||
|
|
||||||
- name: Static Check
|
- name: Lint
|
||||||
uses: dominikh/staticcheck-action@v1
|
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
|
||||||
with:
|
with:
|
||||||
checks: '["all", "-ST1000", "-ST1003", "-ST1020", "-ST1021", "-ST1022", "-SA1019"]'
|
version: v2.11.4
|
||||||
install-go: false
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
@@ -72,7 +71,7 @@ jobs:
|
|||||||
|
|
||||||
# Upload the original go test log as an artifact for later review.
|
# Upload the original go test log as an artifact for later review.
|
||||||
- name: Upload test log
|
- name: Upload test log
|
||||||
uses: actions/upload-artifact@v6
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: test-log
|
name: test-log
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ jobs:
|
|||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
||||||
with:
|
with:
|
||||||
# list of Docker images to use as base name for tags
|
# list of Docker images to use as base name for tags
|
||||||
images: |
|
images: |
|
||||||
@@ -44,7 +44,7 @@ jobs:
|
|||||||
type=semver,pattern=v{{major}}.{{minor}}
|
type=semver,pattern=v{{major}}.{{minor}}
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
|
||||||
with:
|
with:
|
||||||
go-version-file: "go.mod"
|
go-version-file: "go.mod"
|
||||||
|
|
||||||
@@ -52,24 +52,24 @@ jobs:
|
|||||||
run: go mod download
|
run: go mod download
|
||||||
|
|
||||||
- name: Generate code
|
- name: Generate code
|
||||||
uses: magefile/mage-action@v3
|
uses: magefile/mage-action@6f50bbb8ea47d56e62dee92392788acbc8192d0b # v3
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: generate
|
args: generate
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
|||||||
@@ -28,17 +28,17 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
- name: Fetch all tags
|
- name: Fetch all tags
|
||||||
run: git fetch --force --tags
|
run: git fetch --force --tags
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v6
|
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
|
||||||
with:
|
with:
|
||||||
go-version-file: "go.mod"
|
go-version-file: "go.mod"
|
||||||
|
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v6
|
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
|
||||||
with:
|
with:
|
||||||
distribution: goreleaser
|
distribution: goreleaser
|
||||||
version: '~> v2'
|
version: '~> v2'
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
version: "2"
|
||||||
|
linters:
|
||||||
|
default: none
|
||||||
|
enable:
|
||||||
|
- staticcheck
|
||||||
|
settings:
|
||||||
|
staticcheck:
|
||||||
|
checks:
|
||||||
|
- "all"
|
||||||
|
- "-ST1000"
|
||||||
|
- "-ST1003"
|
||||||
|
- "-ST1020"
|
||||||
|
- "-ST1021"
|
||||||
|
- "-ST1022"
|
||||||
|
- "-SA1019"
|
||||||
|
- "-QF1008"
|
||||||
+1
-4
@@ -198,10 +198,7 @@ func getConfig(c *cli.Command) (*config.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
strictMode := true
|
strictMode := !c.Bool("disable-strict-config")
|
||||||
if c.Bool("disable-strict-config") {
|
|
||||||
strictMode = false
|
|
||||||
}
|
|
||||||
|
|
||||||
conf, err := config.NewConfig(confString, strictMode, c, baseFlags)
|
conf, err := config.NewConfig(confString, strictMode, c, baseFlags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -177,6 +177,14 @@ func TestAll() error {
|
|||||||
return mageutil.Run(context.Background(), "go test ./... -count=1 -timeout=4m -v")
|
return mageutil.Run(context.Background(), "go test ./... -count=1 -timeout=4m -v")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runs golangci-lint
|
||||||
|
func Lint() error {
|
||||||
|
if _, err := exec.LookPath("golangci-lint"); err != nil {
|
||||||
|
return errors.New("golangci-lint is not installed, install instructions: https://golangci-lint.run/docs/welcome/install/")
|
||||||
|
}
|
||||||
|
return mageutil.Run(context.Background(), "golangci-lint run ./...")
|
||||||
|
}
|
||||||
|
|
||||||
// cleans up builds
|
// cleans up builds
|
||||||
func Clean() {
|
func Clean() {
|
||||||
fmt.Println("cleaning...")
|
fmt.Println("cleaning...")
|
||||||
|
|||||||
@@ -640,7 +640,7 @@ func GenerateCLIFlags(existingFlags []cli.Flag, hidden bool) ([]cli.Flag, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
var flag cli.Flag
|
var flag cli.Flag
|
||||||
envVar := fmt.Sprintf("LIVEKIT_%s", strings.ToUpper(strings.Replace(name, ".", "_", -1)))
|
envVar := fmt.Sprintf("LIVEKIT_%s", strings.ToUpper(strings.ReplaceAll(name, ".", "_")))
|
||||||
defaultText := cliDefaultText(value)
|
defaultText := cliDefaultText(value)
|
||||||
|
|
||||||
switch kind {
|
switch kind {
|
||||||
|
|||||||
@@ -97,12 +97,12 @@ func (c ClientInfo) SupportsChangeRTPSenderEncodingActive() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c ClientInfo) ComplyWithCodecOrderInSDPAnswer() bool {
|
func (c ClientInfo) ComplyWithCodecOrderInSDPAnswer() bool {
|
||||||
return !((c.isLinux() || c.isAndroid()) && c.isFirefox())
|
return (!c.isLinux() && !c.isAndroid()) || !c.isFirefox()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rust SDK can't decode unknown signal message (TrackSubscribed and ErrorResponse)
|
// Rust SDK can't decode unknown signal message (TrackSubscribed and ErrorResponse)
|
||||||
func (c ClientInfo) SupportsTrackSubscribedEvent() bool {
|
func (c ClientInfo) SupportsTrackSubscribedEvent() bool {
|
||||||
return !(c.ClientInfo.GetSdk() == livekit.ClientInfo_RUST && c.ClientInfo.GetProtocol() < 10)
|
return c.ClientInfo.GetSdk() != livekit.ClientInfo_RUST || c.ClientInfo.GetProtocol() >= 10
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ClientInfo) SupportsRequestResponse() bool {
|
func (c ClientInfo) SupportsRequestResponse() bool {
|
||||||
@@ -110,8 +110,8 @@ func (c ClientInfo) SupportsRequestResponse() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c ClientInfo) SupportsSctpZeroChecksum() bool {
|
func (c ClientInfo) SupportsSctpZeroChecksum() bool {
|
||||||
return !(c.ClientInfo.GetSdk() == livekit.ClientInfo_UNKNOWN ||
|
return c.ClientInfo.GetSdk() != livekit.ClientInfo_UNKNOWN &&
|
||||||
(c.isGo() && c.compareVersion("2.4.0") < 0))
|
(!c.isGo() || c.compareVersion("2.4.0") >= 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// compareVersion compares a semver against the current client SDK version
|
// compareVersion compares a semver against the current client SDK version
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ import (
|
|||||||
|
|
||||||
func TestExtensionParticipantSid(t *testing.T) {
|
func TestExtensionParticipantSid(t *testing.T) {
|
||||||
longTestParticipantID := livekit.ParticipantID(make([]byte, 256))
|
longTestParticipantID := livekit.ParticipantID(make([]byte, 256))
|
||||||
extParticipantSid, err := NewExtensionParticipantSid(longTestParticipantID)
|
_, err := NewExtensionParticipantSid(longTestParticipantID)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
testParticipantID := livekit.ParticipantID("test")
|
testParticipantID := livekit.ParticipantID("test")
|
||||||
extParticipantSid, err = NewExtensionParticipantSid(testParticipantID)
|
extParticipantSid, err := NewExtensionParticipantSid(testParticipantID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
expectedExt := Extension{
|
expectedExt := Extension{
|
||||||
|
|||||||
+1
-1
@@ -2302,7 +2302,7 @@ func GetOtherParticipantInfo(
|
|||||||
|
|
||||||
pInfos := make([]*livekit.ParticipantInfo, 0, len(allParticipants))
|
pInfos := make([]*livekit.ParticipantInfo, 0, len(allParticipants))
|
||||||
for _, op := range allParticipants {
|
for _, op := range allParticipants {
|
||||||
if !(skipSubscriberBroadcast && op.CanSkipBroadcast()) &&
|
if (!skipSubscriberBroadcast || !op.CanSkipBroadcast()) &&
|
||||||
!op.Hidden() &&
|
!op.Hidden() &&
|
||||||
op.Identity() != lpIdentity &&
|
op.Identity() != lpIdentity &&
|
||||||
!isMigratingIn {
|
!isMigratingIn {
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ func (s *signalling) SignalSubscriptionPermissionUpdate(subscriptionPermissionUp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *signalling) SignalMediaSectionsRequirement(mediaSectionsRequirement *livekit.MediaSectionsRequirement) proto.Message {
|
func (s *signalling) SignalMediaSectionsRequirement(mediaSectionsRequirement *livekit.MediaSectionsRequirement) proto.Message {
|
||||||
return &livekit.SignalResponse{
|
return &livekit.SignalResponse{
|
||||||
Message: &livekit.SignalResponse_MediaSectionsRequirement{
|
Message: &livekit.SignalResponse_MediaSectionsRequirement{
|
||||||
MediaSectionsRequirement: mediaSectionsRequirement,
|
MediaSectionsRequirement: mediaSectionsRequirement,
|
||||||
@@ -237,7 +237,7 @@ func (s *signalling) SignalSubscribedAudioCodecUpdate(subscribedAudioCodecUpdate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *signalling) SignalPublishDataTrackResponse(publishDataTrackResponse *livekit.PublishDataTrackResponse) proto.Message {
|
func (s *signalling) SignalPublishDataTrackResponse(publishDataTrackResponse *livekit.PublishDataTrackResponse) proto.Message {
|
||||||
return &livekit.SignalResponse{
|
return &livekit.SignalResponse{
|
||||||
Message: &livekit.SignalResponse_PublishDataTrackResponse{
|
Message: &livekit.SignalResponse_PublishDataTrackResponse{
|
||||||
PublishDataTrackResponse: publishDataTrackResponse,
|
PublishDataTrackResponse: publishDataTrackResponse,
|
||||||
@@ -245,7 +245,7 @@ func (u *signalling) SignalPublishDataTrackResponse(publishDataTrackResponse *li
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *signalling) SignalUnpublishDataTrackResponse(unpublishDataTrackResponse *livekit.UnpublishDataTrackResponse) proto.Message {
|
func (s *signalling) SignalUnpublishDataTrackResponse(unpublishDataTrackResponse *livekit.UnpublishDataTrackResponse) proto.Message {
|
||||||
return &livekit.SignalResponse{
|
return &livekit.SignalResponse{
|
||||||
Message: &livekit.SignalResponse_UnpublishDataTrackResponse{
|
Message: &livekit.SignalResponse_UnpublishDataTrackResponse{
|
||||||
UnpublishDataTrackResponse: unpublishDataTrackResponse,
|
UnpublishDataTrackResponse: unpublishDataTrackResponse,
|
||||||
@@ -253,7 +253,7 @@ func (u *signalling) SignalUnpublishDataTrackResponse(unpublishDataTrackResponse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *signalling) SignalDataTrackSubscriberHandles(dataTrackSubscriberHandles *livekit.DataTrackSubscriberHandles) proto.Message {
|
func (s *signalling) SignalDataTrackSubscriberHandles(dataTrackSubscriberHandles *livekit.DataTrackSubscriberHandles) proto.Message {
|
||||||
return &livekit.SignalResponse{
|
return &livekit.SignalResponse{
|
||||||
Message: &livekit.SignalResponse_DataTrackSubscriberHandles{
|
Message: &livekit.SignalResponse_DataTrackSubscriberHandles{
|
||||||
DataTrackSubscriberHandles: dataTrackSubscriberHandles,
|
DataTrackSubscriberHandles: dataTrackSubscriberHandles,
|
||||||
|
|||||||
@@ -243,10 +243,7 @@ func TestUnsubscribe(t *testing.T) {
|
|||||||
sm.lock.RLock()
|
sm.lock.RLock()
|
||||||
subLen := len(sm.subscriptions)
|
subLen := len(sm.subscriptions)
|
||||||
sm.lock.RUnlock()
|
sm.lock.RUnlock()
|
||||||
if subLen != 0 {
|
return subLen == 0
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}, subSettleTimeout, subCheckInterval, "Track was not unsubscribed")
|
}, subSettleTimeout, subCheckInterval, "Track was not unsubscribed")
|
||||||
|
|
||||||
// no traces should be left
|
// no traces should be left
|
||||||
|
|||||||
@@ -2547,11 +2547,12 @@ func (t *PCTransport) createAndSendOffer(options *webrtc.OfferOptions) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when there's an ongoing negotiation, let it finish and not disrupt its state
|
// when there's an ongoing negotiation, let it finish and not disrupt its state
|
||||||
if t.negotiationState == transport.NegotiationStateRemote {
|
switch t.negotiationState {
|
||||||
|
case transport.NegotiationStateRemote:
|
||||||
t.params.Logger.Debugw("skipping negotiation, trying again later")
|
t.params.Logger.Debugw("skipping negotiation, trying again later")
|
||||||
t.setNegotiationState(transport.NegotiationStateRetry)
|
t.setNegotiationState(transport.NegotiationStateRetry)
|
||||||
return nil
|
return nil
|
||||||
} else if t.negotiationState == transport.NegotiationStateRetry {
|
case transport.NegotiationStateRetry:
|
||||||
// already set to retry, we can safely skip this attempt
|
// already set to retry, we can safely skip this attempt
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ func (s *LivekitServer) healthCheck(w http.ResponseWriter, _ *http.Request) {
|
|||||||
}
|
}
|
||||||
if time.Since(updatedAt) > 4*time.Second {
|
if time.Since(updatedAt) > 4*time.Second {
|
||||||
w.WriteHeader(http.StatusNotAcceptable)
|
w.WriteHeader(http.StatusNotAcceptable)
|
||||||
_, _ = w.Write([]byte(fmt.Sprintf("Not Ready\nNode Updated At %s", updatedAt)))
|
_, _ = fmt.Fprintf(w, "Not Ready\nNode Updated At %s", updatedAt)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ func (s *SignalServer) Start() error {
|
|||||||
return s.server.RegisterAllNodeTopics(s.nodeID)
|
return s.server.RegisterAllNodeTopics(s.nodeID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *SignalServer) Stop() {
|
func (s *SignalServer) Stop() {
|
||||||
r.server.Kill()
|
s.server.Kill()
|
||||||
}
|
}
|
||||||
|
|
||||||
type signalService struct {
|
type signalService struct {
|
||||||
|
|||||||
@@ -278,9 +278,10 @@ func IsH264KeyFrame(payload []byte) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
offset := 0
|
offset := 0
|
||||||
if nalu == 26 {
|
switch nalu {
|
||||||
|
case 26:
|
||||||
offset = 3
|
offset = 3
|
||||||
} else if nalu == 27 {
|
case 27:
|
||||||
offset = 4
|
offset = 4
|
||||||
}
|
}
|
||||||
if offset >= int(length) {
|
if offset >= int(length) {
|
||||||
@@ -426,10 +427,10 @@ func IsH265KeyFrame(payload []byte) (kf bool) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
naluType := (payload[0] & 0x7E) >> 1
|
naluType := (payload[0] & 0x7E) >> 1
|
||||||
switch {
|
switch naluType {
|
||||||
case naluType == 33 || naluType == 34:
|
case 33, 34:
|
||||||
return true
|
return true
|
||||||
case naluType == 48: // AP
|
case 48: // AP
|
||||||
idx := 2
|
idx := 2
|
||||||
for idx < len(payload)-2 {
|
for idx < len(payload)-2 {
|
||||||
// TODO: check the DONL field (controlled by sprop-max-don-diff)
|
// TODO: check the DONL field (controlled by sprop-max-don-diff)
|
||||||
@@ -446,7 +447,7 @@ func IsH265KeyFrame(payload []byte) (kf bool) {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
||||||
case naluType == 49: // FU
|
case 49: // FU
|
||||||
if len(payload) < 3 {
|
if len(payload) < 3 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ func NewSendSideBWE(params SendSideBWEParams) *SendSideBWE {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *SendSideBWE) Type() bwe.BWEType {
|
func (s *SendSideBWE) Type() bwe.BWEType {
|
||||||
return bwe.BWETypeSendSide
|
return bwe.BWETypeSendSide
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1581,7 +1581,7 @@ func TestForwarderGetTranslationParamsVideo(t *testing.T) {
|
|||||||
HeaderSize: 6,
|
HeaderSize: 6,
|
||||||
IsKeyFrame: true,
|
IsKeyFrame: true,
|
||||||
}
|
}
|
||||||
marshalledVP8, err := expectedVP8.Marshal()
|
marshalledVP8, _ := expectedVP8.Marshal()
|
||||||
expectedTP = TranslationParams{
|
expectedTP = TranslationParams{
|
||||||
isSwitching: true,
|
isSwitching: true,
|
||||||
isResuming: true,
|
isResuming: true,
|
||||||
|
|||||||
@@ -37,10 +37,7 @@ func NewForwardStats(latencyUpdateInterval, reportInterval, latencyWindowLength
|
|||||||
|
|
||||||
func (s *ForwardStats) Update(arrival, left int64) (int64, bool) {
|
func (s *ForwardStats) Update(arrival, left int64) (int64, bool) {
|
||||||
transit := left - arrival
|
transit := left - arrival
|
||||||
isHighForwardingLatency := false
|
isHighForwardingLatency := time.Duration(transit) > cHighForwardingLatency
|
||||||
if time.Duration(transit) > cHighForwardingLatency {
|
|
||||||
isHighForwardingLatency = true
|
|
||||||
}
|
|
||||||
|
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
s.latency.Update(time.Duration(arrival), float64(transit))
|
s.latency.Update(time.Duration(arrival), float64(transit))
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ func (r *rtxInfoReader) Read(b []byte, a interceptor.Attributes) (int, intercept
|
|||||||
go r.factory.SetStreamInfo(header.SSRC, mid, rid, rsid)
|
go r.factory.SetStreamInfo(header.SSRC, mid, rid, rsid)
|
||||||
} else {
|
} else {
|
||||||
// ignore padding only packet for probe count
|
// ignore padding only packet for probe count
|
||||||
if !(header.Padding && n-header.MarshalSize()-int(b[n-1]) == 0) {
|
if !header.Padding || n-header.MarshalSize()-int(b[n-1]) != 0 {
|
||||||
r.tryTimes--
|
r.tryTimes--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ func (u *unhandleSimulcastRTPReader) Read(b []byte, a interceptor.Attributes) (i
|
|||||||
return n, a, nil
|
return n, a, nil
|
||||||
} else {
|
} else {
|
||||||
// ignore padding only packet for probe count
|
// ignore padding only packet for probe count
|
||||||
if !(header.Padding && n-header.MarshalSize()-int(b[n-1]) == 0) {
|
if !header.Padding || n-header.MarshalSize()-int(b[n-1]) != 0 {
|
||||||
u.tryTimes--
|
u.tryTimes--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ func (l *LeakyBucket) Enqueue(p *Packet) {
|
|||||||
func (l *LeakyBucket) sendWorker() {
|
func (l *LeakyBucket) sendWorker() {
|
||||||
l.lock.RLock()
|
l.lock.RLock()
|
||||||
interval := l.interval
|
interval := l.interval
|
||||||
bitrate := l.bitrate
|
|
||||||
l.lock.RUnlock()
|
l.lock.RUnlock()
|
||||||
|
var bitrate int
|
||||||
|
|
||||||
timer := time.NewTimer(interval)
|
timer := time.NewTimer(interval)
|
||||||
overage := 0
|
overage := 0
|
||||||
|
|||||||
@@ -1161,10 +1161,10 @@ func (r *ReceiverBase) AddOnReady(fn func()) {
|
|||||||
fn()
|
fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *ReceiverBase) handleCodecChange(newCodec webrtc.RTPCodecParameters) {
|
func (r *ReceiverBase) handleCodecChange(newCodec webrtc.RTPCodecParameters) {
|
||||||
// codec fallback is not supported mid-session, i.e. change of codec via payload type change,
|
// codec fallback is not supported mid-session, i.e. change of codec via payload type change,
|
||||||
// set the codec state to invalid once it happens
|
// set the codec state to invalid once it happens
|
||||||
w.SetCodecState(ReceiverCodecStateInvalid)
|
r.SetCodecState(ReceiverCodecStateInvalid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ReceiverBase) AddOnCodecStateChange(f func(webrtc.RTPCodecParameters, ReceiverCodecState)) {
|
func (r *ReceiverBase) AddOnCodecStateChange(f func(webrtc.RTPCodecParameters, ReceiverCodecState)) {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ func (w *BitStreamWriter) writePartialByte(source uint8, sourceBitCount int, tar
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *BitStreamWriter) WriteNonSymmetric(val, numValues uint32) error {
|
func (w *BitStreamWriter) WriteNonSymmetric(val, numValues uint32) error {
|
||||||
if !(val < numValues && numValues <= 1<<31) {
|
if val >= numValues || numValues > 1<<31 {
|
||||||
return fmt.Errorf("invalid argument, val %d, numValues %d", val, numValues)
|
return fmt.Errorf("invalid argument, val %d, numValues %d", val, numValues)
|
||||||
}
|
}
|
||||||
if numValues == 1 {
|
if numValues == 1 {
|
||||||
|
|||||||
@@ -229,12 +229,13 @@ func (r *DependencyDescriptorReader) readTemplateLayers() error {
|
|||||||
}
|
}
|
||||||
nextLayerIdc = nextLayerIdcType(idc)
|
nextLayerIdc = nextLayerIdcType(idc)
|
||||||
|
|
||||||
if nextLayerIdc == nextTemporalLayer {
|
switch nextLayerIdc {
|
||||||
|
case nextTemporalLayer:
|
||||||
temporalId++
|
temporalId++
|
||||||
if temporalId >= MaxTemporalIds {
|
if temporalId >= MaxTemporalIds {
|
||||||
return ErrDDReaderTooManyTemporalLayers
|
return ErrDDReaderTooManyTemporalLayers
|
||||||
}
|
}
|
||||||
} else if nextLayerIdc == nextSpatialLayer {
|
case nextSpatialLayer:
|
||||||
spatialId++
|
spatialId++
|
||||||
temporalId = 0
|
temporalId = 0
|
||||||
if spatialId >= MaxSpatialIds {
|
if spatialId >= MaxSpatialIds {
|
||||||
@@ -242,7 +243,7 @@ func (r *DependencyDescriptorReader) readTemplateLayers() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(nextLayerIdc != noMoreLayer && r.buffer.Ok()) {
|
if nextLayerIdc == noMoreLayer || !r.buffer.Ok() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,8 +246,8 @@ func (w *DependencyDescriptorWriter) writeExtendedFields() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *DependencyDescriptorWriter) writeTemplateDependencyStructure() error {
|
func (w *DependencyDescriptorWriter) writeTemplateDependencyStructure() error {
|
||||||
if !(w.structure.StructureId >= 0 && w.structure.StructureId < MaxTemplates &&
|
if w.structure.StructureId < 0 || w.structure.StructureId >= MaxTemplates ||
|
||||||
w.structure.NumDecodeTargets > 0 && w.structure.NumDecodeTargets <= MaxDecodeTargets) {
|
w.structure.NumDecodeTargets <= 0 || w.structure.NumDecodeTargets > MaxDecodeTargets {
|
||||||
return fmt.Errorf("invalid arguments, structureId: %d, numDecodeTargets: %d", w.structure.StructureId, w.structure.NumDecodeTargets)
|
return fmt.Errorf("invalid arguments, structureId: %d, numDecodeTargets: %d", w.structure.StructureId, w.structure.NumDecodeTargets)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,8 +283,8 @@ func (w *DependencyDescriptorWriter) writeTemplateDependencyStructure() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *DependencyDescriptorWriter) writeTemplateLayers() error {
|
func (w *DependencyDescriptorWriter) writeTemplateLayers() error {
|
||||||
if !(len(w.structure.Templates) > 0 && len(w.structure.Templates) <= MaxTemplates &&
|
if len(w.structure.Templates) <= 0 || len(w.structure.Templates) > MaxTemplates ||
|
||||||
w.structure.Templates[0].SpatialId == 0 && w.structure.Templates[0].TemporalId == 0) {
|
w.structure.Templates[0].SpatialId != 0 || w.structure.Templates[0].TemporalId != 0 {
|
||||||
return fmt.Errorf("invalid templates, len %d, templates[0]: spatialId %d, temporalId %d", len(w.structure.Templates), w.structure.Templates[0].SpatialId, w.structure.Templates[0].TemporalId)
|
return fmt.Errorf("invalid templates, len %d, templates[0]: spatialId %d, temporalId %d", len(w.structure.Templates), w.structure.Templates[0].SpatialId, w.structure.Templates[0].TemporalId)
|
||||||
}
|
}
|
||||||
for i := 1; i < len(w.structure.Templates); i++ {
|
for i := 1; i < len(w.structure.Templates); i++ {
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ func TestSetLastSnTs(t *testing.T) {
|
|||||||
require.Equal(t, uint64(23332), r.extHighestIncomingSN)
|
require.Equal(t, uint64(23332), r.extHighestIncomingSN)
|
||||||
require.Equal(t, uint64(23333), r.extLastSN)
|
require.Equal(t, uint64(23333), r.extLastSN)
|
||||||
require.Equal(t, uint64(0xabcdef), r.extLastTS)
|
require.Equal(t, uint64(0xabcdef), r.extLastTS)
|
||||||
snOffset, err := r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
_, err = r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
snOffset, err = r.snRangeMap.GetValue(r.extLastSN)
|
snOffset, err := r.snRangeMap.GetValue(r.extLastSN)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, uint64(0), snOffset)
|
require.Equal(t, uint64(0), snOffset)
|
||||||
require.Equal(t, uint64(0), r.snOffset)
|
require.Equal(t, uint64(0), r.snOffset)
|
||||||
@@ -96,9 +96,9 @@ func TestPacketDropped(t *testing.T) {
|
|||||||
require.Equal(t, uint64(23332), r.extHighestIncomingSN)
|
require.Equal(t, uint64(23332), r.extHighestIncomingSN)
|
||||||
require.Equal(t, uint64(23333), r.extLastSN)
|
require.Equal(t, uint64(23333), r.extLastSN)
|
||||||
require.Equal(t, uint64(0xabcdef), r.extLastTS)
|
require.Equal(t, uint64(0xabcdef), r.extLastTS)
|
||||||
snOffset, err := r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
_, err := r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
snOffset, err = r.snRangeMap.GetValue(r.extLastSN)
|
snOffset, err := r.snRangeMap.GetValue(r.extLastSN)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, uint64(0), snOffset)
|
require.Equal(t, uint64(0), snOffset)
|
||||||
require.Equal(t, uint64(0), r.tsOffset)
|
require.Equal(t, uint64(0), r.tsOffset)
|
||||||
@@ -133,7 +133,7 @@ func TestPacketDropped(t *testing.T) {
|
|||||||
|
|
||||||
r.PacketDropped(extPkt)
|
r.PacketDropped(extPkt)
|
||||||
require.Equal(t, uint64(23333), r.extLastSN)
|
require.Equal(t, uint64(23333), r.extLastSN)
|
||||||
snOffset, err = r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
_, err = r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
snOffset, err = r.snRangeMap.GetValue(r.extHighestIncomingSN + 1)
|
snOffset, err = r.snRangeMap.GetValue(r.extHighestIncomingSN + 1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -180,9 +180,10 @@ func TestOutOfOrderSequenceNumber(t *testing.T) {
|
|||||||
}
|
}
|
||||||
extPkt, _ = testutils.GetTestExtPacket(params)
|
extPkt, _ = testutils.GetTestExtPacket(params)
|
||||||
|
|
||||||
tp, err := r.UpdateAndGetSnTs(extPkt, extPkt.Packet.Marker)
|
_, err = r.UpdateAndGetSnTs(extPkt, extPkt.Packet.Marker)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
|
var tp TranslationParamsRTP
|
||||||
// add a missing sequence number to the cache
|
// add a missing sequence number to the cache
|
||||||
err = r.snRangeMap.ExcludeRange(23334, 23335)
|
err = r.snRangeMap.ExcludeRange(23334, 23335)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -278,9 +279,10 @@ func TestPaddingOnlyPacket(t *testing.T) {
|
|||||||
require.Equal(t, tpExpected, tp)
|
require.Equal(t, tpExpected, tp)
|
||||||
require.Equal(t, uint64(23333), r.extHighestIncomingSN)
|
require.Equal(t, uint64(23333), r.extHighestIncomingSN)
|
||||||
require.Equal(t, uint64(23333), r.extLastSN)
|
require.Equal(t, uint64(23333), r.extLastSN)
|
||||||
snOffset, err := r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
_, err = r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
|
var snOffset uint64
|
||||||
// padding only packet with a gap should not report an error
|
// padding only packet with a gap should not report an error
|
||||||
params = &testutils.TestExtPacketParams{
|
params = &testutils.TestExtPacketParams{
|
||||||
SequenceNumber: 23335,
|
SequenceNumber: 23335,
|
||||||
@@ -370,7 +372,7 @@ func TestGapInSequenceNumber(t *testing.T) {
|
|||||||
require.Equal(t, tpExpected, tp)
|
require.Equal(t, tpExpected, tp)
|
||||||
require.Equal(t, uint64(65536+2), r.extHighestIncomingSN)
|
require.Equal(t, uint64(65536+2), r.extHighestIncomingSN)
|
||||||
require.Equal(t, uint64(65536+1), r.extLastSN)
|
require.Equal(t, uint64(65536+1), r.extLastSN)
|
||||||
snOffset, err = r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
_, err = r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
// a packet with a gap should be adjusting for dropped padding packet
|
// a packet with a gap should be adjusting for dropped padding packet
|
||||||
@@ -421,7 +423,7 @@ func TestGapInSequenceNumber(t *testing.T) {
|
|||||||
require.Equal(t, tpExpected, tp)
|
require.Equal(t, tpExpected, tp)
|
||||||
require.Equal(t, uint64(65536+5), r.extHighestIncomingSN)
|
require.Equal(t, uint64(65536+5), r.extHighestIncomingSN)
|
||||||
require.Equal(t, uint64(65536+3), r.extLastSN)
|
require.Equal(t, uint64(65536+3), r.extLastSN)
|
||||||
snOffset, err = r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
_, err = r.snRangeMap.GetValue(r.extHighestIncomingSN)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
// a packet with a gap should be adjusting for dropped packets
|
// a packet with a gap should be adjusting for dropped packets
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ func (r *rtpStatsBase) maybeAdjustFirstPacketTime(
|
|||||||
srData *livekit.RTCPSenderReportState,
|
srData *livekit.RTCPSenderReportState,
|
||||||
tsOffset uint64,
|
tsOffset uint64,
|
||||||
extStartTS uint64,
|
extStartTS uint64,
|
||||||
) (adjustment int64, err error, loggingFields []any) {
|
) (adjustment int64, loggingFields []any, err error) {
|
||||||
nowNano := mono.UnixNano()
|
nowNano := mono.UnixNano()
|
||||||
if time.Duration(nowNano-r.startTime) > cFirstPacketTimeAdjustWindow {
|
if time.Duration(nowNano-r.startTime) > cFirstPacketTimeAdjustWindow {
|
||||||
return
|
return
|
||||||
@@ -476,7 +476,7 @@ func (r *rtpStatsBase) deltaInfo(
|
|||||||
snapshotID uint32,
|
snapshotID uint32,
|
||||||
extStartSN uint64,
|
extStartSN uint64,
|
||||||
extHighestSN uint64,
|
extHighestSN uint64,
|
||||||
) (deltaInfo *RTPDeltaInfo, err error, loggingFields []any) {
|
) (deltaInfo *RTPDeltaInfo, loggingFields []any, err error) {
|
||||||
if r.clockRate == 0 {
|
if r.clockRate == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ func (r *rtpStatsBaseLite) deltaInfoLite(
|
|||||||
snapshotLiteID uint32,
|
snapshotLiteID uint32,
|
||||||
extStartSN uint64,
|
extStartSN uint64,
|
||||||
extHighestSN uint64,
|
extHighestSN uint64,
|
||||||
) (deltaInfoLite *RTPDeltaInfoLite, err error, loggingFields []any) {
|
) (deltaInfoLite *RTPDeltaInfoLite, loggingFields []any, err error) {
|
||||||
then, now := r.getAndResetSnapshotLite(snapshotLiteID, extStartSN, extHighestSN)
|
then, now := r.getAndResetSnapshotLite(snapshotLiteID, extStartSN, extHighestSN)
|
||||||
if now == nil || then == nil {
|
if now == nil || then == nil {
|
||||||
return
|
return
|
||||||
@@ -421,7 +421,7 @@ func (r *rtpStatsBaseLite) marshalLogObject(e zapcore.ObjectEncoder, packetsExpe
|
|||||||
if sb.Len() > 0 {
|
if sb.Len() > 0 {
|
||||||
sb.WriteString(", ")
|
sb.WriteString(", ")
|
||||||
}
|
}
|
||||||
sb.WriteString(fmt.Sprintf("%d:%d", burst+1, count))
|
fmt.Fprintf(&sb, "%d:%d", burst+1, count)
|
||||||
}
|
}
|
||||||
if sb.Len() > 0 {
|
if sb.Len() > 0 {
|
||||||
e.AddString("gapHistogram", "["+sb.String()+"]")
|
e.AddString("gapHistogram", "["+sb.String()+"]")
|
||||||
|
|||||||
@@ -804,7 +804,7 @@ func (r *RTPStatsReceiver) SetRtcpSenderReportData(srData *livekit.RTCPSenderRep
|
|||||||
r.updatePropagationDelayAndRecordSenderReport(srDataExt)
|
r.updatePropagationDelayAndRecordSenderReport(srDataExt)
|
||||||
r.checkRTPClockSkewAgainstMediaPathForSenderReport(srDataExt)
|
r.checkRTPClockSkewAgainstMediaPathForSenderReport(srDataExt)
|
||||||
|
|
||||||
adjustment, err, loggingFields := r.maybeAdjustFirstPacketTime(r.srNewest, 0, r.timestamp.GetExtendedStart())
|
adjustment, loggingFields, err := r.maybeAdjustFirstPacketTime(r.srNewest, 0, r.timestamp.GetExtendedStart())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.logger.Infow(err.Error(), append(loggingFields, "rtpStats", lockedRTPStatsReceiverLogEncoder{r})...)
|
r.logger.Infow(err.Error(), append(loggingFields, "rtpStats", lockedRTPStatsReceiverLogEncoder{r})...)
|
||||||
}
|
}
|
||||||
@@ -887,7 +887,7 @@ func (r *RTPStatsReceiver) DeltaInfo(snapshotID uint32) *RTPDeltaInfo {
|
|||||||
r.lock.Lock()
|
r.lock.Lock()
|
||||||
defer r.lock.Unlock()
|
defer r.lock.Unlock()
|
||||||
|
|
||||||
deltaInfo, err, loggingFields := r.deltaInfo(
|
deltaInfo, loggingFields, err := r.deltaInfo(
|
||||||
snapshotID,
|
snapshotID,
|
||||||
r.sequenceNumber.GetExtendedStart(),
|
r.sequenceNumber.GetExtendedStart(),
|
||||||
r.sequenceNumber.GetExtendedHighest(),
|
r.sequenceNumber.GetExtendedHighest(),
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ func (r *RTPStatsReceiverLite) DeltaInfoLite(snapshotLiteID uint32) *RTPDeltaInf
|
|||||||
r.lock.Lock()
|
r.lock.Lock()
|
||||||
defer r.lock.Unlock()
|
defer r.lock.Unlock()
|
||||||
|
|
||||||
deltaInfoLite, err, loggingFields := r.deltaInfoLite(
|
deltaInfoLite, loggingFields, err := r.deltaInfoLite(
|
||||||
snapshotLiteID,
|
snapshotLiteID,
|
||||||
r.sequenceNumber.GetExtendedStart(),
|
r.sequenceNumber.GetExtendedStart(),
|
||||||
r.sequenceNumber.GetExtendedHighest(),
|
r.sequenceNumber.GetExtendedHighest(),
|
||||||
|
|||||||
@@ -888,7 +888,7 @@ func (r *RTPStatsSender) MaybeAdjustFirstPacketTime(publisherSRData *livekit.RTC
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err, loggingFields := r.maybeAdjustFirstPacketTime(publisherSRData, tsOffset, r.extStartTS); err != nil {
|
if _, loggingFields, err := r.maybeAdjustFirstPacketTime(publisherSRData, tsOffset, r.extStartTS); err != nil {
|
||||||
r.logger.Infow(err.Error(), append(loggingFields, "rtpStats", lockedRTPStatsSenderLogEncoder{r})...)
|
r.logger.Infow(err.Error(), append(loggingFields, "rtpStats", lockedRTPStatsSenderLogEncoder{r})...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1024,7 +1024,7 @@ func (r *RTPStatsSender) DeltaInfo(snapshotID uint32) *RTPDeltaInfo {
|
|||||||
r.lock.Lock()
|
r.lock.Lock()
|
||||||
defer r.lock.Unlock()
|
defer r.lock.Unlock()
|
||||||
|
|
||||||
deltaInfo, err, loggingFields := r.deltaInfo(
|
deltaInfo, loggingFields, err := r.deltaInfo(
|
||||||
snapshotID,
|
snapshotID,
|
||||||
r.extStartSN,
|
r.extStartSN,
|
||||||
r.extHighestSN,
|
r.extHighestSN,
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func TestRangeMapUint32(t *testing.T) {
|
|||||||
require.Equal(t, uint32(1), value)
|
require.Equal(t, uint32(1), value)
|
||||||
|
|
||||||
// excluded range should return error
|
// excluded range should return error
|
||||||
value, err = r.GetValue(10)
|
_, err = r.GetValue(10)
|
||||||
require.ErrorIs(t, err, errKeyExcluded)
|
require.ErrorIs(t, err, errKeyExcluded)
|
||||||
|
|
||||||
// out-of-order exclusion should return error
|
// out-of-order exclusion should return error
|
||||||
@@ -98,11 +98,11 @@ func TestRangeMapUint32(t *testing.T) {
|
|||||||
require.Equal(t, expectedRanges, r.ranges)
|
require.Equal(t, expectedRanges, r.ranges)
|
||||||
|
|
||||||
// excluded range should return error, now is excluded because exclusion range could be extended
|
// excluded range should return error, now is excluded because exclusion range could be extended
|
||||||
value, err = r.GetValue(11)
|
_, err = r.GetValue(11)
|
||||||
require.ErrorIs(t, err, errKeyExcluded)
|
require.ErrorIs(t, err, errKeyExcluded)
|
||||||
|
|
||||||
// getting value in old range should return 0
|
// getting value in old range should return 0
|
||||||
value, err = r.GetValue(6)
|
_, err = r.GetValue(6)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// newer should return 2
|
// newer should return 2
|
||||||
@@ -129,7 +129,7 @@ func TestRangeMapUint32(t *testing.T) {
|
|||||||
require.Equal(t, expectedRanges, r.ranges)
|
require.Equal(t, expectedRanges, r.ranges)
|
||||||
|
|
||||||
// excluded range should return error, now is excluded because exclusion range could be extended
|
// excluded range should return error, now is excluded because exclusion range could be extended
|
||||||
value, err = r.GetValue(15)
|
_, err = r.GetValue(15)
|
||||||
require.ErrorIs(t, err, errKeyExcluded)
|
require.ErrorIs(t, err, errKeyExcluded)
|
||||||
|
|
||||||
// newer should return 12
|
// newer should return 12
|
||||||
@@ -190,15 +190,15 @@ func TestRangeMapUint32(t *testing.T) {
|
|||||||
require.Equal(t, expectedRanges, r.ranges)
|
require.Equal(t, expectedRanges, r.ranges)
|
||||||
|
|
||||||
// excluded range should return error
|
// excluded range should return error
|
||||||
value, err = r.GetValue(50)
|
_, err = r.GetValue(50)
|
||||||
require.ErrorIs(t, err, errKeyExcluded)
|
require.ErrorIs(t, err, errKeyExcluded)
|
||||||
value, err = r.GetValue(28)
|
_, err = r.GetValue(28)
|
||||||
require.ErrorIs(t, err, errKeyExcluded)
|
require.ErrorIs(t, err, errKeyExcluded)
|
||||||
value, err = r.GetValue(17)
|
_, err = r.GetValue(17)
|
||||||
require.ErrorIs(t, err, errKeyTooOld)
|
require.ErrorIs(t, err, errKeyTooOld)
|
||||||
|
|
||||||
// previously valid, but aged out key should return error
|
// previously valid, but aged out key should return error
|
||||||
value, err = r.GetValue(5)
|
_, err = r.GetValue(5)
|
||||||
require.ErrorIs(t, err, errKeyTooOld)
|
require.ErrorIs(t, err, errKeyTooOld)
|
||||||
|
|
||||||
// valid range access should return values
|
// valid range access should return values
|
||||||
@@ -279,7 +279,7 @@ func TestRangeMapUint32(t *testing.T) {
|
|||||||
require.Equal(t, expectedRanges, r.ranges)
|
require.Equal(t, expectedRanges, r.ranges)
|
||||||
|
|
||||||
// before first range access
|
// before first range access
|
||||||
value, err = r.GetValue(5)
|
_, err = r.GetValue(5)
|
||||||
require.ErrorIs(t, err, errKeyTooOld)
|
require.ErrorIs(t, err, errKeyTooOld)
|
||||||
|
|
||||||
// first range access
|
// first range access
|
||||||
@@ -319,7 +319,7 @@ func TestRangeMapUint32(t *testing.T) {
|
|||||||
require.Equal(t, expectedRanges, r.ranges)
|
require.Equal(t, expectedRanges, r.ranges)
|
||||||
|
|
||||||
// aged out range access
|
// aged out range access
|
||||||
value, err = r.GetValue(25)
|
_, err = r.GetValue(25)
|
||||||
require.ErrorIs(t, err, errKeyTooOld)
|
require.ErrorIs(t, err, errKeyTooOld)
|
||||||
|
|
||||||
// access closed range before decrementing value
|
// access closed range before decrementing value
|
||||||
|
|||||||
@@ -71,11 +71,11 @@ func (fc *FrameChain) OnFrame(extFrameNum uint64, fd *dd.FrameDependencyTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
var intact bool
|
var intact bool
|
||||||
switch {
|
switch sd {
|
||||||
case sd == selectorDecisionForwarded:
|
case selectorDecisionForwarded:
|
||||||
intact = true
|
intact = true
|
||||||
|
|
||||||
case sd == selectorDecisionUnknown:
|
case selectorDecisionUnknown:
|
||||||
// If the previous frame is unknown, means it has not arrived but could be recovered by NACK / out-of-order arrival,
|
// If the previous frame is unknown, means it has not arrived but could be recovered by NACK / out-of-order arrival,
|
||||||
// set up a expected callback here to determine if the chain is broken or intact
|
// set up a expected callback here to determine if the chain is broken or intact
|
||||||
if fc.decisions.ExpectDecision(prevFrameInChain, fc.OnExpectFrameChanged) {
|
if fc.decisions.ExpectDecision(prevFrameInChain, fc.OnExpectFrameChanged) {
|
||||||
|
|||||||
+3
-2
@@ -19,9 +19,10 @@ import "sort"
|
|||||||
// MedianFloat32 gets median value for an array of float32
|
// MedianFloat32 gets median value for an array of float32
|
||||||
func MedianFloat32(input []float32) float32 {
|
func MedianFloat32(input []float32) float32 {
|
||||||
num := len(input)
|
num := len(input)
|
||||||
if num == 0 {
|
switch num {
|
||||||
|
case 0:
|
||||||
return 0
|
return 0
|
||||||
} else if num == 1 {
|
case 1:
|
||||||
return input[0]
|
return input[0]
|
||||||
}
|
}
|
||||||
sort.Slice(input, func(i, j int) bool {
|
sort.Slice(input, func(i, j int) bool {
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
"extends": ["config:base"],
|
"extends": ["config:base", "helpers:pinGitHubActionDigests"],
|
||||||
|
"minimumReleaseAge": "2 weeks",
|
||||||
"commitBody": "Generated by renovateBot",
|
"commitBody": "Generated by renovateBot",
|
||||||
"packageRules": [
|
"packageRules": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,10 +66,8 @@ func (d *DataTrackRemote) PacketReceived(packet *datatrack.Packet) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
valid := true
|
valid := len(packet.Payload) != 0
|
||||||
if len(packet.Payload) == 0 {
|
|
||||||
valid = false
|
|
||||||
}
|
|
||||||
for i := range packet.Payload {
|
for i := range packet.Payload {
|
||||||
if packet.Payload[i] != byte(255-i) {
|
if packet.Payload[i] != byte(255-i) {
|
||||||
valid = false
|
valid = false
|
||||||
|
|||||||
Reference in New Issue
Block a user