mirror of
https://github.com/Monibuca/plugin-rtsp.git
synced 2025-09-26 19:51:14 +08:00
feat: push use tcp default
This commit is contained in:
11
client.go
11
client.go
@@ -116,6 +116,8 @@ func (p *RTSPPusher) Connect() error {
|
||||
DialContext: p.DialContext,
|
||||
WriteQueueSize: rtspConfig.WriteBufferCount,
|
||||
}
|
||||
p.Transport = gortsplib.TransportTCP
|
||||
p.Client.Transport = &p.Transport
|
||||
// parse URL
|
||||
u, err := url.Parse(p.RemoteURL)
|
||||
if err != nil {
|
||||
@@ -143,9 +145,12 @@ func (p *RTSPPusher) Push() (err error) {
|
||||
// return fmt.Errorf("timeout")
|
||||
// }
|
||||
// }
|
||||
if _, err = p.Announce(u, p.session); err != nil {
|
||||
var res *base.Response
|
||||
if res, err = p.Announce(u, p.session); err != nil {
|
||||
p.Error("Announce", zap.Error(err))
|
||||
return
|
||||
} else {
|
||||
p.Debug("Announce", zap.Any("res", res))
|
||||
}
|
||||
err = p.SetupAll(u, p.session.Medias)
|
||||
if err != nil {
|
||||
@@ -153,9 +158,11 @@ func (p *RTSPPusher) Push() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err = p.Record(); err != nil {
|
||||
if res, err = p.Record(); err != nil {
|
||||
p.Error("Record", zap.Error(err))
|
||||
return
|
||||
} else {
|
||||
p.Debug("Record", zap.Any("res", res))
|
||||
}
|
||||
p.PlayRTP()
|
||||
return
|
||||
|
6
main.go
6
main.go
@@ -49,9 +49,9 @@ func (conf *RTSPConfig) OnEvent(event any) {
|
||||
}
|
||||
}
|
||||
case SEpublish:
|
||||
if url, ok := conf.PushList[v.Target.Path]; ok {
|
||||
if err := RTSPPlugin.Push(v.Target.Path, url, new(RTSPPusher), false); err != nil {
|
||||
RTSPPlugin.Error("push", zap.String("streamPath", v.Target.Path), zap.String("url", url), zap.Error(err))
|
||||
if remoteURL := conf.CheckPush(v.Target.Path); remoteURL != "" {
|
||||
if err := RTSPPlugin.Push(v.Target.Path, remoteURL, new(RTSPPusher), false); err != nil {
|
||||
RTSPPlugin.Error("push", zap.String("streamPath", v.Target.Path), zap.String("url", remoteURL), zap.Error(err))
|
||||
}
|
||||
}
|
||||
case InvitePublish: //按需拉流
|
||||
|
@@ -39,7 +39,7 @@ func (conf *RTSPConfig) OnSessionClose(ctx *gortsplib.ServerHandlerOnSessionClos
|
||||
|
||||
// called after receiving a DESCRIBE request.
|
||||
func (conf *RTSPConfig) OnDescribe(ctx *gortsplib.ServerHandlerOnDescribeCtx) (*base.Response, *gortsplib.ServerStream, error) {
|
||||
RTSPPlugin.Debug("describe request")
|
||||
RTSPPlugin.Debug("describe request", zap.String("sdp", string(ctx.Request.Body)))
|
||||
var suber RTSPSubscriber
|
||||
suber.server = conf.server
|
||||
suber.RemoteAddr = ctx.Conn.NetConn().RemoteAddr().String()
|
||||
@@ -100,6 +100,7 @@ func (conf *RTSPConfig) OnRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*base
|
||||
}, nil
|
||||
}
|
||||
func (conf *RTSPConfig) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (*base.Response, error) {
|
||||
RTSPPlugin.Debug("annouce request", zap.String("sdp", string(ctx.Request.Body)))
|
||||
p := &RTSPPublisher{}
|
||||
p.SetIO(ctx.Conn.NetConn())
|
||||
if err := RTSPPlugin.Publish(ctx.Path, p); err == nil {
|
||||
|
Reference in New Issue
Block a user