Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
d4392bd0
Unverified
提交
d4392bd0
authored
9月 13, 2021
作者:
Gustavo Garcia
提交者:
GitHub
9月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add packetLoss stats to transport (#648)
上级
304956c2
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
141 行增加
和
1 行删除
+141
-1
direct_transport.rs
rust/src/router/direct_transport.rs
+4
-0
pipe_transport.rs
rust/src/router/pipe_transport.rs
+4
-0
plain_transport.rs
rust/src/router/plain_transport.rs
+4
-0
webrtc_transport.rs
rust/src/router/webrtc_transport.rs
+4
-0
direct_transport.rs
rust/tests/integration/direct_transport.rs
+2
-0
plain_transport.rs
rust/tests/integration/plain_transport.rs
+2
-0
webrtc_transport.rs
rust/tests/integration/webrtc_transport.rs
+2
-0
TransportCongestionControlClient.hpp
worker/include/RTC/TransportCongestionControlClient.hpp
+5
-0
TransportCongestionControlServer.hpp
worker/include/RTC/TransportCongestionControlServer.hpp
+5
-0
Transport.cpp
worker/src/RTC/Transport.cpp
+8
-0
TransportCongestionControlClient.cpp
worker/src/RTC/TransportCongestionControlClient.cpp
+55
-0
TransportCongestionControlServer.cpp
worker/src/RTC/TransportCongestionControlServer.cpp
+46
-1
没有找到文件。
rust/src/router/direct_transport.rs
浏览文件 @
d4392bd0
...
...
@@ -105,6 +105,10 @@ pub struct DirectTransportStat {
pub
available_incoming_bitrate
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
max_incoming_bitrate
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rtp_packet_loss_received
:
Option
<
f64
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rtp_packet_loss_sent
:
Option
<
f64
>
,
}
#[derive(Default)]
...
...
rust/src/router/pipe_transport.rs
浏览文件 @
d4392bd0
...
...
@@ -140,6 +140,10 @@ pub struct PipeTransportStat {
pub
available_incoming_bitrate
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
max_incoming_bitrate
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rtp_packet_loss_received
:
Option
<
f64
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rtp_packet_loss_sent
:
Option
<
f64
>
,
// PipeTransport specific.
pub
tuple
:
Option
<
TransportTuple
>
,
}
...
...
rust/src/router/plain_transport.rs
浏览文件 @
d4392bd0
...
...
@@ -158,6 +158,10 @@ pub struct PlainTransportStat {
pub
available_incoming_bitrate
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
max_incoming_bitrate
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rtp_packet_loss_received
:
Option
<
f64
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rtp_packet_loss_sent
:
Option
<
f64
>
,
// PlainTransport specific.
pub
rtcp_mux
:
bool
,
pub
comedia
:
bool
,
...
...
rust/src/router/webrtc_transport.rs
浏览文件 @
d4392bd0
...
...
@@ -209,6 +209,10 @@ pub struct WebRtcTransportStat {
pub
available_incoming_bitrate
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
max_incoming_bitrate
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rtp_packet_loss_received
:
Option
<
f64
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rtp_packet_loss_sent
:
Option
<
f64
>
,
// WebRtcTransport specific.
pub
ice_role
:
IceRole
,
pub
ice_state
:
IceState
,
...
...
rust/tests/integration/direct_transport.rs
浏览文件 @
d4392bd0
...
...
@@ -150,6 +150,8 @@ fn get_stats_succeeds() {
assert_eq!
(
stats
[
0
]
.rtx_send_bitrate
,
0
);
assert_eq!
(
stats
[
0
]
.probation_bytes_sent
,
0
);
assert_eq!
(
stats
[
0
]
.probation_send_bitrate
,
0
);
assert_eq!
(
stats
[
0
]
.rtp_packet_loss_received
,
None
);
assert_eq!
(
stats
[
0
]
.rtp_packet_loss_sent
,
None
);
});
}
...
...
rust/tests/integration/plain_transport.rs
浏览文件 @
d4392bd0
...
...
@@ -411,6 +411,8 @@ fn get_stats_succeeds() {
assert_eq!
(
stats
[
0
]
.rtx_send_bitrate
,
0
);
assert_eq!
(
stats
[
0
]
.probation_bytes_sent
,
0
);
assert_eq!
(
stats
[
0
]
.probation_send_bitrate
,
0
);
assert_eq!
(
stats
[
0
]
.rtp_packet_loss_received
,
None
);
assert_eq!
(
stats
[
0
]
.rtp_packet_loss_sent
,
None
);
assert
!
(
matches!
(
stats
[
0
]
.tuple
,
Some
(
TransportTuple
::
LocalOnly
{
..
}),
...
...
rust/tests/integration/webrtc_transport.rs
浏览文件 @
d4392bd0
...
...
@@ -360,6 +360,8 @@ fn get_stats_succeeds() {
assert_eq!
(
stats
[
0
]
.probation_send_bitrate
,
0
);
assert_eq!
(
stats
[
0
]
.ice_selected_tuple
,
None
);
assert_eq!
(
stats
[
0
]
.max_incoming_bitrate
,
None
);
assert_eq!
(
stats
[
0
]
.rtp_packet_loss_received
,
None
);
assert_eq!
(
stats
[
0
]
.rtp_packet_loss_sent
,
None
);
});
}
...
...
worker/include/RTC/TransportCongestionControlClient.hpp
浏览文件 @
d4392bd0
...
...
@@ -13,6 +13,7 @@
#include <libwebrtc/api/transport/network_types.h>
#include <libwebrtc/call/rtp_transport_controller_send.h>
#include <libwebrtc/modules/pacing/packet_router.h>
#include <deque>
namespace
RTC
{
...
...
@@ -76,10 +77,12 @@ namespace RTC
return
this
->
bitrates
;
}
uint32_t
GetAvailableBitrate
()
const
;
double
GetPacketLoss
()
const
;
void
RescheduleNextAvailableBitrateEvent
();
private
:
void
MayEmitAvailableBitrateEvent
(
uint32_t
previousAvailableBitrate
);
void
UpdatePacketLoss
(
double
packetLoss
);
// jmillan: missing.
// void OnRemoteNetworkEstimate(NetworkStateEstimate estimate) override;
...
...
@@ -113,6 +116,8 @@ namespace RTC
bool
availableBitrateEventCalled
{
false
};
uint64_t
lastAvailableBitrateEventAtMs
{
0u
};
RTC
::
TrendCalculator
desiredBitrateTrend
;
std
::
deque
<
double
>
packetLossHistory
;
double
packetLoss
{
0
};
};
}
// namespace RTC
...
...
worker/include/RTC/TransportCongestionControlServer.hpp
浏览文件 @
d4392bd0
...
...
@@ -8,6 +8,7 @@
#include "RTC/RtpPacket.hpp"
#include "handles/Timer.hpp"
#include <libwebrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h>
#include <deque>
namespace
RTC
{
...
...
@@ -50,12 +51,14 @@ namespace RTC
return
0u
;
}
}
double
GetPacketLoss
()
const
;
void
IncomingPacket
(
uint64_t
nowMs
,
const
RTC
::
RtpPacket
*
packet
);
void
SetMaxIncomingBitrate
(
uint32_t
bitrate
);
private
:
void
SendTransportCcFeedback
();
void
MaySendLimitationRembFeedback
();
void
UpdatePacketLoss
(
double
packetLoss
);
/* Pure virtual methods inherited from webrtc::RemoteBitrateEstimator::Listener. */
public
:
...
...
@@ -84,6 +87,8 @@ namespace RTC
uint32_t
maxIncomingBitrate
{
0u
};
uint64_t
limitationRembSentAtMs
{
0u
};
uint8_t
unlimitedRembCounter
{
0u
};
std
::
deque
<
double
>
packetLossHistory
;
double
packetLoss
{
0
};
};
}
// namespace RTC
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
d4392bd0
...
...
@@ -552,6 +552,14 @@ namespace RTC
// Add maxIncomingBitrate.
if
(
this
->
maxIncomingBitrate
!=
0u
)
jsonObject
[
"maxIncomingBitrate"
]
=
this
->
maxIncomingBitrate
;
// Add packetLossReceived.
if
(
this
->
tccServer
)
jsonObject
[
"rtpPacketLossReceived"
]
=
this
->
tccServer
->
GetPacketLoss
();
// Add packetLossSent.
if
(
this
->
tccClient
)
jsonObject
[
"rtpPacketLossSent"
]
=
this
->
tccClient
->
GetPacketLoss
();
}
void
Transport
::
HandleRequest
(
Channel
::
ChannelRequest
*
request
)
...
...
worker/src/RTC/TransportCongestionControlClient.cpp
浏览文件 @
d4392bd0
...
...
@@ -16,6 +16,7 @@ namespace RTC
static
constexpr
float
MaxBitrateIncrementFactor
{
1.35
f
};
static
constexpr
float
MaxPaddingBitrateFactor
{
0.85
f
};
static
constexpr
uint64_t
AvailableBitrateEventInterval
{
2000u
};
// In ms.
static
constexpr
size_t
PacketLossHistogramLength
{
24
};
/* Instance methods. */
...
...
@@ -163,9 +164,56 @@ namespace RTC
{
MS_TRACE
();
// Update packet loss history.
size_t
expected_packets
=
feedback
->
GetPacketStatusCount
();
size_t
lost_packets
=
0
;
for
(
const
auto
&
result
:
feedback
->
GetPacketResults
())
{
if
(
!
result
.
received
)
lost_packets
+=
1
;
}
this
->
UpdatePacketLoss
(
static_cast
<
double
>
(
lost_packets
)
/
expected_packets
);
this
->
rtpTransportControllerSend
->
OnTransportFeedback
(
*
feedback
);
}
void
TransportCongestionControlClient
::
UpdatePacketLoss
(
double
packetLoss
)
{
// Add the score into the histogram.
if
(
this
->
packetLossHistory
.
size
()
==
PacketLossHistogramLength
)
this
->
packetLossHistory
.
pop_front
();
this
->
packetLossHistory
.
push_back
(
packetLoss
);
/*
* Scoring mechanism is a weighted average.
*
* The more recent the score is, the more weight it has.
* The oldest score has a weight of 1 and subsequent scores weight is
* increased by one sequentially.
*
* Ie:
* - scores: [1,2,3,4]
* - this->scores = ((1) + (2+2) + (3+3+3) + (4+4+4+4)) / 10 = 2.8 => 3
*/
size_t
weight
{
0
};
size_t
samples
{
0
};
double
totalPacketLoss
{
0
};
for
(
auto
packetLossEntry
:
this
->
packetLossHistory
)
{
weight
++
;
samples
+=
weight
;
totalPacketLoss
+=
weight
*
packetLossEntry
;
}
// clang-tidy "thinks" that this can lead to division by zero but we are
// smarter.
// NOLINTNEXTLINE(clang-analyzer-core.DivideZero)
this
->
packetLoss
=
totalPacketLoss
/
samples
;
}
void
TransportCongestionControlClient
::
SetMaxOutgoingBitrate
(
uint32_t
maxBitrate
)
{
if
(
maxBitrate
<
this
->
initialAvailableBitrate
)
...
...
@@ -245,6 +293,13 @@ namespace RTC
return
this
->
bitrates
.
availableBitrate
;
}
double
TransportCongestionControlClient
::
GetPacketLoss
()
const
{
MS_TRACE
();
return
this
->
packetLoss
;
}
void
TransportCongestionControlClient
::
RescheduleNextAvailableBitrateEvent
()
{
MS_TRACE
();
...
...
worker/src/RTC/TransportCongestionControlServer.cpp
浏览文件 @
d4392bd0
...
...
@@ -15,6 +15,7 @@ namespace RTC
static
constexpr
uint64_t
TransportCcFeedbackSendInterval
{
100u
};
// In ms.
static
constexpr
uint64_t
LimitationRembInterval
{
1500u
};
// In ms.
static
constexpr
uint8_t
UnlimitedRembNumPackets
{
4u
};
static
constexpr
size_t
PacketLossHistogramLength
{
24
};
/* Instance methods. */
...
...
@@ -101,6 +102,13 @@ namespace RTC
}
}
double
TransportCongestionControlServer
::
GetPacketLoss
()
const
{
MS_TRACE
();
return
this
->
packetLoss
;
}
void
TransportCongestionControlServer
::
IncomingPacket
(
uint64_t
nowMs
,
const
RTC
::
RtpPacket
*
packet
)
{
MS_TRACE
();
...
...
@@ -119,7 +127,7 @@ namespace RTC
this
->
transportCcFeedbackMediaSsrc
=
packet
->
GetSsrc
();
this
->
transportCcFeedbackPacket
->
SetSenderSsrc
(
0u
);
this
->
transportCcFeedbackPacket
->
SetMediaSsrc
(
packet
->
GetSsrc
()
);
this
->
transportCcFeedbackPacket
->
SetMediaSsrc
(
this
->
transportCcFeedbackMediaSsrc
);
// Provide the feedback packet with the RTP packet info. If it fails,
// send current feedback and add the packet info to a new one.
...
...
@@ -223,6 +231,17 @@ namespace RTC
this
->
listener
->
OnTransportCongestionControlServerSendRtcpPacket
(
this
,
this
->
transportCcFeedbackPacket
.
get
());
// Update packet loss history.
size_t
expected_packets
=
this
->
transportCcFeedbackPacket
->
GetPacketStatusCount
();
size_t
lost_packets
=
0
;
for
(
const
auto
&
result
:
this
->
transportCcFeedbackPacket
->
GetPacketResults
())
{
if
(
!
result
.
received
)
lost_packets
+=
1
;
}
this
->
UpdatePacketLoss
(
static_cast
<
double
>
(
lost_packets
)
/
expected_packets
);
// Create a new feedback packet.
this
->
transportCcFeedbackPacket
.
reset
(
new
RTC
::
RTCP
::
FeedbackRtpTransportPacket
(
this
->
transportCcFeedbackSenderSsrc
,
this
->
transportCcFeedbackMediaSsrc
));
...
...
@@ -280,6 +299,32 @@ namespace RTC
}
}
void
TransportCongestionControlServer
::
UpdatePacketLoss
(
double
packetLoss
)
{
// Add the score into the histogram.
if
(
this
->
packetLossHistory
.
size
()
==
PacketLossHistogramLength
)
this
->
packetLossHistory
.
pop_front
();
this
->
packetLossHistory
.
push_back
(
packetLoss
);
// Calculate a weighted average
size_t
weight
{
0
};
size_t
samples
{
0
};
double
totalPacketLoss
{
0
};
for
(
auto
packetLossEntry
:
this
->
packetLossHistory
)
{
weight
++
;
samples
+=
weight
;
totalPacketLoss
+=
weight
*
packetLossEntry
;
}
// clang-tidy "thinks" that this can lead to division by zero but we are
// smarter.
// NOLINTNEXTLINE(clang-analyzer-core.DivideZero)
this
->
packetLoss
=
totalPacketLoss
/
samples
;
}
inline
void
TransportCongestionControlServer
::
OnRembServerAvailableBitrate
(
const
webrtc
::
RemoteBitrateEstimator
*
/*rembServer*/
,
const
std
::
vector
<
uint32_t
>&
ssrcs
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论