Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
15e8c6ca
提交
15e8c6ca
authored
3月 27, 2017
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make cppcheck happy and some code/syntax clean up
上级
7ef7a0ff
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
55 行增加
和
50 行删除
+55
-50
FeedbackPsRemb.hpp
worker/include/RTC/RTCP/FeedbackPsRemb.hpp
+2
-2
AimdRateControl.hpp
...er/include/RTC/RemoteBitrateEstimator/AimdRateControl.hpp
+1
-1
InterArrival.hpp
worker/include/RTC/RemoteBitrateEstimator/InterArrival.hpp
+8
-11
OveruseDetector.hpp
...er/include/RTC/RemoteBitrateEstimator/OveruseDetector.hpp
+0
-1
OveruseEstimator.hpp
...r/include/RTC/RemoteBitrateEstimator/OveruseEstimator.hpp
+6
-7
RateControlInput.hpp
...r/include/RTC/RemoteBitrateEstimator/RateControlInput.hpp
+2
-2
RemoteBitrateEstimator.hpp
...ude/RTC/RemoteBitrateEstimator/RemoteBitrateEstimator.hpp
+0
-5
RemoteBitrateEstimatorAbsSendTime.hpp
...oteBitrateEstimator/RemoteBitrateEstimatorAbsSendTime.hpp
+7
-10
RemoteBitrateEstimatorSingleStream.hpp
...teBitrateEstimator/RemoteBitrateEstimatorSingleStream.hpp
+5
-4
AimdRateControl.cpp
worker/src/RTC/RemoteBitrateEstimator/AimdRateControl.cpp
+20
-2
OveruseEstimator.cpp
worker/src/RTC/RemoteBitrateEstimator/OveruseEstimator.cpp
+4
-5
没有找到文件。
worker/include/RTC/RTCP/FeedbackPsRemb.hpp
浏览文件 @
15e8c6ca
...
...
@@ -57,8 +57,8 @@ namespace RTC { namespace RTCP
private
:
std
::
vector
<
uint32_t
>
ssrcs
;
// Bitrate represented in bps
uint64_t
bitrate
;
// Bitrate represented in bps
.
uint64_t
bitrate
=
0
;
bool
isCorrect
=
true
;
};
...
...
worker/include/RTC/RemoteBitrateEstimator/AimdRateControl.hpp
浏览文件 @
15e8c6ca
...
...
@@ -102,7 +102,7 @@ namespace RTC
bool
bitrateIsInitialized
=
false
;
float
beta
=
0.85
f
;
int64_t
rtt
=
kDefaultRttMs
;
int
lastDecrease
;
int
lastDecrease
=
0
;
};
/* Inline methods. */
...
...
worker/include/RTC/RemoteBitrateEstimator/InterArrival.hpp
浏览文件 @
15e8c6ca
...
...
@@ -47,30 +47,27 @@ namespace RTC
TimestampGroup
();
bool
IsFirstPacket
()
const
;
size_t
size
;
uint32_t
first_timestamp
;
uint32_t
timestamp
;
int64_t
complete_time_ms
;
int64_t
last_system_time_ms
;
size_t
size
=
0
;
uint32_t
first_timestamp
=
0
;
uint32_t
timestamp
=
0
;
int64_t
complete_time_ms
=
0
;
int64_t
last_system_time_ms
=
0
;
};
// Returns true if the packet with timestamp |timestamp| arrived in order.
bool
PacketInOrder
(
uint32_t
timestamp
);
// Returns true if the last packet was the end of the current batch and the
// packet with |timestamp| is the first of a new batch.
bool
NewTimestampGroup
(
int64_t
arrival_time_ms
,
uint32_t
timestamp
)
const
;
bool
BelongsToBurst
(
int64_t
arrival_time_ms
,
uint32_t
timestamp
)
const
;
void
Reset
();
const
uint32_t
kTimestampGroupLengthTicks
;
TimestampGroup
currentTimestampGroup
;
TimestampGroup
prevTimestampGroup
;
double
timestampToMsCoeff
;
bool
burstGrouping
;
int
numConsecutiveReorderedPackets
;
double
timestampToMsCoeff
=
0
;
bool
burstGrouping
=
false
;
int
numConsecutiveReorderedPackets
=
0
;
};
/* Inline methods. */
...
...
worker/include/RTC/RemoteBitrateEstimator/OveruseDetector.hpp
浏览文件 @
15e8c6ca
...
...
@@ -32,7 +32,6 @@ namespace RTC
// |numOfDeltas| is the number of deltas the offset estimate is based on.
// Returns the state after the detection update.
BandwidthUsage
Detect
(
double
offset
,
double
timestampDelta
,
int
numOfDeltas
,
int64_t
nowMs
);
// Returns the current detector state.
BandwidthUsage
State
()
const
;
...
...
worker/include/RTC/RemoteBitrateEstimator/OveruseEstimator.hpp
浏览文件 @
15e8c6ca
...
...
@@ -45,7 +45,6 @@ namespace RTC
// |current_hypothesis| should be the hypothesis of the over-use detector at
// this time.
void
Update
(
int64_t
tDelta
,
double
tsDelta
,
int
sizeDelta
,
BandwidthUsage
currentHypothesis
,
int64_t
nowMs
);
// Returns the estimated noise/jitter variance in ms^2.
double
GetVarNoise
()
const
;
// Returns the estimated inter-arrival time delta offset in ms.
...
...
@@ -61,14 +60,14 @@ namespace RTC
private
:
// Must be first member variable. Cannot be const because we need to be copyable.
OverUseDetectorOptions
options
;
uint16_t
numOfDeltas
;
double
slope
;
double
offset
;
double
prevOffset
;
uint16_t
numOfDeltas
=
0
;
double
slope
=
0
;
double
offset
=
0
;
double
prevOffset
=
0
;
double
E
[
2
][
2
];
double
processNoise
[
2
];
double
avgNoise
;
double
varNoise
;
double
avgNoise
=
0
;
double
varNoise
=
0
;
std
::
deque
<
double
>
tsDeltaHist
;
};
...
...
worker/include/RTC/RemoteBitrateEstimator/RateControlInput.hpp
浏览文件 @
15e8c6ca
...
...
@@ -13,8 +13,8 @@ namespace RTC
RateControlInput
(
BandwidthUsage
bwState
,
const
uint32_t
incomingBitrate
,
double
noiseVar
);
BandwidthUsage
bwState
;
uint32_t
incomingBitrate
;
double
noiseVar
;
uint32_t
incomingBitrate
=
0
;
double
noiseVar
=
0
;
};
/* Inline methods. */
...
...
worker/include/RTC/RemoteBitrateEstimator/RemoteBitrateEstimator.hpp
浏览文件 @
15e8c6ca
...
...
@@ -15,7 +15,6 @@
#include "common.hpp"
#include "RTC/RtpPacket.hpp"
#include <cassert>
#include <map>
#include <vector>
...
...
@@ -61,14 +60,11 @@ namespace RTC
// Removes all data for |ssrc|.
virtual
void
RemoveStream
(
uint32_t
ssrc
)
=
0
;
// Returns true if a valid estimate exists and sets |bitrate_bps| to the
// estimated payload bitrate in bits per second. |ssrcs| is the list of ssrcs
// currently being received and of which the bitrate estimate is based upon.
virtual
bool
LatestEstimate
(
std
::
vector
<
uint32_t
>*
ssrcs
,
uint32_t
*
bitrate_bps
)
const
=
0
;
virtual
void
SetMinBitrate
(
int
min_bitrate_bps
)
=
0
;
// (jmillan) borrowed from webrtc/modules/include/module.h.
//
// Returns the number of milliseconds until the module wants a worker
...
...
@@ -81,7 +77,6 @@ namespace RTC
// thread that calls Process() will also have it's tick count reference
// which might not match with what the implementations use.
virtual
int64_t
TimeUntilNextProcess
()
=
0
;
// Process any pending tasks such as timeouts.
// Called on a worker thread.
virtual
void
Process
()
=
0
;
...
...
worker/include/RTC/RemoteBitrateEstimator/RemoteBitrateEstimatorAbsSendTime.hpp
浏览文件 @
15e8c6ca
...
...
@@ -31,9 +31,9 @@ namespace RTC
{
Probe
(
int64_t
sendTimeMs
,
int64_t
recvTimeMs
,
size_t
payloadSize
);
int64_t
sendTimeMs
;
int64_t
recvTimeMs
;
size_t
payloadSize
;
int64_t
sendTimeMs
=
0
;
int64_t
recvTimeMs
=
0
;
size_t
payloadSize
=
0
;
};
struct
Cluster
...
...
@@ -82,18 +82,14 @@ namespace RTC
void
IncomingPacketInfo
(
int64_t
arrivalTimeMs
,
uint32_t
sendTime_24bits
,
size_t
payloadSize
,
uint32_t
ssrc
);
void
ComputeClusters
(
std
::
list
<
Cluster
>*
clusters
)
const
;
std
::
list
<
Cluster
>::
const_iterator
FindBestProbe
(
const
std
::
list
<
Cluster
>&
clusters
)
const
;
// Returns true if a probe which changed the estimate was detected.
ProbeResult
ProcessClusters
(
int64_t
nowMs
);
bool
IsBitrateImproving
(
int
probeBitrateBps
)
const
;
void
TimeoutStreams
(
int64_t
nowMs
);
private
:
Listener
*
const
observer
;
Listener
*
const
observer
=
nullptr
;
std
::
unique_ptr
<
InterArrival
>
interArrival
;
std
::
unique_ptr
<
OveruseEstimator
>
estimator
;
OveruseDetector
detector
;
...
...
@@ -106,7 +102,6 @@ namespace RTC
int64_t
firstPacketTimeMs
=
-
1
;
int64_t
lastUpdateMs
=
-
1
;
bool
umaRecorded
=
false
;
Ssrcs
ssrcs
;
AimdRateControl
remoteRate
;
};
...
...
@@ -124,6 +119,7 @@ namespace RTC
int
Cluster
::
GetSendBitrateBps
()
const
{
assert
(
sendMeanMs
>
0.0
f
);
return
meanSize
*
8
*
1000
/
sendMeanMs
;
}
...
...
@@ -131,6 +127,7 @@ namespace RTC
int
Cluster
::
GetRecvBitrateBps
()
const
{
assert
(
recvMeanMs
>
0.0
f
);
return
meanSize
*
8
*
1000
/
recvMeanMs
;
}
...
...
@@ -157,7 +154,7 @@ namespace RTC
inline
void
RemoteBitrateEstimatorAbsSendTime
::
OnRttUpdate
(
int64_t
avgRttMs
,
int64_t
maxRttMs
)
{
(
void
)
maxRttMs
;
(
void
)
maxRttMs
;
this
->
remoteRate
.
SetRtt
(
avgRttMs
);
}
...
...
worker/include/RTC/RemoteBitrateEstimator/RemoteBitrateEstimatorSingleStream.hpp
浏览文件 @
15e8c6ca
...
...
@@ -20,6 +20,7 @@
#include <map>
#include <memory>
#include <vector>
#include <cassert>
namespace
RTC
{
...
...
@@ -73,9 +74,9 @@ namespace RTC
RateCalculator
incomingBitrate
;
uint32_t
lastValidIncomingBitrate
=
0
;
std
::
unique_ptr
<
AimdRateControl
>
remoteRate
;
Listener
*
observer
;
Listener
*
observer
=
nullptr
;
int64_t
lastProcessTime
=
-
1
;
int64_t
processIntervalMs
;
int64_t
processIntervalMs
=
0
;
bool
umaRecorded
=
false
;
};
...
...
@@ -94,7 +95,7 @@ namespace RTC
incomingBitrate
(),
remoteRate
(
new
AimdRateControl
()),
observer
(
observer
),
processIntervalMs
(
kProcessIntervalMs
)
{
//
MS_ASSERT(this->observer, "'this->observer' missing"
);
//
assert(this->observer
);
}
inline
...
...
@@ -118,7 +119,7 @@ namespace RTC
inline
void
RemoteBitrateEstimatorSingleStream
::
OnRttUpdate
(
int64_t
avgRttMs
,
int64_t
maxRttMs
)
{
(
void
)
maxRttMs
;
(
void
)
maxRttMs
;
GetRemoteRate
()
->
SetRtt
(
avgRttMs
);
}
...
...
worker/src/RTC/RemoteBitrateEstimator/AimdRateControl.cpp
浏览文件 @
15e8c6ca
...
...
@@ -32,6 +32,7 @@ namespace RTC
static
const
int
kRtcpSize
=
80
;
int64_t
interval
=
static_cast
<
int64_t
>
(
kRtcpSize
*
8.0
*
1000.0
/
(
0.05
*
this
->
currentBitrateBps
)
+
0.5
);
const
int64_t
kMinFeedbackIntervalMs
=
200
;
return
std
::
min
(
std
::
max
(
interval
,
kMinFeedbackIntervalMs
),
kMaxFeedbackIntervalMs
);
}
...
...
@@ -49,8 +50,10 @@ namespace RTC
// TODO(terelius/holmer): Investigate consequences of increasing
// the threshold to 0.95 * LatestEstimate().
const
uint32_t
threshold
=
static_cast
<
uint32_t
>
(
0.5
*
LatestEstimate
());
return
incomingBitrateBps
<
threshold
;
}
return
false
;
}
...
...
@@ -65,7 +68,9 @@ namespace RTC
if
(
!
this
->
bitrateIsInitialized
)
{
const
int64_t
kInitializationTimeMs
=
5000
;
//MSDASSERT(kBitrateWindowMs <= kInitializationTimeMs);
// MS_ASSERT(kBitrateWindowMs <= kInitializationTimeMs);
if
(
this
->
timeFirstIncomingEstimate
<
0
)
{
if
(
input
->
incomingBitrate
)
...
...
@@ -105,6 +110,7 @@ namespace RTC
const
int64_t
responseTime
=
(
this
->
rtt
+
100
)
*
2
;
constexpr
double
kMinIncreaseRateBps
=
4000
;
return
static_cast
<
int
>
(
std
::
max
(
kMinIncreaseRateBps
,
(
avgPacketSizeBits
*
1000
)
/
responseTime
));
}
...
...
@@ -116,18 +122,22 @@ namespace RTC
{
return
this
->
currentBitrateBps
;
}
// An over-use should always trigger us to reduce the bitrate, even though
// we have not yet established our first estimate. By acting on the over-use,
// we will end up with a valid estimate.
if
(
!
this
->
bitrateIsInitialized
&&
this
->
currentInput
.
bwState
!=
kBwOverusing
)
return
this
->
currentBitrateBps
;
this
->
updated
=
false
;
ChangeState
(
this
->
currentInput
,
nowMs
);
// Calculated here because it's used in multiple places.
const
float
incomingBitrateKbps
=
incomingBitrateBps
/
1000.0
f
;
// Calculate the max bit rate std dev given the normalized
// variance and the current incoming bit rate.
const
float
stdMaxBitRate
=
sqrt
(
this
->
varMaxBitrateKbps
*
this
->
avgMaxBitrateKbps
);
switch
(
this
->
rateControlState
)
{
case
kRcHold
:
...
...
@@ -187,6 +197,7 @@ namespace RTC
default
:
MS_ASSERT
(
false
,
"invalid this->rateControlState value"
);
}
return
ClampBitrate
(
newBitrateBps
,
incomingBitrateBps
);
}
...
...
@@ -198,11 +209,13 @@ namespace RTC
// We allow a bit more lag at very low rates to not too easily get stuck if
// the encoder produces uneven outputs.
const
uint32_t
maxBitrateBps
=
static_cast
<
uint32_t
>
(
1.5
f
*
incomingBitrateBps
)
+
10000
;
if
(
newBitrateBps
>
this
->
currentBitrateBps
&&
newBitrateBps
>
maxBitrateBps
)
{
newBitrateBps
=
std
::
max
(
this
->
currentBitrateBps
,
maxBitrateBps
);
}
newBitrateBps
=
std
::
max
(
newBitrateBps
,
this
->
minConfiguredBitrateBps
);
return
newBitrateBps
;
}
...
...
@@ -211,11 +224,13 @@ namespace RTC
MS_TRACE
();
double
alpha
=
1.08
;
if
(
lastMs
>
-
1
)
{
int
timeSinceLastUpdateMs
=
std
::
min
(
static_cast
<
int
>
(
nowMs
-
lastMs
),
1000
);
alpha
=
pow
(
alpha
,
timeSinceLastUpdateMs
/
1000.0
);
}
uint32_t
multiplicativeIncreaseBps
=
std
::
max
(
currentBitrateBps
*
(
alpha
-
1.0
),
1000.0
);
return
multiplicativeIncreaseBps
;
...
...
@@ -226,6 +241,7 @@ namespace RTC
MS_TRACE
();
const
float
alpha
=
0.05
f
;
if
(
this
->
avgMaxBitrateKbps
==
-
1.0
f
)
{
this
->
avgMaxBitrateKbps
=
incomingBitrateKbps
;
...
...
@@ -234,9 +250,11 @@ namespace RTC
{
this
->
avgMaxBitrateKbps
=
(
1
-
alpha
)
*
this
->
avgMaxBitrateKbps
+
alpha
*
incomingBitrateKbps
;
}
// Estimate the max bit rate variance and normalize the variance
// with the average max bit rate.
const
float
norm
=
std
::
max
(
this
->
avgMaxBitrateKbps
,
1.0
f
);
this
->
varMaxBitrateKbps
=
(
1
-
alpha
)
*
this
->
varMaxBitrateKbps
+
alpha
*
(
this
->
avgMaxBitrateKbps
-
incomingBitrateKbps
)
*
(
this
->
avgMaxBitrateKbps
-
incomingBitrateKbps
)
/
norm
;
// 0.4 ~= 14 kbit/s at 500 kbit/s
...
...
@@ -255,7 +273,7 @@ namespace RTC
{
MS_TRACE
();
(
void
)
input
;
(
void
)
input
;
switch
(
this
->
currentInput
.
bwState
)
{
case
kBwNormal
:
...
...
worker/src/RTC/RemoteBitrateEstimator/OveruseEstimator.cpp
浏览文件 @
15e8c6ca
...
...
@@ -27,7 +27,7 @@ namespace RTC
{
MS_TRACE
();
(
void
)
nowMs
;
(
void
)
nowMs
;
const
double
minFramePeriod
=
UpdateMinFramePeriod
(
tsDelta
);
const
double
tTsDelta
=
tDelta
-
tsDelta
;
double
fsDelta
=
sizeDelta
;
...
...
@@ -50,11 +50,10 @@ namespace RTC
const
double
h
[
2
]
=
{
fsDelta
,
1.0
};
const
double
Eh
[
2
]
=
{
this
->
E
[
0
][
0
]
*
h
[
0
]
+
this
->
E
[
0
][
1
]
*
h
[
1
],
this
->
E
[
1
][
0
]
*
h
[
0
]
+
this
->
E
[
1
][
1
]
*
h
[
1
]};
const
double
residual
=
tTsDelta
-
this
->
slope
*
h
[
0
]
-
this
->
offset
;
const
bool
inStableState
=
(
currentHypothesis
==
kBwNormal
);
const
double
maxResidual
=
3.0
*
sqrt
(
this
->
varNoise
);
// We try to filter out very late frames. For instance periodic key
// frames doesn't fit the Gaussian model well.
if
(
fabs
(
residual
)
<
maxResidual
)
...
...
@@ -67,9 +66,7 @@ namespace RTC
}
const
double
denom
=
this
->
varNoise
+
h
[
0
]
*
Eh
[
0
]
+
h
[
1
]
*
Eh
[
1
];
const
double
K
[
2
]
=
{
Eh
[
0
]
/
denom
,
Eh
[
1
]
/
denom
};
const
double
IKh
[
2
][
2
]
=
{{
1.0
-
K
[
0
]
*
h
[
0
],
-
K
[
0
]
*
h
[
1
]},
{
-
K
[
1
]
*
h
[
0
],
1.0
-
K
[
1
]
*
h
[
1
]}};
const
double
e00
=
this
->
E
[
0
][
0
];
const
double
e01
=
this
->
E
[
0
][
1
];
...
...
@@ -111,6 +108,7 @@ namespace RTC
minFramePeriod
=
std
::
min
(
oldTsDelta
,
minFramePeriod
);
}
this
->
tsDeltaHist
.
push_back
(
tsDelta
);
return
minFramePeriod
;
}
...
...
@@ -122,6 +120,7 @@ namespace RTC
{
return
;
}
// Faster filter during startup to faster adapt to the jitter level
// of the network. |alpha| is tuned for 30 frames per second, but is scaled
// according to |tsDelta|.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论