From 1188afbc3a1229a2c67a2213d7cbef74dae41ec8 Mon Sep 17 00:00:00 2001 From: dexter <178529795@qq.com> Date: Wed, 15 Feb 2023 19:34:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4=E6=88=B3?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- netConnection.go | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/netConnection.go b/netConnection.go index 9102631..68c58fa 100644 --- a/netConnection.go +++ b/netConnection.go @@ -154,9 +154,8 @@ func (conn *NetConnection) readChunk() (msg *Chunk, err error) { } else { conn.readSeqNum += uint32(n) } - chunk.AVData.Push(mem) - // println("read chunk body", chunk.MessageTypeID, chunk.AVData.ByteLength, ChunkType, msgLen, chunk.Timestamp, chunk.ExtendTimestamp) - if chunk.AVData.ByteLength == msgLen { + if chunk.AVData.Push(mem); chunk.AVData.ByteLength == msgLen { + chunk.ChunkHeader.ExtendTimestamp += chunk.ChunkHeader.Timestamp msg = chunk switch chunk.MessageTypeID { case RTMP_MSG_AUDIO, RTMP_MSG_VIDEO: @@ -204,7 +203,6 @@ func (conn *NetConnection) readChunkStreamID(csid uint32) (chunkStreamID uint32, } func (conn *NetConnection) readChunkType(h *ChunkHeader, chunkType byte) (err error) { - conn.tmpBuf.Reset() b4 := conn.tmpBuf.Malloc(4) b3 := b4[:3] @@ -241,15 +239,11 @@ func (conn *NetConnection) readChunkType(h *ChunkHeader, chunkType byte) (err er if _, err = conn.ReadFull(b4); err != nil { return err } - util.GetBE(b4, &h.ExtendTimestamp) - } else { - if chunkType == 0 { - h.ExtendTimestamp = h.Timestamp - // println("timestamp", h.Timestamp) - } else if chunkType != 3 { - // println("extend timestamp", chunkType, h.Timestamp, h.ExtendTimestamp) - h.ExtendTimestamp += h.Timestamp - } + util.GetBE(b4, &h.Timestamp) + } + if chunkType == 0 { + h.ExtendTimestamp = h.Timestamp + h.Timestamp = 0 } return nil }