Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
b4a3b608
Commit
b4a3b608
authored
4 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复rtmp增长时间戳相关bug
parent
fdbed9e8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
46 行增加
和
50 行删除
+46
-50
src/Rtmp/Rtmp.h
+1
-5
src/Rtmp/RtmpProtocol.cpp
+45
-45
没有找到文件。
src/Rtmp/Rtmp.h
查看文件 @
b4a3b608
/*
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
...
...
@@ -130,8 +130,6 @@ public:
uint8_t
typeId
;
uint32_t
bodySize
=
0
;
uint32_t
timeStamp
=
0
;
bool
hasAbsStamp
=
false
;
bool
hasExtStamp
=
false
;
uint32_t
deltaStamp
=
0
;
uint32_t
streamId
;
uint32_t
chunkId
;
...
...
@@ -153,8 +151,6 @@ public:
typeId
=
that
.
typeId
;
bodySize
=
that
.
bodySize
;
timeStamp
=
that
.
timeStamp
;
hasAbsStamp
=
that
.
hasAbsStamp
;
hasExtStamp
=
that
.
hasExtStamp
;
deltaStamp
=
that
.
deltaStamp
;
streamId
=
that
.
streamId
;
chunkId
=
that
.
chunkId
;
...
...
This diff is collapsed.
Click to expand it.
src/Rtmp/RtmpProtocol.cpp
查看文件 @
b4a3b608
...
...
@@ -514,35 +514,35 @@ void RtmpProtocol::handle_rtmp() {
while
(
!
_strRcvBuf
.
empty
())
{
uint8_t
flags
=
_strRcvBuf
[
0
];
int
iOffset
=
0
;
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
];
_iNowChunkID
=
flags
&
0x3f
;
switch
(
_iNowChunkID
)
{
case
0
:
{
//0 值表示二字节形式,并且 ID 范围 64 - 319
//(第二个字节 + 64)。
if
(
_strRcvBuf
.
size
()
<
2
)
{
//need more data
return
;
case
0
:
{
//0 值表示二字节形式,并且 ID 范围 64 - 319
//(第二个字节 + 64)。
if
(
_strRcvBuf
.
size
()
<
2
)
{
//need more data
return
;
}
_iNowChunkID
=
64
+
(
uint8_t
)
(
_strRcvBuf
[
1
]);
iOffset
=
1
;
}
_iNowChunkID
=
64
+
(
uint8_t
)
(
_strRcvBuf
[
1
])
;
iOffset
=
1
;
}
break
;
case
1
:
{
//1 值表示三字节形式,并且 ID 范围为 64 - 65599
//((第三个字节) * 256 + 第二个字节 + 64)。
if
(
_strRcvBuf
.
size
()
<
3
)
{
//need more data
return
;
break
;
case
1
:
{
//1 值表示三字节形式,并且 ID 范围为 64 - 65599
//((第三个字节) * 256 + 第二个字节 + 64)。
if
(
_strRcvBuf
.
size
()
<
3
)
{
//need more data
return
;
}
_iNowChunkID
=
64
+
((
uint8_t
)
(
_strRcvBuf
[
2
])
<<
8
)
+
(
uint8_t
)
(
_strRcvBuf
[
1
]);
iOffset
=
2
;
}
_iNowChunkID
=
64
+
((
uint8_t
)
(
_strRcvBuf
[
2
])
<<
8
)
+
(
uint8_t
)
(
_strRcvBuf
[
1
]);
iOffset
=
2
;
}
break
;
default
:
//带有 2 值的块流 ID 被保留,用于下层协议控制消息和命令。
break
;
break
;
default
:
//带有 2 值的块流 ID 被保留,用于下层协议控制消息和命令。
break
;
}
if
(
_strRcvBuf
.
size
()
<
iHeaderLen
+
iOffset
)
{
...
...
@@ -553,18 +553,16 @@ void RtmpProtocol::handle_rtmp() {
auto
&
chunkData
=
_mapChunkData
[
_iNowChunkID
];
chunkData
.
chunkId
=
_iNowChunkID
;
switch
(
iHeaderLen
)
{
case
12
:
chunkData
.
hasAbsStamp
=
true
;
chunkData
.
streamId
=
load_le32
(
header
.
streamId
);
case
8
:
chunkData
.
bodySize
=
load_be24
(
header
.
bodySize
);
chunkData
.
typeId
=
header
.
typeId
;
case
4
:
chunkData
.
deltaStamp
=
load_be24
(
header
.
timeStamp
);
chunkData
.
hasExtStamp
=
chunkData
.
deltaStamp
==
0xFFFFFF
;
case
12
:
chunkData
.
streamId
=
load_le32
(
header
.
streamId
);
case
8
:
chunkData
.
bodySize
=
load_be24
(
header
.
bodySize
);
chunkData
.
typeId
=
header
.
typeId
;
case
4
:
chunkData
.
deltaStamp
=
load_be24
(
header
.
timeStamp
);
}
if
(
chunkData
.
hasExtStamp
)
{
if
(
chunkData
.
deltaStamp
==
0xFFFFFF
)
{
if
(
_strRcvBuf
.
size
()
<
iHeaderLen
+
iOffset
+
4
)
{
//need more data
return
;
...
...
@@ -572,32 +570,34 @@ void RtmpProtocol::handle_rtmp() {
chunkData
.
deltaStamp
=
load_be32
(
_strRcvBuf
.
data
()
+
iOffset
+
iHeaderLen
);
iOffset
+=
4
;
}
if
(
chunkData
.
bodySize
<
chunkData
.
strBuf
.
size
())
{
throw
std
::
runtime_error
(
"非法的bodySize"
);
}
auto
iMore
=
min
(
_iChunkLenIn
,
chunkData
.
bodySize
-
chunkData
.
strBuf
.
size
());
if
(
_strRcvBuf
.
size
()
<
iHeaderLen
+
iOffset
+
iMore
)
{
//need more data
return
;
}
if
(
iHeaderLen
==
12
)
{
//绝对时间戳
chunkData
.
timeStamp
=
chunkData
.
deltaStamp
;
}
else
{
//时间戳增量
chunkData
.
timeStamp
+=
chunkData
.
deltaStamp
;
}
chunkData
.
strBuf
.
append
(
_strRcvBuf
,
iHeaderLen
+
iOffset
,
iMore
);
_strRcvBuf
.
erase
(
0
,
iHeaderLen
+
iOffset
+
iMore
);
if
(
chunkData
.
strBuf
.
size
()
==
chunkData
.
bodySize
)
{
//frame is ready
_iNowStreamID
=
chunkData
.
streamId
;
chunkData
.
timeStamp
=
chunkData
.
deltaStamp
+
(
chunkData
.
hasAbsStamp
?
0
:
chunkData
.
timeStamp
);
if
(
chunkData
.
bodySize
){
if
(
chunkData
.
bodySize
)
{
handle_rtmpChunk
(
chunkData
);
}
chunkData
.
strBuf
.
clear
();
chunkData
.
hasAbsStamp
=
false
;
chunkData
.
hasExtStamp
=
false
;
chunkData
.
deltaStamp
=
0
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论