Source File
unwrapper.go
Belonging Package
github.com/pion/interceptor/internal/sequencenumber
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MIT// Package sequencenumber provides a sequence number unwrapperpackage sequencenumberconst (maxSequenceNumberPlusOne = int64(65536)breakpoint = 32768 // half of max uint16)// Unwrapper stores an unwrapped sequence number.type Unwrapper struct {init boollastUnwrapped int64}func isNewer(, uint16) bool {if - == breakpoint {return >}return != && (-) < breakpoint}// Unwrap unwraps the next sequencenumber.func ( *Unwrapper) ( uint16) int64 {if !.init {.init = true.lastUnwrapped = int64()return .lastUnwrapped}:= uint16(.lastUnwrapped) //nolint:gosec // G115:= int64( - )if isNewer(, ) {if < 0 {+= maxSequenceNumberPlusOne}} else if > 0 && .lastUnwrapped+-maxSequenceNumberPlusOne >= 0 {-= maxSequenceNumberPlusOne}.lastUnwrapped +=return .lastUnwrapped}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |