mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
TEST: Upgrade pion to v3.2.9. (#3567)
------ Co-authored-by: chundonglinlin <chundonglinlin@163.com>
This commit is contained in:
parent
104cf14d68
commit
df854339ea
1383 changed files with 118469 additions and 41421 deletions
19
trunk/3rdparty/srs-bench/vendor/github.com/pion/sctp/paramheader.go
generated
vendored
19
trunk/3rdparty/srs-bench/vendor/github.com/pion/sctp/paramheader.go
generated
vendored
|
@ -3,9 +3,8 @@ package sctp
|
|||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type paramHeader struct {
|
||||
|
@ -18,6 +17,14 @@ const (
|
|||
paramHeaderLength = 4
|
||||
)
|
||||
|
||||
// Parameter header parse errors
|
||||
var (
|
||||
ErrParamHeaderTooShort = errors.New("param header too short")
|
||||
ErrParamHeaderSelfReportedLengthShorter = errors.New("param self reported length is shorter than header length")
|
||||
ErrParamHeaderSelfReportedLengthLonger = errors.New("param self reported length is longer than header length")
|
||||
ErrParamHeaderParseFailed = errors.New("failed to parse param type")
|
||||
)
|
||||
|
||||
func (p *paramHeader) marshal() ([]byte, error) {
|
||||
paramLengthPlusHeader := paramHeaderLength + len(p.raw)
|
||||
|
||||
|
@ -31,20 +38,20 @@ func (p *paramHeader) marshal() ([]byte, error) {
|
|||
|
||||
func (p *paramHeader) unmarshal(raw []byte) error {
|
||||
if len(raw) < paramHeaderLength {
|
||||
return errors.New("param header too short")
|
||||
return ErrParamHeaderTooShort
|
||||
}
|
||||
|
||||
paramLengthPlusHeader := binary.BigEndian.Uint16(raw[2:])
|
||||
if int(paramLengthPlusHeader) < paramHeaderLength {
|
||||
return errors.Errorf("param self reported length (%d) smaller than header length (%d)", int(paramLengthPlusHeader), paramHeaderLength)
|
||||
return fmt.Errorf("%w: param self reported length (%d) shorter than header length (%d)", ErrParamHeaderSelfReportedLengthShorter, int(paramLengthPlusHeader), paramHeaderLength)
|
||||
}
|
||||
if len(raw) < int(paramLengthPlusHeader) {
|
||||
return errors.Errorf("param length (%d) shorter than its self reported length (%d)", len(raw), int(paramLengthPlusHeader))
|
||||
return fmt.Errorf("%w: param length (%d) shorter than its self reported length (%d)", ErrParamHeaderSelfReportedLengthLonger, len(raw), int(paramLengthPlusHeader))
|
||||
}
|
||||
|
||||
typ, err := parseParamType(raw[0:])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to parse param type")
|
||||
return fmt.Errorf("%w: %v", ErrParamHeaderParseFailed, err) //nolint:errorlint
|
||||
}
|
||||
p.typ = typ
|
||||
p.raw = raw[paramHeaderLength:paramLengthPlusHeader]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue