Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
694d28c5
提交
694d28c5
authored
4月 10, 2019
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP: RembClient
上级
064a883c
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
128 行增加
和
57 行删除
+128
-57
RembClient.hpp
worker/include/RTC/RembClient.hpp
+4
-25
Settings.hpp
worker/include/Settings.hpp
+1
-1
RembClient.cpp
worker/src/RTC/RembClient.cpp
+107
-15
InterArrival.cpp
worker/src/RTC/RembServer/InterArrival.cpp
+2
-2
RemoteBitrateEstimatorAbsSendTime.cpp
.../src/RTC/RembServer/RemoteBitrateEstimatorAbsSendTime.cpp
+3
-3
SimulcastConsumer.cpp
worker/src/RTC/SimulcastConsumer.cpp
+2
-2
WebRtcTransport.cpp
worker/src/RTC/WebRtcTransport.cpp
+5
-5
Settings.cpp
worker/src/Settings.cpp
+4
-4
没有找到文件。
worker/include/RTC/RembClient.hpp
浏览文件 @
694d28c5
...
@@ -32,33 +32,12 @@ namespace RTC
...
@@ -32,33 +32,12 @@ namespace RTC
private
:
private
:
Listener
*
listener
;
Listener
*
listener
;
RTC
::
RtpDataCounter
transmissionCounter
;
RTC
::
RtpDataCounter
transmissionCounter
;
uint32_t
averageBitrate
{
0
};
uint32_t
bitrateInUse
{
0
};
uint32_t
extraBitrate
{
0
};
uint32_t
extraBitrateInUse
{
0
};
uint32_t
rembBitrate
{
0
};
uint32_t
availableBitrate
{
0
};
uint32_t
availableBitrate
{
0
};
uint64_t
lastEventAt
{
0
};
};
};
/* Inline methods. */
inline
uint32_t
RembClient
::
GetAvailableBitrate
()
const
{
if
(
this
->
availableBitrate
>=
this
->
extraBitrate
)
return
this
->
availableBitrate
-
this
->
extraBitrate
;
else
return
0
;
}
inline
void
RembClient
::
AddExtraBitrate
(
uint32_t
extraBitrate
)
{
this
->
extraBitrate
+=
extraBitrate
;
}
inline
void
RembClient
::
RemoveExtraBitrate
(
uint32_t
extraBitrate
)
{
if
(
this
->
extraBitrate
>=
extraBitrate
)
this
->
extraBitrate
-=
extraBitrate
;
else
this
->
extraBitrate
=
0
;
}
}
// namespace RTC
}
// namespace RTC
#endif
#endif
worker/include/Settings.hpp
浏览文件 @
694d28c5
...
@@ -20,7 +20,7 @@ public:
...
@@ -20,7 +20,7 @@ public:
bool
srtp
{
false
};
bool
srtp
{
false
};
bool
rtcp
{
false
};
bool
rtcp
{
false
};
bool
rtx
{
false
};
bool
rtx
{
false
};
bool
rb
e
{
false
};
bool
bw
e
{
false
};
bool
score
{
false
};
bool
score
{
false
};
bool
simulcast
{
false
};
bool
simulcast
{
false
};
bool
svc
{
false
};
bool
svc
{
false
};
...
...
worker/src/RTC/RembClient.cpp
浏览文件 @
694d28c5
#define MS_CLASS "RTC::RembClient"
#define MS_CLASS "RTC::RembClient"
// #define MS_LOG_DEV
#define MS_LOG_DEV // TODO
#include "RTC/RembClient.hpp"
#include "RTC/RembClient.hpp"
#include "DepLibUV.hpp"
#include "DepLibUV.hpp"
#include "Logger.hpp"
#include "Logger.hpp"
#include <limits>
namespace
RTC
namespace
RTC
{
{
/* Static. */
static
constexpr
uint64_t
EventInterval
{
1500
};
// In ms.
static
constexpr
uint64_t
MaxEventInterval
{
3000
};
// In ms.
/* Instance methods. */
/* Instance methods. */
RembClient
::
RembClient
(
RTC
::
RembClient
::
Listener
*
listener
)
:
listener
(
listener
)
RembClient
::
RembClient
(
RTC
::
RembClient
::
Listener
*
listener
)
:
listener
(
listener
),
lastEventAt
(
DepLibUV
::
GetTime
())
{
{
MS_TRACE
();
MS_TRACE
();
}
}
...
@@ -30,21 +37,106 @@ namespace RTC
...
@@ -30,21 +37,106 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// Update available bitrate.
// Check if we should fire the event.
this
->
availableBitrate
=
static_cast
<
uint32_t
>
(
remb
->
GetBitrate
());
uint64_t
now
=
DepLibUV
::
GetTime
();
if
(
now
-
this
->
lastEventAt
>=
MaxEventInterval
)
{
MS_DEBUG_TAG
(
bwe
,
"ignoring first REMB after inactivity"
);
// Update last event time.
this
->
lastEventAt
=
now
;
return
;
}
else
if
(
now
-
this
->
lastEventAt
<
EventInterval
)
{
return
;
}
uint32_t
newRembBitrate
=
static_cast
<
uint32_t
>
(
remb
->
GetBitrate
());
auto
rembTrend
=
static_cast
<
int64_t
>
(
newRembBitrate
)
-
static_cast
<
int64_t
>
(
this
->
rembBitrate
);
// TODO: Testing.
// Update REMB bitrate.
this
->
rembBitrate
=
newRembBitrate
;
// Update bitrate in use.
this
->
bitrateInUse
=
this
->
transmissionCounter
.
GetRate
(
now
);
// Update last event time.
this
->
lastEventAt
=
now
;
if
(
this
->
rembBitrate
>=
this
->
bitrateInUse
)
{
uint32_t
availableBitrate
=
this
->
rembBitrate
-
this
->
bitrateInUse
;
MS_DEBUG_TAG
(
bwe
,
"available bitrate [REMB:%"
PRIu32
" >= bitrateInUse:%"
PRIu32
", availableBitrate:%"
PRIu32
"]"
,
this
->
rembBitrate
,
this
->
bitrateInUse
,
availableBitrate
);
}
else
if
(
rembTrend
>
0
)
{
MS_DEBUG_TAG
(
bwe
,
"positive REMT trend [REMB:%"
PRIu32
" < bitrateInUse:%"
PRIu32
", trend:%"
PRIi64
"]"
,
this
->
rembBitrate
,
this
->
bitrateInUse
,
rembTrend
);
}
else
{
uint32_t
exceedingBitrate
=
this
->
bitrateInUse
-
this
->
rembBitrate
;
MS_WARN_TAG
(
bwe
,
"exceeding bitrate [REMB:%"
PRIu32
" < bitrateInUse:%"
PRIu32
", exceedingBitrate:%"
PRIu32
"]"
,
this
->
rembBitrate
,
this
->
bitrateInUse
,
exceedingBitrate
);
}
}
uint32_t
RembClient
::
GetAvailableBitrate
()
const
{
MS_TRACE
();
// if (this->bitrateInUse == 0)
// return std::numeric_limits<uint32_t>::max();
// else if (this->availableBitrate >= this->extraBitrateInUse)
// return this->availableBitrate - this->extraBitrateInUse;
// else
// return 0;
return
1234
;
}
void
RembClient
::
AddExtraBitrate
(
uint32_t
extraBitrate
)
{
MS_TRACE
();
// Update last event time.
this
->
lastEventAt
=
DepLibUV
::
GetTime
();
// Increase extra bitrate in use.
this
->
extraBitrateInUse
+=
extraBitrate
;
}
void
RembClient
::
RemoveExtraBitrate
(
uint32_t
extraBitrate
)
{
MS_TRACE
();
// uint32_t rembBitrate = static_cast<uint32_t>(remb->GetBitrate());
// Update last event time.
// uint64_t now = DepLibUV::GetTime();
this
->
lastEventAt
=
DepLibUV
::
GetTime
();
// uint32_t bitrate = this->transmissionCounter.GetRate(now);
// int32_t diff = rembBitrate - bitrate;
// MS_ERROR(
// Decrease extra bitrate in use.
// "REMB received [sending bitrate:%" PRIu32 ", REMB available bitrate:%" PRIu32
if
(
this
->
extraBitrateInUse
>=
extraBitrate
)
// ", diff:%" PRIi32 "]",
this
->
extraBitrateInUse
-=
extraBitrate
;
// bitrate,
else
// rembBitrate,
this
->
extraBitrateInUse
=
0
;
// diff);
}
}
}
// namespace RTC
}
// namespace RTC
worker/src/RTC/RembServer/InterArrival.cpp
浏览文件 @
694d28c5
...
@@ -69,7 +69,7 @@ namespace RTC
...
@@ -69,7 +69,7 @@ namespace RTC
if
(
*
arrivalTimeDeltaMs
-
systemTimeDeltaMs
>=
ArrivalTimeOffsetThresholdMs
)
if
(
*
arrivalTimeDeltaMs
-
systemTimeDeltaMs
>=
ArrivalTimeOffsetThresholdMs
)
{
{
MS_WARN_TAG
(
MS_WARN_TAG
(
rb
e
,
bw
e
,
"the arrival time clock offset has changed, resetting"
"the arrival time clock offset has changed, resetting"
"[diff:%"
PRId64
"ms]"
,
"[diff:%"
PRId64
"ms]"
,
*
arrivalTimeDeltaMs
-
systemTimeDeltaMs
);
*
arrivalTimeDeltaMs
-
systemTimeDeltaMs
);
...
@@ -87,7 +87,7 @@ namespace RTC
...
@@ -87,7 +87,7 @@ namespace RTC
if
(
this
->
numConsecutiveReorderedPackets
>=
ReorderedResetThreshold
)
if
(
this
->
numConsecutiveReorderedPackets
>=
ReorderedResetThreshold
)
{
{
MS_WARN_TAG
(
MS_WARN_TAG
(
rb
e
,
bw
e
,
"packets are being reordered on the path from the "
"packets are being reordered on the path from the "
"socket to the bandwidth estimator, ignoring this "
"socket to the bandwidth estimator, ignoring this "
"packet for bandwidth estimation, resetting"
);
"packet for bandwidth estimation, resetting"
);
...
...
worker/src/RTC/RembServer/RemoteBitrateEstimatorAbsSendTime.cpp
浏览文件 @
694d28c5
...
@@ -146,7 +146,7 @@ namespace RTC
...
@@ -146,7 +146,7 @@ namespace RTC
int
recvBitrateBps
=
it
->
meanSize
*
8
*
1000
/
it
->
recvMeanMs
;
int
recvBitrateBps
=
it
->
meanSize
*
8
*
1000
/
it
->
recvMeanMs
;
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rb
e
,
bw
e
,
"probe failed, sent at %d bps, received at %d bps [mean "
"probe failed, sent at %d bps, received at %d bps [mean "
"send delta:%fms, mean recv delta:%fms, num probes:%d]"
,
"send delta:%fms, mean recv delta:%fms, num probes:%d]"
,
sendBitrateBps
,
sendBitrateBps
,
...
@@ -190,7 +190,7 @@ namespace RTC
...
@@ -190,7 +190,7 @@ namespace RTC
if
(
IsBitrateImproving
(
probeBitrateBps
))
if
(
IsBitrateImproving
(
probeBitrateBps
))
{
{
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rb
e
,
bw
e
,
"probe successful, sent at %d bps, received at %d bps "
"probe successful, sent at %d bps, received at %d bps "
"[mean send delta:%fms, mean recv delta:%f ms, "
"[mean send delta:%fms, mean recv delta:%f ms, "
"num probes:%d"
,
"num probes:%d"
,
...
@@ -309,7 +309,7 @@ namespace RTC
...
@@ -309,7 +309,7 @@ namespace RTC
}
}
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rb
e
,
bw
e
,
"probe packet received [send time:%"
PRId64
"probe packet received [send time:%"
PRId64
"ms, recv "
"ms, recv "
"time:%"
PRId64
"ms, send delta:%dms, recv delta:%d ms]"
,
"time:%"
PRId64
"ms, send delta:%dms, recv delta:%d ms]"
,
...
...
worker/src/RTC/SimulcastConsumer.cpp
浏览文件 @
694d28c5
...
@@ -777,14 +777,14 @@ namespace RTC
...
@@ -777,14 +777,14 @@ namespace RTC
if
(
producerScore
==
0
)
if
(
producerScore
==
0
)
continue
;
continue
;
if
(
producerScore
>=
maxProducerScore
)
if
(
producerScore
>=
maxProducerScore
||
producerScore
>=
7
)
{
{
maxProducerScore
=
producerScore
;
maxProducerScore
=
producerScore
;
newTargetSpatialLayer
=
spatialLayer
;
newTargetSpatialLayer
=
spatialLayer
;
// If this is the preferred or higher spatial layer and has good score,
// If this is the preferred or higher spatial layer and has good score,
// take it and exit.
// take it and exit.
if
(
spatialLayer
>=
this
->
preferredSpatialLayer
&&
maxP
roducerScore
>=
7
)
if
(
spatialLayer
>=
this
->
preferredSpatialLayer
&&
p
roducerScore
>=
7
)
break
;
break
;
}
}
}
}
...
...
worker/src/RTC/WebRtcTransport.cpp
浏览文件 @
694d28c5
...
@@ -626,7 +626,7 @@ namespace RTC
...
@@ -626,7 +626,7 @@ namespace RTC
this
->
maxIncomingBitrate
=
bitrate
;
this
->
maxIncomingBitrate
=
bitrate
;
MS_DEBUG_TAG
(
rb
e
,
"WebRtcTransport maximum incoming bitrate set to %"
PRIu32
"bps"
,
bitrate
);
MS_DEBUG_TAG
(
bw
e
,
"WebRtcTransport maximum incoming bitrate set to %"
PRIu32
"bps"
,
bitrate
);
request
->
Accept
();
request
->
Accept
();
...
@@ -1101,7 +1101,7 @@ namespace RTC
...
@@ -1101,7 +1101,7 @@ namespace RTC
)
)
// clang-format on
// clang-format on
{
{
MS_DEBUG_TAG
(
rb
e
,
"enabling REMB server"
);
MS_DEBUG_TAG
(
bw
e
,
"enabling REMB server"
);
this
->
rembServer
=
new
RTC
::
RembServer
::
RemoteBitrateEstimatorAbsSendTime
(
this
);
this
->
rembServer
=
new
RTC
::
RembServer
::
RemoteBitrateEstimatorAbsSendTime
(
this
);
}
}
...
@@ -1135,7 +1135,7 @@ namespace RTC
...
@@ -1135,7 +1135,7 @@ namespace RTC
)
)
// clang-format on
// clang-format on
{
{
MS_DEBUG_TAG
(
rb
e
,
"enabling REMB client"
);
MS_DEBUG_TAG
(
bw
e
,
"enabling REMB client"
);
this
->
rembClient
=
new
RTC
::
RembClient
(
this
);
this
->
rembClient
=
new
RTC
::
RembClient
(
this
);
}
}
...
@@ -1448,7 +1448,7 @@ namespace RTC
...
@@ -1448,7 +1448,7 @@ namespace RTC
if
(
this
->
maxIncomingBitrate
!=
0u
)
if
(
this
->
maxIncomingBitrate
!=
0u
)
availableBitrate
=
std
::
min
(
availableBitrate
,
this
->
maxIncomingBitrate
);
availableBitrate
=
std
::
min
(
availableBitrate
,
this
->
maxIncomingBitrate
);
if
(
MS_HAS_DEBUG_TAG
(
rb
e
))
if
(
MS_HAS_DEBUG_TAG
(
bw
e
))
{
{
std
::
ostringstream
ssrcsStream
;
std
::
ostringstream
ssrcsStream
;
...
@@ -1459,7 +1459,7 @@ namespace RTC
...
@@ -1459,7 +1459,7 @@ namespace RTC
}
}
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rb
e
,
bw
e
,
"sending RTCP REMB packet [bitrate:%"
PRIu32
"bps, ssrcs:%s]"
,
"sending RTCP REMB packet [bitrate:%"
PRIu32
"bps, ssrcs:%s]"
,
availableBitrate
,
availableBitrate
,
ssrcsStream
.
str
().
c_str
());
ssrcsStream
.
str
().
c_str
());
...
...
worker/src/Settings.cpp
浏览文件 @
694d28c5
...
@@ -187,8 +187,8 @@ void Settings::PrintConfiguration()
...
@@ -187,8 +187,8 @@ void Settings::PrintConfiguration()
logTags
.
emplace_back
(
"rtcp"
);
logTags
.
emplace_back
(
"rtcp"
);
if
(
Settings
::
configuration
.
logTags
.
rtx
)
if
(
Settings
::
configuration
.
logTags
.
rtx
)
logTags
.
emplace_back
(
"rtx"
);
logTags
.
emplace_back
(
"rtx"
);
if
(
Settings
::
configuration
.
logTags
.
rb
e
)
if
(
Settings
::
configuration
.
logTags
.
bw
e
)
logTags
.
emplace_back
(
"
rb
e"
);
logTags
.
emplace_back
(
"
bw
e"
);
if
(
Settings
::
configuration
.
logTags
.
score
)
if
(
Settings
::
configuration
.
logTags
.
score
)
logTags
.
emplace_back
(
"score"
);
logTags
.
emplace_back
(
"score"
);
if
(
Settings
::
configuration
.
logTags
.
simulcast
)
if
(
Settings
::
configuration
.
logTags
.
simulcast
)
...
@@ -308,8 +308,8 @@ void Settings::SetLogTags(const std::vector<std::string>& tags)
...
@@ -308,8 +308,8 @@ void Settings::SetLogTags(const std::vector<std::string>& tags)
newLogTags
.
rtcp
=
true
;
newLogTags
.
rtcp
=
true
;
else
if
(
tag
==
"rtx"
)
else
if
(
tag
==
"rtx"
)
newLogTags
.
rtx
=
true
;
newLogTags
.
rtx
=
true
;
else
if
(
tag
==
"
rb
e"
)
else
if
(
tag
==
"
bw
e"
)
newLogTags
.
rb
e
=
true
;
newLogTags
.
bw
e
=
true
;
else
if
(
tag
==
"score"
)
else
if
(
tag
==
"score"
)
newLogTags
.
score
=
true
;
newLogTags
.
score
=
true
;
else
if
(
tag
==
"simulcast"
)
else
if
(
tag
==
"simulcast"
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论