修复时间戳计算

This commit is contained in:
dexter
2023-02-15 19:34:28 +08:00
parent 082d233dc9
commit 1188afbc3a

View File

@@ -154,9 +154,8 @@ func (conn *NetConnection) readChunk() (msg *Chunk, err error) {
} else { } else {
conn.readSeqNum += uint32(n) conn.readSeqNum += uint32(n)
} }
chunk.AVData.Push(mem) if chunk.AVData.Push(mem); chunk.AVData.ByteLength == msgLen {
// println("read chunk body", chunk.MessageTypeID, chunk.AVData.ByteLength, ChunkType, msgLen, chunk.Timestamp, chunk.ExtendTimestamp) chunk.ChunkHeader.ExtendTimestamp += chunk.ChunkHeader.Timestamp
if chunk.AVData.ByteLength == msgLen {
msg = chunk msg = chunk
switch chunk.MessageTypeID { switch chunk.MessageTypeID {
case RTMP_MSG_AUDIO, RTMP_MSG_VIDEO: 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) { func (conn *NetConnection) readChunkType(h *ChunkHeader, chunkType byte) (err error) {
conn.tmpBuf.Reset() conn.tmpBuf.Reset()
b4 := conn.tmpBuf.Malloc(4) b4 := conn.tmpBuf.Malloc(4)
b3 := b4[:3] b3 := b4[:3]
@@ -241,15 +239,11 @@ func (conn *NetConnection) readChunkType(h *ChunkHeader, chunkType byte) (err er
if _, err = conn.ReadFull(b4); err != nil { if _, err = conn.ReadFull(b4); err != nil {
return err return err
} }
util.GetBE(b4, &h.ExtendTimestamp) util.GetBE(b4, &h.Timestamp)
} else { }
if chunkType == 0 { if chunkType == 0 {
h.ExtendTimestamp = h.Timestamp h.ExtendTimestamp = h.Timestamp
// println("timestamp", h.Timestamp) h.Timestamp = 0
} else if chunkType != 3 {
// println("extend timestamp", chunkType, h.Timestamp, h.ExtendTimestamp)
h.ExtendTimestamp += h.Timestamp
}
} }
return nil return nil
} }