Skip to content

Commit 9595e29

Browse files
committed
client: support reading with UDP-multicast
1 parent 54979e9 commit 9595e29

File tree

10 files changed

+356
-169
lines changed

10 files changed

+356
-169
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Features:
1616
* Client
1717
* Query servers about available streams
1818
* Read
19-
* Read streams from servers with UDP, TCP or TLS/RTSPS
19+
* Read streams from servers with UDP, UDP-multicast, TCP or TLS/RTSPS
2020
* Switch protocol automatically (switch to TCP in case of server error or UDP timeout)
2121
* Read only selected tracks of a stream
2222
* Pause or seek without disconnecting from the server
@@ -31,7 +31,7 @@ Features:
3131
* Sessions and connections are independent
3232
* Read streams from clients with UDP, TCP or TLS/RTSPS
3333
* Write streams to clients with UDP, UDP-multicast, TCP or TLS/RTSPS
34-
* Provide SSRC, RTP-Info automatically
34+
* Provide SSRC, RTP-Info to clients automatically
3535
* Generate RTCP receiver reports automatically
3636
* Utilities
3737
* Encode and decode RTSP primitives, RTP/H264, RTP/AAC, SDP

client.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ func DialPublish(address string, tracks Tracks) (*ClientConn, error) {
3535
return DefaultClient.DialPublish(address, tracks)
3636
}
3737

38+
// ClientProtocol is a RTSP stream protocol used by the client.
39+
type ClientProtocol int
40+
41+
// standard RTSP stream protocols.
42+
const (
43+
ClientProtocolUDP ClientProtocol = iota
44+
ClientProtocolMulticast
45+
ClientProtocolTCP
46+
)
47+
3848
// Client is a RTSP client.
3949
type Client struct {
4050
//
@@ -64,10 +74,10 @@ type Client struct {
6474
//
6575
// reading / writing
6676
//
67-
// the stream protocol (UDP or TCP).
77+
// the stream protocol (UDP, Multicast or TCP).
6878
// If nil, it is chosen automatically (first UDP, then, if it fails, TCP).
6979
// It defaults to nil.
70-
StreamProtocol *base.StreamProtocol
80+
Protocol *ClientProtocol
7181
// If the client is reading with UDP, it must receive
7282
// at least a packet within this timeout.
7383
// It defaults to 3 seconds.

client_publish_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ func TestClientPublishSerial(t *testing.T) {
162162
}()
163163

164164
c := &Client{
165-
StreamProtocol: func() *base.StreamProtocol {
165+
Protocol: func() *ClientProtocol {
166166
if proto == "udp" {
167-
v := base.StreamProtocolUDP
167+
v := ClientProtocolUDP
168168
return &v
169169
}
170-
v := base.StreamProtocolTCP
170+
v := ClientProtocolTCP
171171
return &v
172172
}(),
173173
}
@@ -304,12 +304,12 @@ func TestClientPublishParallel(t *testing.T) {
304304
}()
305305

306306
c := &Client{
307-
StreamProtocol: func() *base.StreamProtocol {
307+
Protocol: func() *ClientProtocol {
308308
if proto == "udp" {
309-
v := base.StreamProtocolUDP
309+
v := ClientProtocolUDP
310310
return &v
311311
}
312-
v := base.StreamProtocolTCP
312+
v := ClientProtocolTCP
313313
return &v
314314
}(),
315315
}
@@ -462,12 +462,12 @@ func TestClientPublishPauseSerial(t *testing.T) {
462462
}()
463463

464464
c := &Client{
465-
StreamProtocol: func() *base.StreamProtocol {
465+
Protocol: func() *ClientProtocol {
466466
if proto == "udp" {
467-
v := base.StreamProtocolUDP
467+
v := ClientProtocolUDP
468468
return &v
469469
}
470-
v := base.StreamProtocolTCP
470+
v := ClientProtocolTCP
471471
return &v
472472
}(),
473473
}
@@ -600,12 +600,12 @@ func TestClientPublishPauseParallel(t *testing.T) {
600600
}()
601601

602602
c := &Client{
603-
StreamProtocol: func() *base.StreamProtocol {
603+
Protocol: func() *ClientProtocol {
604604
if proto == "udp" {
605-
v := base.StreamProtocolUDP
605+
v := ClientProtocolUDP
606606
return &v
607607
}
608-
v := base.StreamProtocolTCP
608+
v := ClientProtocolTCP
609609
return &v
610610
}(),
611611
}
@@ -883,8 +883,8 @@ func TestClientPublishRTCPReport(t *testing.T) {
883883
}()
884884

885885
c := &Client{
886-
StreamProtocol: func() *base.StreamProtocol {
887-
v := base.StreamProtocolTCP
886+
Protocol: func() *ClientProtocol {
887+
v := ClientProtocolTCP
888888
return &v
889889
}(),
890890
senderReportPeriod: 1 * time.Second,

0 commit comments

Comments
 (0)