| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 encoder_config_ = std::move(config); | 476 encoder_config_ = std::move(config); |
| 477 pending_encoder_reconfiguration_ = true; | 477 pending_encoder_reconfiguration_ = true; |
| 478 | 478 |
| 479 // Reconfigure the encoder now if the encoder has an internal source or | 479 // Reconfigure the encoder now if the encoder has an internal source or |
| 480 // if the frame resolution is known. Otherwise, the reconfiguration is | 480 // if the frame resolution is known. Otherwise, the reconfiguration is |
| 481 // deferred until the next frame to minimize the number of reconfigurations. | 481 // deferred until the next frame to minimize the number of reconfigurations. |
| 482 // The codec configuration depends on incoming video frame size. | 482 // The codec configuration depends on incoming video frame size. |
| 483 if (last_frame_info_) { | 483 if (last_frame_info_) { |
| 484 ReconfigureEncoder(); | 484 ReconfigureEncoder(); |
| 485 } else if (settings_.internal_source) { | 485 } else if (settings_.internal_source) { |
| 486 last_frame_info_ = rtc::Optional<VideoFrameInfo>( | 486 last_frame_info_ = |
| 487 VideoFrameInfo(176, 144, kVideoRotation_0, false)); | 487 rtc::Optional<VideoFrameInfo>(VideoFrameInfo(176, 144, false)); |
| 488 ReconfigureEncoder(); | 488 ReconfigureEncoder(); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 | 491 |
| 492 void ViEEncoder::ReconfigureEncoder() { | 492 void ViEEncoder::ReconfigureEncoder() { |
| 493 RTC_DCHECK_RUN_ON(&encoder_queue_); | 493 RTC_DCHECK_RUN_ON(&encoder_queue_); |
| 494 RTC_DCHECK(pending_encoder_reconfiguration_); | 494 RTC_DCHECK(pending_encoder_reconfiguration_); |
| 495 std::vector<VideoStream> streams = | 495 std::vector<VideoStream> streams = |
| 496 encoder_config_.video_stream_factory->CreateEncoderStreams( | 496 encoder_config_.video_stream_factory->CreateEncoderStreams( |
| 497 last_frame_info_->width, last_frame_info_->height, encoder_config_); | 497 last_frame_info_->width, last_frame_info_->height, encoder_config_); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 646 |
| 647 void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame, | 647 void ViEEncoder::EncodeVideoFrame(const VideoFrame& video_frame, |
| 648 int64_t time_when_posted_us) { | 648 int64_t time_when_posted_us) { |
| 649 RTC_DCHECK_RUN_ON(&encoder_queue_); | 649 RTC_DCHECK_RUN_ON(&encoder_queue_); |
| 650 | 650 |
| 651 if (pre_encode_callback_) | 651 if (pre_encode_callback_) |
| 652 pre_encode_callback_->OnFrame(video_frame); | 652 pre_encode_callback_->OnFrame(video_frame); |
| 653 | 653 |
| 654 if (!last_frame_info_ || video_frame.width() != last_frame_info_->width || | 654 if (!last_frame_info_ || video_frame.width() != last_frame_info_->width || |
| 655 video_frame.height() != last_frame_info_->height || | 655 video_frame.height() != last_frame_info_->height || |
| 656 video_frame.rotation() != last_frame_info_->rotation || | |
| 657 video_frame.is_texture() != last_frame_info_->is_texture) { | 656 video_frame.is_texture() != last_frame_info_->is_texture) { |
| 658 pending_encoder_reconfiguration_ = true; | 657 pending_encoder_reconfiguration_ = true; |
| 659 last_frame_info_ = rtc::Optional<VideoFrameInfo>( | 658 last_frame_info_ = rtc::Optional<VideoFrameInfo>(VideoFrameInfo( |
| 660 VideoFrameInfo(video_frame.width(), video_frame.height(), | 659 video_frame.width(), video_frame.height(), video_frame.is_texture())); |
| 661 video_frame.rotation(), video_frame.is_texture())); | |
| 662 LOG(LS_INFO) << "Video frame parameters changed: dimensions=" | 660 LOG(LS_INFO) << "Video frame parameters changed: dimensions=" |
| 663 << last_frame_info_->width << "x" << last_frame_info_->height | 661 << last_frame_info_->width << "x" << last_frame_info_->height |
| 664 << ", rotation=" << last_frame_info_->rotation | 662 << ", texture=" << last_frame_info_->is_texture << "."; |
| 665 << ", texture=" << last_frame_info_->is_texture; | |
| 666 } | 663 } |
| 667 | 664 |
| 668 if (initial_rampup_ < kMaxInitialFramedrop && | 665 if (initial_rampup_ < kMaxInitialFramedrop && |
| 669 video_frame.size() > | 666 video_frame.size() > |
| 670 MaximumFrameSizeForBitrate(encoder_start_bitrate_bps_ / 1000)) { | 667 MaximumFrameSizeForBitrate(encoder_start_bitrate_bps_ / 1000)) { |
| 671 LOG(LS_INFO) << "Dropping frame. Too large for target bitrate."; | 668 LOG(LS_INFO) << "Dropping frame. Too large for target bitrate."; |
| 672 AdaptDown(kQuality); | 669 AdaptDown(kQuality); |
| 673 ++initial_rampup_; | 670 ++initial_rampup_; |
| 674 return; | 671 return; |
| 675 } | 672 } |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 void ViEEncoder::IncrementScaleCounter(int reason, int delta) { | 983 void ViEEncoder::IncrementScaleCounter(int reason, int delta) { |
| 987 // Get the counters and validate. This may also lazily initialize the state. | 984 // Get the counters and validate. This may also lazily initialize the state. |
| 988 const std::vector<int>& counter = GetScaleCounters(); | 985 const std::vector<int>& counter = GetScaleCounters(); |
| 989 if (delta < 0) { | 986 if (delta < 0) { |
| 990 RTC_DCHECK_GE(counter[reason], delta); | 987 RTC_DCHECK_GE(counter[reason], delta); |
| 991 } | 988 } |
| 992 scale_counters_[degradation_preference_][reason] += delta; | 989 scale_counters_[degradation_preference_][reason] += delta; |
| 993 } | 990 } |
| 994 | 991 |
| 995 } // namespace webrtc | 992 } // namespace webrtc |
| OLD | NEW |