Index: webrtc/media/engine/webrtcvideoengine2.cc |
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc |
index 0dd8938dc3451758fb0441cb4df457baa6832abe..a08ab9811b2e5a5c3836e53a09e562466734c516 100644 |
--- a/webrtc/media/engine/webrtcvideoengine2.cc |
+++ b/webrtc/media/engine/webrtcvideoengine2.cc |
@@ -993,14 +993,14 @@ bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) { |
for (uint32_t used_ssrc : sp.ssrcs) |
send_ssrcs_.insert(used_ssrc); |
- webrtc::VideoSendStream::Config config(this); |
- config.overuse_callback = this; |
+ // |config| must be initialized before WebRtcVideoSendStream since |
+ // WebRtcVideoSendStream creates a copy and later change the configuration. |
perkj_webrtc
2016/02/15 12:28:00
remove comments.
perkj_webrtc
2016/02/16 11:18:59
Done.
|
+ webrtc::VideoSendStream::Config config(this); |
WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( |
- call_, sp, config, external_encoder_factory_, options_, |
- bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, |
- send_params_); |
- |
+ call_, sp, config,external_encoder_factory_, options_, |
+ signal_cpu_adaptation_, bitrate_config_.max_bitrate_bps, send_codec_, |
+ send_rtp_extensions_, send_params_); |
uint32_t ssrc = sp.first_ssrc(); |
RTC_DCHECK(ssrc != 0); |
send_streams_[ssrc] = stream; |
@@ -1398,26 +1398,6 @@ void WebRtcVideoChannel2::SetInterface(NetworkInterface* iface) { |
kVideoRtpBufferSize); |
} |
-void WebRtcVideoChannel2::OnLoadUpdate(Load load) { |
- // OnLoadUpdate can not take any locks that are held while creating streams |
- // etc. Doing so establishes lock-order inversions between the webrtc process |
- // thread on stream creation and locks such as stream_crit_ while calling out. |
- rtc::CritScope stream_lock(&capturer_crit_); |
- if (!signal_cpu_adaptation_) |
- return; |
- // Do not adapt resolution for screen content as this will likely result in |
- // blurry and unreadable text. |
- for (auto& kv : capturers_) { |
- if (kv.second != nullptr |
- && !kv.second->IsScreencast() |
- && kv.second->video_adapter() != nullptr) { |
- kv.second->video_adapter()->OnCpuResolutionRequest( |
- load == kOveruse ? CoordinatedVideoAdapter::DOWNGRADE |
- : CoordinatedVideoAdapter::UPGRADE); |
- } |
- } |
-} |
- |
bool WebRtcVideoChannel2::SendRtp(const uint8_t* data, |
size_t len, |
const webrtc::PacketOptions& options) { |
@@ -1482,6 +1462,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
const webrtc::VideoSendStream::Config& config, |
WebRtcVideoEncoderFactory* external_encoder_factory, |
const VideoOptions& options, |
+ bool enable_cpu_overuse_detection, |
int max_bitrate_bps, |
const rtc::Optional<VideoCodecSettings>& codec_settings, |
const std::vector<webrtc::RtpExtension>& rtp_extensions, |
@@ -1512,6 +1493,8 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
parameters_.config.rtp.rtcp_mode = send_params.rtcp.reduced_size |
? webrtc::RtcpMode::kReducedSize |
: webrtc::RtcpMode::kCompound; |
+ parameters_.config.overuse_callback = enable_cpu_overuse_detection ? |
+ this : nullptr; |
if (codec_settings) { |
SetCodecAndOptions(*codec_settings, parameters_.options); |
@@ -1635,9 +1618,6 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() { |
if (capturer_ == NULL) |
return false; |
- if (capturer_->video_adapter() != nullptr) |
- old_adapt_changes_ += capturer_->video_adapter()->adaptation_changes(); |
- |
capturer = capturer_; |
capturer_ = NULL; |
} |
@@ -1929,6 +1909,16 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::Stop() { |
sending_ = false; |
} |
+void WebRtcVideoChannel2::WebRtcVideoSendStream::OnLoadUpdate(Load load) { |
+ rtc::CritScope cs(&lock_); |
+ if (!capturer_) |
+ return; |
+ rtc::VideoSinkWants wants = sink_wants_; |
+ wants.resolution = load == kOveruse ? rtc::VideoSinkWants::Resolution::DOWN : |
+ rtc::VideoSinkWants::Resolution::UP; |
+ capturer_->AddOrUpdateSink(this, wants); |
perkj_webrtc
2016/02/15 12:28:00
This will actually currently not work since OnLoad
|
+} |
perkj_webrtc
2016/02/15 12:28:00
Also- Would it make more sense to store an absolut
nisse-webrtc
2016/02/17 08:19:46
I think so. (Or a scale factor, also with the logi
perkj_webrtc
2016/02/17 17:16:29
Moved logic from CoordinatedVideoAdapter to here.
|
+ |
VideoSenderInfo |
WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { |
VideoSenderInfo info; |
@@ -1967,10 +1957,6 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { |
info.input_frame_width = last_captured_frame_format.width; |
info.input_frame_height = last_captured_frame_format.height; |
} |
- if (capturer_->video_adapter() != nullptr) { |
- info.adapt_changes += capturer_->video_adapter()->adaptation_changes(); |
perkj_webrtc
2016/02/15 12:28:00
where do we want this type of stats to take place?
perkj_webrtc
2016/02/16 11:18:59
Now added a proxy. See comments in asyncproxy.h
|
- info.adapt_reason = capturer_->video_adapter()->adapt_reason(); |
- } |
} |
} |