Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump Golang to 1.23 #610

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,7 +32,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: "1.22"
go-version: "1.23"

- run: |
go mod tidy
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -37,7 +37,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: "1.22"
go-version: "1.23"

- run: make test-highlevel-nodocker

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions client_udp_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions examples/client-play-format-h264-convert-to-jpeg/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build cgo
// +build cgo

package main

import (
Expand Down
3 changes: 3 additions & 0 deletions examples/client-play-format-h264/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build cgo
// +build cgo

package main

import (
Expand Down
3 changes: 3 additions & 0 deletions examples/client-play-format-h265-convert-to-jpeg/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build cgo
// +build cgo

package main

import (
Expand Down
3 changes: 3 additions & 0 deletions examples/client-play-format-h265/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build cgo
// +build cgo

package main

import (
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/bluenviron/gortsplib/v4

go 1.20
go 1.21

require (
github.com/bluenviron/mediacommon v1.13.1
Expand Down
26 changes: 17 additions & 9 deletions pkg/format/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
})
}
2 changes: 1 addition & 1 deletion pkg/format/h264_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
})
}
2 changes: 1 addition & 1 deletion pkg/format/h265_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
})
}
3 changes: 2 additions & 1 deletion pkg/format/rtpav1/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@

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)

Check warning on line 107 in pkg/format/rtpav1/decoder.go

View check run for this annotation

Codecov / codecov/patch

pkg/format/rtpav1/decoder.go#L106-L107

Added lines #L106 - L107 were not covered by tests
}

d.fragments = append(d.fragments, av1header.OBUElements[elementCount-1])
Expand Down
2 changes: 1 addition & 1 deletion pkg/format/rtpav1/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions pkg/format/rtpav1/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions pkg/format/rtpmpeg4audio/encoder_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
Expand Down
36 changes: 18 additions & 18 deletions pkg/headers/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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

Expand All @@ -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])
Expand Down
Loading
Loading