mirror of
https://github.com/bluenviron/mediamtx
synced 2025-02-20 21:46:56 +00:00
move test into gortsplib
This commit is contained in:
parent
9645d18ae4
commit
d5c55a8ddc
2
go.mod
2
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
|
||||
|
4
go.sum
4
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=
|
||||
|
@ -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" +
|
||||
|
Loading…
Reference in New Issue
Block a user