mirror of
https://github.com/aler9/gortsplib
synced 2025-10-09 00:50:24 +08:00
ConnClient: speedup play in case of udp connections
This commit is contained in:
@@ -485,6 +485,19 @@ func (c *ConnClient) Play(u *url.URL) (*Response, error) {
|
||||
return nil, fmt.Errorf("Play() can be called only after SetupUDP() or SetupTCP()")
|
||||
}
|
||||
|
||||
res, err := func() (*Response, error) {
|
||||
if *c.streamProtocol == StreamProtocolUdp {
|
||||
res, err := c.Do(&Request{
|
||||
Method: PLAY,
|
||||
Url: u,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
} else {
|
||||
_, err := c.Do(&Request{
|
||||
Method: PLAY,
|
||||
Url: u,
|
||||
@@ -494,7 +507,6 @@ func (c *ConnClient) Play(u *url.URL) (*Response, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res, err := func() (*Response, error) {
|
||||
frame := &InterleavedFrame{
|
||||
Content: make([]byte, 0, clientTcpReadBufferSize),
|
||||
}
|
||||
@@ -509,18 +521,19 @@ func (c *ConnClient) Play(u *url.URL) (*Response, error) {
|
||||
}
|
||||
|
||||
if res, ok := recv.(*Response); ok {
|
||||
if res.StatusCode != StatusOK {
|
||||
return nil, fmt.Errorf("bad status code: %d (%s)", res.StatusCode, res.StatusMessage)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if res.StatusCode != StatusOK {
|
||||
return nil, fmt.Errorf("bad status code: %d (%s)", res.StatusCode, res.StatusMessage)
|
||||
}
|
||||
|
||||
c.receiverReportTerminate = make(chan struct{})
|
||||
c.receiverReportDone = make(chan struct{})
|
||||
|
||||
|
Reference in New Issue
Block a user