Fix 400 response on PLAY for Reolink Doorbell #562

This commit is contained in:
Alexey Khit
2023-08-23 06:52:33 +03:00
parent 20efe22e60
commit 71f1e445e1
3 changed files with 12 additions and 3 deletions
+3
View File
@@ -38,6 +38,7 @@ type Conn struct {
conn net.Conn
keepalive int
mode core.Mode
playOK bool
reader *bufio.Reader
sequence int
session string
@@ -156,6 +157,8 @@ func (c *Conn) Handle() (err error) {
return
}
c.Fire(res)
// for playing backchannel only after OK response on play
c.playOK = true
continue
case "OPTI", "TEAR", "DESC", "SETU", "PLAY", "PAUS", "RECO", "ANNO", "GET_", "SET_":
+6 -2
View File
@@ -86,7 +86,7 @@ func (c *Conn) packetWriter(codec *core.Codec, channel, payloadType uint8) core.
}
handlerFunc := func(packet *rtp.Packet) {
if c.state == StateNone {
if c.state == StateNone || !c.playOK {
return
}
@@ -102,6 +102,10 @@ func (c *Conn) packetWriter(codec *core.Codec, channel, payloadType uint8) core.
Payload: packet.Payload,
}
if !video {
packet.Marker = true // better to have marker on all audio packets
}
size := 12 + len(packet.Payload)
if n+4+size > len(buf) {
@@ -130,7 +134,7 @@ func (c *Conn) packetWriter(codec *core.Codec, channel, payloadType uint8) core.
n += 4 + size
if video && !packet.Marker {
if !packet.Marker {
return // collect continious video packets to buffer
}
+3 -1
View File
@@ -157,7 +157,9 @@ func (c *Conn) Accept() error {
case MethodRecord, MethodPlay:
res := &tcp.Response{Request: req}
return c.WriteResponse(res)
err = c.WriteResponse(res)
c.playOK = true
return err
case MethodTeardown:
res := &tcp.Response{Request: req}