mirror of
https://github.com/langhuihui/monibuca.git
synced 2026-05-08 01:21:04 +08:00
fix: rtsp send conn read timeout
This commit is contained in:
+3
-1
@@ -72,8 +72,10 @@ func (r *AVRingReader) ReadFrame(conf *config.Subscribe) (err error) {
|
||||
idr := r.Track.GetIDR()
|
||||
if idr != nil {
|
||||
startRing = idr
|
||||
} else {
|
||||
} else if r.Track.ICodecCtx != nil {
|
||||
r.Warn("no IDRring", "track", r.Track.FourCC().String())
|
||||
} else {
|
||||
r.Warn("no codec")
|
||||
}
|
||||
switch conf.SubMode {
|
||||
case SUBMODE_REAL:
|
||||
|
||||
@@ -44,17 +44,18 @@ type NetConnection struct {
|
||||
|
||||
// internal
|
||||
|
||||
auth *util.Auth
|
||||
conn net.Conn
|
||||
keepalive int
|
||||
sequence int
|
||||
Session string
|
||||
sdp string
|
||||
uri string
|
||||
writing atomic.Bool
|
||||
state State
|
||||
stateMu sync.Mutex
|
||||
SDP string
|
||||
auth *util.Auth
|
||||
conn net.Conn
|
||||
keepalive int
|
||||
sequence int
|
||||
Session string
|
||||
sdp string
|
||||
uri string
|
||||
writing atomic.Bool
|
||||
state State
|
||||
stateMu sync.Mutex
|
||||
SDP string
|
||||
keepaliveTS time.Time
|
||||
}
|
||||
|
||||
func (c *NetConnection) StartWrite() {
|
||||
@@ -264,7 +265,7 @@ func (c *NetConnection) Receive(sendMode bool) (channelID byte, buf []byte, err
|
||||
var size int
|
||||
if magic[0] != '$' {
|
||||
magicWord := string(magic)
|
||||
c.Warn("not magic", "magic", magicWord)
|
||||
//c.Warn("not magic", "magic", magicWord)
|
||||
switch magicWord {
|
||||
case "RTSP":
|
||||
var res *util.Response
|
||||
@@ -363,14 +364,13 @@ func (c *NetConnection) Receive(sendMode bool) (channelID byte, buf []byte, err
|
||||
}
|
||||
}
|
||||
|
||||
//if keepaliveDT != 0 && ts.After(keepaliveTS) {
|
||||
// req := &tcp.Request{Method: MethodOptions, URL: c.URL}
|
||||
// if err = c.WriteRequest(req); err != nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// keepaliveTS = ts.Add(keepaliveDT)
|
||||
//}
|
||||
if ts.After(c.keepaliveTS) {
|
||||
req := &util.Request{Method: MethodOptions, URL: c.URL}
|
||||
if err = c.WriteRequest(req); err != nil {
|
||||
return
|
||||
}
|
||||
c.keepaliveTS = ts.Add(25 * time.Second)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user