mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 23:26:54 +08:00
remove ConnClient.CloseUDPListeners
This commit is contained in:
@@ -184,17 +184,6 @@ func (c *ConnClient) checkState(allowed map[connClientState]struct{}) error {
|
|||||||
allowed, c.state)
|
allowed, c.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloseUDPListeners closes any open UDP listener.
|
|
||||||
func (c *ConnClient) CloseUDPListeners() {
|
|
||||||
for _, l := range c.udpRtpListeners {
|
|
||||||
l.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, l := range c.udpRtcpListeners {
|
|
||||||
l.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetConn returns the underlying net.Conn.
|
// NetConn returns the underlying net.Conn.
|
||||||
func (c *ConnClient) NetConn() net.Conn {
|
func (c *ConnClient) NetConn() net.Conn {
|
||||||
return c.conf.Conn
|
return c.conf.Conn
|
||||||
|
@@ -79,13 +79,13 @@ func TestDialReadUDP(t *testing.T) {
|
|||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
|
loopDone := make(chan struct{})
|
||||||
|
defer func() { <-loopDone }()
|
||||||
|
|
||||||
conn, err := DialRead("rtsp://localhost:8554/teststream", StreamProtocolUDP)
|
conn, err := DialRead("rtsp://localhost:8554/teststream", StreamProtocolUDP)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
loopDone := make(chan struct{})
|
|
||||||
defer func() { <-loopDone }()
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(loopDone)
|
defer close(loopDone)
|
||||||
conn.LoopUDP()
|
conn.LoopUDP()
|
||||||
@@ -93,8 +93,6 @@ func TestDialReadUDP(t *testing.T) {
|
|||||||
|
|
||||||
_, err = conn.ReadFrameUDP(0, StreamTypeRtp)
|
_, err = conn.ReadFrameUDP(0, StreamTypeRtp)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
conn.CloseUDPListeners()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDialReadTCP(t *testing.T) {
|
func TestDialReadTCP(t *testing.T) {
|
||||||
@@ -156,13 +154,13 @@ func TestDialReadRedirect(t *testing.T) {
|
|||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
|
loopDone := make(chan struct{})
|
||||||
|
defer func() { <-loopDone }()
|
||||||
|
|
||||||
conn, err := DialRead("rtsp://localhost:8554/path1", StreamProtocolUDP)
|
conn, err := DialRead("rtsp://localhost:8554/path1", StreamProtocolUDP)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
loopDone := make(chan struct{})
|
|
||||||
defer func() { <-loopDone }()
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(loopDone)
|
defer close(loopDone)
|
||||||
conn.LoopUDP()
|
conn.LoopUDP()
|
||||||
@@ -170,8 +168,6 @@ func TestDialReadRedirect(t *testing.T) {
|
|||||||
|
|
||||||
_, err = conn.ReadFrameUDP(0, StreamTypeRtp)
|
_, err = conn.ReadFrameUDP(0, StreamTypeRtp)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
conn.CloseUDPListeners()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDialPublishUDP(t *testing.T) {
|
func TestDialPublishUDP(t *testing.T) {
|
||||||
|
@@ -13,6 +13,9 @@ import (
|
|||||||
// read all tracks with the UDP protocol.
|
// read all tracks with the UDP protocol.
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
defer wg.Wait()
|
||||||
|
|
||||||
// connect to the server and start reading all tracks
|
// connect to the server and start reading all tracks
|
||||||
conn, err := gortsplib.DialRead("rtsp://localhost:8554/mystream", gortsplib.StreamProtocolUDP)
|
conn, err := gortsplib.DialRead("rtsp://localhost:8554/mystream", gortsplib.StreamProtocolUDP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -20,10 +23,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
|
||||||
defer wg.Wait()
|
|
||||||
defer conn.CloseUDPListeners()
|
|
||||||
|
|
||||||
for _, track := range conn.Tracks() {
|
for _, track := range conn.Tracks() {
|
||||||
// read RTP frames
|
// read RTP frames
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
Reference in New Issue
Block a user