mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-26 19:51:14 +08:00
fix: 修复错误的流地址导致的Disconnect时panic
This commit is contained in:
@@ -28,7 +28,7 @@ func (p *RTSPClient) Disconnect() {
|
||||
}
|
||||
|
||||
func (p *RTSPPuller) Connect() error {
|
||||
p.Client = &gortsplib.Client{
|
||||
client := &gortsplib.Client{
|
||||
DialContext: p.DialContext,
|
||||
ReadBufferCount: rtspConfig.ReadBufferCount,
|
||||
AnyPortEnable: true,
|
||||
@@ -37,10 +37,10 @@ func (p *RTSPPuller) Connect() error {
|
||||
switch rtspConfig.PullProtocol {
|
||||
case "tcp", "TCP":
|
||||
p.Transport = gortsplib.TransportTCP
|
||||
p.Client.Transport = &p.Transport
|
||||
client.Transport = &p.Transport
|
||||
case "udp", "UDP":
|
||||
p.Transport = gortsplib.TransportUDP
|
||||
p.Client.Transport = &p.Transport
|
||||
client.Transport = &p.Transport
|
||||
}
|
||||
// parse URL
|
||||
u, err := url.Parse(p.RemoteURL)
|
||||
@@ -48,9 +48,10 @@ func (p *RTSPPuller) Connect() error {
|
||||
return err
|
||||
}
|
||||
// connect to the server
|
||||
if err = p.Client.Start(u.Scheme, u.Host); err != nil {
|
||||
if err = client.Start(u.Scheme, u.Host); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Client = client
|
||||
p.SetIO(p.Client)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user