Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
4de0f4e7
提交
4de0f4e7
authored
6月 08, 2019
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve SimulcastConsumer and SvcConsumer:
- Better handling of GetBitratePriority()
上级
2fa00787
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
106 行增加
和
30 行删除
+106
-30
Consumer.hpp
worker/include/RTC/Consumer.hpp
+1
-1
RtpStream.hpp
worker/include/RTC/RtpStream.hpp
+1
-0
RtpStreamRecv.hpp
worker/include/RTC/RtpStreamRecv.hpp
+7
-0
RtpStreamSend.hpp
worker/include/RTC/RtpStreamSend.hpp
+1
-0
SimulcastConsumer.hpp
worker/include/RTC/SimulcastConsumer.hpp
+1
-1
SvcConsumer.hpp
worker/include/RTC/SvcConsumer.hpp
+1
-1
Consumer.cpp
worker/src/RTC/Consumer.cpp
+2
-2
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+41
-3
RtpStreamSend.cpp
worker/src/RTC/RtpStreamSend.cpp
+11
-0
SimulcastConsumer.cpp
worker/src/RTC/SimulcastConsumer.cpp
+17
-10
SvcConsumer.cpp
worker/src/RTC/SvcConsumer.cpp
+20
-9
WebRtcTransport.cpp
worker/src/RTC/WebRtcTransport.cpp
+3
-3
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
4de0f4e7
...
@@ -65,7 +65,7 @@ namespace RTC
...
@@ -65,7 +65,7 @@ namespace RTC
virtual
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
=
0
;
virtual
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
=
0
;
void
ProducerClosed
();
void
ProducerClosed
();
virtual
void
SetExternallyManagedBitrate
();
virtual
void
SetExternallyManagedBitrate
();
virtual
int16_t
GetBitratePriority
()
const
;
virtual
u
int16_t
GetBitratePriority
()
const
;
virtual
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
);
virtual
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
);
virtual
uint32_t
IncreaseLayer
(
uint32_t
bitrate
);
virtual
uint32_t
IncreaseLayer
(
uint32_t
bitrate
);
virtual
void
ApplyLayers
();
virtual
void
ApplyLayers
();
...
...
worker/include/RTC/RtpStream.hpp
浏览文件 @
4de0f4e7
...
@@ -74,6 +74,7 @@ namespace RTC
...
@@ -74,6 +74,7 @@ namespace RTC
virtual
void
Resume
()
=
0
;
virtual
void
Resume
()
=
0
;
virtual
uint32_t
GetBitrate
(
uint64_t
now
)
=
0
;
virtual
uint32_t
GetBitrate
(
uint64_t
now
)
=
0
;
virtual
uint32_t
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
=
0
;
virtual
uint32_t
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
=
0
;
virtual
uint32_t
GetSpatialLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
)
=
0
;
virtual
uint32_t
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
=
0
;
virtual
uint32_t
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
=
0
;
void
ResetScore
(
uint8_t
score
,
bool
notify
);
void
ResetScore
(
uint8_t
score
,
bool
notify
);
uint8_t
GetFractionLost
()
const
;
uint8_t
GetFractionLost
()
const
;
...
...
worker/include/RTC/RtpStreamRecv.hpp
浏览文件 @
4de0f4e7
...
@@ -31,6 +31,7 @@ namespace RTC
...
@@ -31,6 +31,7 @@ namespace RTC
void
Update
(
RTC
::
RtpPacket
*
packet
);
void
Update
(
RTC
::
RtpPacket
*
packet
);
uint32_t
GetBitrate
(
uint64_t
now
);
uint32_t
GetBitrate
(
uint64_t
now
);
uint32_t
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
);
uint32_t
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
);
uint32_t
GetSpatialLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
);
uint32_t
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
);
uint32_t
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
);
size_t
GetPacketCount
()
const
;
size_t
GetPacketCount
()
const
;
size_t
GetBytes
()
const
;
size_t
GetBytes
()
const
;
...
@@ -53,6 +54,7 @@ namespace RTC
...
@@ -53,6 +54,7 @@ namespace RTC
void
Resume
()
override
;
void
Resume
()
override
;
uint32_t
GetBitrate
(
uint64_t
now
)
override
;
uint32_t
GetBitrate
(
uint64_t
now
)
override
;
uint32_t
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
override
;
uint32_t
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
override
;
uint32_t
GetSpatialLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
)
override
;
uint32_t
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
override
;
uint32_t
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
override
;
private
:
private
:
...
@@ -98,6 +100,11 @@ namespace RTC
...
@@ -98,6 +100,11 @@ namespace RTC
return
this
->
transmissionCounter
.
GetBitrate
(
now
,
spatialLayer
,
temporalLayer
);
return
this
->
transmissionCounter
.
GetBitrate
(
now
,
spatialLayer
,
temporalLayer
);
}
}
inline
uint32_t
RtpStreamRecv
::
GetSpatialLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
)
{
return
this
->
transmissionCounter
.
GetSpatialLayerBitrate
(
now
,
spatialLayer
);
}
inline
uint32_t
RtpStreamRecv
::
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
inline
uint32_t
RtpStreamRecv
::
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
{
{
return
this
->
transmissionCounter
.
GetLayerBitrate
(
now
,
spatialLayer
,
temporalLayer
);
return
this
->
transmissionCounter
.
GetLayerBitrate
(
now
,
spatialLayer
,
temporalLayer
);
...
...
worker/include/RTC/RtpStreamSend.hpp
浏览文件 @
4de0f4e7
...
@@ -51,6 +51,7 @@ namespace RTC
...
@@ -51,6 +51,7 @@ namespace RTC
void
SendProbationRtpPacket
(
uint16_t
seq
);
void
SendProbationRtpPacket
(
uint16_t
seq
);
uint32_t
GetBitrate
(
uint64_t
now
)
override
;
uint32_t
GetBitrate
(
uint64_t
now
)
override
;
uint32_t
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
override
;
uint32_t
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
override
;
uint32_t
GetSpatialLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
)
override
;
uint32_t
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
override
;
uint32_t
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
override
;
private
:
private
:
...
...
worker/include/RTC/SimulcastConsumer.hpp
浏览文件 @
4de0f4e7
...
@@ -26,7 +26,7 @@ namespace RTC
...
@@ -26,7 +26,7 @@ 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
;
void
SetExternallyManagedBitrate
()
override
;
void
SetExternallyManagedBitrate
()
override
;
int16_t
GetBitratePriority
()
const
override
;
u
int16_t
GetBitratePriority
()
const
override
;
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
)
override
;
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
)
override
;
void
ApplyLayers
()
override
;
void
ApplyLayers
()
override
;
...
...
worker/include/RTC/SvcConsumer.hpp
浏览文件 @
4de0f4e7
...
@@ -26,7 +26,7 @@ namespace RTC
...
@@ -26,7 +26,7 @@ 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
;
void
SetExternallyManagedBitrate
()
override
;
void
SetExternallyManagedBitrate
()
override
;
int16_t
GetBitratePriority
()
const
override
;
u
int16_t
GetBitratePriority
()
const
override
;
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
)
override
;
uint32_t
UseAvailableBitrate
(
uint32_t
bitrate
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
)
override
;
uint32_t
IncreaseLayer
(
uint32_t
bitrate
)
override
;
void
ApplyLayers
()
override
;
void
ApplyLayers
()
override
;
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
4de0f4e7
...
@@ -337,13 +337,13 @@ namespace RTC
...
@@ -337,13 +337,13 @@ namespace RTC
// Do nothing.
// Do nothing.
}
}
int16_t
Consumer
::
GetBitratePriority
()
const
u
int16_t
Consumer
::
GetBitratePriority
()
const
{
{
MS_TRACE
();
MS_TRACE
();
// This method must be override by subclasses with layers. By default
// This method must be override by subclasses with layers. By default
// it just returns 0.
// it just returns 0.
return
0
;
return
0
u
;
}
}
uint32_t
Consumer
::
UseAvailableBitrate
(
uint32_t
/*bitrate*/
)
uint32_t
Consumer
::
UseAvailableBitrate
(
uint32_t
/*bitrate*/
)
...
...
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
4de0f4e7
...
@@ -13,6 +13,8 @@ namespace RTC
...
@@ -13,6 +13,8 @@ namespace RTC
RtpStreamRecv
::
TransmissionCounter
::
TransmissionCounter
(
uint8_t
spatialLayers
,
uint8_t
temporalLayers
)
RtpStreamRecv
::
TransmissionCounter
::
TransmissionCounter
(
uint8_t
spatialLayers
,
uint8_t
temporalLayers
)
{
{
MS_TRACE
();
// Reserve vectors capacity.
// Reserve vectors capacity.
this
->
spatialLayerCounters
=
std
::
vector
<
std
::
vector
<
RTC
::
RtpDataCounter
>>
(
spatialLayers
);
this
->
spatialLayerCounters
=
std
::
vector
<
std
::
vector
<
RTC
::
RtpDataCounter
>>
(
spatialLayers
);
;
;
...
@@ -25,6 +27,8 @@ namespace RTC
...
@@ -25,6 +27,8 @@ namespace RTC
void
RtpStreamRecv
::
TransmissionCounter
::
Update
(
RTC
::
RtpPacket
*
packet
)
void
RtpStreamRecv
::
TransmissionCounter
::
Update
(
RTC
::
RtpPacket
*
packet
)
{
{
MS_TRACE
();
auto
spatialLayer
=
packet
->
GetSpatialLayer
();
auto
spatialLayer
=
packet
->
GetSpatialLayer
();
auto
temporalLayer
=
packet
->
GetTemporalLayer
();
auto
temporalLayer
=
packet
->
GetTemporalLayer
();
...
@@ -36,13 +40,15 @@ namespace RTC
...
@@ -36,13 +40,15 @@ namespace RTC
if
(
temporalLayer
>
this
->
spatialLayerCounters
[
0
].
size
()
-
1
)
if
(
temporalLayer
>
this
->
spatialLayerCounters
[
0
].
size
()
-
1
)
temporalLayer
=
this
->
spatialLayerCounters
[
0
].
size
()
-
1
;
temporalLayer
=
this
->
spatialLayerCounters
[
0
].
size
()
-
1
;
auto
&
counter
=
this
->
spatialLayerCounters
.
at
(
spatialLayer
).
at
(
temporalLayer
)
;
auto
&
counter
=
this
->
spatialLayerCounters
[
spatialLayer
][
temporalLayer
]
;
counter
.
Update
(
packet
);
counter
.
Update
(
packet
);
}
}
uint32_t
RtpStreamRecv
::
TransmissionCounter
::
GetBitrate
(
uint64_t
now
)
uint32_t
RtpStreamRecv
::
TransmissionCounter
::
GetBitrate
(
uint64_t
now
)
{
{
MS_TRACE
();
uint32_t
rate
{
0u
};
uint32_t
rate
{
0u
};
for
(
auto
&
spatialLayerCounter
:
this
->
spatialLayerCounters
)
for
(
auto
&
spatialLayerCounter
:
this
->
spatialLayerCounters
)
...
@@ -59,9 +65,11 @@ namespace RTC
...
@@ -59,9 +65,11 @@ namespace RTC
uint32_t
RtpStreamRecv
::
TransmissionCounter
::
GetBitrate
(
uint32_t
RtpStreamRecv
::
TransmissionCounter
::
GetBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
{
{
MS_TRACE
();
MS_ASSERT
(
spatialLayer
<
this
->
spatialLayerCounters
.
size
(),
"spatialLayer too high"
);
MS_ASSERT
(
spatialLayer
<
this
->
spatialLayerCounters
.
size
(),
"spatialLayer too high"
);
MS_ASSERT
(
MS_ASSERT
(
temporalLayer
<
this
->
spatialLayerCounters
.
at
(
spatialLayer
)
.
size
(),
"temporalLayer too high"
);
temporalLayer
<
this
->
spatialLayerCounters
[
spatialLayer
]
.
size
(),
"temporalLayer too high"
);
uint32_t
rate
{
0u
};
uint32_t
rate
{
0u
};
...
@@ -86,12 +94,38 @@ namespace RTC
...
@@ -86,12 +94,38 @@ namespace RTC
return
rate
;
return
rate
;
}
}
uint32_t
RtpStreamRecv
::
TransmissionCounter
::
GetSpatialLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
)
{
MS_TRACE
();
MS_ASSERT
(
spatialLayer
<
this
->
spatialLayerCounters
.
size
(),
"spatialLayer too high"
);
uint32_t
rate
{
0u
};
// clang-format off
for
(
uint8_t
tIdx
{
0u
};
tIdx
<
this
->
spatialLayerCounters
[
spatialLayer
].
size
();
++
tIdx
)
// clang-format on
{
auto
&
temporalLayerCounter
=
this
->
spatialLayerCounters
[
spatialLayer
][
tIdx
];
rate
+=
temporalLayerCounter
.
GetBitrate
(
now
);
}
return
rate
;
}
uint32_t
RtpStreamRecv
::
TransmissionCounter
::
GetLayerBitrate
(
uint32_t
RtpStreamRecv
::
TransmissionCounter
::
GetLayerBitrate
(
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
uint64_t
now
,
uint8_t
spatialLayer
,
uint8_t
temporalLayer
)
{
{
MS_TRACE
();
MS_ASSERT
(
spatialLayer
<
this
->
spatialLayerCounters
.
size
(),
"spatialLayer too high"
);
MS_ASSERT
(
spatialLayer
<
this
->
spatialLayerCounters
.
size
(),
"spatialLayer too high"
);
MS_ASSERT
(
MS_ASSERT
(
temporalLayer
<
this
->
spatialLayerCounters
.
at
(
spatialLayer
)
.
size
(),
"temporalLayer too high"
);
temporalLayer
<
this
->
spatialLayerCounters
[
spatialLayer
]
.
size
(),
"temporalLayer too high"
);
auto
&
counter
=
this
->
spatialLayerCounters
[
spatialLayer
][
temporalLayer
];
auto
&
counter
=
this
->
spatialLayerCounters
[
spatialLayer
][
temporalLayer
];
...
@@ -100,6 +134,8 @@ namespace RTC
...
@@ -100,6 +134,8 @@ namespace RTC
size_t
RtpStreamRecv
::
TransmissionCounter
::
GetPacketCount
()
const
size_t
RtpStreamRecv
::
TransmissionCounter
::
GetPacketCount
()
const
{
{
MS_TRACE
();
size_t
packetCount
{
0u
};
size_t
packetCount
{
0u
};
for
(
auto
&
spatialLayerCounter
:
this
->
spatialLayerCounters
)
for
(
auto
&
spatialLayerCounter
:
this
->
spatialLayerCounters
)
...
@@ -115,6 +151,8 @@ namespace RTC
...
@@ -115,6 +151,8 @@ namespace RTC
size_t
RtpStreamRecv
::
TransmissionCounter
::
GetBytes
()
const
size_t
RtpStreamRecv
::
TransmissionCounter
::
GetBytes
()
const
{
{
MS_TRACE
();
size_t
bytes
{
0u
};
size_t
bytes
{
0u
};
for
(
auto
&
spatialLayerCounter
:
this
->
spatialLayerCounters
)
for
(
auto
&
spatialLayerCounter
:
this
->
spatialLayerCounters
)
...
...
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
4de0f4e7
...
@@ -259,12 +259,23 @@ namespace RTC
...
@@ -259,12 +259,23 @@ namespace RTC
uint32_t
RtpStreamSend
::
GetBitrate
(
uint64_t
/*now*/
,
uint8_t
/*spatialLayer*/
,
uint8_t
/*temporalLayer*/
)
uint32_t
RtpStreamSend
::
GetBitrate
(
uint64_t
/*now*/
,
uint8_t
/*spatialLayer*/
,
uint8_t
/*temporalLayer*/
)
{
{
MS_TRACE
();
MS_ABORT
(
"invalid method call"
);
}
uint32_t
RtpStreamSend
::
GetSpatialLayerBitrate
(
uint64_t
/*now*/
,
uint8_t
/*spatialLayer*/
)
{
MS_TRACE
();
MS_ABORT
(
"invalid method call"
);
MS_ABORT
(
"invalid method call"
);
}
}
uint32_t
RtpStreamSend
::
GetLayerBitrate
(
uint32_t
RtpStreamSend
::
GetLayerBitrate
(
uint64_t
/*now*/
,
uint8_t
/*spatialLayer*/
,
uint8_t
/*temporalLayer*/
)
uint64_t
/*now*/
,
uint8_t
/*spatialLayer*/
,
uint8_t
/*temporalLayer*/
)
{
{
MS_TRACE
();
MS_ABORT
(
"invalid method call"
);
MS_ABORT
(
"invalid method call"
);
}
}
...
...
worker/src/RTC/SimulcastConsumer.cpp
浏览文件 @
4de0f4e7
...
@@ -333,18 +333,24 @@ namespace RTC
...
@@ -333,18 +333,24 @@ namespace RTC
this
->
externallyManagedBitrate
=
true
;
this
->
externallyManagedBitrate
=
true
;
}
}
int16_t
SimulcastConsumer
::
GetBitratePriority
()
const
u
int16_t
SimulcastConsumer
::
GetBitratePriority
()
const
{
{
MS_TRACE
();
MS_TRACE
();
if
(
!
RTC
::
Consumer
::
IsActive
())
if
(
!
RTC
::
Consumer
::
IsActive
())
return
0
;
return
0
u
;
int16_t
prioritySpatialLayer
{
0
};
int16_t
prioritySpatialLayer
{
-
1
};
for
(
size_t
sIdx
{
0
};
sIdx
<
this
->
producerRtpStreams
.
size
();
++
sIdx
)
for
(
size_t
sIdx
{
0
};
sIdx
<
this
->
producerRtpStreams
.
size
();
++
sIdx
)
{
{
auto
spatialLayer
=
static_cast
<
int16_t
>
(
sIdx
);
auto
spatialLayer
=
static_cast
<
int16_t
>
(
sIdx
);
// Do not choose a layer greater than the preferred one if we already found
// an available layer equal or less than the preferred one.
if
(
spatialLayer
>
this
->
preferredSpatialLayer
&&
prioritySpatialLayer
!=
-
1
)
break
;
auto
*
producerRtpStream
=
this
->
producerRtpStreams
.
at
(
sIdx
);
auto
*
producerRtpStream
=
this
->
producerRtpStreams
.
at
(
sIdx
);
// Ignore spatial layers for non existing Producer streams or for those
// Ignore spatial layers for non existing Producer streams or for those
...
@@ -352,17 +358,18 @@ namespace RTC
...
@@ -352,17 +358,18 @@ namespace RTC
if
(
!
producerRtpStream
||
producerRtpStream
->
GetScore
()
==
0
)
if
(
!
producerRtpStream
||
producerRtpStream
->
GetScore
()
==
0
)
continue
;
continue
;
// Do not choose a layer greater than the preferred one if we already found
// an available layer equal or less than the preferred one.
if
(
spatialLayer
>
this
->
preferredSpatialLayer
&&
prioritySpatialLayer
>=
-
1
)
break
;
// Choose this layer for now.
// Choose this layer for now.
prioritySpatialLayer
=
spatialLayer
;
prioritySpatialLayer
=
spatialLayer
;
}
}
// If no spatial layer was chosen (because all producer streams were inactive),
// we have to return >0 anyway. Otherwise UseAvailableBitrate() won't be called
// and we could never switch to target & current spatial -1.
if
(
prioritySpatialLayer
==
-
1
)
return
1u
;
// Return the choosen spatial layer plus one.
// Return the choosen spatial layer plus one.
return
prioritySpatialLayer
+
1
;
return
static_cast
<
uint16_t
>
(
prioritySpatialLayer
+
1
)
;
}
}
uint32_t
SimulcastConsumer
::
UseAvailableBitrate
(
uint32_t
bitrate
)
uint32_t
SimulcastConsumer
::
UseAvailableBitrate
(
uint32_t
bitrate
)
...
...
worker/src/RTC/SvcConsumer.cpp
浏览文件 @
4de0f4e7
...
@@ -307,33 +307,44 @@ namespace RTC
...
@@ -307,33 +307,44 @@ namespace RTC
this
->
externallyManagedBitrate
=
true
;
this
->
externallyManagedBitrate
=
true
;
}
}
int16_t
SvcConsumer
::
GetBitratePriority
()
const
u
int16_t
SvcConsumer
::
GetBitratePriority
()
const
{
{
MS_TRACE
();
MS_TRACE
();
if
(
!
RTC
::
Consumer
::
IsActive
())
if
(
!
RTC
::
Consumer
::
IsActive
())
return
0
;
return
0
u
;
// Return a 0 priority if score of
P
roducer stream is 0.
// Return a 0 priority if score of
p
roducer stream is 0.
if
(
!
this
->
producerRtpStream
||
this
->
producerRtpStream
->
GetScore
()
==
0
)
if
(
!
this
->
producerRtpStream
||
this
->
producerRtpStream
->
GetScore
()
==
0
)
return
0
;
return
0
u
;
auto
now
=
DepLibUV
::
GetTime
();
int16_t
prioritySpatialLayer
{
-
1
};
int16_t
spatialLayer
{
0
};
int16_t
spatialLayer
{
0
};
int16_t
prioritySpatialLayer
{
0
};
for
(;
spatialLayer
<
this
->
producerRtpStream
->
GetSpatialLayers
();
++
spatialLayer
)
for
(;
spatialLayer
<
this
->
producerRtpStream
->
GetSpatialLayers
();
++
spatialLayer
)
{
{
// Do not choose a layer greater than the preferred one if we already found
// Do not choose a layer greater than the preferred one if we already found
// an available layer equal or less than the preferred one.
// an available layer equal or less than the preferred one.
if
(
spatialLayer
>
this
->
preferredSpatialLayer
&&
prioritySpatialLayer
>
=
-
1
)
if
(
spatialLayer
>
this
->
preferredSpatialLayer
&&
prioritySpatialLayer
!
=
-
1
)
break
;
break
;
// Ignore spatial layers with 0 bitrate.
if
(
this
->
producerRtpStream
->
GetSpatialLayerBitrate
(
now
,
spatialLayer
)
==
0
)
continue
;
// Choose this layer for now.
// Choose this layer for now.
prioritySpatialLayer
=
spatialLayer
;
prioritySpatialLayer
=
spatialLayer
;
}
}
// If no spatial layer was chosen (because the producer stream was inactive),
// we have to return >0 anyway. Otherwise UseAvailableBitrate() won't be called
// and we could never switch to target & current spatial -1.
if
(
prioritySpatialLayer
==
-
1
)
return
1u
;
// Return the choosen spatial layer plus one.
// Return the choosen spatial layer plus one.
return
prioritySpatialLayer
+
1
;
return
static_cast
<
uint16_t
>
(
prioritySpatialLayer
+
1
)
;
}
}
uint32_t
SvcConsumer
::
UseAvailableBitrate
(
uint32_t
bitrate
)
uint32_t
SvcConsumer
::
UseAvailableBitrate
(
uint32_t
bitrate
)
...
@@ -521,7 +532,7 @@ namespace RTC
...
@@ -521,7 +532,7 @@ namespace RTC
continue
;
continue
;
}
}
requiredBitrate
=
producerRtpStream
->
GetLayerBitrate
(
now
,
spatialLayer
,
temporalLayer
);
requiredBitrate
=
this
->
producerRtpStream
->
GetLayerBitrate
(
now
,
spatialLayer
,
temporalLayer
);
// 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
)
...
@@ -978,7 +989,7 @@ namespace RTC
...
@@ -978,7 +989,7 @@ namespace RTC
for
(;
spatialLayer
<
this
->
producerRtpStream
->
GetSpatialLayers
();
++
spatialLayer
)
for
(;
spatialLayer
<
this
->
producerRtpStream
->
GetSpatialLayers
();
++
spatialLayer
)
{
{
if
(
!
producerRtpStream
->
GetBitrate
(
now
,
spatialLayer
,
0
))
if
(
!
this
->
producerRtpStream
->
GetSpatialLayerBitrate
(
now
,
spatialLayer
))
continue
;
continue
;
newTargetSpatialLayer
=
spatialLayer
;
newTargetSpatialLayer
=
spatialLayer
;
...
...
worker/src/RTC/WebRtcTransport.cpp
浏览文件 @
4de0f4e7
...
@@ -869,8 +869,8 @@ namespace RTC
...
@@ -869,8 +869,8 @@ namespace RTC
// MS_ASSERT(this->rembClient || this->transportCcClient, "no REMB client nor Transport-CC client");
// MS_ASSERT(this->rembClient || this->transportCcClient, "no REMB client nor Transport-CC client");
MS_ASSERT
(
this
->
rembClient
,
"no REMB client"
);
MS_ASSERT
(
this
->
rembClient
,
"no REMB client"
);
std
::
multimap
<
int16_t
,
RTC
::
Consumer
*>
multimapPriorityConsumer
;
std
::
multimap
<
u
int16_t
,
RTC
::
Consumer
*>
multimapPriorityConsumer
;
int16_t
totalPriorities
{
0
};
u
int16_t
totalPriorities
{
0
};
// Fill the map with Consumers and their priority (if > 0).
// Fill the map with Consumers and their priority (if > 0).
for
(
auto
&
kv
:
this
->
mapConsumers
)
for
(
auto
&
kv
:
this
->
mapConsumers
)
...
@@ -913,7 +913,7 @@ namespace RTC
...
@@ -913,7 +913,7 @@ namespace RTC
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
bwe
,
bwe
,
"main bitrate for Consumer [priority:%"
PRI
i
16
", bitrate:%"
PRIu32
", consumerId:%s]"
,
"main bitrate for Consumer [priority:%"
PRI
u
16
", bitrate:%"
PRIu32
", consumerId:%s]"
,
priority
,
priority
,
bitrate
,
bitrate
,
consumer
->
id
.
c_str
());
consumer
->
id
.
c_str
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论