Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
a46b9829
提交
a46b9829
authored
1月 15, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rtcp: local receiver report generation
上级
9621f000
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
103 行增加
和
14 行删除
+103
-14
DepLibUV.h
worker/include/DepLibUV.h
+7
-0
RtpReceiver.h
worker/include/RTC/RtpReceiver.h
+7
-6
RtpStream.h
worker/include/RTC/RtpStream.h
+8
-0
Room.cpp
worker/src/RTC/Room.cpp
+5
-3
RtpReceiver.cpp
worker/src/RTC/RtpReceiver.cpp
+10
-5
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+66
-0
没有找到文件。
worker/include/DepLibUV.h
浏览文件 @
a46b9829
...
...
@@ -11,6 +11,7 @@ public:
static
void
PrintVersion
();
static
void
RunLoop
();
static
uv_loop_t
*
GetLoop
();
static
uint64_t
GetTime
();
private
:
static
uv_loop_t
*
loop
;
...
...
@@ -24,4 +25,10 @@ uv_loop_t* DepLibUV::GetLoop()
return
DepLibUV
::
loop
;
}
inline
uint64_t
DepLibUV
::
GetTime
()
{
return
uv_now
(
DepLibUV
::
loop
);
}
#endif
worker/include/RTC/RtpReceiver.h
浏览文件 @
a46b9829
...
...
@@ -50,7 +50,7 @@ namespace RTC
RTC
::
RtpParameters
*
GetParameters
();
void
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
RequestRtpRetransmission
(
uint16_t
seq
,
uint16_t
bitmask
,
std
::
vector
<
RTC
::
RtpPacket
*>&
container
);
void
ReceiveRtcp
ReceiverReport
(
RTC
::
RTCP
::
Receiv
erReport
*
report
);
void
ReceiveRtcp
SenderReport
(
RTC
::
RTCP
::
Send
erReport
*
report
);
RTC
::
RTCP
::
ReceiverReport
*
GetRtcpReceiverReport
();
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
);
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
);
...
...
@@ -74,8 +74,6 @@ namespace RTC
// Others.
bool
rtpRawEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
// Receiver Report holding the RTP stats.
std
::
unique_ptr
<
RTC
::
RTCP
::
ReceiverReport
>
receiverReport
;
};
/* Inline methods. */
...
...
@@ -106,10 +104,13 @@ namespace RTC
}
inline
RTC
::
RTCP
::
ReceiverReport
*
RtpReceiver
::
GetRtcpReceiverReport
(
)
void
RtpReceiver
::
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
)
{
return
this
->
receiverReport
.
release
();
};
// TODO: This assumes a single stream for now.
if
(
this
->
rtpStream
)
this
->
rtpStream
->
ReceiveRtcpSenderReport
(
report
);
}
}
#endif
worker/include/RTC/RtpStream.h
浏览文件 @
a46b9829
...
...
@@ -3,6 +3,8 @@
#include "common.h"
#include "RTC/RtpPacket.h"
#include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/SenderReport.h"
#include <vector>
#include <list>
...
...
@@ -29,18 +31,24 @@ namespace RTC
bool
ReceivePacket
(
RTC
::
RtpPacket
*
packet
);
void
RequestRtpRetransmission
(
uint16_t
seq
,
uint16_t
bitmask
,
std
::
vector
<
RTC
::
RtpPacket
*>&
container
);
RTC
::
RTCP
::
ReceiverReport
*
GetRtcpReceiverReport
();
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
private
:
void
InitSeq
(
uint16_t
seq
);
bool
UpdateSeq
(
uint16_t
seq
);
void
CleanBuffer
();
void
StorePacket
(
RTC
::
RtpPacket
*
packet
);
void
CalculateJitter
(
uint32_t
rtpTimestamp
);
void
Dump
();
private
:
// Given as argument.
uint32_t
clockRate
=
0
;
bool
started
=
false
;
// Whether at least a RTP packet has been received.
uint32_t
last_sr_timestamp
=
0
;
// The middle 32 bits out of 64 in the NTP timestamp received in the most recent sender report.
uint64_t
last_sr_received
=
0
;
// Wallclock time representing the most recent sender report arrival.
// https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff.
uint16_t
max_seq
=
0
;
// Highest seq. number seen.
uint32_t
cycles
=
0
;
// Shifted count of seq. number cycles.
...
...
worker/src/RTC/Room.cpp
浏览文件 @
a46b9829
...
...
@@ -604,9 +604,8 @@ namespace RTC
MS_ASSERT
(
this
->
mapRtpSenderRtpReceiver
.
find
(
rtpSender
)
!=
this
->
mapRtpSenderRtpReceiver
.
end
(),
"RtpSender not present in the map"
);
auto
&
rtpReceiver
=
this
->
mapRtpSenderRtpReceiver
[
rtpSender
];
rtpReceiver
->
ReceiveRtcpReceiverReport
(
report
);
// TODO: Calculate real downstream stats for the given RtpSender,
// considering the ReceiverReport generated locally and this one.
}
void
Room
::
onPeerRtcpFeedback
(
RTC
::
Peer
*
peer
,
RTC
::
RtpSender
*
rtpSender
,
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
...
...
@@ -668,6 +667,9 @@ namespace RTC
{
MS_TRACE
();
// RtpReceiver needs the sender report in order to generate it's receiver report.
rtpReceiver
->
ReceiveRtcpSenderReport
(
report
);
MS_ASSERT
(
this
->
mapRtpReceiverRtpSenders
.
find
(
rtpReceiver
)
!=
this
->
mapRtpReceiverRtpSenders
.
end
(),
"RtpReceiver not present in the map"
);
auto
&
rtpSenders
=
this
->
mapRtpReceiverRtpSenders
[
rtpReceiver
];
...
...
worker/src/RTC/RtpReceiver.cpp
浏览文件 @
a46b9829
...
...
@@ -323,12 +323,17 @@ namespace RTC
// SSRC values in received RTP packets to match the chosen random values.
}
void
RtpReceiver
::
ReceiveRtcpReceiverReport
(
RTC
::
RTCP
::
ReceiverReport
*
report
)
RTC
::
RTCP
::
ReceiverReport
*
RtpReceiver
::
GetRtcpReceiverReport
(
)
{
MS_TRACE
();
this
->
receiverReport
.
reset
(
new
RTC
::
RTCP
::
ReceiverReport
(
report
));
this
->
receiverReport
->
Serialize
();
if
(
this
->
rtpStream
)
{
RTC
::
RTCP
::
ReceiverReport
*
report
=
this
->
rtpStream
->
GetRtcpReceiverReport
();
// TODO: This assumes a single stream for now.
report
->
SetSsrc
(
this
->
rtpParameters
->
encodings
[
0
].
ssrc
);
return
report
;
}
else
return
nullptr
;
};
void
RtpReceiver
::
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
a46b9829
...
...
@@ -4,6 +4,7 @@
// #define MS_LOG_DEV
#include "RTC/RtpStream.h"
#include "DepLibUV.h"
#include "Logger.h"
#define MIN_SEQUENTIAL 2
...
...
@@ -62,6 +63,9 @@ namespace RTC
// Dump();
}
// Calculate Jitter
this
->
CalculateJitter
(
packet
->
GetTimestamp
());
return
true
;
}
...
...
@@ -330,6 +334,68 @@ namespace RTC
(
*
new_buffer_it
).
packet
=
packet
->
Clone
(
store
);
}
void
RtpStream
::
CalculateJitter
(
uint32_t
rtpTimestamp
)
{
if
(
!
this
->
clockRate
)
return
;
int
transit
=
DepLibUV
::
GetTime
()
-
(
rtpTimestamp
*
1000
/
this
->
clockRate
);
int
d
=
transit
-
this
->
transit
;
this
->
transit
=
transit
;
if
(
d
<
0
)
d
=
-
d
;
this
->
jitter
+=
(
1.
/
16.
)
*
((
double
)
d
-
this
->
jitter
);
}
RTC
::
RTCP
::
ReceiverReport
*
RtpStream
::
GetRtcpReceiverReport
()
{
RTC
::
RTCP
::
ReceiverReport
*
report
=
new
RTC
::
RTCP
::
ReceiverReport
();
// Calculate Packets Expected and Lost
uint32_t
expected
=
(
this
->
cycles
+
this
->
max_seq
)
-
this
->
base_seq
+
1
;
int32_t
total_lost
=
expected
-
this
->
received
;
report
->
SetTotalLost
(
total_lost
);
// Calculate Fraction Lost
uint32_t
expected_interval
=
expected
-
this
->
expected_prior
;
this
->
expected_prior
=
expected
;
uint32_t
received_interval
=
this
->
received
-
this
->
received_prior
;
this
->
received_prior
=
this
->
received
;
uint32_t
lost_interval
=
expected_interval
-
received_interval
;
uint8_t
fraction_lost
;
if
(
expected_interval
==
0
||
lost_interval
<=
0
)
fraction_lost
=
0
;
else
fraction_lost
=
(
lost_interval
<<
8
)
/
expected_interval
;
report
->
SetFractionLost
(
fraction_lost
);
// Fill the rest of the report
report
->
SetLastSeq
((
uint32_t
)
this
->
max_seq
+
this
->
cycles
);
report
->
SetJitter
(
this
->
jitter
);
if
(
this
->
last_sr_received
)
{
uint32_t
dlsr
=
(
DepLibUV
::
GetTime
()
-
this
->
last_sr_received
)
/
1000
*
65536
;
report
->
SetDelaySinceLastSenderReport
(
dlsr
);
report
->
SetLastSenderReport
(
this
->
last_sr_timestamp
);
}
else
{
report
->
SetDelaySinceLastSenderReport
(
0
);
report
->
SetLastSenderReport
(
0
);
}
return
report
;
}
void
RtpStream
::
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
)
{
this
->
last_sr_received
=
DepLibUV
::
GetTime
();
this
->
last_sr_timestamp
=
htonl
(
report
->
GetNtpSec
())
<<
16
;
this
->
last_sr_timestamp
+=
htonl
(
report
->
GetNtpFrac
())
>>
16
;
}
// TODO: TMP
void
RtpStream
::
Dump
()
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论