mirror of https://bitbucket.org/ausocean/av.git
Removed superfluous packet.bytesRead.
This commit is contained in:
parent
42be87d98a
commit
828cc3780a
|
@ -81,7 +81,7 @@ const (
|
|||
// 3: basic header (chunk type and stream ID) (1 byte)
|
||||
var headerSizes = [...]int{12, 8, 4, 1}
|
||||
|
||||
// packet defines an RTMP packet.
|
||||
// packet represents an RTMP packet.
|
||||
type packet struct {
|
||||
headerType uint8
|
||||
packetType uint8
|
||||
|
@ -90,7 +90,6 @@ type packet struct {
|
|||
timestamp uint32
|
||||
streamID uint32
|
||||
bodySize uint32
|
||||
bytesRead uint32
|
||||
buf []byte
|
||||
body []byte
|
||||
}
|
||||
|
@ -179,7 +178,6 @@ func (pkt *packet) readFrom(c *Conn) error {
|
|||
pkt.timestamp = amf.DecodeInt24(header[:3])
|
||||
if size >= 6 {
|
||||
pkt.bodySize = amf.DecodeInt24(header[3:6])
|
||||
pkt.bytesRead = 0
|
||||
|
||||
if size > 6 {
|
||||
pkt.packetType = header[6]
|
||||
|
@ -205,21 +203,17 @@ func (pkt *packet) readFrom(c *Conn) error {
|
|||
pkt.resize(pkt.bodySize, (hbuf[0]&0xc0)>>6)
|
||||
}
|
||||
|
||||
toRead := pkt.bodySize - pkt.bytesRead
|
||||
chunkSize := c.inChunkSize
|
||||
|
||||
if toRead < chunkSize {
|
||||
chunkSize = toRead
|
||||
sz := c.inChunkSize
|
||||
if pkt.bodySize < sz {
|
||||
sz = pkt.bodySize
|
||||
}
|
||||
|
||||
_, err = c.read(pkt.body[pkt.bytesRead:][:chunkSize])
|
||||
_, err = c.read(pkt.body[:sz])
|
||||
if err != nil {
|
||||
c.log(DebugLevel, pkg+"failed to read packet body", "error", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
pkt.bytesRead += uint32(chunkSize)
|
||||
|
||||
// Keep the packet as a reference for other packets on this channel.
|
||||
if c.channelsIn[pkt.channel] == nil {
|
||||
c.channelsIn[pkt.channel] = &packet{}
|
||||
|
@ -237,7 +231,6 @@ func (pkt *packet) readFrom(c *Conn) error {
|
|||
c.channelTimestamp[pkt.channel] = int32(pkt.timestamp)
|
||||
|
||||
c.channelsIn[pkt.channel].body = nil
|
||||
c.channelsIn[pkt.channel].bytesRead = 0
|
||||
c.channelsIn[pkt.channel].hasAbsTimestamp = false
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue