Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: webrtc/video/vie_encoder.cc

Issue 1754283002: Make ReconfigureVideoEncoder void. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Kbps Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/vie_encoder.h ('k') | webrtc/video_send_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 bool success = vcm_->RegisterSendCodec(
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)) == VCM_OK;
226 return -1; 225 if (!success) {
226 LOG(LS_ERROR) << "Failed to configure encoder.";
227 RTC_DCHECK(success);
227 } 228 }
228 return 0; 229
230 send_payload_router_->SetSendingRtpModules(
231 video_codec.numberOfSimulcastStreams);
232
233 // Restart the media flow
234 Restart();
229 } 235 }
230 236
231 int ViEEncoder::GetPaddingNeededBps() const { 237 int ViEEncoder::GetPaddingNeededBps() const {
232 int64_t time_of_last_frame_activity_ms; 238 int64_t time_of_last_frame_activity_ms;
233 int min_transmit_bitrate_bps; 239 int min_transmit_bitrate_bps;
234 int bitrate_bps; 240 int bitrate_bps;
235 VideoCodec send_codec; 241 VideoCodec send_codec;
236 { 242 {
237 rtc::CritScope lock(&data_cs_); 243 rtc::CritScope lock(&data_cs_);
238 bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 || 244 bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 ||
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 const uint32_t width, 551 const uint32_t width,
546 const uint32_t height) { 552 const uint32_t height) {
547 return vp_->SetTargetResolution(width, height, frame_rate); 553 return vp_->SetTargetResolution(width, height, frame_rate);
548 } 554 }
549 555
550 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) { 556 void QMVideoSettingsCallback::SetTargetFramerate(int frame_rate) {
551 vp_->SetTargetFramerate(frame_rate); 557 vp_->SetTargetFramerate(frame_rate);
552 } 558 }
553 559
554 } // namespace webrtc 560 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder.h ('k') | webrtc/video_send_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698