mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
修正rtmp时间戳的bug
This commit is contained in:
parent
e3c1fb3648
commit
305f272344
@ -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() {
|
|||||||
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() {
|
|||||||
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() {
|
|||||||
|
|
||||||
if (chunkData.strBuf.size() == chunkData.bodySize) {
|
if (chunkData.strBuf.size() == chunkData.bodySize) {
|
||||||
//frame is ready
|
//frame is ready
|
||||||
|
m_iNowStreamID = chunkData.streamId;
|
||||||
chunkData.timeStamp = chunkData.deltaStamp + (chunkData.hasAbsStamp ? 0 : chunkData.timeStamp);
|
chunkData.timeStamp = chunkData.deltaStamp + (chunkData.hasAbsStamp ? 0 : chunkData.timeStamp);
|
||||||
chunkData.hasAbsStamp = false;
|
|
||||||
m_iNowStreamID = chunkData.streamId;
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user