Commit 305f2723 by xzl

修正rtmp时间戳的bug

parent e3c1fb36
...@@ -95,6 +95,7 @@ public: ...@@ -95,6 +95,7 @@ public:
uint32_t bodySize = 0; uint32_t bodySize = 0;
uint32_t timeStamp = 0; uint32_t timeStamp = 0;
bool hasAbsStamp = false; bool hasAbsStamp = false;
bool hasExtStamp = false;
uint32_t deltaStamp = 0; uint32_t deltaStamp = 0;
uint32_t streamId; uint32_t streamId;
uint32_t chunkId; uint32_t chunkId;
......
...@@ -450,6 +450,10 @@ void RtmpProtocol::handle_rtmp() { ...@@ -450,6 +450,10 @@ void RtmpProtocol::handle_rtmp() {
static const size_t HEADER_LENGTH[] = { 12, 8, 4, 1 }; static const size_t HEADER_LENGTH[] = { 12, 8, 4, 1 };
size_t iHeaderLen = HEADER_LENGTH[flags >> 6]; size_t iHeaderLen = HEADER_LENGTH[flags >> 6];
m_iNowChunkID = flags & 0x3f; m_iNowChunkID = flags & 0x3f;
if(m_iNowChunkID >10){
int i=0;
i++;
}
switch (m_iNowChunkID) { switch (m_iNowChunkID) {
case 0: { case 0: {
//0 值表示二字节形式,并且 ID 范围 64 - 319 //0 值表示二字节形式,并且 ID 范围 64 - 319
...@@ -494,14 +498,15 @@ void RtmpProtocol::handle_rtmp() { ...@@ -494,14 +498,15 @@ void RtmpProtocol::handle_rtmp() {
chunkData.typeId = header.typeId; chunkData.typeId = header.typeId;
case 4: case 4:
chunkData.deltaStamp = load_be24(header.timeStamp); chunkData.deltaStamp = load_be24(header.timeStamp);
chunkData.hasExtStamp = chunkData.deltaStamp == 0xFFFFFF;
} }
if (chunkData.deltaStamp == 0xFFFFFF) { if (chunkData.hasExtStamp) {
if (m_strRcvBuf.size() < iHeaderLen + iOffset + 4) { if (m_strRcvBuf.size() < iHeaderLen + iOffset + 4) {
//need more data //need more data
return; return;
} }
chunkData.deltaStamp = load_be32( m_strRcvBuf.data() + iOffset + iHeaderLen); chunkData.deltaStamp = load_be32(m_strRcvBuf.data() + iOffset + iHeaderLen);
iOffset += 4; iOffset += 4;
} }
...@@ -520,13 +525,16 @@ void RtmpProtocol::handle_rtmp() { ...@@ -520,13 +525,16 @@ void RtmpProtocol::handle_rtmp() {
if (chunkData.strBuf.size() == chunkData.bodySize) { if (chunkData.strBuf.size() == chunkData.bodySize) {
//frame is ready //frame is ready
chunkData.timeStamp = chunkData.deltaStamp + (chunkData.hasAbsStamp ? 0 : chunkData.timeStamp);
chunkData.hasAbsStamp = false;
m_iNowStreamID = chunkData.streamId; m_iNowStreamID = chunkData.streamId;
chunkData.timeStamp = chunkData.deltaStamp + (chunkData.hasAbsStamp ? 0 : chunkData.timeStamp);
if(chunkData.bodySize){ if(chunkData.bodySize){
handle_rtmpChunk(chunkData); handle_rtmpChunk(chunkData);
} }
chunkData.strBuf.clear(); chunkData.strBuf.clear();
chunkData.hasAbsStamp = false;
chunkData.hasExtStamp = false;
chunkData.deltaStamp = 0;
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论