rtsp: support reading with VLC and multicast

This commit is contained in:
aler9 2021-11-15 17:55:45 +01:00
parent 99db6f245e
commit b4155a4fdf
4 changed files with 17 additions and 6 deletions

View File

@ -515,7 +515,7 @@ vlc --rtsp-tcp rtsp://localhost:8554/mystream
The RTSP protocol supports the UDP-multicast transport protocol, that allows a server to send packets once, regardless of the number of connected readers, saving bandwidth.
This mode must be requested by readers when handshaking with the server; once a reader has completed a handshake, the server will start sending multicast packets. Other readers will be instructed to pull the stream from the existing multicast packets. When all multicast readers have disconnected from the server, the latter will stop sending multicast packets.
This mode must be requested by readers when handshaking with the server; once a reader has completed a handshake, the server will start sending multicast packets. Other readers will be instructed to read existing multicast packets. When all multicast readers have disconnected from the server, the latter will stop sending multicast packets.
To request and read a stream with UDP-multicast, you can use _FFmpeg_:
@ -529,7 +529,11 @@ or _GStreamer_:
gst-launch-1.0 rtspsrc protocols=udp-mcast location=rtsps://ip:8555/...
```
At the moment _VLC_ doesn't support the UDP-multicast transport protocol. A workaround consists in launching an instance of _rtsp-simple-server_ on the same machine in which _VLC_ is running, using it for reading the stream with the proxy mode and UDP-multicast, and reading the proxied stream with _VLC_.
or _VLC_ (append `?vlcmulticast` to the URL):
```
vlc rtsp://localhost:8554/mystream?vlcmulticast
```
### Encryption

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/aler9/rtsp-simple-server
go 1.17
require (
github.com/aler9/gortsplib v0.0.0-20211113091354-ba7f9aff25cd
github.com/aler9/gortsplib v0.0.0-20211115164017-1411cb33f558
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
View File

@ -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-20211113091354-ba7f9aff25cd h1:/KEW7zhxd13haoMYkL5g1gOQTGUb+chRaqWkIx+BV6Y=
github.com/aler9/gortsplib v0.0.0-20211113091354-ba7f9aff25cd/go.mod h1:fyQrQyHo8QvdR/h357tkv1g36VesZlzEPsdAu2VrHHc=
github.com/aler9/gortsplib v0.0.0-20211115164017-1411cb33f558 h1:uyW1alIzoJCAmNZ2xuo5EOTbSbf9W7tVYOzb0UrzZ0U=
github.com/aler9/gortsplib v0.0.0-20211115164017-1411cb33f558/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=

View File

@ -23,6 +23,7 @@ func TestRTSPServerPublishRead(t *testing.T) {
{"ffmpeg", "udp", "gstreamer", "multicast"},
{"ffmpeg", "udp", "gstreamer", "tcp"},
{"ffmpeg", "udp", "vlc", "udp"},
{"ffmpeg", "udp", "vlc", "multicast"},
{"ffmpeg", "udp", "vlc", "tcp"},
{"ffmpeg", "tcp", "ffmpeg", "udp"},
{"gstreamer", "udp", "ffmpeg", "udp"},
@ -177,7 +178,13 @@ func TestRTSPServerPublishRead(t *testing.T) {
if ca.readerProto == "tcp" {
args = append(args, "--rtsp-tcp")
}
args = append(args, proto+"://localhost:"+port+"/teststream")
ur := proto + "://localhost:" + port + "/teststream"
if ca.readerProto == "multicast" {
ur += "?vlcmulticast"
}
args = append(args, ur)
cnt2, err := newContainer("vlc", "dest", args)
require.NoError(t, err)
defer cnt2.close()