support go 1.18

This commit is contained in:
aler9
2022-04-07 12:28:00 +02:00
committed by Alessandro Ros
parent 6c6c6c68c9
commit 9d12c345f8
15 changed files with 33 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ jobs:
- uses: golangci/golangci-lint-action@v2 - uses: golangci/golangci-lint-action@v2
with: with:
version: v1.44.2 version: v1.45.2
go-mod-tidy: go-mod-tidy:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@@ -24,6 +24,8 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-go@v2 - uses: actions/setup-go@v2
with:
go-version: "1.17"
- run: | - run: |
go mod download go mod download

View File

@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
go: ["1.15", "1.16", "1.17"] go: ["1.16", "1.17", "1.18"]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@@ -24,5 +24,5 @@ jobs:
- run: make test-nodocker - run: make test-nodocker
- if: matrix.go == '1.16' - if: matrix.go == '1.18'
run: bash <(curl -s https://codecov.io/bash) run: bash <(curl -s https://codecov.io/bash)

View File

@@ -1,6 +1,6 @@
BASE_IMAGE = golang:1.17-alpine3.14 BASE_IMAGE = golang:1.17-alpine3.14
LINT_IMAGE = golangci/golangci-lint:v1.44.2 LINT_IMAGE = golangci/golangci-lint:v1.45.2
.PHONY: $(shell ls) .PHONY: $(shell ls)
@@ -28,7 +28,7 @@ mod-tidy:
define DOCKERFILE_FORMAT define DOCKERFILE_FORMAT
FROM $(BASE_IMAGE) FROM $(BASE_IMAGE)
RUN go install mvdan.cc/gofumpt@v0.2.0 RUN go install mvdan.cc/gofumpt@v0.3.1
endef endef
export DOCKERFILE_FORMAT export DOCKERFILE_FORMAT

View File

@@ -9,7 +9,7 @@
RTSP 1.0 client and server library for the Go programming language, written for [rtsp-simple-server](https://github.com/aler9/rtsp-simple-server). RTSP 1.0 client and server library for the Go programming language, written for [rtsp-simple-server](https://github.com/aler9/rtsp-simple-server).
Go &ge; 1.15 is required. Go &ge; 1.16 is required.
Features: Features:

View File

@@ -1263,7 +1263,8 @@ func (c *Client) doSetup(
track Track, track Track,
baseURL *base.URL, baseURL *base.URL,
rtpPort int, rtpPort int,
rtcpPort int) (*base.Response, error) { rtcpPort int,
) (*base.Response, error) {
err := c.checkState(map[clientState]struct{}{ err := c.checkState(map[clientState]struct{}{
clientStateInitial: {}, clientStateInitial: {},
clientStatePrePlay: {}, clientStatePrePlay: {},
@@ -1578,7 +1579,8 @@ func (c *Client) Setup(
track Track, track Track,
baseURL *base.URL, baseURL *base.URL,
rtpPort int, rtpPort int,
rtcpPort int) (*base.Response, error) { rtcpPort int,
) (*base.Response, error) {
cres := make(chan clientRes) cres := make(chan clientRes)
select { select {
case c.setup <- setupReq{ case c.setup <- setupReq{

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/aler9/gortsplib module github.com/aler9/gortsplib
go 1.15 go 1.16
require ( require (
github.com/asticode/go-astits v1.10.0 github.com/asticode/go-astits v1.10.0

View File

@@ -48,7 +48,8 @@ type RTCPReceiver struct {
// New allocates a RTCPReceiver. // New allocates a RTCPReceiver.
func New(period time.Duration, receiverSSRC *uint32, clockRate int, func New(period time.Duration, receiverSSRC *uint32, clockRate int,
writePacketRTCP func(rtcp.Packet)) *RTCPReceiver { writePacketRTCP func(rtcp.Packet),
) *RTCPReceiver {
rr := &RTCPReceiver{ rr := &RTCPReceiver{
period: period, period: period,
receiverSSRC: func() uint32 { receiverSSRC: func() uint32 {

View File

@@ -32,7 +32,8 @@ type RTCPSender struct {
// New allocates a RTCPSender. // New allocates a RTCPSender.
func New(period time.Duration, clockRate int, func New(period time.Duration, clockRate int,
writePacketRTCP func(rtcp.Packet)) *RTCPSender { writePacketRTCP func(rtcp.Packet),
) *RTCPSender {
rs := &RTCPSender{ rs := &RTCPSender{
period: period, period: period,
clockRate: float64(clockRate), clockRate: float64(clockRate),

View File

@@ -22,7 +22,8 @@ import (
func writeReqReadRes(conn net.Conn, func writeReqReadRes(conn net.Conn,
br *bufio.Reader, br *bufio.Reader,
req base.Request) (*base.Response, error) { req base.Request,
) (*base.Response, error) {
var bb bytes.Buffer var bb bytes.Buffer
req.Write(&bb) req.Write(&bb)
_, err := conn.Write(bb.Bytes()) _, err := conn.Write(bb.Bytes())

View File

@@ -51,7 +51,8 @@ type ServerConn struct {
func newServerConn( func newServerConn(
s *Server, s *Server,
nconn net.Conn) *ServerConn { nconn net.Conn,
) *ServerConn {
ctx, ctxCancel := context.WithCancel(s.ctx) ctx, ctxCancel := context.WithCancel(s.ctx)
conn := func() net.Conn { conn := func() net.Conn {

View File

@@ -81,7 +81,8 @@ func newServerUDPListener(
s *Server, s *Server,
multicast bool, multicast bool,
address string, address string,
isRTP bool) (*serverUDPListener, error) { isRTP bool,
) (*serverUDPListener, error) {
var pc *net.UDPConn var pc *net.UDPConn
var listenIP net.IP var listenIP net.IP
if multicast { if multicast {

View File

@@ -24,7 +24,8 @@ type TrackAAC struct {
// NewTrackAAC allocates a TrackAAC. // NewTrackAAC allocates a TrackAAC.
func NewTrackAAC(payloadType uint8, typ int, sampleRate int, func NewTrackAAC(payloadType uint8, typ int, sampleRate int,
channelCount int, aotSpecificConfig []byte) (*TrackAAC, error) { channelCount int, aotSpecificConfig []byte,
) (*TrackAAC, error) {
mpegConf, err := aac.MPEG4AudioConfig{ mpegConf, err := aac.MPEG4AudioConfig{
Type: aac.MPEG4AudioType(typ), Type: aac.MPEG4AudioType(typ),
SampleRate: sampleRate, SampleRate: sampleRate,
@@ -48,7 +49,8 @@ func NewTrackAAC(payloadType uint8, typ int, sampleRate int,
func newTrackAACFromMediaDescription( func newTrackAACFromMediaDescription(
control string, control string,
payloadType uint8, payloadType uint8,
md *psdp.MediaDescription) (*TrackAAC, error) { md *psdp.MediaDescription,
) (*TrackAAC, error) {
v, ok := md.Attribute("fmtp") v, ok := md.Attribute("fmtp")
if !ok { if !ok {
return nil, fmt.Errorf("fmtp attribute is missing") return nil, fmt.Errorf("fmtp attribute is missing")

View File

@@ -87,7 +87,8 @@ func NewTrackGeneric(media string, formats []string, rtpmap string, fmtp string)
func newTrackGenericFromMediaDescription( func newTrackGenericFromMediaDescription(
control string, control string,
md *psdp.MediaDescription) (*TrackGeneric, error) { md *psdp.MediaDescription,
) (*TrackGeneric, error) {
rtpmap := func() string { rtpmap := func() string {
for _, attr := range md.Attributes { for _, attr := range md.Attributes {
if attr.Key == "rtpmap" { if attr.Key == "rtpmap" {

View File

@@ -80,7 +80,8 @@ func NewTrackH264(payloadType uint8, sps []byte, pps []byte, extradata []byte) (
func newTrackH264FromMediaDescription( func newTrackH264FromMediaDescription(
control string, control string,
payloadType uint8, payloadType uint8,
md *psdp.MediaDescription) (*TrackH264, error) { md *psdp.MediaDescription,
) (*TrackH264, error) {
t := &TrackH264{ t := &TrackH264{
trackBase: trackBase{ trackBase: trackBase{
control: control, control: control,

View File

@@ -29,7 +29,8 @@ func newTrackOpusFromMediaDescription(
control string, control string,
payloadType uint8, payloadType uint8,
rtpmapPart1 string, rtpmapPart1 string,
md *psdp.MediaDescription) (*TrackOpus, error) { md *psdp.MediaDescription,
) (*TrackOpus, error) {
tmp := strings.SplitN(rtpmapPart1, "/", 3) tmp := strings.SplitN(rtpmapPart1, "/", 3)
if len(tmp) != 3 { if len(tmp) != 3 {
return nil, fmt.Errorf("invalid rtpmap (%v)", rtpmapPart1) return nil, fmt.Errorf("invalid rtpmap (%v)", rtpmapPart1)