| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 pacer_->Resume(); | 275 pacer_->Resume(); |
| 276 } else { | 276 } else { |
| 277 pacer_->Pause(); | 277 pacer_->Pause(); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 // TODO(mflodman): Move this logic out from CongestionController. | 281 // TODO(mflodman): Move this logic out from CongestionController. |
| 282 void CongestionController::OnNetworkChanged(uint32_t target_bitrate_bps, | 282 void CongestionController::OnNetworkChanged(uint32_t target_bitrate_bps, |
| 283 uint8_t fraction_loss, | 283 uint8_t fraction_loss, |
| 284 int64_t rtt) { | 284 int64_t rtt) { |
| 285 bitrate_allocator_->OnNetworkChanged(target_bitrate_bps, fraction_loss, rtt); | 285 uint32_t allocated_bitrate_bps = bitrate_allocator_->OnNetworkChanged( |
| 286 target_bitrate_bps, fraction_loss, rtt); |
| 286 int pad_up_to_bitrate_bps = 0; | 287 int pad_up_to_bitrate_bps = 0; |
| 287 { | 288 { |
| 288 rtc::CritScope lock(&encoder_crit_); | 289 rtc::CritScope lock(&encoder_crit_); |
| 289 for (const auto& encoder : encoders_) | 290 for (const auto& encoder : encoders_) |
| 290 pad_up_to_bitrate_bps += encoder->GetPaddingNeededBps(); | 291 pad_up_to_bitrate_bps += encoder->GetPaddingNeededBps(); |
| 291 } | 292 } |
| 293 // Allocated bitrate might be higher than bitrate estimate if enforcing min |
| 294 // bitrate, or lower if estimate is higher than the sum of max bitrates, so |
| 295 // set the pacer bitrate to the maximum of the two. |
| 296 uint32_t pacer_bitrate_bps = |
| 297 std::max(target_bitrate_bps, allocated_bitrate_bps); |
| 292 pacer_->UpdateBitrate( | 298 pacer_->UpdateBitrate( |
| 293 target_bitrate_bps / 1000, | 299 pacer_bitrate_bps / 1000, |
| 294 PacedSender::kDefaultPaceMultiplier * target_bitrate_bps / 1000, | 300 PacedSender::kDefaultPaceMultiplier * pacer_bitrate_bps / 1000, |
| 295 pad_up_to_bitrate_bps / 1000); | 301 pad_up_to_bitrate_bps / 1000); |
| 296 } | 302 } |
| 297 | 303 |
| 298 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { | 304 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { |
| 299 if (transport_feedback_adapter_) { | 305 if (transport_feedback_adapter_) { |
| 300 transport_feedback_adapter_->OnSentPacket(sent_packet.packet_id, | 306 transport_feedback_adapter_->OnSentPacket(sent_packet.packet_id, |
| 301 sent_packet.send_time_ms); | 307 sent_packet.send_time_ms); |
| 302 } | 308 } |
| 303 } | 309 } |
| 304 } // namespace webrtc | 310 } // namespace webrtc |
| OLD | NEW |