Index: webrtc/video/payload_router.cc |
diff --git a/webrtc/video/payload_router.cc b/webrtc/video/payload_router.cc |
index 798325a2602e09887f41cc37c64a5debe8fe6dbf..21439022c1dc3b69a91c981e63dcd42357def8ca 100644 |
--- a/webrtc/video/payload_router.cc |
+++ b/webrtc/video/payload_router.cc |
@@ -167,6 +167,25 @@ |
encoded_image._length, fragmentation, &rtp_video_header); |
} |
+void PayloadRouter::SetTargetSendBitrate(uint32_t bitrate_bps) { |
+ rtc::CritScope lock(&crit_); |
+ RTC_DCHECK_LE(streams_.size(), rtp_modules_.size()); |
+ |
+ // TODO(sprang): Rebase https://codereview.webrtc.org/1913073002/ on top of |
+ // this. |
+ int bitrate_remainder = bitrate_bps; |
+ for (size_t i = 0; i < streams_.size() && bitrate_remainder > 0; ++i) { |
+ int stream_bitrate = 0; |
+ if (streams_[i].max_bitrate_bps > bitrate_remainder) { |
+ stream_bitrate = bitrate_remainder; |
+ } else { |
+ stream_bitrate = streams_[i].max_bitrate_bps; |
+ } |
+ bitrate_remainder -= stream_bitrate; |
+ rtp_modules_[i]->SetTargetSendBitrate(stream_bitrate); |
+ } |
+} |
+ |
size_t PayloadRouter::MaxPayloadLength() const { |
size_t min_payload_length = DefaultMaxPayloadLength(); |
rtc::CritScope lock(&crit_); |