Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
46bd7687
提交
46bd7687
authored
11月 17, 2019
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP
上级
d6632c9a
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
28 行增加
和
371 行删除
+28
-371
Consumer.hpp
worker/include/RTC/Consumer.hpp
+0
-1
PipeConsumer.hpp
worker/include/RTC/PipeConsumer.hpp
+0
-1
SimpleConsumer.hpp
worker/include/RTC/SimpleConsumer.hpp
+0
-1
SimulcastConsumer.hpp
worker/include/RTC/SimulcastConsumer.hpp
+0
-1
SvcConsumer.hpp
worker/include/RTC/SvcConsumer.hpp
+0
-1
PipeConsumer.cpp
worker/src/RTC/PipeConsumer.cpp
+0
-8
SimpleConsumer.cpp
worker/src/RTC/SimpleConsumer.cpp
+0
-8
SimulcastConsumer.cpp
worker/src/RTC/SimulcastConsumer.cpp
+13
-182
SvcConsumer.cpp
worker/src/RTC/SvcConsumer.cpp
+10
-157
Transport.cpp
worker/src/RTC/Transport.cpp
+3
-9
TransportCongestionControlClient.cpp
worker/src/RTC/TransportCongestionControlClient.cpp
+2
-2
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
46bd7687
...
@@ -80,7 +80,6 @@ namespace RTC
...
@@ -80,7 +80,6 @@ namespace RTC
void
ProducerClosed
();
void
ProducerClosed
();
void
SetExternallyManagedBitrate
();
void
SetExternallyManagedBitrate
();
virtual
uint8_t
GetBitratePriority
()
const
=
0
;
virtual
uint8_t
GetBitratePriority
()
const
=
0
;
virtual
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
,
bool
considerLoss
)
=
0
;
virtual
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
=
0
;
virtual
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
=
0
;
virtual
void
ApplyLayers
()
=
0
;
virtual
void
ApplyLayers
()
=
0
;
virtual
uint32_t
GetDesiredBitrate
()
const
=
0
;
virtual
uint32_t
GetDesiredBitrate
()
const
=
0
;
...
...
worker/include/RTC/PipeConsumer.hpp
浏览文件 @
46bd7687
...
@@ -23,7 +23,6 @@ namespace RTC
...
@@ -23,7 +23,6 @@ namespace RTC
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
override
;
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
override
;
uint8_t
GetBitratePriority
()
const
override
;
uint8_t
GetBitratePriority
()
const
override
;
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
void
ApplyLayers
()
override
;
void
ApplyLayers
()
override
;
uint32_t
GetDesiredBitrate
()
const
override
;
uint32_t
GetDesiredBitrate
()
const
override
;
...
...
worker/include/RTC/SimpleConsumer.hpp
浏览文件 @
46bd7687
...
@@ -24,7 +24,6 @@ namespace RTC
...
@@ -24,7 +24,6 @@ namespace RTC
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
override
;
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
override
;
uint8_t
GetBitratePriority
()
const
override
;
uint8_t
GetBitratePriority
()
const
override
;
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
void
ApplyLayers
()
override
;
void
ApplyLayers
()
override
;
uint32_t
GetDesiredBitrate
()
const
override
;
uint32_t
GetDesiredBitrate
()
const
override
;
...
...
worker/include/RTC/SimulcastConsumer.hpp
浏览文件 @
46bd7687
...
@@ -25,7 +25,6 @@ namespace RTC
...
@@ -25,7 +25,6 @@ namespace RTC
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
override
;
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
override
;
uint8_t
GetBitratePriority
()
const
override
;
uint8_t
GetBitratePriority
()
const
override
;
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
void
ApplyLayers
()
override
;
void
ApplyLayers
()
override
;
uint32_t
GetDesiredBitrate
()
const
override
;
uint32_t
GetDesiredBitrate
()
const
override
;
...
...
worker/include/RTC/SvcConsumer.hpp
浏览文件 @
46bd7687
...
@@ -26,7 +26,6 @@ namespace RTC
...
@@ -26,7 +26,6 @@ namespace RTC
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
override
;
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
override
;
uint8_t
GetBitratePriority
()
const
override
;
uint8_t
GetBitratePriority
()
const
override
;
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
override
;
void
ApplyLayers
()
override
;
void
ApplyLayers
()
override
;
uint32_t
GetDesiredBitrate
()
const
override
;
uint32_t
GetDesiredBitrate
()
const
override
;
...
...
worker/src/RTC/PipeConsumer.cpp
浏览文件 @
46bd7687
...
@@ -143,14 +143,6 @@ namespace RTC
...
@@ -143,14 +143,6 @@ namespace RTC
return
0u
;
return
0u
;
}
}
uint32_t
PipeConsumer
::
UseAvailableBitrate
(
uint32_t
/*bitrate*/
,
bool
/*considerLoss*/
)
{
MS_TRACE
();
// PipeConsumer does not play the BWE game.
return
0u
;
}
uint32_t
PipeConsumer
::
IncreaseLayer
(
uint32_t
/*bitrate*/
,
bool
/*considerLoss*/
)
uint32_t
PipeConsumer
::
IncreaseLayer
(
uint32_t
/*bitrate*/
,
bool
/*considerLoss*/
)
{
{
MS_TRACE
();
MS_TRACE
();
...
...
worker/src/RTC/SimpleConsumer.cpp
浏览文件 @
46bd7687
...
@@ -155,14 +155,6 @@ namespace RTC
...
@@ -155,14 +155,6 @@ namespace RTC
return
1u
;
return
1u
;
}
}
uint32_t
SimpleConsumer
::
UseAvailableBitrate
(
uint32_t
/*bitrate*/
,
bool
/*considerLoss*/
)
{
MS_TRACE
();
// SimpleConsumer does not play the BWE game.
return
0u
;
}
uint32_t
SimpleConsumer
::
IncreaseLayer
(
uint32_t
/*bitrate*/
,
bool
/*considerLoss*/
)
uint32_t
SimpleConsumer
::
IncreaseLayer
(
uint32_t
/*bitrate*/
,
bool
/*considerLoss*/
)
{
{
MS_TRACE
();
MS_TRACE
();
...
...
worker/src/RTC/SimulcastConsumer.cpp
浏览文件 @
46bd7687
...
@@ -346,187 +346,12 @@ namespace RTC
...
@@ -346,187 +346,12 @@ namespace RTC
return
1u
;
return
1u
;
}
}
uint32_t
SimulcastConsumer
::
UseAvailableBitrate
(
uint32_t
bitrate
,
bool
considerLoss
)
{
MS_TRACE
();
MS_ASSERT
(
this
->
externallyManagedBitrate
,
"bitrate is not externally managed"
);
this
->
provisionalTargetSpatialLayer
=
-
1
;
this
->
provisionalTargetTemporalLayer
=
-
1
;
if
(
!
RTC
::
Consumer
::
IsActive
())
return
0u
;
uint32_t
virtualBitrate
;
if
(
considerLoss
)
{
// Calculate virtual available bitrate based on given bitrate and our
// packet lost.
auto
lossPercentage
=
this
->
rtpStream
->
GetLossPercentage
();
if
(
lossPercentage
<
2
)
virtualBitrate
=
1.08
*
bitrate
;
else
if
(
lossPercentage
>
10
)
virtualBitrate
=
(
1
-
0.5
*
(
lossPercentage
/
100
))
*
bitrate
;
else
virtualBitrate
=
bitrate
;
}
else
{
virtualBitrate
=
bitrate
;
}
uint32_t
usedBitrate
{
0u
};
uint8_t
maxProducerScore
{
0u
};
auto
nowMs
=
DepLibUV
::
GetTimeMs
();
for
(
size_t
sIdx
{
0u
};
sIdx
<
this
->
producerRtpStreams
.
size
();
++
sIdx
)
{
auto
spatialLayer
=
static_cast
<
int16_t
>
(
sIdx
);
auto
*
producerRtpStream
=
this
->
producerRtpStreams
.
at
(
sIdx
);
auto
producerScore
=
producerRtpStream
?
producerRtpStream
->
GetScore
()
:
0u
;
// If this is higher than current spatial layer and we moved to to current spatial
// layer due to BWE limitations, check how much it has elapsed since then.
if
(
nowMs
-
this
->
lastBweDowngradeAtMs
<
BweDowngradeConservativeMs
)
{
if
(
usedBitrate
>
0u
&&
spatialLayer
>
this
->
currentSpatialLayer
)
{
MS_DEBUG_DEV
(
"avoid upgrading to spatial layer %"
PRIi16
" due to recent BWE downgrade"
,
spatialLayer
);
goto
done
;
}
}
// Ignore spatial layers for non existing producer streams or for those
// with score 0.
if
(
producerScore
==
0u
)
continue
;
// If the stream has not been active time enough and we have an active one
// already, move to the next spatial layer.
if
(
usedBitrate
>
0u
&&
producerRtpStream
->
GetActiveMs
()
<
StreamMinActiveMs
)
continue
;
// We may not yet switch to this spatial layer.
if
(
!
CanSwitchToSpatialLayer
(
spatialLayer
))
continue
;
// If the stream score is worse than the best seen and not good enough, ignore
// this stream.
if
(
producerScore
<
maxProducerScore
&&
producerScore
<
StreamGoodScore
)
continue
;
maxProducerScore
=
producerScore
;
int16_t
temporalLayer
{
0
};
// Check bitrate of every temporal layer.
for
(;
temporalLayer
<
producerRtpStream
->
GetTemporalLayers
();
++
temporalLayer
)
{
auto
requiredBitrate
=
producerRtpStream
->
GetBitrate
(
nowMs
,
0u
,
temporalLayer
);
MS_DEBUG_DEV
(
"testing layers %"
PRIi16
":%"
PRIi16
" [virtual bitrate:%"
PRIu32
", required bitrate:%"
PRIu32
"]"
,
spatialLayer
,
temporalLayer
,
virtualBitrate
,
requiredBitrate
);
// If layer is not active move to next spatial layer.
if
(
requiredBitrate
==
0u
)
break
;
// If this layer requires more bitrate than the given one, abort the loop
// (so use the previous chosen layers if any).
if
(
requiredBitrate
>
virtualBitrate
)
goto
done
;
// Set provisional layers and used bitrate.
this
->
provisionalTargetSpatialLayer
=
spatialLayer
;
this
->
provisionalTargetTemporalLayer
=
temporalLayer
;
usedBitrate
=
requiredBitrate
;
// If this is the preferred spatial and temporal layer, exit the loops.
// clang-format off
if
(
this
->
provisionalTargetSpatialLayer
==
this
->
preferredSpatialLayer
&&
this
->
provisionalTargetTemporalLayer
==
this
->
preferredTemporalLayer
&&
producerScore
>=
StreamGoodScore
)
// clang-format on
{
goto
done
;
}
}
// If this is the preferred or higher spatial layer and has good score,
// take it and exit.
// clang-format off
if
(
this
->
provisionalTargetSpatialLayer
>=
this
->
preferredSpatialLayer
&&
producerScore
>=
StreamGoodScore
)
// clang-format on
{
break
;
}
}
done
:
// clang-format off
if
(
this
->
provisionalTargetSpatialLayer
!=
this
->
targetSpatialLayer
||
this
->
provisionalTargetTemporalLayer
!=
this
->
targetTemporalLayer
)
// clang-format on
{
MS_DEBUG_2TAGS
(
bwe
,
simulcast
,
"choosing layers %"
PRIi16
":%"
PRIi16
" [bitrate:%"
PRIu32
", virtual bitrate:%"
PRIu32
", used bitrate:%"
PRIu32
", consumerId:%s]"
,
this
->
provisionalTargetSpatialLayer
,
this
->
provisionalTargetTemporalLayer
,
bitrate
,
virtualBitrate
,
usedBitrate
,
this
->
id
.
c_str
());
}
else
{
MS_DEBUG_DEV
(
"choosing layers %"
PRIi16
":%"
PRIi16
" [bitrate:%"
PRIu32
", virtual bitrate:%"
PRIu32
", used bitrate:%"
PRIu32
", consumerId:%s]"
,
this
->
provisionalTargetSpatialLayer
,
this
->
provisionalTargetTemporalLayer
,
bitrate
,
virtualBitrate
,
usedBitrate
,
this
->
id
.
c_str
());
}
// Must recompute usedBitrate based on given bitrate, virtualBitrate and
// usedBitrate.
if
(
usedBitrate
<=
bitrate
)
return
usedBitrate
;
else
if
(
usedBitrate
<=
virtualBitrate
)
return
bitrate
;
else
return
usedBitrate
;
}
uint32_t
SimulcastConsumer
::
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
uint32_t
SimulcastConsumer
::
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
{
{
MS_TRACE
();
MS_TRACE
();
MS_ASSERT
(
this
->
externallyManagedBitrate
,
"bitrate is not externally managed"
);
MS_ASSERT
(
this
->
externallyManagedBitrate
,
"bitrate is not externally managed"
);
MS_ASSERT
(
IsActive
(),
"should be active
(Consumer::IsActive())
"
);
MS_ASSERT
(
IsActive
(),
"should be active"
);
// If already in the preferred layers, do nothing.
// If already in the preferred layers, do nothing.
// clang-format off
// clang-format off
...
@@ -650,6 +475,14 @@ namespace RTC
...
@@ -650,6 +475,14 @@ namespace RTC
requiredBitrate
=
1u
;
// Don't set 0 since it would be ignored.
requiredBitrate
=
1u
;
// Don't set 0 since it would be ignored.
}
}
MS_DEBUG_DEV
(
"testing layers %"
PRIi16
":%"
PRIi16
" [virtual bitrate:%"
PRIu32
", required bitrate:%"
PRIu32
"]"
,
spatialLayer
,
temporalLayer
,
virtualBitrate
,
requiredBitrate
);
// If active layer, end iterations here. Otherwise move to next spatial layer.
// If active layer, end iterations here. Otherwise move to next spatial layer.
if
(
requiredBitrate
)
if
(
requiredBitrate
)
goto
done
;
goto
done
;
...
@@ -676,10 +509,8 @@ namespace RTC
...
@@ -676,10 +509,8 @@ namespace RTC
this
->
provisionalTargetSpatialLayer
=
spatialLayer
;
this
->
provisionalTargetSpatialLayer
=
spatialLayer
;
this
->
provisionalTargetTemporalLayer
=
temporalLayer
;
this
->
provisionalTargetTemporalLayer
=
temporalLayer
;
MS_DEBUG_2TAGS
(
MS_DEBUG_DEV
(
bwe
,
"setting provisional layers to %"
PRIi16
":%"
PRIi16
" [virtual bitrate:%"
PRIu32
simulcast
,
"upgrading to layers %"
PRIi16
":%"
PRIi16
" [virtual bitrate:%"
PRIu32
", required bitrate:%"
PRIu32
"]"
,
", required bitrate:%"
PRIu32
"]"
,
this
->
provisionalTargetSpatialLayer
,
this
->
provisionalTargetSpatialLayer
,
this
->
provisionalTargetTemporalLayer
,
this
->
provisionalTargetTemporalLayer
,
...
@@ -928,7 +759,7 @@ namespace RTC
...
@@ -928,7 +759,7 @@ namespace RTC
{
{
// Max delay in ms we allow for the stream when switching.
// Max delay in ms we allow for the stream when switching.
// https://en.wikipedia.org/wiki/Audio-to-video_synchronization#Recommendations
// https://en.wikipedia.org/wiki/Audio-to-video_synchronization#Recommendations
static
const
uint32_t
MaxExtraOffsetMs
{
50
u
};
static
const
uint32_t
MaxExtraOffsetMs
{
75
u
};
int64_t
maxTsExtraOffset
=
MaxExtraOffsetMs
*
this
->
rtpStream
->
GetClockRate
()
/
1000
;
int64_t
maxTsExtraOffset
=
MaxExtraOffsetMs
*
this
->
rtpStream
->
GetClockRate
()
/
1000
;
uint32_t
tsExtraOffset
=
uint32_t
tsExtraOffset
=
...
@@ -938,7 +769,7 @@ namespace RTC
...
@@ -938,7 +769,7 @@ namespace RTC
if
(
this
->
keyFrameForTsOffsetRequested
)
if
(
this
->
keyFrameForTsOffsetRequested
)
{
{
// Give up and use the theoretical offset.
// Give up and use the theoretical offset.
tsExtraOffset
=
0
u
;
tsExtraOffset
=
1
u
;
}
}
else
if
(
tsExtraOffset
>
maxTsExtraOffset
)
else
if
(
tsExtraOffset
>
maxTsExtraOffset
)
{
{
...
...
worker/src/RTC/SvcConsumer.cpp
浏览文件 @
46bd7687
...
@@ -306,165 +306,12 @@ namespace RTC
...
@@ -306,165 +306,12 @@ namespace RTC
return
1u
;
return
1u
;
}
}
uint32_t
SvcConsumer
::
UseAvailableBitrate
(
uint32_t
bitrate
,
bool
considerLoss
)
{
MS_TRACE
();
MS_ASSERT
(
this
->
externallyManagedBitrate
,
"bitrate is not externally managed"
);
this
->
provisionalTargetSpatialLayer
=
-
1
;
this
->
provisionalTargetTemporalLayer
=
-
1
;
if
(
!
RTC
::
Consumer
::
IsActive
())
return
0u
;
uint32_t
virtualBitrate
;
if
(
considerLoss
)
{
// Calculate virtual available bitrate based on given bitrate and our
// packet lost.
auto
lossPercentage
=
this
->
rtpStream
->
GetLossPercentage
();
if
(
lossPercentage
<
2
)
virtualBitrate
=
1.08
*
bitrate
;
else
if
(
lossPercentage
>
10
)
virtualBitrate
=
(
1
-
0.5
*
(
lossPercentage
/
100
))
*
bitrate
;
else
virtualBitrate
=
bitrate
;
}
else
{
virtualBitrate
=
bitrate
;
}
uint32_t
usedBitrate
{
0u
};
auto
nowMs
=
DepLibUV
::
GetTimeMs
();
int16_t
spatialLayer
{
0
};
if
(
!
this
->
producerRtpStream
)
goto
done
;
if
(
this
->
producerRtpStream
->
GetScore
()
==
0u
)
goto
done
;
for
(;
spatialLayer
<
this
->
producerRtpStream
->
GetSpatialLayers
();
++
spatialLayer
)
{
// If this is higher than current spatial layer and we moved to to current spatial
// layer due to BWE limitations, check how much it has elapsed since then.
if
(
nowMs
-
this
->
lastBweDowngradeAtMs
<
BweDowngradeConservativeMs
)
{
if
(
usedBitrate
>
0u
&&
spatialLayer
>
this
->
encodingContext
->
GetCurrentSpatialLayer
())
{
MS_DEBUG_DEV
(
"avoid upgrading to spatial layer %"
PRIi16
" due to recent BWE downgrade"
,
spatialLayer
);
goto
done
;
}
}
int16_t
temporalLayer
{
0
};
// Check bitrate of every temporal layer.
for
(;
temporalLayer
<
this
->
producerRtpStream
->
GetTemporalLayers
();
++
temporalLayer
)
{
auto
requiredBitrate
=
this
->
producerRtpStream
->
GetBitrate
(
nowMs
,
spatialLayer
,
temporalLayer
);
MS_DEBUG_DEV
(
"testing layers %"
PRIi16
":%"
PRIi16
" [virtual bitrate:%"
PRIu32
", required bitrate:%"
PRIu32
"]"
,
spatialLayer
,
temporalLayer
,
virtualBitrate
,
requiredBitrate
);
// If layer is not active move to next spatial layer.
if
(
requiredBitrate
==
0u
)
break
;
// If this layer requires more bitrate than the given one, abort the loop
// (so use the previous chosen layers if any).
if
(
requiredBitrate
>
virtualBitrate
)
goto
done
;
// Set provisional layers and used bitrate.
this
->
provisionalTargetSpatialLayer
=
spatialLayer
;
this
->
provisionalTargetTemporalLayer
=
temporalLayer
;
usedBitrate
=
requiredBitrate
;
// If this is the preferred spatial and temporal layer, exit the loops.
// clang-format off
if
(
this
->
provisionalTargetSpatialLayer
==
this
->
preferredSpatialLayer
&&
this
->
provisionalTargetTemporalLayer
==
this
->
preferredTemporalLayer
)
// clang-format on
{
goto
done
;
}
}
// If this is the preferred or higher spatial layer, take it and exit.
if
(
this
->
provisionalTargetSpatialLayer
>=
this
->
preferredSpatialLayer
)
break
;
}
done
:
// clang-format off
if
(
this
->
provisionalTargetSpatialLayer
!=
this
->
encodingContext
->
GetTargetSpatialLayer
()
||
this
->
provisionalTargetTemporalLayer
!=
this
->
encodingContext
->
GetTargetTemporalLayer
()
)
// clang-format on
{
MS_DEBUG_2TAGS
(
bwe
,
svc
,
"choosing layers %"
PRIi16
":%"
PRIi16
" [bitrate:%"
PRIu32
", virtual bitrate:%"
PRIu32
", used bitrate:%"
PRIu32
", consumerId:%s]"
,
this
->
provisionalTargetSpatialLayer
,
this
->
provisionalTargetTemporalLayer
,
bitrate
,
virtualBitrate
,
usedBitrate
,
this
->
id
.
c_str
());
}
else
{
MS_DEBUG_DEV
(
"choosing layers %"
PRIi16
":%"
PRIi16
" [bitrate:%"
PRIu32
", virtual bitrate:%"
PRIu32
", used bitrate:%"
PRIu32
", consumerId:%s]"
,
this
->
provisionalTargetSpatialLayer
,
this
->
provisionalTargetTemporalLayer
,
bitrate
,
virtualBitrate
,
usedBitrate
,
this
->
id
.
c_str
());
}
// Must recompute usedBitrate based on given bitrate, virtualBitrate and
// usedBitrate.
if
(
usedBitrate
<=
bitrate
)
return
usedBitrate
;
else
if
(
usedBitrate
<=
virtualBitrate
)
return
bitrate
;
else
return
usedBitrate
;
}
uint32_t
SvcConsumer
::
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
uint32_t
SvcConsumer
::
IncreaseLayer
(
uint32_t
bitrate
,
bool
considerLoss
)
{
{
MS_TRACE
();
MS_TRACE
();
MS_ASSERT
(
this
->
externallyManagedBitrate
,
"bitrate is not externally managed"
);
MS_ASSERT
(
this
->
externallyManagedBitrate
,
"bitrate is not externally managed"
);
MS_ASSERT
(
IsActive
(),
"should be active"
);
if
(
!
RTC
::
Consumer
::
IsActive
())
return
0u
;
if
(
!
this
->
producerRtpStream
)
return
0u
;
if
(
this
->
producerRtpStream
->
GetScore
()
==
0u
)
if
(
this
->
producerRtpStream
->
GetScore
()
==
0u
)
return
0u
;
return
0u
;
...
@@ -544,6 +391,14 @@ namespace RTC
...
@@ -544,6 +391,14 @@ namespace RTC
requiredBitrate
=
requiredBitrate
=
this
->
producerRtpStream
->
GetLayerBitrate
(
nowMs
,
spatialLayer
,
temporalLayer
);
this
->
producerRtpStream
->
GetLayerBitrate
(
nowMs
,
spatialLayer
,
temporalLayer
);
MS_DEBUG_DEV
(
"testing layers %"
PRIi16
":%"
PRIi16
" [virtual bitrate:%"
PRIu32
", required bitrate:%"
PRIu32
"]"
,
spatialLayer
,
temporalLayer
,
virtualBitrate
,
requiredBitrate
);
// If active layer, end iterations here. Otherwise move to next spatial layer.
// If active layer, end iterations here. Otherwise move to next spatial layer.
if
(
requiredBitrate
)
if
(
requiredBitrate
)
goto
done
;
goto
done
;
...
@@ -570,9 +425,7 @@ namespace RTC
...
@@ -570,9 +425,7 @@ namespace RTC
this
->
provisionalTargetSpatialLayer
=
spatialLayer
;
this
->
provisionalTargetSpatialLayer
=
spatialLayer
;
this
->
provisionalTargetTemporalLayer
=
temporalLayer
;
this
->
provisionalTargetTemporalLayer
=
temporalLayer
;
MS_DEBUG_2TAGS
(
MS_DEBUG_DEV
(
bwe
,
svc
,
"upgrading to layers %"
PRIi16
":%"
PRIi16
" [virtual bitrate:%"
PRIu32
"upgrading to layers %"
PRIi16
":%"
PRIi16
" [virtual bitrate:%"
PRIu32
", required bitrate:%"
PRIu32
"]"
,
", required bitrate:%"
PRIu32
"]"
,
this
->
provisionalTargetSpatialLayer
,
this
->
provisionalTargetSpatialLayer
,
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
46bd7687
...
@@ -1977,7 +1977,7 @@ namespace RTC
...
@@ -1977,7 +1977,7 @@ namespace RTC
this
->
tccClient
->
RescheduleNextAvailableBitrateEvent
();
this
->
tccClient
->
RescheduleNextAvailableBitrateEvent
();
MS_DEBUG_DEV
(
"before iterations [availableBitrate:%"
PRIu32
"]"
,
availableBitrate
);
MS_DEBUG_DEV
(
"before
layer-by-layer
iterations [availableBitrate:%"
PRIu32
"]"
,
availableBitrate
);
// Redistribute the available bitrate by allowing Consumers to increase
// Redistribute the available bitrate by allowing Consumers to increase
// layer by layer.
// layer by layer.
...
@@ -1988,14 +1988,8 @@ namespace RTC
...
@@ -1988,14 +1988,8 @@ namespace RTC
for
(
auto
it
=
multimapPriorityConsumer
.
rbegin
();
it
!=
multimapPriorityConsumer
.
rend
();
++
it
)
for
(
auto
it
=
multimapPriorityConsumer
.
rbegin
();
it
!=
multimapPriorityConsumer
.
rend
();
++
it
)
{
{
auto
*
consumer
=
it
->
second
;
auto
*
consumer
=
it
->
second
;
MS_DEBUG_DEV
(
"layer bitrate for Consumer [bitrate:%"
PRIu32
", consumerId:%s]"
,
availableBitrate
,
consumer
->
id
.
c_str
());
uint32_t
usedBitrate
;
auto
bweType
=
this
->
tccClient
->
GetBweType
();
auto
bweType
=
this
->
tccClient
->
GetBweType
();
uint32_t
usedBitrate
;
switch
(
bweType
)
switch
(
bweType
)
{
{
...
@@ -2016,7 +2010,7 @@ namespace RTC
...
@@ -2016,7 +2010,7 @@ namespace RTC
break
;
break
;
}
}
MS_DEBUG_DEV
(
"after layer-by-layer iteration [availableBitrate:%"
PRIu32
"]"
,
availableBitrate
);
MS_DEBUG_DEV
(
"after layer-by-layer iteration
s
[availableBitrate:%"
PRIu32
"]"
,
availableBitrate
);
// Finally instruct Consumers to apply their computed layers.
// Finally instruct Consumers to apply their computed layers.
for
(
auto
it
=
multimapPriorityConsumer
.
rbegin
();
it
!=
multimapPriorityConsumer
.
rend
();
++
it
)
for
(
auto
it
=
multimapPriorityConsumer
.
rbegin
();
it
!=
multimapPriorityConsumer
.
rend
();
++
it
)
...
...
worker/src/RTC/TransportCongestionControlClient.cpp
浏览文件 @
46bd7687
...
@@ -12,8 +12,8 @@ namespace RTC
...
@@ -12,8 +12,8 @@ namespace RTC
/* Static. */
/* Static. */
static
constexpr
uint32_t
MinBitrate
{
30000u
};
static
constexpr
uint32_t
MinBitrate
{
30000u
};
static
constexpr
float
MaxBitrateIncrementFactor
{
1.
25
f
};
// TODO: Let's see.
static
constexpr
float
MaxBitrateIncrementFactor
{
1.
35
f
};
static
constexpr
float
MaxPaddingBitrateFactor
{
0.
75
f
};
// TODO: Let's see.
static
constexpr
float
MaxPaddingBitrateFactor
{
0.
85
f
};
static
constexpr
uint64_t
AvailableBitrateEventInterval
{
2000u
};
// In ms.
static
constexpr
uint64_t
AvailableBitrateEventInterval
{
2000u
};
// In ms.
/* Instance methods. */
/* Instance methods. */
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论