提交 cc202920 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

WIP: BWE

上级 8fa089fa
......@@ -50,7 +50,6 @@ namespace RTC
RTC::RtpParameters::Type GetType() const;
const std::vector<uint32_t>& GetMediaSsrcs() const;
virtual bool IsActive() const;
virtual void SetBitrateExternallyManaged();
void TransportConnected();
void TransportDisconnected();
bool IsPaused() const;
......@@ -62,6 +61,8 @@ namespace RTC
virtual void ProducerRtpStreamScore(
RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) = 0;
void ProducerClosed();
virtual void SetBitrateExternallyManaged();
virtual int16_t GetBitratePriority() const;
virtual uint32_t UseBitrate(uint32_t bitrate);
virtual void SendRtpPacket(RTC::RtpPacket* packet) = 0;
virtual void GetRtcp(RTC::RTCP::CompoundPacket* packet, uint64_t now) = 0;
......@@ -139,11 +140,6 @@ namespace RTC
this->transportConnected && !this->paused && !this->producerPaused && !this->producerClosed);
}
inline void Consumer::SetBitrateExternallyManaged()
{
// Do nothing.
}
inline bool Consumer::IsPaused() const
{
return this->paused;
......
......@@ -20,11 +20,12 @@ namespace RTC
void FillJsonScore(json& jsonObject) const override;
void HandleRequest(Channel::Request* request) override;
bool IsActive() const override;
void SetBitrateExternallyManaged() override;
void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override;
void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override;
void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override;
virtual uint32_t UseBitrate(uint32_t bitrate) override;
void SetBitrateExternallyManaged() override;
int16_t GetBitratePriority() const override;
uint32_t UseBitrate(uint32_t bitrate) override;
void SendRtpPacket(RTC::RtpPacket* packet) override;
void GetRtcp(RTC::RTCP::CompoundPacket* packet, uint64_t now) override;
void NeedWorstRemoteFractionLost(uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) override;
......@@ -42,9 +43,9 @@ namespace RTC
void CreateRtpStream();
void RequestKeyFrame();
void RetransmitRtpPacket(RTC::RtpPacket* packet);
bool RecalculateTargetLayers(int16_t& newTargetSpatialLayer, int16_t& newTargetTemporalLayer) const;
void UpdateTargetLayers(int16_t newTargetSpatialLayer, int16_t newTargetTemporalLayer);
void UpdateCurrentLayers();
void RecalculateTargetLayers();
void RecalculateAndApplyTargetLayers();
void EmitScore() const;
void EmitLayersChange() const;
RTC::RtpStream* GetProducerCurrentRtpStream() const;
......@@ -90,11 +91,6 @@ namespace RTC
);
// clang-format on
}
inline void SimulcastConsumer::SetBitrateExternallyManaged()
{
this->bitrateExternallyManaged = false;
}
} // namespace RTC
#endif
......@@ -327,6 +327,22 @@ namespace RTC
this->listener->onConsumerProducerClosed(this);
}
void Consumer::SetBitrateExternallyManaged()
{
MS_TRACE();
// Do nothing.
}
int16_t Consumer::GetBitratePriority() const
{
MS_TRACE();
// This method must be override by subclasses with layers. By default
// it just returns 0.
return 0;
}
uint32_t Consumer::UseBitrate(uint32_t /*bitrate*/)
{
MS_TRACE();
......
......@@ -137,7 +137,6 @@ namespace RTC
if (!IsActive())
return;
// Map the payload type.
auto payloadType = packet->GetPayloadType();
// NOTE: This may happen if this Consumer supports just some codecs of those
......
......@@ -1155,6 +1155,14 @@ namespace RTC
// TODO: Make this value configurable.
this->rembClient = new RTC::RembClient(this, 300000);
// Tell all the consumers that we are gonna manage their bitrate.
for (auto& kv : this->mapConsumers)
{
auto* consumer = kv.second;
consumer->SetBitrateExternallyManaged();
}
}
}
......@@ -1172,7 +1180,21 @@ namespace RTC
{
MS_TRACE();
// TODO
// TODO: Should call to a separate function (since it will ba called in
// other cases) that distributes available bitrate based on consumers'
// priority, etc.
for (auto& kv : this->mapConsumers)
{
auto* consumer = kv.second;
auto priority = consumer->GetBitratePriority();
uint32_t bitrate{ 0 };
if (this->rembClient)
bitrate = this->rembClient->GetAvailableBitrate();
consumer->UseBitrate(bitrate);
}
}
inline void WebRtcTransport::OnPacketRecv(
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论