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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 } | 187 } |
188 return 0; | 188 return 0; |
189 } | 189 } |
190 | 190 |
191 int32_t ViEEncoder::DeRegisterExternalEncoder(uint8_t pl_type) { | 191 int32_t ViEEncoder::DeRegisterExternalEncoder(uint8_t pl_type) { |
192 if (vcm_->RegisterExternalEncoder(NULL, pl_type) != VCM_OK) { | 192 if (vcm_->RegisterExternalEncoder(NULL, pl_type) != VCM_OK) { |
193 return -1; | 193 return -1; |
194 } | 194 } |
195 return 0; | 195 return 0; |
196 } | 196 } |
197 | 197 void ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) { |
198 int32_t ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) { | |
199 RTC_DCHECK(send_payload_router_ != NULL); | 198 RTC_DCHECK(send_payload_router_ != NULL); |
200 // Setting target width and height for VPM. | 199 // Setting target width and height for VPM. |
201 if (vp_->SetTargetResolution(video_codec.width, video_codec.height, | 200 RTC_CHECK_EQ(VPM_OK, |
202 video_codec.maxFramerate) != VPM_OK) { | 201 vp_->SetTargetResolution(video_codec.width, video_codec.height, |
203 return -1; | 202 video_codec.maxFramerate)); |
204 } | |
205 | 203 |
206 // Cache codec before calling AddBitrateObserver (which calls OnNetworkChanged | 204 // Cache codec before calling AddBitrateObserver (which calls OnNetworkChanged |
207 // that makes use of the number of simulcast streams configured). | 205 // that makes use of the number of simulcast streams configured). |
208 { | 206 { |
209 rtc::CritScope lock(&data_cs_); | 207 rtc::CritScope lock(&data_cs_); |
210 encoder_config_ = video_codec; | 208 encoder_config_ = video_codec; |
209 encoder_paused_ = true; | |
211 } | 210 } |
212 | 211 |
213 // Add a bitrate observer to the allocator and update the start, max and | 212 // Add a bitrate observer to the allocator and update the start, max and |
214 // min bitrates of the bitrate controller as needed. | 213 // min bitrates of the bitrate controller as needed. |
215 int allocated_bitrate_bps = bitrate_allocator_->AddBitrateObserver( | 214 int allocated_bitrate_bps = bitrate_allocator_->AddBitrateObserver( |
216 bitrate_observer_.get(), video_codec.minBitrate * 1000, | 215 bitrate_observer_.get(), video_codec.minBitrate * 1000, |
217 video_codec.maxBitrate * 1000); | 216 video_codec.maxBitrate * 1000); |
218 | 217 |
219 webrtc::VideoCodec modified_video_codec = video_codec; | 218 webrtc::VideoCodec modified_video_codec = video_codec; |
220 modified_video_codec.startBitrate = allocated_bitrate_bps / 1000; | 219 modified_video_codec.startBitrate = allocated_bitrate_bps / 1000; |
221 | 220 |
222 size_t max_data_payload_length = send_payload_router_->MaxPayloadLength(); | 221 size_t max_data_payload_length = send_payload_router_->MaxPayloadLength(); |
223 if (vcm_->RegisterSendCodec(&modified_video_codec, number_of_cores_, | 222 RTC_CHECK_EQ(VCM_OK, vcm_->RegisterSendCodec( |
pbos-webrtc
2016/03/02 15:37:17
If you prefer we could not CHECK here but rather f
pbos-webrtc
2016/03/02 15:42:19
(Note that this CHECK was effectively in place for
stefan-webrtc
2016/03/02 15:56:33
DCHECK as discussed.
| |
224 static_cast<uint32_t>(max_data_payload_length)) != | 223 &modified_video_codec, number_of_cores_, |
225 VCM_OK) { | 224 static_cast<uint32_t>(max_data_payload_length))); |
226 return -1; | 225 |
227 } | 226 send_payload_router_->SetSendingRtpModules( |
228 return 0; | 227 video_codec.numberOfSimulcastStreams); |
228 | |
229 // Restart the media flow | |
230 Restart(); | |
229 } | 231 } |
230 | 232 |
231 int ViEEncoder::GetPaddingNeededBps() const { | 233 int ViEEncoder::GetPaddingNeededBps() const { |
232 int64_t time_of_last_frame_activity_ms; | 234 int64_t time_of_last_frame_activity_ms; |
233 int min_transmit_bitrate_bps; | 235 int min_transmit_bitrate_bps; |
234 int bitrate_bps; | 236 int bitrate_bps; |
235 VideoCodec send_codec; | 237 VideoCodec send_codec; |
236 { | 238 { |
237 rtc::CritScope lock(&data_cs_); | 239 rtc::CritScope lock(&data_cs_); |
238 bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 || | 240 bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 || |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 const uint32_t width, | 547 const uint32_t width, |
546 const uint32_t height) { | 548 const uint32_t height) { |
547 return vp_->SetTargetResolution(width, height, frame_rate); | 549 return vp_->SetTargetResolution(width, height, frame_rate); |
548 } | 550 } |
549 | 551 |
550 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { | 552 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { |
551 vp_->SetTargetFramerate(frame_rate); | 553 vp_->SetTargetFramerate(frame_rate); |
552 } | 554 } |
553 | 555 |
554 } // namespace webrtc | 556 } // namespace webrtc |
OLD | NEW |