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_ = | 486 last_frame_info_ = rtc::Optional<VideoFrameInfo>( |
487 rtc::Optional<VideoFrameInfo>(VideoFrameInfo(176, 144, false)); | 487 VideoFrameInfo(176, 144, kVideoRotation_0, 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 || |
656 video_frame.is_texture() != last_frame_info_->is_texture) { | 657 video_frame.is_texture() != last_frame_info_->is_texture) { |
657 pending_encoder_reconfiguration_ = true; | 658 pending_encoder_reconfiguration_ = true; |
658 last_frame_info_ = rtc::Optional<VideoFrameInfo>(VideoFrameInfo( | 659 last_frame_info_ = rtc::Optional<VideoFrameInfo>( |
659 video_frame.width(), video_frame.height(), video_frame.is_texture())); | 660 VideoFrameInfo(video_frame.width(), video_frame.height(), |
| 661 video_frame.rotation(), video_frame.is_texture())); |
660 LOG(LS_INFO) << "Video frame parameters changed: dimensions=" | 662 LOG(LS_INFO) << "Video frame parameters changed: dimensions=" |
661 << last_frame_info_->width << "x" << last_frame_info_->height | 663 << last_frame_info_->width << "x" << last_frame_info_->height |
662 << ", texture=" << last_frame_info_->is_texture << "."; | 664 << ", rotation=" << last_frame_info_->rotation |
| 665 << ", texture=" << last_frame_info_->is_texture; |
663 } | 666 } |
664 | 667 |
665 if (initial_rampup_ < kMaxInitialFramedrop && | 668 if (initial_rampup_ < kMaxInitialFramedrop && |
666 video_frame.size() > | 669 video_frame.size() > |
667 MaximumFrameSizeForBitrate(encoder_start_bitrate_bps_ / 1000)) { | 670 MaximumFrameSizeForBitrate(encoder_start_bitrate_bps_ / 1000)) { |
668 LOG(LS_INFO) << "Dropping frame. Too large for target bitrate."; | 671 LOG(LS_INFO) << "Dropping frame. Too large for target bitrate."; |
669 AdaptDown(kQuality); | 672 AdaptDown(kQuality); |
670 ++initial_rampup_; | 673 ++initial_rampup_; |
671 return; | 674 return; |
672 } | 675 } |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 void ViEEncoder::IncrementScaleCounter(int reason, int delta) { | 986 void ViEEncoder::IncrementScaleCounter(int reason, int delta) { |
984 // Get the counters and validate. This may also lazily initialize the state. | 987 // Get the counters and validate. This may also lazily initialize the state. |
985 const std::vector<int>& counter = GetScaleCounters(); | 988 const std::vector<int>& counter = GetScaleCounters(); |
986 if (delta < 0) { | 989 if (delta < 0) { |
987 RTC_DCHECK_GE(counter[reason], delta); | 990 RTC_DCHECK_GE(counter[reason], delta); |
988 } | 991 } |
989 scale_counters_[degradation_preference_][reason] += delta; | 992 scale_counters_[degradation_preference_][reason] += delta; |
990 } | 993 } |
991 | 994 |
992 } // namespace webrtc | 995 } // namespace webrtc |
OLD | NEW |