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

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

Issue 2994513002: Add PacketRouter::SetMaxDesiredReceiveBitrate for application limited receive bandwidth (Closed)
Patch Set: 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
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..e3b870343e8c304ea56bc483b628b482de69256f 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 {
+
eladalon 2017/08/03 12:40:52 nit: I'd have preferred with an empty line between
danilchap 2017/08/03 13:25:33 Acknowledged.
+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<uint32_t>::max()),
eladalon 2017/08/03 12:40:52 Suggestion: max_bitrate_bps_(std::numeric_limits
danilchap 2017/08/03 13:25:33 Done.
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::SetMaxEstimatedBandwidth(uint32_t bitrate_bps) {
+ {
+ rtc::CritScope lock(&remb_crit_);
+ max_bitrate_bps_ = bitrate_bps;
+ if (last_send_bitrate_bps_ > 0 &&
+ rtc::TimeMillis() - last_remb_time_ms_ < kRembSendIntervalMs &&
eladalon 2017/08/03 12:40:52 1. This is a bit confusing; it would be more natur
danilchap 2017/08/03 13:25:33 1. Recent measure bitrate below the cap seems like
eladalon 2017/08/04 08:32:48 1. |a| was |last_send_bitrate_bps_ > 0|, etc. But
danilchap 2017/08/04 10:51:23 to reduce complexity it might make sense to move a
+ 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_);

Powered by Google App Engine
This is Rietveld 408576698