修正rtmp时间戳异常的bug

This commit is contained in:
xzl 2017-05-27 10:10:07 +08:00
parent 9a2d54ce9a
commit c3231d2156
2 changed files with 4 additions and 1 deletions

View File

@ -93,6 +93,7 @@ public:
uint8_t typeId;
uint32_t bodySize = 0;
uint32_t timeStamp = 0;
bool hasAbsStamp = false;
uint32_t deltaStamp = 0;
uint32_t streamId;
uint32_t chunkId;

View File

@ -487,6 +487,7 @@ void RtmpProtocol::handle_rtmp() {
chunkData.chunkId = m_iNowChunkID;
switch (iHeaderLen) {
case 12:
chunkData.hasAbsStamp = true;
chunkData.streamId = load_le32(header.streamId);
case 8:
chunkData.bodySize = load_be24(header.bodySize);
@ -519,7 +520,8 @@ void RtmpProtocol::handle_rtmp() {
if (chunkData.strBuf.size() == chunkData.bodySize) {
//frame is ready
chunkData.timeStamp = chunkData.deltaStamp + (iHeaderLen == 12 ? 0 : chunkData.timeStamp);
chunkData.timeStamp = chunkData.deltaStamp + (chunkData.hasAbsStamp ? 0 : chunkData.timeStamp);
chunkData.hasAbsStamp = false;
m_iNowStreamID = chunkData.streamId;
if(chunkData.bodySize){
handle_rtmpChunk(chunkData);