mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
修复rtmp增长时间戳相关bug
This commit is contained in:
parent
fdbed9e83b
commit
b4a3b608ab
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
@ -130,8 +130,6 @@ public:
|
||||
uint8_t typeId;
|
||||
uint32_t bodySize = 0;
|
||||
uint32_t timeStamp = 0;
|
||||
bool hasAbsStamp = false;
|
||||
bool hasExtStamp = false;
|
||||
uint32_t deltaStamp = 0;
|
||||
uint32_t streamId;
|
||||
uint32_t chunkId;
|
||||
@ -153,8 +151,6 @@ public:
|
||||
typeId = that.typeId;
|
||||
bodySize = that.bodySize;
|
||||
timeStamp = that.timeStamp;
|
||||
hasAbsStamp = that.hasAbsStamp;
|
||||
hasExtStamp = that.hasExtStamp;
|
||||
deltaStamp = that.deltaStamp;
|
||||
streamId = that.streamId;
|
||||
chunkId = that.chunkId;
|
||||
|
@ -554,17 +554,15 @@ void RtmpProtocol::handle_rtmp() {
|
||||
chunkData.chunkId = _iNowChunkID;
|
||||
switch (iHeaderLen) {
|
||||
case 12:
|
||||
chunkData.hasAbsStamp = true;
|
||||
chunkData.streamId = load_le32(header.streamId);
|
||||
case 8:
|
||||
chunkData.bodySize = load_be24(header.bodySize);
|
||||
chunkData.typeId = header.typeId;
|
||||
case 4:
|
||||
chunkData.deltaStamp = load_be24(header.timeStamp);
|
||||
chunkData.hasExtStamp = chunkData.deltaStamp == 0xFFFFFF;
|
||||
}
|
||||
|
||||
if (chunkData.hasExtStamp) {
|
||||
if (chunkData.deltaStamp == 0xFFFFFF) {
|
||||
if (_strRcvBuf.size() < iHeaderLen + iOffset + 4) {
|
||||
//need more data
|
||||
return;
|
||||
@ -583,21 +581,23 @@ void RtmpProtocol::handle_rtmp() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (iHeaderLen == 12) {
|
||||
//绝对时间戳
|
||||
chunkData.timeStamp = chunkData.deltaStamp;
|
||||
} else {
|
||||
//时间戳增量
|
||||
chunkData.timeStamp += chunkData.deltaStamp;
|
||||
}
|
||||
|
||||
chunkData.strBuf.append(_strRcvBuf, iHeaderLen + iOffset, iMore);
|
||||
_strRcvBuf.erase(0, iHeaderLen + iOffset + iMore);
|
||||
|
||||
if (chunkData.strBuf.size() == chunkData.bodySize) {
|
||||
//frame is ready
|
||||
_iNowStreamID = chunkData.streamId;
|
||||
chunkData.timeStamp = chunkData.deltaStamp + (chunkData.hasAbsStamp ? 0 : chunkData.timeStamp);
|
||||
|
||||
if (chunkData.bodySize) {
|
||||
handle_rtmpChunk(chunkData);
|
||||
}
|
||||
chunkData.strBuf.clear();
|
||||
chunkData.hasAbsStamp = false;
|
||||
chunkData.hasExtStamp = false;
|
||||
chunkData.deltaStamp = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user