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

Unified Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 1836043004: Cleanup the VideoAdapter (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed nits Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoengine2.cc
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc
index 2440fce642fc9aa37e5738365aeed729dcbd26cc..5862102cb84a83ae84456e0ec1929d4a0f77ce75 100644
--- a/webrtc/media/engine/webrtcvideoengine2.cc
+++ b/webrtc/media/engine/webrtcvideoengine2.cc
@@ -371,6 +371,9 @@ static const int kDefaultQpMax = 56;
static const int kDefaultRtcpReceiverReportSsrc = 1;
+// Down grade resolution at most 2 times for CPU reasons.
+static const int kMaxCpuDowngrades = 2;
+
std::vector<VideoCodec> DefaultVideoCodecList() {
std::vector<VideoCodec> codecs;
codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp8PlType,
@@ -1832,7 +1835,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters(
<< "RecreateWebRtcStream (send) because of SetSendParameters";
RecreateWebRtcStream();
}
- } // release |lock_|
+ } // release |lock_|
// |capturer_->AddOrUpdateSink| may not be called while holding |lock_| since
// that might cause a lock order inversion.
@@ -2023,8 +2026,14 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) {
rtc::Optional<int> max_pixel_count;
rtc::Optional<int> max_pixel_count_step_up;
if (load == kOveruse) {
- max_pixel_count = rtc::Optional<int>(
- (last_dimensions_.height * last_dimensions_.width) / 2);
+ if (cpu_restricted_counter_ >= kMaxCpuDowngrades) {
+ return;
+ }
+ // The input video frame size will have a resolution with less than or
+ // equal to |max_pixel_count| depending on how the capturer can scale the
+ // input frame size.
+ max_pixel_count = rtc::Optional<int>(
+ (last_dimensions_.height * last_dimensions_.width * 3) / 5);
// Increase |number_of_cpu_adapt_changes_| if
// sink_wants_.max_pixel_count will be changed since
// last time |capturer_->AddOrUpdateSink| was called. That is, this will
@@ -2036,6 +2045,9 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) {
}
} else {
RTC_DCHECK(load == kUnderuse);
+ // The input video frame size will have a resolution with "one step up"
+ // pixels than |max_pixel_count_step_up| where "one step up" depends on
+ // how the capturer can scale the input frame size.
max_pixel_count_step_up = rtc::Optional<int>(last_dimensions_.height *
last_dimensions_.width);
// Increase |number_of_cpu_adapt_changes_| if
@@ -2085,16 +2097,15 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() {
stats = stream_->GetStats();
}
info.adapt_changes = number_of_cpu_adapt_changes_;
- info.adapt_reason = cpu_restricted_counter_ <= 0
- ? CoordinatedVideoAdapter::ADAPTREASON_NONE
- : CoordinatedVideoAdapter::ADAPTREASON_CPU;
+ info.adapt_reason =
+ cpu_restricted_counter_ <= 0 ? ADAPTREASON_NONE : ADAPTREASON_CPU;
// Get bandwidth limitation info from stream_->GetStats().
// Input resolution (output from video_adapter) can be further scaled down or
// higher video layer(s) can be dropped due to bitrate constraints.
// Note, adapt_changes only include changes from the video_adapter.
if (stats.bw_limited_resolution)
- info.adapt_reason |= CoordinatedVideoAdapter::ADAPTREASON_BANDWIDTH;
+ info.adapt_reason |= ADAPTREASON_BANDWIDTH;
info.encoder_implementation_name = stats.encoder_implementation_name;
info.ssrc_groups = ssrc_groups_;
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698