mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 23:52:46 +08:00
ConnClient: send teardown only after playing
This commit is contained in:
@@ -65,6 +65,7 @@ type ConnClient struct {
|
|||||||
udpLastFrameTimes map[int]*int64
|
udpLastFrameTimes map[int]*int64
|
||||||
udpRtpListeners map[int]*connClientUDPListener
|
udpRtpListeners map[int]*connClientUDPListener
|
||||||
udpRtcpListeners map[int]*connClientUDPListener
|
udpRtcpListeners map[int]*connClientUDPListener
|
||||||
|
playing bool
|
||||||
|
|
||||||
receiverReportTerminate chan struct{}
|
receiverReportTerminate chan struct{}
|
||||||
receiverReportDone chan struct{}
|
receiverReportDone chan struct{}
|
||||||
@@ -104,7 +105,7 @@ func NewConnClient(conf ConnClientConf) (*ConnClient, error) {
|
|||||||
|
|
||||||
// Close closes all the ConnClient resources.
|
// Close closes all the ConnClient resources.
|
||||||
func (c *ConnClient) Close() error {
|
func (c *ConnClient) Close() error {
|
||||||
if c.streamUrl != nil {
|
if c.playing {
|
||||||
c.Do(&Request{
|
c.Do(&Request{
|
||||||
Method: TEARDOWN,
|
Method: TEARDOWN,
|
||||||
Url: c.streamUrl,
|
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)
|
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
|
// open the firewall by sending packets to every channel
|
||||||
if *c.streamProtocol == StreamProtocolUDP {
|
if *c.streamProtocol == StreamProtocolUDP {
|
||||||
for trackId := range c.udpRtpListeners {
|
for trackId := range c.udpRtpListeners {
|
||||||
|
Reference in New Issue
Block a user