mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
修正rtmp时间戳异常的bug
This commit is contained in:
parent
a1742d41e9
commit
9a2d54ce9a
@ -93,7 +93,7 @@ public:
|
||||
uint8_t typeId;
|
||||
uint32_t bodySize = 0;
|
||||
uint32_t timeStamp = 0;
|
||||
bool extStamp = false;
|
||||
uint32_t deltaStamp = 0;
|
||||
uint32_t streamId;
|
||||
uint32_t chunkId;
|
||||
std::string strBuf;
|
||||
|
@ -492,24 +492,19 @@ void RtmpProtocol::handle_rtmp() {
|
||||
chunkData.bodySize = load_be24(header.bodySize);
|
||||
chunkData.typeId = header.typeId;
|
||||
case 4:
|
||||
uint32_t ts = load_be24(header.timeStamp);
|
||||
if (ts == 0xFFFFFF) {
|
||||
chunkData.extStamp = true;
|
||||
}else{
|
||||
chunkData.extStamp = false;
|
||||
chunkData.timeStamp = ts + ((iHeaderLen == 12) ? 0 : chunkData.timeStamp);
|
||||
}
|
||||
chunkData.deltaStamp = load_be24(header.timeStamp);
|
||||
}
|
||||
if (chunkData.extStamp) {
|
||||
|
||||
if (chunkData.deltaStamp == 0xFFFFFF) {
|
||||
if (m_strRcvBuf.size() < iHeaderLen + iOffset + 4) {
|
||||
//need more data
|
||||
return;
|
||||
}
|
||||
chunkData.timeStamp = load_be32( m_strRcvBuf.data() + iOffset + iHeaderLen);
|
||||
chunkData.deltaStamp = load_be32( m_strRcvBuf.data() + iOffset + iHeaderLen);
|
||||
iOffset += 4;
|
||||
}
|
||||
|
||||
if (chunkData.bodySize < chunkData.strBuf.size()) {
|
||||
if (chunkData.bodySize < chunkData.strBuf.size()) {
|
||||
throw std::runtime_error("非法的bodySize");
|
||||
}
|
||||
|
||||
@ -518,9 +513,13 @@ void RtmpProtocol::handle_rtmp() {
|
||||
//need more data
|
||||
return;
|
||||
}
|
||||
chunkData.strBuf.append(m_strRcvBuf, iHeaderLen + iOffset, iMore);
|
||||
|
||||
chunkData.strBuf.append(m_strRcvBuf, iHeaderLen + iOffset, iMore);
|
||||
m_strRcvBuf.erase(0, iHeaderLen + iOffset + iMore);
|
||||
|
||||
if (chunkData.strBuf.size() == chunkData.bodySize) {
|
||||
//frame is ready
|
||||
chunkData.timeStamp = chunkData.deltaStamp + (iHeaderLen == 12 ? 0 : chunkData.timeStamp);
|
||||
m_iNowStreamID = chunkData.streamId;
|
||||
if(chunkData.bodySize){
|
||||
handle_rtmpChunk(chunkData);
|
||||
|
Loading…
Reference in New Issue
Block a user