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;
|
uint8_t typeId;
|
||||||
uint32_t bodySize = 0;
|
uint32_t bodySize = 0;
|
||||||
uint32_t timeStamp = 0;
|
uint32_t timeStamp = 0;
|
||||||
bool extStamp = false;
|
uint32_t deltaStamp = 0;
|
||||||
uint32_t streamId;
|
uint32_t streamId;
|
||||||
uint32_t chunkId;
|
uint32_t chunkId;
|
||||||
std::string strBuf;
|
std::string strBuf;
|
||||||
|
@ -492,35 +492,34 @@ void RtmpProtocol::handle_rtmp() {
|
|||||||
chunkData.bodySize = load_be24(header.bodySize);
|
chunkData.bodySize = load_be24(header.bodySize);
|
||||||
chunkData.typeId = header.typeId;
|
chunkData.typeId = header.typeId;
|
||||||
case 4:
|
case 4:
|
||||||
uint32_t ts = load_be24(header.timeStamp);
|
chunkData.deltaStamp = load_be24(header.timeStamp);
|
||||||
if (ts == 0xFFFFFF) {
|
|
||||||
chunkData.extStamp = true;
|
|
||||||
}else{
|
|
||||||
chunkData.extStamp = false;
|
|
||||||
chunkData.timeStamp = ts + ((iHeaderLen == 12) ? 0 : chunkData.timeStamp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (chunkData.extStamp) {
|
|
||||||
|
if (chunkData.deltaStamp == 0xFFFFFF) {
|
||||||
if (m_strRcvBuf.size() < iHeaderLen + iOffset + 4) {
|
if (m_strRcvBuf.size() < iHeaderLen + iOffset + 4) {
|
||||||
//need more data
|
//need more data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chunkData.timeStamp = load_be32( m_strRcvBuf.data() + iOffset + iHeaderLen);
|
chunkData.deltaStamp = load_be32( m_strRcvBuf.data() + iOffset + iHeaderLen);
|
||||||
iOffset += 4;
|
iOffset += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunkData.bodySize < chunkData.strBuf.size()) {
|
if (chunkData.bodySize < chunkData.strBuf.size()) {
|
||||||
throw std::runtime_error("非法的bodySize");
|
throw std::runtime_error("非法的bodySize");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto iMore = min(m_iChunkLenIn, chunkData.bodySize - chunkData.strBuf.size());
|
auto iMore = min(m_iChunkLenIn, chunkData.bodySize - chunkData.strBuf.size());
|
||||||
if (m_strRcvBuf.size() < iHeaderLen + iOffset + iMore) {
|
if (m_strRcvBuf.size() < iHeaderLen + iOffset + iMore) {
|
||||||
//need more data
|
//need more data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chunkData.strBuf.append(m_strRcvBuf, iHeaderLen + iOffset, iMore);
|
|
||||||
|
chunkData.strBuf.append(m_strRcvBuf, iHeaderLen + iOffset, iMore);
|
||||||
m_strRcvBuf.erase(0, iHeaderLen + iOffset + iMore);
|
m_strRcvBuf.erase(0, iHeaderLen + iOffset + iMore);
|
||||||
|
|
||||||
if (chunkData.strBuf.size() == chunkData.bodySize) {
|
if (chunkData.strBuf.size() == chunkData.bodySize) {
|
||||||
|
//frame is ready
|
||||||
|
chunkData.timeStamp = chunkData.deltaStamp + (iHeaderLen == 12 ? 0 : chunkData.timeStamp);
|
||||||
m_iNowStreamID = chunkData.streamId;
|
m_iNowStreamID = chunkData.streamId;
|
||||||
if(chunkData.bodySize){
|
if(chunkData.bodySize){
|
||||||
handle_rtmpChunk(chunkData);
|
handle_rtmpChunk(chunkData);
|
||||||
|
Loading…
Reference in New Issue
Block a user