Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1720)

Unified Diff: webrtc/modules/pacing/packet_router.cc

Issue 2994513002: Add PacketRouter::SetMaxDesiredReceiveBitrate for application limited receive bandwidth (Closed)
Patch Set: Rename the function Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/pacing/packet_router.h ('k') | webrtc/modules/pacing/packet_router_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/pacing/packet_router.cc
diff --git a/webrtc/modules/pacing/packet_router.cc b/webrtc/modules/pacing/packet_router.cc
index 64e1aeacc1cde5277be14adf30b2bf1e8d855ad0..b5cd444495ffd63da75e8f911c8d40d9617e01b9 100644
--- a/webrtc/modules/pacing/packet_router.cc
+++ b/webrtc/modules/pacing/packet_router.cc
@@ -10,6 +10,9 @@
#include "webrtc/modules/pacing/packet_router.h"
+#include <algorithm>
+#include <limits>
+
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
@@ -18,10 +21,17 @@
#include "webrtc/rtc_base/timeutils.h"
namespace webrtc {
+namespace {
+
+constexpr int kRembSendIntervalMs = 200;
+
+} // namespace
PacketRouter::PacketRouter()
: last_remb_time_ms_(rtc::TimeMillis()),
last_send_bitrate_bps_(0),
+ bitrate_bps_(0),
+ max_bitrate_bps_(std::numeric_limits<decltype(max_bitrate_bps_)>::max()),
active_remb_module_(nullptr),
transport_seq_(0) {}
@@ -142,8 +152,6 @@ uint16_t PacketRouter::AllocateSequenceNumber() {
void PacketRouter::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
uint32_t bitrate_bps) {
- const int kRembSendIntervalMs = 200;
-
// % threshold for if we should send a new REMB asap.
const uint32_t kSendThresholdPercent = 97;
@@ -173,10 +181,26 @@ void PacketRouter::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
// a module to actually send it.
last_remb_time_ms_ = now_ms;
last_send_bitrate_bps_ = bitrate_bps;
+ // Cap the value to send in remb with configured value.
+ bitrate_bps = std::min(bitrate_bps, max_bitrate_bps_);
}
SendRemb(bitrate_bps, ssrcs);
}
+void PacketRouter::SetMaxDesiredReceiveBitrate(uint32_t bitrate_bps) {
+ {
+ rtc::CritScope lock(&remb_crit_);
+ max_bitrate_bps_ = bitrate_bps;
+ if (rtc::TimeMillis() - last_remb_time_ms_ < kRembSendIntervalMs &&
+ last_send_bitrate_bps_ > 0 &&
+ last_send_bitrate_bps_ <= max_bitrate_bps_) {
+ // Recent measured bitrate is already below the cap.
+ return;
+ }
+ }
+ SendRemb(bitrate_bps, /*ssrcs=*/{});
+}
+
bool PacketRouter::SendRemb(uint32_t bitrate_bps,
const std::vector<uint32_t>& ssrcs) {
rtc::CritScope lock(&modules_crit_);
« no previous file with comments | « webrtc/modules/pacing/packet_router.h ('k') | webrtc/modules/pacing/packet_router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698