Add support for transport wide sequence numbers

Also refactor packet router to use a map rather than iterate over all
rtp modules for each packet sent.

BUG=webrtc:4311

Review URL: https://codereview.webrtc.org/1247293002

Cr-Commit-Position: refs/heads/master@{#9670}
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
index d54da99..4a045d9 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
@@ -87,7 +87,6 @@
     : clock_(clock),
       observer_(observer),
       last_bitrate_update_ms_(clock_->TimeInMilliseconds()),
-      critsect_(CriticalSectionWrapper::CreateCriticalSection()),
       bandwidth_estimation_(),
       reserved_bitrate_bps_(0),
       last_bitrate_bps_(0),
@@ -107,7 +106,7 @@
 
 void BitrateControllerImpl::SetStartBitrate(int start_bitrate_bps) {
   {
-    CriticalSectionScoped cs(critsect_.get());
+    rtc::CritScope cs(&critsect_);
     bandwidth_estimation_.SetSendBitrate(start_bitrate_bps);
   }
   MaybeTriggerOnNetworkChanged();
@@ -116,7 +115,7 @@
 void BitrateControllerImpl::SetMinMaxBitrate(int min_bitrate_bps,
                                              int max_bitrate_bps) {
   {
-    CriticalSectionScoped cs(critsect_.get());
+    rtc::CritScope cs(&critsect_);
     bandwidth_estimation_.SetMinMaxBitrate(min_bitrate_bps, max_bitrate_bps);
   }
   MaybeTriggerOnNetworkChanged();
@@ -124,7 +123,7 @@
 
 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) {
   {
-    CriticalSectionScoped cs(critsect_.get());
+    rtc::CritScope cs(&critsect_);
     reserved_bitrate_bps_ = reserved_bitrate_bps;
   }
   MaybeTriggerOnNetworkChanged();
@@ -132,7 +131,7 @@
 
 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) {
   {
-    CriticalSectionScoped cs(critsect_.get());
+    rtc::CritScope cs(&critsect_);
     bandwidth_estimation_.UpdateReceiverEstimate(bitrate);
   }
   MaybeTriggerOnNetworkChanged();
@@ -140,7 +139,7 @@
 
 int64_t BitrateControllerImpl::TimeUntilNextProcess() {
   const int64_t kBitrateControllerUpdateIntervalMs = 25;
-  CriticalSectionScoped cs(critsect_.get());
+  rtc::CritScope cs(&critsect_);
   int64_t time_since_update_ms =
       clock_->TimeInMilliseconds() - last_bitrate_update_ms_;
   return std::max<int64_t>(
@@ -151,7 +150,7 @@
   if (TimeUntilNextProcess() > 0)
     return 0;
   {
-    CriticalSectionScoped cs(critsect_.get());
+    rtc::CritScope cs(&critsect_);
     bandwidth_estimation_.UpdateEstimate(clock_->TimeInMilliseconds());
   }
   MaybeTriggerOnNetworkChanged();
@@ -165,7 +164,7 @@
     int number_of_packets,
     int64_t now_ms) {
   {
-    CriticalSectionScoped cs(critsect_.get());
+    rtc::CritScope cs(&critsect_);
     bandwidth_estimation_.UpdateReceiverBlock(fraction_loss, rtt,
                                               number_of_packets, now_ms);
   }
@@ -183,7 +182,7 @@
 bool BitrateControllerImpl::GetNetworkParameters(uint32_t* bitrate,
                                                  uint8_t* fraction_loss,
                                                  int64_t* rtt) {
-  CriticalSectionScoped cs(critsect_.get());
+  rtc::CritScope cs(&critsect_);
   int current_bitrate;
   bandwidth_estimation_.CurrentEstimate(&current_bitrate, fraction_loss, rtt);
   *bitrate = current_bitrate;
@@ -205,7 +204,7 @@
 }
 
 bool BitrateControllerImpl::AvailableBandwidth(uint32_t* bandwidth) const {
-  CriticalSectionScoped cs(critsect_.get());
+  rtc::CritScope cs(&critsect_);
   int bitrate;
   uint8_t fraction_loss;
   int64_t rtt;
@@ -218,5 +217,4 @@
   }
   return false;
 }
-
 }  // namespace webrtc