Skip to content

Commit a19432f

Browse files
authored
bump Golang to 1.23 (#610)
1 parent 01fd803 commit a19432f

File tree

22 files changed

+85
-58
lines changed

22 files changed

+85
-58
lines changed

.github/workflows/lint.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@ jobs:
1010
golangci-lint:
1111
runs-on: ubuntu-22.04
1212

13+
env:
14+
CGO_ENABLED: '0'
15+
1316
steps:
1417
- uses: actions/checkout@v4
1518

1619
- uses: actions/setup-go@v3
1720
with:
18-
go-version: "1.22"
21+
go-version: "1.23"
1922

2023
- uses: golangci/golangci-lint-action@v3
2124
with:
22-
version: v1.59.1
25+
version: v1.61.0
2326

2427
go-mod-tidy:
2528
runs-on: ubuntu-22.04
@@ -29,7 +32,7 @@ jobs:
2932

3033
- uses: actions/setup-go@v3
3134
with:
32-
go-version: "1.22"
35+
go-version: "1.23"
3336

3437
- run: |
3538
go mod tidy

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-22.04
1212
strategy:
1313
matrix:
14-
go: ["1.20", "1.21", "1.22"]
14+
go: ["1.21", "1.22", "1.23"]
1515

1616
steps:
1717
- uses: actions/checkout@v4
@@ -24,7 +24,7 @@ jobs:
2424

2525
- run: make test-nodocker
2626

27-
- if: matrix.go == '1.22'
27+
- if: matrix.go == '1.23'
2828
uses: codecov/codecov-action@v3
2929
with:
3030
token: ${{ secrets.CODECOV_TOKEN }}
@@ -37,7 +37,7 @@ jobs:
3737

3838
- uses: actions/setup-go@v3
3939
with:
40-
go-version: "1.22"
40+
go-version: "1.23"
4141

4242
- run: make test-highlevel-nodocker
4343

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
BASE_IMAGE = golang:1.22-alpine3.18
2-
LINT_IMAGE = golangci/golangci-lint:v1.59.1
1+
BASE_IMAGE = golang:1.23-alpine3.20
2+
LINT_IMAGE = golangci/golangci-lint:v1.61.0
33

44
.PHONY: $(shell ls)
55

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
RTSP 1.0 client and server library for the Go programming language, written for [MediaMTX](https://github.com/bluenviron/mediamtx).
1010

11-
Go ≥ 1.20 is required.
11+
Go ≥ 1.21 is required.
1212

1313
Features:
1414

client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ func (c *Client) PacketPTS(medi *description.Media, pkt *rtp.Packet) (time.Durat
19141914
return multiplyAndDivide(time.Duration(v), time.Second, time.Duration(ct.format.ClockRate())), true
19151915
}
19161916

1917-
// PacketPTS returns the PTS of an incoming RTP packet.
1917+
// PacketPTS2 returns the PTS of an incoming RTP packet.
19181918
// It is computed by decoding the packet timestamp and sychronizing it with other tracks.
19191919
func (c *Client) PacketPTS2(medi *description.Media, pkt *rtp.Packet) (int64, bool) {
19201920
cm := c.medias[medi]

client_udp_listener.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ func int64Ptr(v int64) *int64 {
1515
return &v
1616
}
1717

18-
func randInRange(max int) (int, error) {
19-
b := big.NewInt(int64(max + 1))
18+
func randInRange(maxVal int) (int, error) {
19+
b := big.NewInt(int64(maxVal + 1))
2020
n, err := rand.Int(rand.Reader, b)
2121
if err != nil {
2222
return 0, err

examples/client-play-format-h264-convert-to-jpeg/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build cgo
2+
// +build cgo
3+
14
package main
25

36
import (

examples/client-play-format-h264/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build cgo
2+
// +build cgo
3+
14
package main
25

36
import (

examples/client-play-format-h265-convert-to-jpeg/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build cgo
2+
// +build cgo
3+
14
package main
25

36
import (

examples/client-play-format-h265/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build cgo
2+
// +build cgo
3+
14
package main
25

36
import (

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/bluenviron/gortsplib/v4
22

3-
go 1.20
3+
go 1.21
44

55
require (
66
github.com/bluenviron/mediacommon v1.13.1

pkg/format/format_test.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,8 @@ var casesFormat = []struct {
743743
"s=\n" +
744744
"m=video 0 RTP/AVP 96\n" +
745745
"a=rtpmap:96 MP4V-ES/90000\n" +
746-
"a=fmtp:96 profile-level-id=1; config=000001B001000001B58913000001000000012000C48D8AEE053C04641443000001B24C61766335382E3133342E313030\n",
746+
"a=fmtp:96 profile-level-id=1; " +
747+
"config=000001B001000001B58913000001000000012000C48D8AEE053C04641443000001B24C61766335382E3133342E313030\n",
747748
&MPEG4Video{
748749
PayloadTyp: 96,
749750
ProfileLevelID: 1,
@@ -770,7 +771,8 @@ var casesFormat = []struct {
770771
"s=\n" +
771772
"m=video 0 RTP/AVP 96\n" +
772773
"a=rtpmap:96 H264/90000\n" +
773-
"a=fmtp:96 packetization-mode=1; profile-level-id=64000C; sprop-parameter-sets=Z2QADKw7ULBLQgAAAwACAAADAD0I,aO48gA==\n",
774+
"a=fmtp:96 packetization-mode=1; profile-level-id=64000C; " +
775+
"sprop-parameter-sets=Z2QADKw7ULBLQgAAAwACAAADAD0I,aO48gA==\n",
774776
&H264{
775777
PayloadTyp: 96,
776778
SPS: []byte{
@@ -797,7 +799,8 @@ var casesFormat = []struct {
797799
"s=\n" +
798800
"m=video 0 RTP/AVP 96\n" +
799801
"a=rtpmap:96 H264/90000\n" +
800-
"a=fmtp:96 packetization-mode=1; profile-level-id=64001f; sprop-parameter-sets=Z2QAH6zZQFAFuwFsgAAAAwCAAAAeB4wYyw==,aOvjyyLA\n",
802+
"a=fmtp:96 packetization-mode=1; profile-level-id=64001f; " +
803+
"sprop-parameter-sets=Z2QAH6zZQFAFuwFsgAAAAwCAAAAeB4wYyw==,aOvjyyLA\n",
801804
&H264{
802805
PayloadTyp: 96,
803806
SPS: []byte{
@@ -825,7 +828,8 @@ var casesFormat = []struct {
825828
"s=\n" +
826829
"m=video 0 RTP/AVP 96\n" +
827830
"a=rtpmap:96 H264/90000\n" +
828-
"a=fmtp:96 packetization-mode=1; profile-level-id=640029; sprop-parameter-sets=Z2QAKawTMUB4BEfeA+oCAgPgAAADACAAAAZSgA==,aPqPLA==,aF6jzAMA\n",
831+
"a=fmtp:96 packetization-mode=1; profile-level-id=640029; " +
832+
"sprop-parameter-sets=Z2QAKawTMUB4BEfeA+oCAgPgAAADACAAAAZSgA==,aPqPLA==,aF6jzAMA\n",
829833
&H264{
830834
PayloadTyp: 96,
831835
SPS: []byte{
@@ -870,7 +874,8 @@ var casesFormat = []struct {
870874
"s=\n" +
871875
"m=video 0 RTP/AVP 96\n" +
872876
"a=rtpmap:96 H264/90000\n" +
873-
"a=fmtp:96 packetization-mode=1; profile-level-id=4DE028; sprop-parameter-sets=AAAAAWdNAB6NjUBaHtCAAAOEAACvyAI=,AAAAAWjuOIA=\n",
877+
"a=fmtp:96 packetization-mode=1; profile-level-id=4DE028; " +
878+
"sprop-parameter-sets=AAAAAWdNAB6NjUBaHtCAAAOEAACvyAI=,AAAAAWjuOIA=\n",
874879
&H264{
875880
PayloadTyp: 96,
876881
SPS: []byte{
@@ -897,7 +902,8 @@ var casesFormat = []struct {
897902
"s=\n" +
898903
"m=video 0 RTP/AVP 96\n" +
899904
"a=rtpmap:96 H264/90000\n" +
900-
"a=fmtp:96 packetization-mode=1; profile-level-id=010101; sprop-parameter-sets=QgEBAWAAAAMAAAMAAAMAAAMAlqADwIAQ5Y2uSTJrlnAIAAADAAgAAAMAyEA=,RAHgdrAmQA==\n",
905+
"a=fmtp:96 packetization-mode=1; profile-level-id=010101; " +
906+
"sprop-parameter-sets=QgEBAWAAAAMAAAMAAAMAAAMAlqADwIAQ5Y2uSTJrlnAIAAADAAgAAAMAyEA=,RAHgdrAmQA==\n",
901907
&H264{
902908
PayloadTyp: 96,
903909
PacketizationMode: 1,
@@ -966,7 +972,8 @@ var casesFormat = []struct {
966972
"s=\n" +
967973
"m=video 0 RTP/AVP 96\n" +
968974
"a=rtpmap:96 H265/90000\n" +
969-
"a=fmtp:96 sprop-vps=QAEMAf//AWAAAAMAkAAAAwAAAwB4mZgJ; sprop-sps=QgEBAWAAAAMAkAAAAwAAAwB4oAPAgBDllmZpJMrgEAAAAwAQAAADAeCA; " +
975+
"a=fmtp:96 sprop-vps=QAEMAf//AWAAAAMAkAAAAwAAAwB4mZgJ; " +
976+
"sprop-sps=QgEBAWAAAAMAkAAAAwAAAwB4oAPAgBDllmZpJMrgEAAAAwAQAAADAeCA; " +
970977
"sprop-pps=RAHBcrRiQA==; sprop-max-don-diff=2\n",
971978
&H265{
972979
PayloadTyp: 96,
@@ -1003,7 +1010,8 @@ var casesFormat = []struct {
10031010
"s=\n" +
10041011
"m=video 0 RTP/AVP 96\n" +
10051012
"a=rtpmap:96 H265/90000\n" +
1006-
"a=fmtp:96 sprop-vps=AAAAAUABDAH//wFgAAADAAADAAADAAADAJasCQ==; sprop-sps=AAAAAUIBAQFgAAADAAADAAADAAADAJagBaIB4WNrkkya5Zk=; " +
1013+
"a=fmtp:96 sprop-vps=AAAAAUABDAH//wFgAAADAAADAAADAAADAJasCQ==; " +
1014+
"sprop-sps=AAAAAUIBAQFgAAADAAADAAADAAADAJagBaIB4WNrkkya5Zk=; " +
10071015
"sprop-pps=AAAAAUQB4HawJkA=\n",
10081016
&H265{
10091017
PayloadTyp: 96,
@@ -1224,7 +1232,7 @@ func FuzzUnmarshal(f *testing.F) {
12241232
err := desc.Unmarshal([]byte(in))
12251233

12261234
if err == nil && len(desc.MediaDescriptions) == 1 && len(desc.MediaDescriptions[0].MediaName.Formats) == 1 {
1227-
Unmarshal(desc.MediaDescriptions[0], desc.MediaDescriptions[0].MediaName.Formats[0])
1235+
Unmarshal(desc.MediaDescriptions[0], desc.MediaDescriptions[0].MediaName.Formats[0]) //nolint:errcheck
12281236
}
12291237
})
12301238
}

pkg/format/h264_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestH264DecEncoder(t *testing.T) {
6363
}
6464

6565
func FuzzH264PTSEqualsDTS(f *testing.F) {
66-
f.Fuzz(func(t *testing.T, b []byte) {
66+
f.Fuzz(func(_ *testing.T, b []byte) {
6767
(&H264{}).PTSEqualsDTS(&rtp.Packet{Payload: b})
6868
})
6969
}

pkg/format/h265_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestH265DecEncoder(t *testing.T) {
7272
}
7373

7474
func FuzzH265PTSEqualsDTS(f *testing.F) {
75-
f.Fuzz(func(t *testing.T, b []byte) {
75+
f.Fuzz(func(_ *testing.T, b []byte) {
7676
(&H265{}).PTSEqualsDTS(&rtp.Packet{Payload: b})
7777
})
7878
}

pkg/format/rtpav1/decoder.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ func (d *Decoder) decodeOBUs(pkt *rtp.Packet) ([][]byte, error) {
103103

104104
if d.fragmentsSize > av1.MaxTemporalUnitSize {
105105
d.resetFragments()
106-
return nil, fmt.Errorf("temporal unit size (%d) is too big, maximum is %d", d.fragmentsSize, av1.MaxTemporalUnitSize)
106+
return nil, fmt.Errorf("temporal unit size (%d) is too big, maximum is %d",
107+
d.fragmentsSize, av1.MaxTemporalUnitSize)
107108
}
108109

109110
d.fragments = append(d.fragments, av1header.OBUElements[elementCount-1])

pkg/format/rtpav1/decoder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestDecodeErrorMissingPacket(t *testing.T) {
6868
SequenceNumber: 17645,
6969
SSRC: 0x9dbb7812,
7070
},
71-
Payload: []byte{
71+
Payload: []byte{ //nolint:dupl
7272
0x40, 0xb1, 0x0b, 0x30, 0x30, 0xca, 0x08, 0x12,
7373
0xfd, 0xfd, 0x78, 0x89, 0xe5, 0x3e, 0xa3, 0x80,
7474
0x08, 0x20, 0x82, 0x08, 0x54, 0x50, 0x00, 0x30,

pkg/format/rtpav1/encoder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ var cases = []struct {
266266
SequenceNumber: 17645,
267267
SSRC: 0x9dbb7812,
268268
},
269-
Payload: []byte{
269+
Payload: []byte{ //nolint:dupl
270270
0x40, 0xb1, 0x0b, 0x30, 0x30, 0xca, 0x08, 0x12,
271271
0xfd, 0xfd, 0x78, 0x89, 0xe5, 0x3e, 0xa3, 0x80,
272272
0x08, 0x20, 0x82, 0x08, 0x54, 0x50, 0x00, 0x30,
@@ -523,7 +523,7 @@ var cases = []struct {
523523
SequenceNumber: 17645,
524524
SSRC: 0x9dbb7812,
525525
},
526-
Payload: []byte{
526+
Payload: []byte{ //nolint:dupl
527527
0x48, 0x10, 0x0a, 0x0e, 0x00, 0x00, 0x00, 0x4a,
528528
0xab, 0xbf, 0xc3, 0x77, 0x6b, 0xe4, 0x40, 0x40,
529529
0x40, 0x41, 0xa0, 0x0b, 0x30, 0x30, 0xca, 0x08,
@@ -717,7 +717,7 @@ var cases = []struct {
717717
SequenceNumber: 17646,
718718
SSRC: 0x9dbb7812,
719719
},
720-
Payload: []byte{
720+
Payload: []byte{ //nolint:dupl
721721
0xc0, 0xcc, 0x01, 0x9c, 0x6e, 0x5f, 0x2f, 0x20,
722722
0x78, 0x58, 0x59, 0x92, 0x15, 0xfe, 0x13, 0x07,
723723
0x87, 0xc7, 0x3e, 0x21, 0x04, 0x24, 0x33, 0x60,

pkg/format/rtpmpeg4audio/encoder_generic.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ func (e *Encoder) writeGenericFragmented(au []byte, timestamp uint32) ([]*rtp.Pa
8686

8787
// AU-headers
8888
pos := 0
89-
bits.WriteBits(payload[2:], &pos, uint64(le), e.SizeLength)
90-
bits.WriteBits(payload[2:], &pos, 0, e.IndexLength)
89+
bits.WriteBitsUnsafe(payload[2:], &pos, uint64(le), e.SizeLength)
90+
bits.WriteBitsUnsafe(payload[2:], &pos, 0, e.IndexLength)
9191

9292
// AU
9393
copy(payload[2+auHeadersLenBytes:], au)
@@ -153,13 +153,13 @@ func (e *Encoder) writeGenericAggregated(aus [][]byte, timestamp uint32) ([]*rtp
153153
written := 0
154154
pos := 0
155155
for i, au := range aus {
156-
bits.WriteBits(payload[2:], &pos, uint64(len(au)), e.SizeLength)
156+
bits.WriteBitsUnsafe(payload[2:], &pos, uint64(len(au)), e.SizeLength)
157157
written += e.SizeLength
158158
if i == 0 {
159-
bits.WriteBits(payload[2:], &pos, 0, e.IndexLength)
159+
bits.WriteBitsUnsafe(payload[2:], &pos, 0, e.IndexLength)
160160
written += e.IndexLength
161161
} else {
162-
bits.WriteBits(payload[2:], &pos, 0, e.IndexDeltaLength)
162+
bits.WriteBitsUnsafe(payload[2:], &pos, 0, e.IndexDeltaLength)
163163
written += e.IndexDeltaLength
164164
}
165165
}

pkg/headers/transport.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error {
189189
if v != "" {
190190
ip := net.ParseIP(v)
191191
if ip == nil {
192-
addrs, err := net.LookupHost(v)
193-
if err != nil {
192+
addrs, err2 := net.LookupHost(v)
193+
if err2 != nil {
194194
return fmt.Errorf("invalid source (%v)", v)
195195
}
196196
ip = net.ParseIP(addrs[0])
@@ -211,38 +211,38 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error {
211211
}
212212

213213
case "interleaved":
214-
ports, err := parsePorts(v)
215-
if err != nil {
216-
return err
214+
ports, err2 := parsePorts(v)
215+
if err2 != nil {
216+
return err2
217217
}
218218
h.InterleavedIDs = ports
219219

220220
case "ttl":
221-
tmp, err := strconv.ParseUint(v, 10, 32)
222-
if err != nil {
223-
return err
221+
tmp, err2 := strconv.ParseUint(v, 10, 32)
222+
if err2 != nil {
223+
return err2
224224
}
225225
vu := uint(tmp)
226226
h.TTL = &vu
227227

228228
case "port":
229-
ports, err := parsePorts(v)
230-
if err != nil {
231-
return err
229+
ports, err2 := parsePorts(v)
230+
if err2 != nil {
231+
return err2
232232
}
233233
h.Ports = ports
234234

235235
case "client_port":
236-
ports, err := parsePorts(v)
237-
if err != nil {
238-
return err
236+
ports, err2 := parsePorts(v)
237+
if err2 != nil {
238+
return err2
239239
}
240240
h.ClientPorts = ports
241241

242242
case "server_port":
243-
ports, err := parsePorts(v)
244-
if err != nil {
245-
return err
243+
ports, err2 := parsePorts(v)
244+
if err2 != nil {
245+
return err2
246246
}
247247
h.ServerPorts = ports
248248

@@ -253,7 +253,7 @@ func (h *Transport) Unmarshal(v base.HeaderValue) error {
253253
v = "0" + v
254254
}
255255

256-
if tmp, err := hex.DecodeString(v); err == nil && len(tmp) <= 4 {
256+
if tmp, err2 := hex.DecodeString(v); err2 == nil && len(tmp) <= 4 {
257257
var ssrc [4]byte
258258
copy(ssrc[4-len(tmp):], tmp)
259259
v := uint32(ssrc[0])<<24 | uint32(ssrc[1])<<16 | uint32(ssrc[2])<<8 | uint32(ssrc[3])

0 commit comments

Comments
 (0)