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
...
@@ -57,8 +57,8 @@ namespace RTC { namespace RTCP
private
:
private
:
std
::
vector
<
uint32_t
>
ssrcs
;
std
::
vector
<
uint32_t
>
ssrcs
;
// Bitrate represented in bps
// Bitrate represented in bps
.
uint64_t
bitrate
;
uint64_t
bitrate
=
0
;
bool
isCorrect
=
true
;
bool
isCorrect
=
true
;
};
};
...
...
worker/include/RTC/RemoteBitrateEstimator/AimdRateControl.hpp
浏览文件 @
15e8c6ca
...
@@ -102,7 +102,7 @@ namespace RTC
...
@@ -102,7 +102,7 @@ namespace RTC
bool
bitrateIsInitialized
=
false
;
bool
bitrateIsInitialized
=
false
;
float
beta
=
0.85
f
;
float
beta
=
0.85
f
;
int64_t
rtt
=
kDefaultRttMs
;
int64_t
rtt
=
kDefaultRttMs
;
int
lastDecrease
;
int
lastDecrease
=
0
;
};
};
/* Inline methods. */
/* Inline methods. */
...
...
worker/include/RTC/RemoteBitrateEstimator/InterArrival.hpp
浏览文件 @
15e8c6ca
...
@@ -47,30 +47,27 @@ namespace RTC
...
@@ -47,30 +47,27 @@ namespace RTC
TimestampGroup
();
TimestampGroup
();
bool
IsFirstPacket
()
const
;
bool
IsFirstPacket
()
const
;
size_t
size
;
size_t
size
=
0
;
uint32_t
first_timestamp
;
uint32_t
first_timestamp
=
0
;
uint32_t
timestamp
;
uint32_t
timestamp
=
0
;
int64_t
complete_time_ms
;
int64_t
complete_time_ms
=
0
;
int64_t
last_system_time_ms
;
int64_t
last_system_time_ms
=
0
;
};
};
// Returns true if the packet with timestamp |timestamp| arrived in order.
// Returns true if the packet with timestamp |timestamp| arrived in order.
bool
PacketInOrder
(
uint32_t
timestamp
);
bool
PacketInOrder
(
uint32_t
timestamp
);
// Returns true if the last packet was the end of the current batch and the
// 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.
// packet with |timestamp| is the first of a new batch.
bool
NewTimestampGroup
(
int64_t
arrival_time_ms
,
uint32_t
timestamp
)
const
;
bool
NewTimestampGroup
(
int64_t
arrival_time_ms
,
uint32_t
timestamp
)
const
;
bool
BelongsToBurst
(
int64_t
arrival_time_ms
,
uint32_t
timestamp
)
const
;
bool
BelongsToBurst
(
int64_t
arrival_time_ms
,
uint32_t
timestamp
)
const
;
void
Reset
();
void
Reset
();
const
uint32_t
kTimestampGroupLengthTicks
;
const
uint32_t
kTimestampGroupLengthTicks
;
TimestampGroup
currentTimestampGroup
;
TimestampGroup
currentTimestampGroup
;
TimestampGroup
prevTimestampGroup
;
TimestampGroup
prevTimestampGroup
;
double
timestampToMsCoeff
;
double
timestampToMsCoeff
=
0
;
bool
burstGrouping
;
bool
burstGrouping
=
false
;
int
numConsecutiveReorderedPackets
;
int
numConsecutiveReorderedPackets
=
0
;
};
};
/* Inline methods. */
/* Inline methods. */
...
...
worker/include/RTC/RemoteBitrateEstimator/OveruseDetector.hpp
浏览文件 @
15e8c6ca
...
@@ -32,7 +32,6 @@ namespace RTC
...
@@ -32,7 +32,6 @@ namespace RTC
// |numOfDeltas| is the number of deltas the offset estimate is based on.
// |numOfDeltas| is the number of deltas the offset estimate is based on.
// Returns the state after the detection update.
// Returns the state after the detection update.
BandwidthUsage
Detect
(
double
offset
,
double
timestampDelta
,
int
numOfDeltas
,
int64_t
nowMs
);
BandwidthUsage
Detect
(
double
offset
,
double
timestampDelta
,
int
numOfDeltas
,
int64_t
nowMs
);
// Returns the current detector state.
// Returns the current detector state.
BandwidthUsage
State
()
const
;
BandwidthUsage
State
()
const
;
...
...
worker/include/RTC/RemoteBitrateEstimator/OveruseEstimator.hpp
浏览文件 @
15e8c6ca
...
@@ -45,7 +45,6 @@ namespace RTC
...
@@ -45,7 +45,6 @@ namespace RTC
// |current_hypothesis| should be the hypothesis of the over-use detector at
// |current_hypothesis| should be the hypothesis of the over-use detector at
// this time.
// this time.
void
Update
(
int64_t
tDelta
,
double
tsDelta
,
int
sizeDelta
,
BandwidthUsage
currentHypothesis
,
int64_t
nowMs
);
void
Update
(
int64_t
tDelta
,
double
tsDelta
,
int
sizeDelta
,
BandwidthUsage
currentHypothesis
,
int64_t
nowMs
);
// Returns the estimated noise/jitter variance in ms^2.
// Returns the estimated noise/jitter variance in ms^2.
double
GetVarNoise
()
const
;
double
GetVarNoise
()
const
;
// Returns the estimated inter-arrival time delta offset in ms.
// Returns the estimated inter-arrival time delta offset in ms.
...
@@ -61,14 +60,14 @@ namespace RTC
...
@@ -61,14 +60,14 @@ namespace RTC
private
:
private
:
// Must be first member variable. Cannot be const because we need to be copyable.
// Must be first member variable. Cannot be const because we need to be copyable.
OverUseDetectorOptions
options
;
OverUseDetectorOptions
options
;
uint16_t
numOfDeltas
;
uint16_t
numOfDeltas
=
0
;
double
slope
;
double
slope
=
0
;
double
offset
;
double
offset
=
0
;
double
prevOffset
;
double
prevOffset
=
0
;
double
E
[
2
][
2
];
double
E
[
2
][
2
];
double
processNoise
[
2
];
double
processNoise
[
2
];
double
avgNoise
;
double
avgNoise
=
0
;
double
varNoise
;
double
varNoise
=
0
;
std
::
deque
<
double
>
tsDeltaHist
;
std
::
deque
<
double
>
tsDeltaHist
;
};
};
...
...
worker/include/RTC/RemoteBitrateEstimator/RateControlInput.hpp
浏览文件 @
15e8c6ca
...
@@ -13,8 +13,8 @@ namespace RTC
...
@@ -13,8 +13,8 @@ namespace RTC
RateControlInput
(
BandwidthUsage
bwState
,
const
uint32_t
incomingBitrate
,
double
noiseVar
);
RateControlInput
(
BandwidthUsage
bwState
,
const
uint32_t
incomingBitrate
,
double
noiseVar
);
BandwidthUsage
bwState
;
BandwidthUsage
bwState
;
uint32_t
incomingBitrate
;
uint32_t
incomingBitrate
=
0
;
double
noiseVar
;
double
noiseVar
=
0
;
};
};
/* Inline methods. */
/* Inline methods. */
...
...
worker/include/RTC/RemoteBitrateEstimator/RemoteBitrateEstimator.hpp
浏览文件 @
15e8c6ca
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
#include "common.hpp"
#include "common.hpp"
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpPacket.hpp"
#include <cassert>
#include <map>
#include <map>
#include <vector>
#include <vector>
...
@@ -61,14 +60,11 @@ namespace RTC
...
@@ -61,14 +60,11 @@ namespace RTC
// Removes all data for |ssrc|.
// Removes all data for |ssrc|.
virtual
void
RemoveStream
(
uint32_t
ssrc
)
=
0
;
virtual
void
RemoveStream
(
uint32_t
ssrc
)
=
0
;
// Returns true if a valid estimate exists and sets |bitrate_bps| to the
// 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
// 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.
// 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
bool
LatestEstimate
(
std
::
vector
<
uint32_t
>*
ssrcs
,
uint32_t
*
bitrate_bps
)
const
=
0
;
virtual
void
SetMinBitrate
(
int
min_bitrate_bps
)
=
0
;
virtual
void
SetMinBitrate
(
int
min_bitrate_bps
)
=
0
;
// (jmillan) borrowed from webrtc/modules/include/module.h.
// (jmillan) borrowed from webrtc/modules/include/module.h.
//
//
// Returns the number of milliseconds until the module wants a worker
// Returns the number of milliseconds until the module wants a worker
...
@@ -81,7 +77,6 @@ namespace RTC
...
@@ -81,7 +77,6 @@ namespace RTC
// thread that calls Process() will also have it's tick count reference
// thread that calls Process() will also have it's tick count reference
// which might not match with what the implementations use.
// which might not match with what the implementations use.
virtual
int64_t
TimeUntilNextProcess
()
=
0
;
virtual
int64_t
TimeUntilNextProcess
()
=
0
;
// Process any pending tasks such as timeouts.
// Process any pending tasks such as timeouts.
// Called on a worker thread.
// Called on a worker thread.
virtual
void
Process
()
=
0
;
virtual
void
Process
()
=
0
;
...
...
worker/include/RTC/RemoteBitrateEstimator/RemoteBitrateEstimatorAbsSendTime.hpp
浏览文件 @
15e8c6ca
...
@@ -31,9 +31,9 @@ namespace RTC
...
@@ -31,9 +31,9 @@ namespace RTC
{
{
Probe
(
int64_t
sendTimeMs
,
int64_t
recvTimeMs
,
size_t
payloadSize
);
Probe
(
int64_t
sendTimeMs
,
int64_t
recvTimeMs
,
size_t
payloadSize
);
int64_t
sendTimeMs
;
int64_t
sendTimeMs
=
0
;
int64_t
recvTimeMs
;
int64_t
recvTimeMs
=
0
;
size_t
payloadSize
;
size_t
payloadSize
=
0
;
};
};
struct
Cluster
struct
Cluster
...
@@ -82,18 +82,14 @@ namespace RTC
...
@@ -82,18 +82,14 @@ namespace RTC
void
IncomingPacketInfo
(
int64_t
arrivalTimeMs
,
uint32_t
sendTime_24bits
,
size_t
payloadSize
,
uint32_t
ssrc
);
void
IncomingPacketInfo
(
int64_t
arrivalTimeMs
,
uint32_t
sendTime_24bits
,
size_t
payloadSize
,
uint32_t
ssrc
);
void
ComputeClusters
(
std
::
list
<
Cluster
>*
clusters
)
const
;
void
ComputeClusters
(
std
::
list
<
Cluster
>*
clusters
)
const
;
std
::
list
<
Cluster
>::
const_iterator
FindBestProbe
(
const
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.
// Returns true if a probe which changed the estimate was detected.
ProbeResult
ProcessClusters
(
int64_t
nowMs
);
ProbeResult
ProcessClusters
(
int64_t
nowMs
);
bool
IsBitrateImproving
(
int
probeBitrateBps
)
const
;
bool
IsBitrateImproving
(
int
probeBitrateBps
)
const
;
void
TimeoutStreams
(
int64_t
nowMs
);
void
TimeoutStreams
(
int64_t
nowMs
);
private
:
private
:
Listener
*
const
observer
;
Listener
*
const
observer
=
nullptr
;
std
::
unique_ptr
<
InterArrival
>
interArrival
;
std
::
unique_ptr
<
InterArrival
>
interArrival
;
std
::
unique_ptr
<
OveruseEstimator
>
estimator
;
std
::
unique_ptr
<
OveruseEstimator
>
estimator
;
OveruseDetector
detector
;
OveruseDetector
detector
;
...
@@ -106,7 +102,6 @@ namespace RTC
...
@@ -106,7 +102,6 @@ namespace RTC
int64_t
firstPacketTimeMs
=
-
1
;
int64_t
firstPacketTimeMs
=
-
1
;
int64_t
lastUpdateMs
=
-
1
;
int64_t
lastUpdateMs
=
-
1
;
bool
umaRecorded
=
false
;
bool
umaRecorded
=
false
;
Ssrcs
ssrcs
;
Ssrcs
ssrcs
;
AimdRateControl
remoteRate
;
AimdRateControl
remoteRate
;
};
};
...
@@ -124,6 +119,7 @@ namespace RTC
...
@@ -124,6 +119,7 @@ namespace RTC
int
Cluster
::
GetSendBitrateBps
()
const
int
Cluster
::
GetSendBitrateBps
()
const
{
{
assert
(
sendMeanMs
>
0.0
f
);
assert
(
sendMeanMs
>
0.0
f
);
return
meanSize
*
8
*
1000
/
sendMeanMs
;
return
meanSize
*
8
*
1000
/
sendMeanMs
;
}
}
...
@@ -131,6 +127,7 @@ namespace RTC
...
@@ -131,6 +127,7 @@ namespace RTC
int
Cluster
::
GetRecvBitrateBps
()
const
int
Cluster
::
GetRecvBitrateBps
()
const
{
{
assert
(
recvMeanMs
>
0.0
f
);
assert
(
recvMeanMs
>
0.0
f
);
return
meanSize
*
8
*
1000
/
recvMeanMs
;
return
meanSize
*
8
*
1000
/
recvMeanMs
;
}
}
...
@@ -157,7 +154,7 @@ namespace RTC
...
@@ -157,7 +154,7 @@ namespace RTC
inline
inline
void
RemoteBitrateEstimatorAbsSendTime
::
OnRttUpdate
(
int64_t
avgRttMs
,
int64_t
maxRttMs
)
void
RemoteBitrateEstimatorAbsSendTime
::
OnRttUpdate
(
int64_t
avgRttMs
,
int64_t
maxRttMs
)
{
{
(
void
)
maxRttMs
;
(
void
)
maxRttMs
;
this
->
remoteRate
.
SetRtt
(
avgRttMs
);
this
->
remoteRate
.
SetRtt
(
avgRttMs
);
}
}
...
...
worker/include/RTC/RemoteBitrateEstimator/RemoteBitrateEstimatorSingleStream.hpp
浏览文件 @
15e8c6ca
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include <map>
#include <map>
#include <memory>
#include <memory>
#include <vector>
#include <vector>
#include <cassert>
namespace
RTC
namespace
RTC
{
{
...
@@ -73,9 +74,9 @@ namespace RTC
...
@@ -73,9 +74,9 @@ namespace RTC
RateCalculator
incomingBitrate
;
RateCalculator
incomingBitrate
;
uint32_t
lastValidIncomingBitrate
=
0
;
uint32_t
lastValidIncomingBitrate
=
0
;
std
::
unique_ptr
<
AimdRateControl
>
remoteRate
;
std
::
unique_ptr
<
AimdRateControl
>
remoteRate
;
Listener
*
observer
;
Listener
*
observer
=
nullptr
;
int64_t
lastProcessTime
=
-
1
;
int64_t
lastProcessTime
=
-
1
;
int64_t
processIntervalMs
;
int64_t
processIntervalMs
=
0
;
bool
umaRecorded
=
false
;
bool
umaRecorded
=
false
;
};
};
...
@@ -94,7 +95,7 @@ namespace RTC
...
@@ -94,7 +95,7 @@ namespace RTC
incomingBitrate
(),
incomingBitrate
(),
remoteRate
(
new
AimdRateControl
()),
observer
(
observer
),
processIntervalMs
(
kProcessIntervalMs
)
remoteRate
(
new
AimdRateControl
()),
observer
(
observer
),
processIntervalMs
(
kProcessIntervalMs
)
{
{
//
MS_ASSERT(this->observer, "'this->observer' missing"
);
//
assert(this->observer
);
}
}
inline
inline
...
@@ -118,7 +119,7 @@ namespace RTC
...
@@ -118,7 +119,7 @@ namespace RTC
inline
inline
void
RemoteBitrateEstimatorSingleStream
::
OnRttUpdate
(
int64_t
avgRttMs
,
int64_t
maxRttMs
)
void
RemoteBitrateEstimatorSingleStream
::
OnRttUpdate
(
int64_t
avgRttMs
,
int64_t
maxRttMs
)
{
{
(
void
)
maxRttMs
;
(
void
)
maxRttMs
;
GetRemoteRate
()
->
SetRtt
(
avgRttMs
);
GetRemoteRate
()
->
SetRtt
(
avgRttMs
);
}
}
...
...
worker/src/RTC/RemoteBitrateEstimator/AimdRateControl.cpp
浏览文件 @
15e8c6ca
...
@@ -32,6 +32,7 @@ namespace RTC
...
@@ -32,6 +32,7 @@ namespace RTC
static
const
int
kRtcpSize
=
80
;
static
const
int
kRtcpSize
=
80
;
int64_t
interval
=
static_cast
<
int64_t
>
(
kRtcpSize
*
8.0
*
1000.0
/
(
0.05
*
this
->
currentBitrateBps
)
+
0.5
);
int64_t
interval
=
static_cast
<
int64_t
>
(
kRtcpSize
*
8.0
*
1000.0
/
(
0.05
*
this
->
currentBitrateBps
)
+
0.5
);
const
int64_t
kMinFeedbackIntervalMs
=
200
;
const
int64_t
kMinFeedbackIntervalMs
=
200
;
return
std
::
min
(
std
::
max
(
interval
,
kMinFeedbackIntervalMs
),
kMaxFeedbackIntervalMs
);
return
std
::
min
(
std
::
max
(
interval
,
kMinFeedbackIntervalMs
),
kMaxFeedbackIntervalMs
);
}
}
...
@@ -49,8 +50,10 @@ namespace RTC
...
@@ -49,8 +50,10 @@ namespace RTC
// TODO(terelius/holmer): Investigate consequences of increasing
// TODO(terelius/holmer): Investigate consequences of increasing
// the threshold to 0.95 * LatestEstimate().
// the threshold to 0.95 * LatestEstimate().
const
uint32_t
threshold
=
static_cast
<
uint32_t
>
(
0.5
*
LatestEstimate
());
const
uint32_t
threshold
=
static_cast
<
uint32_t
>
(
0.5
*
LatestEstimate
());
return
incomingBitrateBps
<
threshold
;
return
incomingBitrateBps
<
threshold
;
}
}
return
false
;
return
false
;
}
}
...
@@ -65,7 +68,9 @@ namespace RTC
...
@@ -65,7 +68,9 @@ namespace RTC
if
(
!
this
->
bitrateIsInitialized
)
if
(
!
this
->
bitrateIsInitialized
)
{
{
const
int64_t
kInitializationTimeMs
=
5000
;
const
int64_t
kInitializationTimeMs
=
5000
;
//MSDASSERT(kBitrateWindowMs <= kInitializationTimeMs);
// MS_ASSERT(kBitrateWindowMs <= kInitializationTimeMs);
if
(
this
->
timeFirstIncomingEstimate
<
0
)
if
(
this
->
timeFirstIncomingEstimate
<
0
)
{
{
if
(
input
->
incomingBitrate
)
if
(
input
->
incomingBitrate
)
...
@@ -105,6 +110,7 @@ namespace RTC
...
@@ -105,6 +110,7 @@ namespace RTC
const
int64_t
responseTime
=
(
this
->
rtt
+
100
)
*
2
;
const
int64_t
responseTime
=
(
this
->
rtt
+
100
)
*
2
;
constexpr
double
kMinIncreaseRateBps
=
4000
;
constexpr
double
kMinIncreaseRateBps
=
4000
;
return
static_cast
<
int
>
(
std
::
max
(
kMinIncreaseRateBps
,
(
avgPacketSizeBits
*
1000
)
/
responseTime
));
return
static_cast
<
int
>
(
std
::
max
(
kMinIncreaseRateBps
,
(
avgPacketSizeBits
*
1000
)
/
responseTime
));
}
}
...
@@ -116,18 +122,22 @@ namespace RTC
...
@@ -116,18 +122,22 @@ namespace RTC
{
{
return
this
->
currentBitrateBps
;
return
this
->
currentBitrateBps
;
}
}
// An over-use should always trigger us to reduce the bitrate, even though
// 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 have not yet established our first estimate. By acting on the over-use,
// we will end up with a valid estimate.
// we will end up with a valid estimate.
if
(
!
this
->
bitrateIsInitialized
&&
this
->
currentInput
.
bwState
!=
kBwOverusing
)
if
(
!
this
->
bitrateIsInitialized
&&
this
->
currentInput
.
bwState
!=
kBwOverusing
)
return
this
->
currentBitrateBps
;
return
this
->
currentBitrateBps
;
this
->
updated
=
false
;
this
->
updated
=
false
;
ChangeState
(
this
->
currentInput
,
nowMs
);
ChangeState
(
this
->
currentInput
,
nowMs
);
// Calculated here because it's used in multiple places.
// Calculated here because it's used in multiple places.
const
float
incomingBitrateKbps
=
incomingBitrateBps
/
1000.0
f
;
const
float
incomingBitrateKbps
=
incomingBitrateBps
/
1000.0
f
;
// Calculate the max bit rate std dev given the normalized
// Calculate the max bit rate std dev given the normalized
// variance and the current incoming bit rate.
// variance and the current incoming bit rate.
const
float
stdMaxBitRate
=
sqrt
(
this
->
varMaxBitrateKbps
*
this
->
avgMaxBitrateKbps
);
const
float
stdMaxBitRate
=
sqrt
(
this
->
varMaxBitrateKbps
*
this
->
avgMaxBitrateKbps
);
switch
(
this
->
rateControlState
)
switch
(
this
->
rateControlState
)
{
{
case
kRcHold
:
case
kRcHold
:
...
@@ -187,6 +197,7 @@ namespace RTC
...
@@ -187,6 +197,7 @@ namespace RTC
default
:
default
:
MS_ASSERT
(
false
,
"invalid this->rateControlState value"
);
MS_ASSERT
(
false
,
"invalid this->rateControlState value"
);
}
}
return
ClampBitrate
(
newBitrateBps
,
incomingBitrateBps
);
return
ClampBitrate
(
newBitrateBps
,
incomingBitrateBps
);
}
}
...
@@ -198,11 +209,13 @@ namespace RTC
...
@@ -198,11 +209,13 @@ namespace RTC
// We allow a bit more lag at very low rates to not too easily get stuck if
// We allow a bit more lag at very low rates to not too easily get stuck if
// the encoder produces uneven outputs.
// the encoder produces uneven outputs.
const
uint32_t
maxBitrateBps
=
static_cast
<
uint32_t
>
(
1.5
f
*
incomingBitrateBps
)
+
10000
;
const
uint32_t
maxBitrateBps
=
static_cast
<
uint32_t
>
(
1.5
f
*
incomingBitrateBps
)
+
10000
;
if
(
newBitrateBps
>
this
->
currentBitrateBps
&&
newBitrateBps
>
maxBitrateBps
)
if
(
newBitrateBps
>
this
->
currentBitrateBps
&&
newBitrateBps
>
maxBitrateBps
)
{
{
newBitrateBps
=
std
::
max
(
this
->
currentBitrateBps
,
maxBitrateBps
);
newBitrateBps
=
std
::
max
(
this
->
currentBitrateBps
,
maxBitrateBps
);
}
}
newBitrateBps
=
std
::
max
(
newBitrateBps
,
this
->
minConfiguredBitrateBps
);
newBitrateBps
=
std
::
max
(
newBitrateBps
,
this
->
minConfiguredBitrateBps
);
return
newBitrateBps
;
return
newBitrateBps
;
}
}
...
@@ -211,11 +224,13 @@ namespace RTC
...
@@ -211,11 +224,13 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
double
alpha
=
1.08
;
double
alpha
=
1.08
;
if
(
lastMs
>
-
1
)
if
(
lastMs
>
-
1
)
{
{
int
timeSinceLastUpdateMs
=
std
::
min
(
static_cast
<
int
>
(
nowMs
-
lastMs
),
1000
);
int
timeSinceLastUpdateMs
=
std
::
min
(
static_cast
<
int
>
(
nowMs
-
lastMs
),
1000
);
alpha
=
pow
(
alpha
,
timeSinceLastUpdateMs
/
1000.0
);
alpha
=
pow
(
alpha
,
timeSinceLastUpdateMs
/
1000.0
);
}
}
uint32_t
multiplicativeIncreaseBps
=
std
::
max
(
currentBitrateBps
*
(
alpha
-
1.0
),
1000.0
);
uint32_t
multiplicativeIncreaseBps
=
std
::
max
(
currentBitrateBps
*
(
alpha
-
1.0
),
1000.0
);
return
multiplicativeIncreaseBps
;
return
multiplicativeIncreaseBps
;
...
@@ -226,6 +241,7 @@ namespace RTC
...
@@ -226,6 +241,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
const
float
alpha
=
0.05
f
;
const
float
alpha
=
0.05
f
;
if
(
this
->
avgMaxBitrateKbps
==
-
1.0
f
)
if
(
this
->
avgMaxBitrateKbps
==
-
1.0
f
)
{
{
this
->
avgMaxBitrateKbps
=
incomingBitrateKbps
;
this
->
avgMaxBitrateKbps
=
incomingBitrateKbps
;
...
@@ -234,9 +250,11 @@ namespace RTC
...
@@ -234,9 +250,11 @@ namespace RTC
{
{
this
->
avgMaxBitrateKbps
=
(
1
-
alpha
)
*
this
->
avgMaxBitrateKbps
+
alpha
*
incomingBitrateKbps
;
this
->
avgMaxBitrateKbps
=
(
1
-
alpha
)
*
this
->
avgMaxBitrateKbps
+
alpha
*
incomingBitrateKbps
;
}
}
// Estimate the max bit rate variance and normalize the variance
// Estimate the max bit rate variance and normalize the variance
// with the average max bit rate.
// with the average max bit rate.
const
float
norm
=
std
::
max
(
this
->
avgMaxBitrateKbps
,
1.0
f
);
const
float
norm
=
std
::
max
(
this
->
avgMaxBitrateKbps
,
1.0
f
);
this
->
varMaxBitrateKbps
=
(
1
-
alpha
)
*
this
->
varMaxBitrateKbps
+
this
->
varMaxBitrateKbps
=
(
1
-
alpha
)
*
this
->
varMaxBitrateKbps
+
alpha
*
(
this
->
avgMaxBitrateKbps
-
incomingBitrateKbps
)
*
(
this
->
avgMaxBitrateKbps
-
incomingBitrateKbps
)
/
norm
;
alpha
*
(
this
->
avgMaxBitrateKbps
-
incomingBitrateKbps
)
*
(
this
->
avgMaxBitrateKbps
-
incomingBitrateKbps
)
/
norm
;
// 0.4 ~= 14 kbit/s at 500 kbit/s
// 0.4 ~= 14 kbit/s at 500 kbit/s
...
@@ -255,7 +273,7 @@ namespace RTC
...
@@ -255,7 +273,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
(
void
)
input
;
(
void
)
input
;
switch
(
this
->
currentInput
.
bwState
)
switch
(
this
->
currentInput
.
bwState
)
{
{
case
kBwNormal
:
case
kBwNormal
:
...
...
worker/src/RTC/RemoteBitrateEstimator/OveruseEstimator.cpp
浏览文件 @
15e8c6ca
...
@@ -27,7 +27,7 @@ namespace RTC
...
@@ -27,7 +27,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
(
void
)
nowMs
;
(
void
)
nowMs
;
const
double
minFramePeriod
=
UpdateMinFramePeriod
(
tsDelta
);
const
double
minFramePeriod
=
UpdateMinFramePeriod
(
tsDelta
);
const
double
tTsDelta
=
tDelta
-
tsDelta
;
const
double
tTsDelta
=
tDelta
-
tsDelta
;
double
fsDelta
=
sizeDelta
;
double
fsDelta
=
sizeDelta
;
...
@@ -50,11 +50,10 @@ namespace RTC
...
@@ -50,11 +50,10 @@ namespace RTC
const
double
h
[
2
]
=
{
fsDelta
,
1.0
};
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
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
double
residual
=
tTsDelta
-
this
->
slope
*
h
[
0
]
-
this
->
offset
;
const
bool
inStableState
=
(
currentHypothesis
==
kBwNormal
);
const
bool
inStableState
=
(
currentHypothesis
==
kBwNormal
);
const
double
maxResidual
=
3.0
*
sqrt
(
this
->
varNoise
);
const
double
maxResidual
=
3.0
*
sqrt
(
this
->
varNoise
);
// We try to filter out very late frames. For instance periodic key
// We try to filter out very late frames. For instance periodic key
// frames doesn't fit the Gaussian model well.
// frames doesn't fit the Gaussian model well.
if
(
fabs
(
residual
)
<
maxResidual
)
if
(
fabs
(
residual
)
<
maxResidual
)
...
@@ -67,9 +66,7 @@ namespace RTC
...
@@ -67,9 +66,7 @@ namespace RTC
}
}
const
double
denom
=
this
->
varNoise
+
h
[
0
]
*
Eh
[
0
]
+
h
[
1
]
*
Eh
[
1
];
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
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
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
e00
=
this
->
E
[
0
][
0
];
const
double
e01
=
this
->
E
[
0
][
1
];
const
double
e01
=
this
->
E
[
0
][
1
];
...
@@ -111,6 +108,7 @@ namespace RTC
...
@@ -111,6 +108,7 @@ namespace RTC
minFramePeriod
=
std
::
min
(
oldTsDelta
,
minFramePeriod
);
minFramePeriod
=
std
::
min
(
oldTsDelta
,
minFramePeriod
);
}
}
this
->
tsDeltaHist
.
push_back
(
tsDelta
);
this
->
tsDeltaHist
.
push_back
(
tsDelta
);
return
minFramePeriod
;
return
minFramePeriod
;
}
}
...
@@ -122,6 +120,7 @@ namespace RTC
...
@@ -122,6 +120,7 @@ namespace RTC
{
{
return
;
return
;
}
}
// Faster filter during startup to faster adapt to the jitter level
// 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
// of the network. |alpha| is tuned for 30 frames per second, but is scaled
// according to |tsDelta|.
// according to |tsDelta|.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论