mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 15:46:51 +08:00
ConnClient: send teardown only after playing
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user