From d5c55a8ddcb4ac06e637dc3924b484f03ad38fd3 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Sat, 6 Nov 2021 13:30:43 +0100 Subject: [PATCH] move test into gortsplib --- go.mod | 2 +- go.sum | 4 +- internal/core/rtsp_server_test.go | 123 ------------------------------ 3 files changed, 3 insertions(+), 126 deletions(-) diff --git a/go.mod b/go.mod index fdc62bd4..1037bedb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.16 require ( github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect - github.com/aler9/gortsplib v0.0.0-20211106110157-ee767bfdefbe + github.com/aler9/gortsplib v0.0.0-20211106122816-6e38851a096e github.com/asticode/go-astits v1.10.0 github.com/fsnotify/fsnotify v1.4.9 github.com/gin-gonic/gin v1.7.2 diff --git a/go.sum b/go.sum index a1408478..2dbe8cfb 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/aler9/gortsplib v0.0.0-20211106110157-ee767bfdefbe h1:UuS+N7mG8uCvYGC92wR3OtFcys2keSeeMGkJgG5tWcM= -github.com/aler9/gortsplib v0.0.0-20211106110157-ee767bfdefbe/go.mod h1:fyQrQyHo8QvdR/h357tkv1g36VesZlzEPsdAu2VrHHc= +github.com/aler9/gortsplib v0.0.0-20211106122816-6e38851a096e h1:qSjVAaIvJukmEuLxV0agmQ5KmBabBK+jzb+eNqG3Z+w= +github.com/aler9/gortsplib v0.0.0-20211106122816-6e38851a096e/go.mod h1:fyQrQyHo8QvdR/h357tkv1g36VesZlzEPsdAu2VrHHc= github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927 h1:95mXJ5fUCYpBRdSOnLAQAdJHHKxxxJrVCiaqDi965YQ= github.com/aler9/rtmp v0.0.0-20210403095203-3be4a5535927/go.mod h1:vzuE21rowz+lT1NGsWbreIvYulgBpCGnQyeTyFblUHc= github.com/asticode/go-astikit v0.20.0 h1:+7N+J4E4lWx2QOkRdOf6DafWJMv6O4RRfgClwQokrH8= diff --git a/internal/core/rtsp_server_test.go b/internal/core/rtsp_server_test.go index 991dca73..5d64bebb 100644 --- a/internal/core/rtsp_server_test.go +++ b/internal/core/rtsp_server_test.go @@ -1,7 +1,6 @@ package core import ( - "bytes" "os" "testing" "time" @@ -467,128 +466,6 @@ func TestRTSPServerPublisherOverride(t *testing.T) { } } -func TestRTSPServerNonCompliantFrameSize(t *testing.T) { - t.Run("publish", func(t *testing.T) { - p, ok := newInstance( - "rtmpDisable: yes\n" + - "hlsDisable: yes\n" + - "readBufferSize: 4500\n" + - "paths:\n" + - " all:\n") - require.Equal(t, true, ok) - defer p.close() - - track, err := gortsplib.NewTrackH264(96, - &gortsplib.TrackConfigH264{SPS: []byte{0x01, 0x02, 0x03, 0x04}, PPS: []byte{0x01, 0x02, 0x03, 0x04}}) - require.NoError(t, err) - - client := &gortsplib.Client{ - Transport: func() *gortsplib.Transport { - v := gortsplib.TransportTCP - return &v - }(), - ReadBufferSize: 4500, - } - - source, err := client.DialPublish("rtsp://localhost:8554/teststream", - gortsplib.Tracks{track}) - require.NoError(t, err) - defer source.Close() - - dest, err := client.DialRead("rtsp://localhost:8554/teststream") - require.NoError(t, err) - defer dest.Close() - - input := bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04, 0x05}, 4096/5) - - readDone := make(chan struct{}) - frameRecv := make(chan struct{}) - go func() { - defer close(readDone) - dest.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { - require.Equal(t, gortsplib.StreamTypeRTP, streamType) - require.Equal(t, input, payload) - close(frameRecv) - }) - }() - - err = source.WriteFrame(0, gortsplib.StreamTypeRTP, input) - require.NoError(t, err) - - <-frameRecv - - dest.Close() - <-readDone - }) - - t.Run("proxy", func(t *testing.T) { - p1, ok := newInstance("rtmpDisable: yes\n" + - "hlsDisable: yes\n" + - "protocols: [tcp]\n" + - "readBufferSize: 4500\n" + - "paths:\n" + - " all:\n") - require.Equal(t, true, ok) - defer p1.close() - - track, err := gortsplib.NewTrackH264(96, - &gortsplib.TrackConfigH264{SPS: []byte{0x01, 0x02, 0x03, 0x04}, PPS: []byte{0x01, 0x02, 0x03, 0x04}}) - require.NoError(t, err) - - client := &gortsplib.Client{ - Transport: func() *gortsplib.Transport { - v := gortsplib.TransportTCP - return &v - }(), - ReadBufferSize: 4500, - } - - source, err := client.DialPublish("rtsp://localhost:8554/teststream", - gortsplib.Tracks{track}) - require.NoError(t, err) - defer source.Close() - - p2, ok := newInstance("rtmpDisable: yes\n" + - "hlsDisable: yes\n" + - "protocols: [tcp]\n" + - "readBufferSize: 4500\n" + - "rtspAddress: :8555\n" + - "paths:\n" + - " teststream:\n" + - " source: rtsp://localhost:8554/teststream\n" + - " sourceProtocol: tcp\n") - require.Equal(t, true, ok) - defer p2.close() - - time.Sleep(100 * time.Millisecond) - - dest, err := client.DialRead("rtsp://localhost:8555/teststream") - require.NoError(t, err) - defer dest.Close() - - input := bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04, 0x05}, 4096/5) - - readDone := make(chan struct{}) - frameRecv := make(chan struct{}) - go func() { - defer close(readDone) - dest.ReadFrames(func(trackID int, streamType gortsplib.StreamType, payload []byte) { - require.Equal(t, gortsplib.StreamTypeRTP, streamType) - require.Equal(t, input, payload) - close(frameRecv) - }) - }() - - err = source.WriteFrame(0, gortsplib.StreamTypeRTP, input) - require.NoError(t, err) - - <-frameRecv - - dest.Close() - <-readDone - }) -} - func TestRTSPServerRedirect(t *testing.T) { p1, ok := newInstance("rtmpDisable: yes\n" + "hlsDisable: yes\n" +