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
e4904623
Commit
e4904623
authored
4 years ago
by
xia-chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复rtmp兼容性bug
parent
1f52c727
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
30 行增加
和
10 行删除
+30
-10
src/Rtmp/Rtmp.h
+11
-0
src/Rtmp/RtmpProtocol.cpp
+18
-9
src/Rtmp/RtmpProtocol.h
+1
-1
没有找到文件。
src/Rtmp/Rtmp.h
查看文件 @
e4904623
...
@@ -128,6 +128,7 @@ public:
...
@@ -128,6 +128,7 @@ public:
class
RtmpPacket
:
public
Buffer
{
class
RtmpPacket
:
public
Buffer
{
public
:
public
:
friend
class
RtmpProtocol
;
using
Ptr
=
std
::
shared_ptr
<
RtmpPacket
>
;
using
Ptr
=
std
::
shared_ptr
<
RtmpPacket
>
;
bool
is_abs_stamp
;
bool
is_abs_stamp
;
uint8_t
type_id
;
uint8_t
type_id
;
...
@@ -214,6 +215,16 @@ private:
...
@@ -214,6 +215,16 @@ private:
clear
();
clear
();
}
}
RtmpPacket
&
operator
=
(
const
RtmpPacket
&
that
)
{
is_abs_stamp
=
that
.
is_abs_stamp
;
stream_index
=
that
.
stream_index
;
body_size
=
that
.
body_size
;
type_id
=
that
.
type_id
;
ts_field
=
that
.
ts_field
;
time_stamp
=
that
.
time_stamp
;
return
*
this
;
}
private
:
private
:
//对象个数统计
//对象个数统计
ObjectStatistic
<
RtmpPacket
>
_statistic
;
ObjectStatistic
<
RtmpPacket
>
_statistic
;
...
...
This diff is collapsed.
Click to expand it.
src/Rtmp/RtmpProtocol.cpp
查看文件 @
e4904623
...
@@ -565,13 +565,20 @@ const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) {
...
@@ -565,13 +565,20 @@ const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) {
//need more data
//need more data
return
ptr
;
return
ptr
;
}
}
RtmpHeader
&
header
=
*
((
RtmpHeader
*
)
(
ptr
+
offset
));
RtmpHeader
&
header
=
*
((
RtmpHeader
*
)
(
ptr
+
offset
));
auto
&
packet_ptr
=
_map_chunk_data
[
_now_chunk_id
];
auto
&
pr
=
_map_chunk_data
[
_now_chunk_id
];
if
(
!
packet_ptr
)
{
auto
&
now_packet
=
pr
.
first
;
packet_ptr
=
RtmpPacket
::
create
();
auto
&
last_packet
=
pr
.
second
;
}
if
(
!
now_packet
)
{
auto
&
chunk_data
=
*
packet_ptr
;
now_packet
=
RtmpPacket
::
create
();
if
(
last_packet
)
{
//恢复chunk上下文
*
now_packet
=
*
last_packet
;
}
//绝对时间戳标记复位
now_packet
->
is_abs_stamp
=
false
;
}
auto
&
chunk_data
=
*
now_packet
;
chunk_data
.
chunk_id
=
_now_chunk_id
;
chunk_data
.
chunk_id
=
_now_chunk_id
;
switch
(
header_len
)
{
switch
(
header_len
)
{
case
12
:
case
12
:
...
@@ -598,7 +605,7 @@ const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) {
...
@@ -598,7 +605,7 @@ const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) {
throw
std
::
runtime_error
(
"非法的bodySize"
);
throw
std
::
runtime_error
(
"非法的bodySize"
);
}
}
auto
more
=
min
(
_chunk_size_in
,
(
size_t
)(
chunk_data
.
body_size
-
chunk_data
.
buffer
.
size
()));
auto
more
=
min
(
_chunk_size_in
,
(
size_t
)
(
chunk_data
.
body_size
-
chunk_data
.
buffer
.
size
()));
if
(
len
<
header_len
+
offset
+
more
)
{
if
(
len
<
header_len
+
offset
+
more
)
{
//need more data
//need more data
return
ptr
;
return
ptr
;
...
@@ -612,10 +619,12 @@ const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) {
...
@@ -612,10 +619,12 @@ const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) {
//frame is ready
//frame is ready
_now_stream_index
=
chunk_data
.
stream_index
;
_now_stream_index
=
chunk_data
.
stream_index
;
chunk_data
.
time_stamp
=
time_stamp
+
(
chunk_data
.
is_abs_stamp
?
0
:
chunk_data
.
time_stamp
);
chunk_data
.
time_stamp
=
time_stamp
+
(
chunk_data
.
is_abs_stamp
?
0
:
chunk_data
.
time_stamp
);
//保存chunk上下文
last_packet
=
now_packet
;
if
(
chunk_data
.
body_size
)
{
if
(
chunk_data
.
body_size
)
{
handle_chunk
(
std
::
move
(
packet_ptr
));
handle_chunk
(
std
::
move
(
now_packet
));
}
else
{
}
else
{
packet_ptr
=
nullptr
;
now_packet
=
nullptr
;
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Rtmp/RtmpProtocol.h
查看文件 @
e4904623
...
@@ -106,7 +106,7 @@ private:
...
@@ -106,7 +106,7 @@ private:
//////////Rtmp parser//////////
//////////Rtmp parser//////////
function
<
const
char
*
(
const
char
*
data
,
size_t
len
)
>
_next_step_func
;
function
<
const
char
*
(
const
char
*
data
,
size_t
len
)
>
_next_step_func
;
////////////Chunk////////////
////////////Chunk////////////
unordered_map
<
int
,
RtmpPacket
::
Ptr
>
_map_chunk_data
;
unordered_map
<
int
,
std
::
pair
<
RtmpPacket
::
Ptr
/*now*/
,
RtmpPacket
::
Ptr
/*last*/
>
>
_map_chunk_data
;
};
};
}
/* namespace mediakit */
}
/* namespace mediakit */
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论