From 04d55bc6c887223b4c7ad23c3ed1d818ef0b5bdc Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Sun, 20 Sep 2020 11:45:05 +0200 Subject: [PATCH] ConnClient: send teardown only after playing --- connclient.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connclient.go b/connclient.go index 9779c74d..1e8ff3cf 100644 --- a/connclient.go +++ b/connclient.go @@ -65,6 +65,7 @@ type ConnClient struct { udpLastFrameTimes map[int]*int64 udpRtpListeners map[int]*connClientUDPListener udpRtcpListeners map[int]*connClientUDPListener + playing bool receiverReportTerminate chan struct{} receiverReportDone chan struct{} @@ -104,7 +105,7 @@ func NewConnClient(conf ConnClientConf) (*ConnClient, error) { // Close closes all the ConnClient resources. func (c *ConnClient) Close() error { - if c.streamUrl != nil { + if c.playing { c.Do(&Request{ Method: TEARDOWN, Url: c.streamUrl, @@ -601,6 +602,8 @@ func (c *ConnClient) Play(u *url.URL) (*Response, error) { return nil, fmt.Errorf("bad status code: %d (%s)", res.StatusCode, res.StatusMessage) } + c.playing = true + // open the firewall by sending packets to every channel if *c.streamProtocol == StreamProtocolUDP { for trackId := range c.udpRtpListeners {