mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
update golangci-lint
This commit is contained in:
@@ -6,6 +6,7 @@ linters:
|
|||||||
- gochecknoinits
|
- gochecknoinits
|
||||||
- gocritic
|
- gocritic
|
||||||
- gofmt
|
- gofmt
|
||||||
|
- gofumpt
|
||||||
- golint
|
- golint
|
||||||
- misspell
|
- misspell
|
||||||
- prealloc
|
- prealloc
|
||||||
|
16
Makefile
16
Makefile
@@ -23,12 +23,20 @@ $(blank)
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
mod-tidy:
|
mod-tidy:
|
||||||
docker run --rm -it -v $(PWD):/s $(BASE_IMAGE) \
|
docker run --rm -it -v $(PWD):/s -w /s $(BASE_IMAGE) \
|
||||||
sh -c "apk add git && cd /s && GOPROXY=direct go get && go mod tidy"
|
sh -c "apk add git && GOPROXY=direct go get && go mod tidy"
|
||||||
|
|
||||||
|
define DOCKERFILE_FORMAT
|
||||||
|
FROM $(BASE_IMAGE)
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
RUN GO111MODULE=on go get mvdan.cc/gofumpt
|
||||||
|
endef
|
||||||
|
export DOCKERFILE_FORMAT
|
||||||
|
|
||||||
format:
|
format:
|
||||||
docker run --rm -it -v $(PWD):/s $(BASE_IMAGE) \
|
echo "$$DOCKERFILE_FORMAT" | docker build -q . -f - -t temp
|
||||||
sh -c "cd /s && find . -type f -name '*.go' | xargs gofmt -l -w -s"
|
docker run --rm -it -v $(PWD):/s -w /s temp \
|
||||||
|
sh -c "find . -type f -name '*.go' | xargs gofumpt -l -w"
|
||||||
|
|
||||||
define DOCKERFILE_TEST
|
define DOCKERFILE_TEST
|
||||||
FROM $(BASE_IMAGE)
|
FROM $(BASE_IMAGE)
|
||||||
|
@@ -141,7 +141,6 @@ func TestClientPublishSerial(t *testing.T) {
|
|||||||
IP: net.ParseIP("127.0.0.1"),
|
IP: net.ParseIP("127.0.0.1"),
|
||||||
Port: th.ClientPorts[1],
|
Port: th.ClientPorts[1],
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err = base.InterleavedFrame{
|
err = base.InterleavedFrame{
|
||||||
TrackID: 0,
|
TrackID: 0,
|
||||||
|
@@ -1112,7 +1112,8 @@ func (cc *ClientConn) doAnnounce(u *base.URL, tracks Tracks) (*base.Response, er
|
|||||||
|
|
||||||
if res.StatusCode != base.StatusOK {
|
if res.StatusCode != base.StatusOK {
|
||||||
return nil, liberrors.ErrClientWrongStatusCode{
|
return nil, liberrors.ErrClientWrongStatusCode{
|
||||||
Code: res.StatusCode, Message: res.StatusMessage}
|
Code: res.StatusCode, Message: res.StatusMessage,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cc.streamBaseURL = baseURL
|
cc.streamBaseURL = baseURL
|
||||||
@@ -1139,7 +1140,6 @@ func (cc *ClientConn) doSetup(
|
|||||||
track *Track,
|
track *Track,
|
||||||
rtpPort int,
|
rtpPort int,
|
||||||
rtcpPort int) (*base.Response, error) {
|
rtcpPort int) (*base.Response, error) {
|
||||||
|
|
||||||
err := cc.checkState(map[clientConnState]struct{}{
|
err := cc.checkState(map[clientConnState]struct{}{
|
||||||
clientConnStateInitial: {},
|
clientConnStateInitial: {},
|
||||||
clientConnStatePrePlay: {},
|
clientConnStatePrePlay: {},
|
||||||
@@ -1329,7 +1329,8 @@ func (cc *ClientConn) doSetup(
|
|||||||
if thRes.InterleavedIDs[0] != th.InterleavedIDs[0] ||
|
if thRes.InterleavedIDs[0] != th.InterleavedIDs[0] ||
|
||||||
thRes.InterleavedIDs[1] != th.InterleavedIDs[1] {
|
thRes.InterleavedIDs[1] != th.InterleavedIDs[1] {
|
||||||
return nil, liberrors.ErrClientTransportHeaderWrongInterleavedIDs{
|
return nil, liberrors.ErrClientTransportHeaderWrongInterleavedIDs{
|
||||||
Expected: *th.InterleavedIDs, Value: *thRes.InterleavedIDs}
|
Expected: *th.InterleavedIDs, Value: *thRes.InterleavedIDs,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1391,7 +1392,6 @@ func (cc *ClientConn) Setup(
|
|||||||
track *Track,
|
track *Track,
|
||||||
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 cc.setup <- setupReq{
|
case cc.setup <- setupReq{
|
||||||
@@ -1427,7 +1427,8 @@ func (cc *ClientConn) doPlay(isSwitchingProtocol bool) (*base.Response, error) {
|
|||||||
|
|
||||||
if res.StatusCode != base.StatusOK {
|
if res.StatusCode != base.StatusOK {
|
||||||
return nil, liberrors.ErrClientWrongStatusCode{
|
return nil, liberrors.ErrClientWrongStatusCode{
|
||||||
Code: res.StatusCode, Message: res.StatusMessage}
|
Code: res.StatusCode, Message: res.StatusMessage,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cc.state = clientConnStatePlay
|
cc.state = clientConnStatePlay
|
||||||
@@ -1484,7 +1485,8 @@ func (cc *ClientConn) doRecord() (*base.Response, error) {
|
|||||||
|
|
||||||
if res.StatusCode != base.StatusOK {
|
if res.StatusCode != base.StatusOK {
|
||||||
return nil, liberrors.ErrClientWrongStatusCode{
|
return nil, liberrors.ErrClientWrongStatusCode{
|
||||||
Code: res.StatusCode, Message: res.StatusMessage}
|
Code: res.StatusCode, Message: res.StatusMessage,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cc.state = clientConnStateRecord
|
cc.state = clientConnStateRecord
|
||||||
@@ -1534,7 +1536,8 @@ func (cc *ClientConn) doPause() (*base.Response, error) {
|
|||||||
|
|
||||||
if res.StatusCode != base.StatusOK {
|
if res.StatusCode != base.StatusOK {
|
||||||
return res, liberrors.ErrClientWrongStatusCode{
|
return res, liberrors.ErrClientWrongStatusCode{
|
||||||
Code: res.StatusCode, Message: res.StatusMessage}
|
Code: res.StatusCode, Message: res.StatusMessage,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch cc.state {
|
switch cc.state {
|
||||||
|
@@ -90,7 +90,6 @@ func (va *Validator) ValidateHeader(
|
|||||||
method base.Method,
|
method base.Method,
|
||||||
ur *base.URL,
|
ur *base.URL,
|
||||||
altURL *base.URL) error {
|
altURL *base.URL) error {
|
||||||
|
|
||||||
var auth headers.Authorization
|
var auth headers.Authorization
|
||||||
err := auth.Read(v)
|
err := auth.Read(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -61,7 +61,6 @@ func keyValParse(str string, separator byte) (map[string]string, error) {
|
|||||||
ret[k] = v
|
ret[k] = v
|
||||||
} else {
|
} else {
|
||||||
ret[k] = ""
|
ret[k] = ""
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,7 +108,6 @@ func (rr *RTCPReceiver) ProcessFrame(ts time.Time, streamType base.StreamType, b
|
|||||||
// ignore invalid frames (diff = 0) or reordered frames (diff < 0)
|
// ignore invalid frames (diff = 0) or reordered frames (diff < 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// we can afford to unmarshal all RTCP frames
|
// we can afford to unmarshal all RTCP frames
|
||||||
// since they are sent with a frequency much lower than the one of RTP frames
|
// since they are sent with a frequency much lower than the one of RTP frames
|
||||||
|
@@ -23,7 +23,7 @@ func TestRTCPReceiverBase(t *testing.T) {
|
|||||||
OctetCount: 859127,
|
OctetCount: 859127,
|
||||||
}
|
}
|
||||||
byts, _ := srPkt.Marshal()
|
byts, _ := srPkt.Marshal()
|
||||||
ts := time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
||||||
|
|
||||||
rtpPkt := rtp.Packet{
|
rtpPkt := rtp.Packet{
|
||||||
@@ -38,7 +38,7 @@ func TestRTCPReceiverBase(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
rtpPkt = rtp.Packet{
|
rtpPkt = rtp.Packet{
|
||||||
@@ -53,7 +53,7 @@ func TestRTCPReceiverBase(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 21, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
expectedPkt := rtcp.ReceiverReport{
|
expectedPkt := rtcp.ReceiverReport{
|
||||||
@@ -68,7 +68,7 @@ func TestRTCPReceiverBase(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected, _ := expectedPkt.Marshal()
|
expected, _ := expectedPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 22, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 22, 0, time.UTC)
|
||||||
require.Equal(t, expected, rr.Report(ts))
|
require.Equal(t, expected, rr.Report(ts))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ func TestRTCPReceiverOverflow(t *testing.T) {
|
|||||||
OctetCount: 859127,
|
OctetCount: 859127,
|
||||||
}
|
}
|
||||||
byts, _ := srPkt.Marshal()
|
byts, _ := srPkt.Marshal()
|
||||||
ts := time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
||||||
|
|
||||||
rtpPkt := rtp.Packet{
|
rtpPkt := rtp.Packet{
|
||||||
@@ -99,7 +99,7 @@ func TestRTCPReceiverOverflow(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
rtpPkt = rtp.Packet{
|
rtpPkt = rtp.Packet{
|
||||||
@@ -114,7 +114,7 @@ func TestRTCPReceiverOverflow(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
expectedPkt := rtcp.ReceiverReport{
|
expectedPkt := rtcp.ReceiverReport{
|
||||||
@@ -129,7 +129,7 @@ func TestRTCPReceiverOverflow(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected, _ := expectedPkt.Marshal()
|
expected, _ := expectedPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 21, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC)
|
||||||
require.Equal(t, expected, rr.Report(ts))
|
require.Equal(t, expected, rr.Report(ts))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ func TestRTCPReceiverPacketLost(t *testing.T) {
|
|||||||
OctetCount: 859127,
|
OctetCount: 859127,
|
||||||
}
|
}
|
||||||
byts, _ := srPkt.Marshal()
|
byts, _ := srPkt.Marshal()
|
||||||
ts := time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
||||||
|
|
||||||
rtpPkt := rtp.Packet{
|
rtpPkt := rtp.Packet{
|
||||||
@@ -160,7 +160,7 @@ func TestRTCPReceiverPacketLost(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
rtpPkt = rtp.Packet{
|
rtpPkt = rtp.Packet{
|
||||||
@@ -175,7 +175,7 @@ func TestRTCPReceiverPacketLost(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
expectedPkt := rtcp.ReceiverReport{
|
expectedPkt := rtcp.ReceiverReport{
|
||||||
@@ -195,7 +195,7 @@ func TestRTCPReceiverPacketLost(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected, _ := expectedPkt.Marshal()
|
expected, _ := expectedPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 21, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC)
|
||||||
require.Equal(t, expected, rr.Report(ts))
|
require.Equal(t, expected, rr.Report(ts))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ func TestRTCPReceiverOverflowPacketLost(t *testing.T) {
|
|||||||
OctetCount: 859127,
|
OctetCount: 859127,
|
||||||
}
|
}
|
||||||
byts, _ := srPkt.Marshal()
|
byts, _ := srPkt.Marshal()
|
||||||
ts := time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
||||||
|
|
||||||
rtpPkt := rtp.Packet{
|
rtpPkt := rtp.Packet{
|
||||||
@@ -226,7 +226,7 @@ func TestRTCPReceiverOverflowPacketLost(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
rtpPkt = rtp.Packet{
|
rtpPkt = rtp.Packet{
|
||||||
@@ -241,7 +241,7 @@ func TestRTCPReceiverOverflowPacketLost(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
expectedPkt := rtcp.ReceiverReport{
|
expectedPkt := rtcp.ReceiverReport{
|
||||||
@@ -261,7 +261,7 @@ func TestRTCPReceiverOverflowPacketLost(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected, _ := expectedPkt.Marshal()
|
expected, _ := expectedPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 21, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC)
|
||||||
require.Equal(t, expected, rr.Report(ts))
|
require.Equal(t, expected, rr.Report(ts))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ func TestRTCPReceiverReorderedPackets(t *testing.T) {
|
|||||||
OctetCount: 859127,
|
OctetCount: 859127,
|
||||||
}
|
}
|
||||||
byts, _ := srPkt.Marshal()
|
byts, _ := srPkt.Marshal()
|
||||||
ts := time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
||||||
|
|
||||||
rtpPkt := rtp.Packet{
|
rtpPkt := rtp.Packet{
|
||||||
@@ -292,7 +292,7 @@ func TestRTCPReceiverReorderedPackets(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
rtpPkt = rtp.Packet{
|
rtpPkt = rtp.Packet{
|
||||||
@@ -307,7 +307,7 @@ func TestRTCPReceiverReorderedPackets(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
expectedPkt := rtcp.ReceiverReport{
|
expectedPkt := rtcp.ReceiverReport{
|
||||||
@@ -322,7 +322,7 @@ func TestRTCPReceiverReorderedPackets(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected, _ := expectedPkt.Marshal()
|
expected, _ := expectedPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 21, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC)
|
||||||
require.Equal(t, expected, rr.Report(ts))
|
require.Equal(t, expected, rr.Report(ts))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ func TestRTCPReceiverJitter(t *testing.T) {
|
|||||||
OctetCount: 859127,
|
OctetCount: 859127,
|
||||||
}
|
}
|
||||||
byts, _ := srPkt.Marshal()
|
byts, _ := srPkt.Marshal()
|
||||||
ts := time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTCP, byts)
|
||||||
|
|
||||||
rtpPkt := rtp.Packet{
|
rtpPkt := rtp.Packet{
|
||||||
@@ -353,7 +353,7 @@ func TestRTCPReceiverJitter(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
rtpPkt = rtp.Packet{
|
rtpPkt = rtp.Packet{
|
||||||
@@ -368,7 +368,7 @@ func TestRTCPReceiverJitter(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 21, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 21, 0, time.UTC)
|
||||||
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rr.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
expectedPkt := rtcp.ReceiverReport{
|
expectedPkt := rtcp.ReceiverReport{
|
||||||
@@ -384,6 +384,6 @@ func TestRTCPReceiverJitter(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected, _ := expectedPkt.Marshal()
|
expected, _ := expectedPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 22, 0, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 22, 0, time.UTC)
|
||||||
require.Equal(t, expected, rr.Report(ts))
|
require.Equal(t, expected, rr.Report(ts))
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ func TestRTCPSender(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ := rtpPkt.Marshal()
|
byts, _ := rtpPkt.Marshal()
|
||||||
ts := time.Date(2008, 05, 20, 22, 15, 20, 0, time.UTC)
|
ts := time.Date(2008, 0o5, 20, 22, 15, 20, 0, time.UTC)
|
||||||
rs.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rs.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
rtpPkt = rtp.Packet{
|
rtpPkt = rtp.Packet{
|
||||||
@@ -41,7 +41,7 @@ func TestRTCPSender(t *testing.T) {
|
|||||||
Payload: []byte("\x00\x00"),
|
Payload: []byte("\x00\x00"),
|
||||||
}
|
}
|
||||||
byts, _ = rtpPkt.Marshal()
|
byts, _ = rtpPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 15, 20, 500000000, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 15, 20, 500000000, time.UTC)
|
||||||
rs.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
rs.ProcessFrame(ts, base.StreamTypeRTP, byts)
|
||||||
|
|
||||||
expectedPkt := rtcp.SenderReport{
|
expectedPkt := rtcp.SenderReport{
|
||||||
@@ -52,6 +52,6 @@ func TestRTCPSender(t *testing.T) {
|
|||||||
OctetCount: 4,
|
OctetCount: 4,
|
||||||
}
|
}
|
||||||
expected, _ := expectedPkt.Marshal()
|
expected, _ := expectedPkt.Marshal()
|
||||||
ts = time.Date(2008, 05, 20, 22, 16, 20, 600000000, time.UTC)
|
ts = time.Date(2008, 0o5, 20, 22, 16, 20, 600000000, time.UTC)
|
||||||
require.Equal(t, expected, rs.Report(ts))
|
require.Equal(t, expected, rs.Report(ts))
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,6 @@ func (e *Encoder) Encode(aus [][]byte, firstPTS time.Duration) ([][]byte, error)
|
|||||||
if e.lenAggregated(batch, au) <= rtpPayloadMaxSize {
|
if e.lenAggregated(batch, au) <= rtpPayloadMaxSize {
|
||||||
// add to existing batch
|
// add to existing batch
|
||||||
batch = append(batch, au)
|
batch = append(batch, au)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// write last batch
|
// write last batch
|
||||||
if batch != nil {
|
if batch != nil {
|
||||||
|
@@ -65,7 +65,6 @@ func (e *Encoder) Encode(nalus [][]byte, pts time.Duration) ([][]byte, error) {
|
|||||||
if e.lenAggregated(batch, nalu) <= rtpPayloadMaxSize {
|
if e.lenAggregated(batch, nalu) <= rtpPayloadMaxSize {
|
||||||
// add to existing batch
|
// add to existing batch
|
||||||
batch = append(batch, nalu)
|
batch = append(batch, nalu)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// write batch
|
// write batch
|
||||||
if batch != nil {
|
if batch != nil {
|
||||||
|
@@ -416,8 +416,10 @@ func (s *SessionDescription) unmarshalMediaDescription(value string) error {
|
|||||||
// Set according to currently registered with IANA
|
// Set according to currently registered with IANA
|
||||||
// https://tools.ietf.org/html/rfc4566#section-5.14
|
// https://tools.ietf.org/html/rfc4566#section-5.14
|
||||||
for _, proto := range strings.Split(fields[2], "/") {
|
for _, proto := range strings.Split(fields[2], "/") {
|
||||||
if i := indexOf(proto, []string{"UDP", "RTP", "AVP", "SAVP", "SAVPF",
|
if i := indexOf(proto, []string{
|
||||||
"MP2T", "TLS", "DTLS", "SCTP", "AVPF", "TCP"}); i == -1 {
|
"UDP", "RTP", "AVP", "SAVP", "SAVPF",
|
||||||
|
"MP2T", "TLS", "DTLS", "SCTP", "AVPF", "TCP",
|
||||||
|
}); i == -1 {
|
||||||
return fmt.Errorf("%w `%v`", errSDPInvalidNumericValue, fields[2])
|
return fmt.Errorf("%w `%v`", errSDPInvalidNumericValue, fields[2])
|
||||||
}
|
}
|
||||||
newMediaDesc.MediaName.Protos = append(newMediaDesc.MediaName.Protos, proto)
|
newMediaDesc.MediaName.Protos = append(newMediaDesc.MediaName.Protos, proto)
|
||||||
|
@@ -292,7 +292,6 @@ outer:
|
|||||||
case req := <-s.sessionRequest:
|
case req := <-s.sessionRequest:
|
||||||
if ss, ok := s.sessions[req.id]; ok {
|
if ss, ok := s.sessions[req.id]; ok {
|
||||||
ss.request <- req
|
ss.request <- req
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if !req.create {
|
if !req.create {
|
||||||
req.res <- requestRes{
|
req.res <- requestRes{
|
||||||
|
@@ -151,10 +151,12 @@ func newContainer(image string, name string, args []string) (*container, error)
|
|||||||
exec.Command("docker", "kill", "gortsplib-test-"+name).Run()
|
exec.Command("docker", "kill", "gortsplib-test-"+name).Run()
|
||||||
exec.Command("docker", "wait", "gortsplib-test-"+name).Run()
|
exec.Command("docker", "wait", "gortsplib-test-"+name).Run()
|
||||||
|
|
||||||
cmd := []string{"docker", "run",
|
cmd := []string{
|
||||||
|
"docker", "run",
|
||||||
"--network=host",
|
"--network=host",
|
||||||
"--name=gortsplib-test-" + name,
|
"--name=gortsplib-test-" + name,
|
||||||
"gortsplib-test-" + image}
|
"gortsplib-test-" + image,
|
||||||
|
}
|
||||||
cmd = append(cmd, args...)
|
cmd = append(cmd, args...)
|
||||||
ecmd := exec.Command(cmd[0], cmd[1:]...)
|
ecmd := exec.Command(cmd[0], cmd[1:]...)
|
||||||
ecmd.Stdout = nil
|
ecmd.Stdout = nil
|
||||||
|
@@ -69,7 +69,6 @@ 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)
|
||||||
|
|
||||||
sc := &ServerConn{
|
sc := &ServerConn{
|
||||||
@@ -536,9 +535,11 @@ func (sc *ServerConn) handleRequestOuter(req *base.Request) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *ServerConn) handleRequestInSession(sxID string, req *base.Request, create bool,
|
func (sc *ServerConn) handleRequestInSession(
|
||||||
|
sxID string,
|
||||||
|
req *base.Request,
|
||||||
|
create bool,
|
||||||
) (*ServerSession, *base.Response, error) {
|
) (*ServerSession, *base.Response, error) {
|
||||||
|
|
||||||
// if the session is already linked to this conn, communicate directly with it
|
// if the session is already linked to this conn, communicate directly with it
|
||||||
if sxID != "" {
|
if sxID != "" {
|
||||||
if ss, ok := sc.sessions[sxID]; ok {
|
if ss, ok := sc.sessions[sxID]; ok {
|
||||||
|
@@ -6,8 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ServerHandler is the interface implemented by all the server handlers.
|
// ServerHandler is the interface implemented by all the server handlers.
|
||||||
type ServerHandler interface {
|
type ServerHandler interface{}
|
||||||
}
|
|
||||||
|
|
||||||
// ServerHandlerOnConnOpenCtx is the context of a connection opening.
|
// ServerHandlerOnConnOpenCtx is the context of a connection opening.
|
||||||
type ServerHandlerOnConnOpenCtx struct {
|
type ServerHandlerOnConnOpenCtx struct {
|
||||||
|
@@ -19,11 +19,11 @@ const (
|
|||||||
serverSessionCheckStreamPeriod = 1 * time.Second
|
serverSessionCheckStreamPeriod = 1 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupGetTrackIDPathQuery(url *base.URL,
|
func setupGetTrackIDPathQuery(
|
||||||
|
url *base.URL,
|
||||||
thMode *headers.TransportMode,
|
thMode *headers.TransportMode,
|
||||||
announcedTracks []ServerSessionAnnouncedTrack,
|
announcedTracks []ServerSessionAnnouncedTrack,
|
||||||
setupPath *string, setupQuery *string) (int, string, string, error) {
|
setupPath *string, setupQuery *string) (int, string, string, error) {
|
||||||
|
|
||||||
pathAndQuery, ok := url.RTSPPathAndQuery()
|
pathAndQuery, ok := url.RTSPPathAndQuery()
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, "", "", liberrors.ErrServerInvalidPath{}
|
return 0, "", "", liberrors.ErrServerInvalidPath{}
|
||||||
@@ -143,7 +143,6 @@ func newServerSession(
|
|||||||
id string,
|
id string,
|
||||||
author *ServerConn,
|
author *ServerConn,
|
||||||
) *ServerSession {
|
) *ServerSession {
|
||||||
|
|
||||||
ctx, ctxCancel := context.WithCancel(s.ctx)
|
ctx, ctxCancel := context.WithCancel(s.ctx)
|
||||||
|
|
||||||
ss := &ServerSession{
|
ss := &ServerSession{
|
||||||
@@ -575,7 +574,8 @@ func (ss *ServerSession) handleRequest(sc *ServerConn, req *base.Request) (*base
|
|||||||
return &base.Response{
|
return &base.Response{
|
||||||
StatusCode: base.StatusBadRequest,
|
StatusCode: base.StatusBadRequest,
|
||||||
}, liberrors.ErrServerTransportHeaderWrongInterleavedIDs{
|
}, liberrors.ErrServerTransportHeaderWrongInterleavedIDs{
|
||||||
Expected: [2]int{(trackID * 2), (1 + trackID*2)}, Value: *inTH.InterleavedIDs}
|
Expected: [2]int{(trackID * 2), (1 + trackID*2)}, Value: *inTH.InterleavedIDs,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,7 +911,6 @@ func (ss *ServerSession) WriteFrame(trackID int, streamType StreamType, payload
|
|||||||
Zone: ss.udpZone,
|
Zone: ss.udpZone,
|
||||||
Port: track.udpRTPPort,
|
Port: track.udpRTPPort,
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ss.s.udpRTCPListener.write(payload, &net.UDPAddr{
|
ss.s.udpRTCPListener.write(payload, &net.UDPAddr{
|
||||||
IP: ss.udpIP,
|
IP: ss.udpIP,
|
||||||
|
@@ -61,7 +61,6 @@ func newServerUDPListener(
|
|||||||
s *Server,
|
s *Server,
|
||||||
address string,
|
address string,
|
||||||
streamType StreamType) (*serverUDPListener, error) {
|
streamType StreamType) (*serverUDPListener, error) {
|
||||||
|
|
||||||
tmp, err := s.ListenPacket("udp", address)
|
tmp, err := s.ListenPacket("udp", address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user