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
41c09757
Commit
41c09757
authored
Aug 21, 2021
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决GB28181推流无ntp时间戳导致的问题
parent
ce41fa26
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
15 行增加
和
4 行删除
+15
-4
src/Rtp/GB28181Process.cpp
+4
-1
src/Rtsp/RtpReceiver.cpp
+9
-3
src/Rtsp/RtpReceiver.h
+2
-0
没有找到文件。
src/Rtp/GB28181Process.cpp
查看文件 @
41c09757
...
...
@@ -27,10 +27,13 @@ static inline bool checkTS(const uint8_t *packet, size_t bytes){
class
RtpReceiverImp
:
public
RtpTrackImp
{
public
:
using
Ptr
=
std
::
shared_ptr
<
RtpReceiverImp
>
;
RtpReceiverImp
(
int
sample_rate
,
RtpTrackImp
::
OnSorted
cb
,
RtpTrackImp
::
BeforeSorted
cb_before
=
nullptr
){
RtpReceiverImp
(
int
sample_rate
,
RtpTrackImp
::
OnSorted
cb
,
RtpTrackImp
::
BeforeSorted
cb_before
=
nullptr
)
{
_sample_rate
=
sample_rate
;
setOnSorted
(
std
::
move
(
cb
));
setBeforeSorted
(
std
::
move
(
cb_before
));
//GB28181推流不支持ntp时间戳
setNtpStamp
(
0
,
0
,
0
);
}
~
RtpReceiverImp
()
override
=
default
;
...
...
src/Rtsp/RtpReceiver.cpp
查看文件 @
41c09757
...
...
@@ -89,14 +89,20 @@ RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr,
data
[
3
]
=
len
&
0xFF
;
//拷贝rtp
memcpy
(
&
data
[
4
],
ptr
,
len
);
//设置ntp时间戳
rtp
->
ntp_stamp
=
_ntp_stamp
.
getNtpStamp
(
ntohl
(
rtp
->
getHeader
()
->
stamp
),
sample_rate
);
if
(
_disable_ntp
)
{
//不支持ntp时间戳,例如国标推流,那么直接使用rtp时间戳
rtp
->
ntp_stamp
=
rtp
->
getStamp
()
*
uint64_t
(
1000
)
/
sample_rate
;
}
else
{
//设置ntp时间戳
rtp
->
ntp_stamp
=
_ntp_stamp
.
getNtpStamp
(
ntohl
(
rtp
->
getHeader
()
->
stamp
),
sample_rate
);
}
onBeforeRtpSorted
(
rtp
);
sortPacket
(
rtp
->
getSeq
(),
rtp
);
return
rtp
;
}
void
RtpTrack
::
setNtpStamp
(
uint32_t
rtp_stamp
,
uint32_t
sample_rate
,
uint64_t
ntp_stamp_ms
){
void
RtpTrack
::
setNtpStamp
(
uint32_t
rtp_stamp
,
uint32_t
sample_rate
,
uint64_t
ntp_stamp_ms
)
{
_disable_ntp
=
rtp_stamp
==
0
&&
sample_rate
==
0
&&
ntp_stamp_ms
==
0
;
_ntp_stamp
.
setNtpStamp
(
rtp_stamp
,
sample_rate
,
ntp_stamp_ms
);
}
...
...
src/Rtsp/RtpReceiver.h
查看文件 @
41c09757
...
...
@@ -183,6 +183,7 @@ protected:
virtual
void
onBeforeRtpSorted
(
const
RtpPacket
::
Ptr
&
rtp
)
{}
private
:
bool
_disable_ntp
=
false
;
uint32_t
_ssrc
=
0
;
Ticker
_ssrc_alive
;
NtpStamp
_ntp_stamp
;
...
...
@@ -241,6 +242,7 @@ public:
/**
* 设置ntp时间戳,在收到rtcp sender report时设置
* 如果rtp_stamp/sample_rate/ntp_stamp_ms都为0,那么采用rtp时间戳为ntp时间戳
* @param index track下标索引
* @param rtp_stamp rtp时间戳
* @param sample_rate 时间戳采样率
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论