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

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

Issue 2455063002: Change ViEEncoder to not reconfigure the encoder until the video resolution is known. (Closed)
Patch Set: Fix test UseExternalFactoryForVp8WhenSupported. Created 4 years, 1 month 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/vie_encoder_unittest.cc » ('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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 size_t max_data_payload_length) { 403 size_t max_data_payload_length) {
404 RTC_DCHECK_RUN_ON(&encoder_queue_); 404 RTC_DCHECK_RUN_ON(&encoder_queue_);
405 RTC_DCHECK(sink_); 405 RTC_DCHECK(sink_);
406 LOG(LS_INFO) << "ConfigureEncoder requested."; 406 LOG(LS_INFO) << "ConfigureEncoder requested.";
407 407
408 max_data_payload_length_ = max_data_payload_length; 408 max_data_payload_length_ = max_data_payload_length;
409 encoder_config_ = std::move(config); 409 encoder_config_ = std::move(config);
410 pending_encoder_reconfiguration_ = true; 410 pending_encoder_reconfiguration_ = true;
411 411
412 // Reconfigure the encoder now if the encoder has an internal source or 412 // Reconfigure the encoder now if the encoder has an internal source or
413 // if this is the first time the encoder is configured. 413 // if the frame resolution is known. Otherwise, the reconfiguration is
414 // Otherwise, the reconfiguration is deferred until the next frame to minimize 414 // deferred until the next frame to minimize the number of reconfigurations.
415 // the number of reconfigurations. The codec configuration depends on incoming 415 // The codec configuration depends on incoming video frame size.
416 // video frame size. 416 if (last_frame_info_) {
417 if (!last_frame_info_ || settings_.internal_source) { 417 ReconfigureEncoder();
418 if (!last_frame_info_) { 418 } else if (settings_.internal_source) {
419 last_frame_info_ = rtc::Optional<VideoFrameInfo>( 419 last_frame_info_ = rtc::Optional<VideoFrameInfo>(
420 VideoFrameInfo(176, 144, kVideoRotation_0, false)); 420 VideoFrameInfo(1, 1, kVideoRotation_0, true));
421 }
422 ReconfigureEncoder(); 421 ReconfigureEncoder();
423 } 422 }
424 } 423 }
425 424
426 void ViEEncoder::ReconfigureEncoder() { 425 void ViEEncoder::ReconfigureEncoder() {
427 RTC_DCHECK_RUN_ON(&encoder_queue_); 426 RTC_DCHECK_RUN_ON(&encoder_queue_);
428 RTC_DCHECK(pending_encoder_reconfiguration_); 427 RTC_DCHECK(pending_encoder_reconfiguration_);
429 std::vector<VideoStream> streams = 428 std::vector<VideoStream> streams =
430 encoder_config_.video_stream_factory->CreateEncoderStreams( 429 encoder_config_.video_stream_factory->CreateEncoderStreams(
431 last_frame_info_->width, last_frame_info_->height, encoder_config_); 430 last_frame_info_->width, last_frame_info_->height, encoder_config_);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 534 }
536 encoder_paused_and_dropped_frame_ = false; 535 encoder_paused_and_dropped_frame_ = false;
537 } 536 }
538 537
539 void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame, 538 void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame,
540 int64_t time_when_posted_in_ms) { 539 int64_t time_when_posted_in_ms) {
541 RTC_DCHECK_RUN_ON(&encoder_queue_); 540 RTC_DCHECK_RUN_ON(&encoder_queue_);
542 if (pre_encode_callback_) 541 if (pre_encode_callback_)
543 pre_encode_callback_->OnFrame(video_frame); 542 pre_encode_callback_->OnFrame(video_frame);
544 543
545 if (video_frame.width() != last_frame_info_->width || 544 if (!last_frame_info_ || video_frame.width() != last_frame_info_->width ||
546 video_frame.height() != last_frame_info_->height || 545 video_frame.height() != last_frame_info_->height ||
547 video_frame.rotation() != last_frame_info_->rotation || 546 video_frame.rotation() != last_frame_info_->rotation ||
548 video_frame.is_texture() != last_frame_info_->is_texture) { 547 video_frame.is_texture() != last_frame_info_->is_texture) {
549 pending_encoder_reconfiguration_ = true; 548 pending_encoder_reconfiguration_ = true;
550 last_frame_info_ = rtc::Optional<VideoFrameInfo>( 549 last_frame_info_ = rtc::Optional<VideoFrameInfo>(
551 VideoFrameInfo(video_frame.width(), video_frame.height(), 550 VideoFrameInfo(video_frame.width(), video_frame.height(),
552 video_frame.rotation(), video_frame.is_texture())); 551 video_frame.rotation(), video_frame.is_texture()));
553 LOG(LS_INFO) << "Video frame parameters changed: dimensions=" 552 LOG(LS_INFO) << "Video frame parameters changed: dimensions="
554 << last_frame_info_->width << "x" << last_frame_info_->height 553 << last_frame_info_->width << "x" << last_frame_info_->height
555 << ", rotation=" << last_frame_info_->rotation 554 << ", rotation=" << last_frame_info_->rotation
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 load_observer_->OnLoadUpdate(LoadObserver::kOveruse); 704 load_observer_->OnLoadUpdate(LoadObserver::kOveruse);
706 } 705 }
707 706
708 void ViEEncoder::NormalUsage() { 707 void ViEEncoder::NormalUsage() {
709 RTC_DCHECK_RUN_ON(&encoder_queue_); 708 RTC_DCHECK_RUN_ON(&encoder_queue_);
710 if (load_observer_) 709 if (load_observer_)
711 load_observer_->OnLoadUpdate(LoadObserver::kUnderuse); 710 load_observer_->OnLoadUpdate(LoadObserver::kUnderuse);
712 } 711 }
713 712
714 } // namespace webrtc 713 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder.h ('k') | webrtc/video/vie_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698