Index: webrtc/media/engine/webrtcvideoengine2.cc |
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc |
index 8b4c5df1814601757b5d74b80eccf9087c745be5..e255a2cd62f0cdaf3a3bb7ae39fc0079d076e4a1 100644 |
--- a/webrtc/media/engine/webrtcvideoengine2.cc |
+++ b/webrtc/media/engine/webrtcvideoengine2.cc |
@@ -38,9 +38,10 @@ |
#include "webrtc/video_decoder.h" |
#include "webrtc/video_encoder.h" |
+using DegradationPreference = webrtc::VideoSendStream::DegradationPreference; |
+ |
namespace cricket { |
namespace { |
- |
// If this field trial is enabled, we will enable sending FlexFEC and disable |
// sending ULPFEC whenever the former has been negotiated. Receiving FlexFEC |
// is enabled whenever FlexFEC has been negotiated. |
@@ -1626,26 +1627,35 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( |
} |
if (source_ && stream_) { |
- stream_->SetSource( |
- nullptr, webrtc::VideoSendStream::DegradationPreference::kBalanced); |
+ stream_->SetSource(nullptr, DegradationPreference::kDegradationDisabled); |
} |
// Switch to the new source. |
source_ = source; |
if (source && stream_) { |
- // Do not adapt resolution for screen content as this will likely |
- // result in blurry and unreadable text. |
- // |this| acts like a VideoSource to make sure SinkWants are handled on the |
- // correct thread. |
- stream_->SetSource( |
- this, enable_cpu_overuse_detection_ && |
- !parameters_.options.is_screencast.value_or(false) |
- ? webrtc::VideoSendStream::DegradationPreference::kBalanced |
- : webrtc::VideoSendStream::DegradationPreference:: |
- kMaintainResolution); |
+ stream_->SetSource(this, GetDegradationPreference()); |
} |
return true; |
} |
+webrtc::VideoSendStream::DegradationPreference |
+WebRtcVideoChannel2::WebRtcVideoSendStream::GetDegradationPreference() const { |
+ // Do not adapt resolution for screen content as this will likely |
+ // result in blurry and unreadable text. |
+ // |this| acts like a VideoSource to make sure SinkWants are handled on the |
+ // correct thread. |
+ DegradationPreference degradation_preference; |
+ if (!enable_cpu_overuse_detection_) { |
+ degradation_preference = DegradationPreference::kDegradationDisabled; |
+ } else { |
+ if (parameters_.options.is_screencast.value_or(false)) { |
+ degradation_preference = DegradationPreference::kMaintainResolution; |
+ } else { |
+ degradation_preference = DegradationPreference::kMaintainFramerate; |
+ } |
+ } |
+ return degradation_preference; |
+} |
+ |
const std::vector<uint32_t>& |
WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { |
return ssrcs_; |
@@ -2083,16 +2093,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { |
parameters_.encoder_config.encoder_specific_settings = NULL; |
if (source_) { |
- // Do not adapt resolution for screen content as this will likely result in |
- // blurry and unreadable text. |
- // |this| acts like a VideoSource to make sure SinkWants are handled on the |
- // correct thread. |
- stream_->SetSource( |
- this, enable_cpu_overuse_detection_ && |
- !parameters_.options.is_screencast.value_or(false) |
- ? webrtc::VideoSendStream::DegradationPreference::kBalanced |
- : webrtc::VideoSendStream::DegradationPreference:: |
- kMaintainResolution); |
+ stream_->SetSource(this, GetDegradationPreference()); |
} |
// Call stream_->Start() if necessary conditions are met. |