bump Golang to 1.23 (#610)

This commit is contained in:
Alessandro Ros
2024-11-04 13:39:10 +01:00
committed by GitHub
parent 01fd8033a2
commit a19432fd87
22 changed files with 85 additions and 58 deletions

View File

@@ -10,16 +10,19 @@ jobs:
golangci-lint:
runs-on: ubuntu-22.04
env:
CGO_ENABLED: '0'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: "1.22"
go-version: "1.23"
- uses: golangci/golangci-lint-action@v3
with:
version: v1.59.1
version: v1.61.0
go-mod-tidy:
runs-on: ubuntu-22.04
@@ -29,7 +32,7 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: "1.22"
go-version: "1.23"
- run: |
go mod tidy

View File

@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
go: ["1.20", "1.21", "1.22"]
go: ["1.21", "1.22", "1.23"]
steps:
- uses: actions/checkout@v4
@@ -24,7 +24,7 @@ jobs:
- run: make test-nodocker
- if: matrix.go == '1.22'
- if: matrix.go == '1.23'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
@@ -37,7 +37,7 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: "1.22"
go-version: "1.23"
- run: make test-highlevel-nodocker

View File

@@ -1,5 +1,5 @@
BASE_IMAGE = golang:1.22-alpine3.18
LINT_IMAGE = golangci/golangci-lint:v1.59.1
BASE_IMAGE = golang:1.23-alpine3.20
LINT_IMAGE = golangci/golangci-lint:v1.61.0
.PHONY: $(shell ls)

View File

@@ -8,7 +8,7 @@
RTSP 1.0 client and server library for the Go programming language, written for [MediaMTX](https://github.com/bluenviron/mediamtx).
Go ≥ 1.20 is required.
Go ≥ 1.21 is required.
Features:

View File

@@ -1914,7 +1914,7 @@ func (c *Client) PacketPTS(medi *description.Media, pkt *rtp.Packet) (time.Durat
return multiplyAndDivide(time.Duration(v), time.Second, time.Duration(ct.format.ClockRate())), true
}
// PacketPTS returns the PTS of an incoming RTP packet.
// PacketPTS2 returns the PTS of an incoming RTP packet.
// It is computed by decoding the packet timestamp and sychronizing it with other tracks.
func (c *Client) PacketPTS2(medi *description.Media, pkt *rtp.Packet) (int64, bool) {
cm := c.medias[medi]

View File

@@ -15,8 +15,8 @@ func int64Ptr(v int64) *int64 {
return &v
}
func randInRange(max int) (int, error) {
b := big.NewInt(int64(max + 1))
func randInRange(maxVal int) (int, error) {
b := big.NewInt(int64(maxVal + 1))
n, err := rand.Int(rand.Reader, b)
if err != nil {
return 0, err

View File

@@ -1,3 +1,6 @@
//go:build cgo
// +build cgo
package main
import (

View File

@@ -1,3 +1,6 @@
//go:build cgo
// +build cgo
package main
import (

View File

@@ -1,3 +1,6 @@
//go:build cgo
// +build cgo
package main
import (

View File

@@ -1,3 +1,6 @@
//go:build cgo
// +build cgo
package main
import (

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/bluenviron/gortsplib/v4
go 1.20
go 1.21
require (
github.com/bluenviron/mediacommon v1.13.1

View File

@@ -743,7 +743,8 @@ var casesFormat = []struct {
"s=\n" +
"m=video 0 RTP/AVP 96\n" +
"a=rtpmap:96 MP4V-ES/90000\n" +
"a=fmtp:96 profile-level-id=1; config=000001B001000001B58913000001000000012000C48D8AEE053C04641443000001B24C61766335382E3133342E313030\n",
"a=fmtp:96 profile-level-id=1; " +
"config=000001B001000001B58913000001000000012000C48D8AEE053C04641443000001B24C61766335382E3133342E313030\n",
&MPEG4Video{
PayloadTyp: 96,
ProfileLevelID: 1,
@@ -770,7 +771,8 @@ var casesFormat = []struct {
"s=\n" +
"m=video 0 RTP/AVP 96\n" +
"a=rtpmap:96 H264/90000\n" +
"a=fmtp:96 packetization-mode=1; profile-level-id=64000C; sprop-parameter-sets=Z2QADKw7ULBLQgAAAwACAAADAD0I,aO48gA==\n",
"a=fmtp:96 packetization-mode=1; profile-level-id=64000C; " +
"sprop-parameter-sets=Z2QADKw7ULBLQgAAAwACAAADAD0I,aO48gA==\n",
&H264{
PayloadTyp: 96,
SPS: []byte{
@@ -797,7 +799,8 @@ var casesFormat = []struct {
"s=\n" +
"m=video 0 RTP/AVP 96\n" +
"a=rtpmap:96 H264/90000\n" +
"a=fmtp:96 packetization-mode=1; profile-level-id=64001f; sprop-parameter-sets=Z2QAH6zZQFAFuwFsgAAAAwCAAAAeB4wYyw==,aOvjyyLA\n",
"a=fmtp:96 packetization-mode=1; profile-level-id=64001f; " +
"sprop-parameter-sets=Z2QAH6zZQFAFuwFsgAAAAwCAAAAeB4wYyw==,aOvjyyLA\n",
&H264{
PayloadTyp: 96,
SPS: []byte{
@@ -825,7 +828,8 @@ var casesFormat = []struct {
"s=\n" +
"m=video 0 RTP/AVP 96\n" +
"a=rtpmap:96 H264/90000\n" +
"a=fmtp:96 packetization-mode=1; profile-level-id=640029; sprop-parameter-sets=Z2QAKawTMUB4BEfeA+oCAgPgAAADACAAAAZSgA==,aPqPLA==,aF6jzAMA\n",
"a=fmtp:96 packetization-mode=1; profile-level-id=640029; " +
"sprop-parameter-sets=Z2QAKawTMUB4BEfeA+oCAgPgAAADACAAAAZSgA==,aPqPLA==,aF6jzAMA\n",
&H264{
PayloadTyp: 96,
SPS: []byte{
@@ -870,7 +874,8 @@ var casesFormat = []struct {
"s=\n" +
"m=video 0 RTP/AVP 96\n" +
"a=rtpmap:96 H264/90000\n" +
"a=fmtp:96 packetization-mode=1; profile-level-id=4DE028; sprop-parameter-sets=AAAAAWdNAB6NjUBaHtCAAAOEAACvyAI=,AAAAAWjuOIA=\n",
"a=fmtp:96 packetization-mode=1; profile-level-id=4DE028; " +
"sprop-parameter-sets=AAAAAWdNAB6NjUBaHtCAAAOEAACvyAI=,AAAAAWjuOIA=\n",
&H264{
PayloadTyp: 96,
SPS: []byte{
@@ -897,7 +902,8 @@ var casesFormat = []struct {
"s=\n" +
"m=video 0 RTP/AVP 96\n" +
"a=rtpmap:96 H264/90000\n" +
"a=fmtp:96 packetization-mode=1; profile-level-id=010101; sprop-parameter-sets=QgEBAWAAAAMAAAMAAAMAAAMAlqADwIAQ5Y2uSTJrlnAIAAADAAgAAAMAyEA=,RAHgdrAmQA==\n",
"a=fmtp:96 packetization-mode=1; profile-level-id=010101; " +
"sprop-parameter-sets=QgEBAWAAAAMAAAMAAAMAAAMAlqADwIAQ5Y2uSTJrlnAIAAADAAgAAAMAyEA=,RAHgdrAmQA==\n",
&H264{
PayloadTyp: 96,
PacketizationMode: 1,
@@ -966,7 +972,8 @@ var casesFormat = []struct {
"s=\n" +
"m=video 0 RTP/AVP 96\n" +
"a=rtpmap:96 H265/90000\n" +
"a=fmtp:96 sprop-vps=QAEMAf//AWAAAAMAkAAAAwAAAwB4mZgJ; sprop-sps=QgEBAWAAAAMAkAAAAwAAAwB4oAPAgBDllmZpJMrgEAAAAwAQAAADAeCA; " +
"a=fmtp:96 sprop-vps=QAEMAf//AWAAAAMAkAAAAwAAAwB4mZgJ; " +
"sprop-sps=QgEBAWAAAAMAkAAAAwAAAwB4oAPAgBDllmZpJMrgEAAAAwAQAAADAeCA; " +
"sprop-pps=RAHBcrRiQA==; sprop-max-don-diff=2\n",
&H265{
PayloadTyp: 96,
@@ -1003,7 +1010,8 @@ var casesFormat = []struct {
"s=\n" +
"m=video 0 RTP/AVP 96\n" +
"a=rtpmap:96 H265/90000\n" +
"a=fmtp:96 sprop-vps=AAAAAUABDAH//wFgAAADAAADAAADAAADAJasCQ==; sprop-sps=AAAAAUIBAQFgAAADAAADAAADAAADAJagBaIB4WNrkkya5Zk=; " +
"a=fmtp:96 sprop-vps=AAAAAUABDAH//wFgAAADAAADAAADAAADAJasCQ==; " +
"sprop-sps=AAAAAUIBAQFgAAADAAADAAADAAADAJagBaIB4WNrkkya5Zk=; " +
"sprop-pps=AAAAAUQB4HawJkA=\n",
&H265{
PayloadTyp: 96,
@@ -1224,7 +1232,7 @@ func FuzzUnmarshal(f *testing.F) {
err := desc.Unmarshal([]byte(in))
if err == nil && len(desc.MediaDescriptions) == 1 && len(desc.MediaDescriptions[0].MediaName.Formats) == 1 {
Unmarshal(desc.MediaDescriptions[0], desc.MediaDescriptions[0].MediaName.Formats[0])
Unmarshal(desc.MediaDescriptions[0], desc.MediaDescriptions[0].MediaName.Formats[0]) //nolint:errcheck
}
})
}

View File

@@ -63,7 +63,7 @@ func TestH264DecEncoder(t *testing.T) {
}
func FuzzH264PTSEqualsDTS(f *testing.F) {
f.Fuzz(func(t *testing.T, b []byte) {
f.Fuzz(func(_ *testing.T, b []byte) {
(&H264{}).PTSEqualsDTS(&rtp.Packet{Payload: b})
})
}

View File

@@ -72,7 +72,7 @@ func TestH265DecEncoder(t *testing.T) {
}
func FuzzH265PTSEqualsDTS(f *testing.F) {
f.Fuzz(func(t *testing.T, b []byte) {
f.Fuzz(func(_ *testing.T, b []byte) {
(&H265{}).PTSEqualsDTS(&rtp.Packet{Payload: b})
})
}

View File

@@ -103,7 +103,8 @@ func (d *Decoder) decodeOBUs(pkt *rtp.Packet) ([][]byte, error) {
if d.fragmentsSize > av1.MaxTemporalUnitSize {
d.resetFragments()
return nil, fmt.Errorf("temporal unit size (%d) is too big, maximum is %d", d.fragmentsSize, av1.MaxTemporalUnitSize)
return nil, fmt.Errorf("temporal unit size (%d) is too big, maximum is %d",
d.fragmentsSize, av1.MaxTemporalUnitSize)
}
d.fragments = append(d.fragments, av1header.OBUElements[elementCount-1])

View File

@@ -68,7 +68,7 @@ func TestDecodeErrorMissingPacket(t *testing.T) {
SequenceNumber: 17645,
SSRC: 0x9dbb7812,
},
Payload: []byte{
Payload: []byte{ //nolint:dupl
0x40, 0xb1, 0x0b, 0x30, 0x30, 0xca, 0x08, 0x12,
0xfd, 0xfd, 0x78, 0x89, 0xe5, 0x3e, 0xa3, 0x80,
0x08, 0x20, 0x82, 0x08, 0x54, 0x50, 0x00, 0x30,

View File

@@ -266,7 +266,7 @@ var cases = []struct {
SequenceNumber: 17645,
SSRC: 0x9dbb7812,
},
Payload: []byte{
Payload: []byte{ //nolint:dupl
0x40, 0xb1, 0x0b, 0x30, 0x30, 0xca, 0x08, 0x12,
0xfd, 0xfd, 0x78, 0x89, 0xe5, 0x3e, 0xa3, 0x80,
0x08, 0x20, 0x82, 0x08, 0x54, 0x50, 0x00, 0x30,
@@ -523,7 +523,7 @@ var cases = []struct {
SequenceNumber: 17645,
SSRC: 0x9dbb7812,
},
Payload: []byte{
Payload: []byte{ //nolint:dupl
0x48, 0x10, 0x0a, 0x0e, 0x00, 0x00, 0x00, 0x4a,
0xab, 0xbf, 0xc3, 0x77, 0x6b, 0xe4, 0x40, 0x40,
0x40, 0x41, 0xa0, 0x0b, 0x30, 0x30, 0xca, 0x08,
@@ -717,7 +717,7 @@ var cases = []struct {
SequenceNumber: 17646,
SSRC: 0x9dbb7812,
},
Payload: []byte{
Payload: []byte{ //nolint:dupl
0xc0, 0xcc, 0x01, 0x9c, 0x6e, 0x5f, 0x2f, 0x20,
0x78, 0x58, 0x59, 0x92, 0x15, 0xfe, 0x13, 0x07,
0x87, 0xc7, 0x3e, 0x21, 0x04, 0x24, 0x33, 0x60,

View File

@@ -86,8 +86,8 @@ func (e *Encoder) writeGenericFragmented(au []byte, timestamp uint32) ([]*rtp.Pa
// AU-headers
pos := 0
bits.WriteBits(payload[2:], &pos, uint64(le), e.SizeLength)
bits.WriteBits(payload[2:], &pos, 0, e.IndexLength)
bits.WriteBitsUnsafe(payload[2:], &pos, uint64(le), e.SizeLength)
bits.WriteBitsUnsafe(payload[2:], &pos, 0, e.IndexLength)
// AU
copy(payload[2+auHeadersLenBytes:], au)
@@ -153,13 +153,13 @@ func (e *Encoder) writeGenericAggregated(aus [][]byte, timestamp uint32) ([]*rtp
written := 0
pos := 0
for i, au := range aus {
bits.WriteBits(payload[2:], &pos, uint64(len(au)), e.SizeLength)
bits.WriteBitsUnsafe(payload[2:], &pos, uint64(len(au)), e.SizeLength)
written += e.SizeLength
if i == 0 {
bits.WriteBits(payload[2:], &pos, 0, e.IndexLength)
bits.WriteBitsUnsafe(payload[2:], &pos, 0, e.IndexLength)
written += e.IndexLength
} else {
bits.WriteBits(payload[2:], &pos, 0, e.IndexDeltaLength)
bits.WriteBitsUnsafe(payload[2:], &pos, 0, e.IndexDeltaLength)
written += e.IndexDeltaLength
}
}

View File

@@ -189,8 +189,8 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error {
if v != "" {
ip := net.ParseIP(v)
if ip == nil {
addrs, err := net.LookupHost(v)
if err != nil {
addrs, err2 := net.LookupHost(v)
if err2 != nil {
return fmt.Errorf("invalid source (%v)", v)
}
ip = net.ParseIP(addrs[0])
@@ -211,38 +211,38 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error {
}
case "interleaved":
ports, err := parsePorts(v)
if err != nil {
return err
ports, err2 := parsePorts(v)
if err2 != nil {
return err2
}
h.InterleavedIDs = ports
case "ttl":
tmp, err := strconv.ParseUint(v, 10, 32)
if err != nil {
return err
tmp, err2 := strconv.ParseUint(v, 10, 32)
if err2 != nil {
return err2
}
vu := uint(tmp)
h.TTL = &vu
case "port":
ports, err := parsePorts(v)
if err != nil {
return err
ports, err2 := parsePorts(v)
if err2 != nil {
return err2
}
h.Ports = ports
case "client_port":
ports, err := parsePorts(v)
if err != nil {
return err
ports, err2 := parsePorts(v)
if err2 != nil {
return err2
}
h.ClientPorts = ports
case "server_port":
ports, err := parsePorts(v)
if err != nil {
return err
ports, err2 := parsePorts(v)
if err2 != nil {
return err2
}
h.ServerPorts = ports
@@ -253,7 +253,7 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error {
v = "0" + v
}
if tmp, err := hex.DecodeString(v); err == nil && len(tmp) <= 4 {
if tmp, err2 := hex.DecodeString(v); err2 == nil && len(tmp) <= 4 {
var ssrc [4]byte
copy(ssrc[4-len(tmp):], tmp)
v := uint32(ssrc[0])<<24 | uint32(ssrc[1])<<16 | uint32(ssrc[2])<<8 | uint32(ssrc[3])

View File

@@ -3010,7 +3010,8 @@ var cases = []struct {
"m=video 0 RTP/AVP 96\r\n" +
"a=control:trackID=0\r\n" +
"a=rtpmap:96 H264/90000\r\n" +
"a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z00AMpY1QFEBf03AQEBAgA==,aO4xsg==; profile-level-id=4D0032\r\n" +
"a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z00AMpY1QFEBf03AQEBAgA==,aO4xsg==; " +
"profile-level-id=4D0032\r\n" +
"m=audio 0 RTP/AVP 14\r\n" +
"a=control:trackID=1\r\n" +
"m=text 0 RTP/AVP 103\r\n" +
@@ -3023,7 +3024,8 @@ var cases = []struct {
"m=video 0 RTP/AVP 96\r\n" +
"a=control:trackID=0\r\n" +
"a=rtpmap:96 H264/90000\r\n" +
"a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z00AMpY1QFEBf03AQEBAgA==,aO4xsg==; profile-level-id=4D0032\r\n" +
"a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z00AMpY1QFEBf03AQEBAgA==,aO4xsg==; " +
"profile-level-id=4D0032\r\n" +
"m=audio 0 RTP/AVP 14\r\n" +
"a=control:trackID=1\r\n" +
"m=text 0 RTP/AVP 103\r\n" +
@@ -3060,8 +3062,9 @@ var cases = []struct {
Value: "96 H264/90000",
},
{
Key: "fmtp",
Value: "96 packetization-mode=1; sprop-parameter-sets=Z00AMpY1QFEBf03AQEBAgA==,aO4xsg==; profile-level-id=4D0032",
Key: "fmtp",
Value: "96 packetization-mode=1; sprop-parameter-sets=Z00AMpY1QFEBf03AQEBAgA==,aO4xsg==; " +
"profile-level-id=4D0032",
},
},
},

View File

@@ -1,4 +1,5 @@
lint:
docker run --rm -v $(PWD):/app -w /app \
-e CGO_ENABLED=0 \
$(LINT_IMAGE) \
golangci-lint run -v

View File

@@ -206,8 +206,7 @@ func TestServerRecordErrorSetup(t *testing.T) {
var inTH *headers.Transport
switch ca.name {
case "invalid transport":
if ca.name == "invalid transport" {
inTH = &headers.Transport{
Delivery: deliveryPtr(headers.TransportDeliveryUnicast),
Mode: nil,