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
c1d2adeb
Unverified
Commit
c1d2adeb
authored
Apr 28, 2022
by
alexliyu7352
Committed by
GitHub
Apr 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtmp拉流的兼容性改进 (#1595)
* 修复play指令的bug * 修改MSG_AGGREGATE的时间戳处理逻辑 这里参考了ffmpeg的方式来计算时间戳. * add bom
parent
c31d44d6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
3 行删除
+12
-3
src/Rtmp/RtmpPlayer.cpp
+3
-2
src/Rtmp/RtmpProtocol.cpp
+9
-1
没有找到文件。
src/Rtmp/RtmpPlayer.cpp
查看文件 @
c1d2adeb
...
@@ -214,7 +214,7 @@ inline void RtmpPlayer::send_createStream() {
...
@@ -214,7 +214,7 @@ inline void RtmpPlayer::send_createStream() {
inline
void
RtmpPlayer
::
send_play
()
{
inline
void
RtmpPlayer
::
send_play
()
{
AMFEncoder
enc
;
AMFEncoder
enc
;
enc
<<
"play"
<<
++
_send_req_id
<<
nullptr
<<
_stream_id
<<
(
double
)
_stream_index
;
enc
<<
"play"
<<
++
_send_req_id
<<
nullptr
<<
_stream_id
<<
"-2000"
;
sendRequest
(
MSG_CMD
,
enc
.
data
());
sendRequest
(
MSG_CMD
,
enc
.
data
());
auto
fun
=
[](
AMFValue
&
val
)
{
auto
fun
=
[](
AMFValue
&
val
)
{
//TraceL << "play onStatus";
//TraceL << "play onStatus";
...
@@ -297,7 +297,8 @@ void RtmpPlayer::onCmd_onStatus(AMFDecoder &dec) {
...
@@ -297,7 +297,8 @@ void RtmpPlayer::onCmd_onStatus(AMFDecoder &dec) {
auto
level
=
val
[
"level"
];
auto
level
=
val
[
"level"
];
auto
code
=
val
[
"code"
].
as_string
();
auto
code
=
val
[
"code"
].
as_string
();
if
(
level
.
type
()
==
AMF_STRING
)
{
if
(
level
.
type
()
==
AMF_STRING
)
{
if
(
level
.
as_string
()
!=
"status"
)
{
// warning 不应该断开
if
(
level
.
as_string
()
!=
"status"
&&
level
.
as_string
()
!=
"warning"
)
{
throw
std
::
runtime_error
(
StrPrinter
<<
"onStatus 失败:"
<<
level
.
as_string
()
<<
" "
<<
code
<<
endl
);
throw
std
::
runtime_error
(
StrPrinter
<<
"onStatus 失败:"
<<
level
.
as_string
()
<<
" "
<<
code
<<
endl
);
}
}
}
}
...
...
src/Rtmp/RtmpProtocol.cpp
查看文件 @
c1d2adeb
...
@@ -766,6 +766,9 @@ void RtmpProtocol::handle_chunk(RtmpPacket::Ptr packet) {
...
@@ -766,6 +766,9 @@ void RtmpProtocol::handle_chunk(RtmpPacket::Ptr packet) {
case
MSG_AGGREGATE
:
{
case
MSG_AGGREGATE
:
{
auto
ptr
=
(
uint8_t
*
)
chunk_data
.
buffer
.
data
();
auto
ptr
=
(
uint8_t
*
)
chunk_data
.
buffer
.
data
();
auto
ptr_tail
=
ptr
+
chunk_data
.
buffer
.
size
();
auto
ptr_tail
=
ptr
+
chunk_data
.
buffer
.
size
();
uint32_t
latest_ts
,
timestamp
;
timestamp
=
chunk_data
.
time_stamp
;
bool
first_message
=
true
;
while
(
ptr
+
8
+
3
<
ptr_tail
)
{
while
(
ptr
+
8
+
3
<
ptr_tail
)
{
auto
type
=
*
ptr
;
auto
type
=
*
ptr
;
ptr
+=
1
;
ptr
+=
1
;
...
@@ -781,12 +784,17 @@ void RtmpProtocol::handle_chunk(RtmpPacket::Ptr packet) {
...
@@ -781,12 +784,17 @@ void RtmpProtocol::handle_chunk(RtmpPacket::Ptr packet) {
if
(
ptr
+
size
>
ptr_tail
)
{
if
(
ptr
+
size
>
ptr_tail
)
{
break
;
break
;
}
}
if
(
!
first_message
)
{
timestamp
+=
ts
-
latest_ts
;
}
first_message
=
false
;
latest_ts
=
ts
;
auto
sub_packet_ptr
=
RtmpPacket
::
create
();
auto
sub_packet_ptr
=
RtmpPacket
::
create
();
auto
&
sub_packet
=
*
sub_packet_ptr
;
auto
&
sub_packet
=
*
sub_packet_ptr
;
sub_packet
.
buffer
.
assign
((
char
*
)
ptr
,
size
);
sub_packet
.
buffer
.
assign
((
char
*
)
ptr
,
size
);
sub_packet
.
type_id
=
type
;
sub_packet
.
type_id
=
type
;
sub_packet
.
body_size
=
size
;
sub_packet
.
body_size
=
size
;
sub_packet
.
time_stamp
=
t
s
;
sub_packet
.
time_stamp
=
t
imestamp
;
sub_packet
.
stream_index
=
chunk_data
.
stream_index
;
sub_packet
.
stream_index
=
chunk_data
.
stream_index
;
sub_packet
.
chunk_id
=
chunk_data
.
chunk_id
;
sub_packet
.
chunk_id
=
chunk_data
.
chunk_id
;
handle_chunk
(
std
::
move
(
sub_packet_ptr
));
handle_chunk
(
std
::
move
(
sub_packet_ptr
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论