Unverified 提交 80189816 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

TransportCongestionControlClient: allow setting maxOutgoingBitrate before created (#833)

- Fixes #831
- Remove no longer used `RtpBufferSize` in `RtpPacket.hpp`.
上级 f147f77e
...@@ -14,8 +14,6 @@ using json = nlohmann::json; ...@@ -14,8 +14,6 @@ using json = nlohmann::json;
namespace RTC namespace RTC
{ {
// Max RTP length.
constexpr size_t RtpBufferSize{ 65536u };
// Max MTU size. // Max MTU size.
constexpr size_t MtuSize{ 1500u }; constexpr size_t MtuSize{ 1500u };
// MID header extension max length (just used when setting/updating MID // MID header extension max length (just used when setting/updating MID
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
namespace RTC namespace RTC
{ {
constexpr uint32_t TransportCongestionControlMinOutgoingBitrate{ 30000u };
class TransportCongestionControlClient : public webrtc::PacketRouter, class TransportCongestionControlClient : public webrtc::PacketRouter,
public webrtc::TargetTransferRateObserver, public webrtc::TargetTransferRateObserver,
public Timer::Listener public Timer::Listener
......
...@@ -630,13 +630,18 @@ namespace RTC ...@@ -630,13 +630,18 @@ namespace RTC
MS_THROW_TYPE_ERROR("missing bitrate"); MS_THROW_TYPE_ERROR("missing bitrate");
} }
if (this->tccClient) uint32_t bitrate = jsonBitrateIt->get<uint32_t>();
if (bitrate < RTC::TransportCongestionControlMinOutgoingBitrate)
{ {
uint32_t bitrate = jsonBitrateIt->get<uint32_t>(); MS_THROW_TYPE_ERROR(
"bitrate must be >= %" PRIu32 " bps", RTC::TransportCongestionControlMinOutgoingBitrate);
}
// NOTE: This may throw if given bitrate is less than current if (this->tccClient)
// initialAvailableOutgoingBitrate, so don't update things before {
// calling this method. // NOTE: This may throw so don't update things before calling this
// method.
this->tccClient->SetMaxOutgoingBitrate(bitrate); this->tccClient->SetMaxOutgoingBitrate(bitrate);
this->maxOutgoingBitrate = bitrate; this->maxOutgoingBitrate = bitrate;
...@@ -644,6 +649,10 @@ namespace RTC ...@@ -644,6 +649,10 @@ namespace RTC
ComputeOutgoingDesiredBitrate(); ComputeOutgoingDesiredBitrate();
} }
else
{
this->maxOutgoingBitrate = bitrate;
}
request->Accept(); request->Accept();
......
...@@ -12,7 +12,8 @@ namespace RTC ...@@ -12,7 +12,8 @@ namespace RTC
{ {
/* Static. */ /* Static. */
static constexpr uint32_t MinBitrate{ 30000u }; // NOTE: TransportCongestionControlMinOutgoingBitrate is defined in
// TransportCongestionControlClient.hpp and exposed publicly.
static constexpr float MaxBitrateMarginFactor{ 0.1f }; static constexpr float MaxBitrateMarginFactor{ 0.1f };
static constexpr float MaxBitrateIncrementFactor{ 1.35f }; static constexpr float MaxBitrateIncrementFactor{ 1.35f };
static constexpr float MaxPaddingBitrateFactor{ 0.85f }; static constexpr float MaxPaddingBitrateFactor{ 0.85f };
...@@ -27,7 +28,8 @@ namespace RTC ...@@ -27,7 +28,8 @@ namespace RTC
uint32_t initialAvailableBitrate, uint32_t initialAvailableBitrate,
uint32_t maxOutgoingBitrate) uint32_t maxOutgoingBitrate)
: listener(listener), bweType(bweType), : listener(listener), bweType(bweType),
initialAvailableBitrate(std::max<uint32_t>(initialAvailableBitrate, MinBitrate)), initialAvailableBitrate(std::max<uint32_t>(
initialAvailableBitrate, RTC::TransportCongestionControlMinOutgoingBitrate)),
maxOutgoingBitrate(maxOutgoingBitrate) maxOutgoingBitrate(maxOutgoingBitrate)
{ {
MS_TRACE(); MS_TRACE();
...@@ -262,9 +264,6 @@ namespace RTC ...@@ -262,9 +264,6 @@ namespace RTC
void TransportCongestionControlClient::SetMaxOutgoingBitrate(uint32_t maxBitrate) void TransportCongestionControlClient::SetMaxOutgoingBitrate(uint32_t maxBitrate)
{ {
if (maxBitrate < MinBitrate)
MS_THROW_ERROR("maxOutgoingBitrate must be >= 30000bps");
this->maxOutgoingBitrate = maxBitrate; this->maxOutgoingBitrate = maxBitrate;
ApplyBitrateUpdates(); ApplyBitrateUpdates();
...@@ -290,10 +289,11 @@ namespace RTC ...@@ -290,10 +289,11 @@ namespace RTC
this->bitrates.desiredBitrate = desiredBitrate; this->bitrates.desiredBitrate = desiredBitrate;
this->bitrates.effectiveDesiredBitrate = this->desiredBitrateTrend.GetValue(); this->bitrates.effectiveDesiredBitrate = this->desiredBitrateTrend.GetValue();
this->bitrates.minBitrate = MinBitrate; this->bitrates.minBitrate = RTC::TransportCongestionControlMinOutgoingBitrate;
// NOTE: Setting 'startBitrate' to 'availableBitrate' has proven to generate // NOTE: Setting 'startBitrate' to 'availableBitrate' has proven to generate
// more stable values. // more stable values.
this->bitrates.startBitrate = std::max<uint32_t>(MinBitrate, this->bitrates.availableBitrate); this->bitrates.startBitrate = std::max<uint32_t>(
RTC::TransportCongestionControlMinOutgoingBitrate, this->bitrates.availableBitrate);
ApplyBitrateUpdates(); ApplyBitrateUpdates();
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论