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
cffc0743
Commit
cffc0743
authored
Jul 14, 2022
by
xiongguangjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
format code use clang-format
parent
602b475a
全部展开
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
172 行增加
和
171 行删除
+172
-171
src/Rtcp/Rtcp.cpp
+0
-0
src/Rtcp/Rtcp.h
+71
-76
src/Rtcp/RtcpContext.cpp
+49
-43
src/Rtcp/RtcpContext.h
+22
-23
src/Rtcp/RtcpFCI.cpp
+0
-0
src/Rtcp/RtcpFCI.h
+30
-29
webrtc/WebRtcTransport.cpp
+0
-0
没有找到文件。
src/Rtcp/Rtcp.cpp
查看文件 @
cffc0743
差异被折叠。
点击展开。
src/Rtcp/Rtcp.h
查看文件 @
cffc0743
差异被折叠。
点击展开。
src/Rtcp/RtcpContext.cpp
查看文件 @
cffc0743
...
@@ -14,7 +14,8 @@ using namespace toolkit;
...
@@ -14,7 +14,8 @@ using namespace toolkit;
namespace
mediakit
{
namespace
mediakit
{
void
RtcpContext
::
onRtp
(
uint16_t
/*seq*/
,
uint32_t
stamp
,
uint64_t
ntp_stamp_ms
,
uint32_t
/*sample_rate*/
,
size_t
bytes
)
{
void
RtcpContext
::
onRtp
(
uint16_t
/*seq*/
,
uint32_t
stamp
,
uint64_t
ntp_stamp_ms
,
uint32_t
/*sample_rate*/
,
size_t
bytes
)
{
++
_packets
;
++
_packets
;
_bytes
+=
bytes
;
_bytes
+=
bytes
;
_last_rtp_stamp
=
stamp
;
_last_rtp_stamp
=
stamp
;
...
@@ -52,9 +53,9 @@ Buffer::Ptr RtcpContext::createRtcpXRDLRR(uint32_t rtcp_ssrc, uint32_t rtp_ssrc)
...
@@ -52,9 +53,9 @@ Buffer::Ptr RtcpContext::createRtcpXRDLRR(uint32_t rtcp_ssrc, uint32_t rtp_ssrc)
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
void
RtcpContextForSend
::
onRtcp
(
RtcpHeader
*
rtcp
)
{
void
RtcpContextForSend
::
onRtcp
(
RtcpHeader
*
rtcp
)
{
switch
((
RtcpType
)
rtcp
->
pt
)
{
switch
((
RtcpType
)
rtcp
->
pt
)
{
case
RtcpType
:
:
RTCP_RR
:
{
case
RtcpType
:
:
RTCP_RR
:
{
auto
rtcp_rr
=
(
RtcpRR
*
)
rtcp
;
auto
rtcp_rr
=
(
RtcpRR
*
)
rtcp
;
for
(
auto
item
:
rtcp_rr
->
getItemList
())
{
for
(
auto
item
:
rtcp_rr
->
getItemList
())
{
if
(
!
item
->
last_sr_stamp
)
{
if
(
!
item
->
last_sr_stamp
)
{
continue
;
continue
;
...
@@ -63,32 +64,34 @@ void RtcpContextForSend::onRtcp(RtcpHeader *rtcp) {
...
@@ -63,32 +64,34 @@ void RtcpContextForSend::onRtcp(RtcpHeader *rtcp) {
if
(
it
==
_sender_report_ntp
.
end
())
{
if
(
it
==
_sender_report_ntp
.
end
())
{
continue
;
continue
;
}
}
//
发送sr到收到rr之间的时间戳增量
//
发送sr到收到rr之间的时间戳增量
auto
ms_inc
=
getCurrentMillisecond
()
-
it
->
second
;
auto
ms_inc
=
getCurrentMillisecond
()
-
it
->
second
;
//
rtp接收端收到sr包后,回复rr包的延时,已转换为毫秒
//
rtp接收端收到sr包后,回复rr包的延时,已转换为毫秒
auto
delay_ms
=
(
uint64_t
)
item
->
delay_since_last_sr
*
1000
/
65536
;
auto
delay_ms
=
(
uint64_t
)
item
->
delay_since_last_sr
*
1000
/
65536
;
auto
rtt
=
(
int
)
(
ms_inc
-
delay_ms
);
auto
rtt
=
(
int
)
(
ms_inc
-
delay_ms
);
if
(
rtt
>=
0
)
{
if
(
rtt
>=
0
)
{
//
rtt不可能小于0
//
rtt不可能小于0
_rtt
[
item
->
ssrc
]
=
rtt
;
_rtt
[
item
->
ssrc
]
=
rtt
;
//
InfoL << "ssrc:" << item->ssrc << ",rtt:" << rtt;
//
InfoL << "ssrc:" << item->ssrc << ",rtt:" << rtt;
}
}
}
}
break
;
break
;
}
}
case
RtcpType
:
:
RTCP_XR
:
{
case
RtcpType
:
:
RTCP_XR
:
{
auto
rtcp_xr
=
(
RtcpXRRRTR
*
)
rtcp
;
auto
rtcp_xr
=
(
RtcpXRRRTR
*
)
rtcp
;
if
(
rtcp_xr
->
bt
==
4
){
if
(
rtcp_xr
->
bt
==
4
)
{
_xr_xrrtr_recv_last_rr
[
rtcp_xr
->
ssrc
]
=
((
rtcp_xr
->
ntpmsw
&
0xFFFF
)
<<
16
)
|
((
rtcp_xr
->
ntplsw
>>
16
)
&
0xFFFF
);
_xr_xrrtr_recv_last_rr
[
rtcp_xr
->
ssrc
]
=
((
rtcp_xr
->
ntpmsw
&
0xFFFF
)
<<
16
)
|
((
rtcp_xr
->
ntplsw
>>
16
)
&
0xFFFF
);
_xr_rrtr_recv_sys_stamp
[
rtcp_xr
->
ssrc
]
=
getCurrentMillisecond
();
_xr_rrtr_recv_sys_stamp
[
rtcp_xr
->
ssrc
]
=
getCurrentMillisecond
();
}
else
if
(
rtcp_xr
->
bt
==
5
)
{
}
else
if
(
rtcp_xr
->
bt
==
5
)
{
TraceL
<<
"for sender not recive dlrr"
;
TraceL
<<
"for sender not recive dlrr"
;
}
else
{
}
else
{
TraceL
<<
"not support xr bt "
<<
rtcp_xr
->
bt
;
TraceL
<<
"not support xr bt "
<<
rtcp_xr
->
bt
;
}
}
break
;
break
;
}
}
default
:
break
;
default
:
break
;
}
}
}
}
...
@@ -105,21 +108,21 @@ Buffer::Ptr RtcpContextForSend::createRtcpSR(uint32_t rtcp_ssrc) {
...
@@ -105,21 +108,21 @@ Buffer::Ptr RtcpContextForSend::createRtcpSR(uint32_t rtcp_ssrc) {
rtcp
->
setNtpStamp
(
_last_ntp_stamp_ms
);
rtcp
->
setNtpStamp
(
_last_ntp_stamp_ms
);
rtcp
->
rtpts
=
htonl
(
_last_rtp_stamp
);
rtcp
->
rtpts
=
htonl
(
_last_rtp_stamp
);
rtcp
->
ssrc
=
htonl
(
rtcp_ssrc
);
rtcp
->
ssrc
=
htonl
(
rtcp_ssrc
);
rtcp
->
packet_count
=
htonl
((
uint32_t
)
_packets
);
rtcp
->
packet_count
=
htonl
((
uint32_t
)
_packets
);
rtcp
->
octet_count
=
htonl
((
uint32_t
)
_bytes
);
rtcp
->
octet_count
=
htonl
((
uint32_t
)
_bytes
);
//记录上次发送的sender report信息,用于后续统计rtt
//
记录上次发送的sender report信息,用于后续统计rtt
auto
last_sr_lsr
=
((
ntohl
(
rtcp
->
ntpmsw
)
&
0xFFFF
)
<<
16
)
|
((
ntohl
(
rtcp
->
ntplsw
)
>>
16
)
&
0xFFFF
);
auto
last_sr_lsr
=
((
ntohl
(
rtcp
->
ntpmsw
)
&
0xFFFF
)
<<
16
)
|
((
ntohl
(
rtcp
->
ntplsw
)
>>
16
)
&
0xFFFF
);
_sender_report_ntp
[
last_sr_lsr
]
=
getCurrentMillisecond
();
_sender_report_ntp
[
last_sr_lsr
]
=
getCurrentMillisecond
();
if
(
_sender_report_ntp
.
size
()
>=
5
)
{
if
(
_sender_report_ntp
.
size
()
>=
5
)
{
//删除最早的sr rtcp
//
删除最早的sr rtcp
_sender_report_ntp
.
erase
(
_sender_report_ntp
.
begin
());
_sender_report_ntp
.
erase
(
_sender_report_ntp
.
begin
());
}
}
return
RtcpHeader
::
toBuffer
(
std
::
move
(
rtcp
));
return
RtcpHeader
::
toBuffer
(
std
::
move
(
rtcp
));
}
}
toolkit
::
Buffer
::
Ptr
RtcpContextForSend
::
createRtcpXRDLRR
(
uint32_t
rtcp_ssrc
,
uint32_t
rtp_ssrc
){
toolkit
::
Buffer
::
Ptr
RtcpContextForSend
::
createRtcpXRDLRR
(
uint32_t
rtcp_ssrc
,
uint32_t
rtp_ssrc
)
{
auto
rtcp
=
RtcpXRDLRR
::
create
(
1
);
auto
rtcp
=
RtcpXRDLRR
::
create
(
1
);
rtcp
->
bt
=
5
;
rtcp
->
bt
=
5
;
rtcp
->
reserved
=
0
;
rtcp
->
reserved
=
0
;
...
@@ -127,14 +130,14 @@ toolkit::Buffer::Ptr RtcpContextForSend::createRtcpXRDLRR(uint32_t rtcp_ssrc, ui
...
@@ -127,14 +130,14 @@ toolkit::Buffer::Ptr RtcpContextForSend::createRtcpXRDLRR(uint32_t rtcp_ssrc, ui
rtcp
->
ssrc
=
htonl
(
rtcp_ssrc
);
rtcp
->
ssrc
=
htonl
(
rtcp_ssrc
);
rtcp
->
items
.
ssrc
=
htonl
(
rtp_ssrc
);
rtcp
->
items
.
ssrc
=
htonl
(
rtp_ssrc
);
if
(
_xr_xrrtr_recv_last_rr
.
find
(
rtp_ssrc
)
==
_xr_xrrtr_recv_last_rr
.
end
())
{
if
(
_xr_xrrtr_recv_last_rr
.
find
(
rtp_ssrc
)
==
_xr_xrrtr_recv_last_rr
.
end
())
{
rtcp
->
items
.
lrr
=
0
;
rtcp
->
items
.
lrr
=
0
;
WarnL
;
WarnL
;
}
else
{
}
else
{
rtcp
->
items
.
lrr
=
htonl
(
_xr_xrrtr_recv_last_rr
[
rtp_ssrc
]);
rtcp
->
items
.
lrr
=
htonl
(
_xr_xrrtr_recv_last_rr
[
rtp_ssrc
]);
}
}
if
(
_xr_rrtr_recv_sys_stamp
.
find
(
rtp_ssrc
)
==
_xr_rrtr_recv_sys_stamp
.
end
())
{
if
(
_xr_rrtr_recv_sys_stamp
.
find
(
rtp_ssrc
)
==
_xr_rrtr_recv_sys_stamp
.
end
())
{
rtcp
->
items
.
dlrr
=
0
;
rtcp
->
items
.
dlrr
=
0
;
WarnL
;
WarnL
;
}
else
{
}
else
{
...
@@ -149,39 +152,41 @@ toolkit::Buffer::Ptr RtcpContextForSend::createRtcpXRDLRR(uint32_t rtcp_ssrc, ui
...
@@ -149,39 +152,41 @@ toolkit::Buffer::Ptr RtcpContextForSend::createRtcpXRDLRR(uint32_t rtcp_ssrc, ui
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
void
RtcpContextForRecv
::
onRtp
(
uint16_t
seq
,
uint32_t
stamp
,
uint64_t
ntp_stamp_ms
,
uint32_t
sample_rate
,
size_t
bytes
)
{
void
RtcpContextForRecv
::
onRtp
(
uint16_t
seq
,
uint32_t
stamp
,
uint64_t
ntp_stamp_ms
,
uint32_t
sample_rate
,
size_t
bytes
)
{
{
{
//接收者才做复杂的统计运算
//
接收者才做复杂的统计运算
auto
sys_stamp
=
getCurrentMillisecond
();
auto
sys_stamp
=
getCurrentMillisecond
();
if
(
_last_rtp_sys_stamp
)
{
if
(
_last_rtp_sys_stamp
)
{
//计算时间戳抖动值
// 计算时间戳抖动值
double
diff
=
double
((
int64_t
(
sys_stamp
)
-
int64_t
(
_last_rtp_sys_stamp
))
*
(
sample_rate
/
double
(
1000.0
))
double
diff
=
double
(
(
int64_t
(
sys_stamp
)
-
int64_t
(
_last_rtp_sys_stamp
))
*
(
sample_rate
/
double
(
1000.0
))
-
(
int64_t
(
stamp
)
-
int64_t
(
_last_rtp_stamp
)));
-
(
int64_t
(
stamp
)
-
int64_t
(
_last_rtp_stamp
)));
if
(
diff
<
0
)
{
if
(
diff
<
0
)
{
diff
=
-
diff
;
diff
=
-
diff
;
}
}
//抖动单位为采样次数
//
抖动单位为采样次数
_jitter
+=
(
diff
-
_jitter
)
/
16.0
;
_jitter
+=
(
diff
-
_jitter
)
/
16.0
;
}
else
{
}
else
{
_jitter
=
0
;
_jitter
=
0
;
}
}
if
(
_last_rtp_seq
>
0xFF00
&&
seq
<
0xFF
&&
(
!
_seq_cycles
||
_packets
-
_last_cycle_packets
>
0x1FFF
))
{
if
(
_last_rtp_seq
>
0xFF00
&&
seq
<
0xFF
&&
(
!
_seq_cycles
||
_packets
-
_last_cycle_packets
>
0x1FFF
))
{
//上次seq大于0xFF00且本次seq小于0xFF,
//
上次seq大于0xFF00且本次seq小于0xFF,
//且未发生回环或者距离上次回环间隔超过0x1FFF个包,则认为回环
//
且未发生回环或者距离上次回环间隔超过0x1FFF个包,则认为回环
++
_seq_cycles
;
++
_seq_cycles
;
_last_cycle_packets
=
_packets
;
_last_cycle_packets
=
_packets
;
_seq_max
=
seq
;
_seq_max
=
seq
;
}
else
if
(
seq
>
_seq_max
)
{
}
else
if
(
seq
>
_seq_max
)
{
//本次回环前最大seq
//
本次回环前最大seq
_seq_max
=
seq
;
_seq_max
=
seq
;
}
}
if
(
!
_seq_base
)
{
if
(
!
_seq_base
)
{
//记录第一个rtp的seq
//
记录第一个rtp的seq
_seq_base
=
seq
;
_seq_base
=
seq
;
}
else
if
(
!
_seq_cycles
&&
seq
<
_seq_base
)
{
}
else
if
(
!
_seq_cycles
&&
seq
<
_seq_base
)
{
//未发生回环,那么取最新的seq为基准seq
//
未发生回环,那么取最新的seq为基准seq
_seq_base
=
seq
;
_seq_base
=
seq
;
}
}
...
@@ -192,9 +197,9 @@ void RtcpContextForRecv::onRtp(uint16_t seq, uint32_t stamp, uint64_t ntp_stamp_
...
@@ -192,9 +197,9 @@ void RtcpContextForRecv::onRtp(uint16_t seq, uint32_t stamp, uint64_t ntp_stamp_
}
}
void
RtcpContextForRecv
::
onRtcp
(
RtcpHeader
*
rtcp
)
{
void
RtcpContextForRecv
::
onRtcp
(
RtcpHeader
*
rtcp
)
{
switch
((
RtcpType
)
rtcp
->
pt
)
{
switch
((
RtcpType
)
rtcp
->
pt
)
{
case
RtcpType
:
:
RTCP_SR
:
{
case
RtcpType
:
:
RTCP_SR
:
{
auto
rtcp_sr
=
(
RtcpSR
*
)
rtcp
;
auto
rtcp_sr
=
(
RtcpSR
*
)
rtcp
;
/**
/**
last SR timestamp (LSR): 32 bits
last SR timestamp (LSR): 32 bits
The middle 32 bits out of 64 in the NTP timestamp (as explained in
The middle 32 bits out of 64 in the NTP timestamp (as explained in
...
@@ -206,7 +211,8 @@ void RtcpContextForRecv::onRtcp(RtcpHeader *rtcp) {
...
@@ -206,7 +211,8 @@ void RtcpContextForRecv::onRtcp(RtcpHeader *rtcp) {
_last_sr_ntp_sys
=
getCurrentMillisecond
();
_last_sr_ntp_sys
=
getCurrentMillisecond
();
break
;
break
;
}
}
default
:
break
;
default
:
break
;
}
}
}
}
...
@@ -236,7 +242,7 @@ Buffer::Ptr RtcpContextForRecv::createRtcpRR(uint32_t rtcp_ssrc, uint32_t rtp_ss
...
@@ -236,7 +242,7 @@ Buffer::Ptr RtcpContextForRecv::createRtcpRR(uint32_t rtcp_ssrc, uint32_t rtp_ss
auto
rtcp
=
RtcpRR
::
create
(
1
);
auto
rtcp
=
RtcpRR
::
create
(
1
);
rtcp
->
ssrc
=
htonl
(
rtcp_ssrc
);
rtcp
->
ssrc
=
htonl
(
rtcp_ssrc
);
ReportItem
*
item
=
(
ReportItem
*
)
&
rtcp
->
items
;
ReportItem
*
item
=
(
ReportItem
*
)
&
rtcp
->
items
;
item
->
ssrc
=
htonl
(
rtp_ssrc
);
item
->
ssrc
=
htonl
(
rtp_ssrc
);
uint8_t
fraction
=
0
;
uint8_t
fraction
=
0
;
...
@@ -255,9 +261,9 @@ Buffer::Ptr RtcpContextForRecv::createRtcpRR(uint32_t rtcp_ssrc, uint32_t rtp_ss
...
@@ -255,9 +261,9 @@ Buffer::Ptr RtcpContextForRecv::createRtcpRR(uint32_t rtcp_ssrc, uint32_t rtp_ss
// now - Last SR time,单位毫秒
// now - Last SR time,单位毫秒
auto
delay
=
getCurrentMillisecond
()
-
_last_sr_ntp_sys
;
auto
delay
=
getCurrentMillisecond
()
-
_last_sr_ntp_sys
;
// in units of 1/65536 seconds
// in units of 1/65536 seconds
auto
dlsr
=
(
uint32_t
)
(
delay
/
1000.0
f
*
65536
);
auto
dlsr
=
(
uint32_t
)(
delay
/
1000.0
f
*
65536
);
item
->
delay_since_last_sr
=
htonl
(
_last_sr_lsr
?
dlsr
:
0
);
item
->
delay_since_last_sr
=
htonl
(
_last_sr_lsr
?
dlsr
:
0
);
return
RtcpHeader
::
toBuffer
(
rtcp
);
return
RtcpHeader
::
toBuffer
(
rtcp
);
}
}
}
//
namespace
mediakit
}
//
namespace
mediakit
\ No newline at end of file
\ No newline at end of file
src/Rtcp/RtcpContext.h
查看文件 @
cffc0743
...
@@ -11,9 +11,9 @@
...
@@ -11,9 +11,9 @@
#ifndef ZLMEDIAKIT_RTCPCONTEXT_H
#ifndef ZLMEDIAKIT_RTCPCONTEXT_H
#define ZLMEDIAKIT_RTCPCONTEXT_H
#define ZLMEDIAKIT_RTCPCONTEXT_H
#include <stdint.h>
#include <stddef.h>
#include "Rtcp.h"
#include "Rtcp.h"
#include <stddef.h>
#include <stdint.h>
namespace
mediakit
{
namespace
mediakit
{
...
@@ -55,7 +55,6 @@ public:
...
@@ -55,7 +55,6 @@ public:
*/
*/
virtual
toolkit
::
Buffer
::
Ptr
createRtcpSR
(
uint32_t
rtcp_ssrc
);
virtual
toolkit
::
Buffer
::
Ptr
createRtcpSR
(
uint32_t
rtcp_ssrc
);
/**
/**
* @brief 创建xr的dlrr包,用于接收者估算rtt
* @brief 创建xr的dlrr包,用于接收者估算rtt
*
*
...
@@ -82,11 +81,11 @@ public:
...
@@ -82,11 +81,11 @@ public:
virtual
size_t
geLostInterval
();
virtual
size_t
geLostInterval
();
protected
:
protected
:
//收到或发送的rtp的字节数
//
收到或发送的rtp的字节数
size_t
_bytes
=
0
;
size_t
_bytes
=
0
;
//收到或发送的rtp的个数
//
收到或发送的rtp的个数
size_t
_packets
=
0
;
size_t
_packets
=
0
;
//上次的rtp时间戳,毫秒
//
上次的rtp时间戳,毫秒
uint32_t
_last_rtp_stamp
=
0
;
uint32_t
_last_rtp_stamp
=
0
;
uint64_t
_last_ntp_stamp_ms
=
0
;
uint64_t
_last_ntp_stamp_ms
=
0
;
};
};
...
@@ -107,11 +106,11 @@ public:
...
@@ -107,11 +106,11 @@ public:
uint32_t
getRtt
(
uint32_t
ssrc
)
const
;
uint32_t
getRtt
(
uint32_t
ssrc
)
const
;
private
:
private
:
std
::
map
<
uint32_t
/*ssrc*/
,
uint32_t
/*rtt*/
>
_rtt
;
std
::
map
<
uint32_t
/*ssrc*/
,
uint32_t
/*rtt*/
>
_rtt
;
std
::
map
<
uint32_t
/*last_sr_lsr*/
,
uint64_t
/*ntp stamp*/
>
_sender_report_ntp
;
std
::
map
<
uint32_t
/*last_sr_lsr*/
,
uint64_t
/*ntp stamp*/
>
_sender_report_ntp
;
std
::
map
<
uint32_t
/*ssrc*/
,
uint64_t
/*xr rrtr sys stamp*/
>
_xr_rrtr_recv_sys_stamp
;
std
::
map
<
uint32_t
/*ssrc*/
,
uint64_t
/*xr rrtr sys stamp*/
>
_xr_rrtr_recv_sys_stamp
;
std
::
map
<
uint32_t
/*ssrc*/
,
uint32_t
/*last rr */
>
_xr_xrrtr_recv_last_rr
;
std
::
map
<
uint32_t
/*ssrc*/
,
uint32_t
/*last rr */
>
_xr_xrrtr_recv_last_rr
;
};
};
class
RtcpContextForRecv
:
public
RtcpContext
{
class
RtcpContextForRecv
:
public
RtcpContext
{
...
@@ -125,29 +124,29 @@ public:
...
@@ -125,29 +124,29 @@ public:
void
onRtcp
(
RtcpHeader
*
rtcp
)
override
;
void
onRtcp
(
RtcpHeader
*
rtcp
)
override
;
private
:
private
:
//时间戳抖动值
//
时间戳抖动值
double
_jitter
=
0
;
double
_jitter
=
0
;
//第一个seq的值
//
第一个seq的值
uint16_t
_seq_base
=
0
;
uint16_t
_seq_base
=
0
;
//rtp最大seq
//
rtp最大seq
uint16_t
_seq_max
=
0
;
uint16_t
_seq_max
=
0
;
//rtp回环次数
//
rtp回环次数
uint16_t
_seq_cycles
=
0
;
uint16_t
_seq_cycles
=
0
;
//上次回环发生时,记录的rtp包数
//
上次回环发生时,记录的rtp包数
size_t
_last_cycle_packets
=
0
;
size_t
_last_cycle_packets
=
0
;
//上次的seq
//
上次的seq
uint16_t
_last_rtp_seq
=
0
;
uint16_t
_last_rtp_seq
=
0
;
//上次的rtp的系统时间戳(毫秒)用于统计抖动
//
上次的rtp的系统时间戳(毫秒)用于统计抖动
uint64_t
_last_rtp_sys_stamp
=
0
;
uint64_t
_last_rtp_sys_stamp
=
0
;
//上次统计的丢包总数
//
上次统计的丢包总数
size_t
_last_lost
=
0
;
size_t
_last_lost
=
0
;
//上次统计应收rtp包总数
//
上次统计应收rtp包总数
size_t
_last_expected
=
0
;
size_t
_last_expected
=
0
;
//上次收到sr包时计算出的Last SR timestamp
//
上次收到sr包时计算出的Last SR timestamp
uint32_t
_last_sr_lsr
=
0
;
uint32_t
_last_sr_lsr
=
0
;
//上次收到sr时的系统时间戳,单位毫秒
//
上次收到sr时的系统时间戳,单位毫秒
uint64_t
_last_sr_ntp_sys
=
0
;
uint64_t
_last_sr_ntp_sys
=
0
;
};
};
}
//
namespace mediakit
}
//
namespace mediakit
#endif //ZLMEDIAKIT_RTCPCONTEXT_H
#endif //
ZLMEDIAKIT_RTCPCONTEXT_H
src/Rtcp/RtcpFCI.cpp
查看文件 @
cffc0743
差异被折叠。
点击展开。
src/Rtcp/RtcpFCI.h
查看文件 @
cffc0743
...
@@ -11,21 +11,21 @@
...
@@ -11,21 +11,21 @@
#ifndef ZLMEDIAKIT_RTCPFCI_H
#ifndef ZLMEDIAKIT_RTCPFCI_H
#define ZLMEDIAKIT_RTCPFCI_H
#define ZLMEDIAKIT_RTCPFCI_H
#include "Rtcp.h"
#include "Common/config.h"
#include "Common/config.h"
#include "Rtcp.h"
namespace
mediakit
{
namespace
mediakit
{
/////////////////////////////////////////// PSFB ////////////////////////////////////////////////////
/////////////////////////////////////////// PSFB ////////////////////////////////////////////////////
//PSFB fmt = 2
//
PSFB fmt = 2
//https://tools.ietf.org/html/rfc4585#section-6.3.2.2
//
https://tools.ietf.org/html/rfc4585#section-6.3.2.2
// 0 1 2 3
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | First | Number | PictureID |
// | First | Number | PictureID |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//First: 13 bits
//
First: 13 bits
// The macroblock (MB) address of the first lost macroblock. The MB
// The macroblock (MB) address of the first lost macroblock. The MB
// numbering is done such that the macroblock in the upper left
// numbering is done such that the macroblock in the upper left
// corner of the picture is considered macroblock number 1 and the
// corner of the picture is considered macroblock number 1 and the
...
@@ -101,8 +101,8 @@ public:
...
@@ -101,8 +101,8 @@ public:
}
PACKED
;
}
PACKED
;
#endif
#endif
//PSFB fmt = 4
//
PSFB fmt = 4
//https://tools.ietf.org/html/rfc5104#section-4.3.1.1
//
https://tools.ietf.org/html/rfc5104#section-4.3.1.1
// 0 1 2 3
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...
@@ -188,8 +188,8 @@ private:
...
@@ -188,8 +188,8 @@ private:
#endif
#endif
//PSFB fmt = 15
//
PSFB fmt = 15
//https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03
//
https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03
// 0 1 2 3
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...
@@ -227,9 +227,9 @@ public:
...
@@ -227,9 +227,9 @@ public:
std
::
vector
<
uint32_t
>
getSSRC
();
std
::
vector
<
uint32_t
>
getSSRC
();
private
:
private
:
//Unique identifier 'R' 'E' 'M' 'B'
//
Unique identifier 'R' 'E' 'M' 'B'
char
magic
[
4
];
char
magic
[
4
];
//Num SSRC (8 bits)/BR Exp (6 bits)/ BR Mantissa (18 bits)
//
Num SSRC (8 bits)/BR Exp (6 bits)/ BR Mantissa (18 bits)
uint8_t
bitrate
[
4
];
uint8_t
bitrate
[
4
];
// SSRC feedback (32 bits) Consists of one or more SSRC entries which
// SSRC feedback (32 bits) Consists of one or more SSRC entries which
// this feedback message applies to.
// this feedback message applies to.
...
@@ -238,8 +238,8 @@ private:
...
@@ -238,8 +238,8 @@ private:
/////////////////////////////////////////// RTPFB ////////////////////////////////////////////////////
/////////////////////////////////////////// RTPFB ////////////////////////////////////////////////////
//RTPFB fmt = 1
//
RTPFB fmt = 1
//https://tools.ietf.org/html/rfc4585#section-6.2.1
//
https://tools.ietf.org/html/rfc4585#section-6.2.1
// 0 1 2 3
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...
@@ -255,7 +255,7 @@ public:
...
@@ -255,7 +255,7 @@ public:
void
check
(
size_t
size
);
void
check
(
size_t
size
);
uint16_t
getPid
()
const
;
uint16_t
getPid
()
const
;
uint16_t
getBlp
()
const
;
uint16_t
getBlp
()
const
;
//返回丢包列表,总长度17,第一个包必丢
//
返回丢包列表,总长度17,第一个包必丢
// TODO: replace std::bitset
// TODO: replace std::bitset
std
::
vector
<
bool
>
getBitArray
()
const
;
std
::
vector
<
bool
>
getBitArray
()
const
;
std
::
string
dumpString
()
const
;
std
::
string
dumpString
()
const
;
...
@@ -318,20 +318,20 @@ public:
...
@@ -318,20 +318,20 @@ public:
} PACKED;
} PACKED;
#endif
#endif
enum
class
SymbolStatus
:
uint8_t
{
enum
class
SymbolStatus
:
uint8_t
{
//Packet not received
//
Packet not received
not_received
=
0
,
not_received
=
0
,
//Packet received, small delta (所谓small detal是指能用一个字节表示的数值)
//
Packet received, small delta (所谓small detal是指能用一个字节表示的数值)
small_delta
=
1
,
small_delta
=
1
,
// Packet received, large ornegative delta (large即是能用两个字节表示的数值)
// Packet received, large ornegative delta (large即是能用两个字节表示的数值)
large_delta
=
2
,
large_delta
=
2
,
//Reserved
//
Reserved
reserved
=
3
reserved
=
3
};
};
//RTPFB fmt = 15
//
RTPFB fmt = 15
//https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#section-3.1
//
https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#section-3.1
//https://zhuanlan.zhihu.com/p/206656654
//
https://zhuanlan.zhihu.com/p/206656654
// 0 1 2 3
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...
@@ -351,14 +351,15 @@ enum class SymbolStatus : uint8_t{
...
@@ -351,14 +351,15 @@ enum class SymbolStatus : uint8_t{
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | recv delta | recv delta | zero padding |
// | recv delta | recv delta | zero padding |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
class
FCI_TWCC
{
class
FCI_TWCC
{
public
:
public
:
static
size_t
constexpr
kSize
=
8
;
static
size_t
constexpr
kSize
=
8
;
using
TwccPacketStatus
=
std
::
map
<
uint16_t
/*rtp ext seq*/
,
std
::
pair
<
SymbolStatus
,
int16_t
/*recv delta,单位为250us*/
>
>
;
using
TwccPacketStatus
=
std
::
map
<
uint16_t
/*rtp ext seq*/
,
std
::
pair
<
SymbolStatus
,
int16_t
/*recv delta,单位为250us*/
>>
;
void
check
(
size_t
size
);
void
check
(
size_t
size
);
std
::
string
dumpString
(
size_t
total_size
)
const
;
std
::
string
dumpString
(
size_t
total_size
)
const
;
uint16_t
getBaseSeq
()
const
;
uint16_t
getBaseSeq
()
const
;
//单位64ms
//
单位64ms
uint32_t
getReferenceTime
()
const
;
uint32_t
getReferenceTime
()
const
;
uint16_t
getPacketCount
()
const
;
uint16_t
getPacketCount
()
const
;
TwccPacketStatus
getPacketChunkList
(
size_t
total_size
)
const
;
TwccPacketStatus
getPacketChunkList
(
size_t
total_size
)
const
;
...
@@ -366,15 +367,15 @@ public:
...
@@ -366,15 +367,15 @@ public:
static
std
::
string
create
(
uint32_t
ref_time
,
uint8_t
fb_pkt_count
,
TwccPacketStatus
&
status
);
static
std
::
string
create
(
uint32_t
ref_time
,
uint8_t
fb_pkt_count
,
TwccPacketStatus
&
status
);
private
:
private
:
//base sequence number,基础序号,本次反馈的第一个包的序号;也就是RTP扩展头的序列号
//
base sequence number,基础序号,本次反馈的第一个包的序号;也就是RTP扩展头的序列号
uint16_t
base_seq
;
uint16_t
base_seq
;
//packet status count, 包个数,本次反馈包含多少个包的状态;从基础序号开始算
//
packet status count, 包个数,本次反馈包含多少个包的状态;从基础序号开始算
uint16_t
pkt_status_count
;
uint16_t
pkt_status_count
;
//reference time,基准时间,绝对时间;计算该包中每个媒体包的到达时间都要基于这个基准时间计算
//
reference time,基准时间,绝对时间;计算该包中每个媒体包的到达时间都要基于这个基准时间计算
uint8_t
ref_time
[
3
];
uint8_t
ref_time
[
3
];
//feedback packet count,反馈包号,本包是第几个transport-cc包,每次加1 |
//
feedback packet count,反馈包号,本包是第几个transport-cc包,每次加1 |
uint8_t
fb_pkt_count
;
uint8_t
fb_pkt_count
;
}
PACKED
;
}
PACKED
;
}
//namespace mediakit
}
//
namespace mediakit
#endif //ZLMEDIAKIT_RTCPFCI_H
#endif //
ZLMEDIAKIT_RTCPFCI_H
webrtc/WebRtcTransport.cpp
查看文件 @
cffc0743
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论