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