OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 if (rtp_video_header.simulcastIdx >= num_sending_modules_) | 160 if (rtp_video_header.simulcastIdx >= num_sending_modules_) |
161 return -1; | 161 return -1; |
162 stream_idx = rtp_video_header.simulcastIdx; | 162 stream_idx = rtp_video_header.simulcastIdx; |
163 | 163 |
164 return rtp_modules_[stream_idx]->SendOutgoingData( | 164 return rtp_modules_[stream_idx]->SendOutgoingData( |
165 encoded_image._frameType, payload_type_, encoded_image._timeStamp, | 165 encoded_image._frameType, payload_type_, encoded_image._timeStamp, |
166 encoded_image.capture_time_ms_, encoded_image._buffer, | 166 encoded_image.capture_time_ms_, encoded_image._buffer, |
167 encoded_image._length, fragmentation, &rtp_video_header); | 167 encoded_image._length, fragmentation, &rtp_video_header); |
168 } | 168 } |
169 | 169 |
170 void PayloadRouter::SetTargetSendBitrate(uint32_t bitrate_bps) { | |
171 rtc::CritScope lock(&crit_); | |
172 RTC_DCHECK_LE(streams_.size(), rtp_modules_.size()); | |
173 | |
174 // TODO(sprang): Rebase https://codereview.webrtc.org/1913073002/ on top of | |
175 // this. | |
176 int bitrate_remainder = bitrate_bps; | |
177 for (size_t i = 0; i < streams_.size() && bitrate_remainder > 0; ++i) { | |
178 int stream_bitrate = 0; | |
179 if (streams_[i].max_bitrate_bps > bitrate_remainder) { | |
180 stream_bitrate = bitrate_remainder; | |
181 } else { | |
182 stream_bitrate = streams_[i].max_bitrate_bps; | |
183 } | |
184 bitrate_remainder -= stream_bitrate; | |
185 rtp_modules_[i]->SetTargetSendBitrate(stream_bitrate); | |
186 } | |
187 } | |
188 | |
189 size_t PayloadRouter::MaxPayloadLength() const { | 170 size_t PayloadRouter::MaxPayloadLength() const { |
190 size_t min_payload_length = DefaultMaxPayloadLength(); | 171 size_t min_payload_length = DefaultMaxPayloadLength(); |
191 rtc::CritScope lock(&crit_); | 172 rtc::CritScope lock(&crit_); |
192 for (size_t i = 0; i < num_sending_modules_; ++i) { | 173 for (size_t i = 0; i < num_sending_modules_; ++i) { |
193 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); | 174 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); |
194 if (module_payload_length < min_payload_length) | 175 if (module_payload_length < min_payload_length) |
195 min_payload_length = module_payload_length; | 176 min_payload_length = module_payload_length; |
196 } | 177 } |
197 return min_payload_length; | 178 return min_payload_length; |
198 } | 179 } |
199 | 180 |
200 } // namespace webrtc | 181 } // namespace webrtc |
OLD | NEW |